Add a stripline to the legend.
label - Sets Label for Strip Line in 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>
JavaScript
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Strip line is..."
},
axisX:{
stripLines:[
{
startValue:1935,
endValue:1945,
color:"red"
}
],
valueFormatString:"####"
},
axisX2: {
title: "",
tickLength: 2,
margin:0,
lineThickness:0,
minimum:0,
maximum:0,
valueFormatString:" ",
},
data: [
{
type: "splineArea",
color: "rgba(83, 223, 128, .6)",
dataPoints: [
{ x: 1910, y: 5 },
{ x: 1920, y: 9 },
{ x: 1930, y: 17},
{ x: 1940, y: 32},
{ x: 1950, y: 22},
{ x: 1960, y: 14},
{ x: 1970, y: 25},
{ x: 1980, y: 18},
{ x: 1990, y: 20}
]
},
{
type:'rangeArea',
axisXType: "secondary",
name: "...in the legend!",
color:"red",
toolTipContent: null,
showInLegend: true,
markerSize: 0,
dataPoints:[{x:0, y:null}]
}
]
});
chart.render();
}