novus / nvd3

A reusable charting library written in d3.js
http://nvd3.org/
Other
7.22k stars 2.15k forks source link

lineWithFocusChart - brush event hijacking #942

Open jufemaiz opened 9 years ago

jufemaiz commented 9 years ago

Hi guys, wondering if there's a way to hijack the brush events for the focus window. I want to use the focused area's start/end datetimestamps (in my case) to work with the data in another part of the page (and vice-versa).

Cheers, Joel

liquidpele commented 9 years ago

There is a 'brush' dispatch if you look at the lineWithFocusChart model.

chart.dispatch.on('brush', function(extent, brush){ console.log(extent, brush); });
Orguf commented 9 years ago

Is it possible to get the brushend event, this is part of D3 but I am unable to get this working on nvd3.

My shortcut for now is exposing the brush by exposing it as a public variable and attach the brushend event.

//Expose brush in nvd3 chart.brush = brush;

//Set brushend event in code chart.brush.on('brushend', function() { console.log('brush ended'); });

liquidpele commented 9 years ago

Oh thats actually not a bad idea to do...

robstrr commented 8 years ago

Hey, @Orguf could you please post a full working example ? What is the brush variable ?

I was thinking of editing the lineChart.js on line around 300 and add brushend ...