创建过滤要显示的数据的 Highcharts 数据标签格式化程序

Create Highcharts data label formatter that filters the data to display

我在我的 AngularJS 应用程序中使用 highcharts-ng,想知道是否可以使用 dataLabels formatter function?

过滤数据

我想显示 {point.name}{point.value} 只有当 {point.value}.

我尝试了下面的函数(和一些变体),但这似乎不起作用:

dataLabels: {
    enabled: true,
    formatter: function () {
        if ('{point.value}') {
            return '{point.name} {point.value}'
        }
    }
}

解决方法很简单。

我修改了我的代码如下:

dataLabels: { 
    formatter: function () {
        if (this.point.value) {
            return [this.point.name, this.point.value];
        }
    }
}

我的问题在 Highcharts 论坛上得到了回答:

http://forum.highcharts.com/post128864.html#p128864