forked from extern/egroupware
57 lines
9.8 KiB
JavaScript
57 lines
9.8 KiB
JavaScript
|
/**
|
||
|
* jqPlot
|
||
|
* Pure JavaScript plotting plugin using jQuery
|
||
|
*
|
||
|
* Version: 1.0.0b2_r947
|
||
|
*
|
||
|
* Copyright (c) 2009-2011 Chris Leonello
|
||
|
* jqPlot is currently available for use in all personal or commercial projects
|
||
|
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
||
|
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
||
|
* choose the license that best suits your project and use it accordingly.
|
||
|
*
|
||
|
* Although not required, the author would appreciate an email letting him
|
||
|
* know of any substantial use of jqPlot. You can reach the author at:
|
||
|
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
||
|
*
|
||
|
* If you are feeling kind and generous, consider supporting the project by
|
||
|
* making a donation at: http://www.jqplot.com/donate.php .
|
||
|
*
|
||
|
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
||
|
*
|
||
|
* version 2007.04.27
|
||
|
* author Ash Searle
|
||
|
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
||
|
* http://hexmen.com/js/sprintf.js
|
||
|
* The author (Ash Searle) has placed this code in the public domain:
|
||
|
* "This code is unrestricted: you are free to use it however you like."
|
||
|
*
|
||
|
* included jsDate library by Chris Leonello:
|
||
|
*
|
||
|
* Copyright (c) 2010-2011 Chris Leonello
|
||
|
*
|
||
|
* jsDate is currently available for use in all personal or commercial projects
|
||
|
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
||
|
* choose the license that best suits your project and use it accordingly.
|
||
|
*
|
||
|
* jsDate borrows many concepts and ideas from the Date Instance
|
||
|
* Methods by Ken Snyder along with some parts of Ken's actual code.
|
||
|
*
|
||
|
* Ken's origianl Date Instance Methods and copyright notice:
|
||
|
*
|
||
|
* Ken Snyder (ken d snyder at gmail dot com)
|
||
|
* 2008-09-10
|
||
|
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
||
|
* Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
||
|
*
|
||
|
* jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
|
||
|
* Larry has generously given permission to adapt his code for inclusion
|
||
|
* into jqPlot.
|
||
|
*
|
||
|
* Larry's original code can be found here:
|
||
|
*
|
||
|
* https://github.com/lsiden/export-jqplot-to-png
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
(function(c){if(c.jqplot.PyramidAxisRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidAxisRenderer.js",dataType:"script",async:false})}if(c.jqplot.PyramidGridRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidGridRenderer.js",dataType:"script",async:false})}c.jqplot.PyramidRenderer=function(){c.jqplot.LineRenderer.call(this)};c.jqplot.PyramidRenderer.prototype=new c.jqplot.LineRenderer();c.jqplot.PyramidRenderer.prototype.constructor=c.jqplot.PyramidRenderer;c.jqplot.PyramidRenderer.prototype.init=function(j,o){j=j||{};this._type="pyramid";this.barPadding=10;this.barWidth=null;this.fill=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];if(j.highlightMouseDown&&j.highlightMouseOver==null){j.highlightMouseOver=false}this.side="right";c.extend(true,this,j);this.renderer.options=j;this._highlightedPoint=null;this._dataColors=[];this._barPoints=[];this.fillAxis="y";this._primaryAxis="_yaxis";this._xnudge=0;var n={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shapeRenderer.init(n);var m=j.shadowOffset;if(m==null){if(this.lineWidth>2.5){m=1.25*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{m=1.25*Math.atan((this.lineWidth/2.5))/0.785398163}}var h={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,angle:this.shadowAngle,offset:m,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shadowRenderer.init(h);o.postDrawHooks.addOnce(f);o.eventListenerHooks.addOnce("jqplotMouseMove",e);if(this.side==="left"){for(var k=0,g=this.data.length;k<g;k++){this.data[k][1]=-Math.abs(this.data[k][1])}}};c.jqplot.PyramidRenderer.prototype.setGridData=function(p){var j=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var k=this._plotData;var n=this._prevPlotData;this.gridData=[];this._prevGridData=[];var g=k.length;var m=false;var h;for(h=0;h<g;h++){if(k[h][1]<0){this.side="left"}}if(this._yaxis.name==="yMidAxis"&&this.side==="right"){this._xnudge=this._xaxis.max/2000;m=true}for(h=0;h<g;h++){if(k[h][0]!=null&&k[h][1]!=null){this.gridData.push([j(k[h][1]),o(k[h][0])])}else{if(k[h][0]==null){this.gridData.push([j(k[h][1]),null])}else{if(k[h][1]==null){this.gridData.push(null,[o(k[h][0])])}}}if(k[h][1]===0&&m){this.gridData[h][0]=j(this._xnudge)}}};c.jqplot.PyramidRenderer.prototype.makeGridData=function(m,p){var k=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var j=[];var g=m.length;var n=false;var h;for(h=0;h<g;h++){if(m[h][1]<0){this.side="left"}}if(this._yaxis.name==="yMidAxis"&&this.side==="right"){this._xnudge=this._xaxis.max/2000;n=true}for(h=0;h<g;h++){if(m[h][0]!=null&&m[h][1]!=null){j.push([k(m[h][1]),o(m[h][0])])}else{if(m[h][0]==null){j.push([k(m[h][1]),null])}else{if(m[h][1]==null){j.push([null,o(m[h][0])])}}}if(m[h][1]===0&&n){j[h][0]=k(this._xnudge)}}return j};c.jqplot.PyramidRenderer.prototype.setBarWidth=function(){var k;var g=0;var h=0;var m=this[this._primaryAxis];var q,l,o;g=m.max-m.min;var n=m.numberTicks;var j=(n-1)/2;var p=(this.barPadding===0)?1:0;if(m.name=="xaxis"||m.name=="x2axis"){this.barWidth=(m._offsets.max-m._offsets.min)/g-this.barPadding+p}else{if(this.fill){this.barWidth=(m._offsets.min-m._offsets.max)/g-this.barPadding+p}else{this.barWidth=(m._offsets.min-m._offsets.max)/g}}};c.jqplot.PyramidRenderer.prototype.draw=function(A,G,k){var D;var t=c.extend({},k);var p=(t.shadow!=undefined)?t.shadow:this.shadow;var I=(t.showLine!=undefined)?t.showLine:this.showLine;var B=(t.fill!=undefined)?t.fill:this.fill;var s=this._xaxis.series_u2p;var F=this._yaxis.series_u2p;var y,v;this._dataColors=[];this._barPoints=[];if(this.renderer.options.barWidth==null){this.renderer.setBarWidth.call(this)}var C=[],r,E;if(I){var q=new c.jqplot.ColorGenerator(this.negativeSeriesColors);var u=new c.jqplot.ColorGenerator(this.seriesColors);var H=q.get(this.index);if(!this.useNegativeColors){H=t.fillStyle}var o=t.fillStyle;var
|