在Highcharts中对齐左侧和右侧的文本

时间:2016-01-15 06:24:57

标签: javascript jquery css highcharts

我想设置栏的VALUERIGHT,以及始终在bar1, bar2, bar3的{​​{1}}的SERIES(在我的情况下为LEFT)的值酒吧。就像它在图片中一样。

enter image description here

这是我的代码:link

plotOptions: {
bar: {
dataLabels: {
padding: 0,
allowOverlap: true,
enabled: true,
align: 'left',
color: '#FFFFFF',
inside: true,
crop: false,
overflow: "none",
formatter: function() {            
  return this.series.name + " " + this.y;                       
},
style: {
  width:100
}                       
.
.
.

1 个答案:

答案 0 :(得分:0)

这可以通过将轴标签对齐设置为左并启用数据标签来完成。 见jsFiddle:http://jsfiddle.net/euot9L66/1/



$(function() {
  $('#container').highcharts({
    chart: {
      type: 'bar'
    },
    xAxis: {
      categories: ['Bar 1', 'Bar 2', 'Bar 3'],
      labels: {
        align: 'left',
        x: 5
      }
    },
    plotOptions: {
      series: {
        dataLabels: {
          enabled: true
        }
      }
    },
    series: [{
      data: [52, 90, 42]
    }]
  });
});