Highcharts - Column Chart Drilldown, how to change the drilldown bar color based on some value

[亡魂溺海] 提交于 2019-12-24 22:25:00

问题


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.


回答1:


You can use zones like that :

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

Here a Fiddle



来源:https://stackoverflow.com/questions/48660900/highcharts-column-chart-drilldown-how-to-change-the-drilldown-bar-color-based

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