JavaScript
var dates = [
'2017-01-01',
'2017-01-02',
'2017-01-03',
'2017-01-04',
'2017-01-05',
'2017-01-06',
];
var values = [
10,
20,
150,
200,
235,
200
];
var options = {
responsive: true,
layout: {
padding: {
top: 16,
bottom: 32,
left: 16,
right: 32
}
},
scales: {
xAxes: [{
gridLines: {
offsetGridLines: false
},
}],
yAxes:[{
type: 'linear',
position: 'left',
display: true,
id: 'test',
scaleLabel: {
display: true,
labelString: 'test'
},
ticks:{
min: 0,
suggestedMax: 240,
beginAtZero: true
}
}
]
}
};
var data = {
labels: dates,
datasets: [
{
label: "Test",
fill: false,
hidden: false,
type: 'line',
lineTension: 0,
backgroundColor: "rgba(99,140,206,0.4)",
borderColor: "rgba(99,140,206,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(99,140,206,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(99,140,206,1)",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 5,
pointStyle: 'circle',
pointHitRadius: 10,
yAxisID: 'test',
data: values
}
]
};
console.log(data, options)
var chart = new Chart($("#chart"), {
type: 'line',
data: data,
options: options
});