如何动态更改Highchart颜色 [英] How to change the Highchart color dynamically

查看:121
本文介绍了如何动态更改Highchart颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的高图有问题,我的系列通过循环模型动态填充。如果我还需要更改我的系列图的价值,我的highchart base的颜色。

这是我的代码

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


推荐答案

您可以尝试类似于此 JSFiddle 的方法,并从图表数据中设置MaxValue。

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

然后在series.zones中使用它:

Then use this in series.zones:

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

这篇关于如何动态更改Highchart颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆