3

I am using Highcharts v5 in styled mode.

In normal mode you can specify the color of the chart with the 'color'-attribute as so:

series: [{
    data: [...],
    name: "mySeries",
    color: '#FF0000'
}]

In styled mode you are supposed to specify the color by colorIndex...

series: [{
    data: [...],
    name: "mySeries",
    colorIndex: 2
}]

...and, in the css, you have to specify the color for the colorIndex.

.highcharts-color-2 {
    fill: #8E44AD;
    stroke: #8E44AD;
}

Is there any way in styled mode i can set the color by its hex-code directly, without having to implement a css-class first?

LocalHorst
  • 1,048
  • 2
  • 11
  • 24
  • 3
    Seems pretty cut-and dried: `In this mode, presentational styles from the API are no longer supported` | http://www.highcharts.com/docs/chart-design-and-style/style-by-css – jlbriggs Apr 10 '17 at 19:34
  • That seems so.. but..but..but.. Imagine you get the series data WITH the corresponding color code from another source and can't predict how that code looks like... i have no choice then add a class for each imaginably color code, do i? – LocalHorst Apr 11 '17 at 06:21
  • 1
    You could, potentially, create your CSS with generic color selectors (1,2,3, a,b,c, whatever...) with a set of default colors, fetch your data, parse the color information out, and assign the actual color to the generic color placeholder. Then send the data to the chart. Possibly helpful: http://stackoverflow.com/questions/707565/how-do-you-add-css-with-javascript | http://stackoverflow.com/questions/265984/how-to-redefine-css-classes-with-javascript/266110#266110 – jlbriggs Apr 11 '17 at 12:20

0 Answers0