palantir / plottable

:bar_chart: A library of modular chart components built on D3
http://plottablejs.org/
MIT License
2.97k stars 224 forks source link

In unusual circumstances, TimeScale breaks when passed timestamps not dates #2751

Open teamdandelion opened 9 years ago

teamdandelion commented 9 years ago

TimeScale's typing specifies that it should take Dates, but it actually functions perfectly if you pass in milisecond timestamps - unless you have a single data point, so that _ExpandSingleValueDomain is called, in which case it calls getTime on the number and throws an error.

This presents a situation where a user (especially a javscript user) thinks everything is working fine, until they run it on a very unusual dataset. I think the TimeScale should either type check and force the user to use dates and not numbers, or it should gracefully handle this edge case.

MarcMueltin commented 8 years ago

Are there any updates on this bug? I have the same issue. I am plotting values which subsequently arrive after several minutes. As long as I have only one data point for one single timestamp, I get the following error:

TypeError: singleValueDomain[0].getTime is not a function
    at Time._expandSingleValueDomain (http://127.0.0.1:8000/.../plottable.js:2258:54)
    at Time.QuantitativeScale._padDomain (http://127.0.0.1:8000.../plottable.js:1634:29)
    at Time.QuantitativeScale._getExtent (http://127.0.0.1:8000/.../plottable.js:1586:31)
    at Time.QuantitativeScale._autoDomainIfAutomaticMode (http://127.0.0.1:8000/.../plottable.js:1559:39)
    at Time.Scale.addIncludedValuesProvider (http://127.0.0.1:8000/.../plottable.js:1513:18)
    at http://127.0.0.1:8000/.../plottable.js:6710:68
    at Array.forEach (native)
    at Line.Plot._updateExtents (http://127.0.0.1:8000/.../plottable.js:6710:28)
    at Line.Plot._onDatasetUpdate (http://127.0.0.1:8000/.../plottable.js:6611:18)
    at CallbackSet.Plot._onDatasetUpdateCallback (http://127.0.0.1:8000/.../plottable.js:6569:72)

(the full path to the plottable file has been shortened with '...')

This is not very nice as the user can see these logs in the browser and may worry what this error is all about. There should be a graceful handling as crmoford suggested. Any other ideas how to prevent this in the meantime? The only thing I can think of is generating another timestamp which differs e.g. by one second so that there is an actual (tiny) timespan which would display this data point.

jrgleason commented 7 years ago

What is the status of this bug?