Hi @yisrael-wix , awesome, thank you.
I am passing a few query results (numbers) into a function to populate a chart. If the number is 0, I get NaN on the chart log and nothing renders.
So if I get a 0 back I want to assign a value of 0.1 or something to recognise a number and get the render to happen. Full code is:
export async function populateChart(
owner,
month_current,
month_minus_1,
month_minus_2,
month_minus_3,
month_minus_4,
month_minus_5,
month_minus_6,
month_minus_7,
month_minus_8,
month_minus_9,
month_minus_10,
month_minus_11,
) {
let months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
let currentMonth = new Date().getMonth();
let monthsB = months.splice((currentMonth + 1) % 12).reverse();
months = months.reverse();
months.push(monthsB);
months = months.flat();
let label = [
months[0],
months[1],
months[2],
months[3],
months[4],
months[5],
months[6],
months[7],
months[8],
months[9],
months[10],
months[11]
];
let data = [
month_current,
month_minus_1,
month_minus_2,
month_minus_3,
month_minus_4,
month_minus_5,
month_minus_6,
month_minus_7,
month_minus_8,
month_minus_9,
month_minus_10,
month_minus_11
];
let background_colour = [
"rgba(54, 162, 235, 0.2)",
"rgba(255, 206, 86, 0.2)",
"rgba(75, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(255, 159, 64, 0.2)",
"rgba(255, 99, 132, 0.2)",
"rgba(85, 162, 235, 0.2)",
"rgba(33, 206, 86, 0.2)",
"rgba(180, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(200, 159, 64, 0.2)",
"rgba(100, 99, 132, 0.2)"
];
let border_colour = [
"rgba(54, 162, 235, 1)",
"rgba(255, 206, 86, 1)",
"rgba(75, 192, 192, 1)",
"rgba(153, 102, 255, 1)",
"rgba(255, 159, 64, 1)",
"rgba(255, 99, 132, 1)",
"rgba(85, 162, 235, 1)",
"rgba(33, 206, 86, 1)",
"rgba(180, 192, 192, 1)",
"rgba(200, 102, 255, 1)",
"rgba(255, 159, 64, 1)",
"rgba(100, 99, 132, 1)"
];
console.log(items);
let chart = new ChartJSAPI($w('#specificationTimeline'));
chart.customization = chartCustomization;
chart.data = {
label,
datasets: [{ data, background_colour, border colour }]
}
$w('#specificationTimeline').show();
$w('#specificationTimeline').expand();
}