export function binPerName(data, name) { const nameIds = nameId(data, name); const histogram = d3.layout.histogram() .bins(nameIds.range()) .value(d => nameIds(name(d))); return histogram(data); }
// hide paths over edges of clipped projections function hideShowPoints(d) { var p = projection.rotate(), angle = d3.geo.distance([d.lon, d.lat], [-p[0], -p[1]]), maxAngle = clipAngle * Math.PI / 180; return (angle > maxAngle) ? '0' : '1.0'; }
// bounds array [[top, left], [bottom, right]] // of the lon/lat range box function getBounds(projection, rangeBox) { return d3.geo.path().projection(projection).bounds(rangeBox); }
d3.range(0, 360 + step, step).forEach(function(deg, index) { var theta = deg * Math.PI / 180; var radius = _equation(theta); t.push(deg); r.push(radius); });
function countScatterGeoTextNodes() { return d3.selectAll('g.trace.scattergeo') .selectAll('g') .select('text') .size(); }
d3.select('body') .append('div') .classed('buttons', true) .selectAll('.button') .data(this.scenes) .enter() .append('button') .classed('scene', true) .text(d => d.label) .on('click', d => this.loadScene(d)) .on('touchstart', d => this.loadScene(d))
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(); });
cb.fillcolor(d3.scale.linear() .domain(scl.map(function(v) { return zmin + v[0] * (zmax - zmin); })) .range(scl.map(function(v) { return v[1]; }))) .filllevels({start: zmin, end: zmax, size: (zmax - zmin) / 254}) .options(trace.colorbar)();
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); });
function removeZoombox(gd) { d3.select(gd) .selectAll('.zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners') .remove(); }
it('has the correct name spaces', function() { var mainSVGs = d3.selectAll('.main-svg'); mainSVGs.each(function() { var node = this; assertNamespaces(node); }); });
function countChoroplethPaths() { return d3.selectAll('g.trace.choropleth') .selectAll('path.choroplethlocation') .size(); }