简体   繁体   English

将堆栈标签添加到highcharts-ng

[英]Adding stacklabels to highcharts-ng

I'm trying to add stack labels ( http://api.highcharts.com/highcharts#yAxis.stackLabels ) to my chart 我正在尝试将堆栈标签( http://api.highcharts.com/highcharts#yAxis.stackLabels )添加到我的图表中

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

According to the docs, https://github.com/pablojim/highcharts-ng all options should go into options object. 根据文档, https://github.com/pablojim/highcharts-ng所有选项都应放入options对象。

$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? 我究竟做错了什么?

You just need to add the bar stacking method to plotOptions , in chartConfig.options : 您只需要在chartConfig.options bar叠加方法添加到plotOptions中:

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

When this value is null (or not specified), the stack values are disabled. 当此值为null(或未指定)时,将禁用堆栈值。

Here is a working demo: http://jsfiddle.net/scfy8w53/ 这是一个有效的演示: http : //jsfiddle.net/scfy8w53/

The xAxis should be an object and not an array. xAxis应该是一个对象,而不是数组。 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 小提琴网址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM