在Highcharts Stacked Column Graph中显示不同数量的组

时间:2012-10-25 17:34:33

标签: graph highcharts

我正在尝试创建堆叠和分组的列高清图,但我只希望最后几个x值具有多个组/堆栈。第一个x值只有一个组/堆栈。

为了解释,我正在制定历史价值,然后比较乐观和保守的预测情景。

这是我的jsFiddle。更好的方法吗?

 series: [{
            name: 'Thermal',
            data: [5, 3, 4, 5],
            stack: 'conservative',
            color:'blue'
        }, {
            name: 'PV',
            data: [3, 4, 4, 6],
            stack: 'conservative',
            color: 'red'
        }, {
            name: 'Thermal',
            data: [0, 0, 0, 10],
            stack: 'optimistic',
            color: 'blue',
            showInLegend: false
        }, {
            name: 'PV',
            data: [0,0,0, 12],
            stack: 'optimistic',
            color: 'red',
            showInLegend: false
        }]

1 个答案:

答案 0 :(得分:0)

基本上,highcharts非常棒,您可以堆叠条形图并以点为基础为它们提供相关数据。我为我的系列数组传递了以下内容,并将其他attrs传递给工具提示。见jsFiddle here

 series:[
         {name:'Apples', color:'green', data:[{x:0, y:10, year: '2009', scenario: 'historic'}, {x:1, y:11,year: '2010',  scenario: 'historic'} ]}, 
         {name:'Oranges', color:'orange', data:[{x:0, y:2, year: '2009',  scenario:'historic'}, {x:1, y:5, year: '2010', scenario:'historic'}]},
         {name:'Apples',color:'green', data:[{x:1.75, y:12, year:'2011',scenario:'optimistic'}], showInLegend: false },
         {name:'Apples', color:'green',data:[{x:2.25, y:3,year:'2011',  scenario:'conservative'}], showInLegend: false },
         {name:'Oranges',color:'orange',  data:[{x:1.75, y:11, year:'2011',scenario:'optimistic'}], showInLegend: false},
         {name:'Oranges',color:'orange',  data:[{x:2.25, y:6, year:'2011',scenario:'conservative'}], showInLegend: false},
]