Execute the script if clicked on bars only in bar chart

Is there a way we can excute certain script only if the user clicks on the bars of a bar chart.

I have some script perfectly working fine which I put on click event of a bar chart. But this script executes when the user clicks any where inside the chart and I need that script to be executed when the user clicks on the bars only.

The thing to check is whether there is any data related to the click. So if they click a bar it has data, if they click anywhere else then there is no data.


Something like

if(e.relatedData != null)
{
//do your stuff
}


Thanks David. Where Do I find all this small script samples / documentation. I search in dundas BI site but no luck.

Another option is to use the action Selected Data Changed for your script. Keep in mind that usually hovering over data is also considered a selection, so you will have to change that setting:

Image title