Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
momo
Regular Visitor

Javascript SDK - Catch multiple data selected events across multiple charts

I have an embedded report with multiple charts. It's possible to select multiple data points accros multiple charts using Ctrl+click. I would like to catch such multiple data selected events using the javascript SDK. When adding an event listener "dataSelected" I can just catch the latest data selected event, not the multiple data selected events. I can catch multiple data selected events in one single chart but not accros multiple charts. Is there a way to do it ?

4 REPLIES 4
dmarkham
Frequent Visitor

I'm also interested in this, but do not see a solution.. has any been found?
Thanks!

momo
Regular Visitor

On embedded report with multiple charts, it's possible, since February 2018 release, to select multiple data points accros multiple charts using Ctrl+click. It should be possible to catch such multiple data selected events using the javascript SDK by adding an event listener "dataSelected". Unfortunately, it seems it's not the case today.

v-micsh-msft
Employee
Employee

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.