updateStars = function (stars) {
var filtered;
if(test === 1) {
filtered = yelp.filter(d => intersection(project(d.cy, d.cx).x, project(d.cy, d.cx).y));
} else {
filtered = yelp.filter(d => d.rating >= stars);
}
console.log(stars);
const shops = d3.selectAll(".points")
.data(filtered)
.join(
enter => enter.append("circle")
.attr('cx', d => project(d.cy, d.cx).x)
.attr('cy', d => project(d.cy, d.cx).y)
.attr('r', d => 0)
.attr("opacity", 0)
// .attr("fill", "black")
,
update => update,
// Add code to customize how countries exit the scene.
// Idea: use transition to fade out to transparent and shrink to zero size before removal
exit => exit.transition()
.duration(1000)
.attr("r", d => 0)
.attr("opacity", 0)
.remove()
);
// Animate enter + update countries to current position and size
// Hint: If you modify opacity above, you probably want to update it here!
shops.transition()
.duration(1000)
// .ease(d3.easeCubic)
// .attr('cx', d => project(d.cy, d.cx).x)
// .attr('cy', d => project(d.cy, d.cx).y)
// .attr('r', d => size(d.pop))
// .attr("opacity", .75);
// d3.select("#scatter-dynamic")
// .select("#yearLabel")
// .text(newYear);
const drag = d3.selectAll(".drag")
// .selectAll("#shop")
// .selectAll(".countryCircles")
.data(stars)
// .data(filtered.filter(function intersect() {
// node = this.node();
// nodeBox = node.getBBox();
// nodeLeft = nodeBox.x;
// nodeRight = nodeBox.x + nodeBox.width;
// nodeTop = nodeBox.y;
// nodeBottom = nodeBox.y + nodeBox.height;
// }))
.join(
// Add code to customize how countries enter the scene.
// Idea: fade in from transparent and grow from zero size
// Make sure new elements have their properties properly initialized!
enter => enter
// .transition()
// .duration(1000)
// .attr('cx', d => project(d.cy, d.cx).x)
// .attr('cy', d => project(d.cy, d.cx).y)
// .attr('r', d => 0)
// .attr("opacity", 0)
// .attr("fill", "black")
,
update => update,
// Add code to customize how countries exit the scene.
// Idea: use transition to fade out to transparent and shrink to zero size before removal
exit => exit.transition()
// .duration(1000)
// .attr("opacity", 0)
// .remove()
);
drag.transition()
.duration(1000)
}