Hello everyone,
I’m using chart js advanced mode and I’m trying to figure out how am I going to replace the information from Labels and Datasets with the information from fetched collections.
See these examples below:
I have a chart like this
This is my label
return ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
This is my dataset
return [{
label: 'Receita',
data: [12000, 15000, 8000, 18000, 20000, 24000, 22000],
fill: true,
borderColor: '#887EF2',
backgroundColor: function(context) {
const chart = context.chart;
const {ctx, chartArea} = chart;
if (!chartArea) {
return null;
}
const gradient = ctx.createLinearGradient(0, chartArea.top, 0, chartArea.bottom);
gradient.addColorStop(0, 'rgba(136, 126, 242, 0.50)');
gradient.addColorStop(1, 'rgba(255, 255, 255, 0)');
return gradient;
},
tension: 0.5,
borderWidth: 2,
pointRadius: 0
}];
I wonder how I replace
return ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
and
data: [12000, 15000, 8000, 18000, 20000, 24000, 22000],
with the information fetched from Xano’s database.
Can someone help me on this?
Ps. I don’t know any javascript. All of these were made with chatgpt.
Thanks!