Optimized rendering of graph layout and zooming events

This commit is contained in:
Filip Barl
2017-02-01 16:27:23 +01:00
parent b25417ea2f
commit 632e3756c4
27 changed files with 506 additions and 633 deletions
@@ -0,0 +1,12 @@
import { line, curveCardinalClosed } from 'd3-shape';
import range from 'lodash/range';
const shapeSpline = line().curve(curveCardinalClosed.tension(0.65));
export function nodeShapePolygon(radius, n) {
const innerAngle = (2 * Math.PI) / n;
return shapeSpline(range(0, n).map(k => [
radius * Math.sin(k * innerAngle),
-radius * Math.cos(k * innerAngle)
]));
}