update the graph correctly. popcorn-port
authorhamidouk
Thu, 09 Feb 2012 11:01:47 +0100
branchpopcorn-port
changeset 790 9d2b6f31994d
parent 789 15c32b49de59
child 791 f1d90a404de4
update the graph correctly.
src/js/widgets/sparklineWidget.js
--- a/src/js/widgets/sparklineWidget.js	Thu Feb 09 10:30:49 2012 +0100
+++ b/src/js/widgets/sparklineWidget.js	Thu Feb 09 11:01:47 2012 +0100
@@ -124,9 +124,16 @@
   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   var time_step = Math.round(duration / num_columns); /* the time interval between two columns */
   var begin = +annotation.begin;
+  var end = +annotation.end;
   
-  var index = Math.floor(begin / time_step);
-  this._results[index]++;
+  /* increment all the values between the beginning and the end of the annotation */
+  var index_begin = Math.floor(begin / time_step);
+  var index_end = Math.floor(end / time_step);
+  
+  for (var i = index_begin; i < Math.min(index_end, this._results.length); i++) {
+    this._results[i]++;
+  }
+  
   this.selector.find(".Ldt-sparkLine").sparkline(this._results, {lineColor: "#7492b4", fillColor: "#aeaeb8",
                                                            spotColor: "#b70056",
                                                            width: this.width, height: this.height});