Skip to content

Instantly share code, notes, and snippets.

@davo
Last active October 23, 2015 21: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 davo/c5239219b1c808bd7e02 to your computer and use it in GitHub Desktop.
Save davo/c5239219b1c808bd7e02 to your computer and use it in GitHub Desktop.
Bono Scale

Learning how to make a threshold scale while making a tribute to the lead singer of U2 and his well-known proficent spanish.

Built with blockbuilder.org

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width: 100%; height: 100%; font-family: Helvetica, Arial, _sans; font-size: .75em; }
.axis text {
font: 10px sans-serif;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.caption {
font-weight: bold;
}
</style>
</head>
<body>
<script>
var vertigo = [1,2,3,14];
var width = 960,
height = 500;
var threshold = d3.scale.threshold()
.domain(vertigo)
var x = d3.scale.linear()
.domain([1, 14])
.range([1, 600])
var xAxis = d3.svg.axis()
.scale(x).tickSize(13).tickValues(threshold.domain())
.orient("bottom");
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + (width-600) / 2 + "," + height / 2 + ")");
svg.append("g")
.attr("class", "x axis")
.call(xAxis);
svg.call(xAxis).append("text")
.attr("class", "caption")
.attr("y", -9)
.text("Bono Scale");
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment