Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_onDensityChartDomainChanged = (brushSelection) => {
const brushSelectionMin = brushSelection[0];
const brushSelectionMax = brushSelection[1];
// converts for a time-scale
const brushedDomain = brushSelection.map(this.densityChartXScale.invert);
d3Select(this.histogramChartRef.current).call(this.zoom.transform, d3ZoomIdentity
.scale(this.state.densityChartDimensions.width / (brushSelectionMax - brushSelectionMin))
.translate(-brushSelection[0], 0));
this._updateBrushedDomainAndReRenderTheHistogramPlot(brushedDomain);
};
function zoomTo(datum, animate = true) {
const size = datum.r * 2 * (1 + viewPadding);
const k = Math.min(width, height) / size;
const transform = zoomIdentity
.scale(k)
.translate(
- datum.x + width / 2 / k,
- datum.y + height / 2 / k,
);
zoomBehavior.transform(
!animate ? zoomRoot : zoomRoot.transition().duration(1000),
transform
);
}
export function resetZoom(svgGroups) {
svgGroups
.svg
.transition()
.duration(800)
.call(myZoom.transform, zoomIdentity.scale(1).translate(1, 1));
}
this.highlightedNodes.forEach(node => {
x1 = Math.min(x1, node.getXForLinks())
y1 = Math.min(y1, node.getYForLinks())
x2 = Math.max(x2, node.getXForLinks() + node.getWidthForLinks())
y2 = Math.max(y2, node.getYForLinks() + node.getHeightForLinks())
})
let dx = (x2 - x1)
let dy = (y2 - y1)
x1 -= dx * 0.3
x2 += dx * 0
y1 -= dy * 0.1
y2 += dy * 0.1
let k = w / Math.max(w, (x2 - x1))
let x = (x2 + x1) / -2
let y = (y2 + y1) / -2
let transform = zoomIdentity.scale(k).translate(x, y)
/*
TODO make transition duration depend on distance of transforms
let vx = x * k - this.transform.x * this.transform.k
let vy = y * k - this.transform.y * this.transform.k
let len = Math.sqrt(vx * vx + vy * vy)
logger.debug('len', len)
let duration = len / 200 * 1000
*/
let duration = 1000
this.svg.transition().duration(duration).call(this.zoom.transform, transform)
this.zoomToNodes = false
}
setTxLabel (type) {