Forum Discussion
Javascript SDK - Catch multiple data selected events across multiple charts
How you define the DataSelected Events here?
If you would like to get the history data, then you may need to create an array to hold the data selected previously.
I believe the DataSelected Event captures every click, but in your code it only returns the last Event information.
You may consider add a log function similar to the Power BI Embed sample, which would log every steps with user interaction.
Code example:
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Get a reference to the embedded report.
report = powerbi.get(embedContainer);
// Report.off removes a given event listener if it exists.
report.off("dataSelected");
// Report.on will add an event listener.
report.on("dataSelected", function(event) {
var data = event.detail;
Log.log(data);
});
// Select Run and select an element of a visualization.
// For example, a bar in a bar chart. You should see an entry in the Log window.
Log.logText("Select data to see events in Log window.");Regards,
Michael
- momo8 years agoRegular Visitor
Thank you Michael for your answer!
I catch all the DataSelected events using code similar to the Power BI sample. I can store the full events history but this doesn't help me as I don't know if it was a simple click or a ctrl-click which throw the event. With a simple click, only the last data point is selected. But with a ctrl-click, multiple data points are selected (with AND logic between data points on different charts. This is visible graphically on the embedded report).
I compared the JSON returned in events and could see no differences between a click event and a ctrl-click event (on multiple charts).
Best regards,
François