Highcharts 高度图表,最小值,最大值,带附加标签

Highcharts 高度图表,最小值,最大值,带附加标签,highcharts,label,max,min,Highcharts,Label,Max,Min,我有大约2000点的时间线图,数据是从csv文件加载的。 我想为最小值、最大值和最后一点添加标签 当我以这种方式做这件事时,它会花费太多的时间来生成它。 我怎样才能更快地做到这一点 var chart = new Highcharts.Chart(options); chart.series[0].data[chartMinNo].update({ marker: { radius: 2, lineColor: '#CC2929', lineWidth: 2,

我有大约2000点的时间线图,数据是从csv文件加载的。 我想为最小值、最大值和最后一点添加标签

当我以这种方式做这件事时,它会花费太多的时间来生成它。 我怎样才能更快地做到这一点

var chart = new Highcharts.Chart(options);
chart.series[0].data[chartMinNo].update({ 
  marker: {
    radius: 2,
    lineColor: '#CC2929',
    lineWidth: 2,
    fillColor: '#CC2929',
    enabled: true
  },
  dataLabels: {
    enabled: true,
    borderRadius: 3,
    borderColor: '#CC2929',
    borderWidth: 1,
    y: -23,
    formatter: function() {
      return "Min : " + chartMinValue;
      }
    }
});

它的工作速度很慢,因为您使用的是Highcharts,在Highcharts中显示2000点并不是最好的主意。我建议改为使用Highstock,将点分组以显示点组的平均值/总和/等

不过,这里是演示

和代码:

    $('#container').highcharts({
        xAxis: {
            type: 'datetime'
        },
        plotOptions: {
            series: {
                marker: {
                    enabled: false
                },
                dataLabels: {
                    enabled: true,
                    formatter: function () {
                        if (this.point.options.showLabel) {
                            return this.y;
                        }
                        return null;
                    }
                }
            }
        },
        series: [{
            name: 'AAPL',
            data: data,
            tooltip: {
                valueDecimals: 2
            }
        }]
    }, callback);
});

function callback(chart) {
    var series = chart.series[0],
        points = series.points,
        pLen = points.length,
        i = 0,
        lastIndex = pLen - 1,
        minIndex = series.processedYData.indexOf(series.dataMin),
        maxIndex = series.processedYData.indexOf(series.dataMax);

    points[minIndex].options.showLabel = true;
    points[maxIndex].options.showLabel = true;
    points[lastIndex].options.showLabel = true;
    series.isDirty = true;
    chart.redraw();
}