fwahlqvist / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

TIMEPLOT: Dom Error when the data is only one #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
timeplot.loadText('/test.txt', ',', eventSource);

When this is only one line in test.txt.  There is a js error.

The detailed error is 0x8053000c (NS_ERROR_DOM_SYNTAX_ERR).

After some debug, i found the problem:  

file : geometry.js  
function: Timeplot.DefaultTimeGeometry.prototypetime.toScreen

reason:  when with only one file, this._mappedPeriod = 0, so toScreen
return NaN which make the following moveTo throwing the exception.

Fix: ( I did a monkey patch in my app js, but it should easily to be fixed
in geometry.js)

      Timeplot.DefaultTimeGeometry.prototypetime.toScreen = function(time) {
        if (this._canvas && this._latestDate) {
          var t = time - this._earliestDate.getTime();
          if (this._mappedPeriod == 0) {
            return 0;
          } else {
            return this._canvas.width * this._map.direct(t) /
this._mappedPeriod;
          }
        } else {
          return -50;
        } 
      };

Original issue reported on code.google.com by YeDingd...@gmail.com on 8 Oct 2008 at 6:52

GoogleCodeExporter commented 9 years ago
Thank you YeDingding. Not sure if anyone is actively working on Timeplot. If 
you'd 
like to contribute to the project, that'd be great.

Original comment by larryklu...@gmail.com on 11 Oct 2008 at 11:10

GoogleCodeExporter commented 9 years ago
Hi, larrykluger. i'm glad to contribute but have few time everyday.  I will 
patch the
project when i meet the problems.

Original comment by YeDingd...@gmail.com on 14 Oct 2008 at 9:00

GoogleCodeExporter commented 9 years ago
Patch accepted (modified slightly) and committed.

Original comment by ryan...@csail.mit.edu on 15 Jan 2009 at 8:47