Skip to content

Instantly share code, notes, and snippets.

@caged
caged / d3-multi-line.js.coffee
Created December 30, 2011 17:23
d3.js line chart with multiple lines and points
$ ->
version = Number(document.location.hash.replace('#', ''))
data = [[3,7,9,1,4,6,8,2,5], [5,2,3,4,9,6,4,6,8]]
[pt, pl, pr, pb] = [20, 20, 20, 20] # padding
w = 800 - (pl + pr)
h = 300 - (pt + pb)
max = d3.max(data, (d) -> d3.max(d))
# Scales
x = d3.scale.linear().domain([0, data[0].length - 1]).range [0, w]