123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- (function($) {
-
- $.jqplot.BlockRenderer = function(){
- $.jqplot.LineRenderer.call(this);
- };
-
- $.jqplot.BlockRenderer.prototype = new $.jqplot.LineRenderer();
- $.jqplot.BlockRenderer.prototype.constructor = $.jqplot.BlockRenderer;
-
-
- $.jqplot.BlockRenderer.prototype.init = function(options) {
-
-
-
-
-
-
- this.css = {padding:'2px', border:'1px solid #999', textAlign:'center'};
-
-
- this.escapeHtml = false;
-
-
- this.insertBreaks = true;
-
-
-
-
-
- this.varyBlockColors = false;
- $.extend(true, this, options);
- if (this.css.backgroundColor) {
- this.color = this.css.backgroundColor;
- }
- else if (this.css.background) {
- this.color = this.css.background;
- }
- else if (!this.varyBlockColors) {
- this.css.background = this.color;
- }
- this.canvas = new $.jqplot.BlockCanvas();
- this.shadowCanvas = new $.jqplot.BlockCanvas();
- this.canvas._plotDimensions = this._plotDimensions;
- this.shadowCanvas._plotDimensions = this._plotDimensions;
- this._type = 'block';
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.moveBlock = function (idx, x, y, duration) {
-
-
- var el = this.canvas._elem.children(':eq('+idx+')');
- this.data[idx][0] = x;
- this.data[idx][1] = y;
- this._plotData[idx][0] = x;
- this._plotData[idx][1] = y;
- this._stackData[idx][0] = x;
- this._stackData[idx][1] = y;
- this.gridData[idx][0] = this._xaxis.series_u2p(x);
- this.gridData[idx][1] = this._yaxis.series_u2p(y);
- var w = el.outerWidth();
- var h = el.outerHeight();
- var left = this.gridData[idx][0] - w/2 + 'px';
- var top = this.gridData[idx][1] - h/2 + 'px';
- if (duration) {
- if (parseInt(duration, 10)) {
- duration = parseInt(duration, 10);
- }
- el.animate({left:left, top:top}, duration);
- }
- else {
- el.css({left:left, top:top});
- }
- el = null;
- };
- };
-
-
- $.jqplot.BlockRenderer.prototype.draw = function (ctx, gd, options) {
- if (this.plugins.pointLabels) {
- this.plugins.pointLabels.show = false;
- }
- var i, el, d, gd, t, css, w, h, left, top;
- var opts = (options != undefined) ? options : {};
- var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
- this.canvas._elem.empty();
- for (i=0; i<this.gridData.length; i++) {
- d = this.data[i];
- gd = this.gridData[i];
- t = '';
- css = {};
- if (typeof d[2] == 'string') {
- t = d[2];
- }
- else if (typeof d[2] == 'object') {
- css = d[2];
- }
- if (typeof d[3] == 'object') {
- css = d[3];
- }
- if (this.insertBreaks){
- t = t.replace(/ /g, '<br />');
- }
- css = $.extend(true, {}, this.css, css);
-
- el = $('<div style="position:absolute;margin-left:auto;margin-right:auto;"></div>');
- this.canvas._elem.append(el);
-
- this.escapeHtml ? el.text(t) : el.html(t);
-
-
- delete css.position;
- delete css.marginRight;
- delete css.marginLeft;
- if (!css.background && !css.backgroundColor && !css.backgroundImage){
- css.background = colorGenerator.next();
- }
- el.css(css);
- w = el.outerWidth();
- h = el.outerHeight();
- left = gd[0] - w/2 + 'px';
- top = gd[1] - h/2 + 'px';
- el.css({left:left, top:top});
- el = null;
- }
- };
-
- $.jqplot.BlockCanvas = function() {
- $.jqplot.ElemContainer.call(this);
- this._ctx;
- };
-
- $.jqplot.BlockCanvas.prototype = new $.jqplot.ElemContainer();
- $.jqplot.BlockCanvas.prototype.constructor = $.jqplot.BlockCanvas;
-
- $.jqplot.BlockCanvas.prototype.createElement = function(offsets, clss, plotDimensions) {
- this._offsets = offsets;
- var klass = 'jqplot-blockCanvas';
- if (clss != undefined) {
- klass = clss;
- }
- var elem;
-
- if (this._elem) {
- elem = this._elem.get(0);
- }
- else {
- elem = document.createElement('div');
- }
-
- if (plotDimensions != undefined) {
- this._plotDimensions = plotDimensions;
- }
-
- var w = this._plotDimensions.width - this._offsets.left - this._offsets.right + 'px';
- var h = this._plotDimensions.height - this._offsets.top - this._offsets.bottom + 'px';
- this._elem = $(elem);
- this._elem.css({ position: 'absolute', width:w, height:h, left: this._offsets.left, top: this._offsets.top });
-
- this._elem.addClass(klass);
- return this._elem;
- };
-
- $.jqplot.BlockCanvas.prototype.setContext = function() {
- this._ctx = {
- canvas:{
- width:0,
- height:0
- },
- clearRect:function(){return null;}
- };
- return this._ctx;
- };
-
- })(jQuery);
-
-
|