src/js/widgets/sparklineWidget.js
branchpopcorn-port
changeset 790 9d2b6f31994d
parent 688 76953dd536de
child 820 7968346b9689
equal deleted inserted replaced
789:15c32b49de59 790:9d2b6f31994d
   122 IriSP.SparklineWidget.prototype.handleNewAnnotation = function(annotation) {
   122 IriSP.SparklineWidget.prototype.handleNewAnnotation = function(annotation) {
   123   var num_columns = this._results.length;
   123   var num_columns = this._results.length;
   124   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   124   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   125   var time_step = Math.round(duration / num_columns); /* the time interval between two columns */
   125   var time_step = Math.round(duration / num_columns); /* the time interval between two columns */
   126   var begin = +annotation.begin;
   126   var begin = +annotation.begin;
       
   127   var end = +annotation.end;
   127   
   128   
   128   var index = Math.floor(begin / time_step);
   129   /* increment all the values between the beginning and the end of the annotation */
   129   this._results[index]++;
   130   var index_begin = Math.floor(begin / time_step);
       
   131   var index_end = Math.floor(end / time_step);
       
   132   
       
   133   for (var i = index_begin; i < Math.min(index_end, this._results.length); i++) {
       
   134     this._results[i]++;
       
   135   }
       
   136   
   130   this.selector.find(".Ldt-sparkLine").sparkline(this._results, {lineColor: "#7492b4", fillColor: "#aeaeb8",
   137   this.selector.find(".Ldt-sparkLine").sparkline(this._results, {lineColor: "#7492b4", fillColor: "#aeaeb8",
   131                                                            spotColor: "#b70056",
   138                                                            spotColor: "#b70056",
   132                                                            width: this.width, height: this.height});
   139                                                            width: this.width, height: this.height});
   133 };
   140 };