in src/visual.ts [235:279]
private init(options: VisualConstructorOptions): void {
const root: d3.Selection<any> = d3.select(options.element);
this.colorPalette = options.host.colorPalette;
this.colorHelper = new ColorHelper(this.colorPalette);
this.tooltipServiceWrapper = createTooltipServiceWrapper(
options.host.tooltipService,
options.element,
undefined,
ForceGraph.getEvent
);
this.forceLayout = d3.layout.force<ForceGraphLink, ForceGraphNode>();
this.forceLayout.drag()
.on("dragstart", ((d: ForceGraphNode) => {
this.forceLayout.stop();
d.isDrag = true;
this.fadeNode(d);
}))
.on("dragend", ((d: ForceGraphNode) => {
this.forceLayout.tick();
this.forceLayout.resume();
d.isDrag = false;
this.fadeNode(d);
}))
.on("drag", (d: ForceGraphNode) => {
d.px += (d3.event as any).dx;
d.py += (d3.event as any).dy;
d.x += (d3.event as any).dx;
d.y += (d3.event as any).dy;
this.fadeNode(d);
this.forceLayout.tick();
});
const svg: d3.Selection<any> = root
.append("svg")
.attr({
width: "100%",
height: "100%"
})
.classed(ForceGraph.VisualClassName, true);
this.container = svg.append("g").classed("chartContainer", true);
}