I'm trying to use a visualization as a selector on a D3 costum chart. I'm following the SDK documentation Here, and I can't make my example work.
Basicly I star by declaring "me" var and enable the "use as filter" option.
var me = this;
this.addUseAsFilterMenuItem();
Then, when appending de 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 getting 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 on my bars:
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 it does not work. I manage to console d.selection on the bar click event, i it's undifined.
Can some one please give me a hand on this?
Thank you.
MicroStrategy Desktop on Windows and MacOpen a dossier. Click the + button under Custom in the Gallery of visualizations on the right and choose Import Visualization. On the Import Visualization dialog, navigate to the plug-in . zip file for the custom visualization you want to import and click Open.
You can select attribute elements or metric values to filter data that appears in a visualization by creating a visualization filter. Create a visualization filter by dragging attributes and metrics from the Datasets panel. Open the dossier you want to modify.
The MicroStrategy Visualization SDK provides APIs, sample code, documentation, and the Custom Visualization Tool. This tool is designed to help users quickly and easily create the file and folder structure of a visualization plug-in that is integrated with MicroStrategy.
Selectors provide dossier-style documents with interactivity, allowing each user to change how they see the data. A selector can change panels, the focus of a grid or graph report, or dynamic text fields (a text field that is a reference to an object on a report) in a panel stack, as described below.
I was able to find out what was wrong with my code, after spending many many hours on this. The selection method must be called like this:
.on("click", function(d, i) {
me.applySelection(data[i].attributeSelector);
return true;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With