Click anywhere in a chart to launch a Event

Hi

Tryed to add a event to a chart to launch a action.
I just found the “onItemClick” method and wanna known if there is a possibility to click ANYWHERE in the chart (instead exactly on the datapoint) to launch a action or function ?

Used code for the “onItemClick” method:

chart_1.attachEvent(“onItemClick”, function(id){
show_long_statistics_for_lpar(system_name, “AME FAKTOR”, “ame”, “1”);
})

Many thanks !
Regards,
Franky

Hi,

you may set event listener to div where chart is drawn. Try to use dhtmlx.event helper:

dhtmlx.event(document.getElementById(“chartDiv”),“click”,function(){
// your code here
});

Hello Alexandra

Thanks for your answer.
I didn’t use

for my charts, I draw them directly in the cell.
Could be that the misstake I make ?

var chart_1 = chart_layout_4.cells(“a”).attachChart(line_low_chart_1_cfg);

I’m really not a crack with HTML :frowning:

Hello,

You may use the private property on a chart ("_obj") to get the container where the chart is created:

var chart_1 = chart_layout_4.cells(“a”).attachChart(line_low_chart_1_cfg);

dhtmlx.event(chart_1._obj,“click”,function(){
// your code here
});

Alexandra

Thats really great !!! :smiley:
Works exactlty the way I wanted :stuck_out_tongue:

Best whishes
Franky