45 this.startTs = opts.startTs || Date.now(); |
45 this.startTs = opts.startTs || Date.now(); |
46 this.ignoreAnnots = opts.ignoreAnnots; |
46 this.ignoreAnnots = opts.ignoreAnnots; |
47 |
47 |
48 var yInit = opts.yInit; |
48 var yInit = opts.yInit; |
49 var annotStyles = _(opts.annotStyles).defaults(defaultAnnotStyles).value(); |
49 var annotStyles = _(opts.annotStyles).defaults(defaultAnnotStyles).value(); |
|
50 var marginX = 15; |
50 for(var style in annotStyles) { |
51 for(var style in annotStyles) { |
51 if (annotStyles[style].wordWrap === true){ |
52 if (annotStyles[style].wordWrap === true){ |
52 annotStyles[style].wordWrapWidth = this.widthRoll; |
53 annotStyles[style].wordWrapWidth = this.widthRoll - marginX; |
53 } |
54 } |
54 } |
55 } |
55 var started = false; |
56 var started = false; |
56 var ws = opts.ws; |
57 var ws = opts.ws; |
57 var externalRefresh = opts.externalRefresh; |
58 var externalRefresh = opts.externalRefresh; |
83 }; |
84 }; |
84 |
85 |
85 this.getColor = function(ts, code) { |
86 this.getColor = function(ts, code) { |
86 var colorsDef; |
87 var colorsDef; |
87 _(this.annotColors).eachRight(function(cdef) { |
88 _(this.annotColors).eachRight(function(cdef) { |
88 console.log("cDef", cdef); |
|
89 console.log("cDef ts", cdef.ts, ts); |
|
90 if(cdef.ts < ts) { |
89 if(cdef.ts < ts) { |
91 colorsDef = cdef.colors; |
90 colorsDef = cdef.colors; |
92 return false; |
91 return false; |
93 } |
92 } |
94 }); |
93 }); |
95 var resColor; |
94 var resColor; |
96 console.log("colorsDef", colorsDef); |
|
97 if(colorsDef) { |
95 if(colorsDef) { |
98 resColor = colorsDef[code]; |
96 resColor = colorsDef[code]; |
99 } |
97 } |
100 if(!resColor) { |
98 if(!resColor) { |
101 resColor = DEFAULT_ANNOT_COLOR; |
99 resColor = DEFAULT_ANNOT_COLOR; |
122 var textHeight = 0; |
120 var textHeight = 0; |
123 var catLabel = new PIXI.Text( |
121 var catLabel = new PIXI.Text( |
124 category, |
122 category, |
125 _(annotStyles.label).extend({fill: color}).value() |
123 _(annotStyles.label).extend({fill: color}).value() |
126 ); |
124 ); |
127 catLabel.x = x + 20; |
125 catLabel.x = x + marginX; |
128 catLabel.y = y - 23; |
126 catLabel.y = y - 23; |
129 this.container.addChild(catLabel); |
127 this.container.addChild(catLabel); |
130 textHeight += (catLabel.height - 23 + 2); |
128 textHeight += (catLabel.height - 23 + 2); |
131 |
129 |
132 if(text) { |
130 if(text) { |
133 var catText = new PIXI.Text(text, annotStyles.text); |
131 var catText = new PIXI.Text(text, annotStyles.text); |
134 catText.x = x + 20; |
132 catText.x = x + marginX; |
135 catText.y = y + textHeight; |
133 catText.y = y + textHeight; |
136 this.container.addChild(catText); |
134 this.container.addChild(catText); |
137 textHeight += (catText.height + 2); |
135 textHeight += (catText.height + 2); |
138 } |
136 } |
139 |
137 |
140 var catUser = new PIXI.Text(user, annotStyles.user); |
138 var catUser = new PIXI.Text(user, annotStyles.user); |
141 catUser.x = x + 20; |
139 catUser.x = x + marginX; |
142 catUser.y = y + textHeight; |
140 catUser.y = y + textHeight; |
143 this.container.addChild(catUser); |
141 this.container.addChild(catUser); |
144 textHeight += (catUser.height + 8); |
142 textHeight += (catUser.height + 8); |
145 |
143 |
146 if (this.ignoreAnnots === true){ |
144 if (this.ignoreAnnots === true){ |