How to change the Highchart color dynamically

2019-09-15 19:23发布

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;  
           })()
        }]

2条回答
相关推荐>>
2楼-- · 2019-09-15 20:02

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]
        }]
查看更多
唯我独甜
3楼-- · 2019-09-15 20:09

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'},...]
查看更多
登录 后发表回答