如果超过2000点,Highstock.js将显示错误的值

时间:2019-05-07 19:32:18

标签: javascript highcharts

我正在使用highstock.js,并尝试制作超过10000点的图表。 问题是当我的点值大于2000时显示不正确,但是如果点数小于2000则一切正常。

这是我所做的here

Highcharts.stockChart('container',
 {
          rangeSelector: {

                buttons: [
                    {
                        type: 'month',
                        count: 1,
                        text: '1m'
                    },
                    {
                        type: 'month',
                        count: 6,
                        text: '6m'
                    },
                    {
                        type: 'year',
                        count: 1,
                        text: '1y'
                    },
                    {
                        type: 'year',
                        count: 3,
                        text: '3y'
                    },
                    {
                        type: 'all',
                        text: 'All'
                    }
                ],
                selected: 2
            },

            scrollbar: {
                enabled: false
            },

            yAxis: {
                labels: {
                    formatter: function () {
                        return this.value + '%';
                    }
                }
            },

            plotOptions:{
                series:{
                    turboThreshold: 10000
                }
            },
            series: [{
                data: data,
                dataGrouping: {
                 forced: true,
                 units: [
                 ['day', [1]]
                 ]
                 },
                tooltip: {
                    headerFormat: '',
                    pointFormat: '<table><tr><td style="padding:0">Purchased: <b>{point.x:%d/%m/%Y}</b></td></tr><br>'+
                                 '<tr><td style="padding:0">Yield On Cost: <b>{point.y}%</b></td></tr></table>',
                    footerFormat: '',
                    shared: true,
                    useHTML: true,
                    valueDecimals: 2,
                    split: false
                }
            }]
        });

现在我有超过2000点这样的结果link 而当接近1800点时,结果为link

1 个答案:

答案 0 :(得分:0)

此行为是由默认情况下启用的Highstock数据分组引起的。您可以这样禁用它:

Highcharts.stockChart('container', {
  series: [{
    name: 'AAPL',
    dataGrouping: {
      enabled: false
    },
    data: [
      [1539264600000, 214.45],
      [1539351000000, 222.11],
      [1539610200000, 217.36],
      [1539696600000, 222.15],
      [1539783000000, 221.19],
      [1539869400000, 216.02],
      ...
    ]
  }]
});

演示:

API参考:

相关问题