nvd3 + lineAndFocus + BrushExtent(access focus part that is clicked)
Asked Answered
T

1

6

I'm using the lineWithFocusChart.js model shown in the nvd3 examples shown here: http://nvd3.org/examples/lineWithFocus.html

I want to be able to get access to the values that the user selects in the brushExtent (slightly related see here) and then apply the focus to all other lineAndFocus charts.

I can do so for the line-chart part with this:

chart.lines.dispatch.on('elementClick.customNameSpace', function(e) {
    console.log('click', e);
});

Is there something similar for the brushExtent?

EDIT1: I can control where it focuses using this code. Editing this example here

chart.brushExtent([10,20])
chart.update()

EDIT2: This is what I am looking for, now I just need to put it all together,(i.e. draw the graph,listen for changes, then draw the graph with the changes...)

chart.dispatch.on('brush.update', function(b) { 
     console.log(b.extent[0], b.extent[1]);
});
Tagmeme answered 23/5, 2014 at 3:40 Comment(0)
C
0

Just do:

chart.focus.dispatch.on('onBrush', function brushChanged(brushExtent) {
  otherCharts.forEach((chart) => chart.brushExtent(brushExtent));
});

I used a similar approach in my lineWithFocusPlusSecondaryChart model.

Chair answered 27/3, 2017 at 0:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.