How can I change the colors of my highcharts piechart?

前端 未结 8 633
不知归路
不知归路 2020-12-13 17:15

I\'m using highcharts to make a piechart but I\'m having trouble loading a custom color set for my chart.

Here is my code:

     

        
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 17:51

    To answer @Loko Web Design's question https://stackoverflow.com/a/38794379/7475250

    Is there a webpage that says to what each of the "colors" corresponds? All the answers here show something like:

    colors: ['#333', '#CB2326', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#CB2326', '#6AF9C4']
    

    But what do #333, #CB2326, etc. actually change? Obviously I can just change them and see what changes, but it would nice to have this reference available somewhere.

    The color docs are available here. Although helpful they do not describe what changing a specific color actually does. Below is my best description.

    The colors prop gives Highcharts the colors you would like the chart to loop through. For example if you had the following color prop.

    colors: ['blue', 'green']
    

    Your pie slices would alternate between blue and green. Changing blue to red your colors would then alternate between red and green. Test it with the following fiddle

    Expanding the color list increases the number of colors before repeating.

    colors: ['blue', 'green', 'yellow']
    

    Would repeat the colors if more than 4 slices are in your dataset.

提交回复
热议问题