Highchart在钻取图表上显示图例项目

时间:2014-03-31 09:28:07

标签: jquery highcharts

对于我的项目,我们使用HighChart jquery插件。在示例中,我们找到了饼图和柱形图的向下钻取图表。但是在使用钻取时:传说是错误的。这是我的代码:

$('#container').highcharts({
    chart: {
        type: 'column'
    },
    credits: {
        enabled: false
    },          
    title: {
        text: 'Drilldown wagenparkinstroom'
    },
    xAxis: {
        type: 'category'
    },
    yAxis: {
        title: {
            text: "aantal auto's"
        }
    },
    legend: {
        enabled: true
    },

    plotOptions: {
        series: {
            borderWidth: 0,
            dataLabels: {
                enabled: true,
            }
        }
    },
    series: [{
        name: 'Liters',
        colorByPoint: true,
        data: [{
            name: 'Q1',
            y: 55,
            drilldown: 'q1',
        }, {
            name: 'Q2',
            y: 17,
            drilldown: 'q2'
        }, {
            name: 'Q3',
            y: 16,
            drilldown: 'q3'
        }, {
            name: 'Q4',
            y: 10,
            drilldown: 'q4'
        }]
    }],
    drilldown: {
        series: [{
            id: 'q1',
            name: 'Q1',
            data: [
                ['Audi', 6],
                ['Volvo', 8],
                ['Volkswagen', 11],
                ['BMW', 7],
                ['Ford', 7],
                ['Renault', 6],
                ['Peugeot', 4],
                ['Mercedes-Benz', 1],
                ['Skoda', 2],
                ['Opel', 3]
            ]
        },{
            id: 'q2',
            name: 'Q2',
            data: [
                ['Audi', 3],
                ['Volvo', 1],
                ['Volkswagen', 0],
                ['BMW', 2],
                ['Ford', 3],
                ['Renault', 2],
                ['Peugeot', 1],
                ['Mercedes-Benz', 4],
                ['Skoda', 0],
                ['Opel', 1]
            ]
        },{
            id: 'q3',
            name: 'Q3',
            data: [
                ['Audi', 5],
                ['Volvo', 4],
                ['Volkswagen', 2],
                ['BMW', 1],
                ['Ford', 1],
                ['Renault', 1],
                ['Peugeot', 1],
                ['Mercedes-Benz', 0],
                ['Skoda', 1],
                ['Opel', 0]
            ]
        },{
            id: 'q4',
            name: 'Q4',
            data: [
                ['Audi', 1],
                ['Volvo', 2],
                ['Volkswagen', 0],
                ['BMW', 3],
                ['Ford', 1],
                ['Renault', 2],
                ['Peugeot', 0],
                ['Mercedes-Benz', 0],
                ['Skoda', 1],
                ['Opel', 0]
            ]
        }]
    }
});

产地:

enter image description here

如您所见:图例与条形图不匹配。这是一个解决方案,让我的传奇与酒吧相匹配?谢谢!

---编辑--- 已经尝试过了。但酒吧空无一人:

series: [{
        name: 'Q1',
        y: 55,
        drilldown: 'q1',
    }, {
        name: 'Q2',
        y: 17,
        drilldown: 'q2'
    }, {
        name: 'Q3',
        y: 16,
        drilldown: 'q3'
    }, {
        name: 'Q4',
        y: 10,
        drilldown: 'q4'
}],

1 个答案:

答案 0 :(得分:1)

在下钻时,你有一个系列,但只有彩色点。图例显示系列而非点数,因此您只有单个项目。