import * as d3 from 'd3'; import { LinkStyle } from '../../styles/LinkStyle'; import { LinkRenderer } from './LinkRenderer'; const PI6 = Math.PI / 6; class NaturalCurveRenderer extends LinkRenderer { _arrowheadSize: number; constructor (style?: LinkStyle) { super(style); this._arrowheadSize = 10; } render (context: CanvasRenderingContext2D, x: d3.ScaleLinear, y: d3.ScaleLinear): void { const arrowx: number[] = []; const arrowy: number[] = []; context.save(); context.beginPath(); this._links.forEach(link => { const path = link.path; if (path) { path.apply(context, x, y); const angle = path.angleAlong(1, x, y) + Math.PI; const arrow = path.pointAlong(1, x, y); this._arrow(arrow.x, arrow.y, angle, arrowx, arrowy); } }); this._doStroke(context); context.beginPath(); const n = arrowx.length; for (let i=0; i