Zoom reset not working
The zoom reset button stops working as soon as data is changed dynamically and stockChart.render() is called.
by jcmalek
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.stock.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the StockChart -->
<div id="stockChartContainer" style="height: 450px; width: 100%;"></div>
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 stockChart = new CanvasJS.StockChart("stockChartContainer", {
title:{
text: "Basic StockChart"
},
rangeChanged: (event) => {
stockChart.options.charts[0].data[0].dataPoints = dataPoints;
stockChart.render();
},
exportEnabled: true,
charts: [{
zoomEnabled: true,
data: [{
type: "line",
dataPoints: dataPoints
}]
}],
navigator: {
slider: {
minimum: new Date(2018, 07, 00),
maximum: new Date(2019, 07, 00)
},
data: [{dataPoints: dataPoints}],
}
});
stockChart.render();