<canvas id="canvas"/>
const getArrow=( startX, startY, finalX, finalY,theta=30,headlen=10,width=1,color="#000")=>{
var idName = document.getElementById("canvas");
var ctx = idName.getContext("2d");
var angle = Math.atan2(startY - finalY, startX - finalX) * 180 / Math.PI,
angle1 = (angle + theta) * Math.PI / 180,
angle2 = (angle - theta) * Math.PI / 180,
topX = headlen * Math.cos(angle1),
topY = headlen * Math.sin(angle1),
botX = headlen * Math.cos(angle2),
botY = headlen * Math.sin(angle2);
ctx.save();
var arrowX ,arrowY ;
ctx.beginPath();
arrowX = finalX + topX;
arrowY = finalY + topY;
ctx.moveTo(arrowX, arrowY);
ctx.lineTo(finalX, finalY);
arrowX = finalX + botX;
arrowY = finalY + botY;
ctx.lineTo(arrowX, arrowY);
ctx.strokeStyle = color;
ctx.lineWidth = width;
ctx.stroke();
ctx.closePath();
arrowX = startX - topX;
arrowY = startY - topY;
ctx.beginPath();
ctx.setLineDash([28, 8]);
ctx.moveTo(arrowX, arrowY);
ctx.moveTo(startX, startY);
ctx.lineTo(finalX, finalY);
ctx.stroke();
ctx.restore();
}