Login Register

Bar Chart - different formatting(color) for each bar.

Hi,
I have a requirement for Bar chart where every bar of the chart is of a unique color. How can I achieve this? Can I create a theme for the same? Is it already available?

instead of

chart18.addSeries("Series A", [29, 21, 13, 44, 57], {stroke: {color: "red"}, fill: "lightpink", plot: "myBarPlot"});

I wrote

chart18.addSeries("Series A", [29, 0, 0, 0, 0], {stroke: {color: "red"}, fill: "lightpink", plot: "myBarPlot"});
        chart18.addSeries("Series B", [0, 21, 0, 0, 0], {stroke: {color: "green"}, fill: "lime", plot: "myBarPlot"});
        chart18.addSeries("Series C", [0, 0, 13, 0, 0], {stroke: {color: "blue"}, fill: "cyan", plot: "myBarPlot"});
        chart18.addSeries("Series D", [0, 0, 0, 44, 0], {stroke: {color: "yellow"}, fill: "lightyellow", plot: "myBarPlot"});
        chart18.addSeries("Series E", [0, 0, 0, 0, 57], {stroke: {color: "orange"}, fill: "magenta", plot: "myBarPlot"});

For obvious reasons it is not the best way to do things, any suggestions?

Regards,
Yazad Khambata
yazad3@gmail.com

What you did is ok for a

What you did is ok for a single chart. If you plan to have several charts like that, e.g., several charts on the same page, or different pages reusing the same colors, your best bet is to create a theme.

Thanks... :)

Thanks Eugene, The first thing I tried is having a look at the code in themes... but that made me feel a little dizzy :|

But if that is the cleaner way to do it... than i will surely look into it... Thank you for again for showing the way...

Regards,
Yazad Khambata
yazad3@gmail.com

Yeah, probably we should ask

Yeah, probably we should ask Tom Trenka (the creator of themes) to write a tutorial on how to create you very own theme. I can try to document it after I am done with general charting docs.