Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lightweight-charts Uncaught Error: Value is null

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

enter image description here

and repeated error of Uncaught Error: Value is null

enter image description here

jsfiddle

like image 729
Milad Avatar asked Jul 10 '26 22:07

Milad


1 Answers

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.
like image 142
Milad Avatar answered Jul 17 '26 21:07

Milad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!