最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - lightweight-charts Uncaught Error: Value is null - Stack Overflow

programmeradmin4浏览0评论

Lightweight Charts Version: 3.1.3

I am using your chart for the cryptocurrency trade application in Vue project but no matter what I get this error below is a sample code

There is no duplicated or null data.


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);

Actual behavior:

The chart is drawn with no candlestick

and repeated error of Uncaught Error: Value is null

jsfiddle

Lightweight Charts Version: 3.1.3

I am using your chart for the cryptocurrency trade application in Vue project but no matter what I get this error below is a sample code

There is no duplicated or null data.


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);

Actual behavior:

The chart is drawn with no candlestick

and repeated error of Uncaught Error: Value is null

jsfiddle

Share Improve this question edited Dec 22, 2020 at 12:24 Milad asked Dec 22, 2020 at 12:16 MiladMilad 8591 gold badge12 silver badges33 bronze badges 1
  • 2 Are you data ordered by time in asc order? – timocov Commented Dec 22, 2020 at 12:51
Add a comment  | 

2 Answers 2

Reset to default 25

If you get this error 99% chance that your data source has one of three problems

  1. part of the data is null
  2. there is duplication on data in timestamp
  3. my problem: data should be ordered by time in ASC order, not in desc.

if you're using an Object structure, aren't you forgetting the commas after adding a new element to the array?

let cdata = [

{ close: 22750.76, high: 22759.53, low: 22750.25, open: 22752.8, time: 1608635340, }, .... ]

because without the commas it seems to be a unique element in the object, which is not correct.

发布评论

评论列表(0)

  1. 暂无评论