如何在highcharts组合图表中控制图表的订单?

时间:2015-08-30 10:31:28

标签: highcharts

我正在使用highcharts创建一个包含饼图和气泡图的组合图表。

series: [
            {
                type: 'pie',
                name: 'Total consumption',
                data: [
                    {name: 'CE', y: 20},
                    {name: 'RR', y: 20},
                    {name: 'AC', y: 20},
                    {name: 'AE', y: 20}
                ],
                //center: [400, 200],
                align: 'center',
                //size: 200,
                showInLegend: false,
                dataLabels: {
                    enabled: false
                }
            },
            {
                type: 'bubble',
                name: 'Joe',
                data: [
                    {x: 5, y: 9, z: 14.7, name: 'DE', country: 'Germany', zIndex: 1},
                    {x: 0, y: 0, z: 1, name: 'BE', country: 'Belgium', zIndex: 1}

                ],
                zIndex: 9
            }
        ],

但是我怎么能把气泡图放在饼图上?无论我如何设置zIndex,饼图总是在更大的泡沫之上。

1 个答案:

答案 0 :(得分:0)

您需要为每个类型指定zIndex才能按预期工作

series: [
        {
            type: 'pie',
            name: 'Total consumption',
            data: [
                {name: 'CE', y: 20},
                {name: 'RR', y: 20},
                {name: 'AC', y: 20},
                {name: 'AE', y: 20}
            ],
            zIndex: 2,
            //center: [400, 200],
            align: 'center',
            //size: 200,
            showInLegend: false,
            dataLabels: {
                enabled: false
            }
        },
        {
            type: 'bubble',
            name: 'Joe',
            data: [
                {x: 5, y: 9, z: 14.7, name: 'DE', country: 'Germany', zIndex: 1},
                {x: 0, y: 0, z: 1, name: 'BE', country: 'Belgium', zIndex: 1}

            ],
            zIndex: 9
        }
    ]

Example