Line on top of Doughnut slice - CanvasJS JavaScript Charts

Line on top of Doughnut slice - 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>
<div id="chartContainer" style="height: 360px; width: 99%;">
</div>
  <canvas id="userCanvas" height="360px" width="100%"></canvas>
</div>

CSS

#chartContainer {
  position:absolute;
}
#userCanvas {
  position:absolute;
  z-index: 2;
  opacity: 1;
}

JavaScript

var chart = new CanvasJS.Chart("chartContainer",
{
	title: {
  	text: "Line on top of Doughnut slice"
  },
	data: [
	{
		type: "doughnut",
		dataPoints: [
			{ y: 71 },
			{ y: 55 },
			{ y: 50 },
			{ y: 65 },
			{ y: 95 },
			{ y: 68 },
			{ y: 28 },
			{ y: 34 },
			{ y: 14 }
		]
	}					
	]
});

chart.render();

document.getElementsByClassName("canvasjs-chart-canvas")[1].style.zIndex = "10";

var userCanvas = document.getElementById("userCanvas");
userCanvas.width = document.getElementsByClassName("canvasjs-chart-canvas")[0].width;
var myContext = userCanvas.getContext("2d");
var x1 = userCanvas.width/2, y1 = userCanvas.height;
var x2 = userCanvas.width/2, y2= userCanvas.height - 70;
drawLine(x1, x2, y1, y2);
function drawLine(x1, x2, y1, y2) {
	myContext.strokeStyle = "red";
	myContext.lineWidth = 1;
  myContext.moveTo(x1, y1);
  myContext.lineTo(x2, y2);
  myContext.stroke();
}