Hi,

i have changed three things in the current timeplot code from svn:

o Changed global 'unit' variable to be of local scope

o Added support for entity of a value to be displayed in tooltip, see 
example:
   http://gpsvision.biz/timeplot.png

o Workaround for stale mouseevents
   Note: this is no fix but a workaround only, I have reported the bug 
in a previous mail

Is it possible to apply this to the current svn?

Thank you for all

Marcel

********* timeplot-svn-2009-08-15.patch ***********

Index: scripts/geometry.js
===================================================================
--- scripts/geometry.js    (Revision 2043)
+++ scripts/geometry.js    (Arbeitskopie)
@@ -589,11 +589,10 @@
        
         if (p == 0) return grid;
        
+        var unit = time.MILLENNIUM;
         // find the time units nearest to the time period
-        if (p > time.gregorianUnitLengths[time.MILLENNIUM]) {
-            unit = time.MILLENNIUM;
-        } else {
-            for (var unit = time.MILLENNIUM; unit > 0; unit--) {
+        if (p <= time.gregorianUnitLengths[time.MILLENNIUM]) {
+            for (; unit > 0; unit--) {
                 if (time.gregorianUnitLengths[unit-1] <= p && p < 
time.gregorianUnitLengths[unit]) {
                     unit--;
                     break;
Index: scripts/timeplot.js
===================================================================
--- scripts/timeplot.js    (Revision 2043)
+++ scripts/timeplot.js    (Arbeitskopie)
@@ -51,7 +51,8 @@
         roundValues:       ("roundValues" in params) ? 
params.roundValues : true,
         valuesOpacity:     ("valuesOpacity" in params) ? 
params.valuesOpacity : 75,
         bubbleWidth:       ("bubbleWidth" in params) ? 
params.bubbleWidth : 300,
-        bubbleHeight:      ("bubbleHeight" in params) ? 
params.bubbleHeight : 200
+        bubbleHeight:      ("bubbleHeight" in params) ? 
params.bubbleHeight : 200,
+        valueEntity:       ("valueEntity" in params) ? 
params.valueEntity : ""
     };
 };
 
Index: scripts/plot.js
===================================================================
--- scripts/plot.js    (Revision 2043)
+++ scripts/plot.js    (Arbeitskopie)
@@ -66,7 +66,8 @@
             var month = 30 * day;
            
             var mouseMoveHandler = function(elmt, evt, target) {
-                if (typeof SimileAjax != "undefined" && 
plot._plotInfo.showValues) {
+                if (typeof SimileAjax != "undefined" && 
plot._plotInfo.showValues
+                    && plot._dataSource != null) {
                     var c = plot._canvas;
                     var x = 
Math.round(SimileAjax.DOM.getEventRelativeCoordinates(evt,plot._canvas).x);
                     if (x > c.width) x = c.width;
@@ -78,10 +79,12 @@
                     }
                    
                     var validTime = 
plot._dataSource.getClosestValidTime(t);
+                    if (validTime == 0) // event from removed DataSource?!
+                      return;
                     x = plot._timeGeometry.toScreen(validTime);
                     var v = plot._dataSource.getValue(validTime);
                     if (plot._plotInfo.roundValues) v = Math.round(v);
-                    plot._valueFlag.innerHTML = new String(v);
+                    plot._valueFlag.innerHTML = new String(v + 
plot._plotInfo.valueEntity); // 80 km/h
                     var d = new Date(validTime);
                     var p = plot._timeGeometry.getPeriod();
                     if (p < day) {




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to