A static beeswarm plot implemented using d3-force’s collision constraint. A Voronoi overlay improves hover interaction.
Created
June 26, 2018 15:31
-
-
Save ojassvi/044af14c548b4bdce916924e6a98b6d7 to your computer and use it in GitHub Desktop.
Beeswarm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id | value | |
---|---|---|
flare.data.DataField | 1759 | |
flare.data.DataSchema | 2165 | |
flare.data.DataSet | 586 | |
flare.data.DataSource | 3331 | |
flare.data.DataTable | 772 | |
flare.data.DataUtil | 3322 | |
flare.display.LineSprite | 1732 | |
flare.display.RectSprite | 3623 | |
flare.flex | ||
flare.flex.FlareVis | 4116 | |
flare.physics | ||
flare.physics.GravityForce | 1336 | |
flare.physics.IForce | 319 | |
flare.physics.Particle | 2822 | |
flare.physics.Spring | 2213 | |
flare.physics.SpringForce | 1681 | |
flare.query | ||
flare.query.AggregateExpression | 1616 | |
flare.query.And | 1027 | |
flare.query.Arithmetic | 3891 | |
flare.query.Average | 891 | |
flare.query.BinaryExpression | 2893 | |
flare.query.Comparison | 5103 | |
flare.query.CompositeExpression | 3677 | |
flare.query.Count | 781 | |
flare.query.Distinct | 933 | |
flare.query.Expression | 5130 | |
flare.query.ExpressionIterator | 3617 | |
flare.query.Fn | 3240 | |
flare.query.If | 2732 | |
flare.query.IsA | 2039 | |
flare.query.Literal | 1214 | |
flare.query.Match | 3748 | |
flare.query.Maximum | 843 | |
flare.query.methods | ||
flare.query.methods.add | 593 | |
flare.query.methods.and | 330 | |
flare.query.methods.average | 287 | |
flare.query.methods.count | 277 | |
flare.query.methods.distinct | 292 | |
flare.query.methods.div | 595 | |
flare.query.methods.eq | 594 | |
flare.query.methods.fn | 460 | |
flare.query.methods.gt | 603 | |
flare.query.methods.gte | 625 | |
flare.query.methods.iff | 748 | |
flare.query.methods.isa | 461 | |
flare.query.methods.lt | 597 | |
flare.query.methods.lte | 619 | |
flare.query.methods.max | 283 | |
flare.query.methods.min | 283 | |
flare.query.methods.mod | 591 | |
flare.query.methods.mul | 603 | |
flare.query.methods.neq | 599 | |
flare.query.methods.not | 386 | |
flare.query.methods.or | 323 | |
flare.query.methods.orderby | 307 | |
flare.query.methods.range | 772 | |
flare.query.methods.select | 296 | |
flare.query.methods.stddev | 363 | |
flare.query.methods.sub | 600 | |
flare.query.methods.sum | 280 | |
flare.query.methods.update | 307 | |
flare.query.methods.variance | 335 | |
flare.query.methods.where | 299 | |
flare.query.methods.xor | 354 | |
flare.query.methods._ | 264 | |
flare.query.Minimum | 843 | |
flare.query.Not | 1554 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
.axis text { | |
font: 10px sans-serif; | |
} | |
.cells path { | |
fill: none; | |
pointer-events: all; | |
} | |
.cells :hover circle { | |
fill: red; | |
} | |
</style> | |
<svg width="960" height="200"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script> | |
var svg = d3.select("svg"), | |
width = svg.attr("width"), | |
height = svg.attr("height"); | |
var x = d3.scaleLinear().rangeRound([0, width]); | |
var g = svg.append("g") | |
.attr("transform", "translate(" + 10 + "," + 0 + ")"); | |
d3.csv("flare.csv", type, function(error, data) { | |
if (error) throw error; | |
x.domain(d3.extent(data, function(d) { return d.value; })); | |
var simulation = d3.forceSimulation(data) | |
.force("x", d3.forceX(function(d) { return x(d.value); }).strength(1)) | |
.force("y", d3.forceY(height / 2)) | |
.force("collide", d3.forceCollide(4)) | |
.stop(); | |
for (var i = 0; i < 100; ++i) simulation.tick(); | |
var cell = g.append("g") | |
.attr("class", "cells") | |
.selectAll("g").data(d3.voronoi() | |
.extent([[0, 0], [width, height]]) | |
.x(function(d) { return d.x; }) | |
.y(function(d) { return d.y; }) | |
.polygons(data)).enter().append("g"); | |
cell.append("circle") | |
.attr("r", 3) | |
.attr("cx", function(d) { return d.data.x; }) | |
.attr("cy", function(d) { return d.data.y; }); | |
}); | |
function type(d) { | |
if (!d.value) return; | |
d.value = +d.value; | |
return d; | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
�PNG | |