I have a graphData array and I would like to push the close price array values of this response data I got from finhub into the x key of the graphData and the timestamps into the y key of the graphData array.
so it would be like this: graphData[{x:timestamp, y:closing price}]
So essentially I want to have the x values of graphData to be the timestamp each stock and the y values of graphData to be the closing price of each stock so that I can graph it
This is the Line Graph I am using from chartjs:
return (
<div className="linegraph">
<Line
data={{
datasets: [
{
type: "line",
backgroundColor: "black",
borderColor: "#5AC53B",
borderWidth: 2,
pointBorderColor: "rgba(0, 0, 0, 0)",
pointBackgroundColor: "rgba(0, 0, 0, 0)",
pointHoverBackgroundColor: "#5AC53B",
pointHoverBorderColor: "#000000",
pointHoverBorderWidth: 4,
pointHoverRadius: 6,
data: graphData,
},
],
}}
options={{
maintainAspectRatio: false,
legend: {
display: false,
},
tooltips: {
mode: "index",
intersect: false,
},
scales: {
yAxes: [
{
gridLines: {
display: false,
},
},
],
},
}}
/>
</div>
);
}
Any kind of help will be appreciated. I am sorry if I could not word the question properly. English is not my first language and if you need any additional information to understand me properly please ask