Dojo Charting Woes

Man oh man.  I wish dojox.charting worked better.

I have a chart with 2 different types of plots, and several "Series" for both of them.  It's a stacked bar chart with a few marker lines also.  My page allows the user to regenerate the chart.  Unfortunately for me, the dojox.charting.widget.Legend does not update when I regenereate the chart, even if I call legend.refresh.  There is a solution on the net for this, but even the author admits, it is a bad workaround.

I found a solution.  Here's the code:


if (chart == undefined) {
chart = new dojox.charting.Chart("chart");
} else {
chart.removePlot("bars");
chart.removePlot("lines");
}
...
chart.render();
...

if (legend != undefined) {
legend.destroyRecursive(true);
}
legend = new dojox.charting.widget.Legend({
chart : chart,
horizontal : false
}, "legend");




Also I found that dojox.charting.widget.SelectableLegend does not work with my chart.  I think it is the multiple different types of plots that is messing it up.  If I un-check an item in the legend, the wrong bar/line is removed from my chart.  Whoops!

Comments

Popular Posts