JavaScript
var dataPoints = [
{ x: new Date(2018, 0, 0), y: 71 },
{ x: new Date(2018, 01, 0), y: 55 },
{ x: new Date(2018, 02, 0), y: 50 },
{ x: new Date(2018, 03, 0), y: 65 },
{ x: new Date(2018, 04, 0), y: 95 },
{ x: new Date(2018, 05, 0), y: 68 },
{ x: new Date(2018, 06, 0), y: 28 },
{ x: new Date(2018, 07, 0), y: 34 },
{ x: new Date(2018, 08, 0), y: 14 },
{ x: new Date(2018, 09, 0), y: 71 },
{ x: new Date(2018, 10, 0), y: 55 },
{ x: new Date(2018, 11, 0), y: 50 },
{ x: new Date(2019, 0, 0), y: 71 },
{ x: new Date(2019, 01, 0), y: 55 },
{ x: new Date(2019, 02, 0), y: 50 },
{ x: new Date(2019, 03, 0), y: 65 },
{ x: new Date(2019, 04, 0), y: 95 },
{ x: new Date(2019, 05, 0), y: 68 },
{ x: new Date(2019, 06, 0), y: 28 },
{ x: new Date(2019, 07, 0), y: 34 },
{ x: new Date(2019, 08, 0), y: 14 },
{ x: new Date(2019, 09, 0), y: 71 },
{ x: new Date(2019, 10, 0), y: 55 },
{ x: new Date(2019, 11, 0), y: 50 }
];
var maximum, minimum = 0;
var stockChart = new CanvasJS.StockChart("stockChartContainer", {
title: {
text:"Chart test",
fontSize: 24,
padding: 15
},
exportEnabled: false,
rangeChanged: hideUnhideZoomToolbar,
navigator: {
height: 40,
animationEnabled: true,
slider: {
maskColor: "#3f51b5",
maskOpacity: 0.2
}
},
subtitles: [{
text:""
}],
charts: [{
rangeChanged: hideUnhideZoomToolbar,
zoomEnabled: true,
zoomType: "x",
axisX: {
crosshair: {
enabled: true,
snapToDataPoint: true,
valueFormatString: "DD MMM YYYY"
},
labelFormatter: function (e) {
return CanvasJS.formatDate( e.value, "DD MMM");
},
labelAngle: -20
},
axisY: {
// title: "Price quotation",
//prefix: "$",
//suffix: "M",
prefix: "",
suffix: "",
gridThickness: 1,
gridColor: "#e6e6e6",
crosshair: {
enabled: true,
snapToDataPoint: true,
...