[ Launch: Tributary inlet ] 7142407 by trinary
-
-
Save trinary/7142407 to your computer and use it in GitHub Desktop.
Closer to the real thing
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
{"description":"Closer to the real thing","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/QqnMsaf.png"} |
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
var d = [ | |
{name: "Alice",value: 7}, | |
{name: "Bob", value: 20}, | |
{name: "Carol",value: 33}, | |
{name: "Dave", value: 9 }, | |
{name: "Erica",value: 1 }, | |
{name: "Frank",value: 44}, | |
{name: "Gwen", value: 15}, | |
{name: "Henry",value: 26} | |
]; | |
var height = 300, | |
width = 500, | |
margin = { left: 40, right: 0, top: 20, bottom: 20}, | |
svg = d3.select("svg"), | |
container, yScale, xScale, yAxis, xAxis, bars; | |
container = svg.append("g").attr("transform","translate(" + [margin.left, margin.top] + ")"); | |
yScale = d3.scale.linear() | |
.domain([0,d3.max(d,function(d,i) { return d.value;})]) | |
.range([height, 0]); | |
xScale = d3.scale.ordinal() | |
.domain(d.map(function(d) { return d.name } )) | |
.rangeRoundBands([0,width], 0.25); | |
xAxis = d3.svg.axis().scale(xScale).orient("bottom"); | |
yAxis = d3.svg.axis().scale(yScale).orient("left"); | |
container.append("g").attr("class","x axis") | |
.attr("transform","translate(" + [0, height] + ")") | |
.call(xAxis); | |
container.append("g").attr("class","y axis") | |
.call(yAxis); | |
bars = container.selectAll(".bars") | |
.data(d); | |
bars.enter() | |
.append("g") | |
.append("rect") | |
.classed("bars",true) | |
.attr({ | |
x: function(d,i) { return xScale(d.value);}, | |
y: function(d,i) { return yScale(d.value);}, | |
width: xScale.rangeBand(), | |
height: function(d,i) { return height - yScale(d.value);} | |
}) | |
.style("fill","grey"); | |
bars.append("text") | |
.style("text-anchor", "middle") | |
.attr("transform", function(d,i) { return "translate(" + [xScale(d.value) + (xScale.rangeBand() / 2), yScale(d.value) - 2] + ")"}) | |
.text(function(d,i) { return d.value; }); |
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
body { | |
font: 13px sans-serif; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
rect { | |
shape-rendering: crispEdges; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment