# HG changeset patch # User rougeronj # Date 1421939814 -3600 # Node ID d8ef840eaf68f98ac067f0d8b905ca468471f6f8 # Parent 3b11017a76a4ca93e7865f20f5b6f0bfab4e1967 get the correct json category depending on the timestamp diff -r 3b11017a76a4 -r d8ef840eaf68 client/annotviz/app/js/annotsroll.js --- a/client/annotviz/app/js/annotsroll.js Thu Jan 22 15:49:07 2015 +0100 +++ b/client/annotviz/app/js/annotsroll.js Thu Jan 22 16:16:54 2015 +0100 @@ -96,7 +96,7 @@ resColor = colorsDef[code]; } if(!resColor) { - resColor = this.annotColors[0].defaultColor || DEFAULT_ANNOT_COLOR; + resColor = colorsDef.defaultColor || DEFAULT_ANNOT_COLOR; } return resColor; } diff -r 3b11017a76a4 -r d8ef840eaf68 client/annotviz/app/js/annotstimeline.js --- a/client/annotviz/app/js/annotstimeline.js Thu Jan 22 15:49:07 2015 +0100 +++ b/client/annotviz/app/js/annotstimeline.js Thu Jan 22 16:16:54 2015 +0100 @@ -85,14 +85,23 @@ //Add Annotation to the TimeLine this.addAnnot = function(data){ + var ts = Date.parse(data.ts); + var colorsDef; + _(this.annotCategories).eachRight(function(cdef) { + if(cdef.ts < ts) { + colorsDef = cdef; + return false; + } + }); + if (this.timeEnd > Date.parse(data.ts)){ var i = Math.floor(((Date.parse(data.ts) + 3600*1000) - this.timeBegin)/(1000*this.intervalDuration)); if (typeof(this.cells[i].graphics) === 'undefined'){ - this.initCell(this.cells[i]); + this.initCell(this.cells[i], colorsDef); } - if (typeof(this.annotCategories[0].colors[data.content.category.code]) !== 'undefined'){ + if (typeof(colorsDef.colors[data.content.category.code]) !== 'undefined'){ var annotCode = data.content.category.code; } else { var annotCode = 'default'; @@ -100,7 +109,7 @@ this.cells[i].categories[annotCode].count += 1; this.cells[i].totalAnnots +=1; - this.redrawCell(this.cells[i], i); + this.redrawCell(this.cells[i], colorsDef); } }; @@ -134,7 +143,7 @@ } //Draw the cellule - this.redrawCell = function(cell){ + this.redrawCell = function(cell, colorsDef){ var y = 0; @@ -146,8 +155,8 @@ } //Draw the rect depending on the height step calculated - for (var i=0; i< this.annotCategories[0].order.length; i++){ - var currentCode = this.annotCategories[0].order[i]; + for (var i=0; i< colorsDef.order.length; i++){ + var currentCode = colorsDef.order[i]; cell.graphics.beginFill(cell.categories[currentCode].color.replace("#", "0x")) .drawRect(0, y, this.intervalWidth-1, -cell.categories[currentCode].count * heightStep) .endFill(); @@ -155,22 +164,22 @@ } } - this.initCell = function(cell){ + this.initCell = function(cell, colorsDef){ 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){ + for (var category in colorsDef.colors){ cell.categories[category] = { "count": 0, - "color": this.annotCategories[0].colors[category] + "color": colorsDef.colors[category] }; } cell.categories['default'] = { "count": 0, - "color": this.annotCategories[0].defaultColor + "color": colorsDef.defaultColor } }