How to change the Highchart color dynamically

耗尽温柔 提交于 2019-12-13 22:19:31

问题


I have a problem with my highchart my series is populated dynamically by looping my model. What if I also need to change the color of my highchart base on the value of my series.
Here is my code

series: [{
           name: 'Flag',
           showInLegend: false,
           pointWidth:24,
           pointPadding:0,
           groupPadding:0,
           data: (function()
           {
              var data = [];

               @{ 
                    var itemSumaryListData  = Model;
                    int subordinateCount = itemSumaryListData.subordinateCount;                                    
                    if(itemSumaryListData.employeeteamlevelsummarylist.Count > 0){
                        foreach (var employee in itemSumaryListData.employeeteamlevelsummarylist) {
                            <text>data.push(@employee.TotalFlag );</text>
                            }
                     }
                 }

                 return data;  
           })()
        }]

回答1:


You can set color parameter:

http://jsfiddle.net/x8JVj/

series: [{
            name: 'Tokyo',
            color:'yellow',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
        }]



回答2:


You could try something similar to this JSFiddle and set the MaxValue from your chart data.

Then use this in series.zones:

[{value: ($.MaxValue )*0.5, color: '#00ffff'},...]


来源:https://stackoverflow.com/questions/14767540/how-to-change-the-highchart-color-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!