Using Chart.js in Wix (Velo) Cannot read properties of null (reading 'style')

37 Views Asked by At

I'm using this tutorial to draw charts using chart.js in Wix Valo

It works on some of the Wix pages

The code:

chart1 = new ChartJSAPI($w('#CustomElement1'))
chart1.customization = data_chart.customization
chart1.data = data_chart.data 

But on some pages, I got this error:

Uncaught TypeError: Cannot read properties of null (reading 'style')
    at r.value (chart.js:8:33)

enter image description here

UPDATE:

The code look like:

chart1[index] = new ChartJSAPI($item('#customElement10'));
    chart1[index].customization = insight_cart_json.customization;
    chart1[index].data = insight_cart_json.data;
    

if I add this line for example or add a login bar I get the above error, if I remove this line, it works fine, why? and how to fix this:

$item("#insightImage").hide() 

Suddenly, it sometimes works and sometimes gets an error

0

There are 0 best solutions below