Skip to content

Instantly share code, notes, and snippets.

@shaneshifflett
Last active December 24, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneshifflett/6783555 to your computer and use it in GitHub Desktop.
Save shaneshifflett/6783555 to your computer and use it in GitHub Desktop.
nested bubble scale with swatch
var legend = function(r, notes, fmt, label, points){
notes.append("svg:circle")
.attr("cy", 40 + r(points[2]))
.attr("cx", 0)
.attr("r", r(points[2]))
.style("stroke", "#444455")
.style("stroke-width", "1")
.style("fill", "none");
notes.append("svg:circle")
.attr("cy", 40 + r(points[1]))
.attr("cx", 0)
.attr("r", r(points[1]))
.style("stroke", "#444455")
.style("stroke-width", "1")
.style("fill", "none");
notes.append("svg:circle")
.attr("cy", 40 + r(points[0]))
.attr("cx", 0)
.attr("r", r(points[0]))
.style("stroke", "#444455")
.style("stroke-width", "1")
.style("fill", "none");
notes.append("line")
.attr("x1", 0)
.attr("x2", 50)
.attr("y1", 40 + r(points[0]) * 2)
.attr("y2", 40 + r(points[0]) * 2)
.style("stroke", "#444455")
.style("stroke-width", "1");
notes.append("line")
.attr("x1", 0)
.attr("x2", 50)
.attr("y1", 40 + r(points[1]) * 2)
.attr("y2", 40 + r(points[1]) * 2)
.style("stroke", "#444455")
.style("stroke-width", "1");
notes.append("line")
.attr("x1", 0)
.attr("x2", 50)
.attr("y1", 40 + r(points[2]) * 2)
.attr("y2", 40 + r(points[2]) * 2)
.style("stroke", "#444455")
.style("stroke-width", "1");
notes.append("text")
.attr("x1", 0)
.attr("x2", 50)
.attr("y1", 46)
.attr("y2", 46)
.style("stroke", "#444455")
.style("stroke-width", "1");
notes.append("text")
.attr("x1", 0)
.attr("x2", 50)
.attr("y1", 58)
.attr("y2", 58)
.style("stroke", "#444455")
.style("stroke-width", "1");
notes.append("text")
.attr("x", 50)
.attr("y", 43 + r(points[2]) * 2)
.text(fmt(points[2]))
.style("font-size", "75%");
notes.append("text")
.attr("x", 50)
.attr("y", 43 + r(points[1]) * 2)
.text(fmt(points[1]))
.style("font-size", "75%");
notes.append("text")
.attr("x", 50)
.attr("y", 43 + r(points[0]) * 2)
.text(fmt(points[0]))
.style("font-size", "75%");
notes.append("text")
.attr("x", 10)
.attr("y", 20)
.text(label)
.attr("text-anchor", "middle")
.style("font-size", "75%");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment