intervalType - Sets the Unit of Interval on Axis X - 0 | JSFiddle Sample Code
intervalType - Sets the Unit of Interval on Axis X - 0 | JSFiddle Sample Code
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 300px; width: 100%;">
</div>
<div style="margin-top:16px;color:dimgrey;font-size:9px;font-family: Verdana, Arial, Helvetica, sans-serif;text-decoration:none;">Source: <a href="https://canvasjs.com/docs/charts/chart-options/axisx/intervaltype/" target="_blank" title="intervalType - Sets the Unit of Interval on Axis X ">https://canvasjs.com/docs/charts/chart-options/axisx/intervaltype/</a></div>
JavaScript
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Months do not align on multiple axis"
},
toolTip: {
shared: true
},
axisX:[
{
crosshair: {
enabled: true
},
title: 'Month ONE',
interval: 1,
intervalType: "month",
},
{
crosshair: {
enabled: true
},
title: ' Month TWO',
interval: 1,
intervalType: "month"
}
],
data: [
{
axisXIndex: 0,
type: "line",
dataPoints: [
{
x: new Date(2021, 0, 1),
y: 1,
},
{
x: new Date(2021, 1, 1),
y: 2
},
{
x: new Date(2021, 2, 1),
y: 3,
}
]
},
{
axisXIndex: 1,
type: "line",
dataPoints: [
{
x: new Date(2021, 3, 1),
y: 4,
},
{
x: new Date(2021, 4, 1),
y: 5
},
{
x: new Date(2021, 5, 1),
y: 6,
},
]
}
]
});
chart.render();
}