Is there any way to get the color of a series that was automatically assigned when the series was created? We need to create "mini-graphs" that match the color of larger graphs on a different chart. I know we could explicitly assign the colors to the larger graphs that need to be matched. However, Highcharts does a pretty good job of allocating colors, and I'd rather not add the complexity of assigning and tracking colors if there's a way to get the color of series that had its color automatically assigned. Any help appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you're ok with waiting until after the chart is rendered, then you can get the series color dynamically through a native method call like the following:
If you need the series color before the chart is rendered though, then I don't know if there is a way to get it through the Highcharts API. It may be easiest to just look at the array of colors that Highcharts provides in the JS, and move those into a variable in your application (I believe Highcharts simply cycles through the array of colors each time you create a new series). E.g. look for a line like the following in either the "highcharts.js" file or the theme "JS" file (if you're using themes):
We don't need the color-matched mini-charts until after the big charts have been rendered. The native JavaScript method works like a charm! Thanks so much.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any way to get the color of a series that was automatically assigned when the series was created? We need to create "mini-graphs" that match the color of larger graphs on a different chart. I know we could explicitly assign the colors to the larger graphs that need to be matched. However, Highcharts does a pretty good job of allocating colors, and I'd rather not add the complexity of assigning and tracking colors if there's a way to get the color of series that had its color automatically assigned. Any help appreciated.
If you're ok with waiting until after the chart is rendered, then you can get the series color dynamically through a native method call like the following:
If you need the series color before the chart is rendered though, then I don't know if there is a way to get it through the Highcharts API. It may be easiest to just look at the array of colors that Highcharts provides in the JS, and move those into a variable in your application (I believe Highcharts simply cycles through the array of colors each time you create a new series). E.g. look for a line like the following in either the "highcharts.js" file or the theme "JS" file (if you're using themes):
Hope that helps!
We don't need the color-matched mini-charts until after the big charts have been rendered. The native JavaScript method works like a charm! Thanks so much.