--- a/client/annotviz/app/js/annotstimeline.js Thu Jan 22 15:02:54 2015 +0100
+++ b/client/annotviz/app/js/annotstimeline.js Thu Jan 22 15:03:58 2015 +0100
@@ -39,7 +39,7 @@
this.intervalWidth = opts.intervalWidth;
this.maxCellHeight = opts.maxCellHeight;
this.annotCategories = opts.annotCategories;
-
+
this.circleX = opts.circleX || (this.width/2);
this.circleY = opts.circleY || (this.height/2);
this.radius = opts.radius;
@@ -55,13 +55,6 @@
this.cells[i].i = i;
this.cells[i].totalAnnots = 0;
this.cells[i].categories = {};
-
- for (var category in this.annotCategories[0].colors){
- this.cells[i].categories[category] = {
- "count": 0,
- "color": this.annotCategories[0].colors[category]
- };
- }
}
var ws = opts.ws;
@@ -91,34 +84,26 @@
//Add Annotation to the TimeLine
this.addAnnot = function(data){
- if (typeof(this.annotCategories[0].colors[data.content.category.code]) !== 'undefined'){
- var annotCode = data.content.category.code;
- } else {
- var annotCode = this.annotCategories[0].order[this.annotCategories[0].order.length -1];
- }
- var annotTime = Date.parse(data.ts);
+
+ if (this.timeEnd > Date.parse(data.ts)){
+ var i = Math.floor(((Date.parse(data.ts) + 3600*1000) - this.timeBegin)/(1000*this.intervalDuration));
- if (this.timeEnd > Date.parse(data.ts)){
- console.log(this.timeBegin);
- console.log(data.ts);
- console.log(Date.parse(data.ts));
- console.log(Date.now());
- var i = Math.floor(((Date.parse(data.ts) + 3600*1000) - this.timeBegin)/(1000*this.intervalDuration));
- console.log(i);
+ if (typeof(this.cells[i].graphics) === 'undefined'){
+ this.initCell(this.cells[i]);
+ }
+
+ if (typeof(this.annotCategories[0].colors[data.content.category.code]) !== 'undefined'){
+ var annotCode = data.content.category.code;
+ } else {
+ var annotCode = 'default';
+ }
+
this.cells[i].categories[annotCode].count += 1;
this.cells[i].totalAnnots +=1;
this.redrawCell(this.cells[i], i);
}
};
- this.initCell = function(cell){
- cell.graphics = new PIXI.Graphics();
- cell.graphics.position.x = this.circleX + this.radius * Math.sin(cell.i*(360/totalIndex)*(Math.PI/180));
- cell.graphics.position.y = this.circleY - this.radius * Math.cos(cell.i*(360/totalIndex)*(Math.PI/180));
- cell.graphics.rotation = (cell.i)*(360/totalIndex)*(Math.PI/180) + (360/(totalIndex*2))*(Math.PI/180);
- this.container.addChild(cell.graphics);
- }
-
this.initTimeTexts = function() {
var tBeg = new PIXI.Text(Utils.formatTime(this.timeBegin), { font: '12pt Gothic Standard', fill: '#646464' });
tBeg.x = this.circleX + 15;
@@ -150,13 +135,7 @@
//Draw the cellule
this.redrawCell = function(cell){
-
- if (typeof(cell.graphics) === 'undefined'){
- this.initCell(cell);
- } else {
- cell.graphics.clear();
- }
-
+
var y = 0;
//Check if total height is higher than Max Cell Height
@@ -175,6 +154,25 @@
y -= cell.categories[currentCode].count*heightStep;
}
}
+
+ this.initCell = function(cell){
+ cell.graphics = new PIXI.Graphics();
+ cell.graphics.position.x = this.circleX + this.radius * Math.sin(cell.i*(360/totalIndex)*(Math.PI/180));
+ cell.graphics.position.y = this.circleY - this.radius * Math.cos(cell.i*(360/totalIndex)*(Math.PI/180));
+ cell.graphics.rotation = (cell.i)*(360/totalIndex)*(Math.PI/180) + (360/(totalIndex*2))*(Math.PI/180);
+ this.container.addChild(cell.graphics);
+
+ for (var category in this.annotCategories[0].colors){
+ cell.categories[category] = {
+ "count": 0,
+ "color": this.annotCategories[0].colors[category]
+ };
+ }
+ cell.categories['default'] = {
+ "count": 0,
+ "color": this.annotCategories[0].defaultColor
+ }
+ }
this.init = function() {
ws.message(function(data) {