| 1 |
dojo.provide("dojox.widget.DataPresentation"); |
| 2 |
dojo.experimental("dojox.widget.DataPresentation"); |
| 3 |
|
| 4 |
dojo.require("dojox.grid.DataGrid"); |
| 5 |
dojo.require("dojox.charting.Chart2D"); |
| 6 |
dojo.require("dojox.charting.widget.Legend"); |
| 7 |
dojo.require("dojox.charting.action2d.Tooltip"); |
| 8 |
dojo.require("dojox.charting.action2d.Highlight"); |
| 9 |
dojo.require("dojo.colors"); |
| 10 |
dojo.require("dojo.data.ItemFileWriteStore"); |
| 11 |
|
| 12 |
(function(){ |
| 13 |
|
| 14 |
|
| 15 |
var getLabels = function(range, labelMod, charttype, domNode){ |
| 16 |
|
| 17 |
|
| 18 |
var labels = []; |
| 19 |
|
| 20 |
labels[0] = {value: 0, text: ''}; |
| 21 |
|
| 22 |
var nlabels = range.length; |
| 23 |
|
| 24 |
|
| 25 |
if((charttype !== "ClusteredBars") && (charttype !== "StackedBars")){ |
| 26 |
var cwid = domNode.offsetWidth; |
| 27 |
var tmp = ("" + range[0]).length * range.length * 7; |
| 28 |
|
| 29 |
if(labelMod == 1){ |
| 30 |
for(var z = 1; z < 500; ++z){ |
| 31 |
if((tmp / z) < cwid){ |
| 32 |
break; |
| 33 |
} |
| 34 |
++labelMod; |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
for(var i = 0; i < nlabels; i++){ |
| 41 |
|
| 42 |
labels.push({ |
| 43 |
value: i + 1, |
| 44 |
text: (!labelMod || i % labelMod) ? "" : range[i] |
| 45 |
}); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
labels.push({value: nlabels + 1, text:''}); |
| 50 |
|
| 51 |
return labels; |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
var getIndependentAxisArgs = function(charttype, labels){ |
| 56 |
|
| 57 |
var args = { vertical: false, labels: labels, min: 0, max: labels.length-1, majorTickStep: 1, minorTickStep: 1 }; |
| 58 |
|
| 59 |
|
| 60 |
if((charttype === "ClusteredBars") || (charttype === "StackedBars")){ |
| 61 |
args.vertical = true; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
if((charttype === "Lines") || (charttype === "Areas") || (charttype === "StackedAreas")){ |
| 66 |
args.min++; |
| 67 |
args.max--; |
| 68 |
} |
| 69 |
|
| 70 |
return args; |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
var getDependentAxisArgs = function(charttype, axistype, minval, maxval){ |
| 75 |
|
| 76 |
var args = { vertical: true, fixLower: "major", fixUpper: "major", natural: true }; |
| 77 |
|
| 78 |
|
| 79 |
if(axistype === "secondary"){ |
| 80 |
args.leftBottom = false; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
if((charttype === "ClusteredBars") || (charttype === "StackedBars")){ |
| 85 |
args.vertical = false; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
if(minval == maxval){ |
| 90 |
args.min = minval - 1; |
| 91 |
args.max = maxval + 1; |
| 92 |
} |
| 93 |
|
| 94 |
return args; |
| 95 |
}; |
| 96 |
|
| 97 |
|
| 98 |
var getPlotArgs = function(charttype, axistype, animate){ |
| 99 |
|
| 100 |
var args = { type: charttype, hAxis: "independent", vAxis: "dependent-" + axistype, gap: 4, lines: false, areas: false, markers: false }; |
| 101 |
|
| 102 |
|
| 103 |
if((charttype === "ClusteredBars") || (charttype === "StackedBars")){ |
| 104 |
args.hAxis = args.vAxis; |
| 105 |
args.vAxis = "independent"; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
if((charttype === "Lines") || (charttype === "Hybrid-Lines") || (charttype === "Areas") || (charttype === "StackedAreas")){ |
| 110 |
args.lines = true; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
if((charttype === "Areas") || (charttype === "StackedAreas")){ |
| 115 |
args.areas = true; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
if(charttype === "Lines"){ |
| 120 |
args.markers = true; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
if(charttype === "Hybrid-Lines"){ |
| 126 |
args.shadows = {dx: 2, dy: 2, dw: 2}; |
| 127 |
args.type = "Lines"; |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
if(charttype === "Hybrid-ClusteredColumns"){ |
| 132 |
args.type = "ClusteredColumns"; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
if(animate){ |
| 137 |
args.animate = animate; |
| 138 |
} |
| 139 |
|
| 140 |
return args; |
| 141 |
}; |
| 142 |
|
| 143 |
|
| 144 |
var setupChart = function(domNode, chart, type, reverse, animate, labelMod, theme, tooltip, store, query, queryOptions){ |
| 145 |
var _chart = chart; |
| 146 |
|
| 147 |
if(!_chart){ |
| 148 |
domNode.innerHTML = ""; |
| 149 |
_chart = new dojox.charting.Chart2D(domNode); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
if(theme){ |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
theme._clone = function(){ |
| 160 |
var result = new dojox.charting.Theme({ |
| 161 |
chart: this.chart, |
| 162 |
plotarea: this.plotarea, |
| 163 |
axis: this.axis, |
| 164 |
series: this.series, |
| 165 |
marker: this.marker, |
| 166 |
antiAlias: this.antiAlias, |
| 167 |
assignColors: this.assignColors, |
| 168 |
assignMarkers: this.assigneMarkers, |
| 169 |
colors: dojo.delegate(this.colors) |
| 170 |
}); |
| 171 |
|
| 172 |
result.markers = this.markers; |
| 173 |
result._buildMarkerArray(); |
| 174 |
|
| 175 |
return result; |
| 176 |
}; |
| 177 |
|
| 178 |
_chart.setTheme(theme); |
| 179 |
} |
| 180 |
|
| 181 |
var range = store.series_data[0].slice(0); |
| 182 |
|
| 183 |
|
| 184 |
if(reverse){ |
| 185 |
range.reverse(); |
| 186 |
} |
| 187 |
|
| 188 |
var labels = getLabels(range, labelMod, type, domNode); |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
var plots = {}; |
| 193 |
|
| 194 |
|
| 195 |
var maxval = null; |
| 196 |
var minval = null; |
| 197 |
|
| 198 |
var seriestoremove = {}; |
| 199 |
for(var sname in _chart.runs){ |
| 200 |
seriestoremove[sname] = true; |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
var nseries = store.series_name.length; |
| 205 |
for(var i = 0; i < nseries; i++){ |
| 206 |
|
| 207 |
if(store.series_chart[i] && (store.series_data[i].length > 0)){ |
| 208 |
|
| 209 |
var charttype = type; |
| 210 |
var axistype = store.series_axis[i]; |
| 211 |
|
| 212 |
if(charttype == "Hybrid"){ |
| 213 |
if(store.series_charttype[i] == 'line'){ |
| 214 |
charttype = "Hybrid-Lines"; |
| 215 |
}else{ |
| 216 |
charttype = "Hybrid-ClusteredColumns"; |
| 217 |
} |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
if(!plots[axistype]){ |
| 222 |
plots[axistype] = {}; |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
if(!plots[axistype][charttype]){ |
| 227 |
var axisname = axistype + "-" + charttype; |
| 228 |
|
| 229 |
|
| 230 |
_chart.addPlot(axisname, getPlotArgs(charttype, axistype, animate)); |
| 231 |
|
| 232 |
var tooltipArgs = {}; |
| 233 |
if(typeof tooltip == 'string'){ |
| 234 |
tooltipArgs.text = function(o){ |
| 235 |
var substitutions = [o.element, o.run.name, range[o.index], ((charttype === "ClusteredBars") || (charttype === "StackedBars")) ? o.x : o.y]; |
| 236 |
return dojo.replace(tooltip, substitutions); |
| 237 |
|
| 238 |
} |
| 239 |
}else if(typeof tooltip == 'function'){ |
| 240 |
tooltipArgs.text = tooltip; |
| 241 |
} |
| 242 |
new dojox.charting.action2d.Tooltip(_chart, axisname, tooltipArgs); |
| 243 |
|
| 244 |
|
| 245 |
if(charttype !== "Lines" && charttype !== "Hybrid-Lines"){ |
| 246 |
new dojox.charting.action2d.Highlight(_chart, axisname); |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
plots[axistype][charttype] = true; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
var xvals = []; |
| 255 |
var valen = store.series_data[i].length; |
| 256 |
for(var j = 0; j < valen; j++){ |
| 257 |
var val = store.series_data[i][j]; |
| 258 |
xvals.push(val); |
| 259 |
if(maxval === null || val > maxval){ |
| 260 |
maxval = val; |
| 261 |
} |
| 262 |
if(minval === null || val < minval){ |
| 263 |
minval = val; |
| 264 |
} |
| 265 |
} |
| 266 |
|
| 267 |
|
| 268 |
if(reverse){ |
| 269 |
xvals.reverse(); |
| 270 |
} |
| 271 |
|
| 272 |
var seriesargs = { plot: axistype + "-" + charttype }; |
| 273 |
if(store.series_linestyle[i]){ |
| 274 |
seriesargs.stroke = { style: store.series_linestyle[i] }; |
| 275 |
} |
| 276 |
|
| 277 |
_chart.addSeries(store.series_name[i], xvals, seriesargs); |
| 278 |
delete seriestoremove[store.series_name[i]]; |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
for(sname in seriestoremove){ |
| 284 |
_chart.removeSeries(sname); |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
_chart.addAxis("independent", getIndependentAxisArgs(type, labels)); |
| 289 |
_chart.addAxis("dependent-primary", getDependentAxisArgs(type, "primary", minval, maxval)); |
| 290 |
_chart.addAxis("dependent-secondary", getDependentAxisArgs(type, "secondary", minval, maxval)); |
| 291 |
|
| 292 |
return _chart; |
| 293 |
}; |
| 294 |
|
| 295 |
|
| 296 |
var setupLegend = function(domNode, legend, chart, horizontal){ |
| 297 |
|
| 298 |
var _legend = legend; |
| 299 |
|
| 300 |
if(!_legend){ |
| 301 |
_legend = new dojox.charting.widget.Legend({ chart: chart, horizontal: horizontal }, domNode); |
| 302 |
}else{ |
| 303 |
_legend.refresh(); |
| 304 |
} |
| 305 |
|
| 306 |
return _legend; |
| 307 |
}; |
| 308 |
|
| 309 |
|
| 310 |
var setupGrid = function(domNode, grid, store, query, queryOptions){ |
| 311 |
var _grid = grid || new dojox.grid.DataGrid({}, domNode); |
| 312 |
_grid.startup(); |
| 313 |
_grid.setStore(store, query, queryOptions); |
| 314 |
|
| 315 |
var structure = []; |
| 316 |
for(var ser = 0; ser < store.series_name.length; ser++){ |
| 317 |
|
| 318 |
if(store.series_grid[ser] && (store.series_data[ser].length > 0)){ |
| 319 |
structure.push({ field: "data." + ser, name: store.series_name[ser], width: "auto", formatter: store.series_gridformatter[ser] }); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
_grid.setStructure(structure); |
| 324 |
|
| 325 |
return _grid; |
| 326 |
}; |
| 327 |
|
| 328 |
|
| 329 |
var setupTitle = function(domNode, store){ |
| 330 |
if(store.title){ |
| 331 |
domNode.innerHTML = store.title; |
| 332 |
} |
| 333 |
}; |
| 334 |
|
| 335 |
|
| 336 |
var setupFooter = function(domNode, store){ |
| 337 |
if(store.footer){ |
| 338 |
domNode.innerHTML = store.footer; |
| 339 |
} |
| 340 |
}; |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
var getSubfield = function(object, field){ |
| 345 |
var result = object; |
| 346 |
|
| 347 |
if(field){ |
| 348 |
var fragments = field.split(/[.\[\]]+/); |
| 349 |
for(var frag = 0, l = fragments.length; frag < l; frag++){ |
| 350 |
if(result){ |
| 351 |
result = result[fragments[frag]]; |
| 352 |
} |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
return result; |
| 357 |
}; |
| 358 |
|
| 359 |
dojo.declare("dojox.widget.DataPresentation", null, { |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
type: "chart", |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
chartType: "clusteredBars", |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
reverse: false, |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
animate: null, |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
labelMod: 1, |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
legendHorizontal: true, |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
constructor: function(node, args){ |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
dojo.mixin(this, args); |
| 569 |
|
| 570 |
|
| 571 |
this.domNode = dojo.byId(node); |
| 572 |
|
| 573 |
|
| 574 |
this[this.type + "Node"] = this.domNode; |
| 575 |
|
| 576 |
|
| 577 |
if(typeof this.theme == 'string'){ |
| 578 |
this.theme = dojo.getObject(this.theme); |
| 579 |
} |
| 580 |
|
| 581 |
|
| 582 |
this.chartNode = dojo.byId(this.chartNode); |
| 583 |
this.legendNode = dojo.byId(this.legendNode); |
| 584 |
this.gridNode = dojo.byId(this.gridNode); |
| 585 |
this.titleNode = dojo.byId(this.titleNode); |
| 586 |
this.footerNode = dojo.byId(this.footerNode); |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
if(this.legendVertical){ |
| 591 |
this.legendHorizontal = !this.legendVertical; |
| 592 |
} |
| 593 |
|
| 594 |
if(this.url){ |
| 595 |
this.setURL(null, null, this.refreshInterval); |
| 596 |
} |
| 597 |
else{ |
| 598 |
if(this.data){ |
| 599 |
this.setData(null, this.refreshInterval); |
| 600 |
} |
| 601 |
else{ |
| 602 |
this.setStore(); |
| 603 |
} |
| 604 |
} |
| 605 |
}, |
| 606 |
|
| 607 |
setURL: function(url, urlContent, refreshInterval){ |
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
if(refreshInterval){ |
| 616 |
this.cancelRefresh(); |
| 617 |
} |
| 618 |
|
| 619 |
this.url = url || this.url; |
| 620 |
this.urlContent = urlContent || this.urlContent; |
| 621 |
this.refreshInterval = refreshInterval || this.refreshInterval; |
| 622 |
|
| 623 |
var me = this; |
| 624 |
|
| 625 |
dojo.xhrGet({ |
| 626 |
url: this.url, |
| 627 |
content: this.urlContent, |
| 628 |
handleAs: 'json-comment-optional', |
| 629 |
load: function(response, ioArgs){ |
| 630 |
me.setData(response); |
| 631 |
}, |
| 632 |
error: function(xhr, ioArgs){ |
| 633 |
if(me.urlError && (typeof me.urlError == "function")){ |
| 634 |
me.urlError(xhr, ioArgs); |
| 635 |
} |
| 636 |
} |
| 637 |
}); |
| 638 |
|
| 639 |
if(refreshInterval && (this.refreshInterval > 0)){ |
| 640 |
this.refreshIntervalPending = setInterval(function(){ |
| 641 |
me.setURL(); |
| 642 |
}, this.refreshInterval); |
| 643 |
} |
| 644 |
}, |
| 645 |
|
| 646 |
setData: function(data, refreshInterval){ |
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
if(refreshInterval){ |
| 654 |
this.cancelRefresh(); |
| 655 |
} |
| 656 |
|
| 657 |
this.data = data || this.data; |
| 658 |
this.refreshInterval = refreshInterval || this.refreshInterval; |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
var _series = (typeof this.series == 'function') ? this.series(this.data) : this.series; |
| 664 |
|
| 665 |
var datasets = [], |
| 666 |
series_data = [], |
| 667 |
series_name = [], |
| 668 |
series_chart = [], |
| 669 |
series_charttype = [], |
| 670 |
series_linestyle = [], |
| 671 |
series_axis = [], |
| 672 |
series_grid = [], |
| 673 |
series_gridformatter = [], |
| 674 |
maxlen = 0; |
| 675 |
|
| 676 |
|
| 677 |
for(var ser = 0; ser < _series.length; ser++){ |
| 678 |
datasets[ser] = getSubfield(this.data, _series[ser].datapoints); |
| 679 |
if(datasets[ser] && (datasets[ser].length > maxlen)){ |
| 680 |
maxlen = datasets[ser].length; |
| 681 |
} |
| 682 |
|
| 683 |
series_data[ser] = []; |
| 684 |
|
| 685 |
series_name[ser] = _series[ser].name || (_series[ser].namefield ? getSubfield(this.data, _series[ser].namefield) : null) || ("series " + ser); |
| 686 |
series_chart[ser] = (_series[ser].chart !== false); |
| 687 |
series_charttype[ser] = _series[ser].charttype || "bar"; |
| 688 |
series_linestyle[ser] = _series[ser].linestyle; |
| 689 |
series_axis[ser] = _series[ser].axis || "primary"; |
| 690 |
series_grid[ser] = (_series[ser].grid !== false); |
| 691 |
series_gridformatter[ser] = _series[ser].gridformatter; |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
var point, datapoint, datavalue, fdatavalue; |
| 701 |
var datapoints = []; |
| 702 |
|
| 703 |
for(point = 0; point < maxlen; point++){ |
| 704 |
datapoint = { index: point }; |
| 705 |
for(ser = 0; ser < _series.length; ser++){ |
| 706 |
if(datasets[ser] && (datasets[ser].length > point)){ |
| 707 |
datavalue = getSubfield(datasets[ser][point], _series[ser].field); |
| 708 |
|
| 709 |
if(series_chart[ser]){ |
| 710 |
|
| 711 |
fdatavalue = parseFloat(datavalue); |
| 712 |
if(!isNaN(fdatavalue)){ |
| 713 |
datavalue = fdatavalue; |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
datapoint["data." + ser] = datavalue; |
| 718 |
series_data[ser].push(datavalue); |
| 719 |
} |
| 720 |
} |
| 721 |
datapoints.push(datapoint); |
| 722 |
} |
| 723 |
|
| 724 |
if(maxlen <= 0){ |
| 725 |
datapoints.push({index: 0}); |
| 726 |
} |
| 727 |
|
| 728 |
|
| 729 |
var store = new dojo.data.ItemFileWriteStore({ data: { identifier: 'index', items: datapoints }}); |
| 730 |
if(this.data.title){ |
| 731 |
store.title = this.data.title; |
| 732 |
} |
| 733 |
if(this.data.footer){ |
| 734 |
store.footer = this.data.footer; |
| 735 |
} |
| 736 |
|
| 737 |
store.series_data = series_data; |
| 738 |
store.series_name = series_name; |
| 739 |
store.series_chart = series_chart; |
| 740 |
store.series_charttype = series_charttype; |
| 741 |
store.series_linestyle = series_linestyle; |
| 742 |
store.series_axis = series_axis; |
| 743 |
store.series_grid = series_grid; |
| 744 |
store.series_gridformatter = series_gridformatter; |
| 745 |
|
| 746 |
this.setPreparedStore(store); |
| 747 |
|
| 748 |
if(refreshInterval && (this.refreshInterval > 0)){ |
| 749 |
var me = this; |
| 750 |
this.refreshIntervalPending = setInterval(function(){ |
| 751 |
me.setData(); |
| 752 |
}, this.refreshInterval); |
| 753 |
} |
| 754 |
}, |
| 755 |
|
| 756 |
refresh: function(){ |
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
if(this.url){ |
| 764 |
this.setURL(this.url, this.urlContent, this.refreshInterval); |
| 765 |
}else if(this.data){ |
| 766 |
this.setData(this.data, this.refreshInterval); |
| 767 |
} |
| 768 |
}, |
| 769 |
|
| 770 |
cancelRefresh: function(){ |
| 771 |
|
| 772 |
|
| 773 |
if(this.refreshIntervalPending){ |
| 774 |
|
| 775 |
clearInterval(this.refreshIntervalPending); |
| 776 |
this.refreshIntervalPending = undefined; |
| 777 |
} |
| 778 |
}, |
| 779 |
|
| 780 |
setStore: function(store, query, queryOptions){ |
| 781 |
|
| 782 |
this.setPreparedStore(store, query, queryOptions); |
| 783 |
}, |
| 784 |
|
| 785 |
setPreparedStore: function(store, query, queryOptions){ |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
this.preparedstore = store || this.store; |
| 790 |
this.query = query || this.query; |
| 791 |
this.queryOptions = queryOptions || this.queryOptions; |
| 792 |
|
| 793 |
if(this.preparedstore){ |
| 794 |
if(this.chartNode){ |
| 795 |
this.chartWidget = setupChart(this.chartNode, this.chartWidget, this.chartType, this.reverse, this.animate, this.labelMod, this.theme, this.tooltip, this.preparedstore, this.query, this.queryOptions); |
| 796 |
this.renderChartWidget(); |
| 797 |
} |
| 798 |
if(this.legendNode){ |
| 799 |
this.legendWidget = setupLegend(this.legendNode, this.legendWidget, this.chartWidget, this.legendHorizontal); |
| 800 |
} |
| 801 |
if(this.gridNode){ |
| 802 |
this.gridWidget = setupGrid(this.gridNode, this.gridWidget, this.preparedstore, this.query, this.queryOptions); |
| 803 |
this.renderGridWidget(); |
| 804 |
} |
| 805 |
if(this.titleNode){ |
| 806 |
setupTitle(this.titleNode, this.preparedstore); |
| 807 |
} |
| 808 |
if(this.footerNode){ |
| 809 |
setupFooter(this.footerNode, this.preparedstore); |
| 810 |
} |
| 811 |
} |
| 812 |
}, |
| 813 |
|
| 814 |
renderChartWidget: function(){ |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
if(this.chartWidget){ |
| 820 |
this.chartWidget.render(); |
| 821 |
} |
| 822 |
}, |
| 823 |
|
| 824 |
renderGridWidget: function(){ |
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
if(this.gridWidget){ |
| 830 |
this.gridWidget.render(); |
| 831 |
} |
| 832 |
}, |
| 833 |
|
| 834 |
getChartWidget: function(){ |
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
return this.chartWidget; |
| 839 |
}, |
| 840 |
|
| 841 |
getGridWidget: function(){ |
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
return this.gridWidget; |
| 846 |
}, |
| 847 |
|
| 848 |
destroy: function(){ |
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
this.cancelRefresh(); |
| 854 |
|
| 855 |
if(this.chartWidget){ |
| 856 |
this.chartWidget.destroy(); |
| 857 |
delete this.chartWidget; |
| 858 |
} |
| 859 |
|
| 860 |
if(this.legendWidget){ |
| 861 |
|
| 862 |
delete this.legendWidget; |
| 863 |
} |
| 864 |
|
| 865 |
if(this.gridWidget){ |
| 866 |
|
| 867 |
delete this.gridWidget; |
| 868 |
} |
| 869 |
|
| 870 |
if(this.chartNode){ |
| 871 |
this.chartNode.innerHTML = ""; |
| 872 |
} |
| 873 |
|
| 874 |
if(this.legendNode){ |
| 875 |
this.legendNode.innerHTML = ""; |
| 876 |
} |
| 877 |
|
| 878 |
if(this.gridNode){ |
| 879 |
this.gridNode.innerHTML = ""; |
| 880 |
} |
| 881 |
|
| 882 |
if(this.titleNode){ |
| 883 |
this.titleNode.innerHTML = ""; |
| 884 |
} |
| 885 |
|
| 886 |
if(this.footerNode){ |
| 887 |
this.footerNode.innerHTML = ""; |
| 888 |
} |
| 889 |
} |
| 890 |
|
| 891 |
}); |
| 892 |
|
| 893 |
})(); |