0
votes

I Want to assign my own color for each column for drilldown graph of column based chart. So i have created zones and assigned color codes based on some pre calculation.

My code is as below :

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',
                    14 // Over max set in zone get default color
                ],
                [
                    'v8.0',
                    10
                ],
                [
                    'v6.0',
                    8
                ],
                [
                    'v7.0',
                    4
                ]
            ],
            zones: [{
                color: '#ffcc00'
            }, {
                color: '#AA7F39'
            }, {
                color: '#ff8000'
            }, {
                color: '#FFFF00'
            }]
        }, {
            name: 'Firefox',
            id: 'Firefox',
            data: [
                [
                   'v35',
                    12,

                ],
                [
                    'v34',
                    10
                ],
                [
                    'v38',
                    7
                ],
                [
                    'v33',
                    4
                ],
                [
                    'v32',
                    3
                ]
            ],
            zones: [{
                color: '#FFFF00'
            }, {
                color: '#FFFF00'
            }, {
                color: '#ff8000'
            }, {
                color: '#AA7F39'
            }]
        }]
    }
});

My Fiddle is

https://jsfiddle.net/jqefrrj0/

Now when I click on Microsoft, the drilldown graph has all yellow color columns, whereas I want it to change as per the each color given in zones.

Like first yellow, then mustard, orange, yellow.

How can I achieve the above colors for each column of drilldown series.

1

1 Answers

2
votes

You forgot to set the zones.value Documentation

        zones: [{
            color: '#ffcc00',
            value:5
        }, {
            color: '#AA7F39',
            value:12
        }, {
            color: '#ff8000'
        }, {
            color: '#FFFF00'
        }]

Updadted Fiddle