[英]D3 Brush Extent Inverted
So the issue I'm seeing is that. 所以我看到的问题是那个。 When using a timescale and setting a brush extent. 使用时间刻度并设置画笔范围时。 Most of the time its fine. 大多数时候情况都很好。 But there is an area that becomes very goofed. 但是有一个区域变得非常愚蠢。
In this plunker I set the brush end to reposition the extent into the brush 在这个this孔器中,我将画笔末端设置为将范围重新定位到画笔中
http://plnkr.co/edit/TBPSJm?p=info http://plnkr.co/edit/TBPSJm?p=info
Here are the important snippets: 以下是重要的摘要:
Setting the scale: 设置比例:
chartXScale = d3.time.scale().range([0, brushWidth]).domain([
new Date("Tue Feb 11 2014 14:37:00 GMT-0500 (EST)"),
new Date("Tue Feb 11 2014 16:37:00 GMT-0500 (EST)")]);
Setting the Extent: 设置范围:
var stringStartTime = "Tue Feb 11 2014 14:59:00 GMT-0500 (EST)",
stringEndTime = "Tue Feb 11 2014 15:07:00 GMT-0500 (EST)";
brush.extent([
new Date(stringStartTime),
new Date(stringEndTime)
]);
brush(brushg);
I thought I must just be doing it wrong and have been working for a day to trace what I'm doing wrong, now I'm not to sure. 我以为我一定做错了,并且已经工作了一天来追踪我做错了什么,现在我不确定。
I posted a bug report with d3 incase I'm not doing something wrong. 如果我没有做错什么,我会用d3发布一个错误报告。
https://github.com/mbostock/d3/issues/1736 https://github.com/mbostock/d3/issues/1736
http://plnkr.co/edit/oakPie?p=preview http://plnkr.co/edit/oakPie?p=preview
Your brushWidth was a string. 您的brushWidth是一个字符串。 Add the "+" in front to change it to an int. 在前面添加“ +”以将其更改为int。
chartXScale = d3.time.scale().range([0, +brushWidth]).domain([
new Date("Tue Feb 11 2014 14:37:00 GMT-0500 (EST)"),
new Date("Tue Feb 11 2014 16:37:00 GMT-0500 (EST)")
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.