Adding stacklabels to highcharts-ng

180 Views Asked by At

I'm trying to add stack labels (http://api.highcharts.com/highcharts#yAxis.stackLabels) to my chart

http://jsfiddle.net/Hjdnw/970/

According to the docs, https://github.com/pablojim/highcharts-ng all options should go into options object.

$scope.chartConfig = {
        options: {
            chart: {
                type: 'bar'
            },
            yAxis: {
              stackLabels: {
                style: {
              color: 'black'
            },
            enabled: true
          }
        },
        },

        series: [{
            data: [10, 15, 12, 8, 7]
        }],
        title: {
            text: 'Hello'
        },

        loading: false
    }

What am I doing wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

You just need to add the bar stacking method to plotOptions, in chartConfig.options:

plotOptions: {
    bar: {
        stacking: 'normal'
    }
}

When this value is null (or not specified), the stack values are disabled.

Here is a working demo: http://jsfiddle.net/scfy8w53/

1
On

The xAxis should be an object and not an array. The config should be set up like so:

xAxis: {
  categories: ['Option 1', 'Option 2 ']
}

And the update should be:

$scope.chartConfig.xAxis.categories = ['Option New 1', 'Option New 2'];

Fiddle URL