JSFiddle - React, Tailwind, and code Playground
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 chart = new CanvasJS.Chart("chartContainer",
{
backgroundColor: "#444",
title: {
text: "My Chart",
fontColor: "#fff"
},
axisX: {
stripLines: [
{
value: 20,
label: "stripline"
}
]
},
data: [
{
type: "line",
showInLegend: true,
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55 },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14 }
]
},
{
type: "line",
showInLegend: true,
dataPoints: [
{ x: 10, y: 61 },
{ x: 20, y: 45 },
{ x: 30, y: 80 },
{ x: 40, y: 35 },
{ x: 50, y: 75 },
{ x: 60, y: 64 },
{ x: 70, y: 35 },
{ x: 80, y: 68 },
{ x: 90, y: 53 }
]
}
]
});
chart.render();
var max = chart.axisX[0].get("maximum");
var min = chart.axisX[0].get("minimum");
var stripLineOptions = {
startValue: max,
endValue: min,
color: "#fff",
};
chart.legend.set("fontColor", "#fff", false);
chart.axisX[0].set("labelFontColor", "#fff", false);
chart.axisY[0].set("labelFontColor", "#fff", false);
chart.axisX[0].set("stripLines", [stripLineOptions].concat(chart.axisX[0].stripLines));