const weierstrass = (x) => { const a = 0.5; const b = (1 + 3 * Math.PI / 2) / a; // eslint-disable-line return d3.sum(d3.range(100).map(n => Math.pow(a, n) * Math.cos(Math.pow(b, n) * Math.PI * x))); // eslint-disable-line }
d3.range(0, 360 + step, step).map(function(deg, index) { var theta = deg * Math.PI / 180; var radius = _equation(theta); return [ deg, radius ]; })
// 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)"; });
export function connectionMatrix(data, sourceKey = 'source', targetKey = 'target', valueKey = 'value') { const nameIds = nameId(allUniqueNames(data, 'Source', 'Target'), d => d); const uniqueIds = nameIds.domain(); const matrix = d3.range(uniqueIds.length).map(() => d3.range(uniqueIds.length).map(() => 1)); data.forEach((d) => { matrix[nameIds(d[sourceKey])][nameIds(d[targetKey])] += Number(d[valueKey]); }); return matrix; }
d3.nest() .key(d => d.death.episode) .key(d => d.death.season) .entries(data.filter(d => !d.death.isFlashback)) .map(v => { return d3.range(1, totalSeasons + 1).reduce((item, episodeNumber) => { const deaths = v.values.filter(d => +d.key === episodeNumber).shift() || 0; item[`season-${episodeNumber}`] = deaths ? deaths.values.length : 0; return item; }, { episode: v.key }); }) .sort((a, b) => +a.episode - +b.episode)
//Draw the background circles axisGrid.selectAll(".levels") .data(d3.range(1,(cfg.levels+1)).reverse()) .enter() .append("circle") .attr("class", "gridCircle") .attr("r", function(d, i){return radius/cfg.levels*d;}) .style("fill", "#CDCDCD") .style("stroke", "#CDCDCD") .style("fill-opacity", cfg.opacityCircles) .style("filter" , "url(#glow)");
function generate(maxJitter) { var x = d3.range(-1, 1.5, 0.5); // left closed, right open interval var y = d3.range(-1, 1.5, 0.5); // left closed, right open interval var i, j, p, z = new Array(x.length); for(i = 0; i < x.length; i++) { z[i] = new Array(y.length); for(j = 0; j < y.length; j++) { p = rotate(Math.PI / 4, {x: x[i], y: -y[j]}); z[i][j] = jitter(maxJitter, Math.pow(p.x, 2) + Math.pow(p.y, 2)); } } return {x: x, y: y, z: z}; // looking forward to the ES2015 return {x, y, z} }
birthyears.selectAll(".birthyear") .data((d3.range(year0 - age1, year1 + 1, 5))) .enter().append("g") .attr("class", "birthyear") .attr("transform", (birthyear) => `translate(${x(birthyear)},0)`)
d3.range(50).map(function(d) { return { id: d, size: 1 + Math.floor(Math.random() * 50), r: Math.random() * 50, color: Math.floor(Math.random() * 100), f: (Math.random() > 0.5 ? -1 : 1) * (Math.random() * 10000 + 1000) }; })
svg.selectAll(".age") .data(d3.range(0, age1 + 1, 5)) .enter().append("text") .attr("class", "age") .attr("x", function(age) { return x(year - age); }) .attr("y", height + 4) .attr("dy", ".71em") .text(function(age) { return age; })
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); });
d3.range(numVertices).map(function(i) { var angle = radius * (i+10); return {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; })
constructor(props) { super(props); this.state = { data: d3.range(1000).map(d3.randomBates(10)) }; }