I try to draw multi line chart (single line doesn't work as well) using react-chartjs-2 Line
component
My data structure
const data = {
labels: dataFromDb.map(item => item.period),
datasets: [
{
data: dataFromDb,
backgroundColor: '#FAA46A',
borderColor: '#FAA46A',
label: i18n.sellPrice,
parsing: { yAxisKey: 'price_so' },
},
{
data: dataFromDb,
backgroundColor: '#1DCF35',
borderColor: '#1DCF35',
label: i18n.purchasePrice,
parsing: { yAxisKey: 'price_po' },
},
],
};
Data from db is array of objects {period: string, price_so: number, price_po: number, quantity: number}
My chart
<Line
height={400}
data={data}
options={{
animation: false,
maintainAspectRatio: false,
elements: { line: { tension: 0.4 } },
scales: {
x: { grid: { display: false }, offset: true },
y: {
title: { text: i18n.amount, display: true },
grid: { display: false },
},
},
}}
/>
Problem is that none of the lines Visible. I can see that data is read as y axis have values mapped by object properties price_so
and price_po
(900 is highest value for price_po in objects array from db) and legend recognized datasets as correct colors applied but lines not draw. Am I missing something in configuration?