将HighCharts数据标签拉到右侧

时间:2014-10-06 08:32:44

标签: highcharts

目前,我的Highcharts数据标签与条形图对齐:

The current chart

我希望数据标签与右边框对齐:

The desired chart

任何想法?

Uadate

感谢Pawel:

...
xAxis: [{
    categories: data[dimension].keys,
    gridLineWidth: 0,
    lineWidth: 0,
    minorGridLineWidth: 0,
    lineColor: 'transparent',
    minorTickLength: 0,
    tickLength: 0
}, {
    opposite: true,
    linkedTo: 0,
    categories: data[dimension].value,
    gridLineWidth: 0,
    lineWidth: 0,
    minorGridLineWidth: 0,
    lineColor: 'transparent',
    minorTickLength: 0,
    tickLength: 0
}],
...

1 个答案:

答案 0 :(得分:1)

对于为dataLabels设置固定宽度的图表:

    plotOptions: {
        bar: {
            dataLabels: {
                enabled: true,
                align: 'left',   
                inside: true,
                x: 390
            }
        }
    },

演示:http://jsfiddle.net/zf7te5ef/

如果您有响应式图表,那么为此使用单独的xAxis怎么样?像这样:

    xAxis: [{
        categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania']
    }, {
        opposite: true,
        linkedTo: 0,
        categories: [107, 31, 635, 203, 2]
    }],

演示:http://jsfiddle.net/zf7te5ef/1/

如果这还不够,请阅读this question