Adding StripLines at irregular intervals on Axis Y - CanvasJS JavaScript Charts
Adding StripLines at irregular intervals on Axis Y - CanvasJS JavaScript Charts
by canvasjs
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
JavaScript
var axisYLabels = [0,50,100,200,400]; //Please add the Axis Y labels to be displayed
var stripLines = [];
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Adding Axis Y Labels at Irregular Intervals"
},
axisY:{
labelFormatter: function(e){
return " ";
},
tickThickness: 0,
gridThickness: 0,
stripLines: stripLines,
},
data: [
{
type: "column",
dataPoints: [
{ x: 10, y: 10 },
{ x: 20, y: 50 },
{ x: 30, y: 150 },
{ x: 40, y: 95 },
{ x: 50, y: 148 },
{ x: 60, y: 150 },
{ x: 70, y: 310 },
{ x: 80, y: 150 },
{ x: 90, y: 100 }
]
}
]
});
addStripLines();
chart.render();
function addStripLines(){
for (var i = 0; i < axisYLabels.length; i++) {
stripLines.push({ value: axisYLabels[i], color: "black", label:axisYLabels[i], labelPlacement: "outside", labelBackgroundColor: "transparent", labelFontColor: "black" });
}
}