Jump to content

How to make chart values a specific color's depending on the value.

Recommended Posts

Hi everyone,

I create reports with column, bar and pie charts every 3 months, but each one will have a different range of values in it (for example one chart might have 15 values in it, and the next might only have 6 of those same values. To compare between the charts, I would like the value "Website" to be the same color in every chart it is included in, and so on with every value.

I currently do this with the following CSS code in the header: 

/* CSS for Website */
g.highcharts-legend-item.highcharts-bar-series.highcharts-color-0.highcharts-series-0>rect {
  fill: #FFA07A;
/* CSS for Family/Friend Recommendation */
g.highcharts-legend-item.highcharts-bar-series.highcharts-color-1.highcharts-series-1>rect {
  fill: #8ede8e;

...and so on for all values.

While this works to change the colors; when I have a chart that has no values called "Website", this means I have to go into this code and change the numbers of every following section to by subtracting 1 to make sure they are the color that is associated with that value. 

Does anyone know a solution where the color can be set based on the value? E.g. "Website" = #FFA07A and "Family/Friend Recommendation" = #8ede8e

I am an amateur with CSS and a complete rookie with Javascript so wouldn't know where to start...

Many thanks in advance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...