client/annotviz/app/js/generalView.js
changeset 92 a323578ea954
parent 91 09a9074ea7b0
child 99 9d968fbcaa2a
--- a/client/annotviz/app/js/generalView.js	Fri Jan 16 22:09:56 2015 +0100
+++ b/client/annotviz/app/js/generalView.js	Mon Jan 19 09:52:52 2015 +0100
@@ -10,7 +10,7 @@
 var PIXI = require('pixi');
 var randomColor = require('randomColor');
 
-function GeneralView(parentContainer, xInit, yInit, width, height, duration, interval, beginTime){
+function GeneralView(parentContainer, xInit, yInit, width, height, timeBegin, timeEnd, intervalSize){
 	console.log(width);
     var _this = this;
     this.container = new PIXI.DisplayObjectContainer();
@@ -20,15 +20,16 @@
     this.container.height = height;
     parentContainer.addChild(this.container);
     
-    this.duration = duration;
-    this.beginTime = beginTime;
+    this.timeBegin = timeBegin;
+    this.timeEnd = timeEnd;
+    this.duration = (timeEnd - timeBegin)/1000 
     this.width = width;
     this.height = height;
     //define interval corresponding to the time of one step
     //e.g: 60 for a step of 60 seconds
-    this.interval = interval;
+    this.intervalSize = intervalSize;
     // define the step depending the interval we passed and the duration
-    this.step = width*interval/duration;
+    this.intervalDuration = (intervalSize*this.duration/width);
     
   //Initialise the list of step
     //each cell will contain the list categories and the number of annotations per categories
@@ -45,7 +46,7 @@
     this.container.addChild(graphics);
 
     this.addAnnot = function(category, time){
-    	var x = Math.floor( (time-this.beginTime)/(1000*this.interval)) * this.step;
+    	var x = Math.floor( (time-this.timeBegin)/(1000*this.intervalDuration)) * this.intervalSize;
     	var y = (-this.height/2);
     	
     	//Check if cell is already set.
@@ -66,7 +67,7 @@
     	// We draw the rectangle
         var graphics = new PIXI.Graphics();
         graphics.beginFill(0x536991);
-        graphics.drawRect(x, y, this.step, -10);
+        graphics.drawRect(x, y, this.intervalSize, -10);
         graphics.endFill();
         
         this.container.addChild(graphics);