[Charts_HowTo] How to change color of the items in the Legend?

[Charts_HowTo] How to change color of the items in the Legend?

Forge Component
Published on 2015-01-19 by Nuno Rosado
9 votes
Published on 2015-01-19 by Nuno Rosado
First of all, nice work!
I'm using a stacked chart. I'm able to define the colors in the data points for the columns, green for "Respondidos" and red for "Não respondidos".
But the Legend gets it's own automatica colors not corresponding to the values in the columns.
I've searched HighCharts API Reference and the examples in "Charts_HowTo" on how to customize the Legend in an advanced way but could not find anything. (The example that you give of using a stacked charts uses automatic colors).
Can you help?

Hi Tiago

You just need to add  colors: ['#008000', '#A52A2A'], on the same order as series, on json (AdvancedFormat).
Check this example and try to change the colors: http://jsfiddle.net/ruus/aaLejbc7/
Let me know if any trouble doing this - I can help you.


Thank you for the reply.
I already had figure it out, in a different form from your solution. I wasn't fast enough to reply here.
I had to build a list of the structure "AdvancedDataSeriesFormat", with 2 elements, one for each series, with the attribute "DataSeriesJSON" like for example " color: '#008000' ".
Then pass that list to the action AdvancedFormat_Init() in the "DataSeriesFormats" parameter.

I was incorrectly trying to do the formating of the colors of the elements in the legend using the parameter "HighchartsJSON" of the action AdvancedFormat_Init().

Can't you add a colour by point functionality like we do on HighCharts?

This can help caters for more columns display....