在Highcharts堆积柱形图中显示不同数量的组 [英] Display Different Number of Groups in Highcharts Stacked Column Graph

查看:202
本文介绍了在Highcharts堆积柱形图中显示不同数量的组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to create a column highchart that is stacked and grouped, but I only want the last few x-values to have multiple groups/stacks. The first x-values only have one group/stack.

为了解释,我正在绘制历史值,然后比较乐观和保守的预测方案.

To explain, I am charting historical values and then comparing optimistic and conservative forecast scenarios.

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

Here is my jsFiddle. A better way to do this?

 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
        }]

推荐答案

基本上,高图表非常棒,您可以堆叠条形图并按点为它们提供相关数据.我为系列数组传递了以下内容,并向工具提示传递了其他属性.请参见 jsFiddle此处:

Basically highcharts is awesome and you can stack bars and give them relevant data on a point basis. I passed the following for my series array, with additional attrs to passs to the tooltip. See 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},
]

这篇关于在Highcharts堆积柱形图中显示不同数量的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆