0

I have a Highcharts line graph that has dataLabels configured in the plotOptions. This is all working well and I have a nice label displayed over each point.

plotOptions: {
    line: {
        dataLabels: {
            enabled: true,
            formatter: function() {
            return '$' + Highcharts.numberFormat(Math.round(this.y),0,0,",");
            }
        }
    }
}

However, is there a way to set an interval that determines how often the dataLabels appear over the points? I want to show every point in my graph, but due to space constraints, only show the dataLabel every 2 or 3 points.

Edit:

Difficulty level: My graph has multiple y-axes, uses datetime for the x-axis, and has irregular data. http://jsfiddle.net/SQkMW/68/

4

1 回答 1

3

是的,如果点 x mod 2 为 0,则您可以只返回一个空白字符串,以便每隔 2 次显示一次,例如(http://jsfiddle.net/HzYtV/):

formatter: function() {
    if(this.point.x % 2 == 0) return '';
    return this.y +'mm';
}

对于日期时间轴,您必须创建一个变量并手动增加它http://jsfiddle.net/SQkMW/69/

于 2013-02-08T19:56:07.210 回答