I am trying to use visualization as a selector on a D3 costum graph. I follow the SDK documentation. And I can't get my example to work.
Basically, I start declaring "me" var and turn on the "use as filter" option.
var me = this;
this.addUseAsFilterMenuItem();
Then, adding the svg element, I add the clear and end selecion methods:
var g = d3.select(this.domNode).append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.on("click", function(d) {
if (event.target.classList.contains('bar')) {
me.clearSelections();
me.endSelections();
return true;
} else {
return true;
}
});
When retrieving data, I use the hasSelection attribute:
var data = this.dataInterface.getRawData(mstrmojo.models.template.DataInterface.ENUM_RAW_DATA_FORMAT.TREE, {
hasSelection: true
}).children;
And when adding the "applyselection" method to my lines:
g.selectAll(".bar")
.data(data)
.enter()
.append("rect")
.attr("class", "bar")
.attr("x", function(d) {
return x(d.name);
})
.attr("y", function(d) {
return y(d.value);
})
.attr("height", function(d) {
return height - y(d.value);
})
.attr("width", x.rangeBand())
.style("fill", function(d) {
})
.on("click", function(d) {
me.applySelection(d.selection);
});
But that will not work. I manage the d.selection console on the click event of strokes, I do not decrypt it.
Can someone please give me a hand on this?
Thanks.