1

我正在使用 Highcharts 生成两列条形图。意味着我每天都会显示下载次数和注册次数。现在我需要进行下钻,显示每小时数据。Highcharts 文档通过指定 y 值显示了 Signle 列的示例。但是当我显示固定条时,我有两个 y 值用于同一日期。我使用的代码如下:

series: [{
 name    : 'Signups,
 color   : '#0066FF',
 data    : <?=$series_1?>, //data in JSON format from PHP
 drilldown: true                       
 }, {
 name    : 'Downloads',
 color   : '#E81531',
 data    : <?=$series_2?>, //data in JSON format from PHP
 drilldown: true

}],
4

2 回答 2

1

为您提供两个系列的深入示例,包括:http stacking: 'normal': //jsfiddle.net/6zYmJ/10/

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

    legend: {
        enabled: false
    },

    plotOptions: {
        series: {
            stacking: 'normal',
            borderWidth: 0,
            dataLabels: {
                enabled: true,
            }
        }
    },

    series: [{
        name: 'Things',
        colorByPoint: true,
        data: [{
            name: 'Animals',
            y: 5,
            drilldown: 'animals'
        }, {
            name: 'Fruits',
            y: 2,
            drilldown: 'fruits'
        }, {
            name: 'Cars',
            y: 4,
            drilldown: 'cars'
        }]
    }, {
        name: 'Things2',
        colorByPoint: true,
        data: [{
            name: 'Animals2',
            y: 5,
            drilldown: 'animals2'
        }, {
            name: 'Fruits2',
            y: 2,
            drilldown: 'fruits2'
        }, {
            name: 'Cars2',
            y: 4,
            drilldown: 'cars2'
        }]
    }],
    drilldown: {
        series: [{
            id: 'animals',
            data: [
                ['Cats', 4],
                ['Dogs', 2],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]
            ]
        }, {
            id: 'fruits',
            data: [
                ['Apples', 4],
                ['Oranges', 2]
            ]
        }, {
            id: 'cars',
            data: [
                ['Toyota', 4],
                ['Opel', 2],
                ['Volkswagen', 2]
            ]
        },{
            id: 'animals2',
            data: [
                ['Cats', 4],
                ['Dogs', 2],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]
            ]
        }, {
            id: 'fruits2',
            data: [
                ['Apples', 4],
                ['Oranges', 2]
            ]
        }, {
            id: 'cars2',
            data: [
                ['Toyota', 4],
                ['Opel', 2],
                ['Volkswagen', 2]
            ]
        }]
    }
})
于 2014-03-21T09:41:06.200 回答
1

添加到 Pawel 响应中-

只需用这个值替换 plotOptions

列:{pointPadding:0.2,borderWidth:0},

于 2016-01-21T11:08:56.570 回答