将数据标签调整到特定位置(HIGHCHARTS)

时间:2016-01-14 05:49:13

标签: javascript css highcharts

我想为条形图的VALUE设置一个数据标签,以及始终位于条形图左侧的SERIES(在我的情况下为#34; bar1,bar2,bar3和#34;)的值。就像它在图片中一样。enter image description here

这是我的代码

http://jsfiddle.net/pb1q9wzk/

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)

只需增加align: right中的plotOptions

我希望这能解决你的问题。

 plotOptions: {
            bar: {
                dataLabels: {
                padding:0,
                allowOverlap:true,
                    enabled: true,
                    align: 'right',
                    color: '#FFFFFF',
                    inside: true,
                    crop: false,
                    overflow:"none",
                        formatter: function() {

                    return this.series.name+ " "+ this.y;

                    console.log(this.series.name);
                },