nvd3 + lineAndFocus + BrushExtent(单击的访问焦点部分)

Hat*_*kNZ 6 nvd3.js

我正在使用此处显示的nvd3示例中显示的lineWithFocusChart.js模型:http://nvd3.org/examples/lineWithFocus.html

我希望能够访问用户在brushExtent(稍微相关的参见此处)中选择的值,然后将焦点应用于所有其他lineAndFocus图表.

我可以这样做的折线图部分:

chart.lines.dispatch.on('elementClick.customNameSpace', function(e) {
    console.log('click', e);
});
Run Code Online (Sandbox Code Playgroud)

是否有类似的东西brushExtent

编辑1:我可以使用此代码控制它聚焦的位置.在此处编辑此示例

chart.brushExtent([10,20])
chart.update()
Run Code Online (Sandbox Code Playgroud)

EDIT2:这就是我要找的东西,现在我只需要将它们放在一起,(即绘制图形,监听变化,然后绘制带有变化的图形......)

chart.dispatch.on('brush.update', function(b) { 
     console.log(b.extent[0], b.extent[1]);
});
Run Code Online (Sandbox Code Playgroud)

jez*_*nag 0

做就是了:

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

我在lineWithFocusPlusSecondaryChart模型中使用了类似的方法。