JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script src="https://canvasjs.com/assets/script/canvasjs.stock.min.js"></script>
<div id="stockChartContainer" style="height: 450px; width: 100%;"></div>
JavaScript
window.onload = function () {
var dataPoints = [];
var stockChart = new CanvasJS.StockChart("stockChartContainer", {
exportEnabled: true,
title: {
text:"StockChart with CustomBreaks"
},
charts: [{
axisX: {
scaleBreaks: {
type: "straight",
customBreaks: [{
startValue: new Date(2007, 00, 01),
endValue: new Date(2010, 00, 01)
}]
}
},
axisY: {
title: "Million of Dollars",
prefix: "$",
suffix: "M"
},
data: [{
type: "line",
xValueFormatString: "MMM YYYY",
yValueFormatString: "$#,###.##M",
dataPoints : dataPoints
}]
}],
navigator: {
slider: {
minimum: new Date(1999, 07, 01),
maximum: new Date(2014, 00, 01)
}
}
});
$.getJSON("https://canvasjs.com/data/gallery/stock-chart/grocery-sales.json", function(data) {
for(var i = 0; i < data.length; i++){
dataPoints.push({x: new Date(data[i].date), y: Number(data[i].sale)});
}
stockChart.render();
});
}