0

I am trying to use a bisector graph with unix timestamps and his Answer

Multiseries line chart with mouseover tooltip

I am fiddling for some hours now, and don't seem to get why it doesn't work. The bisector always cries about


    d3.v3.min.js:1 Uncaught TypeError: Cannot read property 'length' of undefined

although I am using:


      dataset.forEach(function(d) {
        d.date = new Date(d.time);
        d.close = +d.close;
      });

I have put everything together i a standalone pastebin. Excuse the formatting please. I'd be extremely glad if someone points out the mistake I have done. http://pastebin.com/ycDjYTUW

Community
  • 1
  • 1
joeysql1
  • 47
  • 5

1 Answers1

1

First, bisect expects an array as a first argument, you are passing it a single value (actually undefined). I think you meant to just pass d to it. Second, in my example you link too, the lines array is an array of paths, you've changed it to an array of g.

var xDate = xScale.invert(mouse[0]),
  bisect = d3.bisector(function(d) { return d.date; }).left;
  idx = bisect(d, xDate);

var beginning = 0,
  end = lines[i].children[0].getTotalLength(),
  target = null;

...

Running code here.

Mark
  • 106,305
  • 20
  • 172
  • 230