Adjust datalabel to specific position (HIGHCHARTS)

2019-09-09 21:25发布

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.enter image description here

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条回答
混吃等死
2楼-- · 2019-09-09 22:08

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);
                },
查看更多
登录 后发表回答