最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to set d3.brush extent right? - Stack Overflow

programmeradmin3浏览0评论

I am writing a d3 widget based on Mike Bostocks example 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);

...

the entire code here

I am writing a d3 widget based on Mike Bostocks example http://bl.ocks/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);

...

the entire code here http://plnkr.co/edit/H3nt9t8pw0nXM4yHp25P?p=preview

Share Improve this question asked Jun 22, 2014 at 11:42 Taras ShchybovykTaras Shchybovyk 4164 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

As I understood, you want to set initially the date period. You'll need to call brush ponent with desired extent.

        brush.extent([new Date("May 2001"), new Date("May 2002")]);
        context.select('.brush').call(brush);
        brushed();

Working code is here

发布评论

评论列表(0)

  1. 暂无评论