Highcharts:酒吧里面堆积的酒吧

时间:2015-09-01 07:52:58

标签: javascript highcharts bar-chart

我想创建一个带有条形图的图表,如图所示。 Chart http://i61.tinypic.com/317axx4.jpg

我设法将列放在列中但是,我无法使其适用于栏。如何将条形物放入堆积条中?

My code - JsFiddle

var chart = new Highcharts.Chart({
    chart: {
        renderTo:'container',
    },
    title: {
        text: 'Test %'
    },
    xAxis: {
        categories: ['2014', '2013', '2012', '2011']
    },
    yAxis: {
        opposite: true,
        labels: {
            format: '{value}%',
        },
    },
    plotOptions: {
        series: {
            stacking: 'normal'
        },
        column: {
            stacking: 'percent'
        }
    },
    legend: {
        enabled: false
    },
    series: [{
        name: 'red',
        type: 'bar',
        data: [70, 70, 70, 70],
        color: 'rgba(253, 155, 155, 1)',
        pointPadding: 0.1,
        pointPlacement: -0.2,
        stack: 'bar'
    }, {
        name: 'yellow',
        type: 'bar',
        data: [5, 5, 5, 5],
        color: 'rgba(255, 255, 153, 1)',
        pointPadding: 0.1,
        pointPlacement: -0.2,
        stack: 'bar'
    }, {
        name: 'green',
        type: 'bar',
        data: [25, 25, 25, 25],
        color: 'rgba(204, 255, 153, 1)',
        pointPadding: 0.1,
        pointPlacement: -0.2,
        stack: 'bar'
    }, {
        name: 'Value',
        type: 'bar',
        data: [35, 30, 25, 20],
        color: 'rgba(126,86,134,.9)',
        pointPadding: 0.35,
        pointPlacement: -0.2,
        dataLabels: {
            enabled: true,
            format: '{y}%'
        },
    }]
});

任何帮助表示感谢。

2 个答案:

答案 0 :(得分:1)

您可以将分组设置为false,因此所有堆叠将放在彼此之上 - 彼此重叠。

示例:http://jsfiddle.net/zs6juetp/2/

plotOptions: {
    series: {
        grouping: false
        ...

API参考:plotOptions.bar.grouping

答案 1 :(得分:1)

It looks like you're making a bullet graph.

I have examples of this here:

.

plotOptions:{
        bar:{
            grouping: false,
            shadow:false,
            borderWidth:0,
            pointPadding:.25,
            groupPadding:0
        },
        scatter:{
            marker:{
                symbol:'line',
                lineWidth:3,
                radius:9,
                lineColor:'#333'
            }
        }
    }

Also uses a function to extend the marker object for the target line, on a scatter series:

Highcharts.Renderer.prototype.symbols.line = function(x, y, width, height) {
    return ['M',x ,y + width / 2,'L',x+height,y + width / 2];
};