const svg = d3Select(mapRef.current) svg.call(zoom) }, [width, height, a1, a2, b1, b2, minZoom, maxZoom, projection, onMoveStart, onMove, onMoveEnd, filterZoomEvent]) const x = coords[0] * zoom const y = coords[1] * zoom const svg = d3Select(mapRef.current) svg.call(zoomRef.current.transform, d3ZoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom)) setPosition({ x: width / 2 - x, y: height / 2 - y, k: zoom })
updatePanes() { this.left.style.width = this.sepLeft + 'px'; this.resizerLeft.style('left', this.sepLeft + 'px'); this.right.style.width = (document.body.getBoundingClientRect().width - this.sepRight) + 'px'; this.resizerRight.style('right', (document.body.getBoundingClientRect().width - this.sepRight - 1) + 'px'); this.updateRangesPane(); this.panesUpdatedCallback(); }
// This function will be triggered on load function transition() { d3.selectAll("path") .data(function() { var d = layers1; layers1 = layers0; return layers0 = d; }) .transition() .duration(2500) .attr("d", area); }
s.each(function(d) { // put xp and yp into d if pixel scaling is already done var x = d.xp || xa.c2p(d.x), y = d.yp || ya.c2p(d.y), p = d3.select(this); if(isNumeric(x) && isNumeric(y)) { // for multiline text this works better if(this.nodeName === 'text') p.attr('x', x).attr('y', y); else p.attr('transform', 'translate(' + x + ',' + y + ')'); } else p.remove(); });
it('has the correct name spaces', function() { var mainSVGs = d3.selectAll('.main-svg'); mainSVGs.each(function() { var node = this; assertNamespaces(node); }); });
// could use transparent gradient overlay to vary raindrop color svg.selectAll("path") .data(d3.range(2000)) .enter().append("path") .attr("class", "pathRD") .attr("fill", "url(#gradient)") .attr("d", function() { return raindrop(10 + Math.random() * 250); }) .attr("transform", function(d) { return "rotate(" + d + ")" + "translate(" + (height / 3.8 + Math.random() * height / 5.2) + ",0)" + "rotate(90)"; });
it('has as many *point* nodes as there are traces', function() { var nodes = d3.selectAll('path.point'); var Npts = 0; mock.data.forEach(function(trace) { Npts += trace.x.length; }); expect(nodes.size()).toEqual(Npts); });