Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
When I add the following Highcharts snippet, the bars are styled the way I want. But ultimately I want each section to have its own color scheme. (light purple, dark purple, light blue, dark blue etc.):
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.label}'
tooltip: {
valueSuffix: ' km'
pointPadding: 0,
groupPadding: 0.1,
borderWidth: 0,
colorByPoint: false // Switch this to true in the jsFiddle
If you switch colorByPoint
to true, the colors alternate and progress the way I want, but suddenly both bars in each group are colored the same color.
How do I use the colorByPoint
while maintaining that each POINT remains a different color (you'd think it would do this by default).
jsFiddle
–
–
–
As was mentioned in the comment, colorByPoint works per series, so it won't work with the global color arrays. However, you can define colors array per series just as colorByPoint works. Then you can split the initial array and assign them to series.
var colors = ['#CDAED1', '#82368C', '#94B8D2', '#2a71a5', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', 'orange'];
var splitColors = [
colors.forEach((color, i) => {
splitColors[i % 2].push(color)
In chart config:
series: [{
colors: splitColors[0]
colors: splitColors[1]
example: http://jsfiddle.net/u59176h4/33/
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.