Junior
Junior

Reputation: 309

Sort descendants data in categories in highcharts

I want to sort data inside categories using highcharts. I try all data types but none work to me. it's possible? My wish would be (image from Paint):

click to see my expected result

original code (from http://jsfiddle.net/BKLrA/2/):

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Performance for the last week'
        },
        xAxis: {
            type: 'category',
            categories: ['Mon', 'Tue', 'Wed']
        },
        yAxis: {
            min: 0,
            title: {
                text: '# of devices'
            }
        },
        tooltip: {
            enabled: false
        },
        series: [{
            name: 'Green',
            data: [
                {
                    x: 0,
                    name: 'Mon',
                    y: 100
                }, 
                {
                    x: 1,
                    name: 'Tue',
                    y: 400
                }, 
                {
                    x: 2,
                    name: 'Wed',
                    y: 350
                }
            ],
            color: 'green'

        }, {
            name: 'Yellow',
            data: [
                //{
                //    name: 'Mon',
                //    y: 100
                //}, 
                {
                    x: 1,
                    name: 'Tue',
                    y: 140
                }, 
                {
                    x: 2,
                    name: 'Wed',
                    y: 170
                }
            ],
            color: 'yellow'
        }]
    });
});

Upvotes: 0

Views: 449

Answers (2)

Junior
Junior

Reputation: 309

I would like to generate this data dynamically, but it seems like that is impossible, because there seems to be a natural method. The tool let me much at that point. Anyway thanks.

Upvotes: 0

Kacper Madej
Kacper Madej

Reputation: 7886

You could use stacked series with clone series linkedTo (to allow legend click hide/show) to the main series. Basically each series would have to have as many linkedTo series as stacks there will be.

Example: http://jsfiddle.net/ju0p683j/

Upvotes: 1

Related Questions