views:

997

answers:

1

I'm using dojo charting and for some reason the legend for my chart is showing x's instead of the colours.

Here is my code:

dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.widget.Legend");
dojo.require("dojox.layout.FloatingPane");
dojo.require("dojox.charting.themes.MiamiNice");
dojo.require("dojo.colors");
makeCharts = function(){
var chart1 = new dojox.charting.Chart2D("simplechart");

chart1.addPlot("default", {type: "StackedColumns", markers: true, tension:3, shadows: {dx: 2, dy: 2, dw: 2}});
chart1.addAxis("x",{labels: [{value: 1 , text: '18-Mar'}, {value: 2 , text: '19-Mar'}, {value: 3 , text: '20-Mar'}, {value: 4 , text: '21-Mar'}, {value: 5 , text: '22-Mar'}, {value: 6 , text: '23-Mar'}]});
chart1.addAxis("y", {vertical:true});

chart1.addSeries("Four", [196,209,77,218,48,243]);

chart1.addSeries("One", [266,158,131,228,217,262]);

chart1.addSeries("Three", [296,214,267,80,40,225]);

chart1.addSeries("Two", [207,264,115,227,193,27]);

chart1.setTheme(dojox.charting.themes.MiamiNice);
var legend = new dojox.charting.widget.Legend({chart: chart1, horizontal: true}, "legend");

chart1.render();
}

dojo.addOnLoad(makeCharts);

As I said the Chart displays perfectly but, the Legend doesn't have any colours on it.

A: 

Found out the Issue, the Legend has to be declared after the chart is rendered.

Many thanks to the people at #dojo for their pointing me at more examples that helped me notice this.

Omar Kooheji
I read this Q via RSS, went to answer that you need to swap 2 lines, and found that you already found it out. :-) In general #dojo and the dojo forum are right places to ask dojo-specific questions. SO is good for generic questions.
Eugene Lazutkin
Yeah ttrenka and I spent a few minutes looking at it before I noticed that I'd got them the wrong way round.Thanks.
Omar Kooheji