JavaScript
//This I would get from an ajax service
var labels = ["jan","feb","mar","apr","may","jun","jul","aug"];
var dataY1a = [46,47,47,47,48,50,51,51];
var dataY1b = [56,56,56,56,56,57,57,57];
var dataY2a = [8,8,8,7,5,5,5,5]
var colour = function (r, g, b, a) {
return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
}
var getLegendTemplate = function (datasets) {
var result = "<ul class=\"a-legend\">";
$.each(datasets, function () {
var dataset = this;
result += "<li><span style = \"background-color:" + dataset.strokeColor + "\"></span>";
if (dataset.label)
result += dataset.label;
result += "</li>";
});
result += "</ul >";
return result;
}
var chartData = {
labels: labels,
datasets: [
{
label: "data1a",
data: dataY1a,
yAxisID: "y-axis-1",
borderColor: colour(51, 96, 61, 0.7),
backgroundColor: colour(51, 96, 61, 0.1),
pointBorderColor : colour(51, 96, 61, 0.7),
pointBackgroundColor : colour(51, 96, 61, 0.1),
pointBorderWidth : 1
}, {
label: "data1b",
data: dataY1b,
yAxisID: "y-axis-1",
borderColor: colour(83, 78, 41, 0.7),
backgroundColor: colour(83, 78, 41, 0.1),
pointBorderColor : colour(83, 78, 41, 0.7),
pointBackgroundColor : colour(83, 78, 41, 0.1),
pointBorderWidth : 1
}, {
label: "data2a",
data: dataY2a,
yAxisID: "y-axis-2",
borderColor: colour(80, 84, 247, 0.7),
backgroundColor: colour(80, 84, 247, 0.1),
pointBorderColor : colour(80, 84, 247, 0.7),
pointBackgroundColor : colour(80, 84, 247, 0.1),
pointBorderWidth : 1
}
]
}
var chartSettings = {
data: chartData,
...