D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
jasondavies
Full window
Github gist
Fast highlighting in D3
<!DOCTYPE html> <head> <title>Fast highlighting in D3</title> <style> circle { fill: #fff; stroke: #000; } .highlight { fill: #fc0; } </style> <script src="https://d3js.org/d3.v2.min.js"></script> </head> <body> <script> var w = 500, active = null; d3.select("body").append("svg") .attr("width", w) .attr("height", w) .selectAll("circle") .data(d3.range(1000)) .enter().append("circle") .attr("r", 10) .attr("cx", x) .attr("cy", x) .on("click", function() { if (active) active.classed("highlight", false); active = d3.select(this.parentNode.appendChild(this)) .classed("highlight", true); }); function x() { return Math.random() * w; } </script> </body>
Modified
http://d3js.org/d3.v2.min.js
to a secure url
https://d3js.org/d3.v2.min.js