epochjs / epoch

A general purpose, real-time visualization library.
http://epochjs.github.io/epoch
MIT License
4.97k stars 278 forks source link

Fixes rendering bug in Epoch.Time.Heatmap #153

Closed rsandor closed 9 years ago

rsandor commented 9 years ago

At the top of the Epoch.Time.Heatmap.redraw there is a series of checks that ensures the chart has data before fully redrawing chart. It was erroneously inspecting the @data member when ensuring that the first layer had actual values to display.

rsandor commented 9 years ago

@jamesarosen - Can you take a look at this and make sure I am not mad? Also, if you have any suggestions for how to clean up that line to make it more readable, I am entirely comprised of ears.

jamesarosen commented 9 years ago

How about

isNonEmptyArray = (ary) ->
  Epoch.isArray(ary) and ary.length > 0

redraw: ->
  return unless isNonEmptyArray(@data) and isNonEmptyArray(@data[0].values)
rsandor commented 9 years ago

Ooh, good call, could probably put that in Epoch.Util. Updates en route.

rsandor commented 9 years ago

@jamesarosen - That should do it, thoughts?

jamesarosen commented 9 years ago

+1

rsandor commented 9 years ago

Yeah, while non-empty is a double negative, I think it is used quite often to describe the test. An alternative would be to replace it with not Epoch.isEmptyArray(ary) but that just seems to make the test less clear. Should be good to go, from my perspective.