Question

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

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.

https://github.com/mbostock/d3/issues/1736

Was it helpful?

Solution

http://plnkr.co/edit/oakPie?p=preview

Your brushWidth was a string. Add the "+" in front to change it to an 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)")
]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top