-2

Hi have the following chart configuration:

private InputData: any = {
            chart: { type: 'column' },
            title : { text : 'some title' },
            xAxis: {
                categories: ['Monday', 'Tuesday']
            },
            yAxis: {
                allowDecimals: false,
                title: { text: ''}
            },
            series: [
                {
                    name: 'Students',
                    data: [100,80],
                    color: '#3366cc'
                }
            ],
            plotOptions: {
                column: {
                    dataLabels: {
                    enabled: true,
                    formatter: function(){
                        // return Highcharts.numberFormat(this.y,0);
                        }
                    }
                }
            }
        };

It works fine. But is there anyway I can make the chart in percentage format? Do I need to use any events or is there any configuration available?

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
blackdaemon
  • 755
  • 5
  • 19
  • 44

1 Answers1

2

try something like this

Plunker demo

plotOptions: {
            column: {
                dataLabels: {
                enabled: true,
                formatter: function(){
                  var seriesData=this.series.data;
                  var total=0;
                  for(var i=0;i<seriesData.length;i++){
                    total+=seriesData[i].y
                  }
                  return (100 * this.y / total).toFixed(2) + "%";
                 }
              }
            }
        },
Deep 3015
  • 9,929
  • 5
  • 30
  • 54