Crossfilter Example with d3.layout.histogram

624 views
Skip to first unread message

Max Schulze

unread,
Jul 12, 2012, 6:06:37 AM7/12/12
to d3...@googlegroups.com
Hello everyone,

I'm trying to rebuild the http://square.github.com/crossfilter/ example, but using d3.layout.histogram() + crossfilter to generate the data. I have some issues understanding what I have to change to make it work. I've already changed the scales but the resizePath method is not quite clear to me (and how the bars are drawn):

barPath = (groups) ->
  path = []
  i = -1
  n = groups.length
          
  while ++i < n
    d = groups[i]
            
    path.push("M", x(d.key), ",", height, "V", y(d.value), "h9V", height)
          
  return path.join("")
resizePath = (d) ->
  e = +(d == "e")
  x1 = e ? 1 : -1
  y1 = height / 3
          
  return "M#{(.5 * x1)},#{y1}A6,6 0 0 #{e} #{(6.5 * x1)},#{(y1 + 6)}
          V#{(2 * y1 - 6)}A6,6 0 0 #{e} #{(.5 * x1)},#{(2 * y1)}
          Z
          M#{(2.5 * x1)},#{(y1 + 8)}
          V#{(2 * y1 - 8)}
          M#{(4.5 * x1)},#{(y1 + 8)}
          V#{(2 * y1 - 8)}"

Could anyone help me understand better?

Thank you,
Max

Mike Bostock

unread,
Jul 13, 2012, 10:24:17 AM7/13/12
to d3...@googlegroups.com
There's no reason to use Crossfilter with d3.layout.histogram—they do
the same thing. Either use crossfilter to compute the bins, or you use
the histogram layout.

Mike
Reply all
Reply to author
Forward
0 new messages