user2159399
user2159399

Reputation: 63

D3 v4 Multi line chart Brush Issue NaN when moving brush

I have been working on D3 v4 multi line with brush axis. The graph plots correctly with multi lines in it , however when I am trying to move the brush, D3 is throwing me an NaN error.

Attached is the below link in blockbuilder.org:

http://blockbuilder.org/mhaneef50673/0b7304759ccbc1e3ba8cf4aa58e56695

Upvotes: 1

Views: 274

Answers (1)

Gerardo Furtado
Gerardo Furtado

Reputation: 102194

Why are you using brush.extent() as a getter? You have to change the scale's domain instead, using d3.event.selection, like this:

xFocus.domain(d3.event.selection === null ? xContext.domain() : 
    d3.event.selection.map(xContext.invert, xContext));

Also, you have to pass d.values to the line generator, not just d.

Here is your updated bl.ocks: https://bl.ocks.org/GerardoFurtado/cb7048512af17ed3683e79637eee40d7/9d8d7945bbcb39dabb568dd68247316d2ace5ac3

Upvotes: 1

Related Questions