How to send values in the x-axis and y-axis in data?
Hi all,
How to send values in the x-axis and y-axis in data? like this
{
data: [
{x: '200', y: 30},
{x: '210', y: 40},
{x: '220', y: 50},
{x: '230', y: 60},
{x: '240', y: 70}
],
color: (opacity = 1) => rgba(255, 0, 0, ${opacity}), // optional
strokeWidth: 2, // optional
},
Hi @Ranjit8298, if you follow the docs example, you have set the data prop for the x-axis and y-axis data as shown in the below example
data={{
labels: [], /*x-axis values array*/
datasets: [
{
data:[] ,/*y-axis values array*/
strokeWidth: 2, // optional
},
],
}}
Hi @Ranjit8298
This is how you would send in the values into the x-axis and y-axis.
const chartData = { labels: ['200', '210', '220', '230', '240'], /x-axis values array/ datasets: [ { data: [30, 40, 50, 60, 70], /y-axis values array/ strokeWidth: 2, // optional }, ], };
OR
const chartData = { labels: data.map((item) => item.x), datasets: [ { data: data.map((item) => item.y), strokeWidth: 2, }, ], };
Thanks @namzo198 and @bilal1031 You are right. I can use it like this but how can I use it in multi-line charts or when we have multiple x-axis?