Code Node
const rows = items.map(i => i.json);
// Extract 'Month' and 'Revenue ($)'
const labels = rows.map(r => r["Month"]);
const values = rows.map(r => Number(r["Revenue ($)"]));
// Output for QuickChart
return [
{
json: {
chartData: {
type: $('Edit Fields').first().json.type,
data: {
labels,
datasets: [{
label: "Monthly Revenue ($)",
data: values,
fill: false,
borderWidth: 2,
tension: 0.3,
pointRadius: 2
}]
},
options: {
responsive: true,
plugins: { legend: { display: true } },
scales: {
y: { beginAtZero: false },
x: { ticks: { autoSkip: true } }
}
}
}
}
}
];