10

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

我希望能够为要在负载时关注的图形选择特定的 x 范围。我认为图表中会有一个变量可以设置来完成此操作。

4

2 回答 2

12

假设页面上只有一个由 nvd3 生成的图表:

chart = nv.graphs[0] // how to choose the graph by DOM id?
chart.brushExtent([10,20])
chart.update()

感谢@elsherbini 的评论。

于 2013-09-19T05:29:45.110 回答
0

此处提供的解决方案不再适用于最新版本的 NVD3。相反,您可以在创建图表时使用以下内容:

  chart = nv.models.lineWithFocusChart()
    .options({
      brushExtent: [10000,490000]
    });

或者在你创建它之后:

chart.brushExtent([10000,490000]);

请参阅此处的文档:http: //nvd3-community.github.io/nvd3/examples/documentation.html#lineWithFocusChart

于 2016-02-21T01:51:34.403 回答