Hi,
I have added code for a bar chart drill down. The first time the chart loads, the drill down works as expected. The next time when I try to get data, the drilldown takes it as 2 clicks and displays 3rd level graph when clicking on 1st level graph.
Here is the code :
function loadChart(frm, data,duration) {
chart1 = new cfx.Chart();
chart1.setDataSource(data);
chart1.setGallery(cfx.Gallery.Bars);
$("#graph1").empty();
var divHolder = graph1;
chart1.create(divHolder);
$("#graph1").click(function(evt) {
doClick(evt, frm);
});
}
function doClick(evt, frm) {
// alert('in graph click');
if (evt.hitType == cfx.HitType.Point) {
var node = chart1.getSeries().getItem(evt.series).getText();
displayDrillDownGraph(frm, node, level);
}
}
displayDrillDownGraph(frm, node, level){
var data = datafromajaxcall();
loadDrillDownChart(frm, data,duration);
}
function loadDrillDownChart(frm, data,duration) {
chart1 = new cfx.Chart();
chart1.setDataSource(data);
chart1.setGallery(cfx.Gallery.Bars);
$("#graph1").empty();
var divHolder = graph1;
chart1.create(divHolder);
$("#graph1").click(function(evt) {
doClick(evt, frm);
});
}
The flow is : When the 1st level graph is clicked, the displaydrilldowngraph is called and data is retrieved in json format and loaddrilldownchart is called.Clicking on the 2nd level graph will call the displaydrilldowngraph but with a different set of parameters. The first time I am requesting the graph, the drilldown to 3rd level works as expected. The second time if I request the graph with the previous graph already displayed in the <div>, the click on 1st level graph displays 3rd level graph. The execution does go to display second level graph but automatically takes as a click on it and displays the 3rd level. I have tried to debug when it is taking as a click when its not even displaying the second level,but in vain.I suspect the $(#graph1).empty() is doing something, but I have no idea.
Any ideas, please help !!
Thanks
Swapna