当我在高股价图中设置多个系列类型时,数据显示错误



我试图制作一个具有多个系列类型、行和列的图表。这里的示例:Jsfidle

$(function () {
var seriesOptions = [],
    seriesCounter = 0,
    names = ['MSFT', 'AAPL', 'GOOG'];
/**
 * Create the chart when all data is loaded
 * @returns {undefined}
 */
function createChart() {
    $('#container').highcharts('StockChart', {
        rangeSelector: {
            selected: 4
        },
        yAxis: {
            labels: {
                formatter: function () {
                    return (this.value > 0 ? ' + ' : '') + this.value + '%';
                }
            },
            plotLines: [{
                value: 0,
                width: 2,
                color: 'silver'
            }]
        },
        plotOptions: {
            series: {
                compare: 'percent'
            }
        },
        tooltip: {
            pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
            valueDecimals: 2
        },
        series: seriesOptions
    });
}
$.each(names, function (i, name) {
    $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=' + name.toLowerCase() + '-c.json&callback=?',    function (data) {
        seriesOptions[i] = {
            name: name,
            data: data,
        };
        if(name == 'GOOG'){
            seriesOptions[i].type = 'column';
        }
        // As we're loading the data asynchronously, we don't know what order it will arrive. So
        // we keep a counter and create the chart when all the data is loaded.
        seriesCounter += 1;
        if (seriesCounter === names.length) {
            createChart();
        }
    });
});

});

当我不缩放时,我有错误的数据(比正常情况下更多),当我放大时,我得到了好的数据。

问题出在哪里?我不知道为什么系列类型可以更改数据

谢谢你的帮助!

默认情况下,Highstock使用dataGrouping,它根据单位对点进行分组。您可以通过参数禁用它。

plotOptions:{
   series:{
      dataGrouping:{
          enabled: true
      }
   }
}

最新更新