Highcharts - 柱状图钻取,如何根据某些值更改钻取柱颜色 [英] Highcharts - Column Chart Drilldown, how to change the drilldown bar color based on some value

查看:497
本文介绍了Highcharts - 柱状图钻取,如何根据某些值更改钻取柱颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用下面的js对高图中的柱形图进行深入分析

  //创建图表
Highcharts.chart('container',{
chart:{
type:'column'
},
title:{
text:'浏览器市场份额。2015年1月至2015年5月'
},
字幕:{
text:'点击列以查看版本信息来源:< a href =http:// netmarketshare。 '
},
xAxis:{
类型:'category'
},
yAxis:{
标题:{
text:'占总市场份额的百分比'b $ b}
$ b},
图例:{
启用:false
},
plotOptions:{
series:{
borderWidth:0,
dataLabels:{
enabled:true,
format:'{point.y :.1f}%'
}
}
},

tooltip:{
headerFormat:'< span style =font-size:11px> {series.name}< / span>< br>',
pointFormat:'< span style =color:{point.color}> {point.name}< / span>:< b> {point.y:.2f}%< / b个总计< br />'
},

系列:[{
name:'Brands',
colorByPoint:true,
data: [{
name:'Microsoft Internet Explorer',
y:56.33,
drilldown:'Microsoft Internet Explorer'
},{
name:'Firefox',
y:10.38,
drilldown:'Firefox'
}]
}],
钻取:{
series:[{
name:' Microsoft Internet Explorer',
id:'Microsoft Internet Explorer',
data:[
[
'v11.0',
24.13
],
[
'v8.0',
17.2
],
[
'v6.0',
1.06
],
[
'v7.0',
0.5
]
]
},{
名称:'Firefox',
id:' Firefox',
data:[
[
'v35',
2.76
],
[
'v34',
1.27
],
[
'v38',
1.02
],
[
'v33',
0.22
],
[
'v32',
0.15
]
]
}]
}
} );

是否可以根据某些不同的x轴或y来更改钻取列颜色

以下数据基于new_info,我想根据

  [{name:Microsoft Internet Explorer,data:[['v11.0',14,(new_info)6],['v8.0',10,8(new_info)] ,['v6.0',8,3(new_info)]] 

- 8红色,7-5琥珀色,4-3黄色。



当我点击钻取时,它会显示一些n列图表,以橙色等等。

解决方案

您可以使用 zones

  ... 
区域:[{
值:4,
颜色:'#ffcc00'
},{
值:7.1,
颜色: '#AA7F39'
},{
值:13,
颜色:'#ff0000'
}]
...

这里有一个小提琴


I'm trying to make drilldown for a column chart in highcharts using below js

// Create the chart
Highcharts.chart('container', {
    chart: {
        type: 'column'
    },
    title: {
        text: 'Browser market shares. January, 2015 to May, 2015'
    },
    subtitle: {
        text: 'Click the columns to view versions. Source: <a href="http://netmarketshare.com">netmarketshare.com</a>.'
    },
    xAxis: {
        type: 'category'
    },
    yAxis: {
        title: {
            text: 'Total percent market share'
        }

    },
    legend: {
        enabled: false
    },
    plotOptions: {
        series: {
            borderWidth: 0,
            dataLabels: {
                enabled: true,
                format: '{point.y:.1f}%'
            }
        }
    },

    tooltip: {
        headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
        pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
    },

    series: [{
        name: 'Brands',
        colorByPoint: true,
        data: [{
            name: 'Microsoft Internet Explorer',
            y: 56.33,
            drilldown: 'Microsoft Internet Explorer'
        }, {
            name: 'Firefox',
            y: 10.38,
            drilldown: 'Firefox'
        }]
    }],
    drilldown: {
        series: [{
            name: 'Microsoft Internet Explorer',
            id: 'Microsoft Internet Explorer',
            data: [
                [
                    'v11.0',
                    24.13
                ],
                [
                    'v8.0',
                    17.2
                ],
                [
                    'v6.0',
                    1.06
                ],
                [
                    'v7.0',
                    0.5
                ]
            ]
        }, {
            name: 'Firefox',
            id: 'Firefox',
            data: [
                [
                    'v35',
                    2.76
                ],
                [
                    'v34',
                    1.27
                ],
                [
                    'v38',
                    1.02
                ],
                [
                    'v33',
                    0.22
                ],
                [
                    'v32',
                    0.15
                ]
            ]
        }]
    }
});

Is it possible to change only the drilldown column colors based on some different not the x-axis or y-axis value.

Here in below data based on "new_info" i want to change colour according

  [{"name":Microsoft Internet Explorer, data :[['v11.0',14, (new_info) 6] , ['v8.0',10, 8(new_info)] , ['v6.0',8, 3 (new_info)]]

If value is between 10 - 8 red, 7-5 amber, 4-3 yellow.

When I click on drilldown it should show me some n column chart few columns in red few in yellow few in orange and so on.

解决方案

You can use zones like that :

...
zones: [{
            value: 4,
            color: '#ffcc00'
        }, {
            value: 7.1,
            color: '#AA7F39'
        }, {
                value:13,
            color: '#ff0000'
        }]
...

Here a Fiddle

这篇关于Highcharts - 柱状图钻取,如何根据某些值更改钻取柱颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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