Adjust datalabel to specific position (HIGHCHARTS)

不羁岁月 提交于 2019-12-12 01:36:42

问题


I want to set a datalabel for the VALUE to RIGHT of the bar, and the value of the SERIES (in my case "bar1, bar2, bar3") that are always at the LEFT of the bar. as it is in the picture.

this is my code

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:


Just increase your align: right in plotOptions.

I hope this will solve your problem.

 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);
                },


来源:https://stackoverflow.com/questions/34782508/adjust-datalabel-to-specific-position-highcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!