javascript - 如何修复 HighChart 错误 #20?

标签 javascript highcharts

我有一个带有动态数据加载的烛台图。我正在使用 addPint API 来添加新点。由于我需要在工具提示中使用一些自定义数据,因此我将点设置为对象,如下所示:

    chart.series[0].addPoint({
        x: time, 
        low: lowValue, 
        high: highValue, 
        open: openValue, 
        close: closeValue, 
        customParameter: myCustomPramameter
});

但我收到此错误:无法将对象点配置添加到长数据系列 Highcharts 错误 #20: http://www.highcharts.com/errors/20

我已将对象语法更改为数组语法,我的问题已得到解决。但我无法将任何进一步的数据嵌入到我的工具提示中使用的点。 有没有办法使用数组语法来解决此问题,并且我还可以在其中嵌入自定义数据以在我的工具提示点中使用?

这是我当前的图表选项:

chart: {
    renderTo: 'chart-container',
    marginRight: 10,
    zoomType: 'x'
},
title: {
    text: 'My Chart'
},
xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: {
        day: '%b - %H:%M:%S',
        second: '%b - %H:%M:%S'
    }
},
yAxis: {
    tickInterval: 0.25,
    opposite: false
},
navigator: {
    adaptToUpdatedData: false
},
scrollbar: {
    liveRedraw: false
},
rangeSelector: {
    buttons: [{
        count: 1,
        type: 'minute',
        text: '1M'
    }, {
        count: 5,
        type: 'minute',
        text: '5M'
    }, {
        count: 15,
        type: 'minute',
        text: '15M'
    }, {
        count: 30,
        type: 'minute',
        text: '30M'
    }, {
        count: 60,
        type: 'minute',
        text: '60M'
    }, {
        count: 2,
        type: 'hour',
        text: '2H'
    }, {
        count: 4,
        type: 'hour',
        text: '4H'
    }, {
        count: 8,
        type: 'hour',
        text: '8H'
    }, {
        count: 1,
        type: 'day',
        text: '1D'
    }, {
        count: 2,
        type: 'day',
        text: '2D'
    }, {
        count: 3,
        type: 'day',
        text: '3D'
    }, {
        count: 4,
        type: 'day',
        text: '4D'
    }, {
        count: 5,
        type: 'day',
        text: '5D'
    }, {
        count: 6,
        type: 'day',
        text: '6D'
    }, {
        count: 7,
        type: 'day',
        text: '7D'
    }, {
        type: 'all',
        text: 'All'
    }],
    inputEnabled: false,
    selected: 0
},
tooltip: {
    formatter: function (e) {
        var point = this.points[0].point;
        return '<div><b>#: </b><span>' + point.barNumber + '</span></div><br /><div><b>Open: </b><span>' + point.open + '</span></div><div><b> Close: </b><span>' + point.close + '</span></div><br /><div><b>High: </b><span>' + point.high + '</span></div><div><b> Low: </b><span>' + point.low + '</span></div><br /><div><b>Custom Param: </b><span>' + point.customParam + '</span></div>'
    }
},
legend: {
    enabled: false
},
exporting: {
    enabled: false
},
series: [
    {
        name: 'My Chart',
        type: 'candlestick',
        data: []
    },
    {
        name: 'Average',
        type: 'spline',
        data: [],
        marker: {
            lineWidth: 2,
            lineColor: Highcharts.getOptions().colors[3],
            fillColor: 'white'
        },
        color: Highcharts.getOptions().colors[3]
    }]

最佳答案

根据以下票证(后续评论),

How to embed more data to candlestick HighChart tooltip?

我发现可以通过将 turboThreshold 设置为 0 来忽略此限制。

请注意,您应该将其设置为绘图选项!不是图表选项。

plotOptions: {
    candlestick: {
        turboThreshold: 0
    }

关于javascript - 如何修复 HighChart 错误 #20?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45387787/

相关文章:

javascript - 在已经隐藏的 div 上切换隐藏?

javascript - 语义 UI 搜索栏 - 你能切断描述,让它只显示前几个词,但仍然搜索所有词吗?

javascript - HighCharts - 数据点未出现

javascript - 如何为数组的数组制作 Javascript 输出括号。 (对于 Highcharts)

javascript - 按标题查找图表 (Highcharts)

javascript - 一些数据标签未显示在堆叠列 Highchart 中

javascript - 使用 colorValue 的 Highcharts 饼图切片颜色强度

javascript - 如何在 Storybook 中显示副标题?

javascript - 如何解决无限 Javascript promise ?

javascript - 未处理的拒绝 SequelizeConnectionRefusedError : connect ECONNREFUSED 127. 0.0.1:3306