dalejung / id3

interactive d3
Apache License 2.0
4 stars 0 forks source link

Handle instances where we are in the region of a chart that has no data. #21

Closed dalejung closed 11 years ago

dalejung commented 11 years ago

This can happen when you have multiple datasets that don't align perfectly on the x-axis.For example, stock A might not have data for the entire period.

There are two scenarios with this:

  1. Partial empty data. For the candlestick it will set the heights to the candlestick svg elements to 0. So while the elements do exist, they are unseen.
  2. Completely empty data

Right now this errors for candlestick and line because the y scale has [NaN, Nan] for its domain and thus returns NaN.

So the question is, what is the correct path to handle empty data? Remove the DOM elements or just make them hidden?

While not on purpose, I think how the first case is handled is better. There won't be any overhead in creating and destroying dom elements, and if you're just panning the brush, the correct number of DOM elements will stay on screen.

So yeah, do that.

dalejung commented 11 years ago

https://github.com/mbostock/d3/issues/583 touches on this too. Though not applicable here since all my .data() is just the index values.

dalejung commented 11 years ago

finished fixing line issue with https://github.com/dalejung/id3/commit/24d3fa9ce202aedf023141e75c4f349950ea6852

Also, fixed the partial data problem where the line showed up at 0.