Skip to content

Instantly share code, notes, and snippets.

@k-izzo
Created March 16, 2014 16:37
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 k-izzo/9585991 to your computer and use it in GitHub Desktop.
Save k-izzo/9585991 to your computer and use it in GitHub Desktop.
ordinal scale compare
{"description":"ordinal scale compare","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"a.style":{"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,"ajax-caching":true}
data = [0, 9, 11, 3, 4, 7]
svg = d3.select('svg')
xsP = d3.scale.ordinal()
.domain(d3.range(data.length))
.rangePoints([100, 400])
xsB = d3.scale.ordinal()
.domain(d3.range(data.length))
.rangeBands([100, 400])
svg.selectAll('.blues')
.data(data)
.enter()
.append('circle')
.classed('blues', true)
.attr({
cx: (d, i) -> xsP(i)
cy: 100
r: 9
})
svg.selectAll('.reds')
.data(data)
.enter()
.append('circle')
.classed('reds', true)
.attr({
cx: (d, i) -> xsB(i)
cy: 150
r: 9
})
circle.blues {
fill: blue;
}
circle.reds {
fill: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment