I'm trying to work out how to plot labels to the correct places using Chart.js
var json = {
"competition one": [
{
"date": "2015-05-20",
"position": 37
},
{
"date": "2015-05-21",
"position": 22
}
],
"competition two": [
{
"date": "2015-05-20",
"position": 29
},
{
"date": "2015-05-21",
"position": 19
}
]
}
How can I plot the labels to the correct places? With the dates going to the correct labels so it isn't repeated?
Specifically, I'm struggling to get "competition one"
into the label
of the dataset
array (label: "competition one"
)
I need it to resemble the following data structure that is required by Chart.js?
var data = {
labels: ["2015-05-20", "2015-05-21"],
datasets: [
{
label: "competition one",
data: [37, 22]
},
{
label: "Competition two",
data: [29, 19]
}
]
};