如何设置d3.brush extent? [英] how to set d3.brush extent right?
本文介绍了如何设置d3.brush extent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个基于Mike Bostocks的d3小部件示例 http://bl.ocks.org/mbostock / 1667367
所以我试图用预定义的日期设置笔刷范围,但是范围矩形不适用于这些日期。
I am writing a d3 widget based on Mike Bostocks example http://bl.ocks.org/mbostock/1667367 So I am trying to set brush extent with predefined dates, but the extent rectangle is not applied to those dates.
var brush = d3.svg.brush()
.x(x2)
.extent([new Date("May 2001"), new Date("May 2002")])
.on('brush', brushed);
...
这里 http://plnkr.co/edit/H3nt9t8pw0nXM4yHp25P?p=preview
推荐答案
如我所知,您想要初始设置日期时间。您需要以所需的程度调用画刷组件。
As I understood, you want to set initially the date period. You'll need to call brush component with desired extent.
brush.extent([new Date("May 2001"), new Date("May 2002")]);
context.select('.brush').call(brush);
brushed();
工作代码此处
这篇关于如何设置d3.brush extent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文