HighCharts Stacked专栏

时间:2016-09-19 11:37:46

标签: highcharts

我使用的是HighCharts,我有这个数组,

enter image description here

我想创建一个这样的图表:

enter image description here

据我所知,系列的格式是这样的:

series:[{
        name: 'Production',
        data: [0.074, 0.040,0.034,0.036,0.068]
    }, {
        name: 'Reprise',
        data: [0.024,0.022,0.029, 0.055, 0.052]
    }]

with categories array:

['Mario', 'Andre', 'Jean Jacques', 'Fidy', 'Judith']

如果我想将列Volumes的每个值粘贴到每个Production Stacked Bar值,如上图所示,该怎么办?

谢谢!

2 个答案:

答案 0 :(得分:0)

您可以在此处查看示例:http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/column-stacked/

series: [{
        name: 'Volume',
        data: [1, 0.16, 0.46, 0.37, 0.24]
    }, {
        name: 'Reprise',
        data: [0.024, 0.0.....]
    }, {
        name: 'Production',
        data: [....]
    }]

稍后编辑:要将音量显示为数据标签,您可以使用格式化程序功能:

column: {
                stacking: 'normal',
                dataLabels: {
                    formatter: function () {
                        return this.x;//you can have a little logic here if (thix.x == 'Production) return myVariable[y];myVariable will contains values from volume or something similar
                    }
                }
            }

答案 1 :(得分:0)

在数据数组中定义卷:

data: [{y:0.074,volume:1}, {y:0.040,volume:0.15}]

在datalabels选项中使用formatter获取自定义值:

formatter: function () {
    return this.point.volume + ' km';   
}

jsfiddle