lightweight-charts Uncaught Error: Value is null

lightweight-charts Uncaught Error: Value is null

轻量级图表版本:3.1.3

我在 Vue 项目的加密货币交易应用程序中使用您的图表 但无论我得到什么,下面的错误都是示例代码

没有重复或空数据。


import {createChart} from "lightweight-charts";
export default {
data() {
return {
                chartProperties: {
                  width: 700,
                  height: 300,
                  timeScale: {
                     timeVisible: true,
                     secondsVisible: false
                },
                layout: {
                    //backgroundColor: '#262C49', //Dark Theme
                    //textColor: '#80859E',
                    fontSize: 12,
                    fontFamily: 'irsans ,Calibri'
                }
            },
            chartData: [],
            candleSeries: null,
}
}
mounted() {

let cdata = [
{
close: 22750.76
high: 22759.53
low: 22750.25
open: 22752.8
time: 1608635340
},
....
];

this.chartElement = document.getElementById('chart');
this.chartProperties.width = this.chartElement.offsetWidth;
this.chart = createChart(this.chartElement, this.chartProperties);
this.candleSeries = this.chart.addCandlestickSeries();

this.candleSeries.setData(cdata);

实际行为:

绘制的图表没有烛台

并重复出现Uncaught Error: Value is null

jsfiddle

如果您收到此错误 99% 可能是您的数据源存在三个问题之一

  1. 部分数据为空
  2. 时间戳中的数据存在重复
  3. 我的问题: 数据应该按照ASC顺序按时间排序,而不是 描述

如果您使用的是 Object 结构,在向数组添加新元素后不会忘记逗号吗?

let cdata = [

{ 关闭:22750.76, 高:22759.53, 低:22750.25, 打开:22752.8, 时间:1608635340, }, .... ]

因为没有逗号,它似乎是对象中的唯一元素,这是不正确的。