Highcharts Level 3向下钻取

时间:2017-01-06 18:03:43

标签: javascript php jquery highcharts

我有一个Highchart列,如下所示:

  • Level-1包含年度图表
  • Level-2包含其年份的月度图
  • Level-3包含年龄和月份的动物

但是当第3级打开时,会显示一些包含最新数据的数据, 例如:2017年1月,我有7只动物。 2016年1月我有6只动物。并且它显示我在1月2016年只有7只动物。是否可以通过2个条件显示数据库中的一些数据?

请告诉我我的错误。

以下是我正在进行的深入研究的示例:

$(function () {

// Create the chart
$('#container').highcharts({
    chart: {
        type: 'column'
    },
    title: {
        text: 'Basic drilldown'
    },
    xAxis: {
        type: 'category'
    },

    legend: {
        enabled: false
    },

    plotOptions: {
        series: {
            borderWidth: 0,
            dataLabels: {
                enabled: true,
            }
        }
    },

    series: [{
        name: 'Things',
        colorByPoint: true,
        data: [{
            name: '2017',
            y: 5,
            drilldown: '2017'
        },
        {
            name: '2016',
            y: 4,
            drilldown: '2016'
        }]
    }],
    drilldown: {
        series: [{
            id: '2017',
            name: '2017',
            data: [{
                name: 'January',
                y: 7,
                drilldown: 'january'
            },{
                name: 'July',
                y: 5,
                drilldown: 'july'
            },
            ],
        },
        {
            id: '2016',
            name: '2016',
            data: [{
                name: 'January',
                y: 6,
                drilldown: 'january'
            },{
                name: 'July',
                y: 3,
                drilldown: 'july'
            },
            ],
        },
        {

            id: 'january',
            data: [['Dogs', 2],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]]
        },{
        id: 'january',
            data: [['Dogs', 3],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]]
        }]
    }
})
});

1 个答案:

答案 0 :(得分:0)

抱歉,我忘记更改每年的明细ID

drilldown: {
        series: [{
            id: '2017',
            name: '2017',
            data: [{
                name: 'January',
                y: 7,
                drilldown: '2017-january'
            },{
                name: 'July',
                y: 5,
                drilldown: '2017-july'
            },
            ],
        },
        {
            id: '2016',
            name: '2016',
            data: [{
                name: 'January',
                y: 6,
                drilldown: '2016-january'
            },{
                name: 'July',
                y: 3,
                drilldown: '2017-july'
            },
            ],
        },
        {

            id: '2017-january',
            data: [['Dogs', 2],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]]
        },{
        id: '2016-january',
            data: [['Dogs', 3],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]]
        }]
    }