我想用条件格式标记系列数据,但它对我不起作用。请帮我解决这个问题。我已经粘贴了基本数据系列的代码,我想根据阈值对其进行标记,但我无法做到这一点。如果我评论 if 条件,则标签会显示整个系列。
$(function () {
$('#container').highcharts({
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
if(this.y: >130){
format: '{y} mm'
}
}
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
最佳答案
使用formatter
option使用包含您的逻辑并返回您想要的格式的回调。请参阅文档链接以获取可在回调中使用的数据。
将 format
替换为以下 formatter
:
formatter: function() {
return this.y > 130 ? this.y + ' mm' : null;
}
这是一个JSFiddle example .
关于javascript - Highcharts 条件数据标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32429564/