src/js/widgets/sparklineWidget.js
branchpopcorn-port
changeset 645 0c8ca890c9f1
parent 644 492d3c8d776a
child 688 76953dd536de
equal deleted inserted replaced
644:492d3c8d776a 645:0c8ca890c9f1
    99 
    99 
   100 /** react when a new annotation is added */
   100 /** react when a new annotation is added */
   101 IriSP.SparklineWidget.prototype.handleNewAnnotation = function(annotation) {
   101 IriSP.SparklineWidget.prototype.handleNewAnnotation = function(annotation) {
   102   var num_columns = (this.selector.width()) / IriSP.widgetsDefaults["SparklineWidget"].column_width;
   102   var num_columns = (this.selector.width()) / IriSP.widgetsDefaults["SparklineWidget"].column_width;
   103   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   103   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   104   var time_step = duration / num_columns; /* the time interval between two columns */
   104   var time_step = Math.round(duration / num_columns); /* the time interval between two columns */
   105   var begin = +annotation.begin;
   105   var begin = +annotation.begin;
   106   
   106   
   107   var index = Math.floor(begin / time_step);
   107   var index = Math.floor(begin / time_step);
   108   this._results[index]++;
   108   this._results[index]++;
   109   this.selector.find(".Ldt-sparkLine").sparkline(this._results, {lineColor: "#7492b4", fillColor: "#aeaeb8",
   109   this.selector.find(".Ldt-sparkLine").sparkline(this._results, {lineColor: "#7492b4", fillColor: "#aeaeb8",