| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
(function($) { |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
$.jqplot.CategoryAxisRenderer = function(options) { |
| 44 |
$.jqplot.LinearAxisRenderer.call(this); |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
this.sortMergedLabels = false; |
| 62 |
}; |
| 63 |
|
| 64 |
$.jqplot.CategoryAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); |
| 65 |
$.jqplot.CategoryAxisRenderer.prototype.constructor = $.jqplot.CategoryAxisRenderer; |
| 66 |
|
| 67 |
$.jqplot.CategoryAxisRenderer.prototype.init = function(options){ |
| 68 |
this.groups = 1; |
| 69 |
this.groupLabels = []; |
| 70 |
this._groupLabels = []; |
| 71 |
this._grouped = false; |
| 72 |
this._barsPerGroup = null; |
| 73 |
this.reverse = false; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
$.extend(true, this, {tickOptions:{formatString:'%d'}}, options); |
| 80 |
var db = this._dataBounds; |
| 81 |
|
| 82 |
|
| 83 |
for (var i=0; i<this._series.length; i++) { |
| 84 |
var s = this._series[i]; |
| 85 |
if (s.groups) { |
| 86 |
this.groups = s.groups; |
| 87 |
} |
| 88 |
var d = s.data; |
| 89 |
|
| 90 |
for (var j=0; j<d.length; j++) { |
| 91 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 92 |
if (d[j][0] < db.min || db.min == null) { |
| 93 |
db.min = d[j][0]; |
| 94 |
} |
| 95 |
if (d[j][0] > db.max || db.max == null) { |
| 96 |
db.max = d[j][0]; |
| 97 |
} |
| 98 |
} |
| 99 |
else { |
| 100 |
if (d[j][1] < db.min || db.min == null) { |
| 101 |
db.min = d[j][1]; |
| 102 |
} |
| 103 |
if (d[j][1] > db.max || db.max == null) { |
| 104 |
db.max = d[j][1]; |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
if (this.groupLabels.length) { |
| 111 |
this.groups = this.groupLabels.length; |
| 112 |
} |
| 113 |
}; |
| 114 |
|
| 115 |
|
| 116 |
$.jqplot.CategoryAxisRenderer.prototype.createTicks = function() { |
| 117 |
|
| 118 |
var ticks = this._ticks; |
| 119 |
var userTicks = this.ticks; |
| 120 |
var name = this.name; |
| 121 |
|
| 122 |
var db = this._dataBounds; |
| 123 |
var dim, interval; |
| 124 |
var min, max; |
| 125 |
var pos1, pos2; |
| 126 |
var tt, i; |
| 127 |
|
| 128 |
|
| 129 |
if (userTicks.length) { |
| 130 |
|
| 131 |
if (this.groups > 1 && !this._grouped) { |
| 132 |
var l = userTicks.length; |
| 133 |
var skip = parseInt(l/this.groups, 10); |
| 134 |
var count = 0; |
| 135 |
for (var i=skip; i<l; i+=skip) { |
| 136 |
userTicks.splice(i+count, 0, ' '); |
| 137 |
count++; |
| 138 |
} |
| 139 |
this._grouped = true; |
| 140 |
} |
| 141 |
this.min = 0.5; |
| 142 |
this.max = userTicks.length + 0.5; |
| 143 |
var range = this.max - this.min; |
| 144 |
this.numberTicks = 2*userTicks.length + 1; |
| 145 |
for (i=0; i<userTicks.length; i++){ |
| 146 |
tt = this.min + 2 * i * range / (this.numberTicks-1); |
| 147 |
|
| 148 |
var t = new this.tickRenderer(this.tickOptions); |
| 149 |
t.showLabel = false; |
| 150 |
|
| 151 |
t.setTick(tt, this.name); |
| 152 |
this._ticks.push(t); |
| 153 |
var t = new this.tickRenderer(this.tickOptions); |
| 154 |
t.label = userTicks[i]; |
| 155 |
|
| 156 |
t.showMark = false; |
| 157 |
t.showGridline = false; |
| 158 |
t.setTick(tt+0.5, this.name); |
| 159 |
this._ticks.push(t); |
| 160 |
} |
| 161 |
|
| 162 |
var t = new this.tickRenderer(this.tickOptions); |
| 163 |
t.showLabel = false; |
| 164 |
|
| 165 |
t.setTick(tt+1, this.name); |
| 166 |
this._ticks.push(t); |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
else { |
| 171 |
if (name == 'xaxis' || name == 'x2axis') { |
| 172 |
dim = this._plotDimensions.width; |
| 173 |
} |
| 174 |
else { |
| 175 |
dim = this._plotDimensions.height; |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
if (this.min != null && this.max != null && this.numberTicks != null) { |
| 180 |
this.tickInterval = null; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
if (this.min != null && this.max != null && this.tickInterval != null) { |
| 185 |
if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) { |
| 186 |
this.tickInterval = null; |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
var labels = []; |
| 192 |
var numcats = 0; |
| 193 |
var min = 0.5; |
| 194 |
var max, val; |
| 195 |
var isMerged = false; |
| 196 |
for (var i=0; i<this._series.length; i++) { |
| 197 |
var s = this._series[i]; |
| 198 |
for (var j=0; j<s.data.length; j++) { |
| 199 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 200 |
val = s.data[j][0]; |
| 201 |
} |
| 202 |
else { |
| 203 |
val = s.data[j][1]; |
| 204 |
} |
| 205 |
if ($.inArray(val, labels) == -1) { |
| 206 |
isMerged = true; |
| 207 |
numcats += 1; |
| 208 |
labels.push(val); |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
if (isMerged && this.sortMergedLabels) { |
| 214 |
if (typeof labels[0] == "string") { |
| 215 |
labels.sort(); |
| 216 |
} else { |
| 217 |
labels.sort(function(a,b) { return a - b; }); |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
this.ticks = labels; |
| 223 |
|
| 224 |
|
| 225 |
for (var i=0; i<this._series.length; i++) { |
| 226 |
var s = this._series[i]; |
| 227 |
for (var j=0; j<s.data.length; j++) { |
| 228 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 229 |
val = s.data[j][0]; |
| 230 |
} |
| 231 |
else { |
| 232 |
val = s.data[j][1]; |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
var idx = $.inArray(val, labels)+1; |
| 237 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 238 |
s.data[j][0] = idx; |
| 239 |
} |
| 240 |
else { |
| 241 |
s.data[j][1] = idx; |
| 242 |
} |
| 243 |
} |
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
if (this.groups > 1 && !this._grouped) { |
| 248 |
var l = labels.length; |
| 249 |
var skip = parseInt(l/this.groups, 10); |
| 250 |
var count = 0; |
| 251 |
for (var i=skip; i<l; i+=skip+1) { |
| 252 |
labels[i] = ' '; |
| 253 |
} |
| 254 |
this._grouped = true; |
| 255 |
} |
| 256 |
|
| 257 |
max = numcats + 0.5; |
| 258 |
if (this.numberTicks == null) { |
| 259 |
this.numberTicks = 2*numcats + 1; |
| 260 |
} |
| 261 |
|
| 262 |
var range = max - min; |
| 263 |
this.min = min; |
| 264 |
this.max = max; |
| 265 |
var track = 0; |
| 266 |
|
| 267 |
|
| 268 |
var maxVisibleTicks = parseInt(3+dim/10, 10); |
| 269 |
var skip = parseInt(numcats/maxVisibleTicks, 10); |
| 270 |
|
| 271 |
if (this.tickInterval == null) { |
| 272 |
|
| 273 |
this.tickInterval = range / (this.numberTicks-1); |
| 274 |
|
| 275 |
} |
| 276 |
|
| 277 |
for (var i=0; i<this.numberTicks; i++){ |
| 278 |
tt = this.min + i * this.tickInterval; |
| 279 |
var t = new this.tickRenderer(this.tickOptions); |
| 280 |
|
| 281 |
if (i/2 == parseInt(i/2, 10)) { |
| 282 |
t.showLabel = false; |
| 283 |
t.showMark = true; |
| 284 |
} |
| 285 |
else { |
| 286 |
if (skip>0 && track<skip) { |
| 287 |
t.showLabel = false; |
| 288 |
track += 1; |
| 289 |
} |
| 290 |
else { |
| 291 |
t.showLabel = true; |
| 292 |
track = 0; |
| 293 |
} |
| 294 |
t.label = t.formatter(t.formatString, labels[(i-1)/2]); |
| 295 |
t.showMark = false; |
| 296 |
t.showGridline = false; |
| 297 |
} |
| 298 |
t.setTick(tt, this.name); |
| 299 |
this._ticks.push(t); |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
}; |
| 304 |
|
| 305 |
|
| 306 |
$.jqplot.CategoryAxisRenderer.prototype.draw = function(ctx, plot) { |
| 307 |
if (this.show) { |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
this.renderer.createTicks.call(this); |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
var dim=0; |
| 316 |
var temp; |
| 317 |
|
| 318 |
if (this._elem) { |
| 319 |
|
| 320 |
|
| 321 |
this._elem.emptyForce(); |
| 322 |
} |
| 323 |
|
| 324 |
this._elem = this._elem || $('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>'); |
| 325 |
|
| 326 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 327 |
this._elem.width(this._plotDimensions.width); |
| 328 |
} |
| 329 |
else { |
| 330 |
this._elem.height(this._plotDimensions.height); |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
this.labelOptions.axis = this.name; |
| 335 |
this._label = new this.labelRenderer(this.labelOptions); |
| 336 |
if (this._label.show) { |
| 337 |
var elem = this._label.draw(ctx, plot); |
| 338 |
elem.appendTo(this._elem); |
| 339 |
} |
| 340 |
|
| 341 |
var t = this._ticks; |
| 342 |
for (var i=0; i<t.length; i++) { |
| 343 |
var tick = t[i]; |
| 344 |
if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { |
| 345 |
var elem = tick.draw(ctx, plot); |
| 346 |
elem.appendTo(this._elem); |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
this._groupLabels = []; |
| 351 |
|
| 352 |
for (var i=0; i<this.groupLabels.length; i++) |
| 353 |
{ |
| 354 |
var elem = $('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>'); |
| 355 |
elem.html(this.groupLabels[i]); |
| 356 |
this._groupLabels.push(elem); |
| 357 |
elem.appendTo(this._elem); |
| 358 |
} |
| 359 |
} |
| 360 |
return this._elem; |
| 361 |
}; |
| 362 |
|
| 363 |
|
| 364 |
$.jqplot.CategoryAxisRenderer.prototype.set = function() { |
| 365 |
var dim = 0; |
| 366 |
var temp; |
| 367 |
var w = 0; |
| 368 |
var h = 0; |
| 369 |
var lshow = (this._label == null) ? false : this._label.show; |
| 370 |
if (this.show) { |
| 371 |
var t = this._ticks; |
| 372 |
for (var i=0; i<t.length; i++) { |
| 373 |
var tick = t[i]; |
| 374 |
if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { |
| 375 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 376 |
temp = tick._elem.outerHeight(true); |
| 377 |
} |
| 378 |
else { |
| 379 |
temp = tick._elem.outerWidth(true); |
| 380 |
} |
| 381 |
if (temp > dim) { |
| 382 |
dim = temp; |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
var dim2 = 0; |
| 388 |
for (var i=0; i<this._groupLabels.length; i++) { |
| 389 |
var l = this._groupLabels[i]; |
| 390 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 391 |
temp = l.outerHeight(true); |
| 392 |
} |
| 393 |
else { |
| 394 |
temp = l.outerWidth(true); |
| 395 |
} |
| 396 |
if (temp > dim2) { |
| 397 |
dim2 = temp; |
| 398 |
} |
| 399 |
} |
| 400 |
|
| 401 |
if (lshow) { |
| 402 |
w = this._label._elem.outerWidth(true); |
| 403 |
h = this._label._elem.outerHeight(true); |
| 404 |
} |
| 405 |
if (this.name == 'xaxis') { |
| 406 |
dim += dim2 + h; |
| 407 |
this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'}); |
| 408 |
} |
| 409 |
else if (this.name == 'x2axis') { |
| 410 |
dim += dim2 + h; |
| 411 |
this._elem.css({'height':dim+'px', left:'0px', top:'0px'}); |
| 412 |
} |
| 413 |
else if (this.name == 'yaxis') { |
| 414 |
dim += dim2 + w; |
| 415 |
this._elem.css({'width':dim+'px', left:'0px', top:'0px'}); |
| 416 |
if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { |
| 417 |
this._label._elem.css('width', w+'px'); |
| 418 |
} |
| 419 |
} |
| 420 |
else { |
| 421 |
dim += dim2 + w; |
| 422 |
this._elem.css({'width':dim+'px', right:'0px', top:'0px'}); |
| 423 |
if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { |
| 424 |
this._label._elem.css('width', w+'px'); |
| 425 |
} |
| 426 |
} |
| 427 |
} |
| 428 |
}; |
| 429 |
|
| 430 |
|
| 431 |
$.jqplot.CategoryAxisRenderer.prototype.pack = function(pos, offsets) { |
| 432 |
var ticks = this._ticks; |
| 433 |
var max = this.max; |
| 434 |
var min = this.min; |
| 435 |
var offmax = offsets.max; |
| 436 |
var offmin = offsets.min; |
| 437 |
var lshow = (this._label == null) ? false : this._label.show; |
| 438 |
var i; |
| 439 |
|
| 440 |
for (var p in pos) { |
| 441 |
this._elem.css(p, pos[p]); |
| 442 |
} |
| 443 |
|
| 444 |
this._offsets = offsets; |
| 445 |
|
| 446 |
var pixellength = offmax - offmin; |
| 447 |
var unitlength = max - min; |
| 448 |
|
| 449 |
if (!this.reverse) { |
| 450 |
|
| 451 |
|
| 452 |
this.u2p = function(u){ |
| 453 |
return (u - min) * pixellength / unitlength + offmin; |
| 454 |
}; |
| 455 |
|
| 456 |
this.p2u = function(p){ |
| 457 |
return (p - offmin) * unitlength / pixellength + min; |
| 458 |
}; |
| 459 |
|
| 460 |
if (this.name == 'xaxis' || this.name == 'x2axis'){ |
| 461 |
this.series_u2p = function(u){ |
| 462 |
return (u - min) * pixellength / unitlength; |
| 463 |
}; |
| 464 |
this.series_p2u = function(p){ |
| 465 |
return p * unitlength / pixellength + min; |
| 466 |
}; |
| 467 |
} |
| 468 |
|
| 469 |
else { |
| 470 |
this.series_u2p = function(u){ |
| 471 |
return (u - max) * pixellength / unitlength; |
| 472 |
}; |
| 473 |
this.series_p2u = function(p){ |
| 474 |
return p * unitlength / pixellength + max; |
| 475 |
}; |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
else { |
| 480 |
|
| 481 |
|
| 482 |
this.u2p = function(u){ |
| 483 |
return offmin + (max - u) * pixellength / unitlength; |
| 484 |
}; |
| 485 |
|
| 486 |
this.p2u = function(p){ |
| 487 |
return min + (p - offmin) * unitlength / pixellength; |
| 488 |
}; |
| 489 |
|
| 490 |
if (this.name == 'xaxis' || this.name == 'x2axis'){ |
| 491 |
this.series_u2p = function(u){ |
| 492 |
return (max - u) * pixellength / unitlength; |
| 493 |
}; |
| 494 |
this.series_p2u = function(p){ |
| 495 |
return p * unitlength / pixellength + max; |
| 496 |
}; |
| 497 |
} |
| 498 |
|
| 499 |
else { |
| 500 |
this.series_u2p = function(u){ |
| 501 |
return (min - u) * pixellength / unitlength; |
| 502 |
}; |
| 503 |
this.series_p2u = function(p){ |
| 504 |
return p * unitlength / pixellength + min; |
| 505 |
}; |
| 506 |
} |
| 507 |
|
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
if (this.show) { |
| 512 |
if (this.name == 'xaxis' || this.name == 'x2axis') { |
| 513 |
for (i=0; i<ticks.length; i++) { |
| 514 |
var t = ticks[i]; |
| 515 |
if (t.show && t.showLabel) { |
| 516 |
var shim; |
| 517 |
|
| 518 |
if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { |
| 519 |
|
| 520 |
var temp = (this.name == 'xaxis') ? 1 : -1; |
| 521 |
switch (t.labelPosition) { |
| 522 |
case 'auto': |
| 523 |
|
| 524 |
if (temp * t.angle < 0) { |
| 525 |
shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| 526 |
} |
| 527 |
|
| 528 |
else { |
| 529 |
shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; |
| 530 |
} |
| 531 |
break; |
| 532 |
case 'end': |
| 533 |
shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| 534 |
break; |
| 535 |
case 'start': |
| 536 |
shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; |
| 537 |
break; |
| 538 |
case 'middle': |
| 539 |
shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| 540 |
break; |
| 541 |
default: |
| 542 |
shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| 543 |
break; |
| 544 |
} |
| 545 |
} |
| 546 |
else { |
| 547 |
shim = -t.getWidth()/2; |
| 548 |
} |
| 549 |
var val = this.u2p(t.value) + shim + 'px'; |
| 550 |
t._elem.css('left', val); |
| 551 |
t.pack(); |
| 552 |
} |
| 553 |
} |
| 554 |
|
| 555 |
var labeledge=['bottom', 0]; |
| 556 |
if (lshow) { |
| 557 |
var w = this._label._elem.outerWidth(true); |
| 558 |
this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px'); |
| 559 |
if (this.name == 'xaxis') { |
| 560 |
this._label._elem.css('bottom', '0px'); |
| 561 |
labeledge = ['bottom', this._label._elem.outerHeight(true)]; |
| 562 |
} |
| 563 |
else { |
| 564 |
this._label._elem.css('top', '0px'); |
| 565 |
labeledge = ['top', this._label._elem.outerHeight(true)]; |
| 566 |
} |
| 567 |
this._label.pack(); |
| 568 |
} |
| 569 |
|
| 570 |
|
| 571 |
var step = parseInt(this._ticks.length/this.groups, 10) + 1; |
| 572 |
for (i=0; i<this._groupLabels.length; i++) { |
| 573 |
var mid = 0; |
| 574 |
var count = 0; |
| 575 |
for (var j=i*step; j<(i+1)*step; j++) { |
| 576 |
if (j >= this._ticks.length-1) continue; |
| 577 |
if (this._ticks[j]._elem && this._ticks[j].label != " ") { |
| 578 |
var t = this._ticks[j]._elem; |
| 579 |
var p = t.position(); |
| 580 |
mid += p.left + t.outerWidth(true)/2; |
| 581 |
count++; |
| 582 |
} |
| 583 |
} |
| 584 |
mid = mid/count; |
| 585 |
this._groupLabels[i].css({'left':(mid - this._groupLabels[i].outerWidth(true)/2)}); |
| 586 |
this._groupLabels[i].css(labeledge[0], labeledge[1]); |
| 587 |
} |
| 588 |
} |
| 589 |
else { |
| 590 |
for (i=0; i<ticks.length; i++) { |
| 591 |
var t = ticks[i]; |
| 592 |
if (t.show && t.showLabel) { |
| 593 |
var shim; |
| 594 |
if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { |
| 595 |
|
| 596 |
var temp = (this.name == 'yaxis') ? 1 : -1; |
| 597 |
switch (t.labelPosition) { |
| 598 |
case 'auto': |
| 599 |
|
| 600 |
case 'end': |
| 601 |
if (temp * t.angle < 0) { |
| 602 |
shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; |
| 603 |
} |
| 604 |
else { |
| 605 |
shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; |
| 606 |
} |
| 607 |
break; |
| 608 |
case 'start': |
| 609 |
if (t.angle > 0) { |
| 610 |
shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; |
| 611 |
} |
| 612 |
else { |
| 613 |
shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; |
| 614 |
} |
| 615 |
break; |
| 616 |
case 'middle': |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
shim = -t.getHeight()/2; |
| 624 |
break; |
| 625 |
default: |
| 626 |
shim = -t.getHeight()/2; |
| 627 |
break; |
| 628 |
} |
| 629 |
} |
| 630 |
else { |
| 631 |
shim = -t.getHeight()/2; |
| 632 |
} |
| 633 |
|
| 634 |
var val = this.u2p(t.value) + shim + 'px'; |
| 635 |
t._elem.css('top', val); |
| 636 |
t.pack(); |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
var labeledge=['left', 0]; |
| 641 |
if (lshow) { |
| 642 |
var h = this._label._elem.outerHeight(true); |
| 643 |
this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px'); |
| 644 |
if (this.name == 'yaxis') { |
| 645 |
this._label._elem.css('left', '0px'); |
| 646 |
labeledge = ['left', this._label._elem.outerWidth(true)]; |
| 647 |
} |
| 648 |
else { |
| 649 |
this._label._elem.css('right', '0px'); |
| 650 |
labeledge = ['right', this._label._elem.outerWidth(true)]; |
| 651 |
} |
| 652 |
this._label.pack(); |
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
var step = parseInt(this._ticks.length/this.groups, 10) + 1; |
| 657 |
for (i=0; i<this._groupLabels.length; i++) { |
| 658 |
var mid = 0; |
| 659 |
var count = 0; |
| 660 |
for (var j=i*step; j<(i+1)*step; j++) { |
| 661 |
if (j >= this._ticks.length-1) continue; |
| 662 |
if (this._ticks[j]._elem && this._ticks[j].label != " ") { |
| 663 |
var t = this._ticks[j]._elem; |
| 664 |
var p = t.position(); |
| 665 |
mid += p.top + t.outerHeight()/2; |
| 666 |
count++; |
| 667 |
} |
| 668 |
} |
| 669 |
mid = mid/count; |
| 670 |
this._groupLabels[i].css({'top':mid - this._groupLabels[i].outerHeight()/2}); |
| 671 |
this._groupLabels[i].css(labeledge[0], labeledge[1]); |
| 672 |
|
| 673 |
} |
| 674 |
} |
| 675 |
} |
| 676 |
}; |
| 677 |
|
| 678 |
|
| 679 |
})(jQuery); |