diff options
author | BeezyT <timo@ezdesign.de> | 2011-05-25 22:53:15 +0400 |
---|---|---|
committer | BeezyT <timo@ezdesign.de> | 2011-05-25 22:53:15 +0400 |
commit | 7beb8d16d61a8d79db1e3abc4c92c856d6d59640 (patch) | |
tree | f21253d81058afdd6a5e03f7cec8debd57f78516 /libs/jqplot | |
parent | e27e54dfc65a20469df0cedba8bf27c334b854db (diff) |
refs #2431 removed unneeded jqplot files. reduced jqplot css size. cursor pointer for clickable evolution charts. small sparkline bugfix.
git-svn-id: http://dev.piwik.org/svn/trunk@4808 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/jqplot')
27 files changed, 0 insertions, 13891 deletions
diff --git a/libs/jqplot/excanvas.js b/libs/jqplot/excanvas.js deleted file mode 100644 index f3b70f470d..0000000000 --- a/libs/jqplot/excanvas.js +++ /dev/null @@ -1,1434 +0,0 @@ -// Memory Leaks patch from http://explorercanvas.googlecode.com/svn/trunk/ -// svn : r73 -// ------------------------------------------------------------------ -// Copyright 2006 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -// Known Issues: -// -// * Patterns only support repeat. -// * Radial gradient are not implemented. The VML version of these look very -// different from the canvas one. -// * Clipping paths are not implemented. -// * Coordsize. The width and height attribute have higher priority than the -// width and height style values which isn't correct. -// * Painting mode isn't implemented. -// * Canvas width/height should is using content-box by default. IE in -// Quirks mode will draw the canvas using border-box. Either change your -// doctype to HTML5 -// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype) -// or use Box Sizing Behavior from WebFX -// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html) -// * Non uniform scaling does not correctly scale strokes. -// * Optimize. There is always room for speed improvements. - -// Only add this code if we do not already have a canvas implementation -if (!document.createElement('canvas').getContext) { - -(function() { - - // alias some functions to make (compiled) code shorter - var m = Math; - var mr = m.round; - var ms = m.sin; - var mc = m.cos; - var abs = m.abs; - var sqrt = m.sqrt; - - // this is used for sub pixel precision - var Z = 10; - var Z2 = Z / 2; - - var IE_VERSION = +navigator.userAgent.match(/MSIE ([\d.]+)?/)[1]; - - /** - * This funtion is assigned to the <canvas> elements as element.getContext(). - * @this {HTMLElement} - * @return {CanvasRenderingContext2D_} - */ - function getContext() { - return this.context_ || - (this.context_ = new CanvasRenderingContext2D_(this)); - } - - var slice = Array.prototype.slice; - - /** - * Binds a function to an object. The returned function will always use the - * passed in {@code obj} as {@code this}. - * - * Example: - * - * g = bind(f, obj, a, b) - * g(c, d) // will do f.call(obj, a, b, c, d) - * - * @param {Function} f The function to bind the object to - * @param {Object} obj The object that should act as this when the function - * is called - * @param {*} var_args Rest arguments that will be used as the initial - * arguments when the function is called - * @return {Function} A new function that has bound this - */ - function bind(f, obj, var_args) { - var a = slice.call(arguments, 2); - return function() { - return f.apply(obj, a.concat(slice.call(arguments))); - }; - } - - function encodeHtmlAttribute(s) { - return String(s).replace(/&/g, '&').replace(/"/g, '"'); - } - - function addNamespace(doc, prefix, urn) { - if (!doc.namespaces[prefix]) { - doc.namespaces.add(prefix, urn, '#default#VML'); - } - } - - function addNamespacesAndStylesheet(doc) { - addNamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml'); - addNamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office'); - - // Setup default CSS. Only add one style sheet per document - if (!doc.styleSheets['ex_canvas_']) { - var ss = doc.createStyleSheet(); - ss.owningElement.id = 'ex_canvas_'; - ss.cssText = 'canvas{display:inline-block;overflow:hidden;' + - // default size is 300x150 in Gecko and Opera - 'text-align:left;width:300px;height:150px}'; - } - } - - // Add namespaces and stylesheet at startup. - addNamespacesAndStylesheet(document); - - var G_vmlCanvasManager_ = { - init: function(opt_doc) { - var doc = opt_doc || document; - // Create a dummy element so that IE will allow canvas elements to be - // recognized. - doc.createElement('canvas'); - doc.attachEvent('onreadystatechange', bind(this.init_, this, doc)); - }, - - init_: function(doc) { - // find all canvas elements - var els = doc.getElementsByTagName('canvas'); - for (var i = 0; i < els.length; i++) { - this.initElement(els[i]); - } - }, - - /** - * Public initializes a canvas element so that it can be used as canvas - * element from now on. This is called automatically before the page is - * loaded but if you are creating elements using createElement you need to - * make sure this is called on the element. - * @param {HTMLElement} el The canvas element to initialize. - * @return {HTMLElement} the element that was created. - */ - initElement: function(el) { - if (!el.getContext) { - el.getContext = getContext; - - // Add namespaces and stylesheet to document of the element. - addNamespacesAndStylesheet(el.ownerDocument); - - // Remove fallback content. There is no way to hide text nodes so we - // just remove all childNodes. We could hide all elements and remove - // text nodes but who really cares about the fallback content. - el.innerHTML = ''; - - // do not use inline function because that will leak memory - el.attachEvent('onpropertychange', onPropertyChange); - el.attachEvent('onresize', onResize); - - var attrs = el.attributes; - if (attrs.width && attrs.width.specified) { - // TODO: use runtimeStyle and coordsize - // el.getContext().setWidth_(attrs.width.nodeValue); - el.style.width = attrs.width.nodeValue + 'px'; - } else { - el.width = el.clientWidth; - } - if (attrs.height && attrs.height.specified) { - // TODO: use runtimeStyle and coordsize - // el.getContext().setHeight_(attrs.height.nodeValue); - el.style.height = attrs.height.nodeValue + 'px'; - } else { - el.height = el.clientHeight; - } - //el.getContext().setCoordsize_() - } - return el; - }, - - // Memory Leaks patch : see http://code.google.com/p/explorercanvas/issues/detail?id=82 - uninitElement: function(el){ - if (el.getContext) { - var ctx = el.getContext(); - delete ctx.element_; - delete ctx.canvas; - el.innerHTML = ""; - //el.outerHTML = ""; - el.context_ = null; - el.getContext = null; - el.detachEvent("onpropertychange", onPropertyChange); - el.detachEvent("onresize", onResize); - } - } - }; - - function onPropertyChange(e) { - var el = e.srcElement; - - switch (e.propertyName) { - case 'width': - el.getContext().clearRect(); - el.style.width = el.attributes.width.nodeValue + 'px'; - // In IE8 this does not trigger onresize. - el.firstChild.style.width = el.clientWidth + 'px'; - break; - case 'height': - el.getContext().clearRect(); - el.style.height = el.attributes.height.nodeValue + 'px'; - el.firstChild.style.height = el.clientHeight + 'px'; - break; - } - } - - function onResize(e) { - var el = e.srcElement; - if (el.firstChild) { - el.firstChild.style.width = el.clientWidth + 'px'; - el.firstChild.style.height = el.clientHeight + 'px'; - } - } - - G_vmlCanvasManager_.init(); - - // precompute "00" to "FF" - var decToHex = []; - for (var i = 0; i < 16; i++) { - for (var j = 0; j < 16; j++) { - decToHex[i * 16 + j] = i.toString(16) + j.toString(16); - } - } - - function createMatrixIdentity() { - return [ - [1, 0, 0], - [0, 1, 0], - [0, 0, 1] - ]; - } - - function matrixMultiply(m1, m2) { - var result = createMatrixIdentity(); - - for (var x = 0; x < 3; x++) { - for (var y = 0; y < 3; y++) { - var sum = 0; - - for (var z = 0; z < 3; z++) { - sum += m1[x][z] * m2[z][y]; - } - - result[x][y] = sum; - } - } - return result; - } - - function copyState(o1, o2) { - o2.fillStyle = o1.fillStyle; - o2.lineCap = o1.lineCap; - o2.lineJoin = o1.lineJoin; - o2.lineWidth = o1.lineWidth; - o2.miterLimit = o1.miterLimit; - o2.shadowBlur = o1.shadowBlur; - o2.shadowColor = o1.shadowColor; - o2.shadowOffsetX = o1.shadowOffsetX; - o2.shadowOffsetY = o1.shadowOffsetY; - o2.strokeStyle = o1.strokeStyle; - o2.globalAlpha = o1.globalAlpha; - o2.font = o1.font; - o2.textAlign = o1.textAlign; - o2.textBaseline = o1.textBaseline; - o2.arcScaleX_ = o1.arcScaleX_; - o2.arcScaleY_ = o1.arcScaleY_; - o2.lineScale_ = o1.lineScale_; - } - - var colorData = { - aliceblue: '#F0F8FF', - antiquewhite: '#FAEBD7', - aquamarine: '#7FFFD4', - azure: '#F0FFFF', - beige: '#F5F5DC', - bisque: '#FFE4C4', - black: '#000000', - blanchedalmond: '#FFEBCD', - blueviolet: '#8A2BE2', - brown: '#A52A2A', - burlywood: '#DEB887', - cadetblue: '#5F9EA0', - chartreuse: '#7FFF00', - chocolate: '#D2691E', - coral: '#FF7F50', - cornflowerblue: '#6495ED', - cornsilk: '#FFF8DC', - crimson: '#DC143C', - cyan: '#00FFFF', - darkblue: '#00008B', - darkcyan: '#008B8B', - darkgoldenrod: '#B8860B', - darkgray: '#A9A9A9', - darkgreen: '#006400', - darkgrey: '#A9A9A9', - darkkhaki: '#BDB76B', - darkmagenta: '#8B008B', - darkolivegreen: '#556B2F', - darkorange: '#FF8C00', - darkorchid: '#9932CC', - darkred: '#8B0000', - darksalmon: '#E9967A', - darkseagreen: '#8FBC8F', - darkslateblue: '#483D8B', - darkslategray: '#2F4F4F', - darkslategrey: '#2F4F4F', - darkturquoise: '#00CED1', - darkviolet: '#9400D3', - deeppink: '#FF1493', - deepskyblue: '#00BFFF', - dimgray: '#696969', - dimgrey: '#696969', - dodgerblue: '#1E90FF', - firebrick: '#B22222', - floralwhite: '#FFFAF0', - forestgreen: '#228B22', - gainsboro: '#DCDCDC', - ghostwhite: '#F8F8FF', - gold: '#FFD700', - goldenrod: '#DAA520', - grey: '#808080', - greenyellow: '#ADFF2F', - honeydew: '#F0FFF0', - hotpink: '#FF69B4', - indianred: '#CD5C5C', - indigo: '#4B0082', - ivory: '#FFFFF0', - khaki: '#F0E68C', - lavender: '#E6E6FA', - lavenderblush: '#FFF0F5', - lawngreen: '#7CFC00', - lemonchiffon: '#FFFACD', - lightblue: '#ADD8E6', - lightcoral: '#F08080', - lightcyan: '#E0FFFF', - lightgoldenrodyellow: '#FAFAD2', - lightgreen: '#90EE90', - lightgrey: '#D3D3D3', - lightpink: '#FFB6C1', - lightsalmon: '#FFA07A', - lightseagreen: '#20B2AA', - lightskyblue: '#87CEFA', - lightslategray: '#778899', - lightslategrey: '#778899', - lightsteelblue: '#B0C4DE', - lightyellow: '#FFFFE0', - limegreen: '#32CD32', - linen: '#FAF0E6', - magenta: '#FF00FF', - mediumaquamarine: '#66CDAA', - mediumblue: '#0000CD', - mediumorchid: '#BA55D3', - mediumpurple: '#9370DB', - mediumseagreen: '#3CB371', - mediumslateblue: '#7B68EE', - mediumspringgreen: '#00FA9A', - mediumturquoise: '#48D1CC', - mediumvioletred: '#C71585', - midnightblue: '#191970', - mintcream: '#F5FFFA', - mistyrose: '#FFE4E1', - moccasin: '#FFE4B5', - navajowhite: '#FFDEAD', - oldlace: '#FDF5E6', - olivedrab: '#6B8E23', - orange: '#FFA500', - orangered: '#FF4500', - orchid: '#DA70D6', - palegoldenrod: '#EEE8AA', - palegreen: '#98FB98', - paleturquoise: '#AFEEEE', - palevioletred: '#DB7093', - papayawhip: '#FFEFD5', - peachpuff: '#FFDAB9', - peru: '#CD853F', - pink: '#FFC0CB', - plum: '#DDA0DD', - powderblue: '#B0E0E6', - rosybrown: '#BC8F8F', - royalblue: '#4169E1', - saddlebrown: '#8B4513', - salmon: '#FA8072', - sandybrown: '#F4A460', - seagreen: '#2E8B57', - seashell: '#FFF5EE', - sienna: '#A0522D', - skyblue: '#87CEEB', - slateblue: '#6A5ACD', - slategray: '#708090', - slategrey: '#708090', - snow: '#FFFAFA', - springgreen: '#00FF7F', - steelblue: '#4682B4', - tan: '#D2B48C', - thistle: '#D8BFD8', - tomato: '#FF6347', - turquoise: '#40E0D0', - violet: '#EE82EE', - wheat: '#F5DEB3', - whitesmoke: '#F5F5F5', - yellowgreen: '#9ACD32' - }; - - - function getRgbHslContent(styleString) { - var start = styleString.indexOf('(', 3); - var end = styleString.indexOf(')', start + 1); - var parts = styleString.substring(start + 1, end).split(','); - // add alpha if needed - if (parts.length != 4 || styleString.charAt(3) != 'a') { - parts[3] = 1; - } - return parts; - } - - function percent(s) { - return parseFloat(s) / 100; - } - - function clamp(v, min, max) { - return Math.min(max, Math.max(min, v)); - } - - function hslToRgb(parts){ - var r, g, b, h, s, l; - h = parseFloat(parts[0]) / 360 % 360; - if (h < 0) - h++; - s = clamp(percent(parts[1]), 0, 1); - l = clamp(percent(parts[2]), 0, 1); - if (s == 0) { - r = g = b = l; // achromatic - } else { - var q = l < 0.5 ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - r = hueToRgb(p, q, h + 1 / 3); - g = hueToRgb(p, q, h); - b = hueToRgb(p, q, h - 1 / 3); - } - - return '#' + decToHex[Math.floor(r * 255)] + - decToHex[Math.floor(g * 255)] + - decToHex[Math.floor(b * 255)]; - } - - function hueToRgb(m1, m2, h) { - if (h < 0) - h++; - if (h > 1) - h--; - - if (6 * h < 1) - return m1 + (m2 - m1) * 6 * h; - else if (2 * h < 1) - return m2; - else if (3 * h < 2) - return m1 + (m2 - m1) * (2 / 3 - h) * 6; - else - return m1; - } - - var processStyleCache = {}; - - function processStyle(styleString) { - if (styleString in processStyleCache) { - return processStyleCache[styleString]; - } - - var str, alpha = 1; - - styleString = String(styleString); - if (styleString.charAt(0) == '#') { - str = styleString; - } else if (/^rgb/.test(styleString)) { - var parts = getRgbHslContent(styleString); - var str = '#', n; - for (var i = 0; i < 3; i++) { - if (parts[i].indexOf('%') != -1) { - n = Math.floor(percent(parts[i]) * 255); - } else { - n = +parts[i]; - } - str += decToHex[clamp(n, 0, 255)]; - } - alpha = +parts[3]; - } else if (/^hsl/.test(styleString)) { - var parts = getRgbHslContent(styleString); - str = hslToRgb(parts); - alpha = parts[3]; - } else { - str = colorData[styleString] || styleString; - } - return processStyleCache[styleString] = {color: str, alpha: alpha}; - } - - var DEFAULT_STYLE = { - style: 'normal', - variant: 'normal', - weight: 'normal', - size: 10, - family: 'sans-serif' - }; - - // Internal text style cache - var fontStyleCache = {}; - - function processFontStyle(styleString) { - if (fontStyleCache[styleString]) { - return fontStyleCache[styleString]; - } - - var el = document.createElement('div'); - var style = el.style; - try { - style.font = styleString; - } catch (ex) { - // Ignore failures to set to invalid font. - } - - return fontStyleCache[styleString] = { - style: style.fontStyle || DEFAULT_STYLE.style, - variant: style.fontVariant || DEFAULT_STYLE.variant, - weight: style.fontWeight || DEFAULT_STYLE.weight, - size: style.fontSize || DEFAULT_STYLE.size, - family: style.fontFamily || DEFAULT_STYLE.family - }; - } - - function getComputedStyle(style, element) { - var computedStyle = {}; - - for (var p in style) { - computedStyle[p] = style[p]; - } - - // Compute the size - var canvasFontSize = parseFloat(element.currentStyle.fontSize), - fontSize = parseFloat(style.size); - - if (typeof style.size == 'number') { - computedStyle.size = style.size; - } else if (style.size.indexOf('px') != -1) { - computedStyle.size = fontSize; - } else if (style.size.indexOf('em') != -1) { - computedStyle.size = canvasFontSize * fontSize; - } else if(style.size.indexOf('%') != -1) { - computedStyle.size = (canvasFontSize / 100) * fontSize; - } else if (style.size.indexOf('pt') != -1) { - computedStyle.size = fontSize / .75; - } else { - computedStyle.size = canvasFontSize; - } - - // Different scaling between normal text and VML text. This was found using - // trial and error to get the same size as non VML text. - computedStyle.size *= 0.981; - - return computedStyle; - } - - function buildStyle(style) { - return style.style + ' ' + style.variant + ' ' + style.weight + ' ' + - style.size + 'px ' + style.family; - } - - var lineCapMap = { - 'butt': 'flat', - 'round': 'round' - }; - - function processLineCap(lineCap) { - return lineCapMap[lineCap] || 'square'; - } - - /** - * This class implements CanvasRenderingContext2D interface as described by - * the WHATWG. - * @param {HTMLElement} canvasElement The element that the 2D context should - * be associated with - */ - function CanvasRenderingContext2D_(canvasElement) { - this.m_ = createMatrixIdentity(); - - this.mStack_ = []; - this.aStack_ = []; - this.currentPath_ = []; - - // Canvas context properties - this.strokeStyle = '#000'; - this.fillStyle = '#000'; - - this.lineWidth = 1; - this.lineJoin = 'miter'; - this.lineCap = 'butt'; - this.miterLimit = Z * 1; - this.globalAlpha = 1; - this.font = '10px sans-serif'; - this.textAlign = 'left'; - this.textBaseline = 'alphabetic'; - this.canvas = canvasElement; - - var cssText = 'width:' + canvasElement.clientWidth + 'px;height:' + - canvasElement.clientHeight + 'px;overflow:hidden;position:absolute'; - var el = canvasElement.ownerDocument.createElement('div'); - el.style.cssText = cssText; - canvasElement.appendChild(el); - - var overlayEl = el.cloneNode(false); - // Use a non transparent background. - overlayEl.style.backgroundColor = 'red'; - overlayEl.style.filter = 'alpha(opacity=0)'; - canvasElement.appendChild(overlayEl); - - this.element_ = el; - this.arcScaleX_ = 1; - this.arcScaleY_ = 1; - this.lineScale_ = 1; - } - - var contextPrototype = CanvasRenderingContext2D_.prototype; - contextPrototype.clearRect = function() { - if (this.textMeasureEl_) { - this.textMeasureEl_.removeNode(true); - this.textMeasureEl_ = null; - } - this.element_.innerHTML = ''; - }; - - contextPrototype.beginPath = function() { - // TODO: Branch current matrix so that save/restore has no effect - // as per safari docs. - this.currentPath_ = []; - }; - - contextPrototype.moveTo = function(aX, aY) { - var p = getCoords(this, aX, aY); - this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y}); - this.currentX_ = p.x; - this.currentY_ = p.y; - }; - - contextPrototype.lineTo = function(aX, aY) { - var p = getCoords(this, aX, aY); - this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y}); - - this.currentX_ = p.x; - this.currentY_ = p.y; - }; - - contextPrototype.bezierCurveTo = function(aCP1x, aCP1y, - aCP2x, aCP2y, - aX, aY) { - var p = getCoords(this, aX, aY); - var cp1 = getCoords(this, aCP1x, aCP1y); - var cp2 = getCoords(this, aCP2x, aCP2y); - bezierCurveTo(this, cp1, cp2, p); - }; - - // Helper function that takes the already fixed cordinates. - function bezierCurveTo(self, cp1, cp2, p) { - self.currentPath_.push({ - type: 'bezierCurveTo', - cp1x: cp1.x, - cp1y: cp1.y, - cp2x: cp2.x, - cp2y: cp2.y, - x: p.x, - y: p.y - }); - self.currentX_ = p.x; - self.currentY_ = p.y; - } - - contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) { - // the following is lifted almost directly from - // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes - - var cp = getCoords(this, aCPx, aCPy); - var p = getCoords(this, aX, aY); - - var cp1 = { - x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_), - y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_) - }; - var cp2 = { - x: cp1.x + (p.x - this.currentX_) / 3.0, - y: cp1.y + (p.y - this.currentY_) / 3.0 - }; - - bezierCurveTo(this, cp1, cp2, p); - }; - - contextPrototype.arc = function(aX, aY, aRadius, - aStartAngle, aEndAngle, aClockwise) { - aRadius *= Z; - var arcType = aClockwise ? 'at' : 'wa'; - - var xStart = aX + mc(aStartAngle) * aRadius - Z2; - var yStart = aY + ms(aStartAngle) * aRadius - Z2; - - var xEnd = aX + mc(aEndAngle) * aRadius - Z2; - var yEnd = aY + ms(aEndAngle) * aRadius - Z2; - - // IE won't render arches drawn counter clockwise if xStart == xEnd. - if (xStart == xEnd && !aClockwise) { - xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something - // that can be represented in binary - } - - var p = getCoords(this, aX, aY); - var pStart = getCoords(this, xStart, yStart); - var pEnd = getCoords(this, xEnd, yEnd); - - this.currentPath_.push({type: arcType, - x: p.x, - y: p.y, - radius: aRadius, - xStart: pStart.x, - yStart: pStart.y, - xEnd: pEnd.x, - yEnd: pEnd.y}); - - }; - - contextPrototype.rect = function(aX, aY, aWidth, aHeight) { - this.moveTo(aX, aY); - this.lineTo(aX + aWidth, aY); - this.lineTo(aX + aWidth, aY + aHeight); - this.lineTo(aX, aY + aHeight); - this.closePath(); - }; - - contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) { - var oldPath = this.currentPath_; - this.beginPath(); - - this.moveTo(aX, aY); - this.lineTo(aX + aWidth, aY); - this.lineTo(aX + aWidth, aY + aHeight); - this.lineTo(aX, aY + aHeight); - this.closePath(); - this.stroke(); - - this.currentPath_ = oldPath; - }; - - contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) { - var oldPath = this.currentPath_; - this.beginPath(); - - this.moveTo(aX, aY); - this.lineTo(aX + aWidth, aY); - this.lineTo(aX + aWidth, aY + aHeight); - this.lineTo(aX, aY + aHeight); - this.closePath(); - this.fill(); - - this.currentPath_ = oldPath; - }; - - contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) { - var gradient = new CanvasGradient_('gradient'); - gradient.x0_ = aX0; - gradient.y0_ = aY0; - gradient.x1_ = aX1; - gradient.y1_ = aY1; - return gradient; - }; - - contextPrototype.createRadialGradient = function(aX0, aY0, aR0, - aX1, aY1, aR1) { - var gradient = new CanvasGradient_('gradientradial'); - gradient.x0_ = aX0; - gradient.y0_ = aY0; - gradient.r0_ = aR0; - gradient.x1_ = aX1; - gradient.y1_ = aY1; - gradient.r1_ = aR1; - return gradient; - }; - - contextPrototype.drawImage = function(image, var_args) { - var dx, dy, dw, dh, sx, sy, sw, sh; - - // to find the original width we overide the width and height - var oldRuntimeWidth = image.runtimeStyle.width; - var oldRuntimeHeight = image.runtimeStyle.height; - image.runtimeStyle.width = 'auto'; - image.runtimeStyle.height = 'auto'; - - // get the original size - var w = image.width; - var h = image.height; - - // and remove overides - image.runtimeStyle.width = oldRuntimeWidth; - image.runtimeStyle.height = oldRuntimeHeight; - - if (arguments.length == 3) { - dx = arguments[1]; - dy = arguments[2]; - sx = sy = 0; - sw = dw = w; - sh = dh = h; - } else if (arguments.length == 5) { - dx = arguments[1]; - dy = arguments[2]; - dw = arguments[3]; - dh = arguments[4]; - sx = sy = 0; - sw = w; - sh = h; - } else if (arguments.length == 9) { - sx = arguments[1]; - sy = arguments[2]; - sw = arguments[3]; - sh = arguments[4]; - dx = arguments[5]; - dy = arguments[6]; - dw = arguments[7]; - dh = arguments[8]; - } else { - throw Error('Invalid number of arguments'); - } - - var d = getCoords(this, dx, dy); - - var w2 = sw / 2; - var h2 = sh / 2; - - var vmlStr = []; - - var W = 10; - var H = 10; - - // For some reason that I've now forgotten, using divs didn't work - vmlStr.push(' <g_vml_:group', - ' coordsize="', Z * W, ',', Z * H, '"', - ' coordorigin="0,0"' , - ' style="width:', W, 'px;height:', H, 'px;position:absolute;'); - - // If filters are necessary (rotation exists), create them - // filters are bog-slow, so only create them if abbsolutely necessary - // The following check doesn't account for skews (which don't exist - // in the canvas spec (yet) anyway. - - if (this.m_[0][0] != 1 || this.m_[0][1] || - this.m_[1][1] != 1 || this.m_[1][0]) { - var filter = []; - - // Note the 12/21 reversal - filter.push('M11=', this.m_[0][0], ',', - 'M12=', this.m_[1][0], ',', - 'M21=', this.m_[0][1], ',', - 'M22=', this.m_[1][1], ',', - 'Dx=', mr(d.x / Z), ',', - 'Dy=', mr(d.y / Z), ''); - - // Bounding box calculation (need to minimize displayed area so that - // filters don't waste time on unused pixels. - var max = d; - var c2 = getCoords(this, dx + dw, dy); - var c3 = getCoords(this, dx, dy + dh); - var c4 = getCoords(this, dx + dw, dy + dh); - - max.x = m.max(max.x, c2.x, c3.x, c4.x); - max.y = m.max(max.y, c2.y, c3.y, c4.y); - - vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z), - 'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(', - filter.join(''), ", sizingmethod='clip');"); - - } else { - vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;'); - } - - vmlStr.push(' ">' , - '<g_vml_:image src="', image.src, '"', - ' style="width:', Z * dw, 'px;', - ' height:', Z * dh, 'px"', - ' cropleft="', sx / w, '"', - ' croptop="', sy / h, '"', - ' cropright="', (w - sx - sw) / w, '"', - ' cropbottom="', (h - sy - sh) / h, '"', - ' />', - '</g_vml_:group>'); - - this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join('')); - }; - - contextPrototype.stroke = function(aFill) { - var lineStr = []; - var lineOpen = false; - - var W = 10; - var H = 10; - - lineStr.push('<g_vml_:shape', - ' filled="', !!aFill, '"', - ' style="position:absolute;width:', W, 'px;height:', H, 'px;"', - ' coordorigin="0,0"', - ' coordsize="', Z * W, ',', Z * H, '"', - ' stroked="', !aFill, '"', - ' path="'); - - var newSeq = false; - var min = {x: null, y: null}; - var max = {x: null, y: null}; - - for (var i = 0; i < this.currentPath_.length; i++) { - var p = this.currentPath_[i]; - var c; - - switch (p.type) { - case 'moveTo': - c = p; - lineStr.push(' m ', mr(p.x), ',', mr(p.y)); - break; - case 'lineTo': - lineStr.push(' l ', mr(p.x), ',', mr(p.y)); - break; - case 'close': - lineStr.push(' x '); - p = null; - break; - case 'bezierCurveTo': - lineStr.push(' c ', - mr(p.cp1x), ',', mr(p.cp1y), ',', - mr(p.cp2x), ',', mr(p.cp2y), ',', - mr(p.x), ',', mr(p.y)); - break; - case 'at': - case 'wa': - lineStr.push(' ', p.type, ' ', - mr(p.x - this.arcScaleX_ * p.radius), ',', - mr(p.y - this.arcScaleY_ * p.radius), ' ', - mr(p.x + this.arcScaleX_ * p.radius), ',', - mr(p.y + this.arcScaleY_ * p.radius), ' ', - mr(p.xStart), ',', mr(p.yStart), ' ', - mr(p.xEnd), ',', mr(p.yEnd)); - break; - } - - - // TODO: Following is broken for curves due to - // move to proper paths. - - // Figure out dimensions so we can do gradient fills - // properly - if (p) { - if (min.x == null || p.x < min.x) { - min.x = p.x; - } - if (max.x == null || p.x > max.x) { - max.x = p.x; - } - if (min.y == null || p.y < min.y) { - min.y = p.y; - } - if (max.y == null || p.y > max.y) { - max.y = p.y; - } - } - } - lineStr.push(' ">'); - - if (!aFill) { - appendStroke(this, lineStr); - } else { - appendFill(this, lineStr, min, max); - } - - lineStr.push('</g_vml_:shape>'); - - this.element_.insertAdjacentHTML('beforeEnd', lineStr.join('')); - }; - - function appendStroke(ctx, lineStr) { - var a = processStyle(ctx.strokeStyle); - var color = a.color; - var opacity = a.alpha * ctx.globalAlpha; - var lineWidth = ctx.lineScale_ * ctx.lineWidth; - - // VML cannot correctly render a line if the width is less than 1px. - // In that case, we dilute the color to make the line look thinner. - if (lineWidth < 1) { - opacity *= lineWidth; - } - - lineStr.push( - '<g_vml_:stroke', - ' opacity="', opacity, '"', - ' joinstyle="', ctx.lineJoin, '"', - ' miterlimit="', ctx.miterLimit, '"', - ' endcap="', processLineCap(ctx.lineCap), '"', - ' weight="', lineWidth, 'px"', - ' color="', color, '" />' - ); - } - - function appendFill(ctx, lineStr, min, max) { - var fillStyle = ctx.fillStyle; - var arcScaleX = ctx.arcScaleX_; - var arcScaleY = ctx.arcScaleY_; - var width = max.x - min.x; - var height = max.y - min.y; - if (fillStyle instanceof CanvasGradient_) { - // TODO: Gradients transformed with the transformation matrix. - var angle = 0; - var focus = {x: 0, y: 0}; - - // additional offset - var shift = 0; - // scale factor for offset - var expansion = 1; - - if (fillStyle.type_ == 'gradient') { - var x0 = fillStyle.x0_ / arcScaleX; - var y0 = fillStyle.y0_ / arcScaleY; - var x1 = fillStyle.x1_ / arcScaleX; - var y1 = fillStyle.y1_ / arcScaleY; - var p0 = getCoords(ctx, x0, y0); - var p1 = getCoords(ctx, x1, y1); - var dx = p1.x - p0.x; - var dy = p1.y - p0.y; - angle = Math.atan2(dx, dy) * 180 / Math.PI; - - // The angle should be a non-negative number. - if (angle < 0) { - angle += 360; - } - - // Very small angles produce an unexpected result because they are - // converted to a scientific notation string. - if (angle < 1e-6) { - angle = 0; - } - } else { - var p0 = getCoords(ctx, fillStyle.x0_, fillStyle.y0_); - focus = { - x: (p0.x - min.x) / width, - y: (p0.y - min.y) / height - }; - - width /= arcScaleX * Z; - height /= arcScaleY * Z; - var dimension = m.max(width, height); - shift = 2 * fillStyle.r0_ / dimension; - expansion = 2 * fillStyle.r1_ / dimension - shift; - } - - // We need to sort the color stops in ascending order by offset, - // otherwise IE won't interpret it correctly. - var stops = fillStyle.colors_; - stops.sort(function(cs1, cs2) { - return cs1.offset - cs2.offset; - }); - - var length = stops.length; - var color1 = stops[0].color; - var color2 = stops[length - 1].color; - var opacity1 = stops[0].alpha * ctx.globalAlpha; - var opacity2 = stops[length - 1].alpha * ctx.globalAlpha; - - var colors = []; - for (var i = 0; i < length; i++) { - var stop = stops[i]; - colors.push(stop.offset * expansion + shift + ' ' + stop.color); - } - - // When colors attribute is used, the meanings of opacity and o:opacity2 - // are reversed. - lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"', - ' method="none" focus="100%"', - ' color="', color1, '"', - ' color2="', color2, '"', - ' colors="', colors.join(','), '"', - ' opacity="', opacity2, '"', - ' g_o_:opacity2="', opacity1, '"', - ' angle="', angle, '"', - ' focusposition="', focus.x, ',', focus.y, '" />'); - } else if (fillStyle instanceof CanvasPattern_) { - if (width && height) { - var deltaLeft = -min.x; - var deltaTop = -min.y; - lineStr.push('<g_vml_:fill', - ' position="', - deltaLeft / width * arcScaleX * arcScaleX, ',', - deltaTop / height * arcScaleY * arcScaleY, '"', - ' type="tile"', - // TODO: Figure out the correct size to fit the scale. - //' size="', w, 'px ', h, 'px"', - ' src="', fillStyle.src_, '" />'); - } - } else { - var a = processStyle(ctx.fillStyle); - var color = a.color; - var opacity = a.alpha * ctx.globalAlpha; - lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity, - '" />'); - } - } - - contextPrototype.fill = function() { - this.stroke(true); - }; - - contextPrototype.closePath = function() { - this.currentPath_.push({type: 'close'}); - }; - - function getCoords(ctx, aX, aY) { - var m = ctx.m_; - return { - x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2, - y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2 - }; - }; - - contextPrototype.save = function() { - var o = {}; - copyState(this, o); - this.aStack_.push(o); - this.mStack_.push(this.m_); - this.m_ = matrixMultiply(createMatrixIdentity(), this.m_); - }; - - contextPrototype.restore = function() { - if (this.aStack_.length) { - copyState(this.aStack_.pop(), this); - this.m_ = this.mStack_.pop(); - } - }; - - function matrixIsFinite(m) { - return isFinite(m[0][0]) && isFinite(m[0][1]) && - isFinite(m[1][0]) && isFinite(m[1][1]) && - isFinite(m[2][0]) && isFinite(m[2][1]); - } - - function setM(ctx, m, updateLineScale) { - if (!matrixIsFinite(m)) { - return; - } - ctx.m_ = m; - - if (updateLineScale) { - // Get the line scale. - // Determinant of this.m_ means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - var det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; - ctx.lineScale_ = sqrt(abs(det)); - } - } - - contextPrototype.translate = function(aX, aY) { - var m1 = [ - [1, 0, 0], - [0, 1, 0], - [aX, aY, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), false); - }; - - contextPrototype.rotate = function(aRot) { - var c = mc(aRot); - var s = ms(aRot); - - var m1 = [ - [c, s, 0], - [-s, c, 0], - [0, 0, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), false); - }; - - contextPrototype.scale = function(aX, aY) { - this.arcScaleX_ *= aX; - this.arcScaleY_ *= aY; - var m1 = [ - [aX, 0, 0], - [0, aY, 0], - [0, 0, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), true); - }; - - contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) { - var m1 = [ - [m11, m12, 0], - [m21, m22, 0], - [dx, dy, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), true); - }; - - contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) { - var m = [ - [m11, m12, 0], - [m21, m22, 0], - [dx, dy, 1] - ]; - - setM(this, m, true); - }; - - /** - * The text drawing function. - * The maxWidth argument isn't taken in account, since no browser supports - * it yet. - */ - contextPrototype.drawText_ = function(text, x, y, maxWidth, stroke) { - var m = this.m_, - delta = 1000, - left = 0, - right = delta, - offset = {x: 0, y: 0}, - lineStr = []; - - var fontStyle = getComputedStyle(processFontStyle(this.font), - this.element_); - - var fontStyleString = buildStyle(fontStyle); - - var elementStyle = this.element_.currentStyle; - var textAlign = this.textAlign.toLowerCase(); - switch (textAlign) { - case 'left': - case 'center': - case 'right': - break; - case 'end': - textAlign = elementStyle.direction == 'ltr' ? 'right' : 'left'; - break; - case 'start': - textAlign = elementStyle.direction == 'rtl' ? 'right' : 'left'; - break; - default: - textAlign = 'left'; - } - - // 1.75 is an arbitrary number, as there is no info about the text baseline - switch (this.textBaseline) { - case 'hanging': - case 'top': - offset.y = fontStyle.size / 1.75; - break; - case 'middle': - break; - default: - case null: - case 'alphabetic': - case 'ideographic': - case 'bottom': - offset.y = -fontStyle.size / 2.25; - break; - } - - switch(textAlign) { - case 'right': - left = delta; - right = 0.05; - break; - case 'center': - left = right = delta / 2; - break; - } - - var d = getCoords(this, x + offset.x, y + offset.y); - - lineStr.push('<g_vml_:line from="', -left ,' 0" to="', right ,' 0.05" ', - ' coordsize="100 100" coordorigin="0 0"', - ' filled="', !stroke, '" stroked="', !!stroke, - '" style="position:absolute;width:1px;height:1px;">'); - - if (stroke) { - appendStroke(this, lineStr); - } else { - // TODO: Fix the min and max params. - appendFill(this, lineStr, {x: -left, y: 0}, - {x: right, y: fontStyle.size}); - } - - var skewM = m[0][0].toFixed(3) + ',' + m[1][0].toFixed(3) + ',' + - m[0][1].toFixed(3) + ',' + m[1][1].toFixed(3) + ',0,0'; - - var skewOffset = mr(d.x / Z) + ',' + mr(d.y / Z); - - lineStr.push('<g_vml_:skew on="t" matrix="', skewM ,'" ', - ' offset="', skewOffset, '" origin="', left ,' 0" />', - '<g_vml_:path textpathok="true" />', - '<g_vml_:textpath on="true" string="', - encodeHtmlAttribute(text), - '" style="v-text-align:', textAlign, - ';font:', encodeHtmlAttribute(fontStyleString), - '" /></g_vml_:line>'); - - this.element_.insertAdjacentHTML('beforeEnd', lineStr.join('')); - }; - - contextPrototype.fillText = function(text, x, y, maxWidth) { - this.drawText_(text, x, y, maxWidth, false); - }; - - contextPrototype.strokeText = function(text, x, y, maxWidth) { - this.drawText_(text, x, y, maxWidth, true); - }; - - contextPrototype.measureText = function(text) { - if (!this.textMeasureEl_) { - var s = '<span style="position:absolute;' + - 'top:-20000px;left:0;padding:0;margin:0;border:none;' + - 'white-space:pre;"></span>'; - this.element_.insertAdjacentHTML('beforeEnd', s); - this.textMeasureEl_ = this.element_.lastChild; - } - var doc = this.element_.ownerDocument; - this.textMeasureEl_.innerHTML = ''; - this.textMeasureEl_.style.font = this.font; - // Don't use innerHTML or innerText because they allow markup/whitespace. - this.textMeasureEl_.appendChild(doc.createTextNode(text)); - return {width: this.textMeasureEl_.offsetWidth}; - }; - - /******** STUBS ********/ - contextPrototype.clip = function() { - // TODO: Implement - }; - - contextPrototype.arcTo = function() { - // TODO: Implement - }; - - contextPrototype.createPattern = function(image, repetition) { - return new CanvasPattern_(image, repetition); - }; - - // Gradient / Pattern Stubs - function CanvasGradient_(aType) { - this.type_ = aType; - this.x0_ = 0; - this.y0_ = 0; - this.r0_ = 0; - this.x1_ = 0; - this.y1_ = 0; - this.r1_ = 0; - this.colors_ = []; - } - - CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) { - aColor = processStyle(aColor); - this.colors_.push({offset: aOffset, - color: aColor.color, - alpha: aColor.alpha}); - }; - - function CanvasPattern_(image, repetition) { - assertImageIsValid(image); - switch (repetition) { - case 'repeat': - case null: - case '': - this.repetition_ = 'repeat'; - break - case 'repeat-x': - case 'repeat-y': - case 'no-repeat': - this.repetition_ = repetition; - break; - default: - throwException('SYNTAX_ERR'); - } - - this.src_ = image.src; - this.width_ = image.width; - this.height_ = image.height; - } - - function throwException(s) { - throw new DOMException_(s); - } - - function assertImageIsValid(img) { - if (!img || img.nodeType != 1 || img.tagName != 'IMG') { - throwException('TYPE_MISMATCH_ERR'); - } - if (img.readyState != 'complete') { - throwException('INVALID_STATE_ERR'); - } - } - - function DOMException_(s) { - this.code = this[s]; - this.message = s +': DOM Exception ' + this.code; - } - var p = DOMException_.prototype = new Error; - p.INDEX_SIZE_ERR = 1; - p.DOMSTRING_SIZE_ERR = 2; - p.HIERARCHY_REQUEST_ERR = 3; - p.WRONG_DOCUMENT_ERR = 4; - p.INVALID_CHARACTER_ERR = 5; - p.NO_DATA_ALLOWED_ERR = 6; - p.NO_MODIFICATION_ALLOWED_ERR = 7; - p.NOT_FOUND_ERR = 8; - p.NOT_SUPPORTED_ERR = 9; - p.INUSE_ATTRIBUTE_ERR = 10; - p.INVALID_STATE_ERR = 11; - p.SYNTAX_ERR = 12; - p.INVALID_MODIFICATION_ERR = 13; - p.NAMESPACE_ERR = 14; - p.INVALID_ACCESS_ERR = 15; - p.VALIDATION_ERR = 16; - p.TYPE_MISMATCH_ERR = 17; - - // set up externs - G_vmlCanvasManager = G_vmlCanvasManager_; - CanvasRenderingContext2D = CanvasRenderingContext2D_; - CanvasGradient = CanvasGradient_; - CanvasPattern = CanvasPattern_; - DOMException = DOMException_; -})(); - -} // if diff --git a/libs/jqplot/jqplot.linearTickGenerator.js b/libs/jqplot/jqplot.linearTickGenerator.js deleted file mode 100644 index 75527bf794..0000000000 --- a/libs/jqplot/jqplot.linearTickGenerator.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * The following code was generaously given to me a while back by Scott Prahl. - * He did a good job at computing axes min, max and number of ticks for the - * case where the user has not set any scale related parameters (tickInterval, - * numberTicks, min or max). I had ignored this use case for a long time, - * focusing on the more difficult case where user has set some option controlling - * tick generation. Anyway, about time I got this into jqPlot. - * Thanks Scott!! - */ - - /** - * Copyright (c) 2010 Scott Prahl - * The next three routines are 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. - */ - - // A good format string depends on the interval. If the interval is greater - // than 1 then there is no need to show any decimal digits. If it is < 1.0, then - // use the magnitude of the interval to determine the number of digits to show. - function bestFormatString (interval) - { - interval = Math.abs(interval); - if (interval > 1) {return '%d';} - - var expv = -Math.floor(Math.log(interval)/Math.LN10); - return '%.' + expv + 'f'; - } - - // This will return an interval of form 2 * 10^n, 5 * 10^n or 10 * 10^n - function bestLinearInterval(range, scalefact) { - var expv = Math.floor(Math.log(range)/Math.LN10); - var magnitude = Math.pow(10, expv); - // 0 < f < 10 - var f = range / magnitude; - // console.log('f: %s, scaled: %s ', f, f/scalefact); - // for large plots, scalefact will decrease f and increase number of ticks. - // for small plots, scalefact will increase f and decrease number of ticks. - f = f/scalefact; - - // for large plots, smaller interval, more ticks. - if (f<=0.38) {return 0.1*magnitude;} - if (f<=1.6) {return 0.2*magnitude;} - if (f<=4.0) {return 0.5*magnitude;} - if (f<=8.0) {return magnitude;} - // for very small plots, larger interval, less ticks in number ticks - if (f<=16.0) {return 2*magnitude;} - return 5*magnitude; - } - - // Given the min and max for a dataset, return suitable endpoints - // for the graphing, a good number for the number of ticks, and a - // format string so that extraneous digits are not displayed. - // returned is an array containing [min, max, nTicks, format] - $.jqplot.LinearTickGenerator = function(axis_min, axis_max, scalefact) { - // if endpoints are equal try to include zero otherwise include one - if (axis_min == axis_max) { - axis_max = (axis_max) ? 0 : 1; - } - - scalefact = scalefact || 1.0; - - // make sure range is positive - if (axis_max < axis_min) { - var a = axis_max; - axis_max = axis_min; - axis_min = a; - } - - var ss = bestLinearInterval(axis_max - axis_min, scalefact); - var r = []; - - // Figure out the axis min, max and number of ticks - // the min and max will be some multiple of the tick interval, - // 1*10^n, 2*10^n or 5*10^n. This gaurantees that, if the - // axis min is negative, 0 will be a tick. - r[0] = Math.floor(axis_min / ss) * ss; // min - r[1] = Math.ceil(axis_max / ss) * ss; // max - r[2] = Math.round((r[1]-r[0])/ss+1.0); // number of ticks - r[3] = bestFormatString(ss); // format string - r[4] = ss; // tick Interval - return r; - }; - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/jquery.jqplot.css b/libs/jqplot/jquery.jqplot.css deleted file mode 100644 index c9bf6f923b..0000000000 --- a/libs/jqplot/jquery.jqplot.css +++ /dev/null @@ -1,226 +0,0 @@ -/*rules for the plot target div. These will be cascaded down to all plot elements according to css rules*/ -.jqplot-target { - position: relative; - color: #666666; - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - font-size: 1em; -/* height: 300px; - width: 400px;*/ -} - -/*rules applied to all axes*/ -.jqplot-axis { - font-size: 0.75em; -} - -.jqplot-xaxis { - margin-top: 10px; -} - -.jqplot-x2axis { - margin-bottom: 10px; -} - -.jqplot-yaxis { - margin-right: 10px; -} - -.jqplot-y2axis, .jqplot-y3axis, .jqplot-y4axis, .jqplot-y5axis, .jqplot-y6axis, .jqplot-y7axis, .jqplot-y8axis, .jqplot-y9axis { - margin-left: 10px; - margin-right: 10px; -} - -/*rules applied to all axis tick divs*/ -.jqplot-axis-tick, .jqplot-xaxis-tick, .jqplot-yaxis-tick, .jqplot-x2axis-tick, .jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick { - position: absolute; -} - - -.jqplot-xaxis-tick { - top: 0px; - /* initial position untill tick is drawn in proper place */ - left: 15px; -/* padding-top: 10px;*/ - vertical-align: top; -} - -.jqplot-x2axis-tick { - bottom: 0px; - /* initial position untill tick is drawn in proper place */ - left: 15px; -/* padding-bottom: 10px;*/ - vertical-align: bottom; -} - -.jqplot-yaxis-tick { - right: 0px; - /* initial position untill tick is drawn in proper place */ - top: 15px; -/* padding-right: 10px;*/ - text-align: right; -} - -.jqplot-yaxis-tick.jqplot-breakTick { - right: -20px; - margin-right: 0px; - padding:1px 5px 1px 5px; -/* background-color: white;*/ - z-index: 2; - font-size: 1.5em; -} - -.jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick { - left: 0px; - /* initial position untill tick is drawn in proper place */ - top: 15px; -/* padding-left: 10px;*/ -/* padding-right: 15px;*/ - text-align: left; -} - -.jqplot-meterGauge-tick { - font-size: 0.75em; - color: #999999; -} - -.jqplot-meterGauge-label { - font-size: 1em; - color: #999999; -} -.jqplot-xaxis-label { - margin-top: 10px; - font-size: 11pt; - position: absolute; -} - -.jqplot-x2axis-label { - margin-bottom: 10px; - font-size: 11pt; - position: absolute; -} - -.jqplot-yaxis-label { - margin-right: 10px; -/* text-align: center;*/ - font-size: 11pt; - position: absolute; -} - -.jqplot-y2axis-label, .jqplot-y3axis-label, .jqplot-y4axis-label, .jqplot-y5axis-label, .jqplot-y6axis-label, .jqplot-y7axis-label, .jqplot-y8axis-label, .jqplot-y9axis-label { -/* text-align: center;*/ - font-size: 11pt; - position: absolute; -} - -table.jqplot-table-legend { - margin-top: 12px; - margin-bottom: 12px; - margin-left: 12px; - margin-right: 12px; -} - -table.jqplot-table-legend, table.jqplot-cursor-legend { - background-color: rgba(255,255,255,0.6); - border: 1px solid #cccccc; - position: absolute; - font-size: 0.75em; -} - -td.jqplot-table-legend { - vertical-align:middle; -} - -td.jqplot-seriesToggle:hover, td.jqplot-seriesToggle:active { - cursor: pointer; -} - -td.jqplot-table-legend > div { - border: 1px solid #cccccc; - padding:1px; -} - -div.jqplot-table-legend-swatch { - width:0px; - height:0px; - border-top-width: 5px; - border-bottom-width: 5px; - border-left-width: 6px; - border-right-width: 6px; - border-top-style: solid; - border-bottom-style: solid; - border-left-style: solid; - border-right-style: solid; -} - -.jqplot-title { - top: 0px; - left: 0px; - padding-bottom: 0.5em; - font-size: 1.2em; -} - -table.jqplot-cursor-tooltip { - border: 1px solid #cccccc; - font-size: 0.75em; -} - - -.jqplot-cursor-tooltip { - border: 1px solid #cccccc; - font-size: 0.75em; - white-space: nowrap; - background: rgba(208,208,208,0.5); - padding: 1px; -} - -.jqplot-highlighter-tooltip { - border: 1px solid #cccccc; - font-size: 0.75em; - white-space: nowrap; - background: rgba(208,208,208,0.5); - padding: 1px; -} - -.jqplot-point-label { - font-size: 0.75em; - z-index: 2; -} - -td.jqplot-cursor-legend-swatch { -vertical-align:middle; -text-align:center; -} - -div.jqplot-cursor-legend-swatch { -width:1.2em; -height:0.7em; -} - -.jqplot-error { -/* Styles added to the plot target container when there is an error go here.*/ - text-align: center; -} - -.jqplot-error-message { -/* Styling of the custom error message div goes here.*/ - position: relative; - top: 46%; - display: inline-block; -} - -div.jqplot-bubble-label { - font-size: 0.8em; -/* background: rgba(90%, 90%, 90%, 0.15);*/ - padding-left: 2px; - padding-right: 2px; - color: rgb(20%, 20%, 20%); -} - -div.jqplot-bubble-label.jqplot-bubble-label-highlight { - background: rgba(90%, 90%, 90%, 0.7); -} - -div.jqplot-noData-container { - text-align: center; - background-color: rgba(96%, 96%, 96%, 0.3); -} diff --git a/libs/jqplot/jquery.jqplot.js b/libs/jqplot/jquery.jqplot.js deleted file mode 100644 index f10dc79809..0000000000 --- a/libs/jqplot/jquery.jqplot.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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 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." - * - */ - - /** - * - * This is a boot loader for the source version of jqplot. - * It will load all of the necessary core jqplot files that - * are concated together in the distribution. - * - */ - -(function(){ - var getRootNode = function(){ - // figure out the path to this loader - if(this["document"] && this["document"]["getElementsByTagName"]){ - var scripts = document.getElementsByTagName("script"); - var pat = /jquery\.jqplot\.js/i; - for(var i = 0; i < scripts.length; i++){ - var src = scripts[i].getAttribute("src"); - if(!src){ continue; } - var m = src.match(pat); - if(m){ - return { - node: scripts[i], - root: src.substring(0, m.index) - }; - } - } - } - }; - - - var files = ['jqplot.core.js', 'jqplot.linearTickGenerator.js', 'jqplot.linearAxisRenderer.js', 'jqplot.axisTickRenderer.js', 'jqplot.axisLabelRenderer.js', 'jqplot.tableLegendRenderer.js', 'jqplot.lineRenderer.js', 'jqplot.markerRenderer.js', 'jqplot.divTitleRenderer.js', 'jqplot.canvasGridRenderer.js', 'jqplot.shadowRenderer.js', 'jqplot.shapeRenderer.js', 'jqplot.sprintf.js', 'jsdate.js', 'jqplot.themeEngine.js']; - var rn = getRootNode().root; - for (var i=0; i<files.length; i++) { - var pp = rn+files[i]; - try { - document.write("<scr"+"ipt type='text/javascript' src='"+pp+"'></scr"+"ipt>"); - } catch (e) { - var script = document.createElement("script"); - script.src = pp; - document.getElementsByTagName("head")[0].appendChild(script); - // avoid memory leak - script = null; - } - } - -})();
\ No newline at end of file diff --git a/libs/jqplot/jsdate.js b/libs/jqplot/jsdate.js deleted file mode 100644 index 38c55fa671..0000000000 --- a/libs/jqplot/jsdate.js +++ /dev/null @@ -1,1437 +0,0 @@ - -/** - * @fileOverview Date parsing and formatting operations without extending the Date built-in object. - * @author Chris Leonello - * @version #VERSION# - * @date #DATE# - */ - -(function($) { - - /** - * @description - * <p>Object with extended date parsing and formatting capabilities. - * This library borrows many concepts and ideas from the Date Instance - * Methods by Ken Snyder along with some parts of Ken's actual code.</p> - * - * <p>jsDate takes a different approach by not extending the built-in - * Date Object, improving date parsing, allowing for multiple formatting - * syntaxes and multiple and more easily expandable localization.</p> - * - * @author Chris Leonello - * @date #date# - * @version #VERSION# - * @copyright (c) 2010 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. - * - * <p>Ken's origianl Date Instance Methods and copyright notice:</p> - * <pre> - * 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/) - * </pre> - * - * @class - * @name jsDate - * @param {String | Number | Array | Date Object | Options Object} arguments Optional arguments, either a parsable date/time string, - * a JavaScript timestamp, an array of numbers of form [year, month, day, hours, minutes, seconds, milliseconds], - * a Date object, or an options object of form {syntax: "perl", date:some Date} where all options are optional. - */ - - var jsDate = function () { - - this.syntax = jsDate.config.syntax; - this._type = "jsDate"; - this.utcOffset = new Date().getTimezoneOffset * 60000; - this.proxy = new Date(); - this.options = {}; - this.locale = jsDate.regional.getLocale(); - this.formatString = ''; - this.defaultCentury = jsDate.config.defaultCentury; - - switch ( arguments.length ) { - case 0: - break; - case 1: - // other objects either won't have a _type property or, - // if they do, it shouldn't be set to "jsDate", so - // assume it is an options argument. - if (get_type(arguments[0]) == "[object Object]" && arguments[0]._type != "jsDate") { - var opts = this.options = arguments[0]; - this.syntax = opts.syntax || this.syntax; - this.defaultCentury = opts.defaultCentury || this.defaultCentury; - this.proxy = jsDate.createDate(opts.date); - } - else { - this.proxy = jsDate.createDate(arguments[0]); - } - break; - default: - var a = []; - for ( var i=0; i<arguments.length; i++ ) { - a.push(arguments[i]); - } - this.proxy = new Date( this.utcOffset ); - this.proxy.setFullYear.apply( this.proxy, a.slice(0,3) ); - if ( a.slice(3).length ) { - this.proxy.setHours.apply( this.proxy, a.slice(3) ); - } - break; - } - }; - - /** - * @namespace Configuration options that will be used as defaults for all instances on the page. - * @property {String} defaultLocale The default locale to use [en]. - * @property {String} syntax The default syntax to use [perl]. - */ - jsDate.config = { - defaultLocale: 'en', - syntax: 'perl', - defaultCentury: 1900 - }; - - /** - * Add an arbitrary amount to the currently stored date - * - * @param {Number} number - * @param {String} unit - * @returns {jsDate} - */ - - jsDate.prototype.add = function(number, unit) { - var factor = multipliers[unit] || multipliers.day; - if (typeof factor == 'number') { - this.proxy.setTime(this.proxy.getTime() + (factor * number)); - } else { - factor.add(this, number); - } - return this; - }; - - /** - * Create a new jqplot.date object with the same date - * - * @returns {jsDate} - */ - - jsDate.prototype.clone = function() { - return new jsDate(this.proxy.getTime()); - }; - - /** - * Find the difference between this jsDate and another date. - * - * @param {String| Number| Array| jsDate Object| Date Object} dateObj - * @param {String} unit - * @param {Boolean} allowDecimal - * @returns {Number} Number of units difference between dates. - */ - - jsDate.prototype.diff = function(dateObj, unit, allowDecimal) { - // ensure we have a Date object - dateObj = new jsDate(dateObj); - if (dateObj === null) { - return null; - } - // get the multiplying factor integer or factor function - var factor = multipliers[unit] || multipliers.day; - if (typeof factor == 'number') { - // multiply - var unitDiff = (this.proxy.getTime() - dateObj.proxy.getTime()) / factor; - } else { - // run function - var unitDiff = factor.diff(this.proxy, dateObj.proxy); - } - // if decimals are not allowed, round toward zero - return (allowDecimal ? unitDiff : Math[unitDiff > 0 ? 'floor' : 'ceil'](unitDiff)); - }; - - /** - * Get the abbreviated name of the current week day - * - * @returns {String} - */ - - jsDate.prototype.getAbbrDayName = function() { - return jsDate.regional[this.locale]["dayNamesShort"][this.proxy.getDay()]; - }; - - /** - * Get the abbreviated name of the current month - * - * @returns {String} - */ - - jsDate.prototype.getAbbrMonthName = function() { - return jsDate.regional[this.locale]["monthNamesShort"][this.proxy.getMonth()]; - }; - - /** - * Get UPPER CASE AM or PM for the current time - * - * @returns {String} - */ - - jsDate.prototype.getAMPM = function() { - return this.proxy.getHours() >= 12 ? 'PM' : 'AM'; - }; - - /** - * Get lower case am or pm for the current time - * - * @returns {String} - */ - - jsDate.prototype.getAmPm = function() { - return this.proxy.getHours() >= 12 ? 'pm' : 'am'; - }; - - /** - * Get the century (19 for 20th Century) - * - * @returns {Integer} Century (19 for 20th century). - */ - jsDate.prototype.getCentury = function() { - return parseInt(this.proxy.getFullYear()/100, 10); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getDate = function() { - return this.proxy.getDate(); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getDay = function() { - return this.proxy.getDay(); - }; - - /** - * Get the Day of week 1 (Monday) thru 7 (Sunday) - * - * @returns {Integer} Day of week 1 (Monday) thru 7 (Sunday) - */ - jsDate.prototype.getDayOfWeek = function() { - var dow = this.proxy.getDay(); - return dow===0?7:dow; - }; - - /** - * Get the day of the year - * - * @returns {Integer} 1 - 366, day of the year - */ - jsDate.prototype.getDayOfYear = function() { - var d = this.proxy; - var ms = d - new Date('' + d.getFullYear() + '/1/1 GMT'); - ms += d.getTimezoneOffset()*60000; - d = null; - return parseInt(ms/60000/60/24, 10)+1; - }; - - /** - * Get the name of the current week day - * - * @returns {String} - */ - - jsDate.prototype.getDayName = function() { - return jsDate.regional[this.locale]["dayNames"][this.proxy.getDay()]; - }; - - /** - * Get the week number of the given year, starting with the first Sunday as the first week - * @returns {Integer} Week number (13 for the 13th full week of the year). - */ - jsDate.prototype.getFullWeekOfYear = function() { - var d = this.proxy; - var doy = this.getDayOfYear(); - var rdow = 6-d.getDay(); - var woy = parseInt((doy+rdow)/7, 10); - return woy; - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getFullYear = function() { - return this.proxy.getFullYear(); - }; - - /** - * Get the GMT offset in hours and minutes (e.g. +06:30) - * - * @returns {String} - */ - - jsDate.prototype.getGmtOffset = function() { - // divide the minutes offset by 60 - var hours = this.proxy.getTimezoneOffset() / 60; - // decide if we are ahead of or behind GMT - var prefix = hours < 0 ? '+' : '-'; - // remove the negative sign if any - hours = Math.abs(hours); - // add the +/- to the padded number of hours to : to the padded minutes - return prefix + addZeros(Math.floor(hours), 2) + ':' + addZeros((hours % 1) * 60, 2); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getHours = function() { - return this.proxy.getHours(); - }; - - /** - * Get the current hour on a 12-hour scheme - * - * @returns {Integer} - */ - - jsDate.prototype.getHours12 = function() { - var hours = this.proxy.getHours(); - return hours > 12 ? hours - 12 : (hours == 0 ? 12 : hours); - }; - - - jsDate.prototype.getIsoWeek = function() { - var d = this.proxy; - var woy = d.getWeekOfYear(); - var dow1_1 = (new Date('' + d.getFullYear() + '/1/1')).getDay(); - // First week is 01 and not 00 as in the case of %U and %W, - // so we add 1 to the final result except if day 1 of the year - // is a Monday (then %W returns 01). - // We also need to subtract 1 if the day 1 of the year is - // Friday-Sunday, so the resulting equation becomes: - var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1); - if(idow == 53 && (new Date('' + d.getFullYear() + '/12/31')).getDay() < 4) - { - idow = 1; - } - else if(idow === 0) - { - d = new jsDate(new Date('' + (d.getFullYear()-1) + '/12/31')); - idow = d.getIsoWeek(); - } - d = null; - return idow; - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getMilliseconds = function() { - return this.proxy.getMilliseconds(); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getMinutes = function() { - return this.proxy.getMinutes(); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getMonth = function() { - return this.proxy.getMonth(); - }; - - /** - * Get the name of the current month - * - * @returns {String} - */ - - jsDate.prototype.getMonthName = function() { - return jsDate.regional[this.locale]["monthNames"][this.proxy.getMonth()]; - }; - - /** - * Get the number of the current month, 1-12 - * - * @returns {Integer} - */ - - jsDate.prototype.getMonthNumber = function() { - return this.proxy.getMonth() + 1; - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getSeconds = function() { - return this.proxy.getSeconds(); - }; - - /** - * Return a proper two-digit year integer - * - * @returns {Integer} - */ - - jsDate.prototype.getShortYear = function() { - return this.proxy.getYear() % 100; - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getTime = function() { - return this.proxy.getTime(); - }; - - /** - * Get the timezone abbreviation - * - * @returns {String} Abbreviation for the timezone - */ - jsDate.prototype.getTimezoneAbbr = function() { - return this.proxy.toString().replace(/^.*\(([^)]+)\)$/, '$1'); - }; - - /** - * Get the browser-reported name for the current timezone (e.g. MDT, Mountain Daylight Time) - * - * @returns {String} - */ - jsDate.prototype.getTimezoneName = function() { - var match = /(?:\((.+)\)$| ([A-Z]{3}) )/.exec(this.toString()); - return match[1] || match[2] || 'GMT' + this.getGmtOffset(); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getTimezoneOffset = function() { - return this.proxy.getTimezoneOffset(); - }; - - - /** - * Get the week number of the given year, starting with the first Monday as the first week - * @returns {Integer} Week number (13 for the 13th week of the year). - */ - jsDate.prototype.getWeekOfYear = function() { - var doy = this.getDayOfYear(); - var rdow = 7 - this.getDayOfWeek(); - var woy = parseInt((doy+rdow)/7, 10); - return woy; - }; - - /** - * Get the current date as a Unix timestamp - * - * @returns {Integer} - */ - - jsDate.prototype.getUnix = function() { - return Math.round(this.proxy.getTime() / 1000, 0); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.getYear = function() { - return this.proxy.getYear(); - }; - - /** - * Return a date one day ahead (or any other unit) - * - * @param {String} unit Optional, year | month | day | week | hour | minute | second | millisecond - * @returns {jsDate} - */ - - jsDate.prototype.next = function(unit) { - unit = unit || 'day'; - return this.clone().add(1, unit); - }; - - /** - * Set the jsDate instance to a new date. - * - * @param {String | Number | Array | Date Object | jsDate Object | Options Object} arguments Optional arguments, - * either a parsable date/time string, - * a JavaScript timestamp, an array of numbers of form [year, month, day, hours, minutes, seconds, milliseconds], - * a Date object, jsDate Object or an options object of form {syntax: "perl", date:some Date} where all options are optional. - */ - jsDate.prototype.set = function() { - switch ( arguments.length ) { - case 0: - this.proxy = new Date(); - break; - case 1: - // other objects either won't have a _type property or, - // if they do, it shouldn't be set to "jsDate", so - // assume it is an options argument. - if (get_type(arguments[0]) == "[object Object]" && arguments[0]._type != "jsDate") { - var opts = this.options = arguments[0]; - this.syntax = opts.syntax || this.syntax; - this.defaultCentury = opts.defaultCentury || this.defaultCentury; - this.proxy = jsDate.createDate(opts.date); - } - else { - this.proxy = jsDate.createDate(arguments[0]); - } - break; - default: - var a = []; - for ( var i=0; i<arguments.length; i++ ) { - a.push(arguments[i]); - } - this.proxy = new Date( this.utcOffset ); - this.proxy.setFullYear.apply( this.proxy, a.slice(0,3) ); - if ( a.slice(3).length ) { - this.proxy.setHours.apply( this.proxy, a.slice(3) ); - } - break; - } - }; - - /** - * Sets the day of the month for a specified date according to local time. - * @param {Integer} dayValue An integer from 1 to 31, representing the day of the month. - */ - jsDate.prototype.setDate = function(n) { - return this.proxy.setDate(n); - }; - - /** - * Sets the full year for a specified date according to local time. - * @param {Integer} yearValue The numeric value of the year, for example, 1995. - * @param {Integer} monthValue Optional, between 0 and 11 representing the months January through December. - * @param {Integer} dayValue Optional, between 1 and 31 representing the day of the month. If you specify the dayValue parameter, you must also specify the monthValue. - */ - jsDate.prototype.setFullYear = function() { - return this.proxy.setFullYear.apply(this.proxy, arguments); - }; - - /** - * Sets the hours for a specified date according to local time. - * - * @param {Integer} hoursValue An integer between 0 and 23, representing the hour. - * @param {Integer} minutesValue Optional, An integer between 0 and 59, representing the minutes. - * @param {Integer} secondsValue Optional, An integer between 0 and 59, representing the seconds. - * If you specify the secondsValue parameter, you must also specify the minutesValue. - * @param {Integer} msValue Optional, A number between 0 and 999, representing the milliseconds. - * If you specify the msValue parameter, you must also specify the minutesValue and secondsValue. - */ - jsDate.prototype.setHours = function() { - return this.proxy.setHours.apply(this.proxy, arguments); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.setMilliseconds = function(n) { - return this.proxy.setMilliseconds(n); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.setMinutes = function() { - return this.proxy.setMinutes.apply(this.proxy, arguments); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.setMonth = function() { - return this.proxy.setMonth.apply(this.proxy, arguments); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.setSeconds = function() { - return this.proxy.setSeconds.apply(this.proxy, arguments); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.setTime = function(n) { - return this.proxy.setTime(n); - }; - - /** - * Implements Date functionality - */ - jsDate.prototype.setYear = function() { - return this.proxy.setYear.apply(this.proxy, arguments); - }; - - /** - * Provide a formatted string representation of this date. - * - * @param {String} formatString A format string. - * See: {@link jsDate.formats}. - * @returns {String} Date String. - */ - - jsDate.prototype.strftime = function(formatString) { - formatString = formatString || this.formatString || jsDate.regional[this.locale]['formatString']; - return jsDate.strftime(this, formatString, this.syntax); - }; - - /** - * Return a String representation of this jsDate object. - * @returns {String} Date string. - */ - - jsDate.prototype.toString = function() { - return this.proxy.toString(); - }; - - /** - * Convert the current date to an 8-digit integer (%Y%m%d) - * - * @returns {Integer} - */ - - jsDate.prototype.toYmdInt = function() { - return (this.proxy.getFullYear() * 10000) + (this.getMonthNumber() * 100) + this.proxy.getDate(); - }; - - /** - * @namespace Holds localizations for month/day names. - * <p>jsDate attempts to detect locale when loaded and defaults to 'en'. - * If a localization is detected which is not available, jsDate defaults to 'en'. - * Additional localizations can be added after jsDate loads. After adding a localization, - * call the jsDate.regional.getLocale() method. Currently, en, fr and de are defined.</p> - * - * <p>Localizations must be an object and have the following properties defined: monthNames, monthNamesShort, dayNames, dayNamesShort and Localizations are added like:</p> - * <pre class="code"> - * jsDate.regional['en'] = { - * monthNames : 'January February March April May June July August September October November December'.split(' '), - * monthNamesShort : 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '), - * dayNames : 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'.split(' '), - * dayNamesShort : 'Sun Mon Tue Wed Thu Fri Sat'.split(' ') - * }; - * </pre> - * <p>After adding localizations, call <code>jsDate.regional.getLocale();</code> to update the locale setting with the - * new localizations.</p> - */ - - jsDate.regional = { - 'en': { - monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'], - monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], - dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], - dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'fr': { - monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'], - monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun','Jul','Aoû','Sep','Oct','Nov','Déc'], - dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'], - dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'de': { - monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'], - monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'], - dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], - dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'es': { - monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio', 'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'], - monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun', 'Jul','Ago','Sep','Oct','Nov','Dic'], - dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'], - dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'ru': { - monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'], - monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн','Июл','Авг','Сен','Окт','Ноя','Дек'], - dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'], - dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'ar': { - monthNames: ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'آذار', 'حزيران','تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'], - monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'], - dayNames: ['السبت', 'الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة'], - dayNamesShort: ['سبت', 'أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'pt': { - monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'], - monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'], - dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'], - dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'], - formatString: '%Y-%m-%d %H:%M:%S' - }, - - 'pt-BR': { - monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho', 'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'], - monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'], - dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'], - dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'], - formatString: '%Y-%m-%d %H:%M:%S' - } - - - }; - - // Set english variants to 'en' - jsDate.regional['en-US'] = jsDate.regional['en-GB'] = jsDate.regional['en']; - - /** - * Try to determine the users locale based on the lang attribute of the html page. Defaults to 'en' - * if it cannot figure out a locale of if the locale does not have a localization defined. - * @returns {String} locale - */ - - jsDate.regional.getLocale = function () { - var l = jsDate.config.defaultLocale; - - if ( document && document.getElementsByTagName('html') && document.getElementsByTagName('html')[0].lang ) { - l = document.getElementsByTagName('html')[0].lang; - if (!jsDate.regional.hasOwnProperty(l)) { - l = jsDate.config.defaultLocale; - } - } - - return l; - }; - - // ms in day - var day = 24 * 60 * 60 * 1000; - - // padd a number with zeros - var addZeros = function(num, digits) { - num = String(num); - var i = digits - num.length; - var s = String(Math.pow(10, i)).slice(1); - return s.concat(num); - }; - - // representations used for calculating differences between dates. - // This borrows heavily from Ken Snyder's work. - var multipliers = { - millisecond: 1, - second: 1000, - minute: 60 * 1000, - hour: 60 * 60 * 1000, - day: day, - week: 7 * day, - month: { - // add a number of months - add: function(d, number) { - // add any years needed (increments of 12) - multipliers.year.add(d, Math[number > 0 ? 'floor' : 'ceil'](number / 12)); - // ensure that we properly wrap betwen December and January - var prevMonth = d.getMonth() + (number % 12); - if (prevMonth == 12) { - prevMonth = 0; - d.setYear(d.getFullYear() + 1); - } else if (prevMonth == -1) { - prevMonth = 11; - d.setYear(d.getFullYear() - 1); - } - d.setMonth(prevMonth); - }, - // get the number of months between two Date objects (decimal to the nearest day) - diff: function(d1, d2) { - // get the number of years - var diffYears = d1.getFullYear() - d2.getFullYear(); - // get the number of remaining months - var diffMonths = d1.getMonth() - d2.getMonth() + (diffYears * 12); - // get the number of remaining days - var diffDays = d1.getDate() - d2.getDate(); - // return the month difference with the days difference as a decimal - return diffMonths + (diffDays / 30); - } - }, - year: { - // add a number of years - add: function(d, number) { - d.setYear(d.getFullYear() + Math[number > 0 ? 'floor' : 'ceil'](number)); - }, - // get the number of years between two Date objects (decimal to the nearest day) - diff: function(d1, d2) { - return multipliers.month.diff(d1, d2) / 12; - } - } - }; - // - // Alias each multiplier with an 's' to allow 'year' and 'years' for example. - // This comes from Ken Snyders work. - // - for (var unit in multipliers) { - if (unit.substring(unit.length - 1) != 's') { // IE will iterate newly added properties :| - multipliers[unit + 's'] = multipliers[unit]; - } - } - - // - // take a jsDate instance and a format code and return the formatted value. - // This is a somewhat modified version of Ken Snyder's method. - // - var format = function(d, code, syntax) { - // if shorcut codes are used, recursively expand those. - if (jsDate.formats[syntax]["shortcuts"][code]) { - return jsDate.strftime(d, jsDate.formats[syntax]["shortcuts"][code], syntax); - } else { - // get the format code function and addZeros() argument - var getter = (jsDate.formats[syntax]["codes"][code] || '').split('.'); - var nbr = d['get' + getter[0]] ? d['get' + getter[0]]() : ''; - if (getter[1]) { - nbr = addZeros(nbr, getter[1]); - } - return nbr; - } - }; - - /** - * @static - * Static function for convert a date to a string according to a given format. Also acts as namespace for strftime format codes. - * <p>strftime formatting can be accomplished without creating a jsDate object by calling jsDate.strftime():</p> - * <pre class="code"> - * var formattedDate = jsDate.strftime('Feb 8, 2006 8:48:32', '%Y-%m-%d %H:%M:%S'); - * </pre> - * @param {String | Number | Array | jsDate Object | Date Object} date A parsable date string, JavaScript time stamp, Array of form [year, month, day, hours, minutes, seconds, milliseconds], jsDate Object or Date object. - * @param {String} formatString String with embedded date formatting codes. - * See: {@link jsDate.formats}. - * @param {String} syntax Optional syntax to use [default perl]. - * @param {String} locale Optional locale to use. - * @returns {String} Formatted representation of the date. - */ - // - // Logic as implemented here is very similar to Ken Snyder's Date Instance Methods. - // - jsDate.strftime = function(d, formatString, syntax, locale) { - var syn = 'perl'; - var loc = jsDate.regional.getLocale(); - - // check if syntax and locale are available or reversed - if (syntax && jsDate.formats.hasOwnProperty(syntax)) { - syn = syntax; - } - else if (syntax && jsDate.regional.hasOwnProperty(syntax)) { - loc = syntax; - } - - if (locale && jsDate.formats.hasOwnProperty(locale)) { - syn = locale; - } - else if (locale && jsDate.regional.hasOwnProperty(locale)) { - loc = locale; - } - - if (get_type(d) != "[object Object]" || d._type != "jsDate") { - d = new jsDate(d); - d.locale = loc; - } - if (!formatString) { - formatString = d.formatString || jsDate.regional[loc]['formatString']; - } - // default the format string to year-month-day - var source = formatString || '%Y-%m-%d', - result = '', - match; - // replace each format code - while (source.length > 0) { - if (match = source.match(jsDate.formats[syn].codes.matcher)) { - result += source.slice(0, match.index); - result += (match[1] || '') + format(d, match[2], syn); - source = source.slice(match.index + match[0].length); - } else { - result += source; - source = ''; - } - } - return result; - }; - - /** - * @namespace - * Namespace to hold format codes and format shortcuts. "perl" and "php" format codes - * and shortcuts are defined by default. Additional codes and shortcuts can be - * added like: - * - * <pre class="code"> - * jsDate.formats["perl"] = { - * "codes": { - * matcher: /someregex/, - * Y: "fullYear", // name of "get" method without the "get", - * ..., // more codes - * }, - * "shortcuts": { - * F: '%Y-%m-%d', - * ..., // more shortcuts - * } - * }; - * </pre> - * - * <p>Additionally, ISO and SQL shortcuts are defined and can be accesses via: - * <code>jsDate.formats.ISO</code> and <code>jsDate.formats.SQL</code> - */ - - jsDate.formats = { - ISO:'%Y-%m-%dT%H:%M:%S.%N%G', - SQL:'%Y-%m-%d %H:%M:%S' - }; - - /** - * Perl format codes and shortcuts for strftime. - * - * A hash (object) of codes where each code must be an array where the first member is - * the name of a Date.prototype or jsDate.prototype function to call - * and optionally a second member indicating the number to pass to addZeros() - * - * <p>The following format codes are defined:</p> - * - * <pre class="code"> - * Code Result Description - * == Years == - * %Y 2008 Four-digit year - * %y 08 Two-digit year - * - * == Months == - * %m 09 Two-digit month - * %#m 9 One or two-digit month - * %B September Full month name - * %b Sep Abbreviated month name - * - * == Days == - * %d 05 Two-digit day of month - * %#d 5 One or two-digit day of month - * %e 5 One or two-digit day of month - * %A Sunday Full name of the day of the week - * %a Sun Abbreviated name of the day of the week - * %w 0 Number of the day of the week (0 = Sunday, 6 = Saturday) - * - * == Hours == - * %H 23 Hours in 24-hour format (two digits) - * %#H 3 Hours in 24-hour integer format (one or two digits) - * %I 11 Hours in 12-hour format (two digits) - * %#I 3 Hours in 12-hour integer format (one or two digits) - * %p PM AM or PM - * - * == Minutes == - * %M 09 Minutes (two digits) - * %#M 9 Minutes (one or two digits) - * - * == Seconds == - * %S 02 Seconds (two digits) - * %#S 2 Seconds (one or two digits) - * %s 1206567625723 Unix timestamp (Seconds past 1970-01-01 00:00:00) - * - * == Milliseconds == - * %N 008 Milliseconds (three digits) - * %#N 8 Milliseconds (one to three digits) - * - * == Timezone == - * %O 360 difference in minutes between local time and GMT - * %Z Mountain Standard Time Name of timezone as reported by browser - * %G 06:00 Hours and minutes between GMT - * - * == Shortcuts == - * %F 2008-03-26 %Y-%m-%d - * %T 05:06:30 %H:%M:%S - * %X 05:06:30 %H:%M:%S - * %x 03/26/08 %m/%d/%y - * %D 03/26/08 %m/%d/%y - * %#c Wed Mar 26 15:31:00 2008 %a %b %e %H:%M:%S %Y - * %v 3-Sep-2008 %e-%b-%Y - * %R 15:31 %H:%M - * %r 03:31:00 PM %I:%M:%S %p - * - * == Characters == - * %n \n Newline - * %t \t Tab - * %% % Percent Symbol - * </pre> - * - * <p>Formatting shortcuts that will be translated into their longer version. - * Be sure that format shortcuts do not refer to themselves: this will cause an infinite loop.</p> - * - * <p>Format codes and format shortcuts can be redefined after the jsDate - * module is imported.</p> - * - * <p>Note that if you redefine the whole hash (object), you must supply a "matcher" - * regex for the parser. The default matcher is:</p> - * - * <code>/()%(#?(%|[a-z]))/i</code> - * - * <p>which corresponds to the Perl syntax used by default.</p> - * - * <p>By customizing the matcher and format codes, nearly any strftime functionality is possible.</p> - */ - - jsDate.formats.perl = { - codes: { - // - // 2-part regex matcher for format codes - // - // first match must be the character before the code (to account for escaping) - // second match must be the format code character(s) - // - matcher: /()%(#?(%|[a-z]))/i, - // year - Y: 'FullYear', - y: 'ShortYear.2', - // month - m: 'MonthNumber.2', - '#m': 'MonthNumber', - B: 'MonthName', - b: 'AbbrMonthName', - // day - d: 'Date.2', - '#d': 'Date', - e: 'Date', - A: 'DayName', - a: 'AbbrDayName', - w: 'Day', - // hours - H: 'Hours.2', - '#H': 'Hours', - I: 'Hours12.2', - '#I': 'Hours12', - p: 'AMPM', - // minutes - M: 'Minutes.2', - '#M': 'Minutes', - // seconds - S: 'Seconds.2', - '#S': 'Seconds', - s: 'Unix', - // milliseconds - N: 'Milliseconds.3', - '#N': 'Milliseconds', - // timezone - O: 'TimezoneOffset', - Z: 'TimezoneName', - G: 'GmtOffset' - }, - - shortcuts: { - // date - F: '%Y-%m-%d', - // time - T: '%H:%M:%S', - X: '%H:%M:%S', - // local format date - x: '%m/%d/%y', - D: '%m/%d/%y', - // local format extended - '#c': '%a %b %e %H:%M:%S %Y', - // local format short - v: '%e-%b-%Y', - R: '%H:%M', - r: '%I:%M:%S %p', - // tab and newline - t: '\t', - n: '\n', - '%': '%' - } - }; - - /** - * PHP format codes and shortcuts for strftime. - * - * A hash (object) of codes where each code must be an array where the first member is - * the name of a Date.prototype or jsDate.prototype function to call - * and optionally a second member indicating the number to pass to addZeros() - * - * <p>The following format codes are defined:</p> - * - * <pre class="code"> - * Code Result Description - * === Days === - * %a Sun through Sat An abbreviated textual representation of the day - * %A Sunday - Saturday A full textual representation of the day - * %d 01 to 31 Two-digit day of the month (with leading zeros) - * %e 1 to 31 Day of the month, with a space preceding single digits. - * %j 001 to 366 Day of the year, 3 digits with leading zeros - * %u 1 - 7 (Mon - Sun) ISO-8601 numeric representation of the day of the week - * %w 0 - 6 (Sun - Sat) Numeric representation of the day of the week - * - * === Week === - * %U 13 Full Week number, starting with the first Sunday as the first week - * %V 01 through 53 ISO-8601:1988 week number, starting with the first week of the year - * with at least 4 weekdays, with Monday being the start of the week - * %W 46 A numeric representation of the week of the year, - * starting with the first Monday as the first week - * === Month === - * %b Jan through Dec Abbreviated month name, based on the locale - * %B January - December Full month name, based on the locale - * %h Jan through Dec Abbreviated month name, based on the locale (an alias of %b) - * %m 01 - 12 (Jan - Dec) Two digit representation of the month - * - * === Year === - * %C 19 Two digit century (year/100, truncated to an integer) - * %y 09 for 2009 Two digit year - * %Y 2038 Four digit year - * - * === Time === - * %H 00 through 23 Two digit representation of the hour in 24-hour format - * %I 01 through 12 Two digit representation of the hour in 12-hour format - * %l 1 through 12 Hour in 12-hour format, with a space preceeding single digits - * %M 00 through 59 Two digit representation of the minute - * %p AM/PM UPPER-CASE 'AM' or 'PM' based on the given time - * %P am/pm lower-case 'am' or 'pm' based on the given time - * %r 09:34:17 PM Same as %I:%M:%S %p - * %R 00:35 Same as %H:%M - * %S 00 through 59 Two digit representation of the second - * %T 21:34:17 Same as %H:%M:%S - * %X 03:59:16 Preferred time representation based on locale, without the date - * %z -0500 or EST Either the time zone offset from UTC or the abbreviation - * %Z -0500 or EST The time zone offset/abbreviation option NOT given by %z - * - * === Time and Date === - * %D 02/05/09 Same as %m/%d/%y - * %F 2009-02-05 Same as %Y-%m-%d (commonly used in database datestamps) - * %s 305815200 Unix Epoch Time timestamp (same as the time() function) - * %x 02/05/09 Preferred date representation, without the time - * - * === Miscellaneous === - * %n --- A newline character (\n) - * %t --- A Tab character (\t) - * %% --- A literal percentage character (%) - * </pre> - */ - - jsDate.formats.php = { - codes: { - // - // 2-part regex matcher for format codes - // - // first match must be the character before the code (to account for escaping) - // second match must be the format code character(s) - // - matcher: /()%((%|[a-z]))/i, - // day - a: 'AbbrDayName', - A: 'DayName', - d: 'Date.2', - e: 'Date', - j: 'DayOfYear.3', - u: 'DayOfWeek', - w: 'Day', - // week - U: 'FullWeekOfYear.2', - V: 'IsoWeek.2', - W: 'WeekOfYear.2', - // month - b: 'AbbrMonthName', - B: 'MonthName', - m: 'MonthNumber.2', - h: 'AbbrMonthName', - // year - C: 'Century.2', - y: 'ShortYear.2', - Y: 'FullYear', - // time - H: 'Hours.2', - I: 'Hours12.2', - l: 'Hours12', - p: 'AMPM', - P: 'AmPm', - M: 'Minutes.2', - S: 'Seconds.2', - s: 'Unix', - O: 'TimezoneOffset', - z: 'GmtOffset', - Z: 'TimezoneAbbr' - }, - - shortcuts: { - D: '%m/%d/%y', - F: '%Y-%m-%d', - T: '%H:%M:%S', - X: '%H:%M:%S', - x: '%m/%d/%y', - R: '%H:%M', - r: '%I:%M:%S %p', - t: '\t', - n: '\n', - '%': '%' - } - }; - // - // Conceptually, the logic implemented here is similar to Ken Snyder's Date Instance Methods. - // I use his idea of a set of parsers which can be regular expressions or functions, - // iterating through those, and then seeing if Date.parse() will create a date. - // The parser expressions and functions are a little different and some bugs have been - // worked out. Also, a lot of "pre-parsing" is done to fix implementation - // variations of Date.parse() between browsers. - // - jsDate.createDate = function(date) { - // if passing in multiple arguments, try Date constructor - if (date == null) { - return new Date(); - } - // If the passed value is already a date object, return it - if (date instanceof Date) { - return date; - } - // if (typeof date == 'number') return new Date(date * 1000); - // If the passed value is an integer, interpret it as a javascript timestamp - if (typeof date == 'number') { - return new Date(date); - } - - // Before passing strings into Date.parse(), have to normalize them for certain conditions. - // If strings are not formatted staccording to the EcmaScript spec, results from Date parse will be implementation dependent. - // - // For example: - // * FF and Opera assume 2 digit dates are pre y2k, Chome assumes <50 is pre y2k, 50+ is 21st century. - // * Chrome will correctly parse '1984-1-25' into localtime, FF and Opera will not parse. - // * Both FF, Chrome and Opera will parse '1984/1/25' into localtime. - - // remove leading and trailing spaces - var parsable = String(date).replace(/^\s*(.+)\s*$/g, '$1'); - - // replace dahses (-) with slashes (/) in dates like n[nnn]/n[n]/n[nnn] - parsable = parsable.replace(/^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,4})/, "$1/$2/$3"); - - ///////// - // Need to check for '15-Dec-09' also. - // FF will not parse, but Chrome will. - // Chrome will set date to 2009 as well. - ///////// - - // first check for 'dd-mmm-yyyy' or 'dd/mmm/yyyy' like '15-Dec-2010' - parsable = parsable.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{4})/i, "$1 $2 $3"); - - // Now check for 'dd-mmm-yy' or 'dd/mmm/yy' and normalize years to default century. - var match = parsable.match(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i); - if (match && match.length > 3) { - var m3 = parseFloat(match[3]); - var ny = jsDate.config.defaultCentury + m3; - ny = String(ny); - - // now replace 2 digit year with 4 digit year - parsable = parsable.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i, match[1] +' '+ match[2] +' '+ ny); - - } - - // Check for '1/19/70 8:14PM' - // where starts with mm/dd/yy or yy/mm/dd and have something after - // Check if 1st postiion is greater than 31, assume it is year. - // Assme all 2 digit years are 1900's. - // Finally, change them into US style mm/dd/yyyy representations. - match = parsable.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})[^0-9]/); - - function h1(parsable, match) { - var m1 = parseFloat(match[1]); - var m2 = parseFloat(match[2]); - var m3 = parseFloat(match[3]); - var cent = jsDate.config.defaultCentury; - var ny, nd, nm, str; - - if (m1 > 31) { // first number is a year - nd = m3; - nm = m2; - ny = cent + m1; - } - - else { // last number is the year - nd = m2; - nm = m1; - ny = cent + m3; - } - - str = nm+'/'+nd+'/'+ny; - - // now replace 2 digit year with 4 digit year - return parsable.replace(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})/, str); - - } - - if (match && match.length > 3) { - parsable = h1(parsable, match); - } - - // Now check for '1/19/70' with nothing after and do as above - var match = parsable.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})$/); - - if (match && match.length > 3) { - parsable = h1(parsable, match); - } - - - var i = 0; - var length = jsDate.matchers.length; - var pattern, - ms, - current = parsable; - while (i < length) { - ms = Date.parse(current); - if (!isNaN(ms)) { - return new Date(ms); - } - pattern = jsDate.matchers[i]; - if (typeof pattern == 'function') { - var obj = pattern.call(jsDate, current); - if (obj instanceof Date) { - return obj; - } - } else { - current = parsable.replace(pattern[0], pattern[1]); - } - i++; - } - return NaN; - }; - - - /** - * @static - * Handy static utility function to return the number of days in a given month. - * @param {Integer} year Year - * @param {Integer} month Month (1-12) - * @returns {Integer} Number of days in the month. - */ - // - // handy utility method Borrowed right from Ken Snyder's Date Instance Mehtods. - // - jsDate.daysInMonth = function(year, month) { - if (month == 2) { - return new Date(year, 1, 29).getDate() == 29 ? 29 : 28; - } - return [undefined,31,undefined,31,30,31,30,31,31,30,31,30,31][month]; - }; - - - // - // An Array of regular expressions or functions that will attempt to match the date string. - // Functions are called with scope of a jsDate instance. - // - jsDate.matchers = [ - // convert dd.mmm.yyyy to mm/dd/yyyy (world date to US date). - [/(3[01]|[0-2]\d)\s*\.\s*(1[0-2]|0\d)\s*\.\s*([1-9]\d{3})/, '$2/$1/$3'], - // convert yyyy-mm-dd to mm/dd/yyyy (ISO date to US date). - [/([1-9]\d{3})\s*-\s*(1[0-2]|0\d)\s*-\s*(3[01]|[0-2]\d)/, '$2/$3/$1'], - // Handle 12 hour or 24 hour time with milliseconds am/pm and optional date part. - function(str) { - var match = str.match(/^(?:(.+)\s+)?([012]?\d)(?:\s*\:\s*(\d\d))?(?:\s*\:\s*(\d\d(\.\d*)?))?\s*(am|pm)?\s*$/i); - // opt. date hour opt. minute opt. second opt. msec opt. am or pm - if (match) { - if (match[1]) { - var d = this.createDate(match[1]); - if (isNaN(d)) { - return; - } - } else { - var d = new Date(); - d.setMilliseconds(0); - } - var hour = parseFloat(match[2]); - if (match[6]) { - hour = match[6].toLowerCase() == 'am' ? (hour == 12 ? 0 : hour) : (hour == 12 ? 12 : hour + 12); - } - d.setHours(hour, parseInt(match[3] || 0, 10), parseInt(match[4] || 0, 10), ((parseFloat(match[5] || 0)) || 0)*1000); - return d; - } - else { - return str; - } - }, - // Handle ISO timestamp with time zone. - function(str) { - var match = str.match(/^(?:(.+))[T|\s+]([012]\d)(?:\:(\d\d))(?:\:(\d\d))(?:\.\d+)([\+\-]\d\d\:\d\d)$/i); - if (match) { - if (match[1]) { - var d = this.createDate(match[1]); - if (isNaN(d)) { - return; - } - } else { - var d = new Date(); - d.setMilliseconds(0); - } - var hour = parseFloat(match[2]); - d.setHours(hour, parseInt(match[3], 10), parseInt(match[4], 10), parseFloat(match[5])*1000); - return d; - } - else { - return str; - } - }, - // Try to match ambiguous strings like 12/8/22. - // Use FF date assumption that 2 digit years are 20th century (i.e. 1900's). - // This may be redundant with pre processing of date already performed. - function(str) { - var match = str.match(/^([0-3]?\d)\s*[-\/.\s]{1}\s*([a-zA-Z]{3,9})\s*[-\/.\s]{1}\s*([0-3]?\d)$/); - if (match) { - var d = new Date(); - var cent = jsDate.config.defaultCentury; - var m1 = parseFloat(match[1]); - var m3 = parseFloat(match[3]); - var ny, nd, nm; - if (m1 > 31) { // first number is a year - nd = m3; - ny = cent + m1; - } - - else { // last number is the year - nd = m1; - ny = cent + m3; - } - - var nm = inArray(match[2], jsDate.regional[this.locale]["monthNamesShort"]); - - if (nm == -1) { - nm = inArray(match[2], jsDate.regional[this.locale]["monthNames"]); - } - - d.setFullYear(ny, nm, nd); - d.setHours(0,0,0,0); - return d; - } - - else { - return str; - } - } - ]; - - // - // I think John Reisig published this method on his blog, ejohn. - // - function inArray( elem, array ) { - if ( array.indexOf ) { - return array.indexOf( elem ); - } - - for ( var i = 0, length = array.length; i < length; i++ ) { - if ( array[ i ] === elem ) { - return i; - } - } - - return -1; - } - - // - // Thanks to Kangax, Christian Sciberras and Stack Overflow for this method. - // - function get_type(thing){ - if(thing===null) return "[object Null]"; // special case - return Object.prototype.toString.call(thing); - } - - $.jsDate = jsDate; - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/jsl.conf b/libs/jqplot/jsl.conf deleted file mode 100644 index ce1f7f461a..0000000000 --- a/libs/jqplot/jsl.conf +++ /dev/null @@ -1,143 +0,0 @@ -# -# Configuration File for JavaScript Lint 0.3.0 -# Developed by Matthias Miller (http://www.JavaScriptLint.com) -# -# This configuration file can be used to lint a collection of scripts, or to enable -# or disable warnings for scripts that are linted via the command line. -# - -### Warnings -# Enable or disable warnings based on requirements. -# Use "+WarningName" to display or "-WarningName" to suppress. -# -+no_return_value # function {0} does not always return a value -+duplicate_formal # duplicate formal argument {0} -+equal_as_assign # test for equality (==) mistyped as assignment (=)?{0} -+var_hides_arg # variable {0} hides argument --redeclared_var # redeclaration of {0} {1} --anon_no_return_value # anonymous function does not always return a value -+missing_semicolon # missing semicolon -+meaningless_block # meaningless block; curly braces have no impact -+comma_separated_stmts # multiple statements separated by commas (use semicolons?) -+unreachable_code # unreachable code -+missing_break # missing break statement -+missing_break_for_last_case # missing break statement for last case in switch --comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==) --inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement -+useless_void # use of the void type may be unnecessary (void is always undefined) -+multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs -+use_of_label # use of label -+block_without_braces # block statement without curly braces -+leading_decimal_point # leading decimal point may indicate a number or an object member -+trailing_decimal_point # trailing decimal point may indicate a number or an object member -+octal_number # leading zeros make an octal number -+nested_comment # nested comment -+misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma -+ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement -+empty_statement # empty statement or extra semicolon --missing_option_explicit # the "option explicit" control comment is missing -+partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag -+dup_option_explicit # duplicate "option explicit" control comment -+useless_assign # useless assignment -+ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity -+ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent) --missing_default_case # missing default case in switch statement -+duplicate_case_in_switch # duplicate case in switch statements -+default_not_at_end # the default case is not at the end of the switch statement -+legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax -+jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax -+useless_comparison # useless comparison; comparing identical expressions -+with_statement # with statement hides undeclared variables; use temporary variable instead -+trailing_comma_in_array # extra comma is not recommended in array initializers -+assign_to_function_call # assignment to a function call --parseint_missing_radix # parseInt missing radix parameter - - -### Output format -# Customize the format of the error message. -# __FILE__ indicates current file path -# __FILENAME__ indicates current file name -# __LINE__ indicates current line -# __ERROR__ indicates error message -# -# Visual Studio syntax (default): -+output-format __FILE__(__LINE__): __ERROR__ -# Alternative syntax: -#+output-format __FILE__:__LINE__: __ERROR__ - - -### Context -# Show the in-line position of the error. -# Use "+context" to display or "-context" to suppress. -# -+context - - -### Semicolons -# By default, assignments of an anonymous function to a variable or -# property (such as a function prototype) must be followed by a semicolon. -# -+lambda_assign_requires_semicolon - - -### Control Comments -# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for -# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is -# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason, -# although legacy control comments are enabled by default for backward compatibility. -# -+legacy_control_comments - - -### JScript Function Extensions -# JScript allows member functions to be defined like this: -# function MyObj() { /*constructor*/ } -# function MyObj.prototype.go() { /*member function*/ } -# -# It also allows events to be attached like this: -# function window::onload() { /*init page*/ } -# -# This is a Microsoft-only JavaScript extension. Enable this setting to allow them. -# --jscript_function_extensions - - -### Defining identifiers -# By default, "option explicit" is enabled on a per-file basis. -# To enable this for all files, use "+always_use_option_explicit" -+always_use_option_explicit - -# Define certain identifiers of which the lint is not aware. -# (Use this in conjunction with the "undeclared identifier" warning.) -# -# Common uses for webpages might be: -+define window -+define document -+define jQuery -+define console - - -### Files -# Specify which files to lint -# Use "+recurse" to enable recursion (disabled by default). -# To add a set of files, use "+process FileName", "+process Folder\Path\*.js", -# or "+process Folder\Path\*.htm". -# -#+process jsl-test.js -+process jqplot.axisLabelRenderer.js -+process jqplot.axisTickRenderer.js -+process jqplot.canvasGridRenderer.js -+process jqplot.core.js -+process jqplot.divTitleRenderer.js -+process jqplot.linearAxisRenderer.js -+process jqplot.linearTickGenerator.js -+process jqplot.lineRenderer.js -+process jqplot.markerRenderer.js -+process jqplot.shadowRenderer.js -+process jqplot.shapeRenderer.js -+process jqplot.sprintf.js -+process jqplot.tableLegendRenderer.js -+process jqplot.themeEngine.js -+process jquery.jqplot.js -+process jsdate.js -+process plugins/*.js
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.BezierCurveRenderer.js b/libs/jqplot/plugins/jqplot.BezierCurveRenderer.js deleted file mode 100644 index 96e91e88ef..0000000000 --- a/libs/jqplot/plugins/jqplot.BezierCurveRenderer.js +++ /dev/null @@ -1,312 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - // Class: $.jqplot.BezierCurveRenderer.js - // Renderer which draws lines as stacked bezier curves. - // Data for the line will not be specified as an array of - // [x, y] data point values, but as a an array of [start piont, bezier curve] - // So, the line is specified as: [[xstart, ystart], [cp1x, cp1y, cp2x, cp2y, xend, yend]]. - $.jqplot.BezierCurveRenderer = function(){ - $.jqplot.LineRenderer.call(this); - }; - - $.jqplot.BezierCurveRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.BezierCurveRenderer.prototype.constructor = $.jqplot.BezierCurveRenderer; - - - // Method: setGridData - // converts the user data values to grid coordinates and stores them - // in the gridData array. - // Called with scope of a series. - $.jqplot.BezierCurveRenderer.prototype.setGridData = function(plot) { - // recalculate the grid data - var xp = this._xaxis.series_u2p; - var yp = this._yaxis.series_u2p; - // this._plotData should be same as this.data - var data = this.data; - this.gridData = []; - this._prevGridData = []; - // if seriesIndex = 0, fill to x axis. - // if seriesIndex > 0, fill to previous series data. - var idx = this.index; - if (data.length == 2) { - if (idx == 0) { - this.gridData = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]), - xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])], - [xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, this._yaxis.min)], - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)] - ]; - } - else { - var psd = plot.series[idx-1].data; - this.gridData = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]), - xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])], - [xp.call(this._xaxis, psd[1][4]), yp.call(this._yaxis, psd[1][5])], - [xp.call(this._xaxis, psd[1][2]), yp.call(this._yaxis, psd[1][3]), - xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]), - xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])] - ]; - } - } - else { - if (idx == 0) { - this.gridData = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]), - xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])], - [xp.call(this._xaxis, data[3][1]), yp.call(this._yaxis, this._yaxis.min)], - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)] - ]; - } - else { - var psd = plot.series[idx-1].data; - this.gridData = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]), - xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])], - [xp.call(this._xaxis, psd[3][0]), yp.call(this._yaxis, psd[3][1])], - [xp.call(this._xaxis, psd[2][0]), yp.call(this._yaxis, psd[2][1]), - xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]), - xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])] - ]; - } - } - }; - - // Method: makeGridData - // converts any arbitrary data values to grid coordinates and - // returns them. This method exists so that plugins can use a series' - // linerenderer to generate grid data points without overwriting the - // grid data associated with that series. - // Called with scope of a series. - $.jqplot.BezierCurveRenderer.prototype.makeGridData = function(data, plot) { - // recalculate the grid data - var xp = this._xaxis.series_u2p; - var yp = this._yaxis.series_u2p; - var gd = []; - var pgd = []; - // if seriesIndex = 0, fill to x axis. - // if seriesIndex > 0, fill to previous series data. - var idx = this.index; - if (data.length == 2) { - if (idx == 0) { - gd = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]), - xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])], - [xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, this._yaxis.min)], - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)] - ]; - } - else { - var psd = plot.series[idx-1].data; - gd = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]), - xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])], - [xp.call(this._xaxis, psd[1][4]), yp.call(this._yaxis, psd[1][5])], - [xp.call(this._xaxis, psd[1][2]), yp.call(this._yaxis, psd[1][3]), - xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]), - xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])] - ]; - } - } - else { - if (idx == 0) { - gd = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]), - xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])], - [xp.call(this._xaxis, data[3][1]), yp.call(this._yaxis, this._yaxis.min)], - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)] - ]; - } - else { - var psd = plot.series[idx-1].data; - gd = [ - [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], - [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), - xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]), - xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])], - [xp.call(this._xaxis, psd[3][0]), yp.call(this._yaxis, psd[3][1])], - [xp.call(this._xaxis, psd[2][0]), yp.call(this._yaxis, psd[2][1]), - xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]), - xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])] - ]; - } - } - return gd; - }; - - - // called within scope of series. - $.jqplot.BezierCurveRenderer.prototype.draw = function(ctx, gd, options) { - var i; - ctx.save(); - if (gd.length) { - if (this.showLine) { - ctx.save(); - var opts = (options != null) ? options : {}; - ctx.fillStyle = opts.fillStyle || this.color; - ctx.beginPath(); - ctx.moveTo(gd[0][0], gd[0][1]); - ctx.bezierCurveTo(gd[1][0], gd[1][1], gd[1][2], gd[1][3], gd[1][4], gd[1][5]); - ctx.lineTo(gd[2][0], gd[2][1]); - if (gd[3].length == 2) { - ctx.lineTo(gd[3][0], gd[3][1]); - } - else { - ctx.bezierCurveTo(gd[3][0], gd[3][1], gd[3][2], gd[3][3], gd[3][4], gd[3][5]); - } - ctx.closePath(); - ctx.fill(); - ctx.restore(); - } - } - - ctx.restore(); - }; - - $.jqplot.BezierCurveRenderer.prototype.drawShadow = function(ctx, gd, options) { - // This is a no-op, shadows drawn with lines. - }; - - $.jqplot.BezierAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - }; - - $.jqplot.BezierAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.BezierAxisRenderer.prototype.constructor = $.jqplot.BezierAxisRenderer; - - - // Axes on a plot with Bezier Curves - $.jqplot.BezierAxisRenderer.prototype.init = function(options){ - $.extend(true, this, options); - var db = this._dataBounds; - // Go through all the series attached to this axis and find - // the min/max bounds for this axis. - for (var i=0; i<this._series.length; i++) { - var s = this._series[i]; - var d = s.data; - if (d.length == 4) { - for (var j=0; j<d.length; j++) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - if (d[j][0] < db.min || db.min == null) { - db.min = d[j][0]; - } - if (d[j][0] > db.max || db.max == null) { - db.max = d[j][0]; - } - } - else { - if (d[j][1] < db.min || db.min == null) { - db.min = d[j][1]; - } - if (d[j][1] > db.max || db.max == null) { - db.max = d[j][1]; - } - } - } - } - else { - if (this.name == 'xaxis' || this.name == 'x2axis') { - if (d[0][0] < db.min || db.min == null) { - db.min = d[0][0]; - } - if (d[0][0] > db.max || db.max == null) { - db.max = d[0][0]; - } - for (var j=0; j<5; j+=2) { - if (d[1][j] < db.min || db.min == null) { - db.min = d[1][j]; - } - if (d[1][j] > db.max || db.max == null) { - db.max = d[1][j]; - } - } - } - else { - if (d[0][1] < db.min || db.min == null) { - db.min = d[0][1]; - } - if (d[0][1] > db.max || db.max == null) { - db.max = d[0][1]; - } - for (var j=1; j<6; j+=2) { - if (d[1][j] < db.min || db.min == null) { - db.min = d[1][j]; - } - if (d[1][j] > db.max || db.max == null) { - db.max = d[1][j]; - } - } - } - } - } - }; - - // setup default renderers for axes and legend so user doesn't have to - // called with scope of plot - function preInit(target, data, options) { - options = options || {}; - options.axesDefaults = $.extend(true, {pad:0}, options.axesDefaults); - options.legend = $.extend(true, {placement:'outside'}, options.legend); - // only set these if there is a pie series - var setopts = false; - if (options.seriesDefaults.renderer == $.jqplot.BezierCurveRenderer) { - setopts = true; - } - else if (options.series) { - for (var i=0; i < options.series.length; i++) { - if (options.series[i].renderer == $.jqplot.BezierCurveRenderer) { - setopts = true; - } - } - } - - if (setopts) { - options.axesDefaults.renderer = $.jqplot.BezierAxisRenderer; - } - } - - $.jqplot.preInitHooks.push(preInit); - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.blockRenderer.js b/libs/jqplot/plugins/jqplot.blockRenderer.js deleted file mode 100644 index d113c3ea5b..0000000000 --- a/libs/jqplot/plugins/jqplot.blockRenderer.js +++ /dev/null @@ -1,234 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.BlockRenderer - * Plugin renderer to draw a x-y block chart. A Block chart has data points displayed as - * colored squares with a text label inside. Data must be supplied in the form: - * - * > [[x1, y1, "label 1", {css}], [x2, y2, "label 2", {css}], ...] - * - * The label and css object are optional. If the label is ommitted, the - * box will collapse unless a css height and/or width is specified. - * - * The css object is an object specifying css properties - * such as: - * - * > {background:'#4f98a5', border:'3px solid gray', padding:'1px'} - * - * Note that css properties specified with the data point override defaults - * specified with the series. - * - */ - $.jqplot.BlockRenderer = function(){ - $.jqplot.LineRenderer.call(this); - }; - - $.jqplot.BlockRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.BlockRenderer.prototype.constructor = $.jqplot.BlockRenderer; - - // called with scope of a series - $.jqplot.BlockRenderer.prototype.init = function(options) { - // Group: Properties - // - // prop: css - // default css styles that will be applied to all data blocks. - // these values will be overridden by css styles supplied with the - // individulal data points. - this.css = {padding:'2px', border:'1px solid #999', textAlign:'center'}; - // prop: escapeHtml - // true to escape html in the box label. - this.escapeHtml = false; - // prop: insertBreaks - // true to turn spaces in data block label into html breaks <br />. - this.insertBreaks = true; - // prop: varyBlockColors - // true to vary the color of each block in this series according to - // the seriesColors array. False to set each block to the color - // specified on this series. This has no effect if a css background color - // option is specified in the renderer css options. - 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'; - - // group: Methods - // - // Method: moveBlock - // Moves an individual block. More efficient than redrawing - // the whole series by calling plot.drawSeries(). - // Properties: - // idx - the 0 based index of the block or point in this series. - // x - the x coordinate in data units (value on x axis) to move the block to. - // y - the y coordinate in data units (value on the y axis) to move the block to. - // duration - optional parameter to create an animated movement. Can be a - // number (higher is slower animation) or 'fast', 'normal' or 'slow'. If not - // provided, the element is moved without any animation. - this.moveBlock = function (idx, x, y, duration) { - // update plotData, stackData, data and gridData - // x and y are in data coordinates. - 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; - }; - }; - - // called with scope of series - $.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); - // create a div - el = $('<div style="position:absolute;margin-left:auto;margin-right:auto;"></div>'); - this.canvas._elem.append(el); - // set text - this.escapeHtml ? el.text(t) : el.html(t); - // style it - // remove styles we don't want overridden. - 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 canvas already has a dom element, don't make a new one. - if (this._elem) { - elem = this._elem.get(0); - } - else { - elem = document.createElement('div'); - } - // if new plotDimensions supplied, use them. - 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); - -
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.bubbleRenderer.js b/libs/jqplot/plugins/jqplot.bubbleRenderer.js deleted file mode 100755 index ffcc1e037e..0000000000 --- a/libs/jqplot/plugins/jqplot.bubbleRenderer.js +++ /dev/null @@ -1,754 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - var arrayMax = function( array ){ - return Math.max.apply( Math, array ); - }; - var arrayMin = function( array ){ - return Math.min.apply( Math, array ); - }; - - /** - * Class: $.jqplot.BubbleRenderer - * Plugin renderer to draw a bubble chart. A Bubble chart has data points displayed as - * colored circles with an optional text label inside. To use - * the bubble renderer, you must include the bubble renderer like: - * - * > <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.bubbleRenderer.js"></script> - * - * Data must be supplied in - * the form: - * - * > [[x1, y1, r1, <label or {label:'text', color:color}>], ...] - * - * where the label or options - * object is optional. - * - * Note that all bubble colors will be the same - * unless the "varyBubbleColors" option is set to true. Colors can be specified in the data array - * or in the seriesColors array option on the series. If no colors are defined, the default jqPlot - * series of 16 colors are used. Colors are automatically cycled around again if there are more - * bubbles than colors. - * - * Bubbles are autoscaled by default to fit within the chart area while maintaining - * relative sizes. If the "autoscaleBubbles" option is set to false, the r(adius) values - * in the data array a treated as literal pixel values for the radii of the bubbles. - * - * Properties are passed into the bubble renderer in the rendererOptions object of - * the series options like: - * - * > seriesDefaults: { - * > renderer: $.jqplot.BubbleRenderer, - * > rendererOptions: { - * > bubbleAlpha: 0.7, - * > varyBubbleColors: false - * > } - * > } - * - */ - $.jqplot.BubbleRenderer = function(){ - $.jqplot.LineRenderer.call(this); - }; - - $.jqplot.BubbleRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.BubbleRenderer.prototype.constructor = $.jqplot.BubbleRenderer; - - // called with scope of a series - $.jqplot.BubbleRenderer.prototype.init = function(options, plot) { - // Group: Properties - // - // prop: varyBubbleColors - // True to vary the color of each bubble in this series according to - // the seriesColors array. False to set each bubble to the color - // specified on this series. This has no effect if a css background color - // option is specified in the renderer css options. - this.varyBubbleColors = true; - // prop: autoscaleBubbles - // True to scale the bubble radius based on plot size. - // False will use the radius value as provided as a raw pixel value for - // bubble radius. - this.autoscaleBubbles = true; - // prop: autoscaleMultiplier - // Multiplier the bubble size if autoscaleBubbles is true. - this.autoscaleMultiplier = 1.0; - // prop: autoscalePointsFactor - // Factor which decreases bubble size based on how many bubbles on on the chart. - // 0 means no adjustment for number of bubbles. Negative values will decrease - // size of bubbles as more bubbles are added. Values between 0 and -0.2 - // should work well. - this.autoscalePointsFactor = -0.07; - // prop: escapeHtml - // True to escape html in bubble label text. - this.escapeHtml = true; - // prop: highlightMouseOver - // True to highlight bubbles when moused over. - // This must be false to enable highlightMouseDown to highlight when clicking on a slice. - this.highlightMouseOver = true; - // prop: highlightMouseDown - // True to highlight when a mouse button is pressed over a bubble. - // This will be disabled if highlightMouseOver is true. - this.highlightMouseDown = false; - // prop: highlightColors - // An array of colors to use when highlighting a slice. Calculated automatically - // if not supplied. - this.highlightColors = []; - // prop: bubbleAlpha - // Alpha transparency to apply to all bubbles in this series. - this.bubbleAlpha = 1.0; - // prop: highlightAlpha - // Alpha transparency to apply when highlighting bubble. - // Set to value of bubbleAlpha by default. - this.highlightAlpha = null; - // prop: bubbleGradients - // True to color the bubbles with gradient fills instead of flat colors. - // NOT AVAILABLE IN IE due to lack of excanvas support for radial gradient fills. - // will be ignored in IE. - this.bubbleGradients = false; - // prop: showLabels - // True to show labels on bubbles (if any), false to not show. - this.showLabels = true; - // array of [point index, radius] which will be sorted in descending order to plot - // largest points below smaller points. - this.radii = []; - this.maxRadius = 0; - // index of the currenty highlighted point, if any - this._highlightedPoint = null; - // array of jQuery labels. - this.labels = []; - this.bubbleCanvases = []; - this._type = 'bubble'; - - // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver - if (options.highlightMouseDown && options.highlightMouseOver == null) { - options.highlightMouseOver = false; - } - - $.extend(true, this, options); - - if (this.highlightAlpha == null) { - this.highlightAlpha = this.bubbleAlpha; - if (this.bubbleGradients) { - this.highlightAlpha = 0.35; - } - } - - this.autoscaleMultiplier = this.autoscaleMultiplier * Math.pow(this.data.length, this.autoscalePointsFactor); - - // index of the currenty highlighted point, if any - this._highlightedPoint = null; - - // adjust the series colors for options colors passed in with data or for alpha. - // note, this can leave undefined holes in the seriesColors array. - var comps; - for (var i=0; i<this.data.length; i++) { - var color = null; - var d = this.data[i]; - this.maxRadius = Math.max(this.maxRadius, d[2]); - if (d[3]) { - if (typeof(d[3]) == 'object') { - color = d[3]['color']; - } - } - - if (color == null) { - if (this.seriesColors[i] != null) { - color = this.seriesColors[i]; - } - } - - if (color && this.bubbleAlpha < 1.0) { - comps = $.jqplot.getColorComponents(color); - color = 'rgba('+comps[0]+', '+comps[1]+', '+comps[2]+', '+this.bubbleAlpha+')'; - } - - if (color) { - this.seriesColors[i] = color; - } - } - - if (!this.varyBubbleColors) { - this.seriesColors = [this.color]; - } - - this.colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors); - - // set highlight colors if none provided - if (this.highlightColors.length == 0) { - for (var i=0; i<this.seriesColors.length; i++){ - var rgba = $.jqplot.getColorComponents(this.seriesColors[i]); - var newrgb = [rgba[0], rgba[1], rgba[2]]; - var sum = newrgb[0] + newrgb[1] + newrgb[2]; - for (var j=0; j<3; j++) { - // when darkening, lowest color component can be is 60. - newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); - newrgb[j] = parseInt(newrgb[j], 10); - } - this.highlightColors.push('rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+', '+this.highlightAlpha+')'); - } - } - - this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors); - - var sopts = {fill:true, isarc:true, angle:this.shadowAngle, alpha:this.shadowAlpha, closePath:true}; - - this.renderer.shadowRenderer.init(sopts); - - this.canvas = new $.jqplot.DivCanvas(); - this.canvas._plotDimensions = this._plotDimensions; - - plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove); - plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown); - plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp); - plot.eventListenerHooks.addOnce('jqplotClick', handleClick); - plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); - plot.postDrawHooks.addOnce(postPlotDraw); - - }; - - - // converts the user data values to grid coordinates and stores them - // in the gridData array. - // Called with scope of a series. - $.jqplot.BubbleRenderer.prototype.setGridData = function(plot) { - // recalculate the grid data - var xp = this._xaxis.series_u2p; - var yp = this._yaxis.series_u2p; - var data = this._plotData; - this.gridData = []; - var radii = []; - this.radii = []; - var dim = Math.min(plot._height, plot._width); - for (var i=0; i<this.data.length; i++) { - if (data[i] != null) { - this.gridData.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1]), data[i][2]]); - this.radii.push([i, data[i][2]]); - radii.push(data[i][2]); - } - } - var r, val, maxr = this.maxRadius = arrayMax(radii); - var l = this.gridData.length; - if (this.autoscaleBubbles) { - for (var i=0; i<l; i++) { - val = radii[i]/maxr; - r = this.autoscaleMultiplier * dim / 6; - this.gridData[i][2] = r * val; - } - } - - this.radii.sort(function(a, b) { return b[1] - a[1]; }); - }; - - // converts any arbitrary data values to grid coordinates and - // returns them. This method exists so that plugins can use a series' - // linerenderer to generate grid data points without overwriting the - // grid data associated with that series. - // Called with scope of a series. - $.jqplot.BubbleRenderer.prototype.makeGridData = function(data, plot) { - // recalculate the grid data - var xp = this._xaxis.series_u2p; - var yp = this._yaxis.series_u2p; - var gd = []; - var radii = []; - this.radii = []; - var dim = Math.min(plot._height, plot._width); - for (var i=0; i<data.length; i++) { - if (data[i] != null) { - gd.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1]), data[i][2]]); - radii.push(data[i][2]); - this.radii.push([i, data[i][2]]); - } - } - var r, val, maxr = this.maxRadius = arrayMax(radii); - var l = this.gridData.length; - if (this.autoscaleBubbles) { - for (var i=0; i<l; i++) { - val = radii[i]/maxr; - r = this.autoscaleMultiplier * dim / 6; - gd[i][2] = r * val; - } - } - this.radii.sort(function(a, b) { return b[1] - a[1]; }); - return gd; - }; - - // called with scope of series - $.jqplot.BubbleRenderer.prototype.draw = function (ctx, gd, options) { - if (this.plugins.pointLabels) { - this.plugins.pointLabels.show = false; - } - var opts = (options != undefined) ? options : {}; - var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; - this.canvas._elem.empty(); - for (var i=0; i<this.radii.length; i++) { - var idx = this.radii[i][0]; - var t=null; - var color = null; - var el = null; - var tel = null; - var d = this.data[idx]; - var gd = this.gridData[idx]; - if (d[3]) { - if (typeof(d[3]) == 'object') { - t = d[3]['label']; - } - else if (typeof(d[3]) == 'string') { - t = d[3]; - } - } - - // color = (this.varyBubbleColors) ? this.colorGenerator.get(idx) : this.color; - color = this.colorGenerator.get(idx); - - // If we're drawing a shadow, expand the canvas dimensions to accomodate. - var canvasRadius = gd[2]; - var offset, depth; - if (this.shadow) { - offset = (0.7 + gd[2]/40).toFixed(1); - depth = 1 + Math.ceil(gd[2]/15); - canvasRadius += offset*depth; - } - this.bubbleCanvases[idx] = new $.jqplot.BubbleCanvas(); - this.canvas._elem.append(this.bubbleCanvases[idx].createElement(gd[0], gd[1], canvasRadius)); - this.bubbleCanvases[idx].setContext(); - var ctx = this.bubbleCanvases[idx]._ctx; - var x = ctx.canvas.width/2; - var y = ctx.canvas.height/2; - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, [x, y, gd[2], 0, 2*Math.PI], {offset: offset, depth: depth}); - } - this.bubbleCanvases[idx].draw(gd[2], color, this.bubbleGradients, this.shadowAngle/180*Math.PI); - - // now draw label. - if (t && this.showLabels) { - tel = $('<div style="position:absolute;" class="jqplot-bubble-label"></div>'); - if (this.escapeHtml) { - tel.text(t); - } - else { - tel.html(t); - } - this.canvas._elem.append(tel); - var h = $(tel).outerHeight(); - var w = $(tel).outerWidth(); - var top = gd[1] - 0.5*h; - var left = gd[0] - 0.5*w; - tel.css({top: top, left: left}); - this.labels[idx] = $(tel); - } - } - }; - - - $.jqplot.DivCanvas = function() { - $.jqplot.ElemContainer.call(this); - this._ctx; - }; - - $.jqplot.DivCanvas.prototype = new $.jqplot.ElemContainer(); - $.jqplot.DivCanvas.prototype.constructor = $.jqplot.DivCanvas; - - $.jqplot.DivCanvas.prototype.createElement = function(offsets, clss, plotDimensions) { - this._offsets = offsets; - var klass = 'jqplot-DivCanvas'; - if (clss != undefined) { - klass = clss; - } - var elem; - // if this canvas already has a dom element, don't make a new one. - if (this._elem) { - elem = this._elem.get(0); - } - else { - elem = document.createElement('div'); - } - // if new plotDimensions supplied, use them. - 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.DivCanvas.prototype.setContext = function() { - this._ctx = { - canvas:{ - width:0, - height:0 - }, - clearRect:function(){return null;} - }; - return this._ctx; - }; - - $.jqplot.BubbleCanvas = function() { - $.jqplot.ElemContainer.call(this); - this._ctx; - }; - - $.jqplot.BubbleCanvas.prototype = new $.jqplot.ElemContainer(); - $.jqplot.BubbleCanvas.prototype.constructor = $.jqplot.BubbleCanvas; - - // initialize with the x,y pont of bubble center and the bubble radius. - $.jqplot.BubbleCanvas.prototype.createElement = function(x, y, r) { - var klass = 'jqplot-bubble-point'; - - var elem; - // if this canvas already has a dom element, don't make a new one. - if (this._elem) { - elem = this._elem.get(0); - } - else { - elem = document.createElement('canvas'); - } - - elem.width = (r != null) ? 2*r : elem.width; - elem.height = (r != null) ? 2*r : elem.height; - this._elem = $(elem); - var l = (x != null && r != null) ? x - r : this._elem.css('left'); - var t = (y != null && r != null) ? y - r : this._elem.css('top'); - this._elem.css({ position: 'absolute', left: l, top: t }); - - this._elem.addClass(klass); - if ($.jqplot.use_excanvas) { - window.G_vmlCanvasManager.init_(document); - elem = window.G_vmlCanvasManager.initElement(elem); - } - - return this._elem; - }; - - $.jqplot.BubbleCanvas.prototype.draw = function(r, color, gradients, angle) { - var ctx = this._ctx; - // r = Math.floor(r*1.04); - // var x = Math.round(ctx.canvas.width/2); - // var y = Math.round(ctx.canvas.height/2); - var x = ctx.canvas.width/2; - var y = ctx.canvas.height/2; - ctx.save(); - if (gradients && !$.jqplot.use_excanvas) { - r = r*1.04; - var comps = $.jqplot.getColorComponents(color); - var colorinner = 'rgba('+Math.round(comps[0]+0.8*(255-comps[0]))+', '+Math.round(comps[1]+0.8*(255-comps[1]))+', '+Math.round(comps[2]+0.8*(255-comps[2]))+', '+comps[3]+')'; - var colorend = 'rgba('+comps[0]+', '+comps[1]+', '+comps[2]+', 0)'; - // var rinner = Math.round(0.35 * r); - // var xinner = Math.round(x - Math.cos(angle) * 0.33 * r); - // var yinner = Math.round(y - Math.sin(angle) * 0.33 * r); - var rinner = 0.35 * r; - var xinner = x - Math.cos(angle) * 0.33 * r; - var yinner = y - Math.sin(angle) * 0.33 * r; - var radgrad = ctx.createRadialGradient(xinner, yinner, rinner, x, y, r); - radgrad.addColorStop(0, colorinner); - radgrad.addColorStop(0.93, color); - radgrad.addColorStop(0.96, colorend); - radgrad.addColorStop(1, colorend); - // radgrad.addColorStop(.98, colorend); - ctx.fillStyle = radgrad; - ctx.fillRect(0,0, ctx.canvas.width, ctx.canvas.height); - } - else { - ctx.fillStyle = color; - ctx.strokeStyle = color; - ctx.lineWidth = 1; - ctx.beginPath(); - var ang = 2*Math.PI; - ctx.arc(x, y, r, 0, ang, 0); - ctx.closePath(); - ctx.fill(); - } - ctx.restore(); - }; - - $.jqplot.BubbleCanvas.prototype.setContext = function() { - this._ctx = this._elem.get(0).getContext("2d"); - return this._ctx; - }; - - $.jqplot.BubbleAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - }; - - $.jqplot.BubbleAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.BubbleAxisRenderer.prototype.constructor = $.jqplot.BubbleAxisRenderer; - - // called with scope of axis object. - $.jqplot.BubbleAxisRenderer.prototype.init = function(options){ - $.extend(true, this, options); - var db = this._dataBounds; - var minsidx = 0, - minpidx = 0, - maxsidx = 0, - maxpidx = 0, - maxr = 0, - minr = 0, - minMaxRadius = 0, - maxMaxRadius = 0, - maxMult = 0, - minMult = 0; - // Go through all the series attached to this axis and find - // the min/max bounds for this axis. - for (var i=0; i<this._series.length; i++) { - var s = this._series[i]; - var d = s._plotData; - - for (var j=0; j<d.length; j++) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - if (d[j][0] < db.min || db.min == null) { - db.min = d[j][0]; - minsidx=i; - minpidx=j; - minr = d[j][2]; - minMaxRadius = s.maxRadius; - minMult = s.autoscaleMultiplier; - } - if (d[j][0] > db.max || db.max == null) { - db.max = d[j][0]; - maxsidx=i; - maxpidx=j; - maxr = d[j][2]; - maxMaxRadius = s.maxRadius; - maxMult = s.autoscaleMultiplier; - } - } - else { - if (d[j][1] < db.min || db.min == null) { - db.min = d[j][1]; - minsidx=i; - minpidx=j; - minr = d[j][2]; - minMaxRadius = s.maxRadius; - minMult = s.autoscaleMultiplier; - } - if (d[j][1] > db.max || db.max == null) { - db.max = d[j][1]; - maxsidx=i; - maxpidx=j; - maxr = d[j][2]; - maxMaxRadius = s.maxRadius; - maxMult = s.autoscaleMultiplier; - } - } - } - } - - var minRatio = minr/minMaxRadius; - var maxRatio = maxr/maxMaxRadius; - - // need to estimate the effect of the radius on total axis span and adjust axis accordingly. - var span = db.max - db.min; - // var dim = (this.name == 'xaxis' || this.name == 'x2axis') ? this._plotDimensions.width : this._plotDimensions.height; - var dim = Math.min(this._plotDimensions.width, this._plotDimensions.height); - - var minfact = minRatio * minMult/3 * span; - var maxfact = maxRatio * maxMult/3 * span; - db.max += maxfact; - db.min -= minfact; - }; - - function highlight (plot, sidx, pidx) { - plot.plugins.bubbleRenderer.highlightLabelCanvas.empty(); - var s = plot.series[sidx]; - var canvas = plot.plugins.bubbleRenderer.highlightCanvas; - var ctx = canvas._ctx; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - s._highlightedPoint = pidx; - plot.plugins.bubbleRenderer.highlightedSeriesIndex = sidx; - - var color = s.highlightColorGenerator.get(pidx); - var x = s.gridData[pidx][0], - y = s.gridData[pidx][1], - r = s.gridData[pidx][2]; - ctx.save(); - ctx.fillStyle = color; - ctx.strokeStyle = color; - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.arc(x, y, r, 0, 2*Math.PI, 0); - ctx.closePath(); - ctx.fill(); - ctx.restore(); - // bring label to front - if (s.labels[pidx]) { - plot.plugins.bubbleRenderer.highlightLabel = s.labels[pidx].clone(); - plot.plugins.bubbleRenderer.highlightLabel.appendTo(plot.plugins.bubbleRenderer.highlightLabelCanvas); - plot.plugins.bubbleRenderer.highlightLabel.addClass('jqplot-bubble-label-highlight'); - } - } - - function unhighlight (plot) { - var canvas = plot.plugins.bubbleRenderer.highlightCanvas; - var sidx = plot.plugins.bubbleRenderer.highlightedSeriesIndex; - plot.plugins.bubbleRenderer.highlightLabelCanvas.empty(); - canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height); - for (var i=0; i<plot.series.length; i++) { - plot.series[i]._highlightedPoint = null; - } - plot.plugins.bubbleRenderer.highlightedSeriesIndex = null; - plot.target.trigger('jqplotDataUnhighlight'); - } - - - function handleMove(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var si = neighbor.seriesIndex; - var pi = neighbor.pointIndex; - var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]]; - var evt1 = jQuery.Event('jqplotDataMouseOver'); - evt1.pageX = ev.pageX; - evt1.pageY = ev.pageY; - plot.target.trigger(evt1, ins); - if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.bubbleRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { - var evt = jQuery.Event('jqplotDataHighlight'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - highlight (plot, ins[0], ins[1]); - } - } - else if (neighbor == null) { - unhighlight (plot); - } - } - - function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var si = neighbor.seriesIndex; - var pi = neighbor.pointIndex; - var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]]; - if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.bubbleRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { - var evt = jQuery.Event('jqplotDataHighlight'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - highlight (plot, ins[0], ins[1]); - } - } - else if (neighbor == null) { - unhighlight (plot); - } - } - - function handleMouseUp(ev, gridpos, datapos, neighbor, plot) { - var idx = plot.plugins.bubbleRenderer.highlightedSeriesIndex; - if (idx != null && plot.series[idx].highlightMouseDown) { - unhighlight(plot); - } - } - - function handleClick(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var si = neighbor.seriesIndex; - var pi = neighbor.pointIndex; - var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]]; - var evt = jQuery.Event('jqplotDataClick'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - } - } - - function handleRightClick(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var si = neighbor.seriesIndex; - var pi = neighbor.pointIndex; - var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]]; - var idx = plot.plugins.bubbleRenderer.highlightedSeriesIndex; - if (idx != null && plot.series[idx].highlightMouseDown) { - unhighlight(plot); - } - var evt = jQuery.Event('jqplotDataRightClick'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - } - } - - // called within context of plot - // create a canvas which we can draw on. - // insert it before the eventCanvas, so eventCanvas will still capture events. - function postPlotDraw() { - // Memory Leaks patch - if (this.plugins.bubbleRenderer && this.plugins.bubbleRenderer.highlightCanvas) { - this.plugins.bubbleRenderer.highlightCanvas.resetCanvas(); - this.plugins.bubbleRenderer.highlightCanvas = null; - } - - this.plugins.bubbleRenderer = {highlightedSeriesIndex:null}; - this.plugins.bubbleRenderer.highlightCanvas = new $.jqplot.GenericCanvas(); - this.plugins.bubbleRenderer.highlightLabel = null; - this.plugins.bubbleRenderer.highlightLabelCanvas = $('<div style="position:absolute;"></div>'); - var top = this._gridPadding.top; - var left = this._gridPadding.left; - var width = this._plotDimensions.width - this._gridPadding.left - this._gridPadding.right; - var height = this._plotDimensions.height - this._gridPadding.top - this._gridPadding.bottom; - this.plugins.bubbleRenderer.highlightLabelCanvas.css({top:top, left:left, width:width+'px', height:height+'px'}); - - this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-bubbleRenderer-highlight-canvas', this._plotDimensions, this)); - this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightLabelCanvas); - - var hctx = this.plugins.bubbleRenderer.highlightCanvas.setContext(); - } - - - // setup default renderers for axes and legend so user doesn't have to - // called with scope of plot - function preInit(target, data, options) { - options = options || {}; - options.axesDefaults = options.axesDefaults || {}; - options.seriesDefaults = options.seriesDefaults || {}; - // only set these if there is a Bubble series - var setopts = false; - if (options.seriesDefaults.renderer == $.jqplot.BubbleRenderer) { - setopts = true; - } - else if (options.series) { - for (var i=0; i < options.series.length; i++) { - if (options.series[i].renderer == $.jqplot.BubbleRenderer) { - setopts = true; - } - } - } - - if (setopts) { - options.axesDefaults.renderer = $.jqplot.BubbleAxisRenderer; - options.sortData = false; - } - } - - $.jqplot.preInitHooks.push(preInit); - -})(jQuery); - -
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js b/libs/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js deleted file mode 100644 index c900182427..0000000000 --- a/libs/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.CanvasAxisLabelRenderer - * Renderer to draw axis labels with a canvas element to support advanced - * featrues such as rotated text. This renderer uses a separate rendering engine - * to draw the text on the canvas. Two modes of rendering the text are available. - * If the browser has native font support for canvas fonts (currently Mozila 3.5 - * and Safari 4), you can enable text rendering with the canvas fillText method. - * You do so by setting the "enableFontSupport" option to true. - * - * Browsers lacking native font support will have the text drawn on the canvas - * using the Hershey font metrics. Even if the "enableFontSupport" option is true - * non-supporting browsers will still render with the Hershey font. - * - */ - $.jqplot.CanvasAxisLabelRenderer = function(options) { - // Group: Properties - - // prop: angle - // angle of text, measured clockwise from x axis. - this.angle = 0; - // name of the axis associated with this tick - this.axis; - // prop: show - // wether or not to show the tick (mark and label). - this.show = true; - // prop: showLabel - // wether or not to show the label. - this.showLabel = true; - // prop: label - // label for the axis. - this.label = ''; - // prop: fontFamily - // CSS spec for the font-family css attribute. - // Applies only to browsers supporting native font rendering in the - // canvas tag. Currently Mozilla 3.5 and Safari 4. - this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif'; - // prop: fontSize - // CSS spec for font size. - this.fontSize = '11pt'; - // prop: fontWeight - // CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900 - this.fontWeight = 'normal'; - // prop: fontStretch - // Multiplier to condense or expand font width. - // Applies only to browsers which don't support canvas native font rendering. - this.fontStretch = 1.0; - // prop: textColor - // css spec for the color attribute. - this.textColor = '#666666'; - // prop: enableFontSupport - // true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+. - // If true, label will be drawn with canvas tag native support for fonts. - // If false, label will be drawn with Hershey font metrics. - this.enableFontSupport = true; - // prop: pt2px - // Point to pixel scaling factor, used for computing height of bounding box - // around a label. The labels text renderer has a default setting of 1.4, which - // should be suitable for most fonts. Leave as null to use default. If tops of - // letters appear clipped, increase this. If bounding box seems too big, decrease. - // This is an issue only with the native font renderering capabilities of Mozilla - // 3.5 and Safari 4 since they do not provide a method to determine the font height. - this.pt2px = null; - - this._elem; - this._ctx; - this._plotWidth; - this._plotHeight; - this._plotDimensions = {height:null, width:null}; - - $.extend(true, this, options); - - if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') { - this.angle = -90; - } - - var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily}; - if (this.pt2px) { - ropts.pt2px = this.pt2px; - } - - this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); - }; - - $.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) { - $.extend(true, this, options); - this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily}); - }; - - // return width along the x axis - // will check first to see if an element exists. - // if not, will return the computed text box width. - $.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) { - if (this._elem) { - return this._elem.outerWidth(true); - } - else { - var tr = this._textRenderer; - var l = tr.getWidth(ctx); - var h = tr.getHeight(ctx); - var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l); - return w; - } - }; - - // return height along the y axis. - $.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) { - if (this._elem) { - return this._elem.outerHeight(true); - } - else { - var tr = this._textRenderer; - var l = tr.getWidth(ctx); - var h = tr.getHeight(ctx); - var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l); - return w; - } - }; - - $.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() { - var a = this.angle * Math.PI/180; - return a; - }; - - $.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx, plot) { - // Memory Leaks patch - if (this._elem) { - if ($.jqplot.use_excanvas) { - window.G_vmlCanvasManager.uninitElement(this._elem.get(0)); - } - - this._elem.emptyForce(); - this._elem = null; - } - - // create a canvas here, but can't draw on it untill it is appended - // to dom for IE compatability. - var elem = plot.canvasManager.getCanvas(); - - this._textRenderer.setText(this.label, ctx); - var w = this.getWidth(ctx); - var h = this.getHeight(ctx); - elem.width = w; - elem.height = h; - elem.style.width = w; - elem.style.height = h; - - elem = plot.canvasManager.initCanvas(elem); - - this._elem = $(elem); - this._elem.css({ position: 'absolute'}); - this._elem.addClass('jqplot-'+this.axis+'-label'); - - elem = null; - return this._elem; - }; - - $.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() { - this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label); - }; - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.canvasOverlay.js b/libs/jqplot/plugins/jqplot.canvasOverlay.js deleted file mode 100755 index b8832c0971..0000000000 --- a/libs/jqplot/plugins/jqplot.canvasOverlay.js +++ /dev/null @@ -1,619 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - // class: $.jqplot.CanvasOverlay - $.jqplot.CanvasOverlay = function(opts){ - var options = opts || {}; - this.options = { - show: $.jqplot.config.enablePlugins, - deferDraw: false - }; - // prop: objects - this.objects = []; - this.objectNames = []; - this.canvas = null; - this.markerRenderer = new $.jqplot.MarkerRenderer({style:'line'}); - this.markerRenderer.init(); - if (options.objects) { - var objs = options.objects, - obj; - for (var i=0; i<objs.length; i++) { - obj = objs[i]; - for (var n in obj) { - switch (n) { - case 'line': - this.addLine(obj[n]); - break; - case 'horizontalLine': - this.addHorizontalLine(obj[n]); - break; - case 'dashedHorizontalLine': - this.addDashedHorizontalLine(obj[n]); - break; - case 'verticalLine': - this.addVerticalLine(obj[n]); - break; - case 'dashedVerticalLine': - this.addDashedVerticalLine(obj[n]); - break; - default: - break; - } - } - } - } - $.extend(true, this.options, options); - }; - - // called with scope of a plot object - $.jqplot.CanvasOverlay.postPlotInit = function (target, data, opts) { - var options = opts || {}; - // add a canvasOverlay attribute to the plot - this.plugins.canvasOverlay = new $.jqplot.CanvasOverlay(options.canvasOverlay); - }; - - function Line(options) { - this.type = 'line'; - this.options = { - name: null, - show: true, - lineWidth: 2, - lineCap: 'round', - color: '#666666', - // prop: shadow - // wether or not to draw a shadow on the line - shadow: true, - // prop: shadowAngle - // Shadow angle in degrees - shadowAngle: 45, - // prop: shadowOffset - // Shadow offset from line in pixels - shadowOffset: 1, - // prop: shadowDepth - // Number of times shadow is stroked, each stroke offset shadowOffset from the last. - shadowDepth: 3, - // prop: shadowAlpha - // Alpha channel transparency of shadow. 0 = transparent. - shadowAlpha: '0.07', - xaxis: 'xaxis', - yaxis: 'yaxis', - start: [], - stop: [] - }; - $.extend(true, this.options, options); - } - - function HorizontalLine(options) { - this.type = 'horizontalLine'; - this.options = { - name: null, - show: true, - lineWidth: 2, - lineCap: 'round', - color: '#666666', - // prop: shadow - // wether or not to draw a shadow on the line - shadow: true, - // prop: shadowAngle - // Shadow angle in degrees - shadowAngle: 45, - // prop: shadowOffset - // Shadow offset from line in pixels - shadowOffset: 1, - // prop: shadowDepth - // Number of times shadow is stroked, each stroke offset shadowOffset from the last. - shadowDepth: 3, - // prop: shadowAlpha - // Alpha channel transparency of shadow. 0 = transparent. - shadowAlpha: '0.07', - // prop: xaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired x axis here. - xaxis: 'xaxis', - // prop: yaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired y axis here. - yaxis: 'yaxis', - y: null, - xmin: null, - xmax: null, - xOffset: '6px', // number or string. Number interpreted as units, string as pixels. - xminOffset: null, - xmaxOffset: null - }; - $.extend(true, this.options, options); - } - - function DashedHorizontalLine(options) { - this.type = 'dashedHorizontalLine'; - this.options = { - name: null, - show: true, - lineWidth: 2, - lineCap: 'butt', - color: '#666666', - // prop: shadow - // wether or not to draw a shadow on the line - shadow: true, - // prop: shadowAngle - // Shadow angle in degrees - shadowAngle: 45, - // prop: shadowOffset - // Shadow offset from line in pixels - shadowOffset: 1, - // prop: shadowDepth - // Number of times shadow is stroked, each stroke offset shadowOffset from the last. - shadowDepth: 3, - // prop: shadowAlpha - // Alpha channel transparency of shadow. 0 = transparent. - shadowAlpha: '0.07', - // prop: xaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired x axis here. - xaxis: 'xaxis', - // prop: yaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired y axis here. - yaxis: 'yaxis', - y: null, - xmin: null, - xmax: null, - xOffset: '6px', // number or string. Number interpreted as units, string as pixels. - xminOffset: null, - xmaxOffset: null, - // prop: dashPattern - // Array of line, space settings in pixels. - // Default is 8 pixel of line, 8 pixel of space. - // Note, limit to a 2 element array b/c of bug with higher order arrays. - dashPattern: [8,8] - }; - $.extend(true, this.options, options); - } - - function VerticalLine(options) { - this.type = 'verticalLine'; - this.options = { - name: null, - show: true, - lineWidth: 2, - lineCap: 'round', - color: '#666666', - // prop: shadow - // wether or not to draw a shadow on the line - shadow: true, - // prop: shadowAngle - // Shadow angle in degrees - shadowAngle: 45, - // prop: shadowOffset - // Shadow offset from line in pixels - shadowOffset: 1, - // prop: shadowDepth - // Number of times shadow is stroked, each stroke offset shadowOffset from the last. - shadowDepth: 3, - // prop: shadowAlpha - // Alpha channel transparency of shadow. 0 = transparent. - shadowAlpha: '0.07', - // prop: xaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired x axis here. - xaxis: 'xaxis', - // prop: yaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired y axis here. - yaxis: 'yaxis', - x: null, - ymin: null, - ymax: null, - yOffset: '6px', // number or string. Number interpreted as units, string as pixels. - yminOffset: null, - ymaxOffset: null - }; - $.extend(true, this.options, options); - } - - function DashedVerticalLine(options) { - this.type = 'dashedVerticalLine'; - this.options = { - name: null, - show: true, - lineWidth: 2, - lineCap: 'butt', - color: '#666666', - // prop: shadow - // wether or not to draw a shadow on the line - shadow: true, - // prop: shadowAngle - // Shadow angle in degrees - shadowAngle: 45, - // prop: shadowOffset - // Shadow offset from line in pixels - shadowOffset: 1, - // prop: shadowDepth - // Number of times shadow is stroked, each stroke offset shadowOffset from the last. - shadowDepth: 3, - // prop: shadowAlpha - // Alpha channel transparency of shadow. 0 = transparent. - shadowAlpha: '0.07', - // prop: xaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired x axis here. - xaxis: 'xaxis', - // prop: yaxis - // For drawing, canvas has to know which x-y axes to scale to. - // Specify the desired y axis here. - yaxis: 'yaxis', - x: null, - ymin: null, - ymax: null, - yOffset: '6px', // number or string. Number interpreted as units, string as pixels. - yminOffset: null, - ymaxOffset: null, - // prop: dashPattern - // Array of line, space settings in pixels. - // Default is 8 pixel of line, 8 pixel of space. - // Note, limit to a 2 element array b/c of bug with higher order arrays. - dashPattern: [8,8] - }; - $.extend(true, this.options, options); - } - - $.jqplot.CanvasOverlay.prototype.addLine = function(opts) { - var line = new Line(opts); - this.objects.push(line); - this.objectNames.push(line.options.name); - }; - - $.jqplot.CanvasOverlay.prototype.addHorizontalLine = function(opts) { - var line = new HorizontalLine(opts); - this.objects.push(line); - this.objectNames.push(line.options.name); - }; - - $.jqplot.CanvasOverlay.prototype.addDashedHorizontalLine = function(opts) { - var line = new DashedHorizontalLine(opts); - this.objects.push(line); - this.objectNames.push(line.options.name); - }; - - $.jqplot.CanvasOverlay.prototype.addVerticalLine = function(opts) { - var line = new VerticalLine(opts); - this.objects.push(line); - this.objectNames.push(line.options.name); - }; - - $.jqplot.CanvasOverlay.prototype.addDashedVerticalLine = function(opts) { - var line = new DashedVerticalLine(opts); - this.objects.push(line); - this.objectNames.push(line.options.name); - }; - - $.jqplot.CanvasOverlay.prototype.removeObject = function(idx) { - // check if integer, remove by index - if ($.type(idx) == 'number') { - this.objects.splice(idx, 1); - this.objectNames.splice(idx, 1); - } - // if string, remove by name - else { - var id = $.inArray(idx, this.objectNames); - if (id != -1) { - this.objects.splice(id, 1); - this.objectNames.splice(id, 1); - } - } - }; - - $.jqplot.CanvasOverlay.prototype.getObject = function(idx) { - // check if integer, remove by index - if ($.type(idx) == 'number') { - return this.objects[idx]; - } - // if string, remove by name - else { - var id = $.inArray(idx, this.objectNames); - if (id != -1) { - return this.objects[id]; - } - } - }; - - // Set get as alias for getObject. - $.jqplot.CanvasOverlay.prototype.get = $.jqplot.CanvasOverlay.prototype.getObject; - - $.jqplot.CanvasOverlay.prototype.clear = function(plot) { - this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(), this.canvas.getHeight()); - }; - - $.jqplot.CanvasOverlay.prototype.draw = function(plot) { - var obj, - objs = this.objects, - mr = this.markerRenderer, - start, - stop; - if (this.options.show) { - this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(), this.canvas.getHeight()); - for (var k=0; k<objs.length; k++) { - obj = objs[k]; - var opts = $.extend(true, {}, obj.options); - if (obj.options.show) { - // style and shadow properties should be set before - // every draw of marker renderer. - mr.shadow = obj.options.shadow; - switch (obj.type) { - case 'line': - // style and shadow properties should be set before - // every draw of marker renderer. - mr.style = 'line'; - opts.closePath = false; - start = [plot.axes[obj.options.xaxis].series_u2p(obj.options.start[0]), plot.axes[obj.options.yaxis].series_u2p(obj.options.start[1])]; - stop = [plot.axes[obj.options.xaxis].series_u2p(obj.options.stop[0]), plot.axes[obj.options.yaxis].series_u2p(obj.options.stop[1])]; - mr.draw(start, stop, this.canvas._ctx, opts); - break; - case 'horizontalLine': - - // style and shadow properties should be set before - // every draw of marker renderer. - if (obj.options.y != null) { - mr.style = 'line'; - opts.closePath = false; - var xaxis = plot.axes[obj.options.xaxis], - xstart, - xstop, - y = plot.axes[obj.options.yaxis].series_u2p(obj.options.y), - xminoff = obj.options.xminOffset || obj.options.xOffset, - xmaxoff = obj.options.xmaxOffset || obj.options.xOffset; - if (obj.options.xmin != null) { - xstart = xaxis.series_u2p(obj.options.xmin); - } - else if (xminoff != null) { - if ($.type(xminoff) == "number") { - xstart = xaxis.series_u2p(xaxis.min + xminoff); - } - else if ($.type(xminoff) == "string") { - xstart = xaxis.series_u2p(xaxis.min) + parseFloat(xminoff); - } - } - if (obj.options.xmax != null) { - xstop = xaxis.series_u2p(obj.options.xmax); - } - else if (xmaxoff != null) { - if ($.type(xmaxoff) == "number") { - xstop = xaxis.series_u2p(xaxis.max - xmaxoff); - } - else if ($.type(xmaxoff) == "string") { - xstop = xaxis.series_u2p(xaxis.max) - parseFloat(xmaxoff); - } - } - if (xstop != null && xstart != null) { - mr.draw([xstart, y], [xstop, y], this.canvas._ctx, opts); - } - } - break; - - case 'dashedHorizontalLine': - - var dashPat = obj.options.dashPattern; - var dashPatLen = 0; - for (var i=0; i<dashPat.length; i++) { - dashPatLen += dashPat[i]; - } - - // style and shadow properties should be set before - // every draw of marker renderer. - if (obj.options.y != null) { - mr.style = 'line'; - opts.closePath = false; - var xaxis = plot.axes[obj.options.xaxis], - xstart, - xstop, - y = plot.axes[obj.options.yaxis].series_u2p(obj.options.y), - xminoff = obj.options.xminOffset || obj.options.xOffset, - xmaxoff = obj.options.xmaxOffset || obj.options.xOffset; - if (obj.options.xmin != null) { - xstart = xaxis.series_u2p(obj.options.xmin); - } - else if (xminoff != null) { - if ($.type(xminoff) == "number") { - xstart = xaxis.series_u2p(xaxis.min + xminoff); - } - else if ($.type(xminoff) == "string") { - xstart = xaxis.series_u2p(xaxis.min) + parseFloat(xminoff); - } - } - if (obj.options.xmax != null) { - xstop = xaxis.series_u2p(obj.options.xmax); - } - else if (xmaxoff != null) { - if ($.type(xmaxoff) == "number") { - xstop = xaxis.series_u2p(xaxis.max - xmaxoff); - } - else if ($.type(xmaxoff) == "string") { - xstop = xaxis.series_u2p(xaxis.max) - parseFloat(xmaxoff); - } - } - if (xstop != null && xstart != null) { - var numDash = Math.ceil((xstop - xstart)/dashPatLen); - var b=xstart, e; - for (var i=0; i<numDash; i++) { - for (var j=0; j<dashPat.length; j+=2) { - e = b+dashPat[j]; - mr.draw([b, y], [e, y], this.canvas._ctx, opts); - b += dashPat[j]; - if (j < dashPat.length-1) { - b += dashPat[j+1]; - } - } - } - } - } - break; - - case 'verticalLine': - - // style and shadow properties should be set before - // every draw of marker renderer. - if (obj.options.x != null) { - mr.style = 'line'; - opts.closePath = false; - var yaxis = plot.axes[obj.options.yaxis], - ystart, - ystop, - x = plot.axes[obj.options.xaxis].series_u2p(obj.options.x), - yminoff = obj.options.yminOffset || obj.options.yOffset, - ymaxoff = obj.options.ymaxOffset || obj.options.yOffset; - if (obj.options.ymin != null) { - ystart = yaxis.series_u2p(obj.options.ymin); - } - else if (yminoff != null) { - if ($.type(yminoff) == "number") { - ystart = yaxis.series_u2p(yaxis.min - yminoff); - } - else if ($.type(yminoff) == "string") { - ystart = yaxis.series_u2p(yaxis.min) - parseFloat(yminoff); - } - } - if (obj.options.ymax != null) { - ystop = yaxis.series_u2p(obj.options.ymax); - } - else if (ymaxoff != null) { - if ($.type(ymaxoff) == "number") { - ystop = yaxis.series_u2p(yaxis.max + ymaxoff); - } - else if ($.type(ymaxoff) == "string") { - ystop = yaxis.series_u2p(yaxis.max) + parseFloat(ymaxoff); - } - } - if (ystop != null && ystart != null) { - mr.draw([x, ystart], [x, ystop], this.canvas._ctx, opts); - } - } - break; - - case 'dashedVerticalLine': - - var dashPat = obj.options.dashPattern; - var dashPatLen = 0; - for (var i=0; i<dashPat.length; i++) { - dashPatLen += dashPat[i]; - } - - // style and shadow properties should be set before - // every draw of marker renderer. - if (obj.options.x != null) { - mr.style = 'line'; - opts.closePath = false; - var yaxis = plot.axes[obj.options.yaxis], - ystart, - ystop, - x = plot.axes[obj.options.xaxis].series_u2p(obj.options.x), - yminoff = obj.options.yminOffset || obj.options.yOffset, - ymaxoff = obj.options.ymaxOffset || obj.options.yOffset; - if (obj.options.ymin != null) { - ystart = yaxis.series_u2p(obj.options.ymin); - } - else if (yminoff != null) { - if ($.type(yminoff) == "number") { - ystart = yaxis.series_u2p(yaxis.min - yminoff); - } - else if ($.type(yminoff) == "string") { - ystart = yaxis.series_u2p(yaxis.min) - parseFloat(yminoff); - } - } - if (obj.options.ymax != null) { - ystop = yaxis.series_u2p(obj.options.ymax); - } - else if (ymaxoff != null) { - if ($.type(ymaxoff) == "number") { - ystop = yaxis.series_u2p(yaxis.max + ymaxoff); - } - else if ($.type(ymaxoff) == "string") { - ystop = yaxis.series_u2p(yaxis.max) + parseFloat(ymaxoff); - } - } - - - if (ystop != null && ystart != null) { - var numDash = Math.ceil((ystart - ystop)/dashPatLen); - var firstDashAdjust = ((numDash * dashPatLen) - (ystart - ystop))/2.0; - var b=ystart, e, bs, es; - for (var i=0; i<numDash; i++) { - for (var j=0; j<dashPat.length; j+=2) { - e = b - dashPat[j]; - if (e < ystop) { - e = ystop; - } - if (b < ystop) { - b = ystop; - } - // es = e; - // if (i == 0) { - // es += firstDashAdjust; - // } - mr.draw([x, b], [x, e], this.canvas._ctx, opts); - b -= dashPat[j]; - if (j < dashPat.length-1) { - b -= dashPat[j+1]; - } - } - } - } - } - break; - - default: - break; - } - } - } - } - }; - - // called within context of plot - // create a canvas which we can draw on. - // insert it before the eventCanvas, so eventCanvas will still capture events. - $.jqplot.CanvasOverlay.postPlotDraw = function() { - // Memory Leaks patch - if (this.plugins.canvasOverlay && this.plugins.canvasOverlay.highlightCanvas) { - this.plugins.canvasOverlay.highlightCanvas.resetCanvas(); - this.plugins.canvasOverlay.highlightCanvas = null; - } - this.plugins.canvasOverlay.canvas = new $.jqplot.GenericCanvas(); - - this.eventCanvas._elem.before(this.plugins.canvasOverlay.canvas.createElement(this._gridPadding, 'jqplot-overlayCanvas-canvas', this._plotDimensions, this)); - this.plugins.canvasOverlay.canvas.setContext(); - if (!this.plugins.canvasOverlay.deferDraw) { - this.plugins.canvasOverlay.draw(this); - } - }; - - $.jqplot.postInitHooks.push($.jqplot.CanvasOverlay.postPlotInit); - $.jqplot.postDrawHooks.push($.jqplot.CanvasOverlay.postPlotDraw); - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.ciParser.js b/libs/jqplot/plugins/jqplot.ciParser.js deleted file mode 100644 index ebbaa9be17..0000000000 --- a/libs/jqplot/plugins/jqplot.ciParser.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.ciParser - * Data Renderer function which converts a custom JSON data object into jqPlot data format. - * Set this as a callable on the jqplot dataRenderer plot option: - * - * > plot = $.jqplot('mychart', [data], { dataRenderer: $.jqplot.ciParser, ... }); - * - * Where data is an object in JSON format or a JSON encoded string conforming to the - * City Index API spec. - * - * Note that calling the renderer function is handled internally by jqPlot. The - * user does not have to call the function. The parameters described below will - * automatically be passed to the ciParser function. - * - * Parameters: - * data - JSON encoded string or object. - * plot - reference to jqPlot Plot object. - * - * Returns: - * data array in jqPlot format. - * - */ - $.jqplot.ciParser = function (data, plot) { - var ret = [], - line, - temp, - i, j, k, kk; - - if (typeof(data) == "string") { - data = $.jqplot.JSON.parse(data, handleStrings); - } - - else if (typeof(data) == "object") { - for (k in data) { - for (i=0; i<data[k].length; i++) { - for (kk in data[k][i]) { - data[k][i][kk] = handleStrings(kk, data[k][i][kk]); - } - } - } - } - - else { - return null; - } - - // function handleStrings - // Checks any JSON encoded strings to see if they are - // encoded dates. If so, pull out the timestamp. - // Expects dates to be represented by js timestamps. - - function handleStrings(key, value) { - var a; - if (value != null) { - if (value.toString().indexOf('Date') >= 0) { - //here we will try to extract the ticks from the Date string in the "value" fields of JSON returned data - a = /^\/Date\((-?[0-9]+)\)\/$/.exec(value); - if (a) { - return parseInt(a[1], 10); - } - } - return value; - } - } - - for (var prop in data) { - line = []; - temp = data[prop]; - switch (prop) { - case "PriceTicks": - for (i=0; i<temp.length; i++) { - line.push([temp[i]['TickDate'], temp[i]['Price']]); - } - break; - case "PriceBars": - for (i=0; i<temp.length; i++) { - line.push([temp[i]['BarDate'], temp[i]['Open'], temp[i]['High'], temp[i]['Low'], temp[i]['Close']]); - } - break; - } - ret.push(line); - } - return ret; - }; -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.cursor.js b/libs/jqplot/plugins/jqplot.cursor.js deleted file mode 100755 index 85ae21863d..0000000000 --- a/libs/jqplot/plugins/jqplot.cursor.js +++ /dev/null @@ -1,1051 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - - /** - * Class: $.jqplot.Cursor - * Plugin class representing the cursor as displayed on the plot. - */ - $.jqplot.Cursor = function(options) { - // Group: Properties - // - // prop: style - // CSS spec for cursor style - this.style = 'crosshair'; - this.previousCursor = 'auto'; - // prop: show - // wether to show the cursor or not. - this.show = $.jqplot.config.enablePlugins; - // prop: showTooltip - // show a cursor position tooltip. Location of the tooltip - // will be controlled by followMouse and tooltipLocation. - this.showTooltip = true; - // prop: followMouse - // Tooltip follows the mouse, it is not at a fixed location. - // Tooltip will show on the grid at the location given by - // tooltipLocation, offset from the grid edge by tooltipOffset. - this.followMouse = false; - // prop: tooltipLocation - // Where to position tooltip. If followMouse is true, this is - // relative to the cursor, otherwise, it is relative to the grid. - // One of 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw' - this.tooltipLocation = 'se'; - // prop: tooltipOffset - // Pixel offset of tooltip from the grid boudaries or cursor center. - this.tooltipOffset = 6; - // prop: showTooltipGridPosition - // show the grid pixel coordinates of the mouse. - this.showTooltipGridPosition = false; - // prop: showTooltipUnitPosition - // show the unit (data) coordinates of the mouse. - this.showTooltipUnitPosition = true; - // prop: showTooltipDataPosition - // Used with showVerticalLine to show intersecting data points in the tooltip. - this.showTooltipDataPosition = false; - // prop: tooltipFormatString - // sprintf format string for the tooltip. - // Uses Ash Searle's javascript sprintf implementation - // found here: http://hexmen.com/blog/2007/03/printf-sprintf/ - // See http://perldoc.perl.org/functions/sprintf.html for reference - // Note, if showTooltipDataPosition is true, the default tooltipFormatString - // will be set to the cursorLegendFormatString, not the default given here. - this.tooltipFormatString = '%.4P, %.4P'; - // prop: useAxesFormatters - // Use the x and y axes formatters to format the text in the tooltip. - this.useAxesFormatters = true; - // prop: tooltipAxisGroups - // Show position for the specified axes. - // This is an array like [['xaxis', 'yaxis'], ['xaxis', 'y2axis']] - // Default is to compute automatically for all visible axes. - this.tooltipAxisGroups = []; - // prop: zoom - // Enable plot zooming. - this.zoom = false; - // zoomProxy and zoomTarget properties are not directly set by user. - // They Will be set through call to zoomProxy method. - this.zoomProxy = false; - this.zoomTarget = false; - // prop: looseZoom - // Will expand zoom range to provide more rounded tick values. - // Works only with linear axes and date axes. - this.looseZoom = false; - // prop: clickReset - // Will reset plot zoom if single click on plot without drag. - this.clickReset = false; - // prop: dblClickReset - // Will reset plot zoom if double click on plot without drag. - this.dblClickReset = true; - // prop: showVerticalLine - // draw a vertical line across the plot which follows the cursor. - // When the line is near a data point, a special legend and/or tooltip can - // be updated with the data values. - this.showVerticalLine = false; - // prop: showHorizontalLine - // draw a horizontal line across the plot which follows the cursor. - this.showHorizontalLine = false; - // prop: constrainZoomTo - // 'none', 'x' or 'y' - this.constrainZoomTo = 'none'; - // // prop: autoscaleConstraint - // // when a constrained axis is specified, true will - // // auatoscale the adjacent axis. - // this.autoscaleConstraint = true; - this.shapeRenderer = new $.jqplot.ShapeRenderer(); - this._zoom = {start:[], end:[], started: false, zooming:false, isZoomed:false, axes:{start:{}, end:{}}, gridpos:{}, datapos:{}}; - this._tooltipElem; - this.zoomCanvas; - this.cursorCanvas; - // prop: intersectionThreshold - // pixel distance from data point or marker to consider cursor lines intersecting with point. - // If data point markers are not shown, this should be >= 1 or will often miss point intersections. - this.intersectionThreshold = 2; - // prop: showCursorLegend - // Replace the plot legend with an enhanced legend displaying intersection information. - this.showCursorLegend = false; - // prop: cursorLegendFormatString - // Format string used in the cursor legend. If showTooltipDataPosition is true, - // this will also be the default format string used by tooltipFormatString. - this.cursorLegendFormatString = $.jqplot.Cursor.cursorLegendFormatString; - // whether the cursor is over the grid or not. - this._oldHandlers = {onselectstart: null, ondrag: null, onmousedown: null}; - // prop: constrainOutsideZoom - // True to limit actual zoom area to edges of grid, even when zooming - // outside of plot area. That is, can't zoom out by mousing outside plot. - this.constrainOutsideZoom = true; - // prop: showTooltipOutsideZoom - // True will keep updating the tooltip when zooming of the grid. - this.showTooltipOutsideZoom = false; - // true if mouse is over grid, false if not. - this.onGrid = false; - $.extend(true, this, options); - }; - - $.jqplot.Cursor.cursorLegendFormatString = '%s x:%s, y:%s'; - - // called with scope of plot - $.jqplot.Cursor.init = function (target, data, opts){ - // add a cursor attribute to the plot - var options = opts || {}; - this.plugins.cursor = new $.jqplot.Cursor(options.cursor); - var c = this.plugins.cursor; - - if (c.show) { - $.jqplot.eventListenerHooks.push(['jqplotMouseEnter', handleMouseEnter]); - $.jqplot.eventListenerHooks.push(['jqplotMouseLeave', handleMouseLeave]); - $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMouseMove]); - - if (c.showCursorLegend) { - opts.legend = opts.legend || {}; - opts.legend.renderer = $.jqplot.CursorLegendRenderer; - opts.legend.formatString = this.plugins.cursor.cursorLegendFormatString; - opts.legend.show = true; - } - - if (c.zoom) { - $.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleMouseDown]); - - if (c.clickReset) { - $.jqplot.eventListenerHooks.push(['jqplotClick', handleClick]); - } - - if (c.dblClickReset) { - $.jqplot.eventListenerHooks.push(['jqplotDblClick', handleDblClick]); - } - } - - this.resetZoom = function() { - var axes = this.axes; - if (!c.zoomProxy) { - for (var ax in axes) { - axes[ax].reset(); - axes[ax]._ticks = []; - // fake out tick creation algorithm to make sure original auto - // computed format string is used if _overrideFormatString is true - axes[ax]._autoFormatString = c._zoom.axes[ax].tickFormatString; - } - this.redraw(); - } - else { - var ctx = this.plugins.cursor.zoomCanvas._ctx; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - ctx = null; - } - this.plugins.cursor._zoom.isZoomed = false; - this.target.trigger('jqplotResetZoom', [this, this.plugins.cursor]); - }; - - - if (c.showTooltipDataPosition) { - c.showTooltipUnitPosition = false; - c.showTooltipGridPosition = false; - if (options.cursor.tooltipFormatString == undefined) { - c.tooltipFormatString = $.jqplot.Cursor.cursorLegendFormatString; - } - } - } - }; - - // called with context of plot - $.jqplot.Cursor.postDraw = function() { - var c = this.plugins.cursor; - - // Memory Leaks patch - if (c.zoomCanvas) { - c.zoomCanvas.resetCanvas(); - c.zoomCanvas = null; - } - - if (c.cursorCanvas) { - c.cursorCanvas.resetCanvas(); - c.cursorCanvas = null; - } - - if (c._tooltipElem) { - c._tooltipElem.emptyForce(); - c._tooltipElem = null; - } - - - if (c.zoom) { - c.zoomCanvas = new $.jqplot.GenericCanvas(); - this.eventCanvas._elem.before(c.zoomCanvas.createElement(this._gridPadding, 'jqplot-zoom-canvas', this._plotDimensions, this)); - c.zoomCanvas.setContext(); - } - - var elem = document.createElement('div'); - c._tooltipElem = $(elem); - elem = null; - c._tooltipElem.addClass('jqplot-cursor-tooltip'); - c._tooltipElem.css({position:'absolute', display:'none'}); - - - if (c.zoomCanvas) { - c.zoomCanvas._elem.before(c._tooltipElem); - } - - else { - this.eventCanvas._elem.before(c._tooltipElem); - } - - if (c.showVerticalLine || c.showHorizontalLine) { - c.cursorCanvas = new $.jqplot.GenericCanvas(); - this.eventCanvas._elem.before(c.cursorCanvas.createElement(this._gridPadding, 'jqplot-cursor-canvas', this._plotDimensions, this)); - c.cursorCanvas.setContext(); - } - - // if we are showing the positions in unit coordinates, and no axes groups - // were specified, create a default set. - if (c.showTooltipUnitPosition){ - if (c.tooltipAxisGroups.length === 0) { - var series = this.series; - var s; - var temp = []; - for (var i=0; i<series.length; i++) { - s = series[i]; - var ax = s.xaxis+','+s.yaxis; - if ($.inArray(ax, temp) == -1) { - temp.push(ax); - } - } - for (var i=0; i<temp.length; i++) { - c.tooltipAxisGroups.push(temp[i].split(',')); - } - } - } - }; - - // Group: methods - // - // method: $.jqplot.Cursor.zoomProxy - // links targetPlot to controllerPlot so that plot zooming of - // targetPlot will be controlled by zooming on the controllerPlot. - // controllerPlot will not actually zoom, but acts as an - // overview plot. Note, the zoom options must be set to true for - // zoomProxy to work. - $.jqplot.Cursor.zoomProxy = function(targetPlot, controllerPlot) { - var tc = targetPlot.plugins.cursor; - var cc = controllerPlot.plugins.cursor; - tc.zoomTarget = true; - tc.zoom = true; - tc.style = 'auto'; - tc.dblClickReset = false; - cc.zoom = true; - cc.zoomProxy = true; - - controllerPlot.target.bind('jqplotZoom', plotZoom); - controllerPlot.target.bind('jqplotResetZoom', plotReset); - - function plotZoom(ev, gridpos, datapos, plot, cursor) { - tc.doZoom(gridpos, datapos, targetPlot, cursor); - } - - function plotReset(ev, plot, cursor) { - targetPlot.resetZoom(); - } - }; - - $.jqplot.Cursor.prototype.resetZoom = function(plot, cursor) { - var axes = plot.axes; - var cax = cursor._zoom.axes; - if (!plot.plugins.cursor.zoomProxy && cursor._zoom.isZoomed) { - for (var ax in axes) { - // axes[ax]._ticks = []; - // axes[ax].min = cax[ax].min; - // axes[ax].max = cax[ax].max; - // axes[ax].numberTicks = cax[ax].numberTicks; - // axes[ax].tickInterval = cax[ax].tickInterval; - // // for date axes - // axes[ax].daTickInterval = cax[ax].daTickInterval; - axes[ax].reset(); - axes[ax]._ticks = []; - // fake out tick creation algorithm to make sure original auto - // computed format string is used if _overrideFormatString is true - axes[ax]._autoFormatString = cax[ax].tickFormatString; - } - plot.redraw(); - cursor._zoom.isZoomed = false; - } - else { - var ctx = cursor.zoomCanvas._ctx; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - ctx = null; - } - plot.target.trigger('jqplotResetZoom', [plot, cursor]); - }; - - $.jqplot.Cursor.resetZoom = function(plot) { - plot.resetZoom(); - }; - - $.jqplot.Cursor.prototype.doZoom = function (gridpos, datapos, plot, cursor) { - var c = cursor; - var axes = plot.axes; - var zaxes = c._zoom.axes; - var start = zaxes.start; - var end = zaxes.end; - var min, max, dp, span; - var ctx = plot.plugins.cursor.zoomCanvas._ctx; - // don't zoom if zoom area is too small (in pixels) - if ((c.constrainZoomTo == 'none' && Math.abs(gridpos.x - c._zoom.start[0]) > 6 && Math.abs(gridpos.y - c._zoom.start[1]) > 6) || (c.constrainZoomTo == 'x' && Math.abs(gridpos.x - c._zoom.start[0]) > 6) || (c.constrainZoomTo == 'y' && Math.abs(gridpos.y - c._zoom.start[1]) > 6)) { - if (!plot.plugins.cursor.zoomProxy) { - for (var ax in datapos) { - // make a copy of the original axes to revert back. - if (c._zoom.axes[ax] == undefined) { - c._zoom.axes[ax] = {}; - c._zoom.axes[ax].numberTicks = axes[ax].numberTicks; - c._zoom.axes[ax].tickInterval = axes[ax].tickInterval; - // for date axes... - c._zoom.axes[ax].daTickInterval = axes[ax].daTickInterval; - c._zoom.axes[ax].min = axes[ax].min; - c._zoom.axes[ax].max = axes[ax].max; - c._zoom.axes[ax].tickFormatString = (axes[ax].tickOptions != null) ? axes[ax].tickOptions.formatString : ''; - } - - - if ((c.constrainZoomTo == 'none') || (c.constrainZoomTo == 'x' && ax.charAt(0) == 'x') || (c.constrainZoomTo == 'y' && ax.charAt(0) == 'y')) { - dp = datapos[ax]; - if (dp != null) { - var newmin, newmax; - if (dp > start[ax]) { - newmin = start[ax]; - newmax = dp; - } - else { - span = start[ax] - dp; - newmin = dp; - newmax = start[ax]; - } - - if (this.looseZoom && (axes[ax].renderer.constructor === $.jqplot.LinearAxisRenderer || axes[ax].renderer.constructor === $.jqplot.DateAxisRenderer)) { - var ret = $.jqplot.LinearTickGenerator(newmin, newmax); - axes[ax].min = ret[0]; - axes[ax].max = ret[1]; - axes[ax]._autoFormatString = ret[3]; - axes[ax].numberTicks = ret[2]; - axes[ax].tickInterval = ret[4]; - // for date axes... - axes[ax].daTickInterval = [ret[4]/1000, 'seconds']; - } - else { - axes[ax].min = newmin; - axes[ax].max = newmax; - axes[ax].tickInterval = null; - // for date axes... - axes[ax].daTickInterval = null; - } - - axes[ax]._ticks = []; - } - } - - // if ((c.constrainZoomTo == 'x' && ax.charAt(0) == 'y' && c.autoscaleConstraint) || (c.constrainZoomTo == 'y' && ax.charAt(0) == 'x' && c.autoscaleConstraint)) { - // dp = datapos[ax]; - // if (dp != null) { - // axes[ax].max == null; - // axes[ax].min = null; - // } - // } - } - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - plot.redraw(); - c._zoom.isZoomed = true; - ctx = null; - } - plot.target.trigger('jqplotZoom', [gridpos, datapos, plot, cursor]); - } - }; - - $.jqplot.preInitHooks.push($.jqplot.Cursor.init); - $.jqplot.postDrawHooks.push($.jqplot.Cursor.postDraw); - - function updateTooltip(gridpos, datapos, plot) { - var c = plot.plugins.cursor; - var s = ''; - var addbr = false; - if (c.showTooltipGridPosition) { - s = gridpos.x+', '+gridpos.y; - addbr = true; - } - if (c.showTooltipUnitPosition) { - var g; - for (var i=0; i<c.tooltipAxisGroups.length; i++) { - g = c.tooltipAxisGroups[i]; - if (addbr) { - s += '<br />'; - } - if (c.useAxesFormatters) { - var xf = plot.axes[g[0]]._ticks[0].formatter; - var yf = plot.axes[g[1]]._ticks[0].formatter; - var xfstr = plot.axes[g[0]]._ticks[0].formatString; - var yfstr = plot.axes[g[1]]._ticks[0].formatString; - s += xf(xfstr, datapos[g[0]]) + ', '+ yf(yfstr, datapos[g[1]]); - } - else { - s += $.jqplot.sprintf(c.tooltipFormatString, datapos[g[0]], datapos[g[1]]); - } - addbr = true; - } - } - - if (c.showTooltipDataPosition) { - var series = plot.series; - var ret = getIntersectingPoints(plot, gridpos.x, gridpos.y); - var addbr = false; - - for (var i = 0; i< series.length; i++) { - if (series[i].show) { - var idx = series[i].index; - var label = series[i].label.toString(); - var cellid = $.inArray(idx, ret.indices); - var sx = undefined; - var sy = undefined; - if (cellid != -1) { - var data = ret.data[cellid].data; - if (c.useAxesFormatters) { - var xf = series[i]._xaxis._ticks[0].formatter; - var yf = series[i]._yaxis._ticks[0].formatter; - var xfstr = series[i]._xaxis._ticks[0].formatString; - var yfstr = series[i]._yaxis._ticks[0].formatString; - sx = xf(xfstr, data[0]); - sy = yf(yfstr, data[1]); - } - else { - sx = data[0]; - sy = data[1]; - } - if (addbr) { - s += '<br />'; - } - s += $.jqplot.sprintf(c.tooltipFormatString, label, sx, sy); - addbr = true; - } - } - } - - } - c._tooltipElem.html(s); - } - - function moveLine(gridpos, plot) { - var c = plot.plugins.cursor; - var ctx = c.cursorCanvas._ctx; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - if (c.showVerticalLine) { - c.shapeRenderer.draw(ctx, [[gridpos.x, 0], [gridpos.x, ctx.canvas.height]]); - } - if (c.showHorizontalLine) { - c.shapeRenderer.draw(ctx, [[0, gridpos.y], [ctx.canvas.width, gridpos.y]]); - } - var ret = getIntersectingPoints(plot, gridpos.x, gridpos.y); - if (c.showCursorLegend) { - var cells = $(plot.targetId + ' td.jqplot-cursor-legend-label'); - for (var i=0; i<cells.length; i++) { - var idx = $(cells[i]).data('seriesIndex'); - var series = plot.series[idx]; - var label = series.label.toString(); - var cellid = $.inArray(idx, ret.indices); - var sx = undefined; - var sy = undefined; - if (cellid != -1) { - var data = ret.data[cellid].data; - if (c.useAxesFormatters) { - var xf = series._xaxis._ticks[0].formatter; - var yf = series._yaxis._ticks[0].formatter; - var xfstr = series._xaxis._ticks[0].formatString; - var yfstr = series._yaxis._ticks[0].formatString; - sx = xf(xfstr, data[0]); - sy = yf(yfstr, data[1]); - } - else { - sx = data[0]; - sy = data[1]; - } - } - if (plot.legend.escapeHtml) { - $(cells[i]).text($.jqplot.sprintf(c.cursorLegendFormatString, label, sx, sy)); - } - else { - $(cells[i]).html($.jqplot.sprintf(c.cursorLegendFormatString, label, sx, sy)); - } - } - } - ctx = null; - } - - function getIntersectingPoints(plot, x, y) { - var ret = {indices:[], data:[]}; - var s, i, d0, d, j, r, p; - var threshold; - var c = plot.plugins.cursor; - for (var i=0; i<plot.series.length; i++) { - s = plot.series[i]; - r = s.renderer; - if (s.show) { - threshold = c.intersectionThreshold; - if (s.showMarker) { - threshold += s.markerRenderer.size/2; - } - for (var j=0; j<s.gridData.length; j++) { - p = s.gridData[j]; - // check vertical line - if (c.showVerticalLine) { - if (Math.abs(x-p[0]) <= threshold) { - ret.indices.push(i); - ret.data.push({seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}); - } - } - } - } - } - return ret; - } - - function moveTooltip(gridpos, plot) { - var c = plot.plugins.cursor; - var elem = c._tooltipElem; - switch (c.tooltipLocation) { - case 'nw': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top - c.tooltipOffset - elem.outerHeight(true); - break; - case 'n': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2; - var y = gridpos.y + plot._gridPadding.top - c.tooltipOffset - elem.outerHeight(true); - break; - case 'ne': - var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top - c.tooltipOffset - elem.outerHeight(true); - break; - case 'e': - var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2; - break; - case 'se': - var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset; - break; - case 's': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2; - var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset; - break; - case 'sw': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset; - break; - case 'w': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2; - break; - default: - var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset; - var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset; - break; - } - - elem.css('left', x); - elem.css('top', y); - elem = null; - } - - function positionTooltip(plot) { - // fake a grid for positioning - var grid = plot._gridPadding; - var c = plot.plugins.cursor; - var elem = c._tooltipElem; - switch (c.tooltipLocation) { - case 'nw': - var a = grid.left + c.tooltipOffset; - var b = grid.top + c.tooltipOffset; - elem.css('left', a); - elem.css('top', b); - break; - case 'n': - var a = (grid.left + (plot._plotDimensions.width - grid.right))/2 - elem.outerWidth(true)/2; - var b = grid.top + c.tooltipOffset; - elem.css('left', a); - elem.css('top', b); - break; - case 'ne': - var a = grid.right + c.tooltipOffset; - var b = grid.top + c.tooltipOffset; - elem.css({right:a, top:b}); - break; - case 'e': - var a = grid.right + c.tooltipOffset; - var b = (grid.top + (plot._plotDimensions.height - grid.bottom))/2 - elem.outerHeight(true)/2; - elem.css({right:a, top:b}); - break; - case 'se': - var a = grid.right + c.tooltipOffset; - var b = grid.bottom + c.tooltipOffset; - elem.css({right:a, bottom:b}); - break; - case 's': - var a = (grid.left + (plot._plotDimensions.width - grid.right))/2 - elem.outerWidth(true)/2; - var b = grid.bottom + c.tooltipOffset; - elem.css({left:a, bottom:b}); - break; - case 'sw': - var a = grid.left + c.tooltipOffset; - var b = grid.bottom + c.tooltipOffset; - elem.css({left:a, bottom:b}); - break; - case 'w': - var a = grid.left + c.tooltipOffset; - var b = (grid.top + (plot._plotDimensions.height - grid.bottom))/2 - elem.outerHeight(true)/2; - elem.css({left:a, top:b}); - break; - default: // same as 'se' - var a = grid.right - c.tooltipOffset; - var b = grid.bottom + c.tooltipOffset; - elem.css({right:a, bottom:b}); - break; - } - elem = null; - } - - function handleClick (ev, gridpos, datapos, neighbor, plot) { - ev.preventDefault(); - ev.stopImmediatePropagation(); - var c = plot.plugins.cursor; - if (c.clickReset) { - c.resetZoom(plot, c); - } - var sel = window.getSelection; - if (document.selection && document.selection.empty) - { - document.selection.empty(); - } - else if (sel && !sel().isCollapsed) { - sel().collapse(); - } - return false; - } - - function handleDblClick (ev, gridpos, datapos, neighbor, plot) { - ev.preventDefault(); - ev.stopImmediatePropagation(); - var c = plot.plugins.cursor; - if (c.dblClickReset) { - c.resetZoom(plot, c); - } - var sel = window.getSelection; - if (document.selection && document.selection.empty) - { - document.selection.empty(); - } - else if (sel && !sel().isCollapsed) { - sel().collapse(); - } - return false; - } - - function handleMouseLeave(ev, gridpos, datapos, neighbor, plot) { - var c = plot.plugins.cursor; - c.onGrid = false; - if (c.show) { - $(ev.target).css('cursor', c.previousCursor); - if (c.showTooltip && !(c._zoom.zooming && c.showTooltipOutsideZoom && !c.constrainOutsideZoom)) { - c._tooltipElem.hide(); - } - if (c.zoom) { - c._zoom.gridpos = gridpos; - c._zoom.datapos = datapos; - } - if (c.showVerticalLine || c.showHorizontalLine) { - var ctx = c.cursorCanvas._ctx; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - ctx = null; - } - if (c.showCursorLegend) { - var cells = $(plot.targetId + ' td.jqplot-cursor-legend-label'); - for (var i=0; i<cells.length; i++) { - var idx = $(cells[i]).data('seriesIndex'); - var series = plot.series[idx]; - var label = series.label.toString(); - if (plot.legend.escapeHtml) { - $(cells[i]).text($.jqplot.sprintf(c.cursorLegendFormatString, label, undefined, undefined)); - } - else { - $(cells[i]).html($.jqplot.sprintf(c.cursorLegendFormatString, label, undefined, undefined)); - } - - } - } - } - } - - function handleMouseEnter(ev, gridpos, datapos, neighbor, plot) { - var c = plot.plugins.cursor; - c.onGrid = true; - if (c.show) { - c.previousCursor = ev.target.style.cursor; - ev.target.style.cursor = c.style; - if (c.showTooltip) { - updateTooltip(gridpos, datapos, plot); - if (c.followMouse) { - moveTooltip(gridpos, plot); - } - else { - positionTooltip(plot); - } - c._tooltipElem.show(); - } - if (c.showVerticalLine || c.showHorizontalLine) { - moveLine(gridpos, plot); - } - } - - } - - function handleMouseMove(ev, gridpos, datapos, neighbor, plot) { - var c = plot.plugins.cursor; - if (c.show) { - if (c.showTooltip) { - updateTooltip(gridpos, datapos, plot); - if (c.followMouse) { - moveTooltip(gridpos, plot); - } - } - if (c.showVerticalLine || c.showHorizontalLine) { - moveLine(gridpos, plot); - } - } - } - - function getEventPosition(ev) { - var plot = ev.data.plot; - var go = plot.eventCanvas._elem.offset(); - var gridPos = {x:ev.pageX - go.left, y:ev.pageY - go.top}; - var dataPos = {xaxis:null, yaxis:null, x2axis:null, y2axis:null, y3axis:null, y4axis:null, y5axis:null, y6axis:null, y7axis:null, y8axis:null, y9axis:null}; - var an = ['xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis']; - var ax = plot.axes; - var n, axis; - for (n=11; n>0; n--) { - axis = an[n-1]; - if (ax[axis].show) { - dataPos[axis] = ax[axis].series_p2u(gridPos[axis.charAt(0)]); - } - } - - return {offsets:go, gridPos:gridPos, dataPos:dataPos}; - } - - function handleZoomMove(ev) { - var plot = ev.data.plot; - var c = plot.plugins.cursor; - // don't do anything if not on grid. - if (c.show && c.zoom && c._zoom.started && !c.zoomTarget) { - var ctx = c.zoomCanvas._ctx; - var positions = getEventPosition(ev); - var gridpos = positions.gridPos; - var datapos = positions.dataPos; - c._zoom.gridpos = gridpos; - c._zoom.datapos = datapos; - c._zoom.zooming = true; - var xpos = gridpos.x; - var ypos = gridpos.y; - var height = ctx.canvas.height; - var width = ctx.canvas.width; - if (c.showTooltip && !c.onGrid && c.showTooltipOutsideZoom) { - updateTooltip(gridpos, datapos, plot); - if (c.followMouse) { - moveTooltip(gridpos, plot); - } - } - if (c.constrainZoomTo == 'x') { - c._zoom.end = [xpos, height]; - } - else if (c.constrainZoomTo == 'y') { - c._zoom.end = [width, ypos]; - } - else { - c._zoom.end = [xpos, ypos]; - } - var sel = window.getSelection; - if (document.selection && document.selection.empty) - { - document.selection.empty(); - } - else if (sel && !sel().isCollapsed) { - sel().collapse(); - } - drawZoomBox.call(c); - ctx = null; - } - } - - function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { - var c = plot.plugins.cursor; - $(document).one('mouseup.jqplot_cursor', {plot:plot}, handleMouseUp); - var axes = plot.axes; - if (document.onselectstart != undefined) { - c._oldHandlers.onselectstart = document.onselectstart; - document.onselectstart = function () { return false; }; - } - if (document.ondrag != undefined) { - c._oldHandlers.ondrag = document.ondrag; - document.ondrag = function () { return false; }; - } - if (document.onmousedown != undefined) { - c._oldHandlers.onmousedown = document.onmousedown; - document.onmousedown = function () { return false; }; - } - if (c.zoom) { - if (!c.zoomProxy) { - var ctx = c.zoomCanvas._ctx; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - ctx = null; - } - if (c.constrainZoomTo == 'x') { - c._zoom.start = [gridpos.x, 0]; - } - else if (c.constrainZoomTo == 'y') { - c._zoom.start = [0, gridpos.y]; - } - else { - c._zoom.start = [gridpos.x, gridpos.y]; - } - c._zoom.started = true; - for (var ax in datapos) { - // get zoom starting position. - c._zoom.axes.start[ax] = datapos[ax]; - } - $(document).bind('mousemove.jqplotCursor', {plot:plot}, handleZoomMove); - } - } - - function handleMouseUp(ev) { - var plot = ev.data.plot; - var c = plot.plugins.cursor; - if (c.zoom && c._zoom.zooming && !c.zoomTarget) { - var xpos = c._zoom.gridpos.x; - var ypos = c._zoom.gridpos.y; - var datapos = c._zoom.datapos; - var height = c.zoomCanvas._ctx.canvas.height; - var width = c.zoomCanvas._ctx.canvas.width; - var axes = plot.axes; - - if (c.constrainOutsideZoom && !c.onGrid) { - if (xpos < 0) { xpos = 0; } - else if (xpos > width) { xpos = width; } - if (ypos < 0) { ypos = 0; } - else if (ypos > height) { ypos = height; } - - for (var axis in datapos) { - if (datapos[axis]) { - if (axis.charAt(0) == 'x') { - datapos[axis] = axes[axis].series_p2u(xpos); - } - else { - datapos[axis] = axes[axis].series_p2u(ypos); - } - } - } - } - - if (c.constrainZoomTo == 'x') { - ypos = height; - } - else if (c.constrainZoomTo == 'y') { - xpos = width; - } - c._zoom.end = [xpos, ypos]; - c._zoom.gridpos = {x:xpos, y:ypos}; - - c.doZoom(c._zoom.gridpos, datapos, plot, c); - } - c._zoom.started = false; - c._zoom.zooming = false; - - $(document).unbind('mousemove.jqplotCursor', handleZoomMove); - - if (document.onselectstart != undefined && c._oldHandlers.onselectstart != null){ - document.onselectstart = c._oldHandlers.onselectstart; - c._oldHandlers.onselectstart = null; - } - if (document.ondrag != undefined && c._oldHandlers.ondrag != null){ - document.ondrag = c._oldHandlers.ondrag; - c._oldHandlers.ondrag = null; - } - if (document.onmousedown != undefined && c._oldHandlers.onmousedown != null){ - document.onmousedown = c._oldHandlers.onmousedown; - c._oldHandlers.onmousedown = null; - } - - } - - function drawZoomBox() { - var start = this._zoom.start; - var end = this._zoom.end; - var ctx = this.zoomCanvas._ctx; - var l, t, h, w; - if (end[0] > start[0]) { - l = start[0]; - w = end[0] - start[0]; - } - else { - l = end[0]; - w = start[0] - end[0]; - } - if (end[1] > start[1]) { - t = start[1]; - h = end[1] - start[1]; - } - else { - t = end[1]; - h = start[1] - end[1]; - } - ctx.fillStyle = 'rgba(0,0,0,0.2)'; - ctx.strokeStyle = '#999999'; - ctx.lineWidth = 1.0; - ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height); - ctx.fillRect(0,0,ctx.canvas.width, ctx.canvas.height); - ctx.clearRect(l, t, w, h); - // IE won't show transparent fill rect, so stroke a rect also. - ctx.strokeRect(l,t,w,h); - ctx = null; - } - - $.jqplot.CursorLegendRenderer = function(options) { - $.jqplot.TableLegendRenderer.call(this, options); - this.formatString = '%s'; - }; - - $.jqplot.CursorLegendRenderer.prototype = new $.jqplot.TableLegendRenderer(); - $.jqplot.CursorLegendRenderer.prototype.constructor = $.jqplot.CursorLegendRenderer; - - // called in context of a Legend - $.jqplot.CursorLegendRenderer.prototype.draw = function() { - if (this._elem) { - this._elem.emptyForce(); - this._elem = null; - } - if (this.show) { - var series = this._series, s; - // make a table. one line label per row. - var elem = document.createElement('div'); - this._elem = $(elem); - elem = null; - this._elem.addClass('jqplot-legend jqplot-cursor-legend'); - this._elem.css('position', 'absolute'); - - var pad = false; - for (var i = 0; i< series.length; i++) { - s = series[i]; - if (s.show && s.showLabel) { - var lt = $.jqplot.sprintf(this.formatString, s.label.toString()); - if (lt) { - var color = s.color; - if (s._stack && !s.fill) { - color = ''; - } - addrow.call(this, lt, color, pad, i); - pad = true; - } - // let plugins add more rows to legend. Used by trend line plugin. - for (var j=0; j<$.jqplot.addLegendRowHooks.length; j++) { - var item = $.jqplot.addLegendRowHooks[j].call(this, s); - if (item) { - addrow.call(this, item.label, item.color, pad); - pad = true; - } - } - } - } - series = s = null; - delete series; - delete s; - } - - function addrow(label, color, pad, idx) { - var rs = (pad) ? this.rowSpacing : '0'; - var tr = $('<tr class="jqplot-legend jqplot-cursor-legend"></tr>').appendTo(this._elem); - tr.data('seriesIndex', idx); - $('<td class="jqplot-legend jqplot-cursor-legend-swatch" style="padding-top:'+rs+';">'+ - '<div style="border:1px solid #cccccc;padding:0.2em;">'+ - '<div class="jqplot-cursor-legend-swatch" style="background-color:'+color+';"></div>'+ - '</div></td>').appendTo(tr); - var td = $('<td class="jqplot-legend jqplot-cursor-legend-label" style="vertical-align:middle;padding-top:'+rs+';"></td>'); - td.appendTo(tr); - td.data('seriesIndex', idx); - if (this.escapeHtml) { - td.text(label); - } - else { - td.html(label); - } - tr = null; - td = null; - } - return this._elem; - }; - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.dateAxisRenderer.js b/libs/jqplot/plugins/jqplot.dateAxisRenderer.js deleted file mode 100644 index 0973e2b3fe..0000000000 --- a/libs/jqplot/plugins/jqplot.dateAxisRenderer.js +++ /dev/null @@ -1,439 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.DateAxisRenderer - * A plugin for a jqPlot to render an axis as a series of date values. - * This renderer has no options beyond those supplied by the <Axis> class. - * It supplies it's own tick formatter, so the tickOptions.formatter option - * should not be overridden. - * - * Thanks to Ken Synder for his enhanced Date instance methods which are - * included with this code <http://kendsnyder.com/sandbox/date/>. - * - * To use this renderer, include the plugin in your source - * > <script type="text/javascript" language="javascript" src="plugins/jqplot.dateAxisRenderer.js"></script> - * - * and supply the appropriate options to your plot - * - * > {axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}} - * - * Dates can be passed into the axis in almost any recognizable value and - * will be parsed. They will be rendered on the axis in the format - * specified by tickOptions.formatString. e.g. tickOptions.formatString = '%Y-%m-%d'. - * - * Accecptable format codes - * are: - * - * > Code Result Description - * > == Years == - * > %Y 2008 Four-digit year - * > %y 08 Two-digit year - * > == Months == - * > %m 09 Two-digit month - * > %#m 9 One or two-digit month - * > %B September Full month name - * > %b Sep Abbreviated month name - * > == Days == - * > %d 05 Two-digit day of month - * > %#d 5 One or two-digit day of month - * > %e 5 One or two-digit day of month - * > %A Sunday Full name of the day of the week - * > %a Sun Abbreviated name of the day of the week - * > %w 0 Number of the day of the week (0 = Sunday, 6 = Saturday) - * > %o th The ordinal suffix string following the day of the month - * > == Hours == - * > %H 23 Hours in 24-hour format (two digits) - * > %#H 3 Hours in 24-hour integer format (one or two digits) - * > %I 11 Hours in 12-hour format (two digits) - * > %#I 3 Hours in 12-hour integer format (one or two digits) - * > %p PM AM or PM - * > == Minutes == - * > %M 09 Minutes (two digits) - * > %#M 9 Minutes (one or two digits) - * > == Seconds == - * > %S 02 Seconds (two digits) - * > %#S 2 Seconds (one or two digits) - * > %s 1206567625723 Unix timestamp (Seconds past 1970-01-01 00:00:00) - * > == Milliseconds == - * > %N 008 Milliseconds (three digits) - * > %#N 8 Milliseconds (one to three digits) - * > == Timezone == - * > %O 360 difference in minutes between local time and GMT - * > %Z Mountain Standard Time Name of timezone as reported by browser - * > %G -06:00 Hours and minutes between GMT - * > == Shortcuts == - * > %F 2008-03-26 %Y-%m-%d - * > %T 05:06:30 %H:%M:%S - * > %X 05:06:30 %H:%M:%S - * > %x 03/26/08 %m/%d/%y - * > %D 03/26/08 %m/%d/%y - * > %#c Wed Mar 26 15:31:00 2008 %a %b %e %H:%M:%S %Y - * > %v 3-Sep-2008 %e-%b-%Y - * > %R 15:31 %H:%M - * > %r 3:31:00 PM %I:%M:%S %p - * > == Characters == - * > %n \n Newline - * > %t \t Tab - * > %% % Percent Symbol - */ - $.jqplot.DateAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - this.date = new $.jsDate(); - }; - - $.jqplot.DateAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.DateAxisRenderer.prototype.constructor = $.jqplot.DateAxisRenderer; - - $.jqplot.DateTickFormatter = function(format, val) { - if (!format) { - format = '%Y/%m/%d'; - } - return $.jsDate.strftime(val, format); - }; - - $.jqplot.DateAxisRenderer.prototype.init = function(options){ - // prop: tickRenderer - // A class of a rendering engine for creating the ticks labels displayed on the plot, - // See <$.jqplot.AxisTickRenderer>. - // this.tickRenderer = $.jqplot.AxisTickRenderer; - // this.labelRenderer = $.jqplot.AxisLabelRenderer; - this.tickOptions.formatter = $.jqplot.DateTickFormatter; - this.daTickInterval = null; - this._daTickInterval = null; - - $.extend(true, this, options); - - var db = this._dataBounds, - stats, - sum, - s, - d, - pd, - sd, - intv; - - // Go through all the series attached to this axis and find - // the min/max bounds for this axis. - for (var i=0; i<this._series.length; i++) { - stats = {intervals:[], frequencies:{}, sortedIntervals:[], min:null, max:null, mean:null}; - sum = 0; - s = this._series[i]; - d = s.data; - pd = s._plotData; - sd = s._stackData; - intv = 0; - - for (var j=0; j<d.length; j++) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - d[j][0] = new $.jsDate(d[j][0]).getTime(); - pd[j][0] = new $.jsDate(d[j][0]).getTime(); - sd[j][0] = new $.jsDate(d[j][0]).getTime(); - if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) { - db.min = d[j][0]; - } - if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) { - db.max = d[j][0]; - } - if (j>0) { - intv = Math.abs(d[j][0] - d[j-1][0]); - stats.intervals.push(intv); - if (stats.frequencies.hasOwnProperty(intv)) { - stats.frequencies[intv] += 1; - } - else { - stats.frequencies[intv] = 1; - } - } - sum += intv; - - } - else { - d[j][1] = new $.jsDate(d[j][1]).getTime(); - pd[j][1] = new $.jsDate(d[j][1]).getTime(); - sd[j][1] = new $.jsDate(d[j][1]).getTime(); - if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) { - db.min = d[j][1]; - } - if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) { - db.max = d[j][1]; - } - if (j>0) { - intv = Math.abs(d[j][1] - d[j-1][1]); - stats.intervals.push(intv); - if (stats.frequencies.hasOwnProperty(intv)) { - stats.frequencies[intv] += 1; - } - else { - stats.frequencies[intv] = 1; - } - } - } - sum += intv; - } - - var tempf = 0, - tempn=0; - for (var n in stats.frequencies) { - stats.sortedIntervals.push({interval:n, frequency:stats.frequencies[n]}); - } - stats.sortedIntervals.sort(function(a, b){ - return b.frequency - a.frequency; - }); - - stats.min = $.jqplot.arrayMin(stats.intervals); - stats.max = $.jqplot.arrayMax(stats.intervals); - stats.mean = sum/d.length; - this._intervalStats.push(stats); - stats = sum = s = d = pd = sd = null; - } - db = null; - - }; - - // called with scope of an axis - $.jqplot.DateAxisRenderer.prototype.reset = function() { - this.min = this._min; - this.max = this._max; - this.tickInterval = this._tickInterval; - this.numberTicks = this._numberTicks; - this.daTickInterval = this._daTickInterval; - // this._ticks = this.__ticks; - }; - - $.jqplot.DateAxisRenderer.prototype.createTicks = function() { - // we're are operating on an axis here - var ticks = this._ticks; - var userTicks = this.ticks; - var name = this.name; - // databounds were set on axis initialization. - var db = this._dataBounds; - var iv = this._intervalStats; - var dim, interval; - var min, max; - var pos1, pos2; - var tt, i; - - // if we already have ticks, use them. - // ticks must be in order of increasing value. - - min = ((this.min != null) ? new $.jsDate(this.min).getTime() : db.min); - max = ((this.max != null) ? new $.jsDate(this.max).getTime() : db.max); - - var range = max - min; - - if (userTicks.length) { - // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed - for (i=0; i<userTicks.length; i++){ - var ut = userTicks[i]; - var t = new this.tickRenderer(this.tickOptions); - if (ut.constructor == Array) { - t.value = new $.jsDate(ut[0]).getTime(); - t.label = ut[1]; - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(t.value, this.name); - this._ticks.push(t); - } - - else { - t.value = new $.jsDate(ut).getTime(); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(t.value, this.name); - this._ticks.push(t); - } - } - this.numberTicks = userTicks.length; - this.min = this._ticks[0].value; - this.max = this._ticks[this.numberTicks-1].value; - this.daTickInterval = [(this.max - this.min) / (this.numberTicks - 1)/1000, 'seconds']; - } - - //////// - // We don't have any ticks yet, let's make some! - // Doing complete autoscaling, no user options specified - //////// - - else if (this.tickInterval == null && this.min == null && this.max == null && this.numberTicks == null) { - var ret = $.jqplot.LinearTickGenerator(min, max); - // calculate a padded max and min, points should be less than these - // so that they aren't too close to the edges of the plot. - // User can adjust how much padding is allowed with pad, padMin and PadMax options. - var tumin = min + range*(this.padMin - 1); - var tumax = max - range*(this.padMax - 1); - - if (min <=tumin || max >= tumax) { - tumin = min - range*(this.padMin - 1); - tumax = max + range*(this.padMax - 1); - ret = $.jqplot.LinearTickGenerator(tumin, tumax); - } - - this.min = ret[0]; - this.max = ret[1]; - this.numberTicks = ret[2]; - this.tickInterval = ret[4]; - this.daTickInterval = [this.tickInterval/1000, 'seconds']; - - for (var i=0; i<this.numberTicks; i++){ - var min = new $.jsDate(this.min); - tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime(); - var t = new this.tickRenderer(this.tickOptions); - // var t = new $.jqplot.AxisTickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(tt, this.name); - this._ticks.push(t); - } - } - - //////// - // Some option(s) specified, work around that. - //////// - - else { - if (name == 'xaxis' || name == 'x2axis') { - dim = this._plotDimensions.width; - } - else { - dim = this._plotDimensions.height; - } - - // if min, max and number of ticks specified, user can't specify interval. - if (this.min != null && this.max != null && this.numberTicks != null) { - this.tickInterval = null; - } - - // if user specified a tick interval, convert to usable. - if (this.tickInterval != null) - { - // if interval is a number or can be converted to one, use it. - // Assume it is in SECONDS!!! - if (Number(this.tickInterval)) { - this.daTickInterval = [Number(this.tickInterval), 'seconds']; - } - // else, parse out something we can build from. - else if (typeof this.tickInterval == "string") { - var parts = this.tickInterval.split(' '); - if (parts.length == 1) { - this.daTickInterval = [1, parts[0]]; - } - else if (parts.length == 2) { - this.daTickInterval = [parts[0], parts[1]]; - } - } - } - - // if min and max are same, space them out a bit - if (min == max) { - var adj = 24*60*60*500; // 1/2 day - min -= adj; - max += adj; - } - - range = max - min; - - var optNumTicks = 2 + parseInt(Math.max(0, dim-100)/100, 10); - - - // Here try to set ticks based on data spacing. - // if (this.min == null && this.max == null && this.numberTicks == null && this.tickInterval == null) { - // // - // } - - - var rmin, rmax; - - rmin = (this.min != null) ? new $.jsDate(this.min).getTime() : min - range/2*(this.padMin - 1); - rmax = (this.max != null) ? new $.jsDate(this.max).getTime() : max + range/2*(this.padMax - 1); - this.min = rmin; - this.max = rmax; - range = this.max - this.min; - - if (this.numberTicks == null){ - // if tickInterval is specified by user, we will ignore computed maximum. - // max will be equal or greater to fit even # of ticks. - if (this.daTickInterval != null) { - var nc = new $.jsDate(this.max).diff(this.min, this.daTickInterval[1], true); - this.numberTicks = Math.ceil(nc/this.daTickInterval[0]) +1; - // this.max = new $.jsDate(this.min).add(this.numberTicks-1, this.daTickInterval[1]).getTime(); - this.max = new $.jsDate(this.min).add((this.numberTicks-1) * this.daTickInterval[0], this.daTickInterval[1]).getTime(); - } - else if (dim > 200) { - this.numberTicks = parseInt(3+(dim-200)/100, 10); - } - else { - this.numberTicks = 2; - } - } - - if (this.daTickInterval == null) { - this.daTickInterval = [range / (this.numberTicks-1)/1000, 'seconds']; - } - for (var i=0; i<this.numberTicks; i++){ - var min = new $.jsDate(this.min); - tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime(); - var t = new this.tickRenderer(this.tickOptions); - // var t = new $.jqplot.AxisTickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(tt, this.name); - this._ticks.push(t); - } - } - - - if (this._daTickInterval == null) { - this._daTickInterval = this.daTickInterval; - } - }; - -})(jQuery); - diff --git a/libs/jqplot/plugins/jqplot.donutRenderer.js b/libs/jqplot/plugins/jqplot.donutRenderer.js deleted file mode 100755 index 5e156ad6a3..0000000000 --- a/libs/jqplot/plugins/jqplot.donutRenderer.js +++ /dev/null @@ -1,910 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.DonutRenderer - * Plugin renderer to draw a donut chart. - * x values, if present, will be used as slice labels. - * y values give slice size. - * - * To use this renderer, you need to include the - * donut renderer plugin, for example: - * - * > <script type="text/javascript" src="plugins/jqplot.donutRenderer.js"></script> - * - * Properties described here are passed into the $.jqplot function - * as options on the series renderer. For example: - * - * > plot2 = $.jqplot('chart2', [s1, s2], { - * > seriesDefaults: { - * > renderer:$.jqplot.DonutRenderer, - * > rendererOptions:{ - * > sliceMargin: 2, - * > innerDiameter: 110, - * > startAngle: -90 - * > } - * > } - * > }); - * - * A donut plot will trigger events on the plot target - * according to user interaction. All events return the event object, - * the series index, the point (slice) index, and the point data for - * the appropriate slice. - * - * 'jqplotDataMouseOver' - triggered when user mouseing over a slice. - * 'jqplotDataHighlight' - triggered the first time user mouses over a slice, - * if highlighting is enabled. - * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of - * a highlighted slice. - * 'jqplotDataClick' - triggered when the user clicks on a slice. - * 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if - * the "captureRightClick" option is set to true on the plot. - */ - $.jqplot.DonutRenderer = function(){ - $.jqplot.LineRenderer.call(this); - }; - - $.jqplot.DonutRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.DonutRenderer.prototype.constructor = $.jqplot.DonutRenderer; - - // called with scope of a series - $.jqplot.DonutRenderer.prototype.init = function(options, plot) { - // Group: Properties - // - // prop: diameter - // Outer diameter of the donut, auto computed by default - this.diameter = null; - // prop: innerDiameter - // Inner diameter of the donut, auto calculated by default. - // If specified will override thickness value. - this.innerDiameter = null; - // prop: thickness - // thickness of the donut, auto computed by default - // Overridden by if innerDiameter is specified. - this.thickness = null; - // prop: padding - // padding between the donut and plot edges, legend, etc. - this.padding = 20; - // prop: sliceMargin - // angular spacing between donut slices in degrees. - this.sliceMargin = 0; - // prop: ringMargin - // pixel distance between rings, or multiple series in a donut plot. - // null will compute ringMargin based on sliceMargin. - this.ringMargin = null; - // prop: fill - // true or false, wether to fil the slices. - this.fill = true; - // prop: shadowOffset - // offset of the shadow from the slice and offset of - // each succesive stroke of the shadow from the last. - this.shadowOffset = 2; - // prop: shadowAlpha - // transparency of the shadow (0 = transparent, 1 = opaque) - this.shadowAlpha = 0.07; - // prop: shadowDepth - // number of strokes to apply to the shadow, - // each stroke offset shadowOffset from the last. - this.shadowDepth = 5; - // prop: highlightMouseOver - // True to highlight slice when moused over. - // This must be false to enable highlightMouseDown to highlight when clicking on a slice. - this.highlightMouseOver = true; - // prop: highlightMouseDown - // True to highlight when a mouse button is pressed over a slice. - // This will be disabled if highlightMouseOver is true. - this.highlightMouseDown = false; - // prop: highlightColors - // an array of colors to use when highlighting a slice. - this.highlightColors = []; - // prop: dataLabels - // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices. - // Defaults to percentage of each pie slice. - this.dataLabels = 'percent'; - // prop: showDataLabels - // true to show data labels on slices. - this.showDataLabels = false; - // prop: dataLabelFormatString - // Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage. - this.dataLabelFormatString = null; - // prop: dataLabelThreshold - // Threshhold in percentage (0 - 100) of pie area, below which no label will be displayed. - // This applies to all label types, not just to percentage labels. - this.dataLabelThreshold = 3; - // prop: dataLabelPositionFactor - // A Multiplier (0-1) of the pie radius which controls position of label on slice. - // Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie. - this.dataLabelPositionFactor = 0.4; - // prop: dataLabelNudge - // Number of pixels to slide the label away from (+) or toward (-) the center of the pie. - this.dataLabelNudge = 0; - // prop: startAngle - // Angle to start drawing donut in degrees. - // According to orientation of canvas coordinate system: - // 0 = on the positive x axis - // -90 = on the positive y axis. - // 90 = on the negaive y axis. - // 180 or - 180 = on the negative x axis. - this.startAngle = 0; - this.tickRenderer = $.jqplot.DonutTickRenderer; - // Used as check for conditions where donut shouldn't be drawn. - this._drawData = true; - this._type = 'donut'; - - // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver - if (options.highlightMouseDown && options.highlightMouseOver == null) { - options.highlightMouseOver = false; - } - - $.extend(true, this, options); - if (this.diameter != null) { - this.diameter = this.diameter - this.sliceMargin; - } - this._diameter = null; - this._innerDiameter = null; - this._radius = null; - this._innerRadius = null; - this._thickness = null; - // references to the previous series in the plot to properly calculate diameters - // and thicknesses of nested rings. - this._previousSeries = []; - this._numberSeries = 1; - // array of [start,end] angles arrays, one for each slice. In radians. - this._sliceAngles = []; - // index of the currenty highlighted point, if any - this._highlightedPoint = null; - - // set highlight colors if none provided - if (this.highlightColors.length == 0) { - for (var i=0; i<this.seriesColors.length; i++){ - var rgba = $.jqplot.getColorComponents(this.seriesColors[i]); - var newrgb = [rgba[0], rgba[1], rgba[2]]; - var sum = newrgb[0] + newrgb[1] + newrgb[2]; - for (var j=0; j<3; j++) { - // when darkening, lowest color component can be is 60. - newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); - newrgb[j] = parseInt(newrgb[j], 10); - } - this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')'); - } - } - - plot.postParseOptionsHooks.addOnce(postParseOptions); - plot.postInitHooks.addOnce(postInit); - plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove); - plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown); - plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp); - plot.eventListenerHooks.addOnce('jqplotClick', handleClick); - plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); - plot.postDrawHooks.addOnce(postPlotDraw); - - - }; - - $.jqplot.DonutRenderer.prototype.setGridData = function(plot) { - // set gridData property. This will hold angle in radians of each data point. - var stack = []; - var td = []; - var sa = this.startAngle/180*Math.PI; - var tot = 0; - // don't know if we have any valid data yet, so set plot to not draw. - this._drawData = false; - for (var i=0; i<this.data.length; i++){ - if (this.data[i][1] != 0) { - // we have data, O.K. to draw. - this._drawData = true; - } - stack.push(this.data[i][1]); - td.push([this.data[i][0]]); - if (i>0) { - stack[i] += stack[i-1]; - } - tot += this.data[i][1]; - } - var fact = Math.PI*2/stack[stack.length - 1]; - - for (var i=0; i<stack.length; i++) { - td[i][1] = stack[i] * fact; - td[i][2] = this.data[i][1]/tot; - } - this.gridData = td; - }; - - $.jqplot.DonutRenderer.prototype.makeGridData = function(data, plot) { - var stack = []; - var td = []; - var tot = 0; - var sa = this.startAngle/180*Math.PI; - // don't know if we have any valid data yet, so set plot to not draw. - this._drawData = false; - for (var i=0; i<data.length; i++){ - if (this.data[i][1] != 0) { - // we have data, O.K. to draw. - this._drawData = true; - } - stack.push(data[i][1]); - td.push([data[i][0]]); - if (i>0) { - stack[i] += stack[i-1]; - } - tot += data[i][1]; - } - var fact = Math.PI*2/stack[stack.length - 1]; - - for (var i=0; i<stack.length; i++) { - td[i][1] = stack[i] * fact; - td[i][2] = data[i][1]/tot; - } - return td; - }; - - $.jqplot.DonutRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) { - var r = this._diameter / 2; - var ri = r - this._thickness; - var fill = this.fill; - // var lineWidth = this.lineWidth; - ctx.save(); - ctx.translate(this._center[0], this._center[1]); - // ctx.translate(this.sliceMargin*Math.cos((ang1+ang2)/2), this.sliceMargin*Math.sin((ang1+ang2)/2)); - - if (isShadow) { - for (var i=0; i<this.shadowDepth; i++) { - ctx.save(); - ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI)); - doDraw(); - } - } - - else { - doDraw(); - } - - function doDraw () { - // Fix for IE and Chrome that can't seem to draw circles correctly. - // ang2 should always be <= 2 pi since that is the way the data is converted. - if (ang2 > 6.282 + this.startAngle) { - ang2 = 6.282 + this.startAngle; - if (ang1 > ang2) { - ang1 = 6.281 + this.startAngle; - } - } - // Fix for IE, where it can't seem to handle 0 degree angles. Also avoids - // ugly line on unfilled donuts. - if (ang1 >= ang2) { - return; - } - ctx.beginPath(); - ctx.fillStyle = color; - ctx.strokeStyle = color; - // ctx.lineWidth = lineWidth; - ctx.arc(0, 0, r, ang1, ang2, false); - ctx.lineTo(ri*Math.cos(ang2), ri*Math.sin(ang2)); - ctx.arc(0,0, ri, ang2, ang1, true); - ctx.closePath(); - if (fill) { - ctx.fill(); - } - else { - ctx.stroke(); - } - } - - if (isShadow) { - for (var i=0; i<this.shadowDepth; i++) { - ctx.restore(); - } - } - - ctx.restore(); - }; - - // called with scope of series - $.jqplot.DonutRenderer.prototype.draw = function (ctx, gd, options, plot) { - var i; - var opts = (options != undefined) ? options : {}; - // offset and direction of offset due to legend placement - var offx = 0; - var offy = 0; - var trans = 1; - // var colorGenerator = new this.colorGenerator(this.seriesColors); - if (options.legendInfo && options.legendInfo.placement == 'insideGrid') { - var li = options.legendInfo; - switch (li.location) { - case 'nw': - offx = li.width + li.xoffset; - break; - case 'w': - offx = li.width + li.xoffset; - break; - case 'sw': - offx = li.width + li.xoffset; - break; - case 'ne': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'e': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'se': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'n': - offy = li.height + li.yoffset; - break; - case 's': - offy = li.height + li.yoffset; - trans = -1; - break; - default: - break; - } - } - - var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; - var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; - var fill = (opts.fill != undefined) ? opts.fill : this.fill; - var cw = ctx.canvas.width; - var ch = ctx.canvas.height; - var w = cw - offx - 2 * this.padding; - var h = ch - offy - 2 * this.padding; - var mindim = Math.min(w,h); - var d = mindim; - var ringmargin = (this.ringMargin == null) ? this.sliceMargin * 2.0 : this.ringMargin; - - for (var i=0; i<this._previousSeries.length; i++) { - d -= 2.0 * this._previousSeries[i]._thickness + 2.0 * ringmargin; - } - this._diameter = this.diameter || d; - if (this.innerDiameter != null) { - var od = (this._numberSeries > 1 && this.index > 0) ? this._previousSeries[0]._diameter : this._diameter; - this._thickness = this.thickness || (od - this.innerDiameter - 2.0*ringmargin*this._numberSeries) / this._numberSeries/2.0; - } - else { - this._thickness = this.thickness || mindim / 2 / (this._numberSeries + 1) * 0.85; - } - - var r = this._radius = this._diameter/2; - this._innerRadius = this._radius - this._thickness; - var sa = this.startAngle / 180 * Math.PI; - this._center = [(cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy]; - - if (this.shadow) { - var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')'; - for (var i=0; i<gd.length; i++) { - var ang1 = (i == 0) ? sa : gd[i-1][1] + sa; - // Adjust ang1 and ang2 for sliceMargin - ang1 += this.sliceMargin/180*Math.PI; - this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1]+sa, shadowColor, true); - } - - } - for (var i=0; i<gd.length; i++) { - var ang1 = (i == 0) ? sa : gd[i-1][1] + sa; - // Adjust ang1 and ang2 for sliceMargin - ang1 += this.sliceMargin/180*Math.PI; - var ang2 = gd[i][1] + sa; - this._sliceAngles.push([ang1, ang2]); - this.renderer.drawSlice.call (this, ctx, ang1, ang2, this.seriesColors[i], false); - - if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) { - var fstr, avgang = (ang1+ang2)/2, label; - - if (this.dataLabels == 'label') { - fstr = this.dataLabelFormatString || '%s'; - label = $.jqplot.sprintf(fstr, gd[i][0]); - } - else if (this.dataLabels == 'value') { - fstr = this.dataLabelFormatString || '%d'; - label = $.jqplot.sprintf(fstr, this.data[i][1]); - } - else if (this.dataLabels == 'percent') { - fstr = this.dataLabelFormatString || '%d%%'; - label = $.jqplot.sprintf(fstr, gd[i][2]*100); - } - else if (this.dataLabels.constructor == Array) { - fstr = this.dataLabelFormatString || '%s'; - label = $.jqplot.sprintf(fstr, this.dataLabels[i]); - } - - var fact = this._innerRadius + this._thickness * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge; - - var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left; - var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top; - - var labelelem = $('<span class="jqplot-donut-series jqplot-data-label" style="position:absolute;">' + label + '</span>').insertBefore(plot.eventCanvas._elem); - x -= labelelem.width()/2; - y -= labelelem.height()/2; - x = Math.round(x); - y = Math.round(y); - labelelem.css({left: x, top: y}); - } - } - - }; - - $.jqplot.DonutAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - }; - - $.jqplot.DonutAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.DonutAxisRenderer.prototype.constructor = $.jqplot.DonutAxisRenderer; - - - // There are no traditional axes on a donut chart. We just need to provide - // dummy objects with properties so the plot will render. - // called with scope of axis object. - $.jqplot.DonutAxisRenderer.prototype.init = function(options){ - // - this.tickRenderer = $.jqplot.DonutTickRenderer; - $.extend(true, this, options); - // I don't think I'm going to need _dataBounds here. - // have to go Axis scaling in a way to fit chart onto plot area - // and provide u2p and p2u functionality for mouse cursor, etc. - // for convienence set _dataBounds to 0 and 100 and - // set min/max to 0 and 100. - this._dataBounds = {min:0, max:100}; - this.min = 0; - this.max = 100; - this.showTicks = false; - this.ticks = []; - this.showMark = false; - this.show = false; - }; - - - - - $.jqplot.DonutLegendRenderer = function(){ - $.jqplot.TableLegendRenderer.call(this); - }; - - $.jqplot.DonutLegendRenderer.prototype = new $.jqplot.TableLegendRenderer(); - $.jqplot.DonutLegendRenderer.prototype.constructor = $.jqplot.DonutLegendRenderer; - - /** - * Class: $.jqplot.DonutLegendRenderer - * Legend Renderer specific to donut plots. Set by default - * when user creates a donut plot. - */ - $.jqplot.DonutLegendRenderer.prototype.init = function(options) { - // Group: Properties - // - // prop: numberRows - // Maximum number of rows in the legend. 0 or null for unlimited. - this.numberRows = null; - // prop: numberColumns - // Maximum number of columns in the legend. 0 or null for unlimited. - this.numberColumns = null; - $.extend(true, this, options); - }; - - // called with context of legend - $.jqplot.DonutLegendRenderer.prototype.draw = function() { - var legend = this; - if (this.show) { - var series = this._series; - var ss = 'position:absolute;'; - ss += (this.background) ? 'background:'+this.background+';' : ''; - ss += (this.border) ? 'border:'+this.border+';' : ''; - ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : ''; - ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : ''; - ss += (this.textColor) ? 'color:'+this.textColor+';' : ''; - ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : ''; - ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : ''; - ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : ''; - ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : ''; - this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>'); - // Donut charts legends don't go by number of series, but by number of data points - // in the series. Refactor things here for that. - - var pad = false, - reverse = false, - nr, nc; - var s = series[0]; - var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors); - - if (s.show) { - var pd = s.data; - if (this.numberRows) { - nr = this.numberRows; - if (!this.numberColumns){ - nc = Math.ceil(pd.length/nr); - } - else{ - nc = this.numberColumns; - } - } - else if (this.numberColumns) { - nc = this.numberColumns; - nr = Math.ceil(pd.length/this.numberColumns); - } - else { - nr = pd.length; - nc = 1; - } - - var i, j, tr, td1, td2, lt, rs, color; - var idx = 0; - - for (i=0; i<nr; i++) { - if (reverse){ - tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem); - } - else{ - tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem); - } - for (j=0; j<nc; j++) { - if (idx < pd.length){ - lt = this.labels[idx] || pd[idx][0].toString(); - color = colorGenerator.next(); - if (!reverse){ - if (i>0){ - pad = true; - } - else{ - pad = false; - } - } - else{ - if (i == nr -1){ - pad = false; - } - else{ - pad = true; - } - } - rs = (pad) ? this.rowSpacing : '0'; - - td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+ - '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+ - '</div></td>'); - td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>'); - if (this.escapeHtml){ - td2.text(lt); - } - else { - td2.html(lt); - } - if (reverse) { - td2.prependTo(tr); - td1.prependTo(tr); - } - else { - td1.appendTo(tr); - td2.appendTo(tr); - } - pad = true; - } - idx++; - } - } - } - } - return this._elem; - }; - - // $.jqplot.DonutLegendRenderer.prototype.pack = function(offsets) { - // if (this.show) { - // // fake a grid for positioning - // var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom}; - // if (this.placement == 'insideGrid') { - // switch (this.location) { - // case 'nw': - // var a = grid._left + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('top', b); - // break; - // case 'n': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('top', b); - // break; - // case 'ne': - // var a = offsets.right + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css({right:a, top:b}); - // break; - // case 'e': - // var a = offsets.right + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({right:a, top:b}); - // break; - // case 'se': - // var a = offsets.right + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // case 's': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 'sw': - // var a = grid._left + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 'w': - // var a = grid._left + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({left:a, top:b}); - // break; - // default: // same as 'se' - // var a = grid._right - this.xoffset; - // var b = grid._bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // } - // - // } - // else { - // switch (this.location) { - // case 'nw': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css('right', a); - // this._elem.css('top', b); - // break; - // case 'n': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = this._plotDimensions.height - grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('bottom', b); - // break; - // case 'ne': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css({left:a, top:b}); - // break; - // case 'e': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({left:a, top:b}); - // break; - // case 'se': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 's': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = this._plotDimensions.height - offsets.bottom + this.yoffset; - // this._elem.css({left:a, top:b}); - // break; - // case 'sw': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // case 'w': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({right:a, top:b}); - // break; - // default: // same as 'se' - // var a = grid._right - this.xoffset; - // var b = grid._bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // } - // } - // } - // }; - - // setup default renderers for axes and legend so user doesn't have to - // called with scope of plot - function preInit(target, data, options) { - options = options || {}; - options.axesDefaults = options.axesDefaults || {}; - options.legend = options.legend || {}; - options.seriesDefaults = options.seriesDefaults || {}; - // only set these if there is a donut series - var setopts = false; - if (options.seriesDefaults.renderer == $.jqplot.DonutRenderer) { - setopts = true; - } - else if (options.series) { - for (var i=0; i < options.series.length; i++) { - if (options.series[i].renderer == $.jqplot.DonutRenderer) { - setopts = true; - } - } - } - - if (setopts) { - options.axesDefaults.renderer = $.jqplot.DonutAxisRenderer; - options.legend.renderer = $.jqplot.DonutLegendRenderer; - options.legend.preDraw = true; - options.seriesDefaults.pointLabels = {show: false}; - } - } - - // called with scope of plot. - function postInit(target, data, options) { - // if multiple series, add a reference to the previous one so that - // donut rings can nest. - for (var i=1; i<this.series.length; i++) { - if (!this.series[i]._previousSeries.length){ - for (var j=0; j<i; j++) { - if (this.series[i].renderer.constructor == $.jqplot.DonutRenderer && this.series[j].renderer.constructor == $.jqplot.DonutRenderer) { - this.series[i]._previousSeries.push(this.series[j]); - } - } - } - } - for (i=0; i<this.series.length; i++) { - if (this.series[i].renderer.constructor == $.jqplot.DonutRenderer) { - this.series[i]._numberSeries = this.series.length; - // don't allow mouseover and mousedown at same time. - if (this.series[i].highlightMouseOver) { - this.series[i].highlightMouseDown = false; - } - } - } - this.target.bind('mouseout', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); - } - - var postParseOptionsRun = false; - // called with scope of plot - function postParseOptions(options) { - for (var i=0; i<this.series.length; i++) { - this.series[i].seriesColors = this.seriesColors; - this.series[i].colorGenerator = this.colorGenerator; - } - } - - function highlight (plot, sidx, pidx) { - var s = plot.series[sidx]; - var canvas = plot.plugins.donutRenderer.highlightCanvas; - canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height); - s._highlightedPoint = pidx; - plot.plugins.donutRenderer.highlightedSeriesIndex = sidx; - s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColors[pidx], false); - } - - function unhighlight (plot) { - var canvas = plot.plugins.donutRenderer.highlightCanvas; - canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height); - for (var i=0; i<plot.series.length; i++) { - plot.series[i]._highlightedPoint = null; - } - plot.plugins.donutRenderer.highlightedSeriesIndex = null; - plot.target.trigger('jqplotDataUnhighlight'); - } - - function handleMove(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - var evt1 = jQuery.Event('jqplotDataMouseOver'); - evt1.pageX = ev.pageX; - evt1.pageY = ev.pageY; - plot.target.trigger(evt1, ins); - if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.donutRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { - var evt = jQuery.Event('jqplotDataHighlight'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - highlight (plot, ins[0], ins[1]); - } - } - else if (neighbor == null) { - unhighlight (plot); - } - } - - function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.donutRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { - var evt = jQuery.Event('jqplotDataHighlight'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - highlight (plot, ins[0], ins[1]); - } - } - else if (neighbor == null) { - unhighlight (plot); - } - } - - function handleMouseUp(ev, gridpos, datapos, neighbor, plot) { - var idx = plot.plugins.donutRenderer.highlightedSeriesIndex; - if (idx != null && plot.series[idx].highlightMouseDown) { - unhighlight(plot); - } - } - - function handleClick(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - var evt = jQuery.Event('jqplotDataClick'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - } - } - - function handleRightClick(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - var idx = plot.plugins.donutRenderer.highlightedSeriesIndex; - if (idx != null && plot.series[idx].highlightMouseDown) { - unhighlight(plot); - } - var evt = jQuery.Event('jqplotDataRightClick'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - } - } - - // called within context of plot - // create a canvas which we can draw on. - // insert it before the eventCanvas, so eventCanvas will still capture events. - function postPlotDraw() { - // Memory Leaks patch - if (this.plugins.donutRenderer && this.plugins.donutRenderer.highlightCanvas) { - this.plugins.donutRenderer.highlightCanvas.resetCanvas(); - this.plugins.donutRenderer.highlightCanvas = null; - } - - this.plugins.donutRenderer = {highlightedSeriesIndex:null}; - this.plugins.donutRenderer.highlightCanvas = new $.jqplot.GenericCanvas(); - // do we have any data labels? if so, put highlight canvas before those - // Fix for broken jquery :first selector with canvas (VML) elements. - var labels = $(this.targetId+' .jqplot-data-label'); - if (labels.length) { - $(labels[0]).before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-donutRenderer-highlight-canvas', this._plotDimensions, this)); - } - // else put highlight canvas before event canvas. - else { - this.eventCanvas._elem.before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-donutRenderer-highlight-canvas', this._plotDimensions, this)); - } - var hctx = this.plugins.donutRenderer.highlightCanvas.setContext(); - } - - $.jqplot.preInitHooks.push(preInit); - - $.jqplot.DonutTickRenderer = function() { - $.jqplot.AxisTickRenderer.call(this); - }; - - $.jqplot.DonutTickRenderer.prototype = new $.jqplot.AxisTickRenderer(); - $.jqplot.DonutTickRenderer.prototype.constructor = $.jqplot.DonutTickRenderer; - -})(jQuery); - -
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.dragable.js b/libs/jqplot/plugins/jqplot.dragable.js deleted file mode 100755 index c092be7f65..0000000000 --- a/libs/jqplot/plugins/jqplot.dragable.js +++ /dev/null @@ -1,224 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - - /** - * Class: $.jqplot.Dragable - * Plugin to make plotted points dragable by the user. - */ - $.jqplot.Dragable = function(options) { - // Group: Properties - this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false}); - this.shapeRenderer = new $.jqplot.ShapeRenderer(); - this.isDragging = false; - this.isOver = false; - this._ctx; - this._elem; - this._point; - this._gridData; - // prop: color - // CSS color spec for the dragged point (and adjacent line segment or bar). - this.color; - // prop: constrainTo - // Constrain dragging motion to an axis or to none. - // Allowable values are 'none', 'x', 'y' - this.constrainTo = 'none'; // 'x', 'y', or 'none'; - $.extend(true, this, options); - }; - - function DragCanvas() { - $.jqplot.GenericCanvas.call(this); - this.isDragging = false; - this.isOver = false; - this._neighbor; - this._cursors = []; - } - - DragCanvas.prototype = new $.jqplot.GenericCanvas(); - DragCanvas.prototype.constructor = DragCanvas; - - - // called within scope of series - $.jqplot.Dragable.parseOptions = function (defaults, opts) { - var options = opts || {}; - this.plugins.dragable = new $.jqplot.Dragable(options.dragable); - // since this function is called before series options are parsed, - // we can set this here and it will be overridden if needed. - this.isDragable = $.jqplot.config.enablePlugins; - }; - - // called within context of plot - // create a canvas which we can draw on. - // insert it before the eventCanvas, so eventCanvas will still capture events. - // add a new DragCanvas object to the plot plugins to handle drawing on this new canvas. - $.jqplot.Dragable.postPlotDraw = function() { - // Memory Leaks patch - if (this.plugins.dragable && this.plugins.dragable.highlightCanvas) { - this.plugins.dragable.highlightCanvas.resetCanvas(); - this.plugins.dragable.highlightCanvas = null; - } - - this.plugins.dragable = {previousCursor:'auto', isOver:false}; - this.plugins.dragable.dragCanvas = new DragCanvas(); - - this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding, 'jqplot-dragable-canvas', this._plotDimensions, this)); - var dctx = this.plugins.dragable.dragCanvas.setContext(); - }; - - //$.jqplot.preInitHooks.push($.jqplot.Dragable.init); - $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Dragable.parseOptions); - $.jqplot.postDrawHooks.push($.jqplot.Dragable.postPlotDraw); - $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]); - $.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleDown]); - $.jqplot.eventListenerHooks.push(['jqplotMouseUp', handleUp]); - - - function initDragPoint(plot, neighbor) { - var s = plot.series[neighbor.seriesIndex]; - var drag = s.plugins.dragable; - - // first, init the mark renderer for the dragged point - var smr = s.markerRenderer; - var mr = drag.markerRenderer; - mr.style = smr.style; - mr.lineWidth = smr.lineWidth + 2.5; - mr.size = smr.size + 5; - if (!drag.color) { - var rgba = $.jqplot.getColorComponents(smr.color); - var newrgb = [rgba[0], rgba[1], rgba[2]]; - var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]); - drag.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')'; - } - mr.color = drag.color; - mr.init(); - - var start = (neighbor.pointIndex > 0) ? neighbor.pointIndex - 1 : 0; - var end = neighbor.pointIndex+2; - drag._gridData = s.gridData.slice(start, end); - } - - function handleMove(ev, gridpos, datapos, neighbor, plot) { - if (plot.plugins.dragable.dragCanvas.isDragging) { - var dc = plot.plugins.dragable.dragCanvas; - var dp = dc._neighbor; - var s = plot.series[dp.seriesIndex]; - var drag = s.plugins.dragable; - var gd = s.gridData; - - // compute the new grid position with any constraints. - var x = (drag.constrainTo == 'y') ? dp.gridData[0] : gridpos.x; - var y = (drag.constrainTo == 'x') ? dp.gridData[1] : gridpos.y; - - // compute data values for any listeners. - var xu = s._xaxis.series_p2u(x); - var yu = s._yaxis.series_p2u(y); - - // clear the canvas then redraw effect at new position. - var ctx = dc._ctx; - ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); - - // adjust our gridData for the new mouse position - if (dp.pointIndex > 0) { - drag._gridData[1] = [x, y]; - } - else { - drag._gridData[0] = [x, y]; - } - plot.series[dp.seriesIndex].draw(dc._ctx, {gridData:drag._gridData, shadow:false, preventJqPlotSeriesDrawTrigger:true, color:drag.color, markerOptions:{color:drag.color, shadow:false}, trendline:{show:false}}); - plot.target.trigger('jqplotSeriesPointChange', [dp.seriesIndex, dp.pointIndex, [xu,yu], [x,y]]); - } - else if (neighbor != null) { - var series = plot.series[neighbor.seriesIndex]; - if (series.isDragable) { - var dc = plot.plugins.dragable.dragCanvas; - if (!dc.isOver) { - dc._cursors.push(ev.target.style.cursor); - ev.target.style.cursor = "pointer"; - } - dc.isOver = true; - } - } - else if (neighbor == null) { - var dc = plot.plugins.dragable.dragCanvas; - if (dc.isOver) { - ev.target.style.cursor = dc._cursors.pop(); - dc.isOver = false; - } - } - } - - function handleDown(ev, gridpos, datapos, neighbor, plot) { - var dc = plot.plugins.dragable.dragCanvas; - dc._cursors.push(ev.target.style.cursor); - if (neighbor != null) { - var s = plot.series[neighbor.seriesIndex]; - var drag = s.plugins.dragable; - if (s.isDragable && !dc.isDragging) { - dc._neighbor = neighbor; - dc.isDragging = true; - initDragPoint(plot, neighbor); - drag.markerRenderer.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], dc._ctx); - ev.target.style.cursor = "move"; - plot.target.trigger('jqplotDragStart', [neighbor.seriesIndex, neighbor.pointIndex, gridpos, datapos]); - } - } - // Just in case of a hickup, we'll clear the drag canvas and reset. - else { - var ctx = dc._ctx; - ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); - dc.isDragging = false; - } - } - - function handleUp(ev, gridpos, datapos, neighbor, plot) { - if (plot.plugins.dragable.dragCanvas.isDragging) { - var dc = plot.plugins.dragable.dragCanvas; - // clear the canvas - var ctx = dc._ctx; - ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); - dc.isDragging = false; - // redraw the series canvas at the new point. - var dp = dc._neighbor; - var s = plot.series[dp.seriesIndex]; - var drag = s.plugins.dragable; - // compute the new grid position with any constraints. - var x = (drag.constrainTo == 'y') ? dp.data[0] : datapos[s.xaxis]; - var y = (drag.constrainTo == 'x') ? dp.data[1] : datapos[s.yaxis]; - // var x = datapos[s.xaxis]; - // var y = datapos[s.yaxis]; - s.data[dp.pointIndex][0] = x; - s.data[dp.pointIndex][1] = y; - plot.drawSeries({preventJqPlotSeriesDrawTrigger:true}, dp.seriesIndex); - dc._neighbor = null; - ev.target.style.cursor = dc._cursors.pop(); - plot.target.trigger('jqplotDragStop', [gridpos, datapos]); - } - } -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.enhancedLegendRenderer.js b/libs/jqplot/plugins/jqplot.enhancedLegendRenderer.js deleted file mode 100644 index d93a17d4f1..0000000000 --- a/libs/jqplot/plugins/jqplot.enhancedLegendRenderer.js +++ /dev/null @@ -1,199 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - // class $.jqplot.EnhancedLegendRenderer - // Legend renderer which can specify the number of rows and/or columns in the legend. - $.jqplot.EnhancedLegendRenderer = function(){ - $.jqplot.TableLegendRenderer.call(this); - }; - - $.jqplot.EnhancedLegendRenderer.prototype = new $.jqplot.TableLegendRenderer(); - $.jqplot.EnhancedLegendRenderer.prototype.constructor = $.jqplot.EnhancedLegendRenderer; - - // called with scope of legend. - $.jqplot.EnhancedLegendRenderer.prototype.init = function(options) { - // prop: numberRows - // Maximum number of rows in the legend. 0 or null for unlimited. - this.numberRows = null; - // prop: numberColumns - // Maximum number of columns in the legend. 0 or null for unlimited. - this.numberColumns = null; - // prop: seriesToggle - // false to not enable series on/off toggling on the legend. - // true or a fadein/fadeout speed (number of milliseconds or 'fast', 'normal', 'slow') - // to enable show/hide of series on click of legend item. - this.seriesToggle = 'normal'; - // prop: disableIEFading - // true to toggle series with a show/hide method only and not allow fading in/out. - // This is to overcome poor performance of fade in some versions of IE. - this.disableIEFading = true; - $.extend(true, this, options); - - if (this.seriesToggle) { - $.jqplot.postDrawHooks.push(postDraw); - } - }; - - // called with scope of legend - $.jqplot.EnhancedLegendRenderer.prototype.draw = function() { - var legend = this; - if (this.show) { - var series = this._series; - var s; - var ss = 'position:absolute;'; - ss += (this.background) ? 'background:'+this.background+';' : ''; - ss += (this.border) ? 'border:'+this.border+';' : ''; - ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : ''; - ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : ''; - ss += (this.textColor) ? 'color:'+this.textColor+';' : ''; - ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : ''; - ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : ''; - ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : ''; - ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : ''; - this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>'); - if (this.seriesToggle) { - this._elem.css('z-index', '3'); - } - - var pad = false, - reverse = false, - nr, nc; - if (this.numberRows) { - nr = this.numberRows; - if (!this.numberColumns){ - nc = Math.ceil(series.length/nr); - } - else{ - nc = this.numberColumns; - } - } - else if (this.numberColumns) { - nc = this.numberColumns; - nr = Math.ceil(series.length/this.numberColumns); - } - else { - nr = series.length; - nc = 1; - } - - var i, j, tr, td1, td2, lt, rs; - var idx = 0; - // check to see if we need to reverse - for (i=series.length-1; i>=0; i--) { - if (series[i]._stack || series[i].renderer.constructor == $.jqplot.BezierCurveRenderer){ - reverse = true; - } - } - - for (i=0; i<nr; i++) { - if (reverse){ - tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem); - } - else{ - tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem); - } - for (j=0; j<nc; j++) { - if (idx < series.length && series[idx].show && series[idx].showLabel){ - s = series[idx]; - lt = this.labels[idx] || s.label.toString(); - if (lt) { - var color = s.color; - if (!reverse){ - if (i>0){ - pad = true; - } - else{ - pad = false; - } - } - else{ - if (i == nr -1){ - pad = false; - } - else{ - pad = true; - } - } - rs = (pad) ? this.rowSpacing : '0'; - - td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+ - '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+ - '</div></td>'); - td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>'); - if (this.escapeHtml){ - td2.text(lt); - } - else { - td2.html(lt); - } - if (reverse) { - if (this.showLabels) {td2.prependTo(tr);} - if (this.showSwatches) {td1.prependTo(tr);} - } - else { - if (this.showSwatches) {td1.appendTo(tr);} - if (this.showLabels) {td2.appendTo(tr);} - } - - if (this.seriesToggle) { - var speed; - if (typeof(this.seriesToggle) == 'string' || typeof(this.seriesToggle) == 'number') { - if (!$.browser.msie || !this.disableIEFading) { - speed = this.seriesToggle; - } - } - if (this.showSwatches) { - td1.bind('click', {series:s, speed:speed}, s.toggleDisplay); - td1.addClass('jqplot-seriesToggle'); - } - if (this.showLabels) { - td2.bind('click', {series:s, speed:speed}, s.toggleDisplay); - td2.addClass('jqplot-seriesToggle'); - } - } - - pad = true; - } - } - idx++; - } - } - } - return this._elem; - }; - - // called with scope of plot. - var postDraw = function () { - if (this.legend.renderer.constructor == $.jqplot.EnhancedLegendRenderer && this.legend.seriesToggle){ - var e = this.legend._elem.detach(); - this.eventCanvas._elem.after(e); - } - }; -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.funnelRenderer.js b/libs/jqplot/plugins/jqplot.funnelRenderer.js deleted file mode 100755 index c8899d1c46..0000000000 --- a/libs/jqplot/plugins/jqplot.funnelRenderer.js +++ /dev/null @@ -1,938 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.FunnelRenderer - * Plugin renderer to draw a funnel chart. - * x values, if present, will be used as labels. - * y values give area size. - * - * Funnel charts will draw a single series - * only. - * - * To use this renderer, you need to include the - * funnel renderer plugin, for example: - * - * > <script type="text/javascript" src="plugins/jqplot.funnelRenderer.js"></script> - * - * Properties described here are passed into the $.jqplot function - * as options on the series renderer. For example: - * - * > plot2 = $.jqplot('chart2', [s1, s2], { - * > seriesDefaults: { - * > renderer:$.jqplot.FunnelRenderer, - * > rendererOptions:{ - * > sectionMargin: 12, - * > widthRatio: 0.3 - * > } - * > } - * > }); - * - * IMPORTANT - * - * *The funnel renderer will reorder data in descending order* so the largest value in - * the data set is first and displayed on top of the funnel. Data will then - * be displayed in descending order down the funnel. The area of each funnel - * section will correspond to the value of each data point relative to the sum - * of all values. That is section area is proportional to section value divided by - * sum of all section values. - * - * If your data is not in descending order when passed into the plot, *it will be - * reordered* when stored in the series.data property. A copy of the unordered - * data is kept in the series._unorderedData property. - * - * A funnel plot will trigger events on the plot target - * according to user interaction. All events return the event object, - * the series index, the point (section) index, and the point data for - * the appropriate section. *Note* the point index will referr to the ordered - * data, not the original unordered data. - * - * 'jqplotDataMouseOver' - triggered when mousing over a section. - * 'jqplotDataHighlight' - triggered the first time user mouses over a section, - * if highlighting is enabled. - * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of - * a highlighted section. - * 'jqplotDataClick' - triggered when the user clicks on a section. - * 'jqplotDataRightClick' - tiggered when the user right clicks on a section if - * the "captureRightClick" option is set to true on the plot. - */ - $.jqplot.FunnelRenderer = function(){ - $.jqplot.LineRenderer.call(this); - }; - - $.jqplot.FunnelRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.FunnelRenderer.prototype.constructor = $.jqplot.FunnelRenderer; - - // called with scope of a series - $.jqplot.FunnelRenderer.prototype.init = function(options, plot) { - // Group: Properties - // - // prop: padding - // padding between the funnel and plot edges, legend, etc. - this.padding = {top: 20, right: 20, bottom: 20, left: 20}; - // prop: sectionMargin - // spacing between funnel sections in pixels. - this.sectionMargin = 6; - // prop: fill - // true or false, wether to fill the areas. - this.fill = true; - // prop: shadowOffset - // offset of the shadow from the area and offset of - // each succesive stroke of the shadow from the last. - this.shadowOffset = 2; - // prop: shadowAlpha - // transparency of the shadow (0 = transparent, 1 = opaque) - this.shadowAlpha = 0.07; - // prop: shadowDepth - // number of strokes to apply to the shadow, - // each stroke offset shadowOffset from the last. - this.shadowDepth = 5; - // prop: highlightMouseOver - // True to highlight area when moused over. - // This must be false to enable highlightMouseDown to highlight when clicking on a area. - this.highlightMouseOver = true; - // prop: highlightMouseDown - // True to highlight when a mouse button is pressed over a area. - // This will be disabled if highlightMouseOver is true. - this.highlightMouseDown = false; - // prop: highlightColors - // array of colors to use when highlighting an area. - this.highlightColors = []; - // prop: widthRatio - // The ratio of the width of the top of the funnel to the bottom. - // a ratio of 0 will make an upside down pyramid. - this.widthRatio = 0.2; - // prop: lineWidth - // width of line if areas are stroked and not filled. - this.lineWidth = 2; - // prop: dataLabels - // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices. - // Defaults to percentage of each pie slice. - this.dataLabels = 'percent'; - // prop: showDataLabels - // true to show data labels on slices. - this.showDataLabels = false; - // prop: dataLabelFormatString - // Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage. - this.dataLabelFormatString = null; - // prop: dataLabelThreshold - // Threshhold in percentage (0 - 100) of pie area, below which no label will be displayed. - // This applies to all label types, not just to percentage labels. - this.dataLabelThreshold = 3; - this._type = 'funnel'; - - this.tickRenderer = $.jqplot.FunnelTickRenderer; - - // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver - if (options.highlightMouseDown && options.highlightMouseOver == null) { - options.highlightMouseOver = false; - } - - $.extend(true, this, options); - - // index of the currenty highlighted point, if any - this._highlightedPoint = null; - - // lengths of bases, or horizontal sides of areas of trapezoid. - this._bases = []; - // total area - this._atot; - // areas of segments. - this._areas = []; - // vertical lengths of segments. - this._lengths = []; - // angle of the funnel to vertical. - this._angle; - this._dataIndices = []; - - // sort data - this._unorderedData = $.extend(true, [], this.data); - var idxs = $.extend(true, [], this.data); - for (var i=0; i<idxs.length; i++) { - idxs[i].push(i); - } - this.data.sort( function (a, b) { return b[1] - a[1]; } ); - idxs.sort( function (a, b) { return b[1] - a[1]; }); - for (var i=0; i<idxs.length; i++) { - this._dataIndices.push(idxs[i][2]); - } - - // set highlight colors if none provided - if (this.highlightColors.length == 0) { - for (var i=0; i<this.seriesColors.length; i++){ - var rgba = $.jqplot.getColorComponents(this.seriesColors[i]); - var newrgb = [rgba[0], rgba[1], rgba[2]]; - var sum = newrgb[0] + newrgb[1] + newrgb[2]; - for (var j=0; j<3; j++) { - // when darkening, lowest color component can be is 60. - newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.4 * (255 - newrgb[j]); - newrgb[j] = parseInt(newrgb[j], 10); - } - this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')'); - } - } - - plot.postParseOptionsHooks.addOnce(postParseOptions); - plot.postInitHooks.addOnce(postInit); - plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove); - plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown); - plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp); - plot.eventListenerHooks.addOnce('jqplotClick', handleClick); - plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); - plot.postDrawHooks.addOnce(postPlotDraw); - - }; - - // gridData will be of form [label, percentage of total] - $.jqplot.FunnelRenderer.prototype.setGridData = function(plot) { - // set gridData property. This will hold angle in radians of each data point. - var sum = 0; - var td = []; - for (var i=0; i<this.data.length; i++){ - sum += this.data[i][1]; - td.push([this.data[i][0], this.data[i][1]]); - } - - // normalize y values, so areas are proportional. - for (var i=0; i<td.length; i++) { - td[i][1] = td[i][1]/sum; - } - - this._bases = new Array(td.length + 1); - this._lengths = new Array(td.length); - - this.gridData = td; - }; - - $.jqplot.FunnelRenderer.prototype.makeGridData = function(data, plot) { - // set gridData property. This will hold angle in radians of each data point. - var sum = 0; - var td = []; - for (var i=0; i<this.data.length; i++){ - sum += this.data[i][1]; - td.push([this.data[i][0], this.data[i][1]]); - } - - // normalize y values, so areas are proportional. - for (var i=0; i<td.length; i++) { - td[i][1] = td[i][1]/sum; - } - - this._bases = new Array(td.length + 1); - this._lengths = new Array(td.length); - - return td; - }; - - $.jqplot.FunnelRenderer.prototype.drawSection = function (ctx, vertices, color, isShadow) { - var fill = this.fill; - var lineWidth = this.lineWidth; - ctx.save(); - - if (isShadow) { - for (var i=0; i<this.shadowDepth; i++) { - ctx.save(); - ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI)); - doDraw(); - } - } - - else { - doDraw(); - } - - function doDraw () { - ctx.beginPath(); - ctx.fillStyle = color; - ctx.strokeStyle = color; - ctx.lineWidth = lineWidth; - ctx.moveTo(vertices[0][0], vertices[0][1]); - for (var i=1; i<4; i++) { - ctx.lineTo(vertices[i][0], vertices[i][1]); - } - ctx.closePath(); - if (fill) { - ctx.fill(); - } - else { - ctx.stroke(); - } - } - - if (isShadow) { - for (var i=0; i<this.shadowDepth; i++) { - ctx.restore(); - } - } - - ctx.restore(); - }; - - // called with scope of series - $.jqplot.FunnelRenderer.prototype.draw = function (ctx, gd, options, plot) { - var i; - var opts = (options != undefined) ? options : {}; - // offset and direction of offset due to legend placement - var offx = 0; - var offy = 0; - var trans = 1; - this._areas = []; - // var colorGenerator = new this.colorGenerator(this.seriesColors); - if (options.legendInfo && options.legendInfo.placement == 'insideGrid') { - var li = options.legendInfo; - switch (li.location) { - case 'nw': - offx = li.width + li.xoffset; - break; - case 'w': - offx = li.width + li.xoffset; - break; - case 'sw': - offx = li.width + li.xoffset; - break; - case 'ne': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'e': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'se': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'n': - offy = li.height + li.yoffset; - break; - case 's': - offy = li.height + li.yoffset; - trans = -1; - break; - default: - break; - } - } - - var loff = (trans==1) ? this.padding.left + offx : this.padding.left; - var toff = (trans==1) ? this.padding.top + offy : this.padding.top; - var roff = (trans==-1) ? this.padding.right + offx : this.padding.right; - var boff = (trans==-1) ? this.padding.bottom + offy : this.padding.bottom; - - var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; - var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; - var fill = (opts.fill != undefined) ? opts.fill : this.fill; - var cw = ctx.canvas.width; - var ch = ctx.canvas.height; - this._bases[0] = cw - loff - roff; - var ltot = this._length = ch - toff - boff; - - var hend = this._bases[0]*this.widthRatio; - this._atot = ltot/2 * (this._bases[0] + this._bases[0]*this.widthRatio); - - this._angle = Math.atan((this._bases[0] - hend)/2/ltot); - - for (i=0; i<gd.length; i++) { - this._areas.push(gd[i][1] * this._atot); - } - - - var guess, err, count, lsum=0; - var tolerance = 0.0001; - - for (i=0; i<this._areas.length; i++) { - guess = this._areas[i]/this._bases[i]; - err = 999999; - this._lengths[i] = guess; - count = 0; - while (err > this._lengths[i]*tolerance && count < 100) { - this._lengths[i] = this._areas[i]/(this._bases[i] - this._lengths[i] * Math.tan(this._angle)); - err = Math.abs(this._lengths[i] - guess); - this._bases[i+1] = this._bases[i] - (2*this._lengths[i]*Math.tan(this._angle)); - guess = this._lengths[i]; - count++; - } - lsum += this._lengths[i]; - } - - // figure out vertices of each section - this._vertices = new Array(gd.length); - - // these are 4 coners of entire trapezoid - var p0 = [loff, toff], - p1 = [loff+this._bases[0], toff], - p2 = [loff + (this._bases[0] - this._bases[this._bases.length-1])/2, toff + this._length], - p3 = [p2[0] + this._bases[this._bases.length-1], p2[1]]; - - // equations of right and left sides, returns x, y values given height of section (y value) - function findleft (l) { - var m = (p0[1] - p2[1])/(p0[0] - p2[0]); - var b = p0[1] - m*p0[0]; - var y = l + p0[1]; - - return [(y - b)/m, y]; - } - - function findright (l) { - var m = (p1[1] - p3[1])/(p1[0] - p3[0]); - var b = p1[1] - m*p1[0]; - var y = l + p1[1]; - - return [(y - b)/m, y]; - } - - var x = offx, y = offy; - var h=0, adj=0; - - for (i=0; i<gd.length; i++) { - this._vertices[i] = new Array(); - var v = this._vertices[i]; - var sm = this.sectionMargin; - if (i == 0) { - adj = 0; - } - if (i == 1) { - adj = sm/3; - } - else if (i > 0 && i < gd.length-1) { - adj = sm/2; - } - else if (i == gd.length -1) { - adj = 2*sm/3; - } - v.push(findleft(h+adj)); - v.push(findright(h+adj)); - h += this._lengths[i]; - if (i == 0) { - adj = -2*sm/3; - } - else if (i > 0 && i < gd.length-1) { - adj = -sm/2; - } - else if (i == gd.length - 1) { - adj = 0; - } - v.push(findright(h+adj)); - v.push(findleft(h+adj)); - - } - - if (this.shadow) { - var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')'; - for (var i=0; i<gd.length; i++) { - this.renderer.drawSection.call (this, ctx, this._vertices[i], shadowColor, true); - } - - } - for (var i=0; i<gd.length; i++) { - var v = this._vertices[i]; - this.renderer.drawSection.call (this, ctx, v, this.seriesColors[i]); - - if (this.showDataLabels && gd[i][1]*100 >= this.dataLabelThreshold) { - var fstr, label; - - if (this.dataLabels == 'label') { - fstr = this.dataLabelFormatString || '%s'; - label = $.jqplot.sprintf(fstr, gd[i][0]); - } - else if (this.dataLabels == 'value') { - fstr = this.dataLabelFormatString || '%d'; - label = $.jqplot.sprintf(fstr, this.data[i][1]); - } - else if (this.dataLabels == 'percent') { - fstr = this.dataLabelFormatString || '%d%%'; - label = $.jqplot.sprintf(fstr, gd[i][1]*100); - } - else if (this.dataLabels.constructor == Array) { - fstr = this.dataLabelFormatString || '%s'; - label = $.jqplot.sprintf(fstr, this.dataLabels[this._dataIndices[i]]); - } - - var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge; - - var x = (v[0][0] + v[1][0])/2 + this.canvas._offsets.left; - var y = (v[1][1] + v[2][1])/2 + this.canvas._offsets.top; - - var labelelem = $('<span class="jqplot-funnel-series jqplot-data-label" style="position:absolute;">' + label + '</span>').insertBefore(plot.eventCanvas._elem); - x -= labelelem.width()/2; - y -= labelelem.height()/2; - x = Math.round(x); - y = Math.round(y); - labelelem.css({left: x, top: y}); - } - - } - - }; - - $.jqplot.FunnelAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - }; - - $.jqplot.FunnelAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.FunnelAxisRenderer.prototype.constructor = $.jqplot.FunnelAxisRenderer; - - - // There are no traditional axes on a funnel chart. We just need to provide - // dummy objects with properties so the plot will render. - // called with scope of axis object. - $.jqplot.FunnelAxisRenderer.prototype.init = function(options){ - // - this.tickRenderer = $.jqplot.FunnelTickRenderer; - $.extend(true, this, options); - // I don't think I'm going to need _dataBounds here. - // have to go Axis scaling in a way to fit chart onto plot area - // and provide u2p and p2u functionality for mouse cursor, etc. - // for convienence set _dataBounds to 0 and 100 and - // set min/max to 0 and 100. - this._dataBounds = {min:0, max:100}; - this.min = 0; - this.max = 100; - this.showTicks = false; - this.ticks = []; - this.showMark = false; - this.show = false; - }; - - - - /** - * Class: $.jqplot.FunnelLegendRenderer - * Legend Renderer specific to funnel plots. Set by default - * when the user creates a funnel plot. - */ - $.jqplot.FunnelLegendRenderer = function(){ - $.jqplot.TableLegendRenderer.call(this); - }; - - $.jqplot.FunnelLegendRenderer.prototype = new $.jqplot.TableLegendRenderer(); - $.jqplot.FunnelLegendRenderer.prototype.constructor = $.jqplot.FunnelLegendRenderer; - - $.jqplot.FunnelLegendRenderer.prototype.init = function(options) { - // Group: Properties - // - // prop: numberRows - // Maximum number of rows in the legend. 0 or null for unlimited. - this.numberRows = null; - // prop: numberColumns - // Maximum number of columns in the legend. 0 or null for unlimited. - this.numberColumns = null; - $.extend(true, this, options); - }; - - // called with context of legend - $.jqplot.FunnelLegendRenderer.prototype.draw = function() { - var legend = this; - if (this.show) { - var series = this._series; - var ss = 'position:absolute;'; - ss += (this.background) ? 'background:'+this.background+';' : ''; - ss += (this.border) ? 'border:'+this.border+';' : ''; - ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : ''; - ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : ''; - ss += (this.textColor) ? 'color:'+this.textColor+';' : ''; - ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : ''; - ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : ''; - ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : ''; - ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : ''; - this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>'); - // Funnel charts legends don't go by number of series, but by number of data points - // in the series. Refactor things here for that. - - var pad = false, - reverse = false, - nr, nc; - var s = series[0]; - var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors); - - if (s.show) { - var pd = s.data; - if (this.numberRows) { - nr = this.numberRows; - if (!this.numberColumns){ - nc = Math.ceil(pd.length/nr); - } - else{ - nc = this.numberColumns; - } - } - else if (this.numberColumns) { - nc = this.numberColumns; - nr = Math.ceil(pd.length/this.numberColumns); - } - else { - nr = pd.length; - nc = 1; - } - - var i, j, tr, td1, td2, lt, rs, color; - var idx = 0; - - for (i=0; i<nr; i++) { - if (reverse){ - tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem); - } - else{ - tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem); - } - for (j=0; j<nc; j++) { - if (idx < pd.length){ - lt = this.labels[idx] || pd[idx][0].toString(); - color = colorGenerator.next(); - if (!reverse){ - if (i>0){ - pad = true; - } - else{ - pad = false; - } - } - else{ - if (i == nr -1){ - pad = false; - } - else{ - pad = true; - } - } - rs = (pad) ? this.rowSpacing : '0'; - - td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+ - '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+ - '</div></td>'); - td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>'); - if (this.escapeHtml){ - td2.text(lt); - } - else { - td2.html(lt); - } - if (reverse) { - td2.prependTo(tr); - td1.prependTo(tr); - } - else { - td1.appendTo(tr); - td2.appendTo(tr); - } - pad = true; - } - idx++; - } - } - } - } - return this._elem; - }; - - // $.jqplot.FunnelLegendRenderer.prototype.pack = function(offsets) { - // if (this.show) { - // // fake a grid for positioning - // var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom}; - // if (this.placement == 'insideGrid') { - // switch (this.location) { - // case 'nw': - // var a = grid._left + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('top', b); - // break; - // case 'n': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('top', b); - // break; - // case 'ne': - // var a = offsets.right + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css({right:a, top:b}); - // break; - // case 'e': - // var a = offsets.right + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({right:a, top:b}); - // break; - // case 'se': - // var a = offsets.right + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // case 's': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 'sw': - // var a = grid._left + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 'w': - // var a = grid._left + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({left:a, top:b}); - // break; - // default: // same as 'se' - // var a = grid._right - this.xoffset; - // var b = grid._bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // } - // - // } - // else { - // switch (this.location) { - // case 'nw': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css('right', a); - // this._elem.css('top', b); - // break; - // case 'n': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = this._plotDimensions.height - grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('bottom', b); - // break; - // case 'ne': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css({left:a, top:b}); - // break; - // case 'e': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({left:a, top:b}); - // break; - // case 'se': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 's': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = this._plotDimensions.height - offsets.bottom + this.yoffset; - // this._elem.css({left:a, top:b}); - // break; - // case 'sw': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // case 'w': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({right:a, top:b}); - // break; - // default: // same as 'se' - // var a = grid._right - this.xoffset; - // var b = grid._bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // } - // } - // } - // }; - - // setup default renderers for axes and legend so user doesn't have to - // called with scope of plot - function preInit(target, data, options) { - options = options || {}; - options.axesDefaults = options.axesDefaults || {}; - options.legend = options.legend || {}; - options.seriesDefaults = options.seriesDefaults || {}; - // only set these if there is a funnel series - var setopts = false; - if (options.seriesDefaults.renderer == $.jqplot.FunnelRenderer) { - setopts = true; - } - else if (options.series) { - for (var i=0; i < options.series.length; i++) { - if (options.series[i].renderer == $.jqplot.FunnelRenderer) { - setopts = true; - } - } - } - - if (setopts) { - options.axesDefaults.renderer = $.jqplot.FunnelAxisRenderer; - options.legend.renderer = $.jqplot.FunnelLegendRenderer; - options.legend.preDraw = true; - options.sortData = false; - options.seriesDefaults.pointLabels = {show: false}; - } - } - - function postInit(target, data, options) { - // if multiple series, add a reference to the previous one so that - // funnel rings can nest. - for (var i=0; i<this.series.length; i++) { - if (this.series[i].renderer.constructor == $.jqplot.FunnelRenderer) { - // don't allow mouseover and mousedown at same time. - if (this.series[i].highlightMouseOver) { - this.series[i].highlightMouseDown = false; - } - } - } - this.target.bind('mouseout', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); - } - - // called with scope of plot - function postParseOptions(options) { - for (var i=0; i<this.series.length; i++) { - this.series[i].seriesColors = this.seriesColors; - this.series[i].colorGenerator = this.colorGenerator; - } - } - - function highlight (plot, sidx, pidx) { - var s = plot.series[sidx]; - var canvas = plot.plugins.funnelRenderer.highlightCanvas; - canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height); - s._highlightedPoint = pidx; - plot.plugins.funnelRenderer.highlightedSeriesIndex = sidx; - s.renderer.drawSection.call(s, canvas._ctx, s._vertices[pidx], s.highlightColors[pidx], false); - } - - function unhighlight (plot) { - var canvas = plot.plugins.funnelRenderer.highlightCanvas; - canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height); - for (var i=0; i<plot.series.length; i++) { - plot.series[i]._highlightedPoint = null; - } - plot.plugins.funnelRenderer.highlightedSeriesIndex = null; - plot.target.trigger('jqplotDataUnhighlight'); - } - - function handleMove(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - var evt1 = jQuery.Event('jqplotDataMouseOver'); - evt1.pageX = ev.pageX; - evt1.pageY = ev.pageY; - plot.target.trigger(evt1, ins); - if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.funnelRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { - var evt = jQuery.Event('jqplotDataHighlight'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - highlight (plot, ins[0], ins[1]); - } - } - else if (neighbor == null) { - unhighlight (plot); - } - } - - function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.funnelRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { - var evt = jQuery.Event('jqplotDataHighlight'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - highlight (plot, ins[0], ins[1]); - } - } - else if (neighbor == null) { - unhighlight (plot); - } - } - - function handleMouseUp(ev, gridpos, datapos, neighbor, plot) { - var idx = plot.plugins.funnelRenderer.highlightedSeriesIndex; - if (idx != null && plot.series[idx].highlightMouseDown) { - unhighlight(plot); - } - } - - function handleClick(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - var evt = jQuery.Event('jqplotDataClick'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - } - } - - function handleRightClick(ev, gridpos, datapos, neighbor, plot) { - if (neighbor) { - var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; - var idx = plot.plugins.funnelRenderer.highlightedSeriesIndex; - if (idx != null && plot.series[idx].highlightMouseDown) { - unhighlight(plot); - } - var evt = jQuery.Event('jqplotDataRightClick'); - evt.pageX = ev.pageX; - evt.pageY = ev.pageY; - plot.target.trigger(evt, ins); - } - } - - // called within context of plot - // create a canvas which we can draw on. - // insert it before the eventCanvas, so eventCanvas will still capture events. - function postPlotDraw() { - // Memory Leaks patch - if (this.plugins.funnelRenderer && this.plugins.funnelRenderer.highlightCanvas) { - this.plugins.funnelRenderer.highlightCanvas.resetCanvas(); - this.plugins.funnelRenderer.highlightCanvas = null; - } - - this.plugins.funnelRenderer = {}; - this.plugins.funnelRenderer.highlightCanvas = new $.jqplot.GenericCanvas(); - - // do we have any data labels? if so, put highlight canvas before those - var labels = $(this.targetId+' .jqplot-data-label'); - if (labels.length) { - $(labels[0]).before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-funnelRenderer-highlight-canvas', this._plotDimensions, this)); - } - // else put highlight canvas before event canvas. - else { - this.eventCanvas._elem.before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-funnelRenderer-highlight-canvas', this._plotDimensions, this)); - } - var hctx = this.plugins.funnelRenderer.highlightCanvas.setContext(); - } - - $.jqplot.preInitHooks.push(preInit); - - $.jqplot.FunnelTickRenderer = function() { - $.jqplot.AxisTickRenderer.call(this); - }; - - $.jqplot.FunnelTickRenderer.prototype = new $.jqplot.AxisTickRenderer(); - $.jqplot.FunnelTickRenderer.prototype.constructor = $.jqplot.FunnelTickRenderer; - -})(jQuery); - -
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.highlighter.js b/libs/jqplot/plugins/jqplot.highlighter.js deleted file mode 100755 index 275d29a360..0000000000 --- a/libs/jqplot/plugins/jqplot.highlighter.js +++ /dev/null @@ -1,421 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]); - - /** - * Class: $.jqplot.Highlighter - * Plugin which will highlight data points when they are moused over. - * - * To use this plugin, include the js - * file in your source: - * - * > <script type="text/javascript" src="plugins/jqplot.highlighter.js"></script> - * - * A tooltip providing information about the data point is enabled by default. - * To disable the tooltip, set "showTooltip" to false. - * - * You can control what data is displayed in the tooltip with various - * options. The "tooltipAxes" option controls wether the x, y or both - * data values are displayed. - * - * Some chart types (e.g. hi-low-close) have more than one y value per - * data point. To display the additional values in the tooltip, set the - * "yvalues" option to the desired number of y values present (3 for a hlc chart). - * - * By default, data values will be formatted with the same formatting - * specifiers as used to format the axis ticks. A custom format code - * can be supplied with the tooltipFormatString option. This will apply - * to all values in the tooltip. - * - * For more complete control, the "formatString" option can be set. This - * Allows conplete control over tooltip formatting. Values are passed to - * the format string in an order determined by the "tooltipAxes" and "yvalues" - * options. So, if you have a hi-low-close chart and you just want to display - * the hi-low-close values in the tooltip, you could set a formatString like: - * - * > highlighter: { - * > tooltipAxes: 'y', - * > yvalues: 3, - * > formatString:'<table class="jqplot-highlighter"> - * > <tr><td>hi:</td><td>%s</td></tr> - * > <tr><td>low:</td><td>%s</td></tr> - * > <tr><td>close:</td><td>%s</td></tr></table>' - * > } - * - */ - $.jqplot.Highlighter = function(options) { - // Group: Properties - // - //prop: show - // true to show the highlight. - this.show = $.jqplot.config.enablePlugins; - // prop: markerRenderer - // Renderer used to draw the marker of the highlighted point. - // Renderer will assimilate attributes from the data point being highlighted, - // so no attributes need set on the renderer directly. - // Default is to turn off shadow drawing on the highlighted point. - this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false}); - // prop: showMarker - // true to show the marker - this.showMarker = true; - // prop: lineWidthAdjust - // Pixels to add to the lineWidth of the highlight. - this.lineWidthAdjust = 2.5; - // prop: sizeAdjust - // Pixels to add to the overall size of the highlight. - this.sizeAdjust = 5; - // prop: showTooltip - // Show a tooltip with data point values. - this.showTooltip = true; - // prop: tooltipLocation - // Where to position tooltip, 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw' - this.tooltipLocation = 'nw'; - // prop: fadeTooltip - // true = fade in/out tooltip, flase = show/hide tooltip - this.fadeTooltip = true; - // prop: tooltipFadeSpeed - // 'slow', 'def', 'fast', or number of milliseconds. - this.tooltipFadeSpeed = "fast"; - // prop: tooltipOffset - // Pixel offset of tooltip from the highlight. - this.tooltipOffset = 2; - // prop: tooltipAxes - // Which axes to display in tooltip, 'x', 'y' or 'both', 'xy' or 'yx' - // 'both' and 'xy' are equivalent, 'yx' reverses order of labels. - this.tooltipAxes = 'both'; - // prop; tooltipSeparator - // String to use to separate x and y axes in tooltip. - this.tooltipSeparator = ', '; - // prop; tooltipContentEditor - // Function used to edit/augment/replace the formatted tooltip contents. - // Called as str = tooltipContentEditor(str, seriesIndex, pointIndex) - // where str is the generated tooltip html and seriesIndex and pointIndex identify - // the data point being highlighted. Should return the html for the tooltip contents. - this.tooltipContentEditor = null; - // prop: useAxesFormatters - // Use the x and y axes formatters to format the text in the tooltip. - this.useAxesFormatters = true; - // prop: tooltipFormatString - // sprintf format string for the tooltip. - // Uses Ash Searle's javascript sprintf implementation - // found here: http://hexmen.com/blog/2007/03/printf-sprintf/ - // See http://perldoc.perl.org/functions/sprintf.html for reference. - // Additional "p" and "P" format specifiers added by Chris Leonello. - this.tooltipFormatString = '%.5P'; - // prop: formatString - // alternative to tooltipFormatString - // will format the whole tooltip text, populating with x, y values as - // indicated by tooltipAxes option. So, you could have a tooltip like: - // 'Date: %s, number of cats: %d' to format the whole tooltip at one go. - // If useAxesFormatters is true, values will be formatted according to - // Axes formatters and you can populate your tooltip string with - // %s placeholders. - this.formatString = null; - // prop: yvalues - // Number of y values to expect in the data point array. - // Typically this is 1. Certain plots, like OHLC, will - // have more y values in each data point array. - this.yvalues = 1; - // prop: bringSeriesToFront - // This option requires jQuery 1.4+ - // True to bring the series of the highlighted point to the front - // of other series. - this.bringSeriesToFront = false; - this._tooltipElem; - this.isHighlighting = false; - - $.extend(true, this, options); - }; - - var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w']; - var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7}; - var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e']; - - // axis.renderer.tickrenderer.formatter - - // called with scope of plot - $.jqplot.Highlighter.init = function (target, data, opts){ - var options = opts || {}; - // add a highlighter attribute to the plot - this.plugins.highlighter = new $.jqplot.Highlighter(options.highlighter); - }; - - // called within scope of series - $.jqplot.Highlighter.parseOptions = function (defaults, options) { - // Add a showHighlight option to the series - // and set it to true by default. - this.showHighlight = true; - }; - - // called within context of plot - // create a canvas which we can draw on. - // insert it before the eventCanvas, so eventCanvas will still capture events. - $.jqplot.Highlighter.postPlotDraw = function() { - // Memory Leaks patch - if (this.plugins.highlighter && this.plugins.highlighter.highlightCanvas) { - this.plugins.highlighter.highlightCanvas.resetCanvas(); - this.plugins.highlighter.highlightCanvas = null; - } - - if (this.plugins.highlighter && this.plugins.highlighter._tooltipElem) { - this.plugins.highlighter._tooltipElem.emptyForce(); - this.plugins.highlighter._tooltipElem = null; - } - - this.plugins.highlighter.highlightCanvas = new $.jqplot.GenericCanvas(); - - this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding, 'jqplot-highlight-canvas', this._plotDimensions, this)); - this.plugins.highlighter.highlightCanvas.setContext(); - - var elem = document.createElement('div'); - this.plugins.highlighter._tooltipElem = $(elem); - elem = null; - this.plugins.highlighter._tooltipElem.addClass('jqplot-highlighter-tooltip'); - this.plugins.highlighter._tooltipElem.css({position:'absolute', display:'none'}); - - this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem); - }; - - $.jqplot.preInitHooks.push($.jqplot.Highlighter.init); - $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Highlighter.parseOptions); - $.jqplot.postDrawHooks.push($.jqplot.Highlighter.postPlotDraw); - - function draw(plot, neighbor) { - var hl = plot.plugins.highlighter; - var s = plot.series[neighbor.seriesIndex]; - var smr = s.markerRenderer; - var mr = hl.markerRenderer; - mr.style = smr.style; - mr.lineWidth = smr.lineWidth + hl.lineWidthAdjust; - mr.size = smr.size + hl.sizeAdjust; - var rgba = $.jqplot.getColorComponents(smr.color); - var newrgb = [rgba[0], rgba[1], rgba[2]]; - var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]); - mr.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')'; - mr.init(); - mr.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], hl.highlightCanvas._ctx); - } - - function showTooltip(plot, series, neighbor) { - // neighbor looks like: {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]} - // gridData should be x,y pixel coords on the grid. - // add the plot._gridPadding to that to get x,y in the target. - var hl = plot.plugins.highlighter; - var elem = hl._tooltipElem; - if (hl.useAxesFormatters) { - var xf = series._xaxis._ticks[0].formatter; - var yf = series._yaxis._ticks[0].formatter; - var xfstr = series._xaxis._ticks[0].formatString; - var yfstr = series._yaxis._ticks[0].formatString; - var str; - var xstr = xf(xfstr, neighbor.data[0]); - var ystrs = []; - for (var i=1; i<hl.yvalues+1; i++) { - ystrs.push(yf(yfstr, neighbor.data[i])); - } - if (hl.formatString) { - switch (hl.tooltipAxes) { - case 'both': - case 'xy': - ystrs.unshift(xstr); - ystrs.unshift(hl.formatString); - str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); - break; - case 'yx': - ystrs.push(xstr); - ystrs.unshift(hl.formatString); - str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); - break; - case 'x': - str = $.jqplot.sprintf.apply($.jqplot.sprintf, [hl.formatString, xstr]); - break; - case 'y': - ystrs.unshift(hl.formatString); - str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); - break; - default: // same as xy - ystrs.unshift(xstr); - ystrs.unshift(hl.formatString); - str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); - break; - } - } - else { - switch (hl.tooltipAxes) { - case 'both': - case 'xy': - str = xstr; - for (var i=0; i<ystrs.length; i++) { - str += hl.tooltipSeparator + ystrs[i]; - } - break; - case 'yx': - str = ''; - for (var i=0; i<ystrs.length; i++) { - str += ystrs[i] + hl.tooltipSeparator; - } - str += xstr; - break; - case 'x': - str = xstr; - break; - case 'y': - str = ystrs.join(hl.tooltipSeparator); - break; - default: // same as 'xy' - str = xstr; - for (var i=0; i<ystrs.length; i++) { - str += hl.tooltipSeparator + ystrs[i]; - } - break; - - } - } - } - else { - var str; - if (hl.tooltipAxes == 'both' || hl.tooltipAxes == 'xy') { - str = $.jqplot.sprintf(hl.tooltipFormatString, neighbor.data[0]) + hl.tooltipSeparator + $.jqplot.sprintf(hl.tooltipFormatString, neighbor.data[1]); - } - else if (hl.tooltipAxes == 'yx') { - str = $.jqplot.sprintf(hl.tooltipFormatString, neighbor.data[1]) + hl.tooltipSeparator + $.jqplot.sprintf(hl.tooltipFormatString, neighbor.data[0]); - } - else if (hl.tooltipAxes == 'x') { - str = $.jqplot.sprintf(hl.tooltipFormatString, neighbor.data[0]); - } - else if (hl.tooltipAxes == 'y') { - str = $.jqplot.sprintf(hl.tooltipFormatString, neighbor.data[1]); - } - } - if ($.isFunction(hl.tooltipContentEditor)) { - // args str, seriesIndex, pointIndex are essential so the hook can look up - // extra data for the point. - str = hl.tooltipContentEditor(str, neighbor.seriesIndex, neighbor.pointIndex, plot); - } - elem.html(str); - var gridpos = {x:neighbor.gridData[0], y:neighbor.gridData[1]}; - var ms = 0; - var fact = 0.707; - if (series.markerRenderer.show == true) { - ms = (series.markerRenderer.size + hl.sizeAdjust)/2; - } - - var loc = locations; - if (series.fillToZero && series.fill && neighbor.data[1] < 0) { - loc = oppositeLocations; - } - - switch (loc[locationIndicies[hl.tooltipLocation]]) { - case 'nw': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - hl.tooltipOffset - fact * ms; - var y = gridpos.y + plot._gridPadding.top - hl.tooltipOffset - elem.outerHeight(true) - fact * ms; - break; - case 'n': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2; - var y = gridpos.y + plot._gridPadding.top - hl.tooltipOffset - elem.outerHeight(true) - ms; - break; - case 'ne': - var x = gridpos.x + plot._gridPadding.left + hl.tooltipOffset + fact * ms; - var y = gridpos.y + plot._gridPadding.top - hl.tooltipOffset - elem.outerHeight(true) - fact * ms; - break; - case 'e': - var x = gridpos.x + plot._gridPadding.left + hl.tooltipOffset + ms; - var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2; - break; - case 'se': - var x = gridpos.x + plot._gridPadding.left + hl.tooltipOffset + fact * ms; - var y = gridpos.y + plot._gridPadding.top + hl.tooltipOffset + fact * ms; - break; - case 's': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2; - var y = gridpos.y + plot._gridPadding.top + hl.tooltipOffset + ms; - break; - case 'sw': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - hl.tooltipOffset - fact * ms; - var y = gridpos.y + plot._gridPadding.top + hl.tooltipOffset + fact * ms; - break; - case 'w': - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - hl.tooltipOffset - ms; - var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2; - break; - default: // same as 'nw' - var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - hl.tooltipOffset - fact * ms; - var y = gridpos.y + plot._gridPadding.top - hl.tooltipOffset - elem.outerHeight(true) - fact * ms; - break; - } - elem.css('left', x); - elem.css('top', y); - if (hl.fadeTooltip) { - // Fix for stacked up animations. Thnanks Trevor! - elem.stop(true,true).fadeIn(hl.tooltipFadeSpeed); - } - else { - elem.show(); - } - elem = null; - - } - - function handleMove(ev, gridpos, datapos, neighbor, plot) { - var hl = plot.plugins.highlighter; - var c = plot.plugins.cursor; - if (hl.show) { - if (neighbor == null && hl.isHighlighting) { - var ctx = hl.highlightCanvas._ctx; - ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); - if (hl.fadeTooltip) { - hl._tooltipElem.fadeOut(hl.tooltipFadeSpeed); - } - else { - hl._tooltipElem.hide(); - } - if (hl.bringSeriesToFront) { - plot.restorePreviousSeriesOrder(); - } - hl.isHighlighting = false; - ctx = null; - - } - else if (neighbor != null && plot.series[neighbor.seriesIndex].showHighlight && !hl.isHighlighting) { - hl.isHighlighting = true; - if (hl.showMarker) { - draw(plot, neighbor); - } - if (hl.showTooltip && (!c || !c._zoom.started)) { - showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor); - } - if (hl.bringSeriesToFront) { - plot.moveSeriesToFront(neighbor.seriesIndex); - } - } - } - } -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.json2.js b/libs/jqplot/plugins/jqplot.json2.js deleted file mode 100644 index 46fb942baa..0000000000 --- a/libs/jqplot/plugins/jqplot.json2.js +++ /dev/null @@ -1,475 +0,0 @@ -/* - 2010-11-01 Chris Leonello - - Slightly modified version of the original json2.js to put JSON - functions under the $.jqplot namespace. - - licensing and orignal comments follow: - - http://www.JSON.org/json2.js - 2010-08-25 - - Public Domain. - - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - - See http://www.JSON.org/js.html - - - This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html - - USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO - NOT CONTROL. - - - This file creates a global JSON object containing two methods: stringify - and parse. - - $.jqplot.JSON.stringify(value, replacer, space) - value any JavaScript value, usually an object or array. - - replacer an optional parameter that determines how object - values are stringified for objects. It can be a - function or an array of strings. - - space an optional parameter that specifies the indentation - of nested structures. If it is omitted, the text will - be packed without extra whitespace. If it is a number, - it will specify the number of spaces to indent at each - level. If it is a string (such as '\t' or ' '), - it contains the characters used to indent at each level. - - This method produces a JSON text from a JavaScript value. - - When an object value is found, if the object contains a toJSON - method, its toJSON method will be called and the result will be - stringified. A toJSON method does not serialize: it returns the - value represented by the name/value pair that should be serialized, - or undefined if nothing should be serialized. The toJSON method - will be passed the key associated with the value, and this will be - bound to the value - - For example, this would serialize Dates as ISO strings. - - Date.prototype.toJSON = function (key) { - function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; - } - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - You can provide an optional replacer method. It will be passed the - key and value of each member, with this bound to the containing - object. The value that is returned from your method will be - serialized. If your method returns undefined, then the member will - be excluded from the serialization. - - If the replacer parameter is an array of strings, then it will be - used to select the members to be serialized. It filters the results - such that only members with keys listed in the replacer array are - stringified. - - Values that do not have JSON representations, such as undefined or - functions, will not be serialized. Such values in objects will be - dropped; in arrays they will be replaced with null. You can use - a replacer function to replace those with JSON values. - $.jqplot.JSON.stringify(undefined) returns undefined. - - The optional space parameter produces a stringification of the - value that is filled with line breaks and indentation to make it - easier to read. - - If the space parameter is a non-empty string, then that string will - be used for indentation. If the space parameter is a number, then - the indentation will be that many spaces. - - Example: - - text = $.jqplot.JSON.stringify(['e', {pluribus: 'unum'}]); - // text is '["e",{"pluribus":"unum"}]' - - - text = $.jqplot.JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); - // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' - - text = $.jqplot.JSON.stringify([new Date()], function (key, value) { - return this[key] instanceof Date ? - 'Date(' + this[key] + ')' : value; - }); - // text is '["Date(---current time---)"]' - - - $.jqplot.JSON.parse(text, reviver) - This method parses a JSON text to produce an object or array. - It can throw a SyntaxError exception. - - The optional reviver parameter is a function that can filter and - transform the results. It receives each of the keys and values, - and its return value is used instead of the original value. - If it returns what it received, then the structure is not modified. - If it returns undefined then the member is deleted. - - Example: - - // Parse the text. Values that look like ISO date strings will - // be converted to Date objects. - - myData = $.jqplot.JSON.parse(text, function (key, value) { - var a; - if (typeof value === 'string') { - a = -/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); - if (a) { - return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], - +a[5], +a[6])); - } - } - return value; - }); - - myData = $.jqplot.JSON.parse('["Date(09/09/2001)"]', function (key, value) { - var d; - if (typeof value === 'string' && - value.slice(0, 5) === 'Date(' && - value.slice(-1) === ')') { - d = new Date(value.slice(5, -1)); - if (d) { - return d; - } - } - return value; - }); - - - This is a reference implementation. You are free to copy, modify, or - redistribute. -*/ - -(function($) { - - $.jqplot.JSON = window.JSON; - - if (!window.JSON) { - $.jqplot.JSON = {}; - } - - function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; - } - - if (typeof Date.prototype.toJSON !== 'function') { - - Date.prototype.toJSON = function (key) { - - return isFinite(this.valueOf()) ? - this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z' : null; - }; - - String.prototype.toJSON = - Number.prototype.toJSON = - Boolean.prototype.toJSON = function (key) { - return this.valueOf(); - }; - } - - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }, - rep; - - - function quote(string) { - -// If the string contains no control characters, no quote characters, and no -// backslash characters, then we can safely slap some quotes around it. -// Otherwise we must also replace the offending characters with safe escape -// sequences. - - escapable.lastIndex = 0; - return escapable.test(string) ? - '"' + string.replace(escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' ? c : - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : - '"' + string + '"'; - } - - - function str(key, holder) { - -// Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - -// If the value has a toJSON method, call it to obtain a replacement value. - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - -// If we were called with a replacer function, then call the replacer to -// obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - -// What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - -// JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - -// If the value is a boolean or null, convert it to a string. Note: -// typeof null does not produce 'null'. The case is included here in -// the remote chance that this gets fixed someday. - - return String(value); - -// If the type is 'object', we might be dealing with an object or an array or -// null. - - case 'object': - -// Due to a specification blunder in ECMAScript, typeof null is 'object', -// so watch out for that case. - - if (!value) { - return 'null'; - } - -// Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - -// Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - -// The value is an array. Stringify every element. Use null as a placeholder -// for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - -// Join all of the elements together, separated with commas, and wrap them in -// brackets. - - v = partial.length === 0 ? '[]' : - gap ? '[\n' + gap + - partial.join(',\n' + gap) + '\n' + - mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - -// If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - k = rep[i]; - if (typeof k === 'string') { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } else { - -// Otherwise, iterate through all of the keys in the object. - - for (k in value) { - if (Object.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - -// Join all of the member texts together, separated with commas, -// and wrap them in braces. - - v = partial.length === 0 ? '{}' : - gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + - mind + '}' : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } - } - -// If the JSON object does not yet have a stringify method, give it one. - - if (typeof $.jqplot.JSON.stringify !== 'function') { - $.jqplot.JSON.stringify = function (value, replacer, space) { - -// The stringify method takes a value and an optional replacer, and an optional -// space parameter, and returns a JSON text. The replacer can be a function -// that can replace values, or an array of strings that will select the keys. -// A default replacer method can be provided. Use of the space parameter can -// produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - -// If the space parameter is a number, make an indent string containing that -// many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - -// If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - -// If there is a replacer, it must be a function or an array. -// Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('$.jqplot.JSON.stringify'); - } - -// Make a fake root object containing our value under the key of ''. -// Return the result of stringifying the value. - - return str('', {'': value}); - }; - } - - -// If the JSON object does not yet have a parse method, give it one. - - if (typeof $.jqplot.JSON.parse !== 'function') { - $.jqplot.JSON.parse = function (text, reviver) { - -// The parse method takes a text and an optional reviver function, and returns -// a JavaScript value if the text is a valid JSON text. - - var j; - - function walk(holder, key) { - -// The walk method is used to recursively walk the resulting structure so -// that modifications can be made. - - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - } - - -// Parsing happens in four stages. In the first stage, we replace certain -// Unicode characters with escape sequences. JavaScript handles many characters -// incorrectly, either silently deleting them, or treating them as line endings. - - text = String(text); - cx.lastIndex = 0; - if (cx.test(text)) { - text = text.replace(cx, function (a) { - return '\\u' + - ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }); - } - -// In the second stage, we run the text against regular expressions that look -// for non-JSON patterns. We are especially concerned with '()' and 'new' -// because they can cause invocation, and '=' because it can cause mutation. -// But just to be safe, we want to reject all unexpected forms. - -// We split the second stage into 4 regexp operations in order to work around -// crippling inefficiencies in IE's and Safari's regexp engines. First we -// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we -// replace all simple value tokens with ']' characters. Third, we delete all -// open brackets that follow a colon or comma or that begin the text. Finally, -// we look to see that the remaining characters are only whitespace or ']' or -// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. - - if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { - -// In the third stage we use the eval function to compile the text into a -// JavaScript structure. The '{' operator is subject to a syntactic ambiguity -// in JavaScript: it can begin a block or an object literal. We wrap the text -// in parens to eliminate the ambiguity. - - j = eval('(' + text + ')'); - -// In the optional fourth stage, we recursively walk the new structure, passing -// each name/value pair to a reviver function for possible transformation. - - return typeof reviver === 'function' ? - walk({'': j}, '') : j; - } - -// If the text is not JSON parseable, then a SyntaxError is thrown. - - throw new SyntaxError('$.jqplot.JSON.parse'); - }; - } -})(jQuery); diff --git a/libs/jqplot/plugins/jqplot.logAxisRenderer.js b/libs/jqplot/plugins/jqplot.logAxisRenderer.js deleted file mode 100644 index 60bdb8a7f5..0000000000 --- a/libs/jqplot/plugins/jqplot.logAxisRenderer.js +++ /dev/null @@ -1,446 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * class: $.jqplot.LogAxisRenderer - * A plugin for a jqPlot to render a logarithmic axis. - * - * To use this renderer, include the plugin in your source - * > <script type="text/javascript" language="javascript" src="plugins/jqplot.logAxisRenderer.js"></script> - * - * and supply the appropriate options to your plot - * - * > {axes:{xaxis:{renderer:$.jqplot.LogAxisRenderer}}} - **/ - $.jqplot.LogAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - // prop: axisDefaults - // Default properties which will be applied directly to the series. - // - // Group: Properties - // - // Properties - // - /// base - the logarithmic base, commonly 2, 10 or Math.E - // tickDistribution - 'even' or 'power'. 'even' gives equal pixel - // spacing of the ticks on the plot. 'power' gives ticks in powers - // of 10. - this.axisDefaults = { - base : 10, - tickDistribution :'even' - }; - }; - - $.jqplot.LogAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.LogAxisRenderer.prototype.constructor = $.jqplot.LogAxisRenderer; - - $.jqplot.LogAxisRenderer.prototype.init = function(options) { - // prop: tickRenderer - // A class of a rendering engine for creating the ticks labels displayed on the plot, - // See <$.jqplot.AxisTickRenderer>. - // this.tickRenderer = $.jqplot.AxisTickRenderer; - // this.labelRenderer = $.jqplot.AxisLabelRenderer; - $.extend(true, this.renderer, options); - for (var d in this.renderer.axisDefaults) { - if (this[d] == null) { - this[d] = this.renderer.axisDefaults[d]; - } - } - var db = this._dataBounds; - // Go through all the series attached to this axis and find - // the min/max bounds for this axis. - for (var i=0; i<this._series.length; i++) { - var s = this._series[i]; - var d = s.data; - - for (var j=0; j<d.length; j++) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) { - db.min = d[j][0]; - } - if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) { - db.max = d[j][0]; - } - } - else { - if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) { - db.min = d[j][1]; - } - if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) { - db.max = d[j][1]; - } - } - } - } - }; - - $.jqplot.LogAxisRenderer.prototype.createTicks = function() { - // we're are operating on an axis here - var ticks = this._ticks; - var userTicks = this.ticks; - var name = this.name; - var db = this._dataBounds; - var dim, interval; - var min, max; - var pos1, pos2; - var tt, i; - - // if we already have ticks, use them. - // ticks must be in order of increasing value. - if (userTicks.length) { - // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed - for (i=0; i<userTicks.length; i++){ - var ut = userTicks[i]; - var t = new this.tickRenderer(this.tickOptions); - if (ut.constructor == Array) { - t.value = ut[0]; - t.label = ut[1]; - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(ut[0], this.name); - this._ticks.push(t); - } - - else { - t.value = ut; - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(ut, this.name); - this._ticks.push(t); - } - } - this.numberTicks = userTicks.length; - this.min = this._ticks[0].value; - this.max = this._ticks[this.numberTicks-1].value; - } - - // we don't have any ticks yet, let's make some! - else { - if (name == 'xaxis' || name == 'x2axis') { - dim = this._plotDimensions.width; - } - else { - dim = this._plotDimensions.height; - } - - min = ((this.min != null) ? this.min : db.min); - max = ((this.max != null) ? this.max : db.max); - - // if min and max are same, space them out a bit - if (min == max) { - var adj = 0.05; - min = min*(1-adj); - max = max*(1+adj); - } - - // perform some checks - if (this.min != null && this.min <= 0) { - throw('log axis minimum must be greater than 0'); - } - if (this.max != null && this.max <= 0) { - throw('log axis maximum must be greater than 0'); - } - // if (this.pad >1.99) this.pad = 1.99; - var range = max - min; - var rmin, rmax; - - if (this.tickDistribution == 'even') { - rmin = (this.min != null) ? this.min : min - min*((this.padMin-1)/2); - rmax = (this.max != null) ? this.max : max + max*((this.padMax-1)/2); - this.min = rmin; - this.max = rmax; - range = this.max - this.min; - - if (this.numberTicks == null){ - if (dim > 100) { - this.numberTicks = parseInt(3+(dim-100)/75, 10); - } - else { - this.numberTicks = 2; - } - } - - var u = Math.pow(this.base, (1/(this.numberTicks-1)*Math.log(this.max/this.min)/Math.log(this.base))); - for (var i=0; i<this.numberTicks; i++){ - tt = this.min * Math.pow(u, i); - var t = new this.tickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(tt, this.name); - this._ticks.push(t); - } - - } - - else if (this.tickDistribution == 'power'){ - // for power distribution, open up range to get a nice power of axis.renderer.base. - // power distribution won't respect the user's min/max settings. - rmin = Math.pow(this.base, Math.ceil(Math.log(min*(2-this.padMin))/Math.log(this.base))-1); - rmax = Math.pow(this.base, Math.floor(Math.log(max*this.padMax)/Math.log(this.base))+1); - this.min = rmin; - this.max = rmax; - range = this.max - this.min; - - var fittedTicks = 0; - var minorTicks = 0; - if (this.numberTicks == null){ - if (dim > 100) { - this.numberTicks = Math.round(Math.log(this.max/this.min)/Math.log(this.base) + 1); - if (this.numberTicks < 2) { - this.numberTicks = 2; - } - fittedTicks = parseInt(3+(dim-100)/75, 10); - } - else { - this.numberTicks = 2; - fittedTicks = 2; - } - // if we don't have enough ticks, add some intermediate ticks - // how many to have between major ticks. - if (this.numberTicks < fittedTicks-1) { - minorTicks = Math.floor(fittedTicks/this.numberTicks); - } - } - - for (var i=0; i<this.numberTicks; i++){ - tt = Math.pow(this.base, i - this.numberTicks + 1) * this.max; - var t = new this.tickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(tt, this.name); - this._ticks.push(t); - - if (minorTicks && i<this.numberTicks-1) { - var tt1 = Math.pow(this.base, i - this.numberTicks + 2) * this.max; - var spread = tt1 - tt; - var interval = tt1 / (minorTicks+1); - for (var j=minorTicks-1; j>=0; j--) { - var val = tt1-interval*(j+1); - var t = new this.tickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(val, this.name); - this._ticks.push(t); - } - } - } - } - } - }; - - $.jqplot.LogAxisRenderer.prototype.pack = function(pos, offsets) { - var lb = parseInt(this.base, 10); - var ticks = this._ticks; - var trans = function (v) { return Math.log(v)/Math.log(lb); }; - var invtrans = function (v) { return Math.pow(Math.E, (Math.log(lb)*v)); }; - var max = trans(this.max); - var min = trans(this.min); - var offmax = offsets.max; - var offmin = offsets.min; - var lshow = (this._label == null) ? false : this._label.show; - - for (var p in pos) { - this._elem.css(p, pos[p]); - } - - this._offsets = offsets; - // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left. - var pixellength = offmax - offmin; - var unitlength = max - min; - - // point to unit and unit to point conversions references to Plot DOM element top left corner. - this.p2u = function(p){ - return invtrans((p - offmin) * unitlength / pixellength + min); - }; - - this.u2p = function(u){ - return (trans(u) - min) * pixellength / unitlength + offmin; - }; - - if (this.name == 'xaxis' || this.name == 'x2axis'){ - this.series_u2p = function(u){ - return (trans(u) - min) * pixellength / unitlength; - }; - this.series_p2u = function(p){ - return invtrans(p * unitlength / pixellength + min); - }; - } - // yaxis is max at top of canvas. - else { - this.series_u2p = function(u){ - return (trans(u) - max) * pixellength / unitlength; - }; - this.series_p2u = function(p){ - return invtrans(p * unitlength / pixellength + max); - }; - } - - if (this.show) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - for (var i=0; i<ticks.length; i++) { - var t = ticks[i]; - if (t.show && t.showLabel) { - var shim; - - if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { - switch (t.labelPosition) { - case 'auto': - // position at end - if (t.angle < 0) { - shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - } - // position at start - else { - shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; - } - break; - case 'end': - shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - break; - case 'start': - shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; - break; - case 'middle': - shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - break; - default: - shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - break; - } - } - else { - shim = -t.getWidth()/2; - } - // var shim = t.getWidth()/2; - var val = this.u2p(t.value) + shim + 'px'; - t._elem.css('left', val); - t.pack(); - } - } - if (lshow) { - var w = this._label._elem.outerWidth(true); - this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px'); - if (this.name == 'xaxis') { - this._label._elem.css('bottom', '0px'); - } - else { - this._label._elem.css('top', '0px'); - } - this._label.pack(); - } - } - else { - for (var i=0; i<ticks.length; i++) { - var t = ticks[i]; - if (t.show && t.showLabel) { - var shim; - if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { - switch (t.labelPosition) { - case 'auto': - // position at end - case 'end': - if (t.angle < 0) { - shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; - } - else { - shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; - } - break; - case 'start': - if (t.angle > 0) { - shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; - } - else { - shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; - } - break; - case 'middle': - // if (t.angle > 0) { - // shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - // } - // else { - // shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; - // } - shim = -t.getHeight()/2; - break; - default: - shim = -t.getHeight()/2; - break; - } - } - else { - shim = -t.getHeight()/2; - } - - var val = this.u2p(t.value) + shim + 'px'; - t._elem.css('top', val); - t.pack(); - } - } - if (lshow) { - var h = this._label._elem.outerHeight(true); - this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px'); - if (this.name == 'yaxis') { - this._label._elem.css('left', '0px'); - } - else { - this._label._elem.css('right', '0px'); - } - this._label.pack(); - } - } - } - }; -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.mekkoAxisRenderer.js b/libs/jqplot/plugins/jqplot.mekkoAxisRenderer.js deleted file mode 100644 index 8cb65d82ab..0000000000 --- a/libs/jqplot/plugins/jqplot.mekkoAxisRenderer.js +++ /dev/null @@ -1,610 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - // class: $.jqplot.MekkoAxisRenderer - // An axis renderer for a Mekko chart. - // Should be used with a Mekko chart where the mekkoRenderer is used on the series. - // Displays the Y axis as a range from 0 to 1 (0 to 100%) and the x axis with a tick - // for each series scaled to the sum of all the y values. - $.jqplot.MekkoAxisRenderer = function() { - }; - - // called with scope of axis object. - $.jqplot.MekkoAxisRenderer.prototype.init = function(options){ - // prop: tickMode - // How to space the ticks on the axis. - // 'bar' will place a tick at the width of each bar. - // This is the default for the x axis. - // 'even' will place ticks at even intervals. This is - // the default for x2 axis and y axis. y axis cannot be changed. - this.tickMode; - // prop: barLabelRenderer - // renderer to use to draw labels under each bar. - this.barLabelRenderer = $.jqplot.AxisLabelRenderer; - // prop: barLabels - // array of labels to put under each bar. - this.barLabels = this.barLabels || []; - // prop: barLabelOptions - // options object to pass to the bar label renderer. - this.barLabelOptions = {}; - this.tickOptions = $.extend(true, {showGridline:false}, this.tickOptions); - this._barLabels = []; - $.extend(true, this, options); - if (this.name == 'yaxis') { - this.tickOptions.formatString = this.tickOptions.formatString || "%d\%"; - } - var db = this._dataBounds; - db.min = 0; - // for y axes, scale always go from 0 to 1 (0 to 100%) - if (this.name == 'yaxis' || this.name == 'y2axis') { - db.max = 100; - this.tickMode = 'even'; - } - // For x axes, scale goes from 0 to sum of all y values. - else if (this.name == 'xaxis'){ - this.tickMode = (this.tickMode == null) ? 'bar' : this.tickMode; - for (var i=0; i<this._series.length; i++) { - db.max += this._series[i]._sumy; - } - } - else if (this.name == 'x2axis'){ - this.tickMode = (this.tickMode == null) ? 'even' : this.tickMode; - for (var i=0; i<this._series.length; i++) { - db.max += this._series[i]._sumy; - } - } - }; - - // called with scope of axis - $.jqplot.MekkoAxisRenderer.prototype.draw = function(ctx) { - if (this.show) { - // populate the axis label and value properties. - // createTicks is a method on the renderer, but - // call it within the scope of the axis. - this.renderer.createTicks.call(this); - // fill a div with axes labels in the right direction. - // Need to pregenerate each axis to get it's bounds and - // position it and the labels correctly on the plot. - var dim=0; - var temp; - - var elem = document.createElement('div'); - this._elem = $(elem); - this._elem.addClass('jqplot-axis jqplot-'+this.name); - this._elem.css('position', 'absolute'); - elem = null; - - if (this.name == 'xaxis' || this.name == 'x2axis') { - this._elem.width(this._plotDimensions.width); - } - else { - this._elem.height(this._plotDimensions.height); - } - - // draw the axis label - // create a _label object. - this.labelOptions.axis = this.name; - this._label = new this.labelRenderer(this.labelOptions); - if (this._label.show) { - this._elem.append(this._label.draw(ctx)); - } - - var t, tick, elem; - if (this.showTicks) { - t = this._ticks; - for (var i=0; i<t.length; i++) { - tick = t[i]; - if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { - this._elem.append(tick.draw(ctx)); - } - } - } - - // draw the series labels - for (i=0; i<this.barLabels.length; i++) { - this.barLabelOptions.axis = this.name; - this.barLabelOptions.label = this.barLabels[i]; - this._barLabels.push(new this.barLabelRenderer(this.barLabelOptions)); - if (this.tickMode != 'bar') { - this._barLabels[i].show = false; - } - if (this._barLabels[i].show) { - var elem = this._barLabels[i].draw(ctx); - elem.removeClass('jqplot-'+this.name+'-label'); - elem.addClass('jqplot-'+this.name+'-tick'); - elem.addClass('jqplot-mekko-barLabel'); - elem.appendTo(this._elem); - elem = null; - } - } - - } - return this._elem; - }; - - // called with scope of an axis - $.jqplot.MekkoAxisRenderer.prototype.reset = function() { - this.min = this._min; - this.max = this._max; - this.tickInterval = this._tickInterval; - this.numberTicks = this._numberTicks; - // this._ticks = this.__ticks; - }; - - // called with scope of axis - $.jqplot.MekkoAxisRenderer.prototype.set = function() { - var dim = 0; - var temp; - var w = 0; - var h = 0; - var lshow = (this._label == null) ? false : this._label.show; - if (this.show && this.showTicks) { - var t = this._ticks; - for (var i=0; i<t.length; i++) { - var tick = t[i]; - if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - temp = tick._elem.outerHeight(true); - } - else { - temp = tick._elem.outerWidth(true); - } - if (temp > dim) { - dim = temp; - } - } - } - - if (lshow) { - w = this._label._elem.outerWidth(true); - h = this._label._elem.outerHeight(true); - } - if (this.name == 'xaxis') { - dim = dim + h; - this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'}); - } - else if (this.name == 'x2axis') { - dim = dim + h; - this._elem.css({'height':dim+'px', left:'0px', top:'0px'}); - } - else if (this.name == 'yaxis') { - dim = dim + w; - this._elem.css({'width':dim+'px', left:'0px', top:'0px'}); - if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { - this._label._elem.css('width', w+'px'); - } - } - else { - dim = dim + w; - this._elem.css({'width':dim+'px', right:'0px', top:'0px'}); - if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { - this._label._elem.css('width', w+'px'); - } - } - } - }; - - // called with scope of axis - $.jqplot.MekkoAxisRenderer.prototype.createTicks = function() { - // we're are operating on an axis here - var ticks = this._ticks; - var userTicks = this.ticks; - var name = this.name; - // databounds were set on axis initialization. - var db = this._dataBounds; - var dim, interval; - var min, max; - var pos1, pos2; - var t, tt, i, j; - - // if we already have ticks, use them. - // ticks must be in order of increasing value. - - if (userTicks.length) { - // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed - for (i=0; i<userTicks.length; i++){ - var ut = userTicks[i]; - var t = new this.tickRenderer(this.tickOptions); - if (ut.constructor == Array) { - t.value = ut[0]; - t.label = ut[1]; - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(ut[0], this.name); - this._ticks.push(t); - } - - else { - t.value = ut; - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(ut, this.name); - this._ticks.push(t); - } - } - this.numberTicks = userTicks.length; - this.min = this._ticks[0].value; - this.max = this._ticks[this.numberTicks-1].value; - this.tickInterval = (this.max - this.min) / (this.numberTicks - 1); - } - - // we don't have any ticks yet, let's make some! - else { - if (name == 'xaxis' || name == 'x2axis') { - dim = this._plotDimensions.width; - } - else { - dim = this._plotDimensions.height; - } - - // if min, max and number of ticks specified, user can't specify interval. - if (this.min != null && this.max != null && this.numberTicks != null) { - this.tickInterval = null; - } - - min = (this.min != null) ? this.min : db.min; - max = (this.max != null) ? this.max : db.max; - - // if min and max are same, space them out a bit.+ - if (min == max) { - var adj = 0.05; - if (min > 0) { - adj = Math.max(Math.log(min)/Math.LN10, 0.05); - } - min -= adj; - max += adj; - } - - var range = max - min; - var rmin, rmax; - var temp, prev, curr; - var ynumticks = [3,5,6,11,21]; - - // yaxis divide ticks in nice intervals from 0 to 1. - if (this.name == 'yaxis' || this.name == 'y2axis') { - this.min = 0; - this.max = 100; - // user didn't specify number of ticks. - if (!this.numberTicks){ - if (this.tickInterval) { - this.numberTicks = 3 + Math.ceil(range / this.tickInterval); - } - else { - temp = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); - for (i=0; i<ynumticks.length; i++) { - curr = temp/ynumticks[i]; - if (curr == 1) { - this.numberTicks = ynumticks[i]; - break; - } - else if (curr > 1) { - prev = curr; - continue; - } - else if (curr < 1) { - // was prev or is curr closer to one? - if (Math.abs(prev - 1) < Math.abs(curr - 1)) { - this.numberTicks = ynumticks[i-1]; - break; - } - else { - this.numberTicks = ynumticks[i]; - break; - } - } - else if (i == ynumticks.length -1) { - this.numberTicks = ynumticks[i]; - } - } - this.tickInterval = range / (this.numberTicks - 1); - } - } - - // user did specify number of ticks. - else { - this.tickInterval = range / (this.numberTicks - 1); - } - - for (var i=0; i<this.numberTicks; i++){ - tt = this.min + i * this.tickInterval; - t = new this.tickRenderer(this.tickOptions); - // var t = new $.jqplot.AxisTickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(tt, this.name); - this._ticks.push(t); - } - } - - // for x axes, have number ot ticks equal to number of series and ticks placed - // at sum of y values for each series. - else if (this.tickMode == 'bar') { - this.min = 0; - this.numberTicks = this._series.length + 1; - t = new this.tickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(0, this.name); - this._ticks.push(t); - - temp = 0; - - for (i=1; i<this.numberTicks; i++){ - temp += this._series[i-1]._sumy; - t = new this.tickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(temp, this.name); - this._ticks.push(t); - } - this.max = this.max || temp; - - // if user specified a max and it is greater than sum, add a tick - if (this.max > temp) { - t = new this.tickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(this.max, this.name); - this._ticks.push(t); - - } - } - - else if (this.tickMode == 'even') { - this.min = 0; - this.max = this.max || db.max; - // get a desired number of ticks - var nt = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); - range = this.max - this.min; - this.numberTicks = nt; - this.tickInterval = range / (this.numberTicks - 1); - - for (i=0; i<this.numberTicks; i++){ - tt = this.min + i * this.tickInterval; - t = new this.tickRenderer(this.tickOptions); - // var t = new $.jqplot.AxisTickRenderer(this.tickOptions); - if (!this.showTicks) { - t.showLabel = false; - t.showMark = false; - } - else if (!this.showTickMarks) { - t.showMark = false; - } - t.setTick(tt, this.name); - this._ticks.push(t); - } - - } - } - }; - - // called with scope of axis - $.jqplot.MekkoAxisRenderer.prototype.pack = function(pos, offsets) { - var ticks = this._ticks; - var max = this.max; - var min = this.min; - var offmax = offsets.max; - var offmin = offsets.min; - var lshow = (this._label == null) ? false : this._label.show; - - for (var p in pos) { - this._elem.css(p, pos[p]); - } - - this._offsets = offsets; - // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left. - var pixellength = offmax - offmin; - var unitlength = max - min; - - // point to unit and unit to point conversions references to Plot DOM element top left corner. - this.p2u = function(p){ - return (p - offmin) * unitlength / pixellength + min; - }; - - this.u2p = function(u){ - return (u - min) * pixellength / unitlength + offmin; - }; - - if (this.name == 'xaxis' || this.name == 'x2axis'){ - this.series_u2p = function(u){ - return (u - min) * pixellength / unitlength; - }; - this.series_p2u = function(p){ - return p * unitlength / pixellength + min; - }; - } - - else { - this.series_u2p = function(u){ - return (u - max) * pixellength / unitlength; - }; - this.series_p2u = function(p){ - return p * unitlength / pixellength + max; - }; - } - - if (this.show) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - for (var i=0; i<ticks.length; i++) { - var t = ticks[i]; - if (t.show && t.showLabel) { - var shim; - - if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { - // will need to adjust auto positioning based on which axis this is. - var temp = (this.name == 'xaxis') ? 1 : -1; - switch (t.labelPosition) { - case 'auto': - // position at end - if (temp * t.angle < 0) { - shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - } - // position at start - else { - shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; - } - break; - case 'end': - shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - break; - case 'start': - shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; - break; - case 'middle': - shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - break; - default: - shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; - break; - } - } - else { - shim = -t.getWidth()/2; - } - var val = this.u2p(t.value) + shim + 'px'; - t._elem.css('left', val); - t.pack(); - } - } - var w; - if (lshow) { - w = this._label._elem.outerWidth(true); - this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px'); - if (this.name == 'xaxis') { - this._label._elem.css('bottom', '0px'); - } - else { - this._label._elem.css('top', '0px'); - } - this._label.pack(); - } - // now show the labels under the bars. - var b, l, r; - for (var i=0; i<this.barLabels.length; i++) { - b = this._barLabels[i]; - if (b.show) { - w = b.getWidth(); - l = this._ticks[i].getLeft() + this._ticks[i].getWidth(); - r = this._ticks[i+1].getLeft(); - b._elem.css('left', (r+l-w)/2+'px'); - b._elem.css('top', this._ticks[i]._elem.css('top')); - b.pack(); - } - } - } - else { - for (var i=0; i<ticks.length; i++) { - var t = ticks[i]; - if (t.show && t.showLabel) { - var shim; - if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { - // will need to adjust auto positioning based on which axis this is. - var temp = (this.name == 'yaxis') ? 1 : -1; - switch (t.labelPosition) { - case 'auto': - // position at end - case 'end': - if (temp * t.angle < 0) { - shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; - } - else { - shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; - } - break; - case 'start': - if (t.angle > 0) { - shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; - } - else { - shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; - } - break; - case 'middle': - shim = -t.getHeight()/2; - break; - default: - shim = -t.getHeight()/2; - break; - } - } - else { - shim = -t.getHeight()/2; - } - - var val = this.u2p(t.value) + shim + 'px'; - t._elem.css('top', val); - t.pack(); - } - } - if (lshow) { - var h = this._label._elem.outerHeight(true); - this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px'); - if (this.name == 'yaxis') { - this._label._elem.css('left', '0px'); - } - else { - this._label._elem.css('right', '0px'); - } - this._label.pack(); - } - } - } - }; -})(jQuery); diff --git a/libs/jqplot/plugins/jqplot.mekkoRenderer.js b/libs/jqplot/plugins/jqplot.mekkoRenderer.js deleted file mode 100644 index b93bc60aad..0000000000 --- a/libs/jqplot/plugins/jqplot.mekkoRenderer.js +++ /dev/null @@ -1,436 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.MekkoRenderer - * Draws a Mekko style chart which shows 3 dimensional data on a 2 dimensional graph. - * the <$.jqplot.MekkoAxisRenderer> should be used with mekko charts. The mekko renderer - * overrides the default legend renderer with it's own $.jqplot.MekkoLegendRenderer - * which allows more flexibility to specify number of rows and columns in the legend. - * - * Data is specified per bar in the chart. You can specify data as an array of y values, or as - * an array of [label, value] pairs. Note that labels are used only on the first series. - * Labels on subsequent series are ignored: - * - * > bar1 = [['shirts', 8],['hats', 14],['shoes', 6],['gloves', 16],['dolls', 12]]; - * > bar2 = [15,6,9,13,6]; - * > bar3 = [['grumpy',4],['sneezy',2],['happy',7],['sleepy',9],['doc',7]]; - * - * If you want to place labels for each bar under the axis, you use the barLabels option on - * the axes. The bar labels can be styled with the ".jqplot-mekko-barLabel" css class. - * - * > barLabels = ['Mickey Mouse', 'Donald Duck', 'Goofy']; - * > axes:{xaxis:{barLabels:barLabels}} - * - */ - - - $.jqplot.MekkoRenderer = function(){ - this.shapeRenderer = new $.jqplot.ShapeRenderer(); - // prop: borderColor - // color of the borders between areas on the chart - this.borderColor = null; - // prop: showBorders - // True to draw borders lines between areas on the chart. - // False will draw borders lines with the same color as the area. - this.showBorders = true; - }; - - // called with scope of series. - $.jqplot.MekkoRenderer.prototype.init = function(options, plot) { - this.fill = false; - this.fillRect = true; - this.strokeRect = true; - this.shadow = false; - // width of bar on x axis. - this._xwidth = 0; - this._xstart = 0; - $.extend(true, this.renderer, options); - // set the shape renderer options - var opts = {lineJoin:'miter', lineCap:'butt', isarc:false, fillRect:this.fillRect, strokeRect:this.strokeRect}; - this.renderer.shapeRenderer.init(opts); - plot.axes.x2axis._series.push(this); - this._type = 'mekko'; - }; - - // Method: setGridData - // converts the user data values to grid coordinates and stores them - // in the gridData array. Will convert user data into appropriate - // rectangles. - // Called with scope of a series. - $.jqplot.MekkoRenderer.prototype.setGridData = function(plot) { - // recalculate the grid data - var xp = this._xaxis.series_u2p; - var yp = this._yaxis.series_u2p; - var data = this._plotData; - this.gridData = []; - // figure out width on x axis. - // this._xwidth = this._sumy / plot._sumy * this.canvas.getWidth(); - this._xwidth = xp(this._sumy) - xp(0); - if (this.index>0) { - this._xstart = plot.series[this.index-1]._xstart + plot.series[this.index-1]._xwidth; - } - var totheight = this.canvas.getHeight(); - var sumy = 0; - var cury; - var curheight; - for (var i=0; i<data.length; i++) { - if (data[i] != null) { - sumy += data[i][1]; - cury = totheight - (sumy / this._sumy * totheight); - curheight = data[i][1] / this._sumy * totheight; - this.gridData.push([this._xstart, cury, this._xwidth, curheight]); - } - } - }; - - // Method: makeGridData - // converts any arbitrary data values to grid coordinates and - // returns them. This method exists so that plugins can use a series' - // linerenderer to generate grid data points without overwriting the - // grid data associated with that series. - // Called with scope of a series. - $.jqplot.MekkoRenderer.prototype.makeGridData = function(data, plot) { - // recalculate the grid data - // figure out width on x axis. - var xp = this._xaxis.series_u2p; - var totheight = this.canvas.getHeight(); - var sumy = 0; - var cury; - var curheight; - var gd = []; - for (var i=0; i<data.length; i++) { - if (data[i] != null) { - sumy += data[i][1]; - cury = totheight - (sumy / this._sumy * totheight); - curheight = data[i][1] / this._sumy * totheight; - gd.push([this._xstart, cury, this._xwidth, curheight]); - } - } - return gd; - }; - - - // called within scope of series. - $.jqplot.MekkoRenderer.prototype.draw = function(ctx, gd, options) { - var i; - var opts = (options != undefined) ? options : {}; - var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; - var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors); - ctx.save(); - if (gd.length) { - if (showLine) { - for (i=0; i<gd.length; i++){ - opts.fillStyle = colorGenerator.next(); - if (this.renderer.showBorders) { - opts.strokeStyle = this.renderer.borderColor; - } - else { - opts.strokeStyle = opts.fillStyle; - } - this.renderer.shapeRenderer.draw(ctx, gd[i], opts); - } - } - } - - ctx.restore(); - }; - - $.jqplot.MekkoRenderer.prototype.drawShadow = function(ctx, gd, options) { - // This is a no-op, no shadows on mekko charts. - }; - - /** - * Class: $.jqplot.MekkoLegendRenderer - * Legend renderer used by mekko charts with options for - * controlling number or rows and columns as well as placement - * outside of plot area. - * - */ - $.jqplot.MekkoLegendRenderer = function(){ - // - }; - - $.jqplot.MekkoLegendRenderer.prototype.init = function(options) { - // prop: numberRows - // Maximum number of rows in the legend. 0 or null for unlimited. - this.numberRows = null; - // prop: numberColumns - // Maximum number of columns in the legend. 0 or null for unlimited. - this.numberColumns = null; - // this will override the placement option on the Legend object - this.placement = "outside"; - $.extend(true, this, options); - }; - - // called with scope of legend - $.jqplot.MekkoLegendRenderer.prototype.draw = function() { - var legend = this; - if (this.show) { - var series = this._series; - var ss = 'position:absolute;'; - ss += (this.background) ? 'background:'+this.background+';' : ''; - ss += (this.border) ? 'border:'+this.border+';' : ''; - ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : ''; - ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : ''; - ss += (this.textColor) ? 'color:'+this.textColor+';' : ''; - this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>'); - // Mekko charts legends don't go by number of series, but by number of data points - // in the series. Refactor things here for that. - - var pad = false, - reverse = true, // mekko charts are always stacked, so reverse - nr, nc; - var s = series[0]; - var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors); - - if (s.show) { - var pd = s.data; - if (this.numberRows) { - nr = this.numberRows; - if (!this.numberColumns){ - nc = Math.ceil(pd.length/nr); - } - else{ - nc = this.numberColumns; - } - } - else if (this.numberColumns) { - nc = this.numberColumns; - nr = Math.ceil(pd.length/this.numberColumns); - } - else { - nr = pd.length; - nc = 1; - } - - var i, j, tr, td1, td2, lt, rs, color; - var idx = 0; - - for (i=0; i<nr; i++) { - if (reverse){ - tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem); - } - else{ - tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem); - } - for (j=0; j<nc; j++) { - if (idx < pd.length) { - lt = this.labels[idx] || pd[idx][0].toString(); - color = colorGenerator.next(); - if (!reverse){ - if (i>0){ - pad = true; - } - else{ - pad = false; - } - } - else{ - if (i == nr -1){ - pad = false; - } - else{ - pad = true; - } - } - rs = (pad) ? this.rowSpacing : '0'; - - td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+ - '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+ - '</div></td>'); - td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>'); - if (this.escapeHtml){ - td2.text(lt); - } - else { - td2.html(lt); - } - if (reverse) { - td2.prependTo(tr); - td1.prependTo(tr); - } - else { - td1.appendTo(tr); - td2.appendTo(tr); - } - pad = true; - } - idx++; - } - } - - tr = null; - td1 = null; - td2 = null; - } - } - return this._elem; - }; - - $.jqplot.MekkoLegendRenderer.prototype.pack = function(offsets) { - if (this.show) { - // fake a grid for positioning - var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom}; - if (this.placement == 'insideGrid') { - switch (this.location) { - case 'nw': - var a = grid._left + this.xoffset; - var b = grid._top + this.yoffset; - this._elem.css('left', a); - this._elem.css('top', b); - break; - case 'n': - var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - var b = grid._top + this.yoffset; - this._elem.css('left', a); - this._elem.css('top', b); - break; - case 'ne': - var a = offsets.right + this.xoffset; - var b = grid._top + this.yoffset; - this._elem.css({right:a, top:b}); - break; - case 'e': - var a = offsets.right + this.xoffset; - var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - this._elem.css({right:a, top:b}); - break; - case 'se': - var a = offsets.right + this.xoffset; - var b = offsets.bottom + this.yoffset; - this._elem.css({right:a, bottom:b}); - break; - case 's': - var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - var b = offsets.bottom + this.yoffset; - this._elem.css({left:a, bottom:b}); - break; - case 'sw': - var a = grid._left + this.xoffset; - var b = offsets.bottom + this.yoffset; - this._elem.css({left:a, bottom:b}); - break; - case 'w': - var a = grid._left + this.xoffset; - var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - this._elem.css({left:a, top:b}); - break; - default: // same as 'se' - var a = grid._right - this.xoffset; - var b = grid._bottom + this.yoffset; - this._elem.css({right:a, bottom:b}); - break; - } - - } - else { - switch (this.location) { - case 'nw': - var a = this._plotDimensions.width - grid._left + this.xoffset; - var b = grid._top + this.yoffset; - this._elem.css('right', a); - this._elem.css('top', b); - break; - case 'n': - var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - var b = this._plotDimensions.height - grid._top + this.yoffset; - this._elem.css('left', a); - this._elem.css('bottom', b); - break; - case 'ne': - var a = this._plotDimensions.width - offsets.right + this.xoffset; - var b = grid._top + this.yoffset; - this._elem.css({left:a, top:b}); - break; - case 'e': - var a = this._plotDimensions.width - offsets.right + this.xoffset; - var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - this._elem.css({left:a, top:b}); - break; - case 'se': - var a = this._plotDimensions.width - offsets.right + this.xoffset; - var b = offsets.bottom + this.yoffset; - this._elem.css({left:a, bottom:b}); - break; - case 's': - var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - var b = this._plotDimensions.height - offsets.bottom + this.yoffset; - this._elem.css({left:a, top:b}); - break; - case 'sw': - var a = this._plotDimensions.width - grid._left + this.xoffset; - var b = offsets.bottom + this.yoffset; - this._elem.css({right:a, bottom:b}); - break; - case 'w': - var a = this._plotDimensions.width - grid._left + this.xoffset; - var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - this._elem.css({right:a, top:b}); - break; - default: // same as 'se' - var a = grid._right - this.xoffset; - var b = grid._bottom + this.yoffset; - this._elem.css({right:a, bottom:b}); - break; - } - } - } - }; - - // setup default renderers for axes and legend so user doesn't have to - // called with scope of plot - function preInit(target, data, options) { - options = options || {}; - options.axesDefaults = options.axesDefaults || {}; - options.legend = options.legend || {}; - options.seriesDefaults = options.seriesDefaults || {}; - var setopts = false; - if (options.seriesDefaults.renderer == $.jqplot.MekkoRenderer) { - setopts = true; - } - else if (options.series) { - for (var i=0; i < options.series.length; i++) { - if (options.series[i].renderer == $.jqplot.MekkoRenderer) { - setopts = true; - } - } - } - - if (setopts) { - options.axesDefaults.renderer = $.jqplot.MekkoAxisRenderer; - options.legend.renderer = $.jqplot.MekkoLegendRenderer; - options.legend.preDraw = true; - } - } - - $.jqplot.preInitHooks.push(preInit); - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.meterGaugeRenderer.js b/libs/jqplot/plugins/jqplot.meterGaugeRenderer.js deleted file mode 100644 index 7a8e5f6494..0000000000 --- a/libs/jqplot/plugins/jqplot.meterGaugeRenderer.js +++ /dev/null @@ -1,1142 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.MeterGaugeRenderer - * Plugin renderer to draw a meter gauge chart. - * - * Data consists of a single series with 1 data point to position the gauge needle. - * - * To use this renderer, you need to include the - * meter gauge renderer plugin, for example: - * - * > <script type="text/javascript" src="plugins/jqplot.meterGaugeRenderer.js"></script> - * - * Properties described here are passed into the $.jqplot function - * as options on the series renderer. For example: - * - * > plot0 = $.jqplot('chart0',[[18]],{ - * > title: 'Network Speed', - * > seriesDefaults: { - * > renderer: $.jqplot.MeterGaugeRenderer, - * > rendererOptions: { - * > label: 'MB/s' - * > } - * > } - * > }); - * - * A meterGauge plot does not support events. - */ - $.jqplot.MeterGaugeRenderer = function(){ - $.jqplot.LineRenderer.call(this); - }; - - $.jqplot.MeterGaugeRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.MeterGaugeRenderer.prototype.constructor = $.jqplot.MeterGaugeRenderer; - - // called with scope of a series - $.jqplot.MeterGaugeRenderer.prototype.init = function(options) { - // Group: Properties - // - // prop: diameter - // Outer diameter of the meterGauge, auto computed by default - this.diameter = null; - // prop: padding - // padding between the meterGauge and plot edges, auto - // calculated by default. - this.padding = null; - // prop: shadowOffset - // offset of the shadow from the gauge ring and offset of - // each succesive stroke of the shadow from the last. - this.shadowOffset = 2; - // prop: shadowAlpha - // transparency of the shadow (0 = transparent, 1 = opaque) - this.shadowAlpha = 0.07; - // prop: shadowDepth - // number of strokes to apply to the shadow, - // each stroke offset shadowOffset from the last. - this.shadowDepth = 4; - // prop: background - // background color of the inside of the gauge. - this.background = "#efefef"; - // prop: ringColor - // color of the outer ring, hub, and needle of the gauge. - this.ringColor = "#BBC6D0"; - // needle color not implemented yet. - this.needleColor = "#C3D3E5"; - // prop: tickColor - // color of the tick marks around the gauge. - this.tickColor = "989898"; - // prop: ringWidth - // width of the ring around the gauge. Auto computed by default. - this.ringWidth = null; - // prop: min - // Minimum value on the gauge. Auto computed by default - this.min; - // prop: max - // Maximum value on the gauge. Auto computed by default - this.max; - // prop: ticks - // Array of tick values. Auto computed by default. - this.ticks = []; - // prop: showTicks - // true to show ticks around gauge. - this.showTicks = true; - // prop: showTickLabels - // true to show tick labels next to ticks. - this.showTickLabels = true; - // prop: label - // A gauge label like 'kph' or 'Volts' - this.label = null; - // prop: labelHeightAdjust - // Number of Pixels to offset the label up (-) or down (+) from its default position. - this.labelHeightAdjust = 0; - // prop: labelPosition - // Where to position the label, either 'inside' or 'bottom'. - this.labelPosition = 'inside'; - // prop: intervals - // Array of ranges to be drawn around the gauge. - // Array of form: - // > [value1, value2, ...] - // indicating the values for the first, second, ... intervals. - this.intervals = []; - // prop: intervalColors - // Array of colors to use for the intervals. - this.intervalColors = [ "#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"]; - // prop: intervalInnerRadius - // Radius of the inner circle of the interval ring. - this.intervalInnerRadius = null; - // prop: intervalOuterRadius - // Radius of the outer circle of the interval ring. - this.intervalOuterRadius = null; - this.tickRenderer = $.jqplot.MeterGaugeTickRenderer; - // ticks spaced every 1, 2, 2.5, 5, 10, 20, .1, .2, .25, .5, etc. - this.tickPositions = [1, 2, 2.5, 5, 10]; - // prop: tickSpacing - // Degrees between ticks. This is a target number, if - // incompatible span and ticks are supplied, a suitable - // spacing close to this value will be computed. - this.tickSpacing = 30; - this.numberMinorTicks = null; - // prop: hubRadius - // Radius of the hub at the bottom center of gauge which the needle attaches to. - // Auto computed by default - this.hubRadius = null; - // prop: tickPadding - // padding of the tick marks to the outer ring and the tick labels to marks. - // Auto computed by default. - this.tickPadding = null; - // prop: needleThickness - // Maximum thickness the needle. Auto computed by default. - this.needleThickness = null; - // prop: needlePad - // Padding between needle and inner edge of the ring when the needle is at the min or max gauge value. - this.needlePad = 6; - // prop: pegNeedle - // True will stop needle just below/above the min/max values if data is below/above min/max, - // as if the meter is "pegged". - this.pegNeedle = true; - this._type = 'meterGauge'; - - $.extend(true, this, options); - this.type = null; - this.numberTicks = null; - this.tickInterval = null; - // span, the sweep (in degrees) from min to max. This gauge is - // a semi-circle. - this.span = 180; - // get rid of this nonsense - // this.innerSpan = this.span; - if (this.type == 'circular') { - this.semiCircular = false; - } - else if (this.type != 'circular') { - this.semiCircular = true; - } - else { - this.semiCircular = (this.span <= 180) ? true : false; - } - this._tickPoints = []; - // reference to label element. - this._labelElm = null; - - // start the gauge at the beginning of the span - this.startAngle = (90 + (360 - this.span)/2) * Math.PI/180; - this.endAngle = (90 - (360 - this.span)/2) * Math.PI/180; - - this.setmin = !!(this.min == null); - this.setmax = !!(this.max == null); - - // if given intervals and is an array of values, create labels and colors. - if (this.intervals.length) { - if (this.intervals[0].length == null || this.intervals.length == 1) { - for (var i=0; i<this.intervals.length; i++) { - this.intervals[i] = [this.intervals[i], this.intervals[i], this.intervalColors[i]]; - } - } - else if (this.intervals[0].length == 2) { - for (i=0; i<this.intervals.length; i++) { - this.intervals[i] = [this.intervals[i][0], this.intervals[i][1], this.intervalColors[i]]; - } - } - } - - // compute min, max and ticks if not supplied: - if (this.ticks.length) { - if (this.ticks[0].length == null || this.ticks[0].length == 1) { - for (var i=0; i<this.ticks.length; i++) { - this.ticks[i] = [this.ticks[i], this.ticks[i]]; - } - } - this.min = (this.min == null) ? this.ticks[0][0] : this.min; - this.max = (this.max == null) ? this.ticks[this.ticks.length-1][0] : this.max; - this.setmin = false; - this.setmax = false; - this.numberTicks = this.ticks.length; - this.tickInterval = this.ticks[1][0] - this.ticks[0][0]; - this.tickFactor = Math.floor(parseFloat((Math.log(this.tickInterval)/Math.log(10)).toFixed(11))); - // use the first interal to calculate minor ticks; - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor); - if (!this.numberMinorTicks) { - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1); - } - if (!this.numberMinorTicks) { - this.numberMinorTicks = 1; - } - } - - else if (this.intervals.length) { - this.min = (this.min == null) ? 0 : this.min; - this.setmin = false; - if (this.max == null) { - if (this.intervals[this.intervals.length-1][0] >= this.data[0][1]) { - this.max = this.intervals[this.intervals.length-1][0]; - this.setmax = false; - } - } - else { - this.setmax = false; - } - } - - else { - // no ticks and no intervals supplied, put needle in middle - this.min = (this.min == null) ? 0 : this.min; - this.setmin = false; - if (this.max == null) { - this.max = this.data[0][1] * 1.25; - this.setmax = true; - } - else { - this.setmax = false; - } - } - }; - - $.jqplot.MeterGaugeRenderer.prototype.setGridData = function(plot) { - // set gridData property. This will hold angle in radians of each data point. - var stack = []; - var td = []; - var sa = this.startAngle; - for (var i=0; i<this.data.length; i++){ - stack.push(this.data[i][1]); - td.push([this.data[i][0]]); - if (i>0) { - stack[i] += stack[i-1]; - } - } - var fact = Math.PI*2/stack[stack.length - 1]; - - for (var i=0; i<stack.length; i++) { - td[i][1] = stack[i] * fact; - } - this.gridData = td; - }; - - $.jqplot.MeterGaugeRenderer.prototype.makeGridData = function(data, plot) { - var stack = []; - var td = []; - var sa = this.startAngle; - for (var i=0; i<data.length; i++){ - stack.push(data[i][1]); - td.push([data[i][0]]); - if (i>0) { - stack[i] += stack[i-1]; - } - } - var fact = Math.PI*2/stack[stack.length - 1]; - - for (var i=0; i<stack.length; i++) { - td[i][1] = stack[i] * fact; - } - return td; - }; - - - function getnmt(pos, interval, fact) { - var temp; - for (var i=pos.length-1; i>=0; i--) { - temp = interval/(pos[i] * Math.pow(10, fact)); - if (temp == 4 || temp == 5) { - return temp - 1; - } - } - return null; - } - - // called with scope of series - $.jqplot.MeterGaugeRenderer.prototype.draw = function (ctx, gd, options) { - var i; - var opts = (options != undefined) ? options : {}; - // offset and direction of offset due to legend placement - var offx = 0; - var offy = 0; - var trans = 1; - if (options.legendInfo && options.legendInfo.placement == 'inside') { - var li = options.legendInfo; - switch (li.location) { - case 'nw': - offx = li.width + li.xoffset; - break; - case 'w': - offx = li.width + li.xoffset; - break; - case 'sw': - offx = li.width + li.xoffset; - break; - case 'ne': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'e': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'se': - offx = li.width + li.xoffset; - trans = -1; - break; - case 'n': - offy = li.height + li.yoffset; - break; - case 's': - offy = li.height + li.yoffset; - trans = -1; - break; - default: - break; - } - } - - - - // pre-draw so can get it's dimensions. - if (this.label) { - this._labelElem = $('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+'</div>'); - this.canvas._elem.after(this._labelElem); - } - - var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; - var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; - var fill = (opts.fill != undefined) ? opts.fill : this.fill; - var cw = ctx.canvas.width; - var ch = ctx.canvas.height; - if (this.padding == null) { - this.padding = Math.round(Math.min(cw, ch)/30); - } - var w = cw - offx - 2 * this.padding; - var h = ch - offy - 2 * this.padding; - if (this.labelPosition == 'bottom' && this.label) { - h -= this._labelElem.outerHeight(true); - } - var mindim = Math.min(w,h); - var d = mindim; - - if (!this.diameter) { - if (this.semiCircular) { - if ( w >= 2*h) { - if (!this.ringWidth) { - this.ringWidth = 2*h/35; - } - this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8); - this.innerPad = this.ringWidth/2 + this.needleThickness/2 + this.needlePad; - this.diameter = 2 * (h - 2*this.innerPad); - } - else { - if (!this.ringWidth) { - this.ringWidth = w/35; - } - this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8); - this.innerPad = this.ringWidth/2 + this.needleThickness/2 + this.needlePad; - this.diameter = w - 2*this.innerPad; - } - // center taking into account legend and over draw for gauge bottom below hub. - // this will be center of hub. - this._center = [(cw - trans * offx)/2 + trans * offx, (ch + trans*offy - this.padding - this.ringWidth - this.innerPad)]; - } - else { - if (!this.ringWidth) { - this.ringWidth = d/35; - } - this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8); - this.innerPad = 0; - this.diameter = d - this.ringWidth; - // center in middle of canvas taking into account legend. - // will be center of hub. - this._center = [(cw-trans*offx)/2 + trans * offx, (ch-trans*offy)/2 + trans * offy]; - } - } - - if (this._labelElem && this.labelPosition == 'bottom') { - this._center[1] -= this._labelElem.outerHeight(true); - } - - this._radius = this.diameter/2; - - this.tickSpacing = 6000/this.diameter; - - if (!this.hubRadius) { - this.hubRadius = this.diameter/18; - } - - this.shadowOffset = 0.5 + this.ringWidth/9; - this.shadowWidth = this.ringWidth*1; - - this.tickPadding = 3 + Math.pow(this.diameter/20, 0.7); - this.tickOuterRadius = this._radius - this.ringWidth/2 - this.tickPadding; - this.tickLength = (this.showTicks) ? this._radius/13 : 0; - - if (this.ticks.length == 0) { - // no ticks, lets make some. - var max = this.max, - min = this.min, - setmax = this.setmax, - setmin = this.setmin, - ti = (max - min) * this.tickSpacing / this.span; - var tf = Math.floor(parseFloat((Math.log(ti)/Math.log(10)).toFixed(11))); - var tp = (ti/Math.pow(10, tf)); - (tp > 2 && tp <= 2.5) ? tp = 2.5 : tp = Math.ceil(tp); - var t = this.tickPositions; - var tpindex, nt; - - for (i=0; i<t.length; i++) { - if (tp == t[i] || i && t[i-1] < tp && tp < t[i]) { - ti = t[i]*Math.pow(10, tf); - tpindex = i; - } - } - - for (i=0; i<t.length; i++) { - if (tp == t[i] || i && t[i-1] < tp && tp < t[i]) { - ti = t[i]*Math.pow(10, tf); - nt = Math.ceil((max - min) / ti); - } - } - - // both max and min are free - if (setmax && setmin) { - var tmin = (min > 0) ? min - min % ti : min - min % ti - ti; - if (!this.forceZero) { - var diff = Math.min(min - tmin, 0.8*ti); - var ntp = Math.floor(diff/t[tpindex]); - if (ntp > 1) { - tmin = tmin + t[tpindex] * (ntp-1); - if (parseInt(tmin, 10) != tmin && parseInt(tmin-t[tpindex], 10) == tmin-t[tpindex]) { - tmin = tmin - t[tpindex]; - } - } - } - if (min == tmin) { - min -= ti; - } - else { - // tmin should always be lower than dataMin - if (min - tmin > 0.23*ti) { - min = tmin; - } - else { - min = tmin -ti; - nt += 1; - } - } - nt += 1; - var tmax = min + (nt - 1) * ti; - if (max >= tmax) { - tmax += ti; - nt += 1; - } - // now tmax should always be mroe than dataMax - if (tmax - max < 0.23*ti) { - tmax += ti; - nt += 1; - } - this.max = max = tmax; - this.min = min; - - this.tickInterval = ti; - this.numberTicks = nt; - var it; - for (i=0; i<nt; i++) { - it = parseFloat((min+i*ti).toFixed(11)); - this.ticks.push([it, it]); - } - this.max = this.ticks[nt-1][1]; - - this.tickFactor = tf; - // determine number of minor ticks - - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor); - - if (!this.numberMinorTicks) { - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1); - } - } - // max is free, min is fixed - else if (setmax) { - var tmax = min + (nt - 1) * ti; - if (max >= tmax) { - max = tmax + ti; - nt += 1; - } - else { - max = tmax; - } - - this.tickInterval = this.tickInterval || ti; - this.numberTicks = this.numberTicks || nt; - var it; - for (i=0; i<this.numberTicks; i++) { - it = parseFloat((min+i*this.tickInterval).toFixed(11)); - this.ticks.push([it, it]); - } - this.max = this.ticks[this.numberTicks-1][1]; - - this.tickFactor = tf; - // determine number of minor ticks - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor); - - if (!this.numberMinorTicks) { - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1); - } - } - - // not setting max or min - if (!setmax && !setmin) { - var range = this.max - this.min; - tf = Math.floor(parseFloat((Math.log(range)/Math.log(10)).toFixed(11))) - 1; - var nticks = [5,6,4,7,3,8,9,10,2], res, numticks, nonSigDigits=0, sigRange; - // check to see how many zeros are at the end of the range - if (range > 1) { - var rstr = String(range); - if (rstr.search(/\./) == -1) { - var pos = rstr.search(/0+$/); - nonSigDigits = (pos > 0) ? rstr.length - pos - 1 : 0; - } - } - sigRange = range/Math.pow(10, nonSigDigits); - for (i=0; i<nticks.length; i++) { - res = sigRange/(nticks[i]-1); - if (res == parseInt(res, 10)) { - this.numberTicks = nticks[i]; - this.tickInterval = range/(this.numberTicks-1); - this.tickFactor = tf+1; - break; - } - } - var it; - for (i=0; i<this.numberTicks; i++) { - it = parseFloat((this.min+i*this.tickInterval).toFixed(11)); - this.ticks.push([it, it]); - } - // determine number of minor ticks - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor); - - if (!this.numberMinorTicks) { - this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1); - } - - if (!this.numberMinorTicks) { - this.numberMinorTicks = 1; - var nums = [4, 5, 3, 6, 2]; - for (i=0; i<5; i++) { - var temp = this.tickInterval/nums[i]; - if (temp == parseInt(temp, 10)) { - this.numberMinorTicks = nums[i]-1; - break; - } - } - } - } - } - - - var r = this._radius, - sa = this.startAngle, - ea = this.endAngle, - pi = Math.PI, - hpi = Math.PI/2; - - if (this.semiCircular) { - var overAngle = Math.atan(this.innerPad/r), - outersa = this.outerStartAngle = sa - overAngle, - outerea = this.outerEndAngle = ea + overAngle, - hubsa = this.hubStartAngle = sa - Math.atan(this.innerPad/this.hubRadius*2), - hubea = this.hubEndAngle = ea + Math.atan(this.innerPad/this.hubRadius*2); - - ctx.save(); - - ctx.translate(this._center[0], this._center[1]); - ctx.lineJoin = "round"; - ctx.lineCap = "round"; - - // draw the innerbackground - ctx.save(); - ctx.beginPath(); - ctx.fillStyle = this.background; - ctx.arc(0, 0, r, outersa, outerea, false); - ctx.closePath(); - ctx.fill(); - ctx.restore(); - - // draw the shadow - // the outer ring. - var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')'; - ctx.save(); - for (var i=0; i<this.shadowDepth; i++) { - ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI)); - ctx.beginPath(); - ctx.strokeStyle = shadowColor; - ctx.lineWidth = this.shadowWidth; - ctx.arc(0 ,0, r, outersa, outerea, false); - ctx.closePath(); - ctx.stroke(); - } - ctx.restore(); - - // the inner hub. - ctx.save(); - var tempd = parseInt((this.shadowDepth+1)/2, 10); - for (var i=0; i<tempd; i++) { - ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI)); - ctx.beginPath(); - ctx.fillStyle = shadowColor; - ctx.arc(0 ,0, this.hubRadius, hubsa, hubea, false); - ctx.closePath(); - ctx.fill(); - } - ctx.restore(); - - // draw the outer ring. - ctx.save(); - ctx.beginPath(); - ctx.strokeStyle = this.ringColor; - ctx.lineWidth = this.ringWidth; - ctx.arc(0 ,0, r, outersa, outerea, false); - ctx.closePath(); - ctx.stroke(); - ctx.restore(); - - // draw the hub - - ctx.save(); - ctx.beginPath(); - ctx.fillStyle = this.ringColor; - ctx.arc(0 ,0, this.hubRadius,hubsa, hubea, false); - ctx.closePath(); - ctx.fill(); - ctx.restore(); - - // draw the ticks - if (this.showTicks) { - ctx.save(); - var orad = this.tickOuterRadius, - tl = this.tickLength, - mtl = tl/2, - nmt = this.numberMinorTicks, - ts = this.span * Math.PI / 180 / (this.ticks.length-1), - mts = ts/(nmt + 1); - - for (i = 0; i<this.ticks.length; i++) { - ctx.beginPath(); - ctx.lineWidth = 1.5 + this.diameter/360; - ctx.strokeStyle = this.ringColor; - var wps = ts*i+sa; - ctx.moveTo(-orad * Math.cos(ts*i+sa), orad * Math.sin(ts*i+sa)); - ctx.lineTo(-(orad-tl) * Math.cos(ts*i+sa), (orad - tl) * Math.sin(ts*i+sa)); - this._tickPoints.push([(orad-tl) * Math.cos(ts*i+sa) + this._center[0] + this.canvas._offsets.left, (orad - tl) * Math.sin(ts*i+sa) + this._center[1] + this.canvas._offsets.top, ts*i+sa]); - ctx.stroke(); - ctx.lineWidth = 1.0 + this.diameter/440; - if (i<this.ticks.length-1) { - for (var j=1; j<=nmt; j++) { - ctx.beginPath(); - ctx.moveTo(-orad * Math.cos(ts*i+mts*j+sa), orad * Math.sin(ts*i+mts*j+sa)); - ctx.lineTo(-(orad-mtl) * Math.cos(ts*i+mts*j+sa), (orad-mtl) * Math.sin(ts*i+mts*j+sa)); - ctx.stroke(); - } - } - } - ctx.restore(); - } - - // draw the tick labels - if (this.showTickLabels) { - var elem, l, t, ew, eh, dim, maxdim=0; - var tp = this.tickPadding * (1 - 1/(this.diameter/80+1)); - for (i=0; i<this.ticks.length; i++) { - elem = $('<div class="jqplot-meterGauge-tick" style="position:absolute;">'+this.ticks[i][1]+'</div>'); - this.canvas._elem.after(elem); - ew = elem.outerWidth(true); - eh = elem.outerHeight(true); - l = this._tickPoints[i][0] - ew * (this._tickPoints[i][2]-Math.PI)/Math.PI - tp * Math.cos(this._tickPoints[i][2]); - t = this._tickPoints[i][1] - eh/2 + eh/2 * Math.pow(Math.abs((Math.sin(this._tickPoints[i][2]))), 0.5) + tp/3 * Math.pow(Math.abs((Math.sin(this._tickPoints[i][2]))), 0.5) ; - // t = this._tickPoints[i][1] - eh/2 - eh/2 * Math.sin(this._tickPoints[i][2]) - tp/2 * Math.sin(this._tickPoints[i][2]); - elem.css({left:l, top:t}); - dim = ew*Math.cos(this._tickPoints[i][2]) + eh*Math.sin(Math.PI/2+this._tickPoints[i][2]/2); - maxdim = (dim > maxdim) ? dim : maxdim; - } - } - - // draw the gauge label - if (this.label && this.labelPosition == 'inside') { - var l = this._center[0] + this.canvas._offsets.left; - var tp = this.tickPadding * (1 - 1/(this.diameter/80+1)); - var t = 0.5*(this._center[1] + this.canvas._offsets.top - this.hubRadius) + 0.5*(this._center[1] + this.canvas._offsets.top - this.tickOuterRadius + this.tickLength + tp) + this.labelHeightAdjust; - // this._labelElem = $('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+'</div>'); - // this.canvas._elem.after(this._labelElem); - l -= this._labelElem.outerWidth(true)/2; - t -= this._labelElem.outerHeight(true)/2; - this._labelElem.css({left:l, top:t}); - } - - else if (this.label && this.labelPosition == 'bottom') { - var l = this._center[0] + this.canvas._offsets.left - this._labelElem.outerWidth(true)/2; - var t = this._center[1] + this.canvas._offsets.top + this.innerPad + + this.ringWidth + this.padding + this.labelHeightAdjust; - this._labelElem.css({left:l, top:t}); - - } - - // draw the intervals - - ctx.save(); - var inner = this.intervalInnerRadius || this.hubRadius * 1.5; - if (this.intervalOuterRadius == null) { - if (this.showTickLabels) { - var outer = (this.tickOuterRadius - this.tickLength - this.tickPadding - this.diameter/8); - } - else { - var outer = (this.tickOuterRadius - this.tickLength - this.diameter/16); - } - } - else { - var outer = this.intervalOuterRadius; - } - var range = this.max - this.min; - var intrange = this.intervals[this.intervals.length-1] - this.min; - var start, end, span = this.span*Math.PI/180; - for (i=0; i<this.intervals.length; i++) { - start = (i == 0) ? sa : sa + (this.intervals[i-1][0] - this.min)*span/range; - if (start < 0) { - start = 0; - } - end = sa + (this.intervals[i][0] - this.min)*span/range; - if (end < 0) { - end = 0; - } - ctx.beginPath(); - ctx.fillStyle = this.intervals[i][2]; - ctx.arc(0, 0, inner, start, end, false); - ctx.lineTo(outer*Math.cos(end), outer*Math.sin(end)); - ctx.arc(0, 0, outer, end, start, true); - ctx.lineTo(inner*Math.cos(start), inner*Math.sin(start)); - ctx.closePath(); - ctx.fill(); - } - ctx.restore(); - - // draw the needle - var datapoint = this.data[0][1]; - var dataspan = this.max - this.min; - if (this.pegNeedle) { - if (this.data[0][1] > this.max + dataspan*3/this.span) { - datapoint = this.max + dataspan*3/this.span; - } - if (this.data[0][1] < this.min - dataspan*3/this.span) { - datapoint = this.min - dataspan*3/this.span; - } - } - var dataang = (datapoint - this.min)/dataspan * this.span * Math.PI/180 + this.startAngle; - - - ctx.save(); - ctx.beginPath(); - ctx.fillStyle = this.ringColor; - ctx.strokeStyle = this.ringColor; - this.needleLength = (this.tickOuterRadius - this.tickLength) * 0.85; - this.needleThickness = (this.needleThickness < 2) ? 2 : this.needleThickness; - var endwidth = this.needleThickness * 0.4; - - - var dl = this.needleLength/10; - var dt = (this.needleThickness - endwidth)/10; - var templ; - for (var i=0; i<10; i++) { - templ = this.needleThickness - i*dt; - ctx.moveTo(dl*i*Math.cos(dataang), dl*i*Math.sin(dataang)); - ctx.lineWidth = templ; - ctx.lineTo(dl*(i+1)*Math.cos(dataang), dl*(i+1)*Math.sin(dataang)); - ctx.stroke(); - } - - ctx.restore(); - } - else { - this._center = [(cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy]; - } - }; - - $.jqplot.MeterGaugeAxisRenderer = function() { - $.jqplot.LinearAxisRenderer.call(this); - }; - - $.jqplot.MeterGaugeAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); - $.jqplot.MeterGaugeAxisRenderer.prototype.constructor = $.jqplot.MeterGaugeAxisRenderer; - - - // There are no traditional axes on a gauge chart. We just need to provide - // dummy objects with properties so the plot will render. - // called with scope of axis object. - $.jqplot.MeterGaugeAxisRenderer.prototype.init = function(options){ - // - this.tickRenderer = $.jqplot.MeterGaugeTickRenderer; - $.extend(true, this, options); - // I don't think I'm going to need _dataBounds here. - // have to go Axis scaling in a way to fit chart onto plot area - // and provide u2p and p2u functionality for mouse cursor, etc. - // for convienence set _dataBounds to 0 and 100 and - // set min/max to 0 and 100. - this._dataBounds = {min:0, max:100}; - this.min = 0; - this.max = 100; - this.showTicks = false; - this.ticks = []; - this.showMark = false; - this.show = false; - }; - - $.jqplot.MeterGaugeLegendRenderer = function(){ - $.jqplot.TableLegendRenderer.call(this); - }; - - $.jqplot.MeterGaugeLegendRenderer.prototype = new $.jqplot.TableLegendRenderer(); - $.jqplot.MeterGaugeLegendRenderer.prototype.constructor = $.jqplot.MeterGaugeLegendRenderer; - - /** - * Class: $.jqplot.MeterGaugeLegendRenderer - *Meter gauges don't typically have a legend, this overrides the default legend renderer. - */ - $.jqplot.MeterGaugeLegendRenderer.prototype.init = function(options) { - - // Maximum number of rows in the legend. 0 or null for unlimited. - this.numberRows = null; - // Maximum number of columns in the legend. 0 or null for unlimited. - this.numberColumns = null; - $.extend(true, this, options); - }; - - // called with context of legend - $.jqplot.MeterGaugeLegendRenderer.prototype.draw = function() { - var legend = this; - if (this.show) { - var series = this._series; - var ss = 'position:absolute;'; - ss += (this.background) ? 'background:'+this.background+';' : ''; - ss += (this.border) ? 'border:'+this.border+';' : ''; - ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : ''; - ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : ''; - ss += (this.textColor) ? 'color:'+this.textColor+';' : ''; - ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : ''; - ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : ''; - ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : ''; - ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : ''; - this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>'); - // MeterGauge charts legends don't go by number of series, but by number of data points - // in the series. Refactor things here for that. - - var pad = false, - reverse = false, - nr, nc; - var s = series[0]; - - if (s.show) { - var pd = s.data; - if (this.numberRows) { - nr = this.numberRows; - if (!this.numberColumns){ - nc = Math.ceil(pd.length/nr); - } - else{ - nc = this.numberColumns; - } - } - else if (this.numberColumns) { - nc = this.numberColumns; - nr = Math.ceil(pd.length/this.numberColumns); - } - else { - nr = pd.length; - nc = 1; - } - - var i, j, tr, td1, td2, lt, rs, color; - var idx = 0; - - for (i=0; i<nr; i++) { - if (reverse){ - tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem); - } - else{ - tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem); - } - for (j=0; j<nc; j++) { - if (idx < pd.length){ - lt = this.labels[idx] || pd[idx][0].toString(); - color = colorGenerator.next(); - if (!reverse){ - if (i>0){ - pad = true; - } - else{ - pad = false; - } - } - else{ - if (i == nr -1){ - pad = false; - } - else{ - pad = true; - } - } - rs = (pad) ? this.rowSpacing : '0'; - - td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+ - '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+ - '</div></td>'); - td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>'); - if (this.escapeHtml){ - td2.text(lt); - } - else { - td2.html(lt); - } - if (reverse) { - td2.prependTo(tr); - td1.prependTo(tr); - } - else { - td1.appendTo(tr); - td2.appendTo(tr); - } - pad = true; - } - idx++; - } - } - } - } - return this._elem; - }; - - // $.jqplot.MeterGaugeLegendRenderer.prototype.pack = function(offsets) { - // if (this.show) { - // // fake a grid for positioning - // var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom}; - // if (this.placement == 'insideGrid') { - // switch (this.location) { - // case 'nw': - // var a = grid._left + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('top', b); - // break; - // case 'n': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('top', b); - // break; - // case 'ne': - // var a = offsets.right + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css({right:a, top:b}); - // break; - // case 'e': - // var a = offsets.right + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({right:a, top:b}); - // break; - // case 'se': - // var a = offsets.right + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // case 's': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 'sw': - // var a = grid._left + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 'w': - // var a = grid._left + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({left:a, top:b}); - // break; - // default: // same as 'se' - // var a = grid._right - this.xoffset; - // var b = grid._bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // } - // - // } - // else { - // switch (this.location) { - // case 'nw': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css('right', a); - // this._elem.css('top', b); - // break; - // case 'n': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = this._plotDimensions.height - grid._top + this.yoffset; - // this._elem.css('left', a); - // this._elem.css('bottom', b); - // break; - // case 'ne': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = grid._top + this.yoffset; - // this._elem.css({left:a, top:b}); - // break; - // case 'e': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({left:a, top:b}); - // break; - // case 'se': - // var a = this._plotDimensions.width - offsets.right + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({left:a, bottom:b}); - // break; - // case 's': - // var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; - // var b = this._plotDimensions.height - offsets.bottom + this.yoffset; - // this._elem.css({left:a, top:b}); - // break; - // case 'sw': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = offsets.bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // case 'w': - // var a = this._plotDimensions.width - grid._left + this.xoffset; - // var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; - // this._elem.css({right:a, top:b}); - // break; - // default: // same as 'se' - // var a = grid._right - this.xoffset; - // var b = grid._bottom + this.yoffset; - // this._elem.css({right:a, bottom:b}); - // break; - // } - // } - // } - // }; - - // setup default renderers for axes and legend so user doesn't have to - // called with scope of plot - function preInit(target, data, options) { - options = options || {}; - options.axesDefaults = options.axesDefaults || {}; - options.legend = options.legend || {}; - options.seriesDefaults = options.seriesDefaults || {}; - options.grid = options.grid || {}; - options.gridPadding = options.gridPadding || {}; - - // only set these if there is a gauge series - var setopts = false; - if (options.seriesDefaults.renderer == $.jqplot.MeterGaugeRenderer) { - setopts = true; - } - else if (options.series) { - for (var i=0; i < options.series.length; i++) { - if (options.series[i].renderer == $.jqplot.MeterGaugeRenderer) { - setopts = true; - } - } - } - - if (setopts) { - options.axesDefaults.renderer = $.jqplot.MeterGaugeAxisRenderer; - options.legend.renderer = $.jqplot.MeterGaugeLegendRenderer; - options.legend.preDraw = true; - options.grid.background = options.grid.background || 'white'; - options.grid.drawGridlines = false; - options.grid.borderWidth = (options.grid.borderWidth != null) ? options.grid.borderWidth : 0; - options.grid.shadow = (options.grid.shadow != null) ? options.grid.shadow : false; - options.gridPadding.top = (options.gridPadding.top != null) ? options.gridPadding.top : 0; - options.gridPadding.bottom = (options.gridPadding.bottom != null) ? options.gridPadding.bottom : 0; - options.gridPadding.left = (options.gridPadding.left != null) ? options.gridPadding.left : 0; - options.gridPadding.right = (options.gridPadding.right != null) ? options.gridPadding.right : 0; - } - } - - // called with scope of plot - function postParseOptions(options) { - // - } - - $.jqplot.preInitHooks.push(preInit); - $.jqplot.postParseOptionsHooks.push(postParseOptions); - - $.jqplot.MeterGaugeTickRenderer = function() { - $.jqplot.AxisTickRenderer.call(this); - }; - - $.jqplot.MeterGaugeTickRenderer.prototype = new $.jqplot.AxisTickRenderer(); - $.jqplot.MeterGaugeTickRenderer.prototype.constructor = $.jqplot.MeterGaugeTickRenderer; - -})(jQuery); - -
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.ohlcRenderer.js b/libs/jqplot/plugins/jqplot.ohlcRenderer.js deleted file mode 100644 index a8616a5755..0000000000 --- a/libs/jqplot/plugins/jqplot.ohlcRenderer.js +++ /dev/null @@ -1,372 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - /** - * Class: $.jqplot.OHLCRenderer - * jqPlot Plugin to draw Open Hi Low Close, Candlestick and Hi Low Close charts. - * - * To use this plugin, include the renderer js file in - * your source: - * - * > <script type="text/javascript" src="plugins/jqplot.ohlcRenderer.js"></script> - * - * You will most likely want to use a date axis renderer - * for the x axis also, so include the date axis render js file also: - * - * > <script type="text/javascript" src="plugins/jqplot.dateAxisRenderer.js"></script> - * - * Then you set the renderer in the series options on your plot: - * - * > series: [{renderer:$.jqplot.OHLCRenderer}] - * - * For OHLC and candlestick charts, data should be specified - * like so: - * - * > dat = [['07/06/2009',138.7,139.68,135.18,135.4], ['06/29/2009',143.46,144.66,139.79,140.02], ...] - * - * If the data array has only 4 values per point instead of 5, - * the renderer will create a Hi Low Close chart instead. In that case, - * data should be supplied like: - * - * > dat = [['07/06/2009',139.68,135.18,135.4], ['06/29/2009',144.66,139.79,140.02], ...] - * - * To generate a candlestick chart instead of an OHLC chart, - * set the "candlestick" option to true: - * - * > series: [{renderer:$.jqplot.OHLCRenderer, rendererOptions:{candleStick:true}}], - * - */ - $.jqplot.OHLCRenderer = function(){ - // subclass line renderer to make use of some of it's methods. - $.jqplot.LineRenderer.call(this); - // prop: candleStick - // true to render chart as candleStick. - // Must have an open price, cannot be a hlc chart. - this.candleStick = false; - // prop: tickLength - // length of the line in pixels indicating open and close price. - // Default will auto calculate based on plot width and - // number of points displayed. - this.tickLength = 'auto'; - // prop: bodyWidth - // width of the candlestick body in pixels. Default will auto calculate - // based on plot width and number of candlesticks displayed. - this.bodyWidth = 'auto'; - // prop: openColor - // color of the open price tick mark. Default is series color. - this.openColor = null; - // prop: closeColor - // color of the close price tick mark. Default is series color. - this.closeColor = null; - // prop: wickColor - // color of the hi-lo line thorugh the candlestick body. - // Default is the series color. - this.wickColor = null; - // prop: fillUpBody - // true to render an "up" day (close price greater than open price) - // with a filled candlestick body. - this.fillUpBody = false; - // prop: fillDownBody - // true to render a "down" day (close price lower than open price) - // with a filled candlestick body. - this.fillDownBody = true; - // prop: upBodyColor - // Color of candlestick body of an "up" day. Default is series color. - this.upBodyColor = null; - // prop: downBodyColor - // Color of candlestick body on a "down" day. Default is series color. - this.downBodyColor = null; - // prop: hlc - // true if is a hi-low-close chart (no open price). - // This is determined automatically from the series data. - this.hlc = false; - // prop: lineWidth - // Width of the hi-low line and open/close ticks. - // Must be set in the rendererOptions for the series. - this.lineWidth = 1.5; - this._tickLength; - this._bodyWidth; - }; - - $.jqplot.OHLCRenderer.prototype = new $.jqplot.LineRenderer(); - $.jqplot.OHLCRenderer.prototype.constructor = $.jqplot.OHLCRenderer; - - // called with scope of series. - $.jqplot.OHLCRenderer.prototype.init = function(options) { - options = options || {}; - // lineWidth has to be set on the series, changes in renderer - // constructor have no effect. set the default here - // if no renderer option for lineWidth is specified. - this.lineWidth = options.lineWidth || 1.5; - $.jqplot.LineRenderer.prototype.init.call(this, options); - this._type = 'ohlc'; - // set the yaxis data bounds here to account for hi and low values - var db = this._yaxis._dataBounds; - var d = this._plotData; - // if data points have less than 5 values, force a hlc chart. - if (d[0].length < 5) { - this.renderer.hlc = true; - - for (var j=0; j<d.length; j++) { - if (d[j][2] < db.min || db.min == null) { - db.min = d[j][2]; - } - if (d[j][1] > db.max || db.max == null) { - db.max = d[j][1]; - } - } - } - else { - for (var j=0; j<d.length; j++) { - if (d[j][3] < db.min || db.min == null) { - db.min = d[j][3]; - } - if (d[j][2] > db.max || db.max == null) { - db.max = d[j][2]; - } - } - } - - }; - - // called within scope of series. - $.jqplot.OHLCRenderer.prototype.draw = function(ctx, gd, options) { - var d = this.data; - var xmin = this._xaxis.min; - var xmax = this._xaxis.max; - // index of last value below range of plot. - var xminidx = 0; - // index of first value above range of plot. - var xmaxidx = d.length; - var xp = this._xaxis.series_u2p; - var yp = this._yaxis.series_u2p; - var i, prevColor, ops, b, h, w, a, points; - var o; - var r = this.renderer; - var opts = (options != undefined) ? options : {}; - var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; - var fill = (opts.fill != undefined) ? opts.fill : this.fill; - var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke; - r.bodyWidth = (opts.bodyWidth != undefined) ? opts.bodyWidth : r.bodyWidth; - r.tickLength = (opts.tickLength != undefined) ? opts.tickLength : r.tickLength; - ctx.save(); - if (this.show) { - var x, open, hi, low, close; - // need to get widths based on number of points shown, - // not on total number of points. Use the results - // to speed up drawing in next step. - for (var i=0; i<d.length; i++) { - if (d[i][0] < xmin) { - xminidx = i; - } - else if (d[i][0] < xmax) { - xmaxidx = i+1; - } - } - - var dwidth = this.gridData[xmaxidx-1][0] - this.gridData[xminidx][0]; - var nvisiblePoints = xmaxidx - xminidx; - try { - var dinterval = Math.abs(this._xaxis.series_u2p(parseInt(this._xaxis._intervalStats[0].sortedIntervals[0].interval)) - this._xaxis.series_u2p(0)); - } - - catch (e) { - var dinterval = dwidth / nvisiblePoints; - } - - if (r.candleStick) { - if (typeof(r.bodyWidth) == 'number') { - r._bodyWidth = r.bodyWidth; - } - else { - r._bodyWidth = Math.min(20, dinterval/1.75); - } - } - else { - if (typeof(r.tickLength) == 'number') { - r._tickLength = r.tickLength; - } - else { - r._tickLength = Math.min(10, dinterval/3.5); - } - } - - for (var i=xminidx; i<xmaxidx; i++) { - x = xp(d[i][0]); - if (r.hlc) { - open = null; - hi = yp(d[i][1]); - low = yp(d[i][2]); - close = yp(d[i][3]); - } - else { - open = yp(d[i][1]); - hi = yp(d[i][2]); - low = yp(d[i][3]); - close = yp(d[i][4]); - } - o = {}; - if (r.candleStick && !r.hlc) { - w = r._bodyWidth; - a = x - w/2; - // draw candle - // determine if candle up or down - // up, remember grid coordinates increase downward - if (close < open) { - // draw wick - if (r.wickColor) { - o.color = r.wickColor; - } - else if (r.downBodyColor) { - o.color = r.upBodyColor; - } - ops = $.extend(true, {}, opts, o); - r.shapeRenderer.draw(ctx, [[x, hi], [x, close]], ops); - r.shapeRenderer.draw(ctx, [[x, open], [x, low]], ops); - o = {}; - b = close; - h = open - close; - // if color specified, use it - if (r.fillUpBody) { - o.fillRect = true; - } - else { - o.strokeRect = true; - w = w - this.lineWidth; - a = x - w/2; - } - if (r.upBodyColor) { - o.color = r.upBodyColor; - o.fillStyle = r.upBodyColor; - } - points = [a, b, w, h]; - } - // down - else if (close > open) { - // draw wick - if (r.wickColor) { - o.color = r.wickColor; - } - else if (r.downBodyColor) { - o.color = r.downBodyColor; - } - ops = $.extend(true, {}, opts, o); - r.shapeRenderer.draw(ctx, [[x, hi], [x, open]], ops); - r.shapeRenderer.draw(ctx, [[x, close], [x, low]], ops); - - o = {}; - - b = open; - h = close - open; - // if color specified, use it - if (r.fillDownBody) { - o.fillRect = true; - } - else { - o.strokeRect = true; - w = w - this.lineWidth; - a = x - w/2; - } - if (r.downBodyColor) { - o.color = r.downBodyColor; - o.fillStyle = r.downBodyColor; - } - points = [a, b, w, h]; - } - // even, open = close - else { - // draw wick - if (r.wickColor) { - o.color = r.wickColor; - } - ops = $.extend(true, {}, opts, o); - r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], ops); - o = {}; - o.fillRect = false; - o.strokeRect = false; - a = [x - w/2, open]; - b = [x + w/2, close]; - w = null; - h = null; - points = [a, b]; - } - ops = $.extend(true, {}, opts, o); - r.shapeRenderer.draw(ctx, points, ops); - } - else { - prevColor = opts.color; - if (r.openColor) { - opts.color = r.openColor; - } - // draw open tick - if (!r.hlc) { - r.shapeRenderer.draw(ctx, [[x-r._tickLength, open], [x, open]], opts); - } - opts.color = prevColor; - // draw wick - if (r.wickColor) { - opts.color = r.wickColor; - } - r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], opts); - opts.color = prevColor; - // draw close tick - if (r.closeColor) { - opts.color = r.closeColor; - } - r.shapeRenderer.draw(ctx, [[x, close], [x+r._tickLength, close]], opts); - opts.color = prevColor; - } - } - } - - ctx.restore(); - }; - - $.jqplot.OHLCRenderer.prototype.drawShadow = function(ctx, gd, options) { - // This is a no-op, shadows drawn with lines. - }; - - // called with scope of plot. - $.jqplot.OHLCRenderer.checkOptions = function(target, data, options) { - // provide some sensible highlighter options by default - // These aren't good for hlc, only for ohlc or candlestick - if (!options.highlighter) { - options.highlighter = { - showMarker:false, - tooltipAxes: 'y', - yvalues: 4, - formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>open:</td><td>%s</td></tr><tr><td>hi:</td><td>%s</td></tr><tr><td>low:</td><td>%s</td></tr><tr><td>close:</td><td>%s</td></tr></table>' - }; - } - }; - - //$.jqplot.preInitHooks.push($.jqplot.OHLCRenderer.checkOptions); - -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.pointLabels.js b/libs/jqplot/plugins/jqplot.pointLabels.js deleted file mode 100644 index 3fc82b281b..0000000000 --- a/libs/jqplot/plugins/jqplot.pointLabels.js +++ /dev/null @@ -1,352 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - - /** - * Class: $.jqplot.PointLabels - * Plugin for putting labels at the data points. - * - * To use this plugin, include the js - * file in your source: - * - * > <script type="text/javascript" src="plugins/jqplot.pointLabels.js"></script> - * - * By default, the last value in the data ponit array in the data series is used - * for the label. For most series renderers, extra data can be added to the - * data point arrays and the last value will be used as the label. - * - * For instance, - * this series: - * - * > [[1,4], [3,5], [7,2]] - * - * Would, by default, use the y values in the labels. - * Extra data can be added to the series like so: - * - * > [[1,4,'mid'], [3 5,'hi'], [7,2,'low']] - * - * And now the point labels would be 'mid', 'low', and 'hi'. - * - * Options to the point labels and a custom labels array can be passed into the - * "pointLabels" option on the series option like so: - * - * > series:[{pointLabels:{ - * > labels:['mid', 'hi', 'low'], - * > location:'se', - * > ypadding: 12 - * > } - * > }] - * - * A custom labels array in the options takes precendence over any labels - * in the series data. If you have a custom labels array in the options, - * but still want to use values from the series array as labels, set the - * "labelsFromSeries" option to true. - * - * By default, html entities (<, >, etc.) are escaped in point labels. - * If you want to include actual html markup in the labels, - * set the "escapeHTML" option to false. - * - */ - $.jqplot.PointLabels = function(options) { - // Group: Properties - // - // prop: show - // show the labels or not. - this.show = $.jqplot.config.enablePlugins; - // prop: location - // compass location where to position the label around the point. - // 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw' - this.location = 'n'; - // prop: labelsFromSeries - // true to use labels within data point arrays. - this.labelsFromSeries = false; - // prop: seriesLabelIndex - // array index for location of labels within data point arrays. - // if null, will use the last element of the data point array. - this.seriesLabelIndex = null; - // prop: labels - // array of arrays of labels, one array for each series. - this.labels = []; - // actual labels that will get displayed. - // needed to preserve user specified labels in labels array. - this._labels = []; - // prop: stackedValue - // true to display value as stacked in a stacked plot. - // no effect if labels is specified. - this.stackedValue = false; - // prop: ypadding - // vertical padding in pixels between point and label - this.ypadding = 6; - // prop: xpadding - // horizontal padding in pixels between point and label - this.xpadding = 6; - // prop: escapeHTML - // true to escape html entities in the labels. - // If you want to include markup in the labels, set to false. - this.escapeHTML = true; - // prop: edgeTolerance - // Number of pixels that the label must be away from an axis - // boundary in order to be drawn. Negative values will allow overlap - // with the grid boundaries. - this.edgeTolerance = -5; - // prop: formatter - // A class of a formatter for the tick text. sprintf by default. - this.formatter = $.jqplot.DefaultTickFormatter; - // prop: formatString - // string passed to the formatter. - this.formatString = ''; - // prop: hideZeros - // true to not show a label for a value which is 0. - this.hideZeros = false; - this._elems = []; - - $.extend(true, this, options); - }; - - var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w']; - var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7}; - var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e']; - - // called with scope of a series - $.jqplot.PointLabels.init = function (target, data, seriesDefaults, opts){ - var options = $.extend(true, {}, seriesDefaults, opts); - options.pointLabels = options.pointLabels || {}; - if (this.renderer.constructor == $.jqplot.BarRenderer && this.barDirection == 'horizontal' && !options.pointLabels.location) { - options.pointLabels.location = 'e'; - } - // add a pointLabels attribute to the series plugins - this.plugins.pointLabels = new $.jqplot.PointLabels(options.pointLabels); - this.plugins.pointLabels.setLabels.call(this); - }; - - // called with scope of series - $.jqplot.PointLabels.prototype.setLabels = function() { - var p = this.plugins.pointLabels; - var labelIdx; - if (p.seriesLabelIndex != null) { - labelIdx = p.seriesLabelIndex; - } - else if (this.renderer.constructor == $.jqplot.BarRenderer && this.barDirection == 'horizontal') { - labelIdx = 0; - } - else { - labelIdx = this._plotData[0].length -1; - } - p._labels = []; - if (p.labels.length == 0 || p.labelsFromSeries) { - if (p.stackedValue) { - if (this._plotData.length && this._plotData[0].length){ - // var idx = p.seriesLabelIndex || this._plotData[0].length -1; - for (var i=0; i<this._plotData.length; i++) { - p._labels.push(this._plotData[i][labelIdx]); - } - } - } - else { - var d = this.data; - if (this.renderer.constructor == $.jqplot.BarRenderer && this.waterfall) { - d = this._data; - } - if (d.length && d[0].length) { - // var idx = p.seriesLabelIndex || d[0].length -1; - for (var i=0; i<d.length; i++) { - p._labels.push(d[i][labelIdx]); - } - } - } - } - else if (p.labels.length){ - p._labels = p.labels; - } - }; - - $.jqplot.PointLabels.prototype.xOffset = function(elem, location, padding) { - location = location || this.location; - padding = padding || this.xpadding; - var offset; - - switch (location) { - case 'nw': - offset = -elem.outerWidth(true) - this.xpadding; - break; - case 'n': - offset = -elem.outerWidth(true)/2; - break; - case 'ne': - offset = this.xpadding; - break; - case 'e': - offset = this.xpadding; - break; - case 'se': - offset = this.xpadding; - break; - case 's': - offset = -elem.outerWidth(true)/2; - break; - case 'sw': - offset = -elem.outerWidth(true) - this.xpadding; - break; - case 'w': - offset = -elem.outerWidth(true) - this.xpadding; - break; - default: // same as 'nw' - offset = -elem.outerWidth(true) - this.xpadding; - break; - } - return offset; - }; - - $.jqplot.PointLabels.prototype.yOffset = function(elem, location, padding) { - location = location || this.location; - padding = padding || this.xpadding; - var offset; - - switch (location) { - case 'nw': - offset = -elem.outerHeight(true) - this.ypadding; - break; - case 'n': - offset = -elem.outerHeight(true) - this.ypadding; - break; - case 'ne': - offset = -elem.outerHeight(true) - this.ypadding; - break; - case 'e': - offset = -elem.outerHeight(true)/2; - break; - case 'se': - offset = this.ypadding; - break; - case 's': - offset = this.ypadding; - break; - case 'sw': - offset = this.ypadding; - break; - case 'w': - offset = -elem.outerHeight(true)/2; - break; - default: // same as 'nw' - offset = -elem.outerHeight(true) - this.ypadding; - break; - } - return offset; - }; - - // called with scope of series - $.jqplot.PointLabels.draw = function (sctx, options) { - var p = this.plugins.pointLabels; - // set labels again in case they have changed. - p.setLabels.call(this); - // remove any previous labels - for (var i=0; i<p._elems.length; i++) { - // Memory Leaks patch - // p._elems[i].remove(); - p._elems[i].emptyForce(); - } - p._elems.splice(0, p._elems.length); - - if (p.show) { - var ax = '_'+this._stackAxis+'axis'; - - if (!p.formatString) { - p.formatString = this[ax]._ticks[0].formatString; - p.formatter = this[ax]._ticks[0].formatter; - } - - var pd = this._plotData; - var xax = this._xaxis; - var yax = this._yaxis; - var elem, helem; - - for (var i=0, l=p._labels.length; i < l; i++) { - var label = p._labels[i]; - - if (p.hideZeros && parseInt(p._labels[i], 10) == 0) { - label = ''; - } - - if (label != null) { - label = p.formatter(p.formatString, label); - } - - helem = document.createElement('div'); - p._elems[i] = $(helem); - - elem = p._elems[i]; - - - elem.addClass('jqplot-point-label jqplot-series-'+this.index+' jqplot-point-'+i); - elem.css('position', 'absolute'); - elem.insertAfter(sctx.canvas); - - if (p.escapeHTML) { - elem.text(label); - } - else { - elem.html(label); - } - var location = p.location; - if ((this.fillToZero && pd[i][1] < 0) || (this.waterfall && parseInt(label, 10)) < 0) { - location = oppositeLocations[locationIndicies[location]]; - } - var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location); - var elt = yax.u2p(pd[i][1]) + p.yOffset(elem, location); - if (this.renderer.constructor == $.jqplot.BarRenderer) { - if (this.barDirection == "vertical") { - ell += this._barNudge; - } - else { - elt -= this._barNudge; - } - } - elem.css('left', ell); - elem.css('top', elt); - var elr = ell + elem.width(); - var elb = elt + elem.height(); - var et = p.edgeTolerance; - var scl = $(sctx.canvas).position().left; - var sct = $(sctx.canvas).position().top; - var scr = sctx.canvas.width + scl; - var scb = sctx.canvas.height + sct; - // if label is outside of allowed area, remove it - if (ell - et < scl || elt - et < sct || elr + et > scr || elb + et > scb) { - elem.remove(); - } - elem = null; - helem = null; - } - } - }; - - $.jqplot.postSeriesInitHooks.push($.jqplot.PointLabels.init); - $.jqplot.postDrawSeriesHooks.push($.jqplot.PointLabels.draw); -})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/plugins/jqplot.trendline.js b/libs/jqplot/plugins/jqplot.trendline.js deleted file mode 100644 index 55b3e8b61a..0000000000 --- a/libs/jqplot/plugins/jqplot.trendline.js +++ /dev/null @@ -1,220 +0,0 @@ -/** - * jqPlot - * Pure JavaScript plotting plugin using jQuery - * - * Version: @VERSION - * - * 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." - * - */ -(function($) { - - /** - * Class: $.jqplot.Trendline - * Plugin which will automatically compute and draw trendlines for plotted data. - */ - $.jqplot.Trendline = function() { - // Group: Properties - - // prop: show - // Wether or not to show the trend line. - this.show = $.jqplot.config.enablePlugins; - // prop: color - // CSS color spec for the trend line. - // By default this wil be the same color as the primary line. - this.color = '#666666'; - // prop: renderer - // Renderer to use to draw the trend line. - // The data series that is plotted may not be rendered as a line. - // Therefore, we use our own line renderer here to draw a trend line. - this.renderer = new $.jqplot.LineRenderer(); - // prop: rendererOptions - // Options to pass to the line renderer. - // By default, markers are not shown on trend lines. - this.rendererOptions = {marker:{show:false}}; - // prop: label - // Label for the trend line to use in the legend. - this.label = ''; - // prop: type - // Either 'exponential', 'exp', or 'linear'. - this.type = 'linear'; - // prop: shadow - // true or false, wether or not to show the shadow. - this.shadow = true; - // prop: markerRenderer - // Renderer to use to draw markers on the line. - // I think this is wrong. - this.markerRenderer = {show:false}; - // prop: lineWidth - // Width of the trend line. - this.lineWidth = 1.5; - // prop: shadowAngle - // Angle of the shadow on the trend line. - this.shadowAngle = 45; - // prop: shadowOffset - // pixel offset for each stroke of the shadow. - this.shadowOffset = 1.0; - // prop: shadowAlpha - // Alpha transparency of the shadow. - this.shadowAlpha = 0.07; - // prop: shadowDepth - // number of strokes to make of the shadow. - this.shadowDepth = 3; - this.isTrendline = true; - - }; - - $.jqplot.postSeriesInitHooks.push(parseTrendLineOptions); - $.jqplot.postDrawSeriesHooks.push(drawTrendline); - $.jqplot.addLegendRowHooks.push(addTrendlineLegend); - - // called witin scope of the legend object - // current series passed in - // must return null or an object {label:label, color:color} - function addTrendlineLegend(series) { - var lt = series.trendline.label.toString(); - var ret = null; - if (this.renderer.constructor != $.jqplot.PieRenderer && series.trendline.show && lt) { - ret = {label:lt, color:series.trendline.color}; - } - return ret; - } - - // called within scope of a series - function parseTrendLineOptions (target, data, seriesDefaults, options, plot) { - if (this.renderer.constructor == $.jqplot.LineRenderer) { - this.trendline = new $.jqplot.Trendline(); - options = options || {}; - $.extend(true, this.trendline, {color:this.color}, seriesDefaults.trendline, options.trendline); - this.trendline.renderer.init.call(this.trendline, null); - } - } - - // called within scope of series object - function drawTrendline(sctx, options) { - // if we have options, merge trendline options in with precedence - options = $.extend(true, {}, this.trendline, options); - - if (options.show && this.renderer.constructor != $.jqplot.PieRenderer) { - var fit; - // this.renderer.setGridData.call(this); - var data = options.data || this.data; - fit = fitData(data, this.trendline.type); - var gridData = options.gridData || this.renderer.makeGridData.call(this, fit.data); - this.trendline.renderer.draw.call(this.trendline, sctx, gridData, {showLine:true, shadow:this.trendline.shadow}); - } - } - - function regression(x, y, typ) { - var type = (typ == null) ? 'linear' : typ; - var N = x.length; - var slope; - var intercept; - var SX = 0; - var SY = 0; - var SXX = 0; - var SXY = 0; - var SYY = 0; - var Y = []; - var X = []; - - if (type == 'linear') { - X = x; - Y = y; - } - else if (type == 'exp' || type == 'exponential') { - for ( var i=0; i<y.length; i++) { - // ignore points <= 0, log undefined. - if (y[i] <= 0) { - N--; - } - else { - X.push(x[i]); - Y.push(Math.log(y[i])); - } - } - } - - for ( var i = 0; i < N; i++) { - SX = SX + X[i]; - SY = SY + Y[i]; - SXY = SXY + X[i]* Y[i]; - SXX = SXX + X[i]* X[i]; - SYY = SYY + Y[i]* Y[i]; - } - - slope = (N*SXY - SX*SY)/(N*SXX - SX*SX); - intercept = (SY - slope*SX)/N; - - return [slope, intercept]; - } - - function linearRegression(X,Y) { - var ret; - ret = regression(X,Y,'linear'); - return [ret[0],ret[1]]; - } - - function expRegression(X,Y) { - var ret; - var x = X; - var y = Y; - ret = regression(x, y,'exp'); - var base = Math.exp(ret[0]); - var coeff = Math.exp(ret[1]); - return [base, coeff]; - } - - function fitData(data, typ) { - var type = (typ == null) ? 'linear' : typ; - var ret; - var res; - var x = []; - var y = []; - var ypred = []; - - for (i=0; i<data.length; i++){ - if (data[i] != null && data[i][0] != null && data[i][1] != null) { - x.push(data[i][0]); - y.push(data[i][1]); - } - } - - if (type == 'linear') { - ret = linearRegression(x,y); - for ( var i=0; i<x.length; i++){ - res = ret[0]*x[i] + ret[1]; - ypred.push([x[i], res]); - } - } - else if (type == 'exp' || type == 'exponential') { - ret = expRegression(x,y); - for ( var i=0; i<x.length; i++){ - res = ret[1]*Math.pow(ret[0],x[i]); - ypred.push([x[i], res]); - } - } - return {data: ypred, slope: ret[0], intercept: ret[1]}; - } - -})(jQuery);
\ No newline at end of file |