1👍
✅
You can’t use multiple key values with Chart.JS because it is not meant to accept that data format however you can format incoming data to create a chart based on the two-line sample.
Here is the working demo: https://jsfiddle.net/adelriosantiago/esn2wjxv/27/
This is how data is prepared:
- Raw data in the wrong format is called
rawData
. - The function
getSingleProp
transformsdata
(the second argument) so that only the propertyprop
(the first argument) is extracted. This happens at the line:
data.map((i) => {
return { y: i[prop], x: i.time }
})
- When calling Chart.JS we simply use
getSingleProp("[the property we want]", rawData)
asdata
resulting in the chart you are looking for.
Source:stackexchange.com