wpMandrill - Version 1.22

Version Description

  • UPDATED: Replacing Highcharts in favor of Flot
  • ADD: Cron job to fetch stats
Download this release

Release Info

Developer MC_Will
Plugin Icon wp plugin wpMandrill
Version 1.22
Comparing to
See all releases

Code changes from version 1.21 to 1.22

js/flot/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2007-2009 IOLA and Ole Laursen
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
js/flot/jquery.flot.js ADDED
@@ -0,0 +1,2599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! Javascript plotting library for jQuery, v. 0.7.
2
+ *
3
+ * Released under the MIT license by IOLA, December 2007.
4
+ *
5
+ */
6
+
7
+ // first an inline dependency, jquery.colorhelpers.js, we inline it here
8
+ // for convenience
9
+
10
+ /* Plugin for jQuery for working with colors.
11
+ *
12
+ * Version 1.1.
13
+ *
14
+ * Inspiration from jQuery color animation plugin by John Resig.
15
+ *
16
+ * Released under the MIT license by Ole Laursen, October 2009.
17
+ *
18
+ * Examples:
19
+ *
20
+ * $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
21
+ * var c = $.color.extract($("#mydiv"), 'background-color');
22
+ * console.log(c.r, c.g, c.b, c.a);
23
+ * $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
24
+ *
25
+ * Note that .scale() and .add() return the same modified object
26
+ * instead of making a new one.
27
+ *
28
+ * V. 1.1: Fix error handling so e.g. parsing an empty string does
29
+ * produce a color rather than just crashing.
30
+ */
31
+ (function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]+=I}return G.normalize()};G.scale=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]*=I}return G.normalize()};G.toString=function(){if(G.a>=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return K<J?J:(K>I?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
32
+
33
+ // the actual Flot code
34
+ (function($) {
35
+ function Plot(placeholder, data_, options_, plugins) {
36
+ // data is on the form:
37
+ // [ series1, series2 ... ]
38
+ // where series is either just the data as [ [x1, y1], [x2, y2], ... ]
39
+ // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
40
+
41
+ var series = [],
42
+ options = {
43
+ // the color theme used for graphs
44
+ colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
45
+ legend: {
46
+ show: true,
47
+ noColumns: 1, // number of colums in legend table
48
+ labelFormatter: null, // fn: string -> string
49
+ labelBoxBorderColor: "#ccc", // border color for the little label boxes
50
+ container: null, // container (as jQuery object) to put legend in, null means default on top of graph
51
+ position: "ne", // position of default legend container within plot
52
+ margin: 5, // distance from grid edge to default legend container within plot
53
+ backgroundColor: null, // null means auto-detect
54
+ backgroundOpacity: 0.85 // set to 0 to avoid background
55
+ },
56
+ xaxis: {
57
+ show: null, // null = auto-detect, true = always, false = never
58
+ position: "bottom", // or "top"
59
+ mode: null, // null or "time"
60
+ color: null, // base color, labels, ticks
61
+ tickColor: null, // possibly different color of ticks, e.g. "rgba(0,0,0,0.15)"
62
+ transform: null, // null or f: number -> number to transform axis
63
+ inverseTransform: null, // if transform is set, this should be the inverse function
64
+ min: null, // min. value to show, null means set automatically
65
+ max: null, // max. value to show, null means set automatically
66
+ autoscaleMargin: null, // margin in % to add if auto-setting min/max
67
+ ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
68
+ tickFormatter: null, // fn: number -> string
69
+ labelWidth: null, // size of tick labels in pixels
70
+ labelHeight: null,
71
+ reserveSpace: null, // whether to reserve space even if axis isn't shown
72
+ tickLength: null, // size in pixels of ticks, or "full" for whole line
73
+ alignTicksWithAxis: null, // axis number or null for no sync
74
+
75
+ // mode specific options
76
+ tickDecimals: null, // no. of decimals, null means auto
77
+ tickSize: null, // number or [number, "unit"]
78
+ minTickSize: null, // number or [number, "unit"]
79
+ monthNames: null, // list of names of months
80
+ timeformat: null, // format string to use
81
+ twelveHourClock: false // 12 or 24 time in time mode
82
+ },
83
+ yaxis: {
84
+ autoscaleMargin: 0.02,
85
+ position: "left" // or "right"
86
+ },
87
+ xaxes: [],
88
+ yaxes: [],
89
+ series: {
90
+ points: {
91
+ show: false,
92
+ radius: 3,
93
+ lineWidth: 2, // in pixels
94
+ fill: true,
95
+ fillColor: "#ffffff",
96
+ symbol: "circle" // or callback
97
+ },
98
+ lines: {
99
+ // we don't put in show: false so we can see
100
+ // whether lines were actively disabled
101
+ lineWidth: 2, // in pixels
102
+ fill: false,
103
+ fillColor: null,
104
+ steps: false
105
+ },
106
+ bars: {
107
+ show: false,
108
+ lineWidth: 2, // in pixels
109
+ barWidth: 1, // in units of the x axis
110
+ fill: true,
111
+ fillColor: null,
112
+ align: "left", // or "center"
113
+ horizontal: false
114
+ },
115
+ shadowSize: 3
116
+ },
117
+ grid: {
118
+ show: true,
119
+ aboveData: false,
120
+ color: "#545454", // primary color used for outline and labels
121
+ backgroundColor: null, // null for transparent, else color
122
+ borderColor: null, // set if different from the grid color
123
+ tickColor: null, // color for the ticks, e.g. "rgba(0,0,0,0.15)"
124
+ labelMargin: 5, // in pixels
125
+ axisMargin: 8, // in pixels
126
+ borderWidth: 2, // in pixels
127
+ minBorderMargin: null, // in pixels, null means taken from points radius
128
+ markings: null, // array of ranges or fn: axes -> array of ranges
129
+ markingsColor: "#f4f4f4",
130
+ markingsLineWidth: 2,
131
+ // interactive stuff
132
+ clickable: false,
133
+ hoverable: false,
134
+ autoHighlight: true, // highlight in case mouse is near
135
+ mouseActiveRadius: 10 // how far the mouse can be away to activate an item
136
+ },
137
+ hooks: {}
138
+ },
139
+ canvas = null, // the canvas for the plot itself
140
+ overlay = null, // canvas for interactive stuff on top of plot
141
+ eventHolder = null, // jQuery object that events should be bound to
142
+ ctx = null, octx = null,
143
+ xaxes = [], yaxes = [],
144
+ plotOffset = { left: 0, right: 0, top: 0, bottom: 0},
145
+ canvasWidth = 0, canvasHeight = 0,
146
+ plotWidth = 0, plotHeight = 0,
147
+ hooks = {
148
+ processOptions: [],
149
+ processRawData: [],
150
+ processDatapoints: [],
151
+ drawSeries: [],
152
+ draw: [],
153
+ bindEvents: [],
154
+ drawOverlay: [],
155
+ shutdown: []
156
+ },
157
+ plot = this;
158
+
159
+ // public functions
160
+ plot.setData = setData;
161
+ plot.setupGrid = setupGrid;
162
+ plot.draw = draw;
163
+ plot.getPlaceholder = function() { return placeholder; };
164
+ plot.getCanvas = function() { return canvas; };
165
+ plot.getPlotOffset = function() { return plotOffset; };
166
+ plot.width = function () { return plotWidth; };
167
+ plot.height = function () { return plotHeight; };
168
+ plot.offset = function () {
169
+ var o = eventHolder.offset();
170
+ o.left += plotOffset.left;
171
+ o.top += plotOffset.top;
172
+ return o;
173
+ };
174
+ plot.getData = function () { return series; };
175
+ plot.getAxes = function () {
176
+ var res = {}, i;
177
+ $.each(xaxes.concat(yaxes), function (_, axis) {
178
+ if (axis)
179
+ res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis;
180
+ });
181
+ return res;
182
+ };
183
+ plot.getXAxes = function () { return xaxes; };
184
+ plot.getYAxes = function () { return yaxes; };
185
+ plot.c2p = canvasToAxisCoords;
186
+ plot.p2c = axisToCanvasCoords;
187
+ plot.getOptions = function () { return options; };
188
+ plot.highlight = highlight;
189
+ plot.unhighlight = unhighlight;
190
+ plot.triggerRedrawOverlay = triggerRedrawOverlay;
191
+ plot.pointOffset = function(point) {
192
+ return {
193
+ left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left),
194
+ top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top)
195
+ };
196
+ };
197
+ plot.shutdown = shutdown;
198
+ plot.resize = function () {
199
+ getCanvasDimensions();
200
+ resizeCanvas(canvas);
201
+ resizeCanvas(overlay);
202
+ };
203
+
204
+ // public attributes
205
+ plot.hooks = hooks;
206
+
207
+ // initialize
208
+ initPlugins(plot);
209
+ parseOptions(options_);
210
+ setupCanvases();
211
+ setData(data_);
212
+ setupGrid();
213
+ draw();
214
+ bindEvents();
215
+
216
+
217
+ function executeHooks(hook, args) {
218
+ args = [plot].concat(args);
219
+ for (var i = 0; i < hook.length; ++i)
220
+ hook[i].apply(this, args);
221
+ }
222
+
223
+ function initPlugins() {
224
+ for (var i = 0; i < plugins.length; ++i) {
225
+ var p = plugins[i];
226
+ p.init(plot);
227
+ if (p.options)
228
+ $.extend(true, options, p.options);
229
+ }
230
+ }
231
+
232
+ function parseOptions(opts) {
233
+ var i;
234
+
235
+ $.extend(true, options, opts);
236
+
237
+ if (options.xaxis.color == null)
238
+ options.xaxis.color = options.grid.color;
239
+ if (options.yaxis.color == null)
240
+ options.yaxis.color = options.grid.color;
241
+
242
+ if (options.xaxis.tickColor == null) // backwards-compatibility
243
+ options.xaxis.tickColor = options.grid.tickColor;
244
+ if (options.yaxis.tickColor == null) // backwards-compatibility
245
+ options.yaxis.tickColor = options.grid.tickColor;
246
+
247
+ if (options.grid.borderColor == null)
248
+ options.grid.borderColor = options.grid.color;
249
+ if (options.grid.tickColor == null)
250
+ options.grid.tickColor = $.color.parse(options.grid.color).scale('a', 0.22).toString();
251
+
252
+ // fill in defaults in axes, copy at least always the
253
+ // first as the rest of the code assumes it'll be there
254
+ for (i = 0; i < Math.max(1, options.xaxes.length); ++i)
255
+ options.xaxes[i] = $.extend(true, {}, options.xaxis, options.xaxes[i]);
256
+ for (i = 0; i < Math.max(1, options.yaxes.length); ++i)
257
+ options.yaxes[i] = $.extend(true, {}, options.yaxis, options.yaxes[i]);
258
+
259
+ // backwards compatibility, to be removed in future
260
+ if (options.xaxis.noTicks && options.xaxis.ticks == null)
261
+ options.xaxis.ticks = options.xaxis.noTicks;
262
+ if (options.yaxis.noTicks && options.yaxis.ticks == null)
263
+ options.yaxis.ticks = options.yaxis.noTicks;
264
+ if (options.x2axis) {
265
+ options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis);
266
+ options.xaxes[1].position = "top";
267
+ }
268
+ if (options.y2axis) {
269
+ options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis);
270
+ options.yaxes[1].position = "right";
271
+ }
272
+ if (options.grid.coloredAreas)
273
+ options.grid.markings = options.grid.coloredAreas;
274
+ if (options.grid.coloredAreasColor)
275
+ options.grid.markingsColor = options.grid.coloredAreasColor;
276
+ if (options.lines)
277
+ $.extend(true, options.series.lines, options.lines);
278
+ if (options.points)
279
+ $.extend(true, options.series.points, options.points);
280
+ if (options.bars)
281
+ $.extend(true, options.series.bars, options.bars);
282
+ if (options.shadowSize != null)
283
+ options.series.shadowSize = options.shadowSize;
284
+
285
+ // save options on axes for future reference
286
+ for (i = 0; i < options.xaxes.length; ++i)
287
+ getOrCreateAxis(xaxes, i + 1).options = options.xaxes[i];
288
+ for (i = 0; i < options.yaxes.length; ++i)
289
+ getOrCreateAxis(yaxes, i + 1).options = options.yaxes[i];
290
+
291
+ // add hooks from options
292
+ for (var n in hooks)
293
+ if (options.hooks[n] && options.hooks[n].length)
294
+ hooks[n] = hooks[n].concat(options.hooks[n]);
295
+
296
+ executeHooks(hooks.processOptions, [options]);
297
+ }
298
+
299
+ function setData(d) {
300
+ series = parseData(d);
301
+ fillInSeriesOptions();
302
+ processData();
303
+ }
304
+
305
+ function parseData(d) {
306
+ var res = [];
307
+ for (var i = 0; i < d.length; ++i) {
308
+ var s = $.extend(true, {}, options.series);
309
+
310
+ if (d[i].data != null) {
311
+ s.data = d[i].data; // move the data instead of deep-copy
312
+ delete d[i].data;
313
+
314
+ $.extend(true, s, d[i]);
315
+
316
+ d[i].data = s.data;
317
+ }
318
+ else
319
+ s.data = d[i];
320
+ res.push(s);
321
+ }
322
+
323
+ return res;
324
+ }
325
+
326
+ function axisNumber(obj, coord) {
327
+ var a = obj[coord + "axis"];
328
+ if (typeof a == "object") // if we got a real axis, extract number
329
+ a = a.n;
330
+ if (typeof a != "number")
331
+ a = 1; // default to first axis
332
+ return a;
333
+ }
334
+
335
+ function allAxes() {
336
+ // return flat array without annoying null entries
337
+ return $.grep(xaxes.concat(yaxes), function (a) { return a; });
338
+ }
339
+
340
+ function canvasToAxisCoords(pos) {
341
+ // return an object with x/y corresponding to all used axes
342
+ var res = {}, i, axis;
343
+ for (i = 0; i < xaxes.length; ++i) {
344
+ axis = xaxes[i];
345
+ if (axis && axis.used)
346
+ res["x" + axis.n] = axis.c2p(pos.left);
347
+ }
348
+
349
+ for (i = 0; i < yaxes.length; ++i) {
350
+ axis = yaxes[i];
351
+ if (axis && axis.used)
352
+ res["y" + axis.n] = axis.c2p(pos.top);
353
+ }
354
+
355
+ if (res.x1 !== undefined)
356
+ res.x = res.x1;
357
+ if (res.y1 !== undefined)
358
+ res.y = res.y1;
359
+
360
+ return res;
361
+ }
362
+
363
+ function axisToCanvasCoords(pos) {
364
+ // get canvas coords from the first pair of x/y found in pos
365
+ var res = {}, i, axis, key;
366
+
367
+ for (i = 0; i < xaxes.length; ++i) {
368
+ axis = xaxes[i];
369
+ if (axis && axis.used) {
370
+ key = "x" + axis.n;
371
+ if (pos[key] == null && axis.n == 1)
372
+ key = "x";
373
+
374
+ if (pos[key] != null) {
375
+ res.left = axis.p2c(pos[key]);
376
+ break;
377
+ }
378
+ }
379
+ }
380
+
381
+ for (i = 0; i < yaxes.length; ++i) {
382
+ axis = yaxes[i];
383
+ if (axis && axis.used) {
384
+ key = "y" + axis.n;
385
+ if (pos[key] == null && axis.n == 1)
386
+ key = "y";
387
+
388
+ if (pos[key] != null) {
389
+ res.top = axis.p2c(pos[key]);
390
+ break;
391
+ }
392
+ }
393
+ }
394
+
395
+ return res;
396
+ }
397
+
398
+ function getOrCreateAxis(axes, number) {
399
+ if (!axes[number - 1])
400
+ axes[number - 1] = {
401
+ n: number, // save the number for future reference
402
+ direction: axes == xaxes ? "x" : "y",
403
+ options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis)
404
+ };
405
+
406
+ return axes[number - 1];
407
+ }
408
+
409
+ function fillInSeriesOptions() {
410
+ var i;
411
+
412
+ // collect what we already got of colors
413
+ var neededColors = series.length,
414
+ usedColors = [],
415
+ assignedColors = [];
416
+ for (i = 0; i < series.length; ++i) {
417
+ var sc = series[i].color;
418
+ if (sc != null) {
419
+ --neededColors;
420
+ if (typeof sc == "number")
421
+ assignedColors.push(sc);
422
+ else
423
+ usedColors.push($.color.parse(series[i].color));
424
+ }
425
+ }
426
+
427
+ // we might need to generate more colors if higher indices
428
+ // are assigned
429
+ for (i = 0; i < assignedColors.length; ++i) {
430
+ neededColors = Math.max(neededColors, assignedColors[i] + 1);
431
+ }
432
+
433
+ // produce colors as needed
434
+ var colors = [], variation = 0;
435
+ i = 0;
436
+ while (colors.length < neededColors) {
437
+ var c;
438
+ if (options.colors.length == i) // check degenerate case
439
+ c = $.color.make(100, 100, 100);
440
+ else
441
+ c = $.color.parse(options.colors[i]);
442
+
443
+ // vary color if needed
444
+ var sign = variation % 2 == 1 ? -1 : 1;
445
+ c.scale('rgb', 1 + sign * Math.ceil(variation / 2) * 0.2)
446
+
447
+ // FIXME: if we're getting to close to something else,
448
+ // we should probably skip this one
449
+ colors.push(c);
450
+
451
+ ++i;
452
+ if (i >= options.colors.length) {
453
+ i = 0;
454
+ ++variation;
455
+ }
456
+ }
457
+
458
+ // fill in the options
459
+ var colori = 0, s;
460
+ for (i = 0; i < series.length; ++i) {
461
+ s = series[i];
462
+
463
+ // assign colors
464
+ if (s.color == null) {
465
+ s.color = colors[colori].toString();
466
+ ++colori;
467
+ }
468
+ else if (typeof s.color == "number")
469
+ s.color = colors[s.color].toString();
470
+
471
+ // turn on lines automatically in case nothing is set
472
+ if (s.lines.show == null) {
473
+ var v, show = true;
474
+ for (v in s)
475
+ if (s[v] && s[v].show) {
476
+ show = false;
477
+ break;
478
+ }
479
+ if (show)
480
+ s.lines.show = true;
481
+ }
482
+
483
+ // setup axes
484
+ s.xaxis = getOrCreateAxis(xaxes, axisNumber(s, "x"));
485
+ s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y"));
486
+ }
487
+ }
488
+
489
+ function processData() {
490
+ var topSentry = Number.POSITIVE_INFINITY,
491
+ bottomSentry = Number.NEGATIVE_INFINITY,
492
+ fakeInfinity = Number.MAX_VALUE,
493
+ i, j, k, m, length,
494
+ s, points, ps, x, y, axis, val, f, p;
495
+
496
+ function updateAxis(axis, min, max) {
497
+ if (min < axis.datamin && min != -fakeInfinity)
498
+ axis.datamin = min;
499
+ if (max > axis.datamax && max != fakeInfinity)
500
+ axis.datamax = max;
501
+ }
502
+
503
+ $.each(allAxes(), function (_, axis) {
504
+ // init axis
505
+ axis.datamin = topSentry;
506
+ axis.datamax = bottomSentry;
507
+ axis.used = false;
508
+ });
509
+
510
+ for (i = 0; i < series.length; ++i) {
511
+ s = series[i];
512
+ s.datapoints = { points: [] };
513
+
514
+ executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]);
515
+ }
516
+
517
+ // first pass: clean and copy data
518
+ for (i = 0; i < series.length; ++i) {
519
+ s = series[i];
520
+
521
+ var data = s.data, format = s.datapoints.format;
522
+
523
+ if (!format) {
524
+ format = [];
525
+ // find out how to copy
526
+ format.push({ x: true, number: true, required: true });
527
+ format.push({ y: true, number: true, required: true });
528
+
529
+ if (s.bars.show || (s.lines.show && s.lines.fill)) {
530
+ format.push({ y: true, number: true, required: false, defaultValue: 0 });
531
+ if (s.bars.horizontal) {
532
+ delete format[format.length - 1].y;
533
+ format[format.length - 1].x = true;
534
+ }
535
+ }
536
+
537
+ s.datapoints.format = format;
538
+ }
539
+
540
+ if (s.datapoints.pointsize != null)
541
+ continue; // already filled in
542
+
543
+ s.datapoints.pointsize = format.length;
544
+
545
+ ps = s.datapoints.pointsize;
546
+ points = s.datapoints.points;
547
+
548
+ insertSteps = s.lines.show && s.lines.steps;
549
+ s.xaxis.used = s.yaxis.used = true;
550
+
551
+ for (j = k = 0; j < data.length; ++j, k += ps) {
552
+ p = data[j];
553
+
554
+ var nullify = p == null;
555
+ if (!nullify) {
556
+ for (m = 0; m < ps; ++m) {
557
+ val = p[m];
558
+ f = format[m];
559
+
560
+ if (f) {
561
+ if (f.number && val != null) {
562
+ val = +val; // convert to number
563
+ if (isNaN(val))
564
+ val = null;
565
+ else if (val == Infinity)
566
+ val = fakeInfinity;
567
+ else if (val == -Infinity)
568
+ val = -fakeInfinity;
569
+ }
570
+
571
+ if (val == null) {
572
+ if (f.required)
573
+ nullify = true;
574
+
575
+ if (f.defaultValue != null)
576
+ val = f.defaultValue;
577
+ }
578
+ }
579
+
580
+ points[k + m] = val;
581
+ }
582
+ }
583
+
584
+ if (nullify) {
585
+ for (m = 0; m < ps; ++m) {
586
+ val = points[k + m];
587
+ if (val != null) {
588
+ f = format[m];
589
+ // extract min/max info
590
+ if (f.x)
591
+ updateAxis(s.xaxis, val, val);
592
+ if (f.y)
593
+ updateAxis(s.yaxis, val, val);
594
+ }
595
+ points[k + m] = null;
596
+ }
597
+ }
598
+ else {
599
+ // a little bit of line specific stuff that
600
+ // perhaps shouldn't be here, but lacking
601
+ // better means...
602
+ if (insertSteps && k > 0
603
+ && points[k - ps] != null
604
+ && points[k - ps] != points[k]
605
+ && points[k - ps + 1] != points[k + 1]) {
606
+ // copy the point to make room for a middle point
607
+ for (m = 0; m < ps; ++m)
608
+ points[k + ps + m] = points[k + m];
609
+
610
+ // middle point has same y
611
+ points[k + 1] = points[k - ps + 1];
612
+
613
+ // we've added a point, better reflect that
614
+ k += ps;
615
+ }
616
+ }
617
+ }
618
+ }
619
+
620
+ // give the hooks a chance to run
621
+ for (i = 0; i < series.length; ++i) {
622
+ s = series[i];
623
+
624
+ executeHooks(hooks.processDatapoints, [ s, s.datapoints]);
625
+ }
626
+
627
+ // second pass: find datamax/datamin for auto-scaling
628
+ for (i = 0; i < series.length; ++i) {
629
+ s = series[i];
630
+ points = s.datapoints.points,
631
+ ps = s.datapoints.pointsize;
632
+
633
+ var xmin = topSentry, ymin = topSentry,
634
+ xmax = bottomSentry, ymax = bottomSentry;
635
+
636
+ for (j = 0; j < points.length; j += ps) {
637
+ if (points[j] == null)
638
+ continue;
639
+
640
+ for (m = 0; m < ps; ++m) {
641
+ val = points[j + m];
642
+ f = format[m];
643
+ if (!f || val == fakeInfinity || val == -fakeInfinity)
644
+ continue;
645
+
646
+ if (f.x) {
647
+ if (val < xmin)
648
+ xmin = val;
649
+ if (val > xmax)
650
+ xmax = val;
651
+ }
652
+ if (f.y) {
653
+ if (val < ymin)
654
+ ymin = val;
655
+ if (val > ymax)
656
+ ymax = val;
657
+ }
658
+ }
659
+ }
660
+
661
+ if (s.bars.show) {
662
+ // make sure we got room for the bar on the dancing floor
663
+ var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2;
664
+ if (s.bars.horizontal) {
665
+ ymin += delta;
666
+ ymax += delta + s.bars.barWidth;
667
+ }
668
+ else {
669
+ xmin += delta;
670
+ xmax += delta + s.bars.barWidth;
671
+ }
672
+ }
673
+
674
+ updateAxis(s.xaxis, xmin, xmax);
675
+ updateAxis(s.yaxis, ymin, ymax);
676
+ }
677
+
678
+ $.each(allAxes(), function (_, axis) {
679
+ if (axis.datamin == topSentry)
680
+ axis.datamin = null;
681
+ if (axis.datamax == bottomSentry)
682
+ axis.datamax = null;
683
+ });
684
+ }
685
+
686
+ function makeCanvas(skipPositioning, cls) {
687
+ var c = document.createElement('canvas');
688
+ c.className = cls;
689
+ c.width = canvasWidth;
690
+ c.height = canvasHeight;
691
+
692
+ if (!skipPositioning)
693
+ $(c).css({ position: 'absolute', left: 0, top: 0 });
694
+
695
+ $(c).appendTo(placeholder);
696
+
697
+ if (!c.getContext) // excanvas hack
698
+ c = window.G_vmlCanvasManager.initElement(c);
699
+
700
+ // used for resetting in case we get replotted
701
+ c.getContext("2d").save();
702
+
703
+ return c;
704
+ }
705
+
706
+ function getCanvasDimensions() {
707
+ canvasWidth = placeholder.width();
708
+ canvasHeight = placeholder.height();
709
+
710
+ if (canvasWidth <= 0 || canvasHeight <= 0)
711
+ throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight;
712
+ }
713
+
714
+ function resizeCanvas(c) {
715
+ // resizing should reset the state (excanvas seems to be
716
+ // buggy though)
717
+ if (c.width != canvasWidth)
718
+ c.width = canvasWidth;
719
+
720
+ if (c.height != canvasHeight)
721
+ c.height = canvasHeight;
722
+
723
+ // so try to get back to the initial state (even if it's
724
+ // gone now, this should be safe according to the spec)
725
+ var cctx = c.getContext("2d");
726
+ cctx.restore();
727
+
728
+ // and save again
729
+ cctx.save();
730
+ }
731
+
732
+ function setupCanvases() {
733
+ var reused,
734
+ existingCanvas = placeholder.children("canvas.base"),
735
+ existingOverlay = placeholder.children("canvas.overlay");
736
+
737
+ if (existingCanvas.length == 0 || existingOverlay == 0) {
738
+ // init everything
739
+
740
+ placeholder.html(""); // make sure placeholder is clear
741
+
742
+ placeholder.css({ padding: 0 }); // padding messes up the positioning
743
+
744
+ if (placeholder.css("position") == 'static')
745
+ placeholder.css("position", "relative"); // for positioning labels and overlay
746
+
747
+ getCanvasDimensions();
748
+
749
+ canvas = makeCanvas(true, "base");
750
+ overlay = makeCanvas(false, "overlay"); // overlay canvas for interactive features
751
+
752
+ reused = false;
753
+ }
754
+ else {
755
+ // reuse existing elements
756
+
757
+ canvas = existingCanvas.get(0);
758
+ overlay = existingOverlay.get(0);
759
+
760
+ reused = true;
761
+ }
762
+
763
+ ctx = canvas.getContext("2d");
764
+ octx = overlay.getContext("2d");
765
+
766
+ // we include the canvas in the event holder too, because IE 7
767
+ // sometimes has trouble with the stacking order
768
+ eventHolder = $([overlay, canvas]);
769
+
770
+ if (reused) {
771
+ // run shutdown in the old plot object
772
+ placeholder.data("plot").shutdown();
773
+
774
+ // reset reused canvases
775
+ plot.resize();
776
+
777
+ // make sure overlay pixels are cleared (canvas is cleared when we redraw)
778
+ octx.clearRect(0, 0, canvasWidth, canvasHeight);
779
+
780
+ // then whack any remaining obvious garbage left
781
+ eventHolder.unbind();
782
+ placeholder.children().not([canvas, overlay]).remove();
783
+ }
784
+
785
+ // save in case we get replotted
786
+ placeholder.data("plot", plot);
787
+ }
788
+
789
+ function bindEvents() {
790
+ // bind events
791
+ if (options.grid.hoverable) {
792
+ eventHolder.mousemove(onMouseMove);
793
+ eventHolder.mouseleave(onMouseLeave);
794
+ }
795
+
796
+ if (options.grid.clickable)
797
+ eventHolder.click(onClick);
798
+
799
+ executeHooks(hooks.bindEvents, [eventHolder]);
800
+ }
801
+
802
+ function shutdown() {
803
+ if (redrawTimeout)
804
+ clearTimeout(redrawTimeout);
805
+
806
+ eventHolder.unbind("mousemove", onMouseMove);
807
+ eventHolder.unbind("mouseleave", onMouseLeave);
808
+ eventHolder.unbind("click", onClick);
809
+
810
+ executeHooks(hooks.shutdown, [eventHolder]);
811
+ }
812
+
813
+ function setTransformationHelpers(axis) {
814
+ // set helper functions on the axis, assumes plot area
815
+ // has been computed already
816
+
817
+ function identity(x) { return x; }
818
+
819
+ var s, m, t = axis.options.transform || identity,
820
+ it = axis.options.inverseTransform;
821
+
822
+ // precompute how much the axis is scaling a point
823
+ // in canvas space
824
+ if (axis.direction == "x") {
825
+ s = axis.scale = plotWidth / Math.abs(t(axis.max) - t(axis.min));
826
+ m = Math.min(t(axis.max), t(axis.min));
827
+ }
828
+ else {
829
+ s = axis.scale = plotHeight / Math.abs(t(axis.max) - t(axis.min));
830
+ s = -s;
831
+ m = Math.max(t(axis.max), t(axis.min));
832
+ }
833
+
834
+ // data point to canvas coordinate
835
+ if (t == identity) // slight optimization
836
+ axis.p2c = function (p) { return (p - m) * s; };
837
+ else
838
+ axis.p2c = function (p) { return (t(p) - m) * s; };
839
+ // canvas coordinate to data point
840
+ if (!it)
841
+ axis.c2p = function (c) { return m + c / s; };
842
+ else
843
+ axis.c2p = function (c) { return it(m + c / s); };
844
+ }
845
+
846
+ function measureTickLabels(axis) {
847
+ var opts = axis.options, i, ticks = axis.ticks || [], labels = [],
848
+ l, w = opts.labelWidth, h = opts.labelHeight, dummyDiv;
849
+
850
+ function makeDummyDiv(labels, width) {
851
+ return $('<div style="position:absolute;top:-10000px;' + width + 'font-size:smaller">' +
852
+ '<div class="' + axis.direction + 'Axis ' + axis.direction + axis.n + 'Axis">'
853
+ + labels.join("") + '</div></div>')
854
+ .appendTo(placeholder);
855
+ }
856
+
857
+ if (axis.direction == "x") {
858
+ // to avoid measuring the widths of the labels (it's slow), we
859
+ // construct fixed-size boxes and put the labels inside
860
+ // them, we don't need the exact figures and the
861
+ // fixed-size box content is easy to center
862
+ if (w == null)
863
+ w = Math.floor(canvasWidth / (ticks.length > 0 ? ticks.length : 1));
864
+
865
+ // measure x label heights
866
+ if (h == null) {
867
+ labels = [];
868
+ for (i = 0; i < ticks.length; ++i) {
869
+ l = ticks[i].label;
870
+ if (l)
871
+ labels.push('<div class="tickLabel" style="float:left;width:' + w + 'px">' + l + '</div>');
872
+ }
873
+
874
+ if (labels.length > 0) {
875
+ // stick them all in the same div and measure
876
+ // collective height
877
+ labels.push('<div style="clear:left"></div>');
878
+ dummyDiv = makeDummyDiv(labels, "width:10000px;");
879
+ h = dummyDiv.height();
880
+ dummyDiv.remove();
881
+ }
882
+ }
883
+ }
884
+ else if (w == null || h == null) {
885
+ // calculate y label dimensions
886
+ for (i = 0; i < ticks.length; ++i) {
887
+ l = ticks[i].label;
888
+ if (l)
889
+ labels.push('<div class="tickLabel">' + l + '</div>');
890
+ }
891
+
892
+ if (labels.length > 0) {
893
+ dummyDiv = makeDummyDiv(labels, "");
894
+ if (w == null)
895
+ w = dummyDiv.children().width();
896
+ if (h == null)
897
+ h = dummyDiv.find("div.tickLabel").height();
898
+ dummyDiv.remove();
899
+ }
900
+ }
901
+
902
+ if (w == null)
903
+ w = 0;
904
+ if (h == null)
905
+ h = 0;
906
+
907
+ axis.labelWidth = w;
908
+ axis.labelHeight = h;
909
+ }
910
+
911
+ function allocateAxisBoxFirstPhase(axis) {
912
+ // find the bounding box of the axis by looking at label
913
+ // widths/heights and ticks, make room by diminishing the
914
+ // plotOffset
915
+
916
+ var lw = axis.labelWidth,
917
+ lh = axis.labelHeight,
918
+ pos = axis.options.position,
919
+ tickLength = axis.options.tickLength,
920
+ axismargin = options.grid.axisMargin,
921
+ padding = options.grid.labelMargin,
922
+ all = axis.direction == "x" ? xaxes : yaxes,
923
+ index;
924
+
925
+ // determine axis margin
926
+ var samePosition = $.grep(all, function (a) {
927
+ return a && a.options.position == pos && a.reserveSpace;
928
+ });
929
+ if ($.inArray(axis, samePosition) == samePosition.length - 1)
930
+ axismargin = 0; // outermost
931
+
932
+ // determine tick length - if we're innermost, we can use "full"
933
+ if (tickLength == null)
934
+ tickLength = "full";
935
+
936
+ var sameDirection = $.grep(all, function (a) {
937
+ return a && a.reserveSpace;
938
+ });
939
+
940
+ var innermost = $.inArray(axis, sameDirection) == 0;
941
+ if (!innermost && tickLength == "full")
942
+ tickLength = 5;
943
+
944
+ if (!isNaN(+tickLength))
945
+ padding += +tickLength;
946
+
947
+ // compute box
948
+ if (axis.direction == "x") {
949
+ lh += padding;
950
+
951
+ if (pos == "bottom") {
952
+ plotOffset.bottom += lh + axismargin;
953
+ axis.box = { top: canvasHeight - plotOffset.bottom, height: lh };
954
+ }
955
+ else {
956
+ axis.box = { top: plotOffset.top + axismargin, height: lh };
957
+ plotOffset.top += lh + axismargin;
958
+ }
959
+ }
960
+ else {
961
+ lw += padding;
962
+
963
+ if (pos == "left") {
964
+ axis.box = { left: plotOffset.left + axismargin, width: lw };
965
+ plotOffset.left += lw + axismargin;
966
+ }
967
+ else {
968
+ plotOffset.right += lw + axismargin;
969
+ axis.box = { left: canvasWidth - plotOffset.right, width: lw };
970
+ }
971
+ }
972
+
973
+ // save for future reference
974
+ axis.position = pos;
975
+ axis.tickLength = tickLength;
976
+ axis.box.padding = padding;
977
+ axis.innermost = innermost;
978
+ }
979
+
980
+ function allocateAxisBoxSecondPhase(axis) {
981
+ // set remaining bounding box coordinates
982
+ if (axis.direction == "x") {
983
+ axis.box.left = plotOffset.left;
984
+ axis.box.width = plotWidth;
985
+ }
986
+ else {
987
+ axis.box.top = plotOffset.top;
988
+ axis.box.height = plotHeight;
989
+ }
990
+ }
991
+
992
+ function setupGrid() {
993
+ var i, axes = allAxes();
994
+
995
+ // first calculate the plot and axis box dimensions
996
+
997
+ $.each(axes, function (_, axis) {
998
+ axis.show = axis.options.show;
999
+ if (axis.show == null)
1000
+ axis.show = axis.used; // by default an axis is visible if it's got data
1001
+
1002
+ axis.reserveSpace = axis.show || axis.options.reserveSpace;
1003
+
1004
+ setRange(axis);
1005
+ });
1006
+
1007
+ allocatedAxes = $.grep(axes, function (axis) { return axis.reserveSpace; });
1008
+
1009
+ plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 0;
1010
+ if (options.grid.show) {
1011
+ $.each(allocatedAxes, function (_, axis) {
1012
+ // make the ticks
1013
+ setupTickGeneration(axis);
1014
+ setTicks(axis);
1015
+ snapRangeToTicks(axis, axis.ticks);
1016
+
1017
+ // find labelWidth/Height for axis
1018
+ measureTickLabels(axis);
1019
+ });
1020
+
1021
+ // with all dimensions in house, we can compute the
1022
+ // axis boxes, start from the outside (reverse order)
1023
+ for (i = allocatedAxes.length - 1; i >= 0; --i)
1024
+ allocateAxisBoxFirstPhase(allocatedAxes[i]);
1025
+
1026
+ // make sure we've got enough space for things that
1027
+ // might stick out
1028
+ var minMargin = options.grid.minBorderMargin;
1029
+ if (minMargin == null) {
1030
+ minMargin = 0;
1031
+ for (i = 0; i < series.length; ++i)
1032
+ minMargin = Math.max(minMargin, series[i].points.radius + series[i].points.lineWidth/2);
1033
+ }
1034
+
1035
+ for (var a in plotOffset) {
1036
+ plotOffset[a] += options.grid.borderWidth;
1037
+ plotOffset[a] = Math.max(minMargin, plotOffset[a]);
1038
+ }
1039
+ }
1040
+
1041
+ plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
1042
+ plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;
1043
+
1044
+ // now we got the proper plotWidth/Height, we can compute the scaling
1045
+ $.each(axes, function (_, axis) {
1046
+ setTransformationHelpers(axis);
1047
+ });
1048
+
1049
+ if (options.grid.show) {
1050
+ $.each(allocatedAxes, function (_, axis) {
1051
+ allocateAxisBoxSecondPhase(axis);
1052
+ });
1053
+
1054
+ insertAxisLabels();
1055
+ }
1056
+
1057
+ insertLegend();
1058
+ }
1059
+
1060
+ function setRange(axis) {
1061
+ var opts = axis.options,
1062
+ min = +(opts.min != null ? opts.min : axis.datamin),
1063
+ max = +(opts.max != null ? opts.max : axis.datamax),
1064
+ delta = max - min;
1065
+
1066
+ if (delta == 0.0) {
1067
+ // degenerate case
1068
+ var widen = max == 0 ? 1 : 0.01;
1069
+
1070
+ if (opts.min == null)
1071
+ min -= widen;
1072
+ // always widen max if we couldn't widen min to ensure we
1073
+ // don't fall into min == max which doesn't work
1074
+ if (opts.max == null || opts.min != null)
1075
+ max += widen;
1076
+ }
1077
+ else {
1078
+ // consider autoscaling
1079
+ var margin = opts.autoscaleMargin;
1080
+ if (margin != null) {
1081
+ if (opts.min == null) {
1082
+ min -= delta * margin;
1083
+ // make sure we don't go below zero if all values
1084
+ // are positive
1085
+ if (min < 0 && axis.datamin != null && axis.datamin >= 0)
1086
+ min = 0;
1087
+ }
1088
+ if (opts.max == null) {
1089
+ max += delta * margin;
1090
+ if (max > 0 && axis.datamax != null && axis.datamax <= 0)
1091
+ max = 0;
1092
+ }
1093
+ }
1094
+ }
1095
+ axis.min = min;
1096
+ axis.max = max;
1097
+ }
1098
+
1099
+ function setupTickGeneration(axis) {
1100
+ var opts = axis.options;
1101
+
1102
+ // estimate number of ticks
1103
+ var noTicks;
1104
+ if (typeof opts.ticks == "number" && opts.ticks > 0)
1105
+ noTicks = opts.ticks;
1106
+ else
1107
+ // heuristic based on the model a*sqrt(x) fitted to
1108
+ // some data points that seemed reasonable
1109
+ noTicks = 0.3 * Math.sqrt(axis.direction == "x" ? canvasWidth : canvasHeight);
1110
+
1111
+ var delta = (axis.max - axis.min) / noTicks,
1112
+ size, generator, unit, formatter, i, magn, norm;
1113
+
1114
+ if (opts.mode == "time") {
1115
+ // pretty handling of time
1116
+
1117
+ // map of app. size of time units in milliseconds
1118
+ var timeUnitSize = {
1119
+ "second": 1000,
1120
+ "minute": 60 * 1000,
1121
+ "hour": 60 * 60 * 1000,
1122
+ "day": 24 * 60 * 60 * 1000,
1123
+ "month": 30 * 24 * 60 * 60 * 1000,
1124
+ "year": 365.2425 * 24 * 60 * 60 * 1000
1125
+ };
1126
+
1127
+
1128
+ // the allowed tick sizes, after 1 year we use
1129
+ // an integer algorithm
1130
+ var spec = [
1131
+ [1, "second"], [2, "second"], [5, "second"], [10, "second"],
1132
+ [30, "second"],
1133
+ [1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
1134
+ [30, "minute"],
1135
+ [1, "hour"], [2, "hour"], [4, "hour"],
1136
+ [8, "hour"], [12, "hour"],
1137
+ [1, "day"], [2, "day"], [3, "day"],
1138
+ [0.25, "month"], [0.5, "month"], [1, "month"],
1139
+ [2, "month"], [3, "month"], [6, "month"],
1140
+ [1, "year"]
1141
+ ];
1142
+
1143
+ var minSize = 0;
1144
+ if (opts.minTickSize != null) {
1145
+ if (typeof opts.tickSize == "number")
1146
+ minSize = opts.tickSize;
1147
+ else
1148
+ minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]];
1149
+ }
1150
+
1151
+ for (var i = 0; i < spec.length - 1; ++i)
1152
+ if (delta < (spec[i][0] * timeUnitSize[spec[i][1]]
1153
+ + spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
1154
+ && spec[i][0] * timeUnitSize[spec[i][1]] >= minSize)
1155
+ break;
1156
+ size = spec[i][0];
1157
+ unit = spec[i][1];
1158
+
1159
+ // special-case the possibility of several years
1160
+ if (unit == "year") {
1161
+ magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10));
1162
+ norm = (delta / timeUnitSize.year) / magn;
1163
+ if (norm < 1.5)
1164
+ size = 1;
1165
+ else if (norm < 3)
1166
+ size = 2;
1167
+ else if (norm < 7.5)
1168
+ size = 5;
1169
+ else
1170
+ size = 10;
1171
+
1172
+ size *= magn;
1173
+ }
1174
+
1175
+ axis.tickSize = opts.tickSize || [size, unit];
1176
+
1177
+ generator = function(axis) {
1178
+ var ticks = [],
1179
+ tickSize = axis.tickSize[0], unit = axis.tickSize[1],
1180
+ d = new Date(axis.min);
1181
+
1182
+ var step = tickSize * timeUnitSize[unit];
1183
+
1184
+ if (unit == "second")
1185
+ d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize));
1186
+ if (unit == "minute")
1187
+ d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize));
1188
+ if (unit == "hour")
1189
+ d.setUTCHours(floorInBase(d.getUTCHours(), tickSize));
1190
+ if (unit == "month")
1191
+ d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize));
1192
+ if (unit == "year")
1193
+ d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize));
1194
+
1195
+ // reset smaller components
1196
+ d.setUTCMilliseconds(0);
1197
+ if (step >= timeUnitSize.minute)
1198
+ d.setUTCSeconds(0);
1199
+ if (step >= timeUnitSize.hour)
1200
+ d.setUTCMinutes(0);
1201
+ if (step >= timeUnitSize.day)
1202
+ d.setUTCHours(0);
1203
+ if (step >= timeUnitSize.day * 4)
1204
+ d.setUTCDate(1);
1205
+ if (step >= timeUnitSize.year)
1206
+ d.setUTCMonth(0);
1207
+
1208
+
1209
+ var carry = 0, v = Number.NaN, prev;
1210
+ do {
1211
+ prev = v;
1212
+ v = d.getTime();
1213
+ ticks.push(v);
1214
+ if (unit == "month") {
1215
+ if (tickSize < 1) {
1216
+ // a bit complicated - we'll divide the month
1217
+ // up but we need to take care of fractions
1218
+ // so we don't end up in the middle of a day
1219
+ d.setUTCDate(1);
1220
+ var start = d.getTime();
1221
+ d.setUTCMonth(d.getUTCMonth() + 1);
1222
+ var end = d.getTime();
1223
+ d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
1224
+ carry = d.getUTCHours();
1225
+ d.setUTCHours(0);
1226
+ }
1227
+ else
1228
+ d.setUTCMonth(d.getUTCMonth() + tickSize);
1229
+ }
1230
+ else if (unit == "year") {
1231
+ d.setUTCFullYear(d.getUTCFullYear() + tickSize);
1232
+ }
1233
+ else
1234
+ d.setTime(v + step);
1235
+ } while (v < axis.max && v != prev);
1236
+
1237
+ return ticks;
1238
+ };
1239
+
1240
+ formatter = function (v, axis) {
1241
+ var d = new Date(v);
1242
+
1243
+ // first check global format
1244
+ if (opts.timeformat != null)
1245
+ return $.plot.formatDate(d, opts.timeformat, opts.monthNames);
1246
+
1247
+ var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
1248
+ var span = axis.max - axis.min;
1249
+ var suffix = (opts.twelveHourClock) ? " %p" : "";
1250
+
1251
+ if (t < timeUnitSize.minute)
1252
+ fmt = "%h:%M:%S" + suffix;
1253
+ else if (t < timeUnitSize.day) {
1254
+ if (span < 2 * timeUnitSize.day)
1255
+ fmt = "%h:%M" + suffix;
1256
+ else
1257
+ fmt = "%b %d %h:%M" + suffix;
1258
+ }
1259
+ else if (t < timeUnitSize.month)
1260
+ fmt = "%b %d";
1261
+ else if (t < timeUnitSize.year) {
1262
+ if (span < timeUnitSize.year)
1263
+ fmt = "%b";
1264
+ else
1265
+ fmt = "%b %y";
1266
+ }
1267
+ else
1268
+ fmt = "%y";
1269
+
1270
+ return $.plot.formatDate(d, fmt, opts.monthNames);
1271
+ };
1272
+ }
1273
+ else {
1274
+ // pretty rounding of base-10 numbers
1275
+ var maxDec = opts.tickDecimals;
1276
+ var dec = -Math.floor(Math.log(delta) / Math.LN10);
1277
+ if (maxDec != null && dec > maxDec)
1278
+ dec = maxDec;
1279
+
1280
+ magn = Math.pow(10, -dec);
1281
+ norm = delta / magn; // norm is between 1.0 and 10.0
1282
+
1283
+ if (norm < 1.5)
1284
+ size = 1;
1285
+ else if (norm < 3) {
1286
+ size = 2;
1287
+ // special case for 2.5, requires an extra decimal
1288
+ if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
1289
+ size = 2.5;
1290
+ ++dec;
1291
+ }
1292
+ }
1293
+ else if (norm < 7.5)
1294
+ size = 5;
1295
+ else
1296
+ size = 10;
1297
+
1298
+ size *= magn;
1299
+
1300
+ if (opts.minTickSize != null && size < opts.minTickSize)
1301
+ size = opts.minTickSize;
1302
+
1303
+ axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec);
1304
+ axis.tickSize = opts.tickSize || size;
1305
+
1306
+ generator = function (axis) {
1307
+ var ticks = [];
1308
+
1309
+ // spew out all possible ticks
1310
+ var start = floorInBase(axis.min, axis.tickSize),
1311
+ i = 0, v = Number.NaN, prev;
1312
+ do {
1313
+ prev = v;
1314
+ v = start + i * axis.tickSize;
1315
+ ticks.push(v);
1316
+ ++i;
1317
+ } while (v < axis.max && v != prev);
1318
+ return ticks;
1319
+ };
1320
+
1321
+ formatter = function (v, axis) {
1322
+ return v.toFixed(axis.tickDecimals);
1323
+ };
1324
+ }
1325
+
1326
+ if (opts.alignTicksWithAxis != null) {
1327
+ var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1];
1328
+ if (otherAxis && otherAxis.used && otherAxis != axis) {
1329
+ // consider snapping min/max to outermost nice ticks
1330
+ var niceTicks = generator(axis);
1331
+ if (niceTicks.length > 0) {
1332
+ if (opts.min == null)
1333
+ axis.min = Math.min(axis.min, niceTicks[0]);
1334
+ if (opts.max == null && niceTicks.length > 1)
1335
+ axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]);
1336
+ }
1337
+
1338
+ generator = function (axis) {
1339
+ // copy ticks, scaled to this axis
1340
+ var ticks = [], v, i;
1341
+ for (i = 0; i < otherAxis.ticks.length; ++i) {
1342
+ v = (otherAxis.ticks[i].v - otherAxis.min) / (otherAxis.max - otherAxis.min);
1343
+ v = axis.min + v * (axis.max - axis.min);
1344
+ ticks.push(v);
1345
+ }
1346
+ return ticks;
1347
+ };
1348
+
1349
+ // we might need an extra decimal since forced
1350
+ // ticks don't necessarily fit naturally
1351
+ if (axis.mode != "time" && opts.tickDecimals == null) {
1352
+ var extraDec = Math.max(0, -Math.floor(Math.log(delta) / Math.LN10) + 1),
1353
+ ts = generator(axis);
1354
+
1355
+ // only proceed if the tick interval rounded
1356
+ // with an extra decimal doesn't give us a
1357
+ // zero at end
1358
+ if (!(ts.length > 1 && /\..*0$/.test((ts[1] - ts[0]).toFixed(extraDec))))
1359
+ axis.tickDecimals = extraDec;
1360
+ }
1361
+ }
1362
+ }
1363
+
1364
+ axis.tickGenerator = generator;
1365
+ if ($.isFunction(opts.tickFormatter))
1366
+ axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); };
1367
+ else
1368
+ axis.tickFormatter = formatter;
1369
+ }
1370
+
1371
+ function setTicks(axis) {
1372
+ var oticks = axis.options.ticks, ticks = [];
1373
+ if (oticks == null || (typeof oticks == "number" && oticks > 0))
1374
+ ticks = axis.tickGenerator(axis);
1375
+ else if (oticks) {
1376
+ if ($.isFunction(oticks))
1377
+ // generate the ticks
1378
+ ticks = oticks({ min: axis.min, max: axis.max });
1379
+ else
1380
+ ticks = oticks;
1381
+ }
1382
+
1383
+ // clean up/labelify the supplied ticks, copy them over
1384
+ var i, v;
1385
+ axis.ticks = [];
1386
+ for (i = 0; i < ticks.length; ++i) {
1387
+ var label = null;
1388
+ var t = ticks[i];
1389
+ if (typeof t == "object") {
1390
+ v = +t[0];
1391
+ if (t.length > 1)
1392
+ label = t[1];
1393
+ }
1394
+ else
1395
+ v = +t;
1396
+ if (label == null)
1397
+ label = axis.tickFormatter(v, axis);
1398
+ if (!isNaN(v))
1399
+ axis.ticks.push({ v: v, label: label });
1400
+ }
1401
+ }
1402
+
1403
+ function snapRangeToTicks(axis, ticks) {
1404
+ if (axis.options.autoscaleMargin && ticks.length > 0) {
1405
+ // snap to ticks
1406
+ if (axis.options.min == null)
1407
+ axis.min = Math.min(axis.min, ticks[0].v);
1408
+ if (axis.options.max == null && ticks.length > 1)
1409
+ axis.max = Math.max(axis.max, ticks[ticks.length - 1].v);
1410
+ }
1411
+ }
1412
+
1413
+ function draw() {
1414
+ ctx.clearRect(0, 0, canvasWidth, canvasHeight);
1415
+
1416
+ var grid = options.grid;
1417
+
1418
+ // draw background, if any
1419
+ if (grid.show && grid.backgroundColor)
1420
+ drawBackground();
1421
+
1422
+ if (grid.show && !grid.aboveData)
1423
+ drawGrid();
1424
+
1425
+ for (var i = 0; i < series.length; ++i) {
1426
+ executeHooks(hooks.drawSeries, [ctx, series[i]]);
1427
+ drawSeries(series[i]);
1428
+ }
1429
+
1430
+ executeHooks(hooks.draw, [ctx]);
1431
+
1432
+ if (grid.show && grid.aboveData)
1433
+ drawGrid();
1434
+ }
1435
+
1436
+ function extractRange(ranges, coord) {
1437
+ var axis, from, to, key, axes = allAxes();
1438
+
1439
+ for (i = 0; i < axes.length; ++i) {
1440
+ axis = axes[i];
1441
+ if (axis.direction == coord) {
1442
+ key = coord + axis.n + "axis";
1443
+ if (!ranges[key] && axis.n == 1)
1444
+ key = coord + "axis"; // support x1axis as xaxis
1445
+ if (ranges[key]) {
1446
+ from = ranges[key].from;
1447
+ to = ranges[key].to;
1448
+ break;
1449
+ }
1450
+ }
1451
+ }
1452
+
1453
+ // backwards-compat stuff - to be removed in future
1454
+ if (!ranges[key]) {
1455
+ axis = coord == "x" ? xaxes[0] : yaxes[0];
1456
+ from = ranges[coord + "1"];
1457
+ to = ranges[coord + "2"];
1458
+ }
1459
+
1460
+ // auto-reverse as an added bonus
1461
+ if (from != null && to != null && from > to) {
1462
+ var tmp = from;
1463
+ from = to;
1464
+ to = tmp;
1465
+ }
1466
+
1467
+ return { from: from, to: to, axis: axis };
1468
+ }
1469
+
1470
+ function drawBackground() {
1471
+ ctx.save();
1472
+ ctx.translate(plotOffset.left, plotOffset.top);
1473
+
1474
+ ctx.fillStyle = getColorOrGradient(options.grid.backgroundColor, plotHeight, 0, "rgba(255, 255, 255, 0)");
1475
+ ctx.fillRect(0, 0, plotWidth, plotHeight);
1476
+ ctx.restore();
1477
+ }
1478
+
1479
+ function drawGrid() {
1480
+ var i;
1481
+
1482
+ ctx.save();
1483
+ ctx.translate(plotOffset.left, plotOffset.top);
1484
+
1485
+ // draw markings
1486
+ var markings = options.grid.markings;
1487
+ if (markings) {
1488
+ if ($.isFunction(markings)) {
1489
+ var axes = plot.getAxes();
1490
+ // xmin etc. is backwards compatibility, to be
1491
+ // removed in the future
1492
+ axes.xmin = axes.xaxis.min;
1493
+ axes.xmax = axes.xaxis.max;
1494
+ axes.ymin = axes.yaxis.min;
1495
+ axes.ymax = axes.yaxis.max;
1496
+
1497
+ markings = markings(axes);
1498
+ }
1499
+
1500
+ for (i = 0; i < markings.length; ++i) {
1501
+ var m = markings[i],
1502
+ xrange = extractRange(m, "x"),
1503
+ yrange = extractRange(m, "y");
1504
+
1505
+ // fill in missing
1506
+ if (xrange.from == null)
1507
+ xrange.from = xrange.axis.min;
1508
+ if (xrange.to == null)
1509
+ xrange.to = xrange.axis.max;
1510
+ if (yrange.from == null)
1511
+ yrange.from = yrange.axis.min;
1512
+ if (yrange.to == null)
1513
+ yrange.to = yrange.axis.max;
1514
+
1515
+ // clip
1516
+ if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max ||
1517
+ yrange.to < yrange.axis.min || yrange.from > yrange.axis.max)
1518
+ continue;
1519
+
1520
+ xrange.from = Math.max(xrange.from, xrange.axis.min);
1521
+ xrange.to = Math.min(xrange.to, xrange.axis.max);
1522
+ yrange.from = Math.max(yrange.from, yrange.axis.min);
1523
+ yrange.to = Math.min(yrange.to, yrange.axis.max);
1524
+
1525
+ if (xrange.from == xrange.to && yrange.from == yrange.to)
1526
+ continue;
1527
+
1528
+ // then draw
1529
+ xrange.from = xrange.axis.p2c(xrange.from);
1530
+ xrange.to = xrange.axis.p2c(xrange.to);
1531
+ yrange.from = yrange.axis.p2c(yrange.from);
1532
+ yrange.to = yrange.axis.p2c(yrange.to);
1533
+
1534
+ if (xrange.from == xrange.to || yrange.from == yrange.to) {
1535
+ // draw line
1536
+ ctx.beginPath();
1537
+ ctx.strokeStyle = m.color || options.grid.markingsColor;
1538
+ ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth;
1539
+ ctx.moveTo(xrange.from, yrange.from);
1540
+ ctx.lineTo(xrange.to, yrange.to);
1541
+ ctx.stroke();
1542
+ }
1543
+ else {
1544
+ // fill area
1545
+ ctx.fillStyle = m.color || options.grid.markingsColor;
1546
+ ctx.fillRect(xrange.from, yrange.to,
1547
+ xrange.to - xrange.from,
1548
+ yrange.from - yrange.to);
1549
+ }
1550
+ }
1551
+ }
1552
+
1553
+ // draw the ticks
1554
+ var axes = allAxes(), bw = options.grid.borderWidth;
1555
+
1556
+ for (var j = 0; j < axes.length; ++j) {
1557
+ var axis = axes[j], box = axis.box,
1558
+ t = axis.tickLength, x, y, xoff, yoff;
1559
+ if (!axis.show || axis.ticks.length == 0)
1560
+ continue
1561
+
1562
+ ctx.strokeStyle = axis.options.tickColor || $.color.parse(axis.options.color).scale('a', 0.22).toString();
1563
+ ctx.lineWidth = 1;
1564
+
1565
+ // find the edges
1566
+ if (axis.direction == "x") {
1567
+ x = 0;
1568
+ if (t == "full")
1569
+ y = (axis.position == "top" ? 0 : plotHeight);
1570
+ else
1571
+ y = box.top - plotOffset.top + (axis.position == "top" ? box.height : 0);
1572
+ }
1573
+ else {
1574
+ y = 0;
1575
+ if (t == "full")
1576
+ x = (axis.position == "left" ? 0 : plotWidth);
1577
+ else
1578
+ x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0);
1579
+ }
1580
+
1581
+ // draw tick bar
1582
+ if (!axis.innermost) {
1583
+ ctx.beginPath();
1584
+ xoff = yoff = 0;
1585
+ if (axis.direction == "x")
1586
+ xoff = plotWidth;
1587
+ else
1588
+ yoff = plotHeight;
1589
+
1590
+ if (ctx.lineWidth == 1) {
1591
+ x = Math.floor(x) + 0.5;
1592
+ y = Math.floor(y) + 0.5;
1593
+ }
1594
+
1595
+ ctx.moveTo(x, y);
1596
+ ctx.lineTo(x + xoff, y + yoff);
1597
+ ctx.stroke();
1598
+ }
1599
+
1600
+ // draw ticks
1601
+ ctx.beginPath();
1602
+ for (i = 0; i < axis.ticks.length; ++i) {
1603
+ var v = axis.ticks[i].v;
1604
+
1605
+ xoff = yoff = 0;
1606
+
1607
+ if (v < axis.min || v > axis.max
1608
+ // skip those lying on the axes if we got a border
1609
+ || (t == "full" && bw > 0
1610
+ && (v == axis.min || v == axis.max)))
1611
+ continue;
1612
+
1613
+ if (axis.direction == "x") {
1614
+ x = axis.p2c(v);
1615
+ yoff = t == "full" ? -plotHeight : t;
1616
+
1617
+ if (axis.position == "top")
1618
+ yoff = -yoff;
1619
+ }
1620
+ else {
1621
+ y = axis.p2c(v);
1622
+ xoff = t == "full" ? -plotWidth : t;
1623
+
1624
+ if (axis.position == "left")
1625
+ xoff = -xoff;
1626
+ }
1627
+
1628
+ if (ctx.lineWidth == 1) {
1629
+ if (axis.direction == "x")
1630
+ x = Math.floor(x) + 0.5;
1631
+ else
1632
+ y = Math.floor(y) + 0.5;
1633
+ }
1634
+
1635
+ ctx.moveTo(x, y);
1636
+ ctx.lineTo(x + xoff, y + yoff);
1637
+ }
1638
+
1639
+ ctx.stroke();
1640
+ }
1641
+
1642
+
1643
+ // draw border
1644
+ if (bw) {
1645
+ ctx.lineWidth = bw;
1646
+ ctx.strokeStyle = options.grid.borderColor;
1647
+ ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw);
1648
+ }
1649
+
1650
+ ctx.restore();
1651
+ }
1652
+
1653
+ function insertAxisLabels() {
1654
+ placeholder.find(".tickLabels").remove();
1655
+
1656
+ var html = ['<div class="tickLabels" style="font-size:smaller">'];
1657
+
1658
+ var axes = allAxes();
1659
+ for (var j = 0; j < axes.length; ++j) {
1660
+ var axis = axes[j], box = axis.box;
1661
+ if (!axis.show)
1662
+ continue;
1663
+ //debug: html.push('<div style="position:absolute;opacity:0.10;background-color:red;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>')
1664
+ html.push('<div class="' + axis.direction + 'Axis ' + axis.direction + axis.n + 'Axis" style="color:' + axis.options.color + '">');
1665
+ for (var i = 0; i < axis.ticks.length; ++i) {
1666
+ var tick = axis.ticks[i];
1667
+ if (!tick.label || tick.v < axis.min || tick.v > axis.max)
1668
+ continue;
1669
+
1670
+ var pos = {}, align;
1671
+
1672
+ if (axis.direction == "x") {
1673
+ align = "center";
1674
+ pos.left = Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2);
1675
+ if (axis.position == "bottom")
1676
+ pos.top = box.top + box.padding;
1677
+ else
1678
+ pos.bottom = canvasHeight - (box.top + box.height - box.padding);
1679
+ }
1680
+ else {
1681
+ pos.top = Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2);
1682
+ if (axis.position == "left") {
1683
+ pos.right = canvasWidth - (box.left + box.width - box.padding)
1684
+ align = "right";
1685
+ }
1686
+ else {
1687
+ pos.left = box.left + box.padding;
1688
+ align = "left";
1689
+ }
1690
+ }
1691
+
1692
+ pos.width = axis.labelWidth;
1693
+
1694
+ var style = ["position:absolute", "text-align:" + align ];
1695
+ for (var a in pos)
1696
+ style.push(a + ":" + pos[a] + "px")
1697
+
1698
+ html.push('<div class="tickLabel" style="' + style.join(';') + '">' + tick.label + '</div>');
1699
+ }
1700
+ html.push('</div>');
1701
+ }
1702
+
1703
+ html.push('</div>');
1704
+
1705
+ placeholder.append(html.join(""));
1706
+ }
1707
+
1708
+ function drawSeries(series) {
1709
+ if (series.lines.show)
1710
+ drawSeriesLines(series);
1711
+ if (series.bars.show)
1712
+ drawSeriesBars(series);
1713
+ if (series.points.show)
1714
+ drawSeriesPoints(series);
1715
+ }
1716
+
1717
+ function drawSeriesLines(series) {
1718
+ function plotLine(datapoints, xoffset, yoffset, axisx, axisy) {
1719
+ var points = datapoints.points,
1720
+ ps = datapoints.pointsize,
1721
+ prevx = null, prevy = null;
1722
+
1723
+ ctx.beginPath();
1724
+ for (var i = ps; i < points.length; i += ps) {
1725
+ var x1 = points[i - ps], y1 = points[i - ps + 1],
1726
+ x2 = points[i], y2 = points[i + 1];
1727
+
1728
+ if (x1 == null || x2 == null)
1729
+ continue;
1730
+
1731
+ // clip with ymin
1732
+ if (y1 <= y2 && y1 < axisy.min) {
1733
+ if (y2 < axisy.min)
1734
+ continue; // line segment is outside
1735
+ // compute new intersection point
1736
+ x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1737
+ y1 = axisy.min;
1738
+ }
1739
+ else if (y2 <= y1 && y2 < axisy.min) {
1740
+ if (y1 < axisy.min)
1741
+ continue;
1742
+ x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1743
+ y2 = axisy.min;
1744
+ }
1745
+
1746
+ // clip with ymax
1747
+ if (y1 >= y2 && y1 > axisy.max) {
1748
+ if (y2 > axisy.max)
1749
+ continue;
1750
+ x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1751
+ y1 = axisy.max;
1752
+ }
1753
+ else if (y2 >= y1 && y2 > axisy.max) {
1754
+ if (y1 > axisy.max)
1755
+ continue;
1756
+ x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1757
+ y2 = axisy.max;
1758
+ }
1759
+
1760
+ // clip with xmin
1761
+ if (x1 <= x2 && x1 < axisx.min) {
1762
+ if (x2 < axisx.min)
1763
+ continue;
1764
+ y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1765
+ x1 = axisx.min;
1766
+ }
1767
+ else if (x2 <= x1 && x2 < axisx.min) {
1768
+ if (x1 < axisx.min)
1769
+ continue;
1770
+ y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1771
+ x2 = axisx.min;
1772
+ }
1773
+
1774
+ // clip with xmax
1775
+ if (x1 >= x2 && x1 > axisx.max) {
1776
+ if (x2 > axisx.max)
1777
+ continue;
1778
+ y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1779
+ x1 = axisx.max;
1780
+ }
1781
+ else if (x2 >= x1 && x2 > axisx.max) {
1782
+ if (x1 > axisx.max)
1783
+ continue;
1784
+ y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1785
+ x2 = axisx.max;
1786
+ }
1787
+
1788
+ if (x1 != prevx || y1 != prevy)
1789
+ ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
1790
+
1791
+ prevx = x2;
1792
+ prevy = y2;
1793
+ ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset);
1794
+ }
1795
+ ctx.stroke();
1796
+ }
1797
+
1798
+ function plotLineArea(datapoints, axisx, axisy) {
1799
+ var points = datapoints.points,
1800
+ ps = datapoints.pointsize,
1801
+ bottom = Math.min(Math.max(0, axisy.min), axisy.max),
1802
+ i = 0, top, areaOpen = false,
1803
+ ypos = 1, segmentStart = 0, segmentEnd = 0;
1804
+
1805
+ // we process each segment in two turns, first forward
1806
+ // direction to sketch out top, then once we hit the
1807
+ // end we go backwards to sketch the bottom
1808
+ while (true) {
1809
+ if (ps > 0 && i > points.length + ps)
1810
+ break;
1811
+
1812
+ i += ps; // ps is negative if going backwards
1813
+
1814
+ var x1 = points[i - ps],
1815
+ y1 = points[i - ps + ypos],
1816
+ x2 = points[i], y2 = points[i + ypos];
1817
+
1818
+ if (areaOpen) {
1819
+ if (ps > 0 && x1 != null && x2 == null) {
1820
+ // at turning point
1821
+ segmentEnd = i;
1822
+ ps = -ps;
1823
+ ypos = 2;
1824
+ continue;
1825
+ }
1826
+
1827
+ if (ps < 0 && i == segmentStart + ps) {
1828
+ // done with the reverse sweep
1829
+ ctx.fill();
1830
+ areaOpen = false;
1831
+ ps = -ps;
1832
+ ypos = 1;
1833
+ i = segmentStart = segmentEnd + ps;
1834
+ continue;
1835
+ }
1836
+ }
1837
+
1838
+ if (x1 == null || x2 == null)
1839
+ continue;
1840
+
1841
+ // clip x values
1842
+
1843
+ // clip with xmin
1844
+ if (x1 <= x2 && x1 < axisx.min) {
1845
+ if (x2 < axisx.min)
1846
+ continue;
1847
+ y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1848
+ x1 = axisx.min;
1849
+ }
1850
+ else if (x2 <= x1 && x2 < axisx.min) {
1851
+ if (x1 < axisx.min)
1852
+ continue;
1853
+ y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
1854
+ x2 = axisx.min;
1855
+ }
1856
+
1857
+ // clip with xmax
1858
+ if (x1 >= x2 && x1 > axisx.max) {
1859
+ if (x2 > axisx.max)
1860
+ continue;
1861
+ y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1862
+ x1 = axisx.max;
1863
+ }
1864
+ else if (x2 >= x1 && x2 > axisx.max) {
1865
+ if (x1 > axisx.max)
1866
+ continue;
1867
+ y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
1868
+ x2 = axisx.max;
1869
+ }
1870
+
1871
+ if (!areaOpen) {
1872
+ // open area
1873
+ ctx.beginPath();
1874
+ ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom));
1875
+ areaOpen = true;
1876
+ }
1877
+
1878
+ // now first check the case where both is outside
1879
+ if (y1 >= axisy.max && y2 >= axisy.max) {
1880
+ ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
1881
+ ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max));
1882
+ continue;
1883
+ }
1884
+ else if (y1 <= axisy.min && y2 <= axisy.min) {
1885
+ ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min));
1886
+ ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
1887
+ continue;
1888
+ }
1889
+
1890
+ // else it's a bit more complicated, there might
1891
+ // be a flat maxed out rectangle first, then a
1892
+ // triangular cutout or reverse; to find these
1893
+ // keep track of the current x values
1894
+ var x1old = x1, x2old = x2;
1895
+
1896
+ // clip the y values, without shortcutting, we
1897
+ // go through all cases in turn
1898
+
1899
+ // clip with ymin
1900
+ if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
1901
+ x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1902
+ y1 = axisy.min;
1903
+ }
1904
+ else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
1905
+ x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
1906
+ y2 = axisy.min;
1907
+ }
1908
+
1909
+ // clip with ymax
1910
+ if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) {
1911
+ x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1912
+ y1 = axisy.max;
1913
+ }
1914
+ else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
1915
+ x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
1916
+ y2 = axisy.max;
1917
+ }
1918
+
1919
+ // if the x value was changed we got a rectangle
1920
+ // to fill
1921
+ if (x1 != x1old) {
1922
+ ctx.lineTo(axisx.p2c(x1old), axisy.p2c(y1));
1923
+ // it goes to (x1, y1), but we fill that below
1924
+ }
1925
+
1926
+ // fill triangular section, this sometimes result
1927
+ // in redundant points if (x1, y1) hasn't changed
1928
+ // from previous line to, but we just ignore that
1929
+ ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1));
1930
+ ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));
1931
+
1932
+ // fill the other rectangle if it's there
1933
+ if (x2 != x2old) {
1934
+ ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));
1935
+ ctx.lineTo(axisx.p2c(x2old), axisy.p2c(y2));
1936
+ }
1937
+ }
1938
+ }
1939
+
1940
+ ctx.save();
1941
+ ctx.translate(plotOffset.left, plotOffset.top);
1942
+ ctx.lineJoin = "round";
1943
+
1944
+ var lw = series.lines.lineWidth,
1945
+ sw = series.shadowSize;
1946
+ // FIXME: consider another form of shadow when filling is turned on
1947
+ if (lw > 0 && sw > 0) {
1948
+ // draw shadow as a thick and thin line with transparency
1949
+ ctx.lineWidth = sw;
1950
+ ctx.strokeStyle = "rgba(0,0,0,0.1)";
1951
+ // position shadow at angle from the mid of line
1952
+ var angle = Math.PI/18;
1953
+ plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis);
1954
+ ctx.lineWidth = sw/2;
1955
+ plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis);
1956
+ }
1957
+
1958
+ ctx.lineWidth = lw;
1959
+ ctx.strokeStyle = series.color;
1960
+ var fillStyle = getFillStyle(series.lines, series.color, 0, plotHeight);
1961
+ if (fillStyle) {
1962
+ ctx.fillStyle = fillStyle;
1963
+ plotLineArea(series.datapoints, series.xaxis, series.yaxis);
1964
+ }
1965
+
1966
+ if (lw > 0)
1967
+ plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis);
1968
+ ctx.restore();
1969
+ }
1970
+
1971
+ function drawSeriesPoints(series) {
1972
+ function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol) {
1973
+ var points = datapoints.points, ps = datapoints.pointsize;
1974
+
1975
+ for (var i = 0; i < points.length; i += ps) {
1976
+ var x = points[i], y = points[i + 1];
1977
+ if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
1978
+ continue;
1979
+
1980
+ ctx.beginPath();
1981
+ x = axisx.p2c(x);
1982
+ y = axisy.p2c(y) + offset;
1983
+ if (symbol == "circle")
1984
+ ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false);
1985
+ else
1986
+ symbol(ctx, x, y, radius, shadow);
1987
+ ctx.closePath();
1988
+
1989
+ if (fillStyle) {
1990
+ ctx.fillStyle = fillStyle;
1991
+ ctx.fill();
1992
+ }
1993
+ ctx.stroke();
1994
+ }
1995
+ }
1996
+
1997
+ ctx.save();
1998
+ ctx.translate(plotOffset.left, plotOffset.top);
1999
+
2000
+ var lw = series.points.lineWidth,
2001
+ sw = series.shadowSize,
2002
+ radius = series.points.radius,
2003
+ symbol = series.points.symbol;
2004
+ if (lw > 0 && sw > 0) {
2005
+ // draw shadow in two steps
2006
+ var w = sw / 2;
2007
+ ctx.lineWidth = w;
2008
+ ctx.strokeStyle = "rgba(0,0,0,0.1)";
2009
+ plotPoints(series.datapoints, radius, null, w + w/2, true,
2010
+ series.xaxis, series.yaxis, symbol);
2011
+
2012
+ ctx.strokeStyle = "rgba(0,0,0,0.2)";
2013
+ plotPoints(series.datapoints, radius, null, w/2, true,
2014
+ series.xaxis, series.yaxis, symbol);
2015
+ }
2016
+
2017
+ ctx.lineWidth = lw;
2018
+ ctx.strokeStyle = series.color;
2019
+ plotPoints(series.datapoints, radius,
2020
+ getFillStyle(series.points, series.color), 0, false,
2021
+ series.xaxis, series.yaxis, symbol);
2022
+ ctx.restore();
2023
+ }
2024
+
2025
+ function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
2026
+ var left, right, bottom, top,
2027
+ drawLeft, drawRight, drawTop, drawBottom,
2028
+ tmp;
2029
+
2030
+ // in horizontal mode, we start the bar from the left
2031
+ // instead of from the bottom so it appears to be
2032
+ // horizontal rather than vertical
2033
+ if (horizontal) {
2034
+ drawBottom = drawRight = drawTop = true;
2035
+ drawLeft = false;
2036
+ left = b;
2037
+ right = x;
2038
+ top = y + barLeft;
2039
+ bottom = y + barRight;
2040
+
2041
+ // account for negative bars
2042
+ if (right < left) {
2043
+ tmp = right;
2044
+ right = left;
2045
+ left = tmp;
2046
+ drawLeft = true;
2047
+ drawRight = false;
2048
+ }
2049
+ }
2050
+ else {
2051
+ drawLeft = drawRight = drawTop = true;
2052
+ drawBottom = false;
2053
+ left = x + barLeft;
2054
+ right = x + barRight;
2055
+ bottom = b;
2056
+ top = y;
2057
+
2058
+ // account for negative bars
2059
+ if (top < bottom) {
2060
+ tmp = top;
2061
+ top = bottom;
2062
+ bottom = tmp;
2063
+ drawBottom = true;
2064
+ drawTop = false;
2065
+ }
2066
+ }
2067
+
2068
+ // clip
2069
+ if (right < axisx.min || left > axisx.max ||
2070
+ top < axisy.min || bottom > axisy.max)
2071
+ return;
2072
+
2073
+ if (left < axisx.min) {
2074
+ left = axisx.min;
2075
+ drawLeft = false;
2076
+ }
2077
+
2078
+ if (right > axisx.max) {
2079
+ right = axisx.max;
2080
+ drawRight = false;
2081
+ }
2082
+
2083
+ if (bottom < axisy.min) {
2084
+ bottom = axisy.min;
2085
+ drawBottom = false;
2086
+ }
2087
+
2088
+ if (top > axisy.max) {
2089
+ top = axisy.max;
2090
+ drawTop = false;
2091
+ }
2092
+
2093
+ left = axisx.p2c(left);
2094
+ bottom = axisy.p2c(bottom);
2095
+ right = axisx.p2c(right);
2096
+ top = axisy.p2c(top);
2097
+
2098
+ // fill the bar
2099
+ if (fillStyleCallback) {
2100
+ c.beginPath();
2101
+ c.moveTo(left, bottom);
2102
+ c.lineTo(left, top);
2103
+ c.lineTo(right, top);
2104
+ c.lineTo(right, bottom);
2105
+ c.fillStyle = fillStyleCallback(bottom, top);
2106
+ c.fill();
2107
+ }
2108
+
2109
+ // draw outline
2110
+ if (lineWidth > 0 && (drawLeft || drawRight || drawTop || drawBottom)) {
2111
+ c.beginPath();
2112
+
2113
+ // FIXME: inline moveTo is buggy with excanvas
2114
+ c.moveTo(left, bottom + offset);
2115
+ if (drawLeft)
2116
+ c.lineTo(left, top + offset);
2117
+ else
2118
+ c.moveTo(left, top + offset);
2119
+ if (drawTop)
2120
+ c.lineTo(right, top + offset);
2121
+ else
2122
+ c.moveTo(right, top + offset);
2123
+ if (drawRight)
2124
+ c.lineTo(right, bottom + offset);
2125
+ else
2126
+ c.moveTo(right, bottom + offset);
2127
+ if (drawBottom)
2128
+ c.lineTo(left, bottom + offset);
2129
+ else
2130
+ c.moveTo(left, bottom + offset);
2131
+ c.stroke();
2132
+ }
2133
+ }
2134
+
2135
+ function drawSeriesBars(series) {
2136
+ function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
2137
+ var points = datapoints.points, ps = datapoints.pointsize;
2138
+
2139
+ for (var i = 0; i < points.length; i += ps) {
2140
+ if (points[i] == null)
2141
+ continue;
2142
+ drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth);
2143
+ }
2144
+ }
2145
+
2146
+ ctx.save();
2147
+ ctx.translate(plotOffset.left, plotOffset.top);
2148
+
2149
+ // FIXME: figure out a way to add shadows (for instance along the right edge)
2150
+ ctx.lineWidth = series.bars.lineWidth;
2151
+ ctx.strokeStyle = series.color;
2152
+ var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
2153
+ var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
2154
+ plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis);
2155
+ ctx.restore();
2156
+ }
2157
+
2158
+ function getFillStyle(filloptions, seriesColor, bottom, top) {
2159
+ var fill = filloptions.fill;
2160
+ if (!fill)
2161
+ return null;
2162
+
2163
+ if (filloptions.fillColor)
2164
+ return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor);
2165
+
2166
+ var c = $.color.parse(seriesColor);
2167
+ c.a = typeof fill == "number" ? fill : 0.4;
2168
+ c.normalize();
2169
+ return c.toString();
2170
+ }
2171
+
2172
+ function insertLegend() {
2173
+ placeholder.find(".legend").remove();
2174
+
2175
+ if (!options.legend.show)
2176
+ return;
2177
+
2178
+ var fragments = [], rowStarted = false,
2179
+ lf = options.legend.labelFormatter, s, label;
2180
+ for (var i = 0; i < series.length; ++i) {
2181
+ s = series[i];
2182
+ label = s.label;
2183
+ if (!label)
2184
+ continue;
2185
+
2186
+ if (i % options.legend.noColumns == 0) {
2187
+ if (rowStarted)
2188
+ fragments.push('</tr>');
2189
+ fragments.push('<tr>');
2190
+ rowStarted = true;
2191
+ }
2192
+
2193
+ if (lf)
2194
+ label = lf(label, s);
2195
+
2196
+ fragments.push(
2197
+ '<td class="legendColorBox"><div style="border:1px solid ' + options.legend.labelBoxBorderColor + ';padding:1px"><div style="width:4px;height:0;border:5px solid ' + s.color + ';overflow:hidden"></div></div></td>' +
2198
+ '<td class="legendLabel">' + label + '</td>');
2199
+ }
2200
+ if (rowStarted)
2201
+ fragments.push('</tr>');
2202
+
2203
+ if (fragments.length == 0)
2204
+ return;
2205
+
2206
+ var table = '<table style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>';
2207
+ if (options.legend.container != null)
2208
+ $(options.legend.container).html(table);
2209
+ else {
2210
+ var pos = "",
2211
+ p = options.legend.position,
2212
+ m = options.legend.margin;
2213
+ if (m[0] == null)
2214
+ m = [m, m];
2215
+ if (p.charAt(0) == "n")
2216
+ pos += 'top:' + (m[1] + plotOffset.top) + 'px;';
2217
+ else if (p.charAt(0) == "s")
2218
+ pos += 'bottom:' + (m[1] + plotOffset.bottom) + 'px;';
2219
+ if (p.charAt(1) == "e")
2220
+ pos += 'right:' + (m[0] + plotOffset.right) + 'px;';
2221
+ else if (p.charAt(1) == "w")
2222
+ pos += 'left:' + (m[0] + plotOffset.left) + 'px;';
2223
+ var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(placeholder);
2224
+ if (options.legend.backgroundOpacity != 0.0) {
2225
+ // put in the transparent background
2226
+ // separately to avoid blended labels and
2227
+ // label boxes
2228
+ var c = options.legend.backgroundColor;
2229
+ if (c == null) {
2230
+ c = options.grid.backgroundColor;
2231
+ if (c && typeof c == "string")
2232
+ c = $.color.parse(c);
2233
+ else
2234
+ c = $.color.extract(legend, 'background-color');
2235
+ c.a = 1;
2236
+ c = c.toString();
2237
+ }
2238
+ var div = legend.children();
2239
+ $('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
2240
+ }
2241
+ }
2242
+ }
2243
+
2244
+
2245
+ // interactive features
2246
+
2247
+ var highlights = [],
2248
+ redrawTimeout = null;
2249
+
2250
+ // returns the data item the mouse is over, or null if none is found
2251
+ function findNearbyItem(mouseX, mouseY, seriesFilter) {
2252
+ var maxDistance = options.grid.mouseActiveRadius,
2253
+ smallestDistance = maxDistance * maxDistance + 1,
2254
+ item = null, foundPoint = false, i, j;
2255
+
2256
+ for (i = series.length - 1; i >= 0; --i) {
2257
+ if (!seriesFilter(series[i]))
2258
+ continue;
2259
+
2260
+ var s = series[i],
2261
+ axisx = s.xaxis,
2262
+ axisy = s.yaxis,
2263
+ points = s.datapoints.points,
2264
+ ps = s.datapoints.pointsize,
2265
+ mx = axisx.c2p(mouseX), // precompute some stuff to make the loop faster
2266
+ my = axisy.c2p(mouseY),
2267
+ maxx = maxDistance / axisx.scale,
2268
+ maxy = maxDistance / axisy.scale;
2269
+
2270
+ // with inverse transforms, we can't use the maxx/maxy
2271
+ // optimization, sadly
2272
+ if (axisx.options.inverseTransform)
2273
+ maxx = Number.MAX_VALUE;
2274
+ if (axisy.options.inverseTransform)
2275
+ maxy = Number.MAX_VALUE;
2276
+
2277
+ if (s.lines.show || s.points.show) {
2278
+ for (j = 0; j < points.length; j += ps) {
2279
+ var x = points[j], y = points[j + 1];
2280
+ if (x == null)
2281
+ continue;
2282
+
2283
+ // For points and lines, the cursor must be within a
2284
+ // certain distance to the data point
2285
+ if (x - mx > maxx || x - mx < -maxx ||
2286
+ y - my > maxy || y - my < -maxy)
2287
+ continue;
2288
+
2289
+ // We have to calculate distances in pixels, not in
2290
+ // data units, because the scales of the axes may be different
2291
+ var dx = Math.abs(axisx.p2c(x) - mouseX),
2292
+ dy = Math.abs(axisy.p2c(y) - mouseY),
2293
+ dist = dx * dx + dy * dy; // we save the sqrt
2294
+
2295
+ // use <= to ensure last point takes precedence
2296
+ // (last generally means on top of)
2297
+ if (dist < smallestDistance) {
2298
+ smallestDistance = dist;
2299
+ item = [i, j / ps];
2300
+ }
2301
+ }
2302
+ }
2303
+
2304
+ if (s.bars.show && !item) { // no other point can be nearby
2305
+ var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2,
2306
+ barRight = barLeft + s.bars.barWidth;
2307
+
2308
+ for (j = 0; j < points.length; j += ps) {
2309
+ var x = points[j], y = points[j + 1], b = points[j + 2];
2310
+ if (x == null)
2311
+ continue;
2312
+
2313
+ // for a bar graph, the cursor must be inside the bar
2314
+ if (series[i].bars.horizontal ?
2315
+ (mx <= Math.max(b, x) && mx >= Math.min(b, x) &&
2316
+ my >= y + barLeft && my <= y + barRight) :
2317
+ (mx >= x + barLeft && mx <= x + barRight &&
2318
+ my >= Math.min(b, y) && my <= Math.max(b, y)))
2319
+ item = [i, j / ps];
2320
+ }
2321
+ }
2322
+ }
2323
+
2324
+ if (item) {
2325
+ i = item[0];
2326
+ j = item[1];
2327
+ ps = series[i].datapoints.pointsize;
2328
+
2329
+ return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps),
2330
+ dataIndex: j,
2331
+ series: series[i],
2332
+ seriesIndex: i };
2333
+ }
2334
+
2335
+ return null;
2336
+ }
2337
+
2338
+ function onMouseMove(e) {
2339
+ if (options.grid.hoverable)
2340
+ triggerClickHoverEvent("plothover", e,
2341
+ function (s) { return s["hoverable"] != false; });
2342
+ }
2343
+
2344
+ function onMouseLeave(e) {
2345
+ if (options.grid.hoverable)
2346
+ triggerClickHoverEvent("plothover", e,
2347
+ function (s) { return false; });
2348
+ }
2349
+
2350
+ function onClick(e) {
2351
+ triggerClickHoverEvent("plotclick", e,
2352
+ function (s) { return s["clickable"] != false; });
2353
+ }
2354
+
2355
+ // trigger click or hover event (they send the same parameters
2356
+ // so we share their code)
2357
+ function triggerClickHoverEvent(eventname, event, seriesFilter) {
2358
+ var offset = eventHolder.offset(),
2359
+ canvasX = event.pageX - offset.left - plotOffset.left,
2360
+ canvasY = event.pageY - offset.top - plotOffset.top,
2361
+ pos = canvasToAxisCoords({ left: canvasX, top: canvasY });
2362
+
2363
+ pos.pageX = event.pageX;
2364
+ pos.pageY = event.pageY;
2365
+
2366
+ var item = findNearbyItem(canvasX, canvasY, seriesFilter);
2367
+
2368
+ if (item) {
2369
+ // fill in mouse pos for any listeners out there
2370
+ item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left);
2371
+ item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top);
2372
+ }
2373
+
2374
+ if (options.grid.autoHighlight) {
2375
+ // clear auto-highlights
2376
+ for (var i = 0; i < highlights.length; ++i) {
2377
+ var h = highlights[i];
2378
+ if (h.auto == eventname &&
2379
+ !(item && h.series == item.series &&
2380
+ h.point[0] == item.datapoint[0] &&
2381
+ h.point[1] == item.datapoint[1]))
2382
+ unhighlight(h.series, h.point);
2383
+ }
2384
+
2385
+ if (item)
2386
+ highlight(item.series, item.datapoint, eventname);
2387
+ }
2388
+
2389
+ placeholder.trigger(eventname, [ pos, item ]);
2390
+ }
2391
+
2392
+ function triggerRedrawOverlay() {
2393
+ if (!redrawTimeout)
2394
+ redrawTimeout = setTimeout(drawOverlay, 30);
2395
+ }
2396
+
2397
+ function drawOverlay() {
2398
+ redrawTimeout = null;
2399
+
2400
+ // draw highlights
2401
+ octx.save();
2402
+ octx.clearRect(0, 0, canvasWidth, canvasHeight);
2403
+ octx.translate(plotOffset.left, plotOffset.top);
2404
+
2405
+ var i, hi;
2406
+ for (i = 0; i < highlights.length; ++i) {
2407
+ hi = highlights[i];
2408
+
2409
+ if (hi.series.bars.show)
2410
+ drawBarHighlight(hi.series, hi.point);
2411
+ else
2412
+ drawPointHighlight(hi.series, hi.point);
2413
+ }
2414
+ octx.restore();
2415
+
2416
+ executeHooks(hooks.drawOverlay, [octx]);
2417
+ }
2418
+
2419
+ function highlight(s, point, auto) {
2420
+ if (typeof s == "number")
2421
+ s = series[s];
2422
+
2423
+ if (typeof point == "number") {
2424
+ var ps = s.datapoints.pointsize;
2425
+ point = s.datapoints.points.slice(ps * point, ps * (point + 1));
2426
+ }
2427
+
2428
+ var i = indexOfHighlight(s, point);
2429
+ if (i == -1) {
2430
+ highlights.push({ series: s, point: point, auto: auto });
2431
+
2432
+ triggerRedrawOverlay();
2433
+ }
2434
+ else if (!auto)
2435
+ highlights[i].auto = false;
2436
+ }
2437
+
2438
+ function unhighlight(s, point) {
2439
+ if (s == null && point == null) {
2440
+ highlights = [];
2441
+ triggerRedrawOverlay();
2442
+ }
2443
+
2444
+ if (typeof s == "number")
2445
+ s = series[s];
2446
+
2447
+ if (typeof point == "number")
2448
+ point = s.data[point];
2449
+
2450
+ var i = indexOfHighlight(s, point);
2451
+ if (i != -1) {
2452
+ highlights.splice(i, 1);
2453
+
2454
+ triggerRedrawOverlay();
2455
+ }
2456
+ }
2457
+
2458
+ function indexOfHighlight(s, p) {
2459
+ for (var i = 0; i < highlights.length; ++i) {
2460
+ var h = highlights[i];
2461
+ if (h.series == s && h.point[0] == p[0]
2462
+ && h.point[1] == p[1])
2463
+ return i;
2464
+ }
2465
+ return -1;
2466
+ }
2467
+
2468
+ function drawPointHighlight(series, point) {
2469
+ var x = point[0], y = point[1],
2470
+ axisx = series.xaxis, axisy = series.yaxis;
2471
+
2472
+ if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
2473
+ return;
2474
+
2475
+ var pointRadius = series.points.radius + series.points.lineWidth / 2;
2476
+ octx.lineWidth = pointRadius;
2477
+ octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
2478
+ var radius = 1.5 * pointRadius,
2479
+ x = axisx.p2c(x),
2480
+ y = axisy.p2c(y);
2481
+
2482
+ octx.beginPath();
2483
+ if (series.points.symbol == "circle")
2484
+ octx.arc(x, y, radius, 0, 2 * Math.PI, false);
2485
+ else
2486
+ series.points.symbol(octx, x, y, radius, false);
2487
+ octx.closePath();
2488
+ octx.stroke();
2489
+ }
2490
+
2491
+ function drawBarHighlight(series, point) {
2492
+ octx.lineWidth = series.bars.lineWidth;
2493
+ octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
2494
+ var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString();
2495
+ var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
2496
+ drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
2497
+ 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
2498
+ }
2499
+
2500
+ function getColorOrGradient(spec, bottom, top, defaultColor) {
2501
+ if (typeof spec == "string")
2502
+ return spec;
2503
+ else {
2504
+ // assume this is a gradient spec; IE currently only
2505
+ // supports a simple vertical gradient properly, so that's
2506
+ // what we support too
2507
+ var gradient = ctx.createLinearGradient(0, top, 0, bottom);
2508
+
2509
+ for (var i = 0, l = spec.colors.length; i < l; ++i) {
2510
+ var c = spec.colors[i];
2511
+ if (typeof c != "string") {
2512
+ var co = $.color.parse(defaultColor);
2513
+ if (c.brightness != null)
2514
+ co = co.scale('rgb', c.brightness)
2515
+ if (c.opacity != null)
2516
+ co.a *= c.opacity;
2517
+ c = co.toString();
2518
+ }
2519
+ gradient.addColorStop(i / (l - 1), c);
2520
+ }
2521
+
2522
+ return gradient;
2523
+ }
2524
+ }
2525
+ }
2526
+
2527
+ $.plot = function(placeholder, data, options) {
2528
+ //var t0 = new Date();
2529
+ var plot = new Plot($(placeholder), data, options, $.plot.plugins);
2530
+ //(window.console ? console.log : alert)("time used (msecs): " + ((new Date()).getTime() - t0.getTime()));
2531
+ return plot;
2532
+ };
2533
+
2534
+ $.plot.version = "0.7";
2535
+
2536
+ $.plot.plugins = [];
2537
+
2538
+ // returns a string with the date d formatted according to fmt
2539
+ $.plot.formatDate = function(d, fmt, monthNames) {
2540
+ var leftPad = function(n) {
2541
+ n = "" + n;
2542
+ return n.length == 1 ? "0" + n : n;
2543
+ };
2544
+
2545
+ var r = [];
2546
+ var escape = false, padNext = false;
2547
+ var hours = d.getUTCHours();
2548
+ var isAM = hours < 12;
2549
+ if (monthNames == null)
2550
+ monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2551
+
2552
+ if (fmt.search(/%p|%P/) != -1) {
2553
+ if (hours > 12) {
2554
+ hours = hours - 12;
2555
+ } else if (hours == 0) {
2556
+ hours = 12;
2557
+ }
2558
+ }
2559
+ for (var i = 0; i < fmt.length; ++i) {
2560
+ var c = fmt.charAt(i);
2561
+
2562
+ if (escape) {
2563
+ switch (c) {
2564
+ case 'h': c = "" + hours; break;
2565
+ case 'H': c = leftPad(hours); break;
2566
+ case 'M': c = leftPad(d.getUTCMinutes()); break;
2567
+ case 'S': c = leftPad(d.getUTCSeconds()); break;
2568
+ case 'd': c = "" + d.getUTCDate(); break;
2569
+ case 'm': c = "" + (d.getUTCMonth() + 1); break;
2570
+ case 'y': c = "" + d.getUTCFullYear(); break;
2571
+ case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
2572
+ case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
2573
+ case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
2574
+ case '0': c = ""; padNext = true; break;
2575
+ }
2576
+ if (c && padNext) {
2577
+ c = leftPad(c);
2578
+ padNext = false;
2579
+ }
2580
+ r.push(c);
2581
+ if (!padNext)
2582
+ escape = false;
2583
+ }
2584
+ else {
2585
+ if (c == "%")
2586
+ escape = true;
2587
+ else
2588
+ r.push(c);
2589
+ }
2590
+ }
2591
+ return r.join("");
2592
+ };
2593
+
2594
+ // round to nearby lower multiple of base
2595
+ function floorInBase(n, base) {
2596
+ return base * Math.floor(n / base);
2597
+ }
2598
+
2599
+ })(jQuery);
js/flot/jquery.flot.resize.js ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Flot plugin for automatically redrawing plots when the placeholder
3
+ size changes, e.g. on window resizes.
4
+
5
+ It works by listening for changes on the placeholder div (through the
6
+ jQuery resize event plugin) - if the size changes, it will redraw the
7
+ plot.
8
+
9
+ There are no options. If you need to disable the plugin for some
10
+ plots, you can just fix the size of their placeholders.
11
+ */
12
+
13
+
14
+ /* Inline dependency:
15
+ * jQuery resize event - v1.1 - 3/14/2010
16
+ * http://benalman.com/projects/jquery-resize-plugin/
17
+ *
18
+ * Copyright (c) 2010 "Cowboy" Ben Alman
19
+ * Dual licensed under the MIT and GPL licenses.
20
+ * http://benalman.com/about/license/
21
+ */
22
+ (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
23
+
24
+
25
+ (function ($) {
26
+ var options = { }; // no options
27
+
28
+ function init(plot) {
29
+ function onResize() {
30
+ var placeholder = plot.getPlaceholder();
31
+
32
+ // somebody might have hidden us and we can't plot
33
+ // when we don't have the dimensions
34
+ if (placeholder.width() == 0 || placeholder.height() == 0)
35
+ return;
36
+
37
+ plot.resize();
38
+ plot.setupGrid();
39
+ plot.draw();
40
+ }
41
+
42
+ function bindEvents(plot, eventHolder) {
43
+ plot.getPlaceholder().resize(onResize);
44
+ }
45
+
46
+ function shutdown(plot, eventHolder) {
47
+ plot.getPlaceholder().unbind("resize", onResize);
48
+ }
49
+
50
+ plot.hooks.bindEvents.push(bindEvents);
51
+ plot.hooks.shutdown.push(shutdown);
52
+ }
53
+
54
+ $.plot.plugins.push({
55
+ init: init,
56
+ options: options,
57
+ name: 'resize',
58
+ version: '1.0'
59
+ });
60
+ })(jQuery);
js/flot/jquery.flot.stack.js ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Flot plugin for stacking data sets, i.e. putting them on top of each
3
+ other, for accumulative graphs.
4
+
5
+ The plugin assumes the data is sorted on x (or y if stacking
6
+ horizontally). For line charts, it is assumed that if a line has an
7
+ undefined gap (from a null point), then the line above it should have
8
+ the same gap - insert zeros instead of "null" if you want another
9
+ behaviour. This also holds for the start and end of the chart. Note
10
+ that stacking a mix of positive and negative values in most instances
11
+ doesn't make sense (so it looks weird).
12
+
13
+ Two or more series are stacked when their "stack" attribute is set to
14
+ the same key (which can be any number or string or just "true"). To
15
+ specify the default stack, you can set
16
+
17
+ series: {
18
+ stack: null or true or key (number/string)
19
+ }
20
+
21
+ or specify it for a specific series
22
+
23
+ $.plot($("#placeholder"), [{ data: [ ... ], stack: true }])
24
+
25
+ The stacking order is determined by the order of the data series in
26
+ the array (later series end up on top of the previous).
27
+
28
+ Internally, the plugin modifies the datapoints in each series, adding
29
+ an offset to the y value. For line series, extra data points are
30
+ inserted through interpolation. If there's a second y value, it's also
31
+ adjusted (e.g for bar charts or filled areas).
32
+ */
33
+
34
+ (function ($) {
35
+ var options = {
36
+ series: { stack: null } // or number/string
37
+ };
38
+
39
+ function init(plot) {
40
+ function findMatchingSeries(s, allseries) {
41
+ var res = null
42
+ for (var i = 0; i < allseries.length; ++i) {
43
+ if (s == allseries[i])
44
+ break;
45
+
46
+ if (allseries[i].stack == s.stack)
47
+ res = allseries[i];
48
+ }
49
+
50
+ return res;
51
+ }
52
+
53
+ function stackData(plot, s, datapoints) {
54
+ if (s.stack == null)
55
+ return;
56
+
57
+ var other = findMatchingSeries(s, plot.getData());
58
+ if (!other)
59
+ return;
60
+
61
+ var ps = datapoints.pointsize,
62
+ points = datapoints.points,
63
+ otherps = other.datapoints.pointsize,
64
+ otherpoints = other.datapoints.points,
65
+ newpoints = [],
66
+ px, py, intery, qx, qy, bottom,
67
+ withlines = s.lines.show,
68
+ horizontal = s.bars.horizontal,
69
+ withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
70
+ withsteps = withlines && s.lines.steps,
71
+ fromgap = true,
72
+ keyOffset = horizontal ? 1 : 0,
73
+ accumulateOffset = horizontal ? 0 : 1,
74
+ i = 0, j = 0, l;
75
+
76
+ while (true) {
77
+ if (i >= points.length)
78
+ break;
79
+
80
+ l = newpoints.length;
81
+
82
+ if (points[i] == null) {
83
+ // copy gaps
84
+ for (m = 0; m < ps; ++m)
85
+ newpoints.push(points[i + m]);
86
+ i += ps;
87
+ }
88
+ else if (j >= otherpoints.length) {
89
+ // for lines, we can't use the rest of the points
90
+ if (!withlines) {
91
+ for (m = 0; m < ps; ++m)
92
+ newpoints.push(points[i + m]);
93
+ }
94
+ i += ps;
95
+ }
96
+ else if (otherpoints[j] == null) {
97
+ // oops, got a gap
98
+ for (m = 0; m < ps; ++m)
99
+ newpoints.push(null);
100
+ fromgap = true;
101
+ j += otherps;
102
+ }
103
+ else {
104
+ // cases where we actually got two points
105
+ px = points[i + keyOffset];
106
+ py = points[i + accumulateOffset];
107
+ qx = otherpoints[j + keyOffset];
108
+ qy = otherpoints[j + accumulateOffset];
109
+ bottom = 0;
110
+
111
+ if (px == qx) {
112
+ for (m = 0; m < ps; ++m)
113
+ newpoints.push(points[i + m]);
114
+
115
+ newpoints[l + accumulateOffset] += qy;
116
+ bottom = qy;
117
+
118
+ i += ps;
119
+ j += otherps;
120
+ }
121
+ else if (px > qx) {
122
+ // we got past point below, might need to
123
+ // insert interpolated extra point
124
+ if (withlines && i > 0 && points[i - ps] != null) {
125
+ intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
126
+ newpoints.push(qx);
127
+ newpoints.push(intery + qy);
128
+ for (m = 2; m < ps; ++m)
129
+ newpoints.push(points[i + m]);
130
+ bottom = qy;
131
+ }
132
+
133
+ j += otherps;
134
+ }
135
+ else { // px < qx
136
+ if (fromgap && withlines) {
137
+ // if we come from a gap, we just skip this point
138
+ i += ps;
139
+ continue;
140
+ }
141
+
142
+ for (m = 0; m < ps; ++m)
143
+ newpoints.push(points[i + m]);
144
+
145
+ // we might be able to interpolate a point below,
146
+ // this can give us a better y
147
+ if (withlines && j > 0 && otherpoints[j - otherps] != null)
148
+ bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
149
+
150
+ newpoints[l + accumulateOffset] += bottom;
151
+
152
+ i += ps;
153
+ }
154
+
155
+ fromgap = false;
156
+
157
+ if (l != newpoints.length && withbottom)
158
+ newpoints[l + 2] += bottom;
159
+ }
160
+
161
+ // maintain the line steps invariant
162
+ if (withsteps && l != newpoints.length && l > 0
163
+ && newpoints[l] != null
164
+ && newpoints[l] != newpoints[l - ps]
165
+ && newpoints[l + 1] != newpoints[l - ps + 1]) {
166
+ for (m = 0; m < ps; ++m)
167
+ newpoints[l + ps + m] = newpoints[l + m];
168
+ newpoints[l + 1] = newpoints[l - ps + 1];
169
+ }
170
+ }
171
+
172
+ datapoints.points = newpoints;
173
+ }
174
+
175
+ plot.hooks.processDatapoints.push(stackData);
176
+ }
177
+
178
+ $.plot.plugins.push({
179
+ init: init,
180
+ options: options,
181
+ name: 'stack',
182
+ version: '1.2'
183
+ });
184
+ })(jQuery);
js/highcharts.js DELETED
@@ -1,202 +0,0 @@
1
- /*
2
- Highcharts JS v2.2.1 (2012-03-15)
3
-
4
- (c) 2009-2011 Torstein H?nsi
5
-
6
- License: www.highcharts.com/license
7
- */
8
- (function(){function L(a,b){var c;a||(a={});for(c in b)a[c]=b[c];return a}function za(){for(var a=0,b=arguments,c=b.length,d={};a<c;a++)d[b[a++]]=b[a];return d}function S(a,b){return parseInt(a,b||10)}function Ab(a){return typeof a==="string"}function mb(a){return typeof a==="object"}function Fb(a){return Object.prototype.toString.call(a)==="[object Array]"}function Bb(a){return typeof a==="number"}function nb(a){return oa.log(a)/oa.LN10}function cb(a){return oa.pow(10,a)}function Gb(a,b){for(var c=
9
- a.length;c--;)if(a[c]===b){a.splice(c,1);break}}function s(a){return a!==X&&a!==null}function A(a,b,c){var d,e;if(Ab(b))s(c)?a.setAttribute(b,c):a&&a.getAttribute&&(e=a.getAttribute(b));else if(s(b)&&mb(b))for(d in b)a.setAttribute(d,b[d]);return e}function Hb(a){return Fb(a)?a:[a]}function p(){var a=arguments,b,c,d=a.length;for(b=0;b<d;b++)if(c=a[b],typeof c!=="undefined"&&c!==null)return c}function P(a,b){if(Qb&&b&&b.opacity!==X)b.filter="alpha(opacity="+b.opacity*100+")";L(a.style,b)}function Aa(a,
10
- b,c,d,e){a=x.createElement(a);b&&L(a,b);e&&P(a,{padding:0,border:Ma,margin:0});c&&P(a,c);d&&d.appendChild(a);return a}function pa(a,b){var c=function(){};c.prototype=new a;L(c.prototype,b);return c}function dc(a,b,c,d){var e=Ea.lang,f=isNaN(b=Ba(b))?2:b,b=c===void 0?e.decimalPoint:c,d=d===void 0?e.thousandsSep:d,e=a<0?"-":"",c=String(S(a=Ba(+a||0).toFixed(f))),g=c.length>3?c.length%3:0;return e+(g?c.substr(0,g)+d:"")+c.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+d)+(f?b+Ba(a-c).toFixed(f).slice(2):"")}
11
- function Na(a,b){return Array((b||2)+1-String(a).length).join(0)+a}function ec(a,b,c,d){var e,c=p(c,1);e=a/c;b||(b=[1,2,2.5,5,10],d&&d.allowDecimals===!1&&(c===1?b=[1,2,5,10]:c<=0.1&&(b=[1/c])));for(d=0;d<b.length;d++)if(a=b[d],e<=(b[d]+(b[d+1]||b[d]))/2)break;a*=c;return a}function Kc(a,b){var c=b||[[Rb,[1,2,5,10,20,25,50,100,200,500]],[ob,[1,2,5,10,15,30]],[pb,[1,2,5,10,15,30]],[va,[1,2,3,4,6,8,12]],[Ca,[1,2]],[Ya,[1,2]],[Da,[1,2,3,4,6]],[Za,null]],d=c[c.length-1],e=E[d[0]],f=d[1],g;for(g=0;g<c.length;g++)if(d=
12
- c[g],e=E[d[0]],f=d[1],c[g+1]&&a<=(e*f[f.length-1]+E[c[g+1][0]])/2)break;e===E[Za]&&a<5*e&&(f=[1,2,5]);e===E[Za]&&a<5*e&&(f=[1,2,5]);c=ec(a/e,f);return{unitRange:e,count:c,unitName:d[0]}}function Lc(a,b,c,d){var e=[],f={},g=Ea.global.useUTC,h,i=new Date(b),b=a.unitRange,k=a.count;b>=E[ob]&&(i.setMilliseconds(0),i.setSeconds(b>=E[pb]?0:k*Ta(i.getSeconds()/k)));if(b>=E[pb])i[pc](b>=E[va]?0:k*Ta(i[fc]()/k));if(b>=E[va])i[qc](b>=E[Ca]?0:k*Ta(i[gc]()/k));if(b>=E[Ca])i[hc](b>=E[Da]?1:k*Ta(i[db]()/k));b>=
13
- E[Da]&&(i[rc](b>=E[Za]?0:k*Ta(i[qb]()/k)),h=i[rb]());b>=E[Za]&&(h-=h%k,i[sc](h));if(b===E[Ya])i[hc](i[db]()-i[ic]()+p(d,1));d=1;h=i[rb]();for(var j=i.getTime(),l=i[qb](),i=i[db]();j<c;)e.push(j),b===E[Za]?j=sb(h+d*k,0):b===E[Da]?j=sb(h,l+d*k):!g&&(b===E[Ca]||b===E[Ya])?j=sb(h,l,i+d*k*(b===E[Ca]?1:7)):(j+=b*k,b<=E[va]&&j%E[Ca]===0&&(f[j]=Ca)),d++;e.push(j);e.info=L(a,{higherRanks:f,totalRange:b*k});return e}function tc(){this.symbol=this.color=0}function uc(a,b,c,d,e,f,g,h,i){var k=g.x,g=g.y,i=k+c+
14
- (i?h:-a-h),j=g-b+d+15,l;i<7&&(i=c+k+h);i+a>c+e&&(i-=i+a-(c+e),j=g-b+d-h,l=!0);j<d+5?(j=d+5,l&&g>=j&&g<=j+b&&(j=g+d+h)):j+b>d+f&&(j=d+f-b-h);return{x:i,y:j}}function Mc(a,b){var c=a.length,d,e;for(e=0;e<c;e++)a[e].ss_i=e;a.sort(function(a,c){d=b(a,c);return d===0?a.ss_i-c.ss_i:d});for(e=0;e<c;e++)delete a[e].ss_i}function Sb(a){for(var b=a.length,c=a[0];b--;)a[b]<c&&(c=a[b]);return c}function Ib(a){for(var b=a.length,c=a[0];b--;)a[b]>c&&(c=a[b]);return c}function Jb(a){for(var b in a)a[b]&&a[b].destroy&&
15
- a[b].destroy(),delete a[b]}function Tb(a){tb||(tb=Aa(Ra));a&&tb.appendChild(a);tb.innerHTML=""}function jc(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+a;if(b)throw c;else ca.console&&console.log(c)}function Cb(a){return parseFloat(a.toPrecision(14))}function Kb(a,b){Ub=p(a,b.animation)}function vc(){var a=Ea.global.useUTC,b=a?"getUTC":"get",c=a?"setUTC":"set";sb=a?Date.UTC:function(a,b,c,g,h,i){return(new Date(a,b,p(c,1),p(g,0),p(h,0),p(i,0))).getTime()};fc=b+"Minutes";gc=b+"Hours";
16
- ic=b+"Day";db=b+"Date";qb=b+"Month";rb=b+"FullYear";pc=c+"Minutes";qc=c+"Hours";hc=c+"Date";rc=c+"Month";sc=c+"FullYear"}function Sa(){}function wc(a,b){function c(a){function b(a,c){this.pos=a;this.type=c||"";this.isNew=!0;c||this.addLabel()}function c(a){if(a)this.options=a,this.id=a.id;return this}function d(a,b,c,e){this.isNegative=b;this.options=a;this.x=c;this.stack=e;this.alignOptions={align:a.align||(U?b?"left":"right":"center"),verticalAlign:a.verticalAlign||(U?"middle":b?"bottom":"top"),
17
- y:p(a.y,U?4:b?14:-6),x:p(a.x,U?b?-6:6:0)};this.textAlign=a.textAlign||(U?b?"right":"left":"center")}function e(){var a=[],b=[],c;C=M=null;o(B.series,function(e){if(e.visible||!q.ignoreHiddenSeries){var f=e.options,g,h,i,j,k,m,l,n,Y,ea=f.threshold,B,o=[],xc=0;if(R&&ea<=0)ea=f.threshold=null;if(t)f=e.xData,f.length&&(C=Ua(p(C,f[0]),Sb(f)),M=W(p(M,f[0]),Ib(f)));else{var y,r,G,v=e.cropped,Z=e.xAxis.getExtremes(),V=!!e.modifyValue;g=f.stacking;Ha=g==="percent";if(g)k=f.stack,j=e.type+p(k,""),m="-"+j,e.stackKey=
18
- j,h=a[j]||[],a[j]=h,i=b[m]||[],b[m]=i;Ha&&(C=0,M=99);f=e.processedXData;l=e.processedYData;B=l.length;for(c=0;c<B;c++)if(n=f[c],Y=l[c],Y!==null&&Y!==X&&(g?(r=(y=Y<ea)?i:h,G=y?m:j,Y=r[n]=s(r[n])?r[n]+Y:Y,qa[G]||(qa[G]={}),qa[G][n]||(qa[G][n]=new d(u.stackLabels,y,n,k)),qa[G][n].setTotal(Y)):V&&(Y=e.modifyValue(Y)),v||(f[c+1]||n)>=Z.min&&(f[c-1]||n)<=Z.max))if(n=Y.length)for(;n--;)Y[n]!==null&&(o[xc++]=Y[n]);else o[xc++]=Y;!Ha&&o.length&&(C=Ua(p(C,o[0]),Sb(o)),M=W(p(M,o[0]),Ib(o)));s(ea)&&(C>=ea?(C=
19
- ea,Ma=!0):M<ea&&(M=ea,Na=!0))}}})}function f(a,b,c){for(var d,b=Cb(Ta(b/a)*a),c=Cb(Yb(c/a)*a),e=[];b<=c;){e.push(b);b=Cb(b+a);if(b===d)break;d=b}return e}function g(a,b,c,d){var e=[];if(!d)B._minorAutoInterval=null;if(a>=0.5)a=z(a),e=f(a,b,c);else if(a>=0.08){var h=Ta(b),i,j,k,n,m,l;for(i=a>0.3?[1,2,4]:a>0.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];h<c+1&&!l;h++){k=i.length;for(j=0;j<k&&!l;j++)n=nb(cb(h)*i[j]),n>b&&e.push(m),m>c&&(l=!0),m=n}}else if(b=cb(b),c=cb(c),a=u[d?"minorTickInterval":"tickInterval"],
20
- a=p(a==="auto"?null:a,B._minorAutoInterval,(c-b)*(u.tickPixelInterval/(d?5:1))/((d?D/N.length:D)||1)),a=ec(a,null,oa.pow(10,Ta(oa.log(a)/oa.LN10))),e=Vb(f(a,b,c),nb),!d)B._minorAutoInterval=a/5;d||(Oa=a);return e}function h(){var a=[],b,c;if(R){c=N.length;for(b=1;b<c;b++)a=a.concat(g(Ga,N[b-1],N[b],!0))}else for(b=F+(N[0]-F)%Ga;b<=H;b+=Ga)a.push(b);return a}function i(){var a,b=M-C>=fb,c,d,e,f,g,h;t&&fb===X&&!R&&(s(u.min)||s(u.max)?fb=null:(o(B.series,function(a){f=a.xData;for(d=g=a.xIncrement?1:
21
- f.length-1;d>0;d--)if(e=f[d]-f[d-1],c===X||e<c)c=e}),fb=Ua(c*5,M-C)));H-F<fb&&(a=(fb-H+F)/2,a=[F-a,p(u.min,F-a)],b&&(a[2]=C),F=Ib(a),h=[F+fb,p(u.max,F+fb)],b&&(h[2]=M),H=Sb(h),H-F<fb&&(a[0]=H-fb,a[1]=p(u.min,H-fb),F=Ib(a)))}function j(a){var b,c=u.tickInterval,d=u.tickPixelInterval;da?(na=m[t?"xAxis":"yAxis"][u.linkedTo],b=na.getExtremes(),F=p(b.min,b.dataMin),H=p(b.max,b.dataMax),u.type!==na.options.type&&jc(11,1)):(F=p(ba,u.min,C),H=p(ca,u.max,M));R&&(!a&&Ua(F,C)<=0&&jc(10,1),F=nb(F),H=nb(H));ja&&
22
- (ba=F=W(F,H-ja),ca=H,a&&(ja=null));i();if(!Va&&!Ha&&!da&&s(F)&&s(H)){b=H-F||1;if(!s(u.min)&&!s(ba)&&Ea&&(C<0||!Ma))F-=b*Ea;if(!s(u.max)&&!s(ca)&&Ja&&(M>0||!Na))H+=b*Ja}Oa=F===H||F===void 0||H===void 0?1:da&&!c&&d===na.options.tickPixelInterval?na.tickInterval:p(c,Va?1:(H-F)*d/(D||1));t&&!a&&o(B.series,function(a){a.processData(F!==ma||H!==za)});ib();B.beforeSetTickPositions&&B.beforeSetTickPositions();B.postProcessTickInterval&&(Oa=B.postProcessTickInterval(Oa));!V&&!R&&(Wa=oa.pow(10,Ta(oa.log(Oa)/
23
- oa.LN10)),s(u.tickInterval)||(Oa=ec(Oa,null,Wa,u)));B.tickInterval=Oa;Ga=u.minorTickInterval==="auto"&&Oa?Oa/5:u.minorTickInterval;(N=u.tickPositions||Xa&&Xa.apply(B,[F,H]))||(N=V?(B.getNonLinearTimeTicks||Lc)(Kc(Oa,u.units),F,H,u.startOfWeek,B.ordinalPositions,B.closestPointRange,!0):R?g(Oa,F,H):f(Oa,F,H));if(!da&&(a=N[0],c=N[N.length-1],u.startOnTick?F=a:F>a&&N.shift(),u.endOnTick?H=c:H<c&&N.pop(),gb||(gb={x:0,y:0}),!V&&N.length>gb[w]&&u.alignTicks!==!1))gb[w]=N.length}function k(a){a=(new c(a)).render();
24
- ta.push(a);return a}function l(){var a=u.title,d=u.stackLabels,e=u.alternateGridColor,f=u.lineWidth,g,i,j=m.hasRendered&&s(ma)&&!isNaN(ma),n=(g=B.series.length&&s(F)&&s(H))||p(u.showEmpty,!0),Y,q;if(g||da)if(Ga&&!Va&&o(h(),function(a){va[a]||(va[a]=new b(a,"minor"));j&&va[a].isNew&&va[a].render(null,!0);va[a].isActive=!0;va[a].render()}),o(N.slice(1).concat([N[0]]),function(a,c){c=c===N.length-1?0:c+1;if(!da||a>=F&&a<=H)Pa[a]||(Pa[a]=new b(a)),j&&Pa[a].isNew&&Pa[a].render(c,!0),Pa[a].isActive=!0,
25
- Pa[a].render(c)}),e&&o(N,function(a,b){if(b%2===0&&a<H)Da[a]||(Da[a]=new c),Y=a,q=N[b+1]!==X?N[b+1]:H,Da[a].options={from:R?cb(Y):Y,to:R?cb(q):q,color:e},Da[a].render(),Da[a].isActive=!0}),!B._addedPlotLB)o((u.plotLines||[]).concat(u.plotBands||[]),function(a){k(a)}),B._addedPlotLB=!0;o([Pa,va,Da],function(a){for(var b in a)a[b].isActive?a[b].isActive=!1:(a[b].destroy(),delete a[b])});f&&(g=x+(y?A:0)+T,i=ra-Lb-(y?hb:0)+T,g=I.crispLine([wa,G?x:g,G?i:E,fa,G?sa-Zb:g,G?i:ra-Lb],f),$?$.animate({d:g}):
26
- $=I.path(g).attr({stroke:u.lineColor,"stroke-width":f,zIndex:7}).add(),$[n?"show":"hide"]());if(v&&n)n=G?x:E,f=S(a.style.fontSize||12),n={low:n+(G?0:D),middle:n+D/2,high:n+(G?D:0)}[a.align],f=(G?E+hb:x)+(G?1:-1)*(y?-1:1)*Ya+(r===2?f:0),v[v.isNew?"attr":"animate"]({x:G?n:f+(y?A:0)+T+(a.x||0),y:G?f-(y?hb:0)+T:n+(a.y||0)}),v.isNew=!1;if(d&&d.enabled){var t,yc,d=B.stackTotalGroup;if(!d)B.stackTotalGroup=d=I.g("stack-labels").attr({visibility:eb,zIndex:6}).translate(O,J).add();for(t in qa)for(yc in a=
27
- qa[t],a)a[yc].render(d)}B.isDirty=!1}function n(a){for(var b=ta.length;b--;)ta[b].id===a&&ta[b].destroy()}var t=a.isX,y=a.opposite,G=U?!t:t,r=G?y?0:2:y?1:3,qa={},u=K(t?$b:kc,[Nc,Oc,zc,Pc][r],a),B=this,v,Z=u.type,V=Z==="datetime",R=Z==="logarithmic",T=u.offset||0,w=t?"x":"y",D=0,ua,ia,bb,jb,x,E,A,hb,Lb,Zb,Mb,ib,P,Q,bc,$,C,M,fb=u.minRange||u.maxZoom,ja=u.range,ba,ca,Aa,Ca,H=null,F=null,ma,za,Ea=u.minPadding,Ja=u.maxPadding,Ka=0,da=s(u.linkedTo),na,Ma,Na,Ha,Z=u.events,Sa,ta=[],Oa,Ga,Wa,N,Xa=u.tickPositioner,
28
- Pa={},va={},Da={},Fa,La,Ya,Va=u.categories,db=u.labels.formatter||function(){var a=this.value,b=this.dateTimeLabelFormat;return b?ac(b,a):Oa%1E6===0?a/1E6+"M":Oa%1E3===0?a/1E3+"k":!Va&&a>=1E3?dc(a,0):a},Ra=G&&u.labels.staggerLines,ya=u.reversed,Ia=Va&&u.tickmarkPlacement==="between"?0.5:0;b.prototype={addLabel:function(){var a=this.pos,b=u.labels,c=Va&&G&&Va.length&&!b.step&&!b.staggerLines&&!b.rotation&&ka/Va.length||!G&&ka/2,d=a===N[0],e=a===N[N.length-1],f=Va&&s(Va[a])?Va[a]:a,g=this.label,h=N.info,
29
- i;V&&h&&(i=u.dateTimeLabelFormats[h.higherRanks[a]||h.unitName]);this.isFirst=d;this.isLast=e;a=db.call({axis:B,chart:m,isFirst:d,isLast:e,dateTimeLabelFormat:i,value:R?Cb(cb(f)):f});c=c&&{width:W(1,z(c-2*(b.padding||10)))+ga};c=L(c,b.style);s(g)?g&&g.attr({text:a}).css(c):this.label=s(a)&&b.enabled?I.text(a,0,0,b.useHTML).attr({align:b.align,rotation:b.rotation}).css(c).add(Q):null},getLabelSize:function(){var a=this.label;return a?(this.labelBBox=a.getBBox())[G?"height":"width"]:0},getLabelSides:function(){var a=
30
- u.labels,b=this.labelBBox.width,a=b*{left:0,center:0.5,right:1}[a.align]-a.x;return[-a,b-a]},handleOverflow:function(a){var b=!0,c=this.isFirst,d=this.isLast,e=this.label,f=e.x;if(c||d){var g=this.getLabelSides(),h=g[0],g=g[1],i=m.plotLeft,j=i+B.len,k=(a=Pa[N[a+(c?1:-1)]])&&a.label.x+a.getLabelSides()[c?0:1];c&&!ya||d&&ya?f+h<i&&(f=i-h,a&&f+g>k&&(b=!1)):f+g>j&&(f=j-g,a&&f+h<k&&(b=!1));e.x=f}return b},render:function(a,b){var c=this.type,d=this.label,e=this.pos,f=u.labels,g=this.gridLine,h=c?c+"Grid":
31
- "grid",i=c?c+"Tick":"tick",j=u[h+"LineWidth"],k=u[h+"LineColor"],n=u[h+"LineDashStyle"],m=u[i+"Length"],h=u[i+"Width"]||0,l=u[i+"Color"],Y=u[i+"Position"],i=this.mark,q=f.step,ea=b&&Za||ra,qa=!0,o;o=G?Mb(e+Ia,null,null,b)+bb:x+T+(y?(b&&$a||sa)-Zb-x:0);ea=G?ea-Lb+T-(y?hb:0):ea-Mb(e+Ia,null,null,b)-bb;if(j){e=P(e+Ia,j,b);if(g===X){g={stroke:k,"stroke-width":j};if(n)g.dashstyle=n;if(!c)g.zIndex=1;this.gridLine=g=j?I.path(e).attr(g).add(bc):null}!b&&g&&e&&g.animate({d:e})}if(h)Y==="inside"&&(m=-m),y&&
32
- (m=-m),c=I.crispLine([wa,o,ea,fa,o+(G?0:-m),ea+(G?m:0)],h),i?i.animate({d:c}):this.mark=I.path(c).attr({stroke:l,"stroke-width":h}).add(Q);if(d&&!isNaN(o))o=o+f.x-(Ia&&G?Ia*ia*(ya?-1:1):0),ea=ea+f.y-(Ia&&!G?Ia*ia*(ya?1:-1):0),s(f.y)||(ea+=S(d.styles.lineHeight)*0.9-d.getBBox().height/2),Ra&&(ea+=a/(q||1)%Ra*16),d.x=o,d.y=ea,this.isFirst&&!p(u.showFirstLabel,1)||this.isLast&&!p(u.showLastLabel,1)?qa=!1:!Ra&&G&&f.overflow==="justify"&&!this.handleOverflow(a)&&(qa=!1),q&&a%q&&(qa=!1),qa?(d[this.isNew?
33
- "attr":"animate"]({x:d.x,y:d.y}),d.show(),this.isNew=!1):d.hide()},destroy:function(){Jb(this)}};c.prototype={render:function(){var a=this,b=(B.pointRange||0)/2,c=a.options,d=c.label,e=a.label,f=c.width,g=c.to,h=c.from,i=c.value,j,k=c.dashStyle,n=a.svgElem,m=[],l,Y,u=c.color;Y=c.zIndex;var ea=c.events;R&&(h=nb(h),g=nb(g),i=nb(i));if(f){if(m=P(i,f),b={stroke:u,"stroke-width":f},k)b.dashstyle=k}else if(s(h)&&s(g))h=W(h,F-b),g=Ua(g,H+b),j=P(g),(m=P(h))&&j?m.push(j[4],j[5],j[1],j[2]):m=null,b={fill:u};
34
- else return;if(s(Y))b.zIndex=Y;if(n)m?n.animate({d:m},null,n.onGetPath):(n.hide(),n.onGetPath=function(){n.show()});else if(m&&m.length&&(a.svgElem=n=I.path(m).attr(b).add(),ea))for(l in k=function(b){n.on(b,function(c){ea[b].apply(a,[c])})},ea)k(l);if(d&&s(d.text)&&m&&m.length&&A>0&&hb>0){d=K({align:G&&j&&"center",x:G?!j&&4:10,verticalAlign:!G&&j&&"middle",y:G?j?16:10:j?6:-4,rotation:G&&!j&&90},d);if(!e)a.label=e=I.text(d.text,0,0).attr({align:d.textAlign||d.align,rotation:d.rotation,zIndex:Y}).css(d.style).add();
35
- j=[m[1],m[4],p(m[6],m[1])];m=[m[2],m[5],p(m[7],m[2])];l=Sb(j);Y=Sb(m);e.align(d,!1,{x:l,y:Y,width:Ib(j)-l,height:Ib(m)-Y});e.show()}else e&&e.hide();return a},destroy:function(){Jb(this);Gb(ta,this)}};d.prototype={destroy:function(){Jb(this)},setTotal:function(a){this.cum=this.total=a},render:function(a){var b=this.options.formatter.call(this);this.label?this.label.attr({text:b,visibility:ab}):this.label=m.renderer.text(b,0,0).css(this.options.style).attr({align:this.textAlign,rotation:this.options.rotation,
36
- visibility:ab}).add(a)},setOffset:function(a,b){var c=this.isNegative,d=B.translate(this.total,0,0,0,1),e=B.translate(0),e=Ba(d-e),f=m.xAxis[0].translate(this.x)+a,g=m.plotHeight,c={x:U?c?d:d-e:f,y:U?g-f-b:c?g-d-e:g-d,width:U?e:b,height:U?b:e};this.label&&this.label.align(this.alignOptions,null,c).attr({visibility:eb})}};Mb=function(a,b,c,d,e){var f=1,g=0,h=d?jb:ia,d=d?ma:F,e=u.ordinal||R&&e;h||(h=ia);c&&(f*=-1,g=D);ya&&(f*=-1,g-=f*D);b?(ya&&(a=D-a),a=a/h+d,e&&(a=B.lin2val(a))):(e&&(a=B.val2lin(a)),
37
- a=f*(a-d)*h+g+f*Ka);return a};P=function(a,b,c){var d,e,f,a=Mb(a,null,null,c),g=c&&Za||ra,h=c&&$a||sa,i,c=e=z(a+bb);d=f=z(g-a-bb);if(isNaN(a))i=!0;else if(G){if(d=E,f=g-Lb,c<x||c>x+A)i=!0}else if(c=x,e=h-Zb,d<E||d>E+hb)i=!0;return i?null:I.crispLine([wa,c,d,fa,e,f],b||0)};ib=function(){var a=H-F,b=0,c,d;if(t)da?b=na.pointRange:o(B.series,function(a){b=W(b,a.pointRange);d=a.closestPointRange;!a.noSharedTooltip&&s(d)&&(c=s(c)?Ua(c,d):d)}),B.pointRange=b,B.closestPointRange=c;jb=ia;B.translationSlope=
38
- ia=D/(a+b||1);bb=G?x:Lb;Ka=ia*(b/2)};xa.push(B);m[t?"xAxis":"yAxis"].push(B);U&&t&&ya===X&&(ya=!0);L(B,{addPlotBand:k,addPlotLine:k,adjustTickAmount:function(){if(gb&&gb[w]&&!V&&!Va&&!da&&u.alignTicks!==!1){var a=Fa,b=N.length;Fa=gb[w];if(b<Fa){for(;N.length<Fa;)N.push(Cb(N[N.length-1]+Oa));ia*=(b-1)/(Fa-1);H=N[N.length-1]}if(s(a)&&Fa!==a)B.isDirty=!0}},categories:Va,getExtremes:function(){return{min:R?Cb(cb(F)):F,max:R?Cb(cb(H)):H,dataMin:C,dataMax:M,userMin:ba,userMax:ca}},getPlotLinePath:P,getThreshold:function(a){var b=
39
- R?cb(F):F,c=R?cb(H):H;b>a||a===null?a=b:c<a&&(a=c);return Mb(a,0,1,0,1)},isXAxis:t,options:u,plotLinesAndBands:ta,getOffset:function(){var a=B.series.length&&s(F)&&s(H),c=a||p(u.showEmpty,!0),d=0,e,f=0,g=u.title,h=u.labels,i=[-1,1,1,-1][r],j;Q||(Q=I.g("axis").attr({zIndex:7}).add(),bc=I.g("grid").attr({zIndex:u.gridZIndex||1}).add());La=0;if(a||da)o(N,function(a){Pa[a]?Pa[a].addLabel():Pa[a]=new b(a)}),o(N,function(a){if(r===0||r===2||{1:"left",3:"right"}[r]===h.align)La=W(Pa[a].getLabelSize(),La)}),
40
- Ra&&(La+=(Ra-1)*16);else for(j in Pa)Pa[j].destroy(),delete Pa[j];if(g&&g.text){if(!v)v=B.axisTitle=I.text(g.text,0,0,g.useHTML).attr({zIndex:7,rotation:g.rotation||0,align:g.textAlign||{low:"left",middle:"center",high:"right"}[g.align]}).css(g.style).add(),v.isNew=!0;if(c)d=v.getBBox()[G?"height":"width"],f=p(g.margin,G?5:10),e=g.offset;v[c?"show":"hide"]()}T=i*p(u.offset,pa[r]);Ya=p(e,La+f+(r!==2&&La&&i*u.labels[G?"y":"x"]));pa[r]=W(pa[r],Ya+d+i*T)},render:l,setAxisSize:function(){var a=u.offsetLeft||
41
- 0,b=u.offsetRight||0;x=p(u.left,O+a);E=p(u.top,J);A=p(u.width,ka-a+b);hb=p(u.height,la);Lb=ra-hb-E;Zb=sa-A-x;D=G?A:hb;B.left=x;B.top=E;B.len=D},setAxisTranslation:ib,setCategories:function(b,c){B.categories=a.categories=Va=b;o(B.series,function(a){a.translate();a.setTooltipPoints(!0)});B.isDirty=!0;p(c,!0)&&m.redraw()},setExtremes:function(a,b,c,d,e){c=p(c,!0);e=L(e,{min:a,max:b});aa(B,"setExtremes",e,function(){ba=a;ca=b;B.isDirtyExtremes=!0;c&&m.redraw(d)})},setScale:function(){var a,b,c,d;ma=F;
42
- za=H;ua=D;D=G?A:hb;d=D!==ua;o(B.series,function(a){if(a.isDirtyData||a.isDirty||a.xAxis.isDirty)c=!0});if(d||c||da||ba!==Aa||ca!==Ca){e();j();Aa=ba;Ca=ca;if(!t)for(a in qa)for(b in qa[a])qa[a][b].cum=qa[a][b].total;if(!B.isDirty)B.isDirty=d||F!==ma||H!==za}},setTickPositions:j,translate:Mb,redraw:function(){ub.resetTracker&&ub.resetTracker();l();o(ta,function(a){a.render()});o(B.series,function(a){a.isDirty=!0})},removePlotBand:n,removePlotLine:n,reversed:ya,setTitle:function(a,b){u.title=K(u.title,
43
- a);v=v.destroy();B.isDirty=!0;p(b,!0)&&m.redraw()},series:[],stacks:qa,destroy:function(){var a;Qa(B);for(a in qa)Jb(qa[a]),qa[a]=null;if(B.stackTotalGroup)B.stackTotalGroup=B.stackTotalGroup.destroy();o([Pa,va,Da,ta],function(a){Jb(a)});o([$,Q,bc,v],function(a){a&&a.destroy()});$=Q=bc=v=null}});for(Sa in Z)ha(B,Sa,Z[Sa]);if(R)B.val2lin=nb,B.lin2val=cb}function d(a){function b(){var c=this.points||Hb(this),d=c[0].series,e;e=[d.tooltipHeaderFormatter(c[0].key)];o(c,function(a){d=a.series;e.push(d.tooltipFormatter&&
44
- d.tooltipFormatter(a)||a.point.tooltipFormatter(d.tooltipOptions.pointFormat))});e.push(a.footerFormat||"");return e.join("")}function c(a,b){l=n?a:(2*l+a)/3;q=n?b:(q+b)/2;t.attr({x:l,y:q});lb=Ba(a-l)>1||Ba(b-q)>1?function(){c(a,b)}:null}function d(){if(!n){var a=m.hoverPoints;t.hide();a&&o(a,function(a){a.setState()});m.hoverPoints=null;n=!0}}var e,f=a.borderWidth,g=a.crosshairs,h=[],i=a.style,j=a.shared,k=S(i.padding),n=!0,l=0,q=0;i.padding=0;var t=I.label("",0,0,null,null,null,a.useHTML).attr({padding:k,
45
- fill:a.backgroundColor,"stroke-width":f,r:a.borderRadius,zIndex:8}).css(i).hide().add();Fa||t.shadow(a.shadow);return{shared:j,refresh:function(f){var i,k,l,q,r={},y=[];l=f.tooltipPos;i=a.formatter||b;var r=m.hoverPoints,v;j&&(!f.series||!f.series.noSharedTooltip)?(q=0,r&&o(r,function(a){a.setState()}),m.hoverPoints=f,o(f,function(a){a.setState(ta);q+=a.plotY;y.push(a.getLabelConfig())}),k=f[0].plotX,q=z(q)/f.length,r={x:f[0].category},r.points=y,f=f[0]):r=f.getLabelConfig();r=i.call(r);e=f.series;
46
- k=p(k,f.plotX);q=p(q,f.plotY);i=z(l?l[0]:U?ka-q:k);k=z(l?l[1]:U?la-k:q);l=j||!e.isCartesian||e.tooltipOutsidePlot||Db(i,k);r===!1||!l?d():(n&&(t.show(),n=!1),t.attr({text:r}),v=a.borderColor||f.color||e.color||"#606060",t.attr({stroke:v}),l=uc(t.width,t.height,O,J,ka,la,{x:i,y:k},p(a.distance,12),U),c(z(l.x),z(l.y)));if(g){g=Hb(g);var R;l=g.length;for(var Z;l--;)if(R=f.series[l?"yAxis":"xAxis"],g[l]&&R)if(R=R.getPlotLinePath(l?p(f.stackY,f.y):f.x,1),h[l])h[l].attr({d:R,visibility:eb});else{Z={"stroke-width":g[l].width||
47
- 1,stroke:g[l].color||"#C0C0C0",zIndex:g[l].zIndex||2};if(g[l].dashStyle)Z.dashstyle=g[l].dashStyle;h[l]=I.path(R).attr(Z).add()}}aa(m,"tooltipRefresh",{text:r,x:i+O,y:k+J,borderColor:v})},hide:d,hideCrosshairs:function(){o(h,function(a){a&&a.hide()})},destroy:function(){o(h,function(a){a&&a.destroy()});t&&(t=t.destroy())}}}function e(a){function b(a){var c,d,e,a=a||ca.event;if(!a.target)a.target=a.srcElement;if(a.originalEvent)a=a.originalEvent;if(a.event)a=a.event;c=a.touches?a.touches.item(0):a;
48
- ya=Ac(D);d=ya.left;e=ya.top;Qb?(d=a.x,c=a.y):(d=c.pageX-d,c=c.pageY-e);return L(a,{chartX:z(d),chartY:z(c)})}function c(a){var b={xAxis:[],yAxis:[]};o(xa,function(c){var d=c.translate,e=c.isXAxis;b[e?"xAxis":"yAxis"].push({axis:c,value:d((U?!e:e)?a.chartX-O:la-a.chartY+J,!0)})});return b}function e(){var a=m.hoverSeries,b=m.hoverPoint;if(b)b.onMouseOut();if(a)a.onMouseOut();vb&&(vb.hide(),vb.hideCrosshairs());ob=null}function f(){if(n){var a={xAxis:[],yAxis:[]},b=n.getBBox(),c=b.x-O,d=b.y-J;k&&(o(xa,
49
- function(e){if(e.options.zoomEnabled!==!1){var f=e.translate,g=e.isXAxis,h=U?!g:g,i=f(h?c:la-d-b.height,!0,0,0,1),f=f(h?c+b.width:la-d,!0,0,0,1);a[g?"xAxis":"yAxis"].push({axis:e,min:Ua(i,f),max:W(i,f)})}}),aa(m,"selection",a,zb));n=n.destroy()}P(D,{cursor:"auto"});m.mouseIsDown=Da=k=!1;Qa(x,Ga?"touchend":"mouseup",f)}function g(a){var b=s(a.pageX)?a.pageX:a.page.x,a=s(a.pageX)?a.pageY:a.page.y;ya&&!Db(b-ya.left-O,a-ya.top-J)&&e()}function h(){e();ya=null}var i,j,k,n,l=Fa?"":q.zoomType,t=/x/.test(l),
50
- r=/y/.test(l),y=t&&!U||r&&U,p=r&&!U||t&&U;if(!db)m.trackerGroup=db=I.g("tracker").attr({zIndex:9}).add();if(a.enabled)m.tooltip=vb=d(a),Bb=setInterval(function(){lb&&lb()},32);(function(){D.onmousedown=function(a){a=b(a);!Ga&&a.preventDefault&&a.preventDefault();m.mouseIsDown=Da=!0;m.mouseDownX=i=a.chartX;j=a.chartY;ha(x,Ga?"touchend":"mouseup",f)};var d=function(c){if(!c||!(c.touches&&c.touches.length>1)){c=b(c);if(!Ga)c.returnValue=!1;var d=c.chartX,e=c.chartY,f=!Db(d-O,e-J);Ga&&c.type==="touchstart"&&
51
- (A(c.target,"isTracker")?m.runTrackerClick||c.preventDefault():!kb&&!f&&c.preventDefault());f&&(d<O?d=O:d>O+ka&&(d=O+ka),e<J?e=J:e>J+la&&(e=J+la));if(Da&&c.type!=="touchstart"){if(k=Math.sqrt(Math.pow(i-d,2)+Math.pow(j-e,2)),k>10){var g=Db(i-O,j-J);if(Nb&&(t||r)&&g)n||(n=I.rect(O,J,y?1:ka,p?1:la,0).attr({fill:q.selectionMarkerFill||"rgba(69,114,167,0.25)",zIndex:7}).add());n&&y&&(c=d-i,n.attr({width:Ba(c),x:(c>0?0:c)+i}));n&&p&&(e-=j,n.attr({height:Ba(e),y:(e>0?0:e)+j}));g&&!n&&q.panning&&m.pan(d)}}else if(!f){var h,
52
- d=m.hoverPoint,e=m.hoverSeries,l,o,g=sa,R=U?c.chartY:c.chartX-O;if(vb&&a.shared&&(!e||!e.noSharedTooltip)){h=[];l=Q.length;for(o=0;o<l;o++)if(Q[o].visible&&Q[o].options.enableMouseTracking!==!1&&!Q[o].noSharedTooltip&&Q[o].tooltipPoints.length)c=Q[o].tooltipPoints[R],c._dist=Ba(R-c.plotX),g=Ua(g,c._dist),h.push(c);for(l=h.length;l--;)h[l]._dist>g&&h.splice(l,1);if(h.length&&h[0].plotX!==ob)vb.refresh(h),ob=h[0].plotX}if(e&&e.tracker&&(c=e.tooltipPoints[R])&&c!==d)c.onMouseOver()}return f||!Nb}};D.onmousemove=
53
- d;ha(D,"mouseleave",h);ha(x,"mousemove",g);D.ontouchstart=function(a){if(t||r)D.onmousedown(a);d(a)};D.ontouchmove=d;D.ontouchend=function(){k&&e()};D.onclick=function(a){var d=m.hoverPoint,a=b(a);a.cancelBubble=!0;if(!k)if(d&&(A(a.target,"isTracker")||A(a.target.parentNode,"isTracker"))){var e=d.plotX,f=d.plotY;L(d,{pageX:ya.left+O+(U?ka-f:e),pageY:ya.top+J+(U?la-e:f)});aa(d.series,"click",L(a,{point:d}));d.firePointEvent("click",a)}else L(a,c(a)),Db(a.chartX-O,a.chartY-J)&&aa(m,"click",a);k=!1}})();
54
- L(this,{zoomX:t,zoomY:r,resetTracker:e,normalizeMouseEvent:b,destroy:function(){if(m.trackerGroup)m.trackerGroup=db=m.trackerGroup.destroy();Qa(D,"mouseleave",h);Qa(x,"mousemove",g);D.onclick=D.onmousedown=D.onmousemove=D.ontouchstart=D.ontouchend=D.ontouchmove=null}})}function f(a){var b=a.type||q.type||q.defaultSeriesType,c=Ha[b],d=m.hasRendered;if(d)if(U&&b==="column")c=Ha.bar;else if(!U&&b==="bar")c=Ha.column;b=new c;b.init(m,a);!d&&b.inverted&&(U=!0);if(b.isCartesian)Nb=b.isCartesian;Q.push(b);
55
- return b}function g(){q.alignTicks!==!1&&o(xa,function(a){a.adjustTickAmount()});gb=null}function h(a){var b=m.isDirtyLegend,c,d=m.isDirtyBox,e=Q.length,f=e,h=m.clipRect;for(Kb(a,m);f--;)if(a=Q[f],a.isDirty&&a.options.stacking){c=!0;break}if(c)for(f=e;f--;)if(a=Q[f],a.options.stacking)a.isDirty=!0;o(Q,function(a){a.isDirty&&a.options.legendType==="point"&&(b=!0)});if(b&&Xa.renderLegend)Xa.renderLegend(),m.isDirtyLegend=!1;Nb&&(La||(gb=null,o(xa,function(a){a.setScale()})),g(),Wb(),o(xa,function(a){if(a.isDirtyExtremes)a.isDirtyExtremes=
56
- !1,aa(a,"afterSetExtremes",a.getExtremes());if(a.isDirty||d)a.redraw(),d=!0}));d&&(qb(),h&&(Ob(h),h.animate({width:m.plotSizeX,height:m.plotSizeY+1})));o(Q,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()});ub&&ub.resetTracker&&ub.resetTracker();I.draw();aa(m,"redraw")}function i(){var a=v.xAxis||{},b=v.yAxis||{},a=Hb(a);o(a,function(a,b){a.index=b;a.isX=!0});b=Hb(b);o(b,function(a,b){a.index=b});a=a.concat(b);o(a,function(a){new c(a)});g()}function k(){var a=Ea.lang,b=q.resetZoomButton,
57
- c=b.theme,d=c.states,e=b.relativeTo==="chart"?null:{x:O,y:J,width:ka,height:la};m.resetZoomButton=I.button(a.resetZoom,null,null,Fb,c,d&&d.hover).attr({align:b.position.align,title:a.resetZoomTitle}).add().align(b.position,!1,e)}function j(a,b){$=K(v.title,a);ja=K(v.subtitle,b);o([["title",a,$],["subtitle",b,ja]],function(a){var b=a[0],c=m[b],d=a[1],a=a[2];c&&d&&(c=c.destroy());a&&a.text&&!c&&(m[b]=I.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":Ia+b,zIndex:a.zIndex||4}).css(a.style).add().align(a,
58
- !1,ib))})}function l(){Ja=q.renderTo;na=Ia+lc++;Ab(Ja)&&(Ja=x.getElementById(Ja));Ja||jc(13,!0);Ja.innerHTML="";Ja.offsetWidth||(C=Ja.cloneNode(0),P(C,{position:wb,top:"-9999px",display:""}),x.body.appendChild(C));za=(C||Ja).offsetWidth;Ca=(C||Ja).offsetHeight;m.chartWidth=sa=q.width||za||600;m.chartHeight=ra=q.height||(Ca>19?Ca:400);m.container=D=Aa(Ra,{className:Ia+"container"+(q.className?" "+q.className:""),id:na},L({position:mc,overflow:ab,width:sa+ga,height:ra+ga,textAlign:"left",lineHeight:"normal"},
59
- q.style),C||Ja);m.renderer=I=q.forExport?new Eb(D,sa,ra,!0):new Xb(D,sa,ra);Fa&&I.create(m,D,sa,ra);var a,b;Bc&&D.getBoundingClientRect&&(a=function(){P(D,{left:0,top:0});b=D.getBoundingClientRect();P(D,{left:-(b.left-S(b.left))+ga,top:-(b.top-S(b.top))+ga})},a(),ha(ca,"resize",a),ha(m,"destroy",function(){Qa(ca,"resize",a)}))}function n(){function a(c){var d=q.width||Ja.offsetWidth,e=q.height||Ja.offsetHeight,c=c?c.target:ca;if(d&&e&&(c===ca||c===x)){if(d!==za||e!==Ca)clearTimeout(b),b=setTimeout(function(){tb(d,
60
- e,!1)},100);za=d;Ca=e}}var b;ha(ca,"resize",a);ha(m,"destroy",function(){Qa(ca,"resize",a)})}function t(){m&&aa(m,"endResize",null,function(){La-=1})}function r(){for(var a=U||q.inverted||q.type==="bar"||q.defaultSeriesType==="bar",b=v.series,c=b&&b.length;!a&&c--;)b[c].type==="bar"&&(a=!0);m.inverted=U=a}function Z(){var a=v.labels,b=v.credits,c;j();Xa=m.legend=new Rb;o(xa,function(a){a.setScale()});Wb();o(xa,function(a){a.setTickPositions(!0)});g();Wb();qb();Nb&&o(xa,function(a){a.render()});if(!m.seriesGroup)m.seriesGroup=
61
- I.g("series-group").attr({zIndex:3}).add();o(Q,function(a){a.translate();a.setTooltipPoints();a.render()});a.items&&o(a.items,function(){var b=L(a.style,this.style),c=S(b.left)+O,d=S(b.top)+J+12;delete b.left;delete b.top;I.text(this.html,c,d).attr({zIndex:2}).css(b).add()});if(b.enabled&&!m.credits)c=b.href,m.credits=I.text(b.text,0,0).on("click",function(){if(c)location.href=c}).attr({align:b.position.align,zIndex:8}).css(b.style).add().align(b.position);m.hasRendered=!0}function V(){if(!Pb&&ca==
62
- ca.top&&x.readyState!=="complete"||Fa&&!ca.canvg)Fa?Cc.push(V,v.global.canvasToolsURL):x.attachEvent("onreadystatechange",function(){x.detachEvent("onreadystatechange",V);x.readyState==="complete"&&V()});else{l();aa(m,"init");if(Highcharts.RangeSelector&&v.rangeSelector.enabled)m.rangeSelector=new Highcharts.RangeSelector(m);rb();sb();r();i();o(v.series||[],function(a){f(a)});if(Highcharts.Scroller&&(v.navigator.enabled||v.scrollbar.enabled))m.scroller=new Highcharts.Scroller(m);m.render=Z;m.tracker=
63
- ub=new e(v.tooltip);Z();I.draw();b&&b.apply(m,[m]);o(m.callbacks,function(a){a.apply(m,[m])});C&&(Ja.appendChild(D),Tb(C));aa(m,"load")}}var v,y=a.series;a.series=null;v=K(Ea,a);v.series=a.series=y;var q=v.chart,y=q.margin,y=mb(y)?y:[y,y,y,y],T=p(q.marginTop,y[0]),w=p(q.marginRight,y[1]),E=p(q.marginBottom,y[2]),bb=p(q.marginLeft,y[3]),ia=q.spacingTop,ua=q.spacingRight,R=q.spacingBottom,jb=q.spacingLeft,ib,$,ja,J,ba,M,O,pa,Ja,C,D,na,za,Ca,sa,ra,$a,Za,ma,Na,Sa,da,m=this,kb=(y=q.events)&&!!y.click,
64
- va,Db,vb,Da,xb,pb,Ya,la,ka,ub,db,Xa,Wa,yb,ya,Nb=q.showAxes,La=0,xa=[],gb,Q=[],U,I,lb,Bb,ob,qb,Wb,rb,sb,tb,zb,Fb,Rb=function(){function a(b,c){var d=b.legendItem,e=b.legendLine,g=b.legendSymbol,h=q.color,i=c?f.itemStyle.color:h,h=c?b.color:h;d&&d.css({fill:i});e&&e.attr({stroke:h});g&&g.attr({stroke:h,fill:h})}function b(a){var c=a.legendItem,d=a.legendLine,e=a._legendItemPos,f=e[0],e=e[1],g=a.legendSymbol,a=a.checkbox;c&&c.attr({x:r?f:Wa-f,y:e});d&&d.translate(r?f:Wa-f,e-4);g&&(c=f+g.xOff,g.attr({x:r?
65
- c:Wa-c,y:e+g.yOff}));if(a)a.x=f,a.y=e}function c(){o(j,function(a){var b=a.checkbox,c=A.alignAttr;b&&P(b,{left:c.translateX+a.legendItemWidth+b.x-40+ga,top:c.translateY+b.y-11+ga})})}function d(b){var c,e,j,k,m=b.legendItem;k=b.series||b;var o=k.options,v=o&&o.borderWidth||0;if(!m){k=/^(bar|pie|area|column)$/.test(k.type);b.legendItem=m=I.text(f.labelFormatter.call(b),0,0,f.useHTML).css(b.visible?n:q).on("mouseover",function(){b.setState(ta);m.css(l)}).on("mouseout",function(){m.css(b.visible?n:q);
66
- b.setState()}).on("click",function(){var a=function(){b.setVisible()};b.firePointEvent?b.firePointEvent("legendItemClick",null,a):aa(b,"legendItemClick",null,a)}).attr({align:r?"left":"right",zIndex:2}).add(A);if(!k&&o&&o.lineWidth){var u={"stroke-width":o.lineWidth,zIndex:2};if(o.dashStyle)u.dashstyle=o.dashStyle;b.legendLine=I.path([wa,(-h-i)*(r?1:-1),0,fa,-i*(r?1:-1),0]).attr(u).add(A)}if(k)j=I.rect(c=-h-i,e=-11,h,12,2).attr({zIndex:3}).add(A),r||(c+=h);else if(o&&o.marker&&o.marker.enabled)j=
67
- o.marker.radius,j=I.symbol(b.symbol,c=-h/2-i-j,e=-4-j,2*j,2*j).attr(b.pointAttr[Ka]).attr({zIndex:3}).add(A),r||(c+=h/2);if(j)j.xOff=c+v%2/2,j.yOff=e+v%2/2;b.legendSymbol=j;a(b,b.visible);if(o&&o.showCheckbox)b.checkbox=Aa("input",{type:"checkbox",checked:b.selected,defaultChecked:b.selected},f.itemCheckboxStyle,D),ha(b.checkbox,"click",function(a){aa(b,"checkboxClick",{checked:a.target.checked},function(){b.select()})})}c=m.getBBox();e=b.legendItemWidth=f.itemWidth||h+i+c.width+t;w=c.height;if(g&&
68
- s-V+e>(J||sa-2*t-V))s=V,z+=y+w+p;!g&&z+f.y+w>ra-ia-R&&(z=T,s+=Z,Z=0);Z=W(Z,e);x=W(x,z+p);b._legendItemPos=[s,z];g?s+=e:z+=y+w+p;C=J||W(s-V+(g?0:e),C)}function e(){s=V;z=T;x=C=0;A||(A=I.g("legend").attr({zIndex:7}).add());j=[];o(M,function(a){var b=a.options;b.showInLegend&&(j=j.concat(a.legendItems||(b.legendType==="point"?a.data:a)))});Mc(j,function(a,b){return(a.options.legendIndex||0)-(b.options.legendIndex||0)});jb&&j.reverse();o(j,d);Wa=J||C;yb=x-v+w;if(E||bb){Wa+=2*t;yb+=2*t;if(ua){if(Wa>0&&
69
- yb>0)ua[ua.isNew?"attr":"animate"](ua.crisp(null,null,null,Wa,yb)),ua.isNew=!1}else ua=I.rect(0,0,Wa,yb,f.borderRadius,E||0).attr({stroke:f.borderColor,"stroke-width":E||0,fill:bb||Ma}).add(A).shadow(f.shadow),ua.isNew=!0;ua[j.length?"show":"hide"]()}o(j,b);for(var a=["left","right","top","bottom"],g,h=4;h--;)g=a[h],k[g]&&k[g]!=="auto"&&(f[h<2?"align":"verticalAlign"]=g,f[h<2?"x":"y"]=S(k[g])*(h%2?-1:1));j.length&&A.align(L(f,{width:Wa,height:yb}),!0,ib);La||c()}var f=m.options.legend;if(f.enabled){var g=
70
- f.layout==="horizontal",h=f.symbolWidth,i=f.symbolPadding,j,k=f.style,n=f.itemStyle,l=f.itemHoverStyle,q=K(n,f.itemHiddenStyle),t=f.padding||S(k.padding),r=!f.rtl,y=f.itemMarginTop||0,p=f.itemMarginBottom||0,v=18,Z=0,V=4+t+h+i,T=t+y+v-5,s,z,x,w=0,ua,E=f.borderWidth,bb=f.backgroundColor,A,C,J=f.width,M=m.series,jb=f.reversed;e();ha(m,"endResize",c);return{colorizeItem:a,destroyItem:function(a){var b=a.checkbox;o(["legendItem","legendLine","legendSymbol"],function(b){a[b]&&a[b].destroy()});b&&Tb(a.checkbox)},
71
- renderLegend:e,destroy:function(){ua&&(ua=ua.destroy());A&&(A=A.destroy())}}}};Db=function(a,b){return a>=0&&a<=ka&&b>=0&&b<=la};Fb=function(){var a=m.resetZoomButton;aa(m,"selection",{resetSelection:!0},zb);if(a)m.resetZoomButton=a.destroy()};zb=function(a){var b;m.resetZoomEnabled!==!1&&!m.resetZoomButton&&k();!a||a.resetSelection?o(xa,function(a){a.options.zoomEnabled!==!1&&(a.setExtremes(null,null,!1),b=!0)}):o(a.xAxis.concat(a.yAxis),function(a){var c=a.axis;if(m.tracker[c.isXAxis?"zoomX":"zoomY"])c.setExtremes(a.min,
72
- a.max,!1),b=!0});b&&h(p(q.animation,m.pointCount<100))};m.pan=function(a){var b=m.xAxis[0],c=m.mouseDownX,d=b.pointRange/2,e=b.getExtremes(),f=b.translate(c-a,!0)+d,c=b.translate(c+ka-a,!0)-d;(d=m.hoverPoints)&&o(d,function(a){a.setState()});f>Ua(e.dataMin,e.min)&&c<W(e.dataMax,e.max)&&b.setExtremes(f,c,!0,!1);m.mouseDownX=a;P(D,{cursor:"move"})};Wb=function(){var a=v.legend,b=p(a.margin,10),c=a.x,d=a.y,e=a.align,f=a.verticalAlign,g;rb();if((m.title||m.subtitle)&&!s(T))(g=W(m.title&&!$.floating&&
73
- !$.verticalAlign&&$.y||0,m.subtitle&&!ja.floating&&!ja.verticalAlign&&ja.y||0))&&(J=W(J,g+p($.margin,15)+ia));a.enabled&&!a.floating&&(e==="right"?s(w)||(ba=W(ba,Wa-c+b+ua)):e==="left"?s(bb)||(O=W(O,Wa+c+b+jb)):f==="top"?s(T)||(J=W(J,yb+d+b+ia)):f==="bottom"&&(s(E)||(M=W(M,yb-d+b+R))));m.extraBottomMargin&&(M+=m.extraBottomMargin);m.extraTopMargin&&(J+=m.extraTopMargin);Nb&&o(xa,function(a){a.getOffset()});s(bb)||(O+=pa[3]);s(T)||(J+=pa[0]);s(E)||(M+=pa[2]);s(w)||(ba+=pa[1]);sb()};tb=function(a,b,
74
- c){var d=m.title,e=m.subtitle;La+=1;Kb(c,m);Za=ra;$a=sa;if(s(a))m.chartWidth=sa=z(a);if(s(b))m.chartHeight=ra=z(b);P(D,{width:sa+ga,height:ra+ga});I.setSize(sa,ra,c);ka=sa-O-ba;la=ra-J-M;gb=null;o(xa,function(a){a.isDirty=!0;a.setScale()});o(Q,function(a){a.isDirty=!0});m.isDirtyLegend=!0;m.isDirtyBox=!0;Wb();d&&d.align(null,null,ib);e&&e.align(null,null,ib);h(c);Za=null;aa(m,"resize");Ub===!1?t():setTimeout(t,Ub&&Ub.duration||500)};sb=function(){m.plotLeft=O=z(O);m.plotTop=J=z(J);m.plotWidth=ka=
75
- z(sa-O-ba);m.plotHeight=la=z(ra-J-M);m.plotSizeX=U?la:ka;m.plotSizeY=U?ka:la;ib={x:jb,y:ia,width:sa-jb-ua,height:ra-ia-R};o(xa,function(a){a.setAxisSize();a.setAxisTranslation()})};rb=function(){J=p(T,ia);ba=p(w,ua);M=p(E,R);O=p(bb,jb);pa=[0,0,0,0]};qb=function(){var a=q.borderWidth||0,b=q.backgroundColor,c=q.plotBackgroundColor,d=q.plotBackgroundImage,e,f={x:O,y:J,width:ka,height:la};e=a+(q.shadow?8:0);if(a||b)ma?ma.animate(ma.crisp(null,null,null,sa-e,ra-e)):ma=I.rect(e/2,e/2,sa-e,ra-e,q.borderRadius,
76
- a).attr({stroke:q.borderColor,"stroke-width":a,fill:b||Ma}).add().shadow(q.shadow);c&&(Na?Na.animate(f):Na=I.rect(O,J,ka,la,0).attr({fill:c}).add().shadow(q.plotShadow));d&&(Sa?Sa.animate(f):Sa=I.image(d,O,J,ka,la).add());q.plotBorderWidth&&(da?da.animate(da.crisp(null,O,J,ka,la)):da=I.rect(O,J,ka,la,0,q.plotBorderWidth).attr({stroke:q.plotBorderColor,"stroke-width":q.plotBorderWidth,zIndex:4}).add());m.isDirtyBox=!1};q.reflow!==!1&&ha(m,"load",n);if(y)for(va in y)ha(m,va,y[va]);m.options=v;m.series=
77
- Q;m.xAxis=[];m.yAxis=[];m.addSeries=function(a,b,c){var d;a&&(Kb(c,m),b=p(b,!0),aa(m,"addSeries",{options:a},function(){d=f(a);d.isDirty=!0;m.isDirtyLegend=!0;b&&m.redraw()}));return d};m.animation=Fa?!1:p(q.animation,!0);m.Axis=c;m.destroy=function(){var a,b=D&&D.parentNode;if(m!==null){aa(m,"destroy");Qa(m);for(a=xa.length;a--;)xa[a]=xa[a].destroy();for(a=Q.length;a--;)Q[a]=Q[a].destroy();o("title,subtitle,seriesGroup,clipRect,credits,tracker,scroller,rangeSelector".split(","),function(a){var b=
78
- m[a];b&&(m[a]=b.destroy())});o([ma,da,Na,Xa,vb,I,ub],function(a){a&&a.destroy&&a.destroy()});ma=da=Na=Xa=vb=I=ub=null;if(D)D.innerHTML="",Qa(D),b&&Tb(D),D=null;clearInterval(Bb);for(a in m)delete m[a];v=m=null}};m.get=function(a){var b,c,d;for(b=0;b<xa.length;b++)if(xa[b].options.id===a)return xa[b];for(b=0;b<Q.length;b++)if(Q[b].options.id===a)return Q[b];for(b=0;b<Q.length;b++){d=Q[b].points||[];for(c=0;c<d.length;c++)if(d[c].id===a)return d[c]}return null};m.getSelectedPoints=function(){var a=
79
- [];o(Q,function(b){a=a.concat(nc(b.points,function(a){return a.selected}))});return a};m.getSelectedSeries=function(){return nc(Q,function(a){return a.selected})};m.hideLoading=function(){xb&&cc(xb,{opacity:0},{duration:v.loading.hideDuration||100,complete:function(){P(xb,{display:Ma})}});Ya=!1};m.initSeries=f;m.isInsidePlot=Db;m.redraw=h;m.setSize=tb;m.setTitle=j;m.showLoading=function(a){var b=v.loading;xb||(xb=Aa(Ra,{className:Ia+"loading"},L(b.style,{left:O+ga,top:J+ga,width:ka+ga,height:la+ga,
80
- zIndex:10,display:Ma}),D),pb=Aa("span",null,b.labelStyle,xb));pb.innerHTML=a||v.lang.loading;Ya||(P(xb,{opacity:0,display:""}),cc(xb,{opacity:b.style.opacity},{duration:b.showDuration||0}),Ya=!0)};m.pointCount=0;m.counters=new tc;V()}var X,x=document,ca=window,oa=Math,z=oa.round,Ta=oa.floor,Yb=oa.ceil,W=oa.max,Ua=oa.min,Ba=oa.abs,ja=oa.cos,C=oa.sin,da=oa.PI,Dc=da*2/360,kb=navigator.userAgent,Qb=/msie/i.test(kb)&&!ca.opera,Xa=x.documentMode===8,Ec=/AppleWebKit/.test(kb),Bc=/Firefox/.test(kb),Pb=!!x.createElementNS&&
81
- !!x.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,Qc=Bc&&parseInt(kb.split("Firefox/")[1],10)<4,Fa=!Pb&&!Qb&&!!x.createElement("canvas").getContext,Xb,Ga=x.documentElement.ontouchstart!==X,Fc={},lc=0,tb,Ea,ac,Ub,La,E,Ra="div",wb="absolute",mc="relative",ab="hidden",Ia="highcharts-",eb="visible",ga="px",Ma="none",wa="M",fa="L",Gc="rgba(192,192,192,"+(Pb?1.0E-6:0.0020)+")",Ka="",ta="hover",Rb="millisecond",ob="second",pb="minute",va="hour",Ca="day",Ya="week",Da="month",Za="year",
82
- sb,fc,gc,ic,db,qb,rb,pc,qc,hc,rc,sc,w=ca.HighchartsAdapter,na=w||{},Hc=na.getScript,o=na.each,nc=na.grep,Ac=na.offset,Vb=na.map,K=na.merge,ha=na.addEvent,Qa=na.removeEvent,aa=na.fireEvent,cc=na.animate,Ob=na.stop,Ha={};ca.Highcharts={};ac=function(a,b,c){if(!s(b)||isNaN(b))return"Invalid date";var a=p(a,"%Y-%m-%d %H:%M:%S"),d=new Date(b),e,f=d[gc](),g=d[ic](),h=d[db](),i=d[qb](),k=d[rb](),j=Ea.lang,l=j.weekdays,b={a:l[g].substr(0,3),A:l[g],d:Na(h),e:h,b:j.shortMonths[i],B:j.months[i],m:Na(i+1),y:k.toString().substr(2,
83
- 2),Y:k,H:Na(f),I:Na(f%12||12),l:f%12||12,M:Na(d[fc]()),p:f<12?"AM":"PM",P:f<12?"am":"pm",S:Na(d.getSeconds()),L:Na(z(b%1E3),3)};for(e in b)a=a.replace("%"+e,b[e]);return c?a.substr(0,1).toUpperCase()+a.substr(1):a};tc.prototype={wrapColor:function(a){if(this.color>=a)this.color=0},wrapSymbol:function(a){if(this.symbol>=a)this.symbol=0}};E=za(Rb,1,ob,1E3,pb,6E4,va,36E5,Ca,864E5,Ya,6048E5,Da,2592E6,Za,31556952E3);La={init:function(a,b,c){var b=b||"",d=a.shift,e=b.indexOf("C")>-1,f=e?7:3,g,b=b.split(" "),
84
- c=[].concat(c),h,i,k=function(a){for(g=a.length;g--;)a[g]===wa&&a.splice(g+1,0,a[g+1],a[g+2],a[g+1],a[g+2])};e&&(k(b),k(c));a.isArea&&(h=b.splice(b.length-6,6),i=c.splice(c.length-6,6));d===1&&(c=[].concat(c).splice(0,f).concat(c));a.shift=0;if(b.length)for(a=c.length;b.length<a;)d=[].concat(b).splice(b.length-f,f),e&&(d[f-6]=d[f-2],d[f-5]=d[f-1]),b=b.concat(d);h&&(b=b.concat(h),c=c.concat(i));return[b,c]},step:function(a,b,c,d){var e=[],f=a.length;if(c===1)e=d;else if(f===b.length&&c<1)for(;f--;)d=
85
- parseFloat(a[f]),e[f]=isNaN(d)?a[f]:c*parseFloat(b[f]-d)+d;else e=b;return e}};w&&w.init&&w.init(La);if(!w&&ca.jQuery){var ba=jQuery,Hc=ba.getScript,o=function(a,b){for(var c=0,d=a.length;c<d;c++)if(b.call(a[c],a[c],c,a)===!1)return c},nc=ba.grep,Vb=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)c[d]=b.call(a[d],a[d],d,a);return c},K=function(){var a=arguments;return ba.extend(!0,null,a[0],a[1],a[2],a[3])},Ac=function(a){return ba(a).offset()},ha=function(a,b,c){ba(a).bind(b,c)},Qa=function(a,
86
- b,c){var d=x.removeEventListener?"removeEventListener":"detachEvent";x[d]&&!a[d]&&(a[d]=function(){});ba(a).unbind(b,c)},aa=function(a,b,c,d){var e=ba.Event(b),f="detached"+b,g;L(e,c);a[b]&&(a[f]=a[b],a[b]=null);o(["preventDefault","stopPropagation"],function(a){var b=e[a];e[a]=function(){try{b.call(e)}catch(c){a==="preventDefault"&&(g=!0)}}});ba(a).trigger(e);a[f]&&(a[b]=a[f],a[f]=null);d&&!e.isDefaultPrevented()&&!g&&d(e)},cc=function(a,b,c){var d=ba(a);if(b.d)a.toD=b.d,b.d=1;d.stop();d.animate(b,
87
- c)},Ob=function(a){ba(a).stop()};ba.extend(ba.easing,{easeOutQuad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c}});var Ic=jQuery.fx,Jc=Ic.step;o(["cur","_default","width","height"],function(a,b){var c=b?Jc:Ic.prototype,d=c[a],e;d&&(c[a]=function(a){a=b?a:this;e=a.elem;return e.attr?e.attr(a.prop,a.now):d.apply(this,arguments)})});Jc.d=function(a){var b=a.elem;if(!a.started){var c=La.init(b,b.d,b.toD);a.start=c[0];a.end=c[1];a.started=!0}b.attr("d",La.step(a.start,a.end,a.pos,b.toD))}}w={enabled:!0,
88
- align:"center",x:0,y:15,style:{color:"#666",fontSize:"11px",lineHeight:"14px"}};Ea={colors:"#4572A7,#AA4643,#89A54E,#80699B,#3D96AE,#DB843D,#92A8CD,#A47D7C,#B5CA92".split(","),symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),shortMonths:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
89
- decimalPoint:".",resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:","},global:{useUTC:!0,canvasToolsURL:"http://code.highcharts.com/2.2.1/modules/canvas-tools.js"},chart:{borderColor:"#4572A7",borderRadius:5,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacingTop:10,spacingRight:10,spacingBottom:15,spacingLeft:10,style:{fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif',fontSize:"12px"},backgroundColor:"#FFFFFF",plotBorderColor:"#C0C0C0",
90
- resetZoomButton:{theme:{zIndex:20},position:{align:"right",x:-10,y:10}}},title:{text:"Chart title",align:"center",y:15,style:{color:"#3E576F",fontSize:"16px"}},subtitle:{text:"",align:"center",y:30,style:{color:"#6D869F"}},plotOptions:{line:{allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},lineWidth:2,shadow:!0,marker:{enabled:!0,lineWidth:0,radius:4,lineColor:"#FFFFFF",states:{hover:{},select:{fillColor:"#FFFFFF",lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:K(w,
91
- {enabled:!1,y:-6,formatter:function(){return this.y}}),cropThreshold:300,pointRange:0,showInLegend:!0,states:{hover:{marker:{}},select:{marker:{}}},stickyTracking:!0}},labels:{style:{position:wb,color:"#3E576F"}},legend:{enabled:!0,align:"center",layout:"horizontal",labelFormatter:function(){return this.name},borderWidth:1,borderColor:"#909090",borderRadius:5,shadow:!1,style:{padding:"5px"},itemStyle:{cursor:"pointer",color:"#3E576F"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#C0C0C0"},
92
- itemCheckboxStyle:{position:wb,width:"13px",height:"13px"},symbolWidth:16,symbolPadding:5,verticalAlign:"bottom",x:0,y:0},loading:{labelStyle:{fontWeight:"bold",position:mc,top:"1em"},style:{position:wb,backgroundColor:"white",opacity:0.5,textAlign:"center"}},tooltip:{enabled:!0,backgroundColor:"rgba(255, 255, 255, .85)",borderWidth:2,borderRadius:5,headerFormat:'<span style="font-size: 10px">{point.key}</span><br/>',pointFormat:'<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>',
93
- shadow:!0,shared:Fa,snap:Ga?25:10,style:{color:"#333333",fontSize:"12px",padding:"5px",whiteSpace:"nowrap"}},credits:{enabled:!0,text:"Highcharts.com",href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#909090",fontSize:"10px"}}};var $b={dateTimeLabelFormats:za(Rb,"%H:%M:%S.%L",ob,"%H:%M:%S",pb,"%H:%M",va,"%H:%M",Ca,"%e. %b",Ya,"%e. %b",Da,"%b '%y",Za,"%Y"),endOnTick:!1,gridLineColor:"#C0C0C0",labels:w,lineColor:"#C0D0E0",lineWidth:1,
94
- max:null,min:null,minPadding:0.01,maxPadding:0.01,minorGridLineColor:"#E0E0E0",minorGridLineWidth:1,minorTickColor:"#A0A0A0",minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickColor:"#C0D0E0",tickLength:5,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",tickWidth:1,title:{align:"middle",style:{color:"#6D869F",fontWeight:"bold"}},type:"linear"},kc=K($b,{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{align:"right",x:-8,
95
- y:3},lineWidth:0,maxPadding:0.05,minPadding:0.05,startOnTick:!0,tickWidth:0,title:{rotation:270,text:"Y-values"},stackLabels:{enabled:!1,formatter:function(){return this.total},style:w.style}}),Pc={labels:{align:"right",x:-8,y:null},title:{rotation:270}},Oc={labels:{align:"left",x:8,y:null},title:{rotation:90}},zc={labels:{align:"center",x:0,y:14,overflow:"justify"},title:{rotation:0}},Nc=K(zc,{labels:{y:-5,overflow:"justify"}}),M=Ea.plotOptions,w=M.line;M.spline=K(w);M.scatter=K(w,{lineWidth:0,states:{hover:{lineWidth:0}},
96
- tooltip:{headerFormat:'<span style="font-size: 10px; color:{series.color}">{series.name}</span><br/>',pointFormat:"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>"}});M.area=K(w,{threshold:0});M.areaspline=K(M.area);M.column=K(w,{borderColor:"#FFFFFF",borderWidth:1,borderRadius:0,groupPadding:0.2,marker:null,pointPadding:0.1,minPointLength:0,cropThreshold:50,pointRange:null,states:{hover:{brightness:0.1,shadow:!1},select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}},dataLabels:{y:null,verticalAlign:null},
97
- threshold:0});M.bar=K(M.column,{dataLabels:{align:"left",x:5,y:null,verticalAlign:"middle"}});M.pie=K(w,{borderColor:"#FFFFFF",borderWidth:1,center:["50%","50%"],colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.point.name},y:5},legendType:"point",marker:null,size:"75%",showInLegend:!1,slicedOffset:10,states:{hover:{brightness:0.1,shadow:!1}}});vc();var ma=function(a){var b=[],c;(function(a){(c=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/.exec(a))?
98
- b=[S(c[1]),S(c[2]),S(c[3]),parseFloat(c[4],10)]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(a))&&(b=[S(c[1],16),S(c[2],16),S(c[3],16),1])})(a);return{get:function(c){return b&&!isNaN(b[0])?c==="rgb"?"rgb("+b[0]+","+b[1]+","+b[2]+")":c==="a"?b[3]:"rgba("+b.join(",")+")":a},brighten:function(a){if(Bb(a)&&a!==0){var c;for(c=0;c<3;c++)b[c]+=S(a*255),b[c]<0&&(b[c]=0),b[c]>255&&(b[c]=255)}return this},setOpacity:function(a){b[3]=a;return this}}};Sa.prototype={init:function(a,b){this.element=
99
- b==="span"?Aa(b):x.createElementNS("http://www.w3.org/2000/svg",b);this.renderer=a;this.attrSetters={}},animate:function(a,b,c){b=p(b,Ub,!0);Ob(this);if(b){b=K(b);if(c)b.complete=c;cc(this,a,b)}else this.attr(a),c&&c()},attr:function(a,b){var c,d,e,f,g=this.element,h=g.nodeName,i=this.renderer,k,j=this.attrSetters,l=this.shadows,n,o=this;Ab(a)&&s(b)&&(c=a,a={},a[c]=b);if(Ab(a))c=a,h==="circle"?c={x:"cx",y:"cy"}[c]||c:c==="strokeWidth"&&(c="stroke-width"),o=A(g,c)||this[c]||0,c!=="d"&&c!=="visibility"&&
100
- (o=parseFloat(o));else for(c in a)if(k=!1,d=a[c],e=j[c]&&j[c](d,c),e!==!1){e!==X&&(d=e);if(c==="d")d&&d.join&&(d=d.join(" ")),/(NaN| {2}|^$)/.test(d)&&(d="M 0 0"),this.d=d;else if(c==="x"&&h==="text"){for(e=0;e<g.childNodes.length;e++)f=g.childNodes[e],A(f,"x")===A(g,"x")&&A(f,"x",d);this.rotation&&A(g,"transform","rotate("+this.rotation+" "+d+" "+S(a.y||A(g,"y"))+")")}else if(c==="fill")d=i.color(d,g,c);else if(h==="circle"&&(c==="x"||c==="y"))c={x:"cx",y:"cy"}[c]||c;else if(h==="rect"&&c==="r")A(g,
101
- {rx:d,ry:d}),k=!0;else if(c==="translateX"||c==="translateY"||c==="rotation"||c==="verticalAlign")this[c]=d,this.updateTransform(),k=!0;else if(c==="stroke")d=i.color(d,g,c);else if(c==="dashstyle")if(c="stroke-dasharray",d=d&&d.toLowerCase(),d==="solid")d=Ma;else{if(d){d=d.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");
102
- for(e=d.length;e--;)d[e]=S(d[e])*a["stroke-width"];d=d.join(",")}}else c==="isTracker"?this[c]=d:c==="width"?d=S(d):c==="align"?(c="text-anchor",d={left:"start",center:"middle",right:"end"}[d]):c==="title"&&(e=x.createElementNS("http://www.w3.org/2000/svg","title"),e.appendChild(x.createTextNode(d)),g.appendChild(e));c==="strokeWidth"&&(c="stroke-width");Ec&&c==="stroke-width"&&d===0&&(d=1.0E-6);this.symbolName&&/^(x|y|r|start|end|innerR|anchorX|anchorY)/.test(c)&&(n||(this.symbolAttr(a),n=!0),k=
103
- !0);if(l&&/^(width|height|visibility|x|y|d|transform)$/.test(c))for(e=l.length;e--;)A(l[e],c,d);if((c==="width"||c==="height")&&h==="rect"&&d<0)d=0;c==="text"?(this.textStr=d,this.added&&i.buildText(this)):k||A(g,c,d)}if(Ec&&/Chrome\/(18|19)/.test(kb)&&h==="text"&&(a.x!==X||a.y!==X))c=g.parentNode,d=g.nextSibling,c&&(c.removeChild(g),d?c.insertBefore(g,d):c.appendChild(g));return o},symbolAttr:function(a){var b=this;o("x,y,r,start,end,width,height,innerR,anchorX,anchorY".split(","),function(c){b[c]=
104
- p(a[c],b[c])});b.attr({d:b.renderer.symbols[b.symbolName](b.x,b.y,b.width,b.height,b)})},clip:function(a){return this.attr("clip-path","url("+this.renderer.url+"#"+a.id+")")},crisp:function(a,b,c,d,e){var f,g={},h={},i,a=a||this.strokeWidth||this.attr&&this.attr("stroke-width")||0;i=z(a)%2/2;h.x=Ta(b||this.x||0)+i;h.y=Ta(c||this.y||0)+i;h.width=Ta((d||this.width||0)-2*i);h.height=Ta((e||this.height||0)-2*i);h.strokeWidth=a;for(f in h)this[f]!==h[f]&&(this[f]=g[f]=h[f]);return g},css:function(a){var b=
105
- this.element,b=a&&a.width&&b.nodeName==="text",c,d="",e=function(a,b){return"-"+b.toLowerCase()};if(a&&a.color)a.fill=a.color;this.styles=a=L(this.styles,a);if(Qb&&!Pb)b&&delete a.width,P(this.element,a);else{for(c in a)d+=c.replace(/([A-Z])/g,e)+":"+a[c]+";";this.attr({style:d})}b&&this.added&&this.renderer.buildText(this);return this},on:function(a,b){var c=b;Ga&&a==="click"&&(a="touchstart",c=function(a){a.preventDefault();b()});this.element["on"+a]=c;return this},translate:function(a,b){return this.attr({translateX:a,
106
- translateY:b})},invert:function(){this.inverted=!0;this.updateTransform();return this},htmlCss:function(a){var b=this.element;if(b=a&&b.tagName==="SPAN"&&a.width)delete a.width,this.textWidth=b,this.updateTransform();this.styles=L(this.styles,a);P(this.element,a);return this},htmlGetBBox:function(a){var b=this.element,c=this.bBox;if(!c||a){if(b.nodeName==="text")b.style.position=wb;c=this.bBox={x:b.offsetLeft,y:b.offsetTop,width:b.offsetWidth,height:b.offsetHeight}}return c},htmlUpdateTransform:function(){if(this.added){var a=
107
- this.renderer,b=this.element,c=this.translateX||0,d=this.translateY||0,e=this.x||0,f=this.y||0,g=this.textAlign||"left",h={left:0,center:0.5,right:1}[g],i=g&&g!=="left",k=this.shadows;if(c||d)P(b,{marginLeft:c,marginTop:d}),k&&o(k,function(a){P(a,{marginLeft:c+1,marginTop:d+1})});this.inverted&&o(b.childNodes,function(c){a.invertChild(c,b)});if(b.tagName==="SPAN"){var j,l,k=this.rotation,n;j=0;var t=1,r=0,Z;n=S(this.textWidth);var V=this.xCorr||0,v=this.yCorr||0,y=[k,g,b.innerHTML,this.textWidth].join(",");
108
- if(y!==this.cTT)s(k)&&(j=k*Dc,t=ja(j),r=C(j),P(b,{filter:k?["progid:DXImageTransform.Microsoft.Matrix(M11=",t,", M12=",-r,", M21=",r,", M22=",t,", sizingMethod='auto expand')"].join(""):Ma})),j=p(this.elemWidth,b.offsetWidth),l=p(this.elemHeight,b.offsetHeight),j>n&&(P(b,{width:n+ga,display:"block",whiteSpace:"normal"}),j=n),n=a.fontMetrics(b.style.fontSize).b,V=t<0&&-j,v=r<0&&-l,Z=t*r<0,V+=r*n*(Z?1-h:h),v-=t*n*(k?Z?h:1-h:1),i&&(V-=j*h*(t<0?-1:1),k&&(v-=l*h*(r<0?-1:1)),P(b,{textAlign:g})),this.xCorr=
109
- V,this.yCorr=v;P(b,{left:e+V+ga,top:f+v+ga});this.cTT=y}}else this.alignOnAdd=!0},updateTransform:function(){var a=this.translateX||0,b=this.translateY||0,c=this.inverted,d=this.rotation,e=[];c&&(a+=this.attr("width"),b+=this.attr("height"));(a||b)&&e.push("translate("+a+","+b+")");c?e.push("rotate(90) scale(-1,1)"):d&&e.push("rotate("+d+" "+this.x+" "+this.y+")");e.length&&A(this.element,"transform",e.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,
110
- b,c){a?(this.alignOptions=a,this.alignByTranslate=b,c||this.renderer.alignedObjects.push(this)):(a=this.alignOptions,b=this.alignByTranslate);var c=p(c,this.renderer),d=a.align,e=a.verticalAlign,f=(c.x||0)+(a.x||0),g=(c.y||0)+(a.y||0),h={};/^(right|center)$/.test(d)&&(f+=(c.width-(a.width||0))/{right:1,center:2}[d]);h[b?"translateX":"x"]=z(f);/^(bottom|middle)$/.test(e)&&(g+=(c.height-(a.height||0))/({bottom:1,middle:2}[e]||1));h[b?"translateY":"y"]=z(g);this[this.placed?"animate":"attr"](h);this.placed=
111
- !0;this.alignAttr=h;return this},getBBox:function(a){var b,c,d=this.rotation;c=this.element;var e=d*Dc;if(c.namespaceURI==="http://www.w3.org/2000/svg"){try{b=c.getBBox?L({},c.getBBox()):{width:c.offsetWidth,height:c.offsetHeight}}catch(f){}if(!b||b.width<0)b={width:0,height:0};a=b.width;c=b.height;if(d)b.width=Ba(c*C(e))+Ba(a*ja(e)),b.height=Ba(c*ja(e))+Ba(a*C(e))}else b=this.htmlGetBBox(a);return b},show:function(){return this.attr({visibility:eb})},hide:function(){return this.attr({visibility:ab})},
112
- add:function(a){var b=this.renderer,c=a||b,d=c.element||b.box,e=d.childNodes,f=this.element,g=A(f,"zIndex"),h;this.parentInverted=a&&a.inverted;this.textStr!==void 0&&b.buildText(this);if(g)c.handleZ=!0,g=S(g);if(c.handleZ)for(c=0;c<e.length;c++)if(a=e[c],b=A(a,"zIndex"),a!==f&&(S(b)>g||!s(g)&&s(b))){d.insertBefore(f,a);h=!0;break}h||d.appendChild(f);this.added=!0;aa(this,"add");return this},safeRemoveChild:function(a){var b=a.parentNode;b&&b.removeChild(a)},destroy:function(){var a=this,b=a.element||
113
- {},c=a.shadows,d=a.box,e,f;b.onclick=b.onmouseout=b.onmouseover=b.onmousemove=null;Ob(a);if(a.clipPath)a.clipPath=a.clipPath.destroy();if(a.stops){for(f=0;f<a.stops.length;f++)a.stops[f]=a.stops[f].destroy();a.stops=null}a.safeRemoveChild(b);c&&o(c,function(b){a.safeRemoveChild(b)});d&&d.destroy();Gb(a.renderer.alignedObjects,a);for(e in a)delete a[e];return null},empty:function(){for(var a=this.element,b=a.childNodes,c=b.length;c--;)a.removeChild(b[c])},shadow:function(a,b){var c=[],d,e,f=this.element,
114
- g=this.parentInverted?"(-1,-1)":"(1,1)";if(a){for(d=1;d<=3;d++)e=f.cloneNode(0),A(e,{isShadow:"true",stroke:"rgb(0, 0, 0)","stroke-opacity":0.05*d,"stroke-width":7-2*d,transform:"translate"+g,fill:Ma}),b?b.element.appendChild(e):f.parentNode.insertBefore(e,f),c.push(e);this.shadows=c}return this}};var Eb=function(){this.init.apply(this,arguments)};Eb.prototype={Element:Sa,init:function(a,b,c,d){var e=location,f;f=this.createElement("svg").attr({xmlns:"http://www.w3.org/2000/svg",version:"1.1"});a.appendChild(f.element);
115
- this.isSVG=!0;this.box=f.element;this.boxWrapper=f;this.alignedObjects=[];this.url=Qb?"":e.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1");this.defs=this.createElement("defs").add();this.forExport=d;this.gradients={};this.setSize(b,c,!1)},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();Jb(this.gradients||{});this.gradients=null;if(a)this.defs=a.destroy();return this.alignedObjects=null},createElement:function(a){var b=new this.Element;b.init(this,a);
116
- return b},draw:function(){},buildText:function(a){for(var b=a.element,c=p(a.textStr,"").toString().replace(/<(b|strong)>/g,'<span style="font-weight:bold">').replace(/<(i|em)>/g,'<span style="font-style:italic">').replace(/<a/g,"<span").replace(/<\/(b|strong|i|em|a)>/g,"</span>").split(/<br.*?>/g),d=b.childNodes,e=/style="([^"]+)"/,f=/href="([^"]+)"/,g=A(b,"x"),h=a.styles,i=h&&S(h.width),k=h&&h.lineHeight,j,h=d.length;h--;)b.removeChild(d[h]);i&&!a.added&&this.box.appendChild(b);c[c.length-1]===""&&
117
- c.pop();o(c,function(c,d){var h,r=0,p,c=c.replace(/<span/g,"|||<span").replace(/<\/span>/g,"</span>|||");h=c.split("|||");o(h,function(c){if(c!==""||h.length===1){var l={},o=x.createElementNS("http://www.w3.org/2000/svg","tspan");e.test(c)&&A(o,"style",c.match(e)[1].replace(/(;| |^)color([ :])/,"$1fill$2"));f.test(c)&&(A(o,"onclick",'location.href="'+c.match(f)[1]+'"'),P(o,{cursor:"pointer"}));c=(c.replace(/<(.|\n)*?>/g,"")||" ").replace(/&lt;/g,"<").replace(/&gt;/g,">");o.appendChild(x.createTextNode(c));
118
- r?l.dx=3:l.x=g;if(!r){if(d){!Pb&&a.renderer.forExport&&P(o,{display:"block"});p=ca.getComputedStyle&&S(ca.getComputedStyle(j,null).getPropertyValue("line-height"));if(!p||isNaN(p))p=k||j.offsetHeight||18;A(o,"dy",p)}j=o}A(o,l);b.appendChild(o);r++;if(i)for(var c=c.replace(/-/g,"- ").split(" "),q,T=[];c.length||T.length;)q=a.getBBox().width,l=q>i,!l||c.length===1?(c=T,T=[],c.length&&(o=x.createElementNS("http://www.w3.org/2000/svg","tspan"),A(o,{dy:k||16,x:g}),b.appendChild(o),q>i&&(i=q))):(o.removeChild(o.firstChild),
119
- T.unshift(c.pop())),c.length&&o.appendChild(x.createTextNode(c.join(" ").replace(/- /g,"-")))}})})},button:function(a,b,c,d,e,f,g){var h=this.label(a,b,c),i=0,k,j,l,n,o,a={x1:0,y1:0,x2:0,y2:1},e=K(za("stroke-width",1,"stroke","#999","fill",za("linearGradient",a,"stops",[[0,"#FFF"],[1,"#DDD"]]),"r",3,"padding",3,"style",za("color","black")),e);l=e.style;delete e.style;f=K(e,za("stroke","#68A","fill",za("linearGradient",a,"stops",[[0,"#FFF"],[1,"#ACF"]])),f);n=f.style;delete f.style;g=K(e,za("stroke",
120
- "#68A","fill",za("linearGradient",a,"stops",[[0,"#9BD"],[1,"#CDF"]])),g);o=g.style;delete g.style;ha(h.element,"mouseenter",function(){h.attr(f).css(n)});ha(h.element,"mouseleave",function(){k=[e,f,g][i];j=[l,n,o][i];h.attr(k).css(j)});h.setState=function(a){(i=a)?a===2&&h.attr(g).css(o):h.attr(e).css(l)};return h.on("click",function(){d.call(h)}).attr(e).css(L({cursor:"default"},l))},crispLine:function(a,b){a[1]===a[4]&&(a[1]=a[4]=z(a[1])+b%2/2);a[2]===a[5]&&(a[2]=a[5]=z(a[2])+b%2/2);return a},path:function(a){return this.createElement("path").attr({d:a,
121
- fill:Ma})},circle:function(a,b,c){a=mb(a)?a:{x:a,y:b,r:c};return this.createElement("circle").attr(a)},arc:function(a,b,c,d,e,f){if(mb(a))b=a.y,c=a.r,d=a.innerR,e=a.start,f=a.end,a=a.x;return this.symbol("arc",a||0,b||0,c||0,c||0,{innerR:d||0,start:e||0,end:f||0})},rect:function(a,b,c,d,e,f){if(mb(a))b=a.y,c=a.width,d=a.height,e=a.r,f=a.strokeWidth,a=a.x;e=this.createElement("rect").attr({rx:e,ry:e,fill:Ma});return e.attr(e.crisp(f,a,b,W(c,0),W(d,0)))},setSize:function(a,b,c){var d=this.alignedObjects,
122
- e=d.length;this.width=a;this.height=b;for(this.boxWrapper[p(c,!0)?"animate":"attr"]({width:a,height:b});e--;)d[e].align()},g:function(a){var b=this.createElement("g");return s(a)?b.attr({"class":Ia+a}):b},image:function(a,b,c,d,e){var f={preserveAspectRatio:Ma};arguments.length>1&&L(f,{x:b,y:c,width:d,height:e});f=this.createElement("image").attr(f);f.element.setAttributeNS?f.element.setAttributeNS("http://www.w3.org/1999/xlink","href",a):f.element.setAttribute("hc-svg-href",a);return f},symbol:function(a,
123
- b,c,d,e,f){var g,h=this.symbols[a],h=h&&h(z(b),z(c),d,e,f),i=/^url\((.*?)\)$/,k;if(h)g=this.path(h),L(g,{symbolName:a,x:b,y:c,width:d,height:e}),f&&L(g,f);else if(i.test(a)){var j=function(a,b){a.attr({width:b[0],height:b[1]}).translate(-z(b[0]/2),-z(b[1]/2))};k=a.match(i)[1];a=Fc[k];g=this.image(k).attr({x:b,y:c});a?j(g,a):(g.attr({width:0,height:0}),Aa("img",{onload:function(){j(g,Fc[k]=[this.width,this.height])},src:k}))}return g},symbols:{circle:function(a,b,c,d){var e=0.166*c;return[wa,a+c/2,
124
- b,"C",a+c+e,b,a+c+e,b+d,a+c/2,b+d,"C",a-e,b+d,a-e,b,a+c/2,b,"Z"]},square:function(a,b,c,d){return[wa,a,b,fa,a+c,b,a+c,b+d,a,b+d,"Z"]},triangle:function(a,b,c,d){return[wa,a+c/2,b,fa,a+c,b+d,a,b+d,"Z"]},"triangle-down":function(a,b,c,d){return[wa,a,b,fa,a+c,b,a+c/2,b+d,"Z"]},diamond:function(a,b,c,d){return[wa,a+c/2,b,fa,a+c,b+d/2,a+c/2,b+d,a,b+d/2,"Z"]},arc:function(a,b,c,d,e){var f=e.start,c=e.r||c||d,g=e.end-1.0E-6,d=e.innerR,h=ja(f),i=C(f),k=ja(g),g=C(g),e=e.end-f<da?0:1;return[wa,a+c*h,b+c*i,
125
- "A",c,c,0,e,1,a+c*k,b+c*g,fa,a+d*k,b+d*g,"A",d,d,0,e,0,a+d*h,b+d*i,"Z"]}},clipRect:function(a,b,c,d){var e=Ia+lc++,f=this.createElement("clipPath").attr({id:e}).add(this.defs),a=this.rect(a,b,c,d,0).add(f);a.id=e;a.clipPath=f;return a},color:function(a,b,c){var d,e=/^rgba/;if(a&&a.linearGradient){var f=this,g=a.linearGradient,b=!Fb(g),c=f.gradients,h,i=g.x1||g[0]||0,k=g.y1||g[1]||0,j=g.x2||g[2]||0,l=g.y2||g[3]||0,n,t,r=[b,i,k,j,l,a.stops.join(",")].join(",");c[r]?g=A(c[r].element,"id"):(g=Ia+lc++,
126
- h=f.createElement("linearGradient").attr(L({id:g,x1:i,y1:k,x2:j,y2:l},b?null:{gradientUnits:"userSpaceOnUse"})).add(f.defs),h.stops=[],o(a.stops,function(a){e.test(a[1])?(d=ma(a[1]),n=d.get("rgb"),t=d.get("a")):(n=a[1],t=1);a=f.createElement("stop").attr({offset:a[0],"stop-color":n,"stop-opacity":t}).add(h);h.stops.push(a)}),c[r]=h);return"url("+this.url+"#"+g+")"}else return e.test(a)?(d=ma(a),A(b,c+"-opacity",d.get("a")),d.get("rgb")):(b.removeAttribute(c+"-opacity"),a)},text:function(a,b,c,d){var e=
127
- Ea.chart.style;if(d&&!this.forExport)return this.html(a,b,c);b=z(p(b,0));c=z(p(c,0));a=this.createElement("text").attr({x:b,y:c,text:a}).css({fontFamily:e.fontFamily,fontSize:e.fontSize});a.x=b;a.y=c;return a},html:function(a,b,c){var d=Ea.chart.style,e=this.createElement("span"),f=e.attrSetters,g=e.element,h=e.renderer;f.text=function(a){g.innerHTML=a;return!1};f.x=f.y=f.align=function(a,b){b==="align"&&(b="textAlign");e[b]=a;e.htmlUpdateTransform();return!1};e.attr({text:a,x:z(b),y:z(c)}).css({position:wb,
128
- whiteSpace:"nowrap",fontFamily:d.fontFamily,fontSize:d.fontSize});e.css=e.htmlCss;if(h.isSVG)e.add=function(a){var b,c,d=h.box.parentNode;if(a){if(b=a.div,!b)b=a.div=Aa(Ra,{className:A(a.element,"class")},{position:wb,left:a.attr("translateX")+ga,top:a.attr("translateY")+ga},d),c=b.style,L(a.attrSetters,{translateX:function(a){c.left=a+ga},translateY:function(a){c.top=a+ga},visibility:function(a,b){c[b]=a}})}else b=d;b.appendChild(g);e.added=!0;e.alignOnAdd&&e.htmlUpdateTransform();return e};return e},
129
- fontMetrics:function(a){var a=S(a||11),a=a<24?a+4:z(a*1.2),b=z(a*0.8);return{h:a,b:b}},label:function(a,b,c,d,e,f,g,h){function i(){var a=n.styles,a=a&&a.textAlign,b=v,c;c=h?0:ia;if(s(y)&&(a==="center"||a==="right"))b+={center:0.5,right:1}[a]*(y-p.width);(b!==t.x||c!==t.y)&&t.attr({x:b,y:c});t.x=b;t.y=c}function k(a,b){r?r.attr(a,b):x[a]=b}function j(){n.attr({text:a,x:b,y:c,anchorX:e,anchorY:f})}var l=this,n=l.g(),t=l.text("",0,0,g).attr({zIndex:1}).add(n),r,p,V="left",v=3,y,q,T,A,w=0,x={},ia,g=
130
- n.attrSetters;ha(n,"add",j);g.width=function(a){y=a;return!1};g.height=function(a){q=a;return!1};g.padding=function(a){s(a)&&a!==v&&(v=a,i());return!1};g.align=function(a){V=a;return!1};g.text=function(a,b){t.attr(b,a);var c;c=t.element.style;p=(y===void 0||q===void 0||n.styles.textAlign)&&t.getBBox(!0);n.width=(y||p.width)+2*v;n.height=(q||p.height)+2*v;ia=v+l.fontMetrics(c&&c.fontSize).b;if(!r)c=h?-ia:0,n.box=r=d?l.symbol(d,0,c,n.width,n.height):l.rect(0,c,n.width,n.height,0,x["stroke-width"]),
131
- r.add(n);r.attr(K({width:n.width,height:n.height},x));x=null;i();return!1};g["stroke-width"]=function(a,b){w=a%2/2;k(b,a);return!1};g.stroke=g.fill=g.r=function(a,b){k(b,a);return!1};g.anchorX=function(a,b){e=a;k(b,a+w-T);return!1};g.anchorY=function(a,b){f=a;k(b,a-A);return!1};g.x=function(a){a-={left:0,center:0.5,right:1}[V]*((y||p.width)+v);T=n.x=z(a);n.attr("translateX",T);return!1};g.y=function(a){A=n.y=z(a);n.attr("translateY",a);return!1};var ua=n.css;return L(n,{css:function(a){if(a){var b=
132
- {},a=K({},a);o("fontSize,fontWeight,fontFamily,color,lineHeight,width".split(","),function(c){a[c]!==X&&(b[c]=a[c],delete a[c])});t.css(b)}return ua.call(n,a)},getBBox:function(){return r.getBBox()},shadow:function(a){r.shadow(a);return n},destroy:function(){Qa(n,"add",j);Qa(n.element,"mouseenter");Qa(n.element,"mouseleave");t&&(t=t.destroy());Sa.prototype.destroy.call(n)}})}};Xb=Eb;var $a;if(!Pb&&!Fa)$a={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'],d=["position: ",wb,";"];(b==="shape"||
133
- b===Ra)&&d.push("left:0;top:0;width:10px;height:10px;");Xa&&d.push("visibility: ",b===Ra?ab:eb);c.push(' style="',d.join(""),'"/>');if(b)c=b===Ra||b==="span"||b==="img"?c.join(""):a.prepVML(c),this.element=Aa(c);this.renderer=a;this.attrSetters={}},add:function(a){var b=this.renderer,c=this.element,d=b.box,d=a?a.element||a:d;a&&a.inverted&&b.invertChild(c,d);Xa&&d.gVis===ab&&P(c,{visibility:ab});d.appendChild(c);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();aa(this,
134
- "add");return this},toggleChildren:function(a,b){for(var c=a.childNodes,d=c.length;d--;)P(c[d],{visibility:b}),c[d].nodeName==="DIV"&&this.toggleChildren(c[d],b)},updateTransform:Sa.prototype.htmlUpdateTransform,attr:function(a,b){var c,d,e,f=this.element||{},g=f.style,h=f.nodeName,i=this.renderer,k=this.symbolName,j,l=this.shadows,n,o=this.attrSetters,r=this;Ab(a)&&s(b)&&(c=a,a={},a[c]=b);if(Ab(a))c=a,r=c==="strokeWidth"||c==="stroke-width"?this.strokeweight:this[c];else for(c in a)if(d=a[c],n=!1,
135
- e=o[c]&&o[c](d,c),e!==!1&&d!==null){e!==X&&(d=e);if(k&&/^(x|y|r|start|end|width|height|innerR|anchorX|anchorY)/.test(c))j||(this.symbolAttr(a),j=!0),n=!0;else if(c==="d"){d=d||[];this.d=d.join(" ");e=d.length;for(n=[];e--;)n[e]=Bb(d[e])?z(d[e]*10)-5:d[e]==="Z"?"x":d[e];d=n.join(" ")||"x";f.path=d;if(l)for(e=l.length;e--;)l[e].path=d;n=!0}else if(c==="zIndex"||c==="visibility"){if(Xa&&c==="visibility"&&h==="DIV")f.gVis=d,this.toggleChildren(f,d),d===eb&&(d=null);d&&(g[c]=d);n=!0}else if(c==="width"||
136
- c==="height")d=W(0,d),this[c]=d,this.updateClipping?(this[c]=d,this.updateClipping()):g[c]=d,n=!0;else if(c==="x"||c==="y")this[c]=d,g[{x:"left",y:"top"}[c]]=d;else if(c==="class")f.className=d;else if(c==="stroke")d=i.color(d,f,c),c="strokecolor";else if(c==="stroke-width"||c==="strokeWidth")f.stroked=d?!0:!1,c="strokeweight",this[c]=d,Bb(d)&&(d+=ga);else if(c==="dashstyle")(f.getElementsByTagName("stroke")[0]||Aa(i.prepVML(["<stroke/>"]),null,null,f))[c]=d||"solid",this.dashstyle=d,n=!0;else if(c===
137
- "fill")h==="SPAN"?g.color=d:(f.filled=d!==Ma?!0:!1,d=i.color(d,f,c),c="fillcolor");else if(c==="translateX"||c==="translateY"||c==="rotation")this[c]=d,this.updateTransform(),n=!0;else if(c==="text")this.bBox=null,f.innerHTML=d,n=!0;if(l&&c==="visibility")for(e=l.length;e--;)l[e].style[c]=d;n||(Xa?f[c]=d:A(f,c,d))}return r},clip:function(a){var b=this,c=a.members;c.push(b);b.destroyClip=function(){Gb(c,b)};return b.css(a.getCSS(b.inverted))},css:Sa.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&
138
- Tb(a)},destroy:function(){this.destroyClip&&this.destroyClip();return Sa.prototype.destroy.apply(this)},empty:function(){for(var a=this.element.childNodes,b=a.length,c;b--;)c=a[b],c.parentNode.removeChild(c)},on:function(a,b){this.element["on"+a]=function(){var a=ca.event;a.target=a.srcElement;b(a)};return this},shadow:function(a,b){var c=[],d,e=this.element,f=this.renderer,g,h=e.style,i,k=e.path;k&&typeof k.value!=="string"&&(k="x");if(a){for(d=1;d<=3;d++)i=['<shape isShadow="true" strokeweight="',
139
- 7-2*d,'" filled="false" path="',k,'" coordsize="100,100" style="',e.style.cssText,'" />'],g=Aa(f.prepVML(i),null,{left:S(h.left)+1,top:S(h.top)+1}),i=['<stroke color="black" opacity="',0.05*d,'"/>'],Aa(f.prepVML(i),null,null,g),b?b.element.appendChild(g):e.parentNode.insertBefore(g,e),c.push(g);this.shadows=c}return this}},$a=pa(Sa,$a),w={Element:$a,isIE8:kb.indexOf("MSIE 8.0")>-1,init:function(a,b,c){var d,e;this.alignedObjects=[];d=this.createElement(Ra);e=d.element;e.style.position=mc;a.appendChild(d.element);
140
- this.box=e;this.boxWrapper=d;this.setSize(b,c,!1);if(!x.namespaces.hcv)x.namespaces.add("hcv","urn:schemas-microsoft-com:vml"),x.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "},clipRect:function(a,b,c,d){var e=this.createElement();return L(e,{members:[],left:a,top:b,width:c,height:d,getCSS:function(a){var b=this.top,c=this.left,d=c+this.width,e=b+this.height,b={clip:"rect("+z(a?c:b)+"px,"+z(a?e:d)+"px,"+z(a?d:e)+
141
- "px,"+z(a?b:c)+"px)"};!a&&Xa&&L(b,{width:d+ga,height:e+ga});return b},updateClipping:function(){o(e.members,function(a){a.css(e.getCSS(a.inverted))})}})},color:function(a,b,c){var d,e=/^rgba/;if(a&&a.linearGradient){var f,g,h=a.linearGradient,i=h.x1||h[0]||0,k=h.y1||h[1]||0,j=h.x2||h[2]||0,h=h.y2||h[3]||0,l,n,p,r;o(a.stops,function(a,b){e.test(a[1])?(d=ma(a[1]),f=d.get("rgb"),g=d.get("a")):(f=a[1],g=1);b?(p=f,r=g):(l=f,n=g)});if(c==="fill")a=90-oa.atan((h-k)/(j-i))*180/da,a=['<fill colors="0% ',l,
142
- ",100% ",p,'" angle="',a,'" opacity="',r,'" o:opacity2="',n,'" type="gradient" focus="100%" method="sigma" />'],Aa(this.prepVML(a),null,null,b);else return f}else if(e.test(a)&&b.tagName!=="IMG")return d=ma(a),a=["<",c,' opacity="',d.get("a"),'"/>'],Aa(this.prepVML(a),null,null,b),d.get("rgb");else{b=b.getElementsByTagName(c);if(b.length)b[0].opacity=1;return a}},prepVML:function(a){var b=this.isIE8,a=a.join("");b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=a.indexOf('style="')===
143
- -1?a.replace("/>",' style="display:inline-block;behavior:url(#default#VML);" />'):a.replace('style="','style="display:inline-block;behavior:url(#default#VML);')):a=a.replace("<","<hcv:");return a},text:Eb.prototype.html,path:function(a){return this.createElement("shape").attr({coordsize:"100 100",d:a})},circle:function(a,b,c){return this.symbol("circle").attr({x:a-c,y:b-c,width:2*c,height:2*c})},g:function(a){var b;a&&(b={className:Ia+a,"class":Ia+a});return this.createElement(Ra).attr(b)},image:function(a,
144
- b,c,d,e){var f=this.createElement("img").attr({src:a});arguments.length>1&&f.css({left:b,top:c,width:d,height:e});return f},rect:function(a,b,c,d,e,f){if(mb(a))b=a.y,c=a.width,d=a.height,f=a.strokeWidth,a=a.x;var g=this.symbol("rect");g.r=e;return g.attr(g.crisp(f,a,b,W(c,0),W(d,0)))},invertChild:function(a,b){var c=b.style;P(a,{flip:"x",left:S(c.width)-10,top:S(c.height)-10,rotation:-90})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,c=e.r||c||d,d=ja(f),h=C(f),i=ja(g),k=C(g),e=e.innerR,
145
- j=0.08/c,l=e&&0.25/e||0;if(g-f===0)return["x"];else 2*da-g+f<j?i=-j:g-f<l&&(i=ja(f+l));return["wa",a-c,b-c,a+c,b+c,a+c*d,b+c*h,a+c*i,b+c*k,"at",a-e,b-e,a+e,b+e,a+e*i,b+e*k,a+e*d,b+e*h,"x","e"]},circle:function(a,b,c,d){return["wa",a,b,a+c,b+d,a+c,b+d/2,a+c,b+d/2,"e"]},rect:function(a,b,c,d,e){if(!s(e))return[];var f=a+c,g=b+d,c=Ua(e.r||0,c,d);return[wa,a+c,b,fa,f-c,b,"wa",f-2*c,b,f,b+2*c,f-c,b,f,b+c,fa,f,g-c,"wa",f-2*c,g-2*c,f,g,f,g-c,f-c,g,fa,a+c,g,"wa",a,g-2*c,a+2*c,g,a+c,g,a,g-c,fa,a,b+c,"wa",
146
- a,b,a+2*c,b+2*c,a,b+c,a+c,b,"x","e"]}}},$a=function(){this.init.apply(this,arguments)},$a.prototype=K(Eb.prototype,w),Xb=$a;var oc,Cc;Fa&&(oc=function(){},Cc=function(){function a(){var a=b.length,d;for(d=0;d<a;d++)b[d]();b=[]}var b=[];return{push:function(c,d){b.length===0&&Hc(d,a);b.push(c)}}}());Xb=$a||oc||Eb;wc.prototype.callbacks=[];var lb=function(){};lb.prototype={init:function(a,b,c){var d=a.chart.counters;this.series=a;this.applyOptions(b,c);this.pointAttr={};if(a.options.colorByPoint){b=
147
- a.chart.options.colors;if(!this.options)this.options={};this.color=this.options.color=this.color||b[d.color++];d.wrapColor(b.length)}a.chart.pointCount++;return this},applyOptions:function(a,b){var c=this.series,d=typeof a;this.config=a;if(d==="number"||a===null)this.y=a;else if(typeof a[0]==="number")this.x=a[0],this.y=a[1];else if(d==="object"&&typeof a.length!=="number"){if(L(this,a),this.options=a,a.dataLabels)c._hasPointLabels=!0}else if(typeof a[0]==="string")this.name=a[0],this.y=a[1];if(this.x===
148
- X)this.x=b===X?c.autoIncrement():b},destroy:function(){var a=this.series,b=a.chart.hoverPoints,c;a.chart.pointCount--;b&&(this.setState(),Gb(b,this));if(this===a.chart.hoverPoint)this.onMouseOut();a.chart.hoverPoints=null;if(this.graphic||this.dataLabel)Qa(this),this.destroyElements();this.legendItem&&this.series.chart.legend.destroyItem(this);for(c in this)this[c]=null},destroyElements:function(){for(var a="graphic,tracker,dataLabel,group,connector,shadowGroup".split(","),b,c=6;c--;)b=a[c],this[b]&&
149
- (this[b]=this[b].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},select:function(a,b){var c=this,d=c.series.chart,a=p(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=a;c.setState(a&&"select");b||o(d.getSelectedPoints(),function(a){if(a.selected&&a!==c)a.selected=!1,a.setState(Ka),a.firePointEvent("unselect")})})},
150
- onMouseOver:function(){var a=this.series,b=a.chart,c=b.tooltip,d=b.hoverPoint;if(d&&d!==this)d.onMouseOut();this.firePointEvent("mouseOver");c&&(!c.shared||a.noSharedTooltip)&&c.refresh(this);this.setState(ta);b.hoverPoint=this},onMouseOut:function(){this.firePointEvent("mouseOut");this.setState();this.series.chart.hoverPoint=null},tooltipFormatter:function(a){var b=this.series,c=b.tooltipOptions,d=String(this.y).split("."),d=d[1]?d[1].length:0,e=a.match(/\{(series|point)\.[a-zA-Z]+\}/g),f=/[{\.}]/,
151
- g,h,i,k;for(k in e)h=e[k],Ab(h)&&h!==a&&(i=(" "+h).split(f),g={point:this,series:b}[i[1]],i=i[2],g=g===this&&(i==="y"||i==="open"||i==="high"||i==="low"||i==="close")?(c.valuePrefix||c.yPrefix||"")+dc(this[i],p(c.valueDecimals,c.yDecimals,d))+(c.valueSuffix||c.ySuffix||""):g[i],a=a.replace(h,g));return a},update:function(a,b,c){var d=this,e=d.series,f=d.graphic,g,h=e.data,i=h.length,k=e.chart,b=p(b,!0);d.firePointEvent("update",{options:a},function(){d.applyOptions(a);mb(a)&&(e.getAttribs(),f&&f.attr(d.pointAttr[e.state]));
152
- for(g=0;g<i;g++)if(h[g]===d){e.xData[g]=d.x;e.yData[g]=d.y;e.options.data[g]=a;break}e.isDirty=!0;e.isDirtyData=!0;b&&k.redraw(c)})},remove:function(a,b){var c=this,d=c.series,e=d.chart,f,g=d.data,h=g.length;Kb(b,e);a=p(a,!0);c.firePointEvent("remove",null,function(){for(f=0;f<h;f++)if(g[f]===c){g.splice(f,1);d.options.data.splice(f,1);d.xData.splice(f,1);d.yData.splice(f,1);break}c.destroy();d.isDirty=!0;d.isDirtyData=!0;a&&e.redraw()})},firePointEvent:function(a,b,c){var d=this,e=this.series.options;
153
- (e.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();a==="click"&&e.allowPointSelect&&(c=function(a){d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});aa(this,a,b,c)},importEvents:function(){if(!this.hasImportedEvents){var a=K(this.series.options.point,this.options).events,b;this.events=a;for(b in a)ha(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a){var b=this.plotX,c=this.plotY,d=this.series,e=d.options.states,f=M[d.type].marker&&d.options.marker,
154
- g=f&&!f.enabled,h=f&&f.states[a],i=h&&h.enabled===!1,k=d.stateMarkerGraphic,j=d.chart,l=this.pointAttr,a=a||Ka;if(!(a===this.state||this.selected&&a!=="select"||e[a]&&e[a].enabled===!1||a&&(i||g&&!h.enabled))){if(this.graphic)e=f&&this.graphic.symbolName&&l[a].r,this.graphic.attr(K(l[a],e?{x:b-e,y:c-e,width:2*e,height:2*e}:{}));else{if(a){if(!k)e=f.radius,d.stateMarkerGraphic=k=j.renderer.symbol(d.symbol,-e,-e,2*e,2*e).attr(l[a]).add(d.group);k.translate(b,c)}if(k)k[a?"show":"hide"]()}this.state=
155
- a}}};var $=function(){};$.prototype={isCartesian:!0,type:"line",pointClass:lb,sorted:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor",r:"radius"},init:function(a,b){var c,d;d=a.series.length;this.chart=a;this.options=b=this.setOptions(b);this.bindAxes();L(this,{index:d,name:b.name||"Series "+(d+1),state:Ka,pointAttr:{},visible:b.visible!==!1,selected:b.selected===!0});if(Fa)b.animation=!1;d=b.events;for(c in d)ha(this,c,d[c]);if(d&&d.click||b.point&&b.point.events&&
156
- b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;this.getColor();this.getSymbol();this.setData(b.data,!1)},bindAxes:function(){var a=this,b=a.options,c=a.chart,d;a.isCartesian&&o(["xAxis","yAxis"],function(e){o(c[e],function(c){d=c.options;if(b[e]===d.index||b[e]===X&&d.index===0)c.series.push(a),a[e]=c,c.isDirty=!0})})},autoIncrement:function(){var a=this.options,b=this.xIncrement,b=p(b,a.pointStart,0);this.pointInterval=p(this.pointInterval,a.pointInterval,1);this.xIncrement=b+this.pointInterval;
157
- return b},getSegments:function(){var a=-1,b=[],c,d=this.points,e=d.length;if(e)if(this.options.connectNulls){for(c=e;c--;)d[c].y===null&&d.splice(c,1);d.length&&(b=[d])}else o(d,function(c,g){c.y===null?(g>a+1&&b.push(d.slice(a+1,g)),a=g):g===e-1&&b.push(d.slice(a+1,g+1))});this.segments=b},setOptions:function(a){var b=this.chart.options,c=b.plotOptions,d=a.data;a.data=null;c=K(c[this.type],c.series,a);c.data=a.data=d;this.tooltipOptions=K(b.tooltip,c.tooltip);return c},getColor:function(){var a=
158
- this.chart.options.colors,b=this.chart.counters;this.color=this.options.color||a[b.color++]||"#0000ff";b.wrapColor(a.length)},getSymbol:function(){var a=this.options.marker,b=this.chart,c=b.options.symbols,b=b.counters;this.symbol=a.symbol||c[b.symbol++];if(/^url/.test(this.symbol))a.radius=0;b.wrapSymbol(c.length)},addPoint:function(a,b,c,d){var e=this.data,f=this.graph,g=this.area,h=this.chart,i=this.xData,k=this.yData,j=f&&f.shift||0,l=this.options.data;Kb(d,h);if(f&&c)f.shift=j+1;if(g){if(c)g.shift=
159
- j+1;g.isArea=!0}b=p(b,!0);d={series:this};this.pointClass.prototype.applyOptions.apply(d,[a]);i.push(d.x);k.push(this.valueCount===4?[d.open,d.high,d.low,d.close]:d.y);l.push(a);c&&(e[0]?e[0].remove(!1):(e.shift(),i.shift(),k.shift(),l.shift()));this.getAttribs();this.isDirtyData=this.isDirty=!0;b&&h.redraw()},setData:function(a,b){var c=this.points,d=this.options,e=this.initialColor,f=this.chart,g=null;this.xIncrement=null;this.pointRange=this.xAxis&&this.xAxis.categories&&1||d.pointRange;if(s(e))f.counters.color=
160
- e;var h=[],i=[],k=a?a.length:[],j=this.valueCount===4;if(k>(d.turboThreshold||1E3)){for(e=0;g===null&&e<k;)g=a[e],e++;if(Bb(g)){g=p(d.pointStart,0);d=p(d.pointInterval,1);for(e=0;e<k;e++)h[e]=g,i[e]=a[e],g+=d;this.xIncrement=g}else if(Fb(g))if(j)for(e=0;e<k;e++)d=a[e],h[e]=d[0],i[e]=d.slice(1,5);else for(e=0;e<k;e++)d=a[e],h[e]=d[0],i[e]=d[1]}else for(e=0;e<k;e++)d={series:this},this.pointClass.prototype.applyOptions.apply(d,[a[e]]),h[e]=d.x,i[e]=j?[d.open,d.high,d.low,d.close]:d.y;this.data=[];this.options.data=
161
- a;this.xData=h;this.yData=i;for(e=c&&c.length||0;e--;)c[e]&&c[e].destroy&&c[e].destroy();this.isDirty=this.isDirtyData=f.isDirtyBox=!0;p(b,!0)&&f.redraw(!1)},remove:function(a,b){var c=this,d=c.chart,a=p(a,!0);if(!c.isRemoving)c.isRemoving=!0,aa(c,"remove",null,function(){c.destroy();d.isDirtyLegend=d.isDirtyBox=!0;a&&d.redraw(b)});c.isRemoving=!1},processData:function(a){var b=this.xData,c=this.yData,d=b.length,e=0,f=d,g,h,i=this.xAxis,k=this.options,j=k.cropThreshold,l=this.isCartesian;if(l&&!this.isDirty&&
162
- !i.isDirty&&!this.yAxis.isDirty&&!a)return!1;if(l&&this.sorted&&(!j||d>j||this.forceCrop))if(a=i.getExtremes(),i=a.min,j=a.max,b[d-1]<i||b[0]>j)b=[],c=[];else if(b[0]<i||b[d-1]>j){for(a=0;a<d;a++)if(b[a]>=i){e=W(0,a-1);break}for(;a<d;a++)if(b[a]>j){f=a+1;break}b=b.slice(e,f);c=c.slice(e,f);g=!0}for(a=b.length-1;a>0;a--)if(d=b[a]-b[a-1],d>0&&(h===X||d<h))h=d;this.cropped=g;this.cropStart=e;this.processedXData=b;this.processedYData=c;if(k.pointRange===null)this.pointRange=h||1;this.closestPointRange=
163
- h},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,e=this.processedYData,f=this.pointClass,g=d.length,h=this.cropStart||0,i,k=this.hasGroupedData,j,l=[],n;if(!b&&!k)b=[],b.length=a.length,b=this.data=b;for(n=0;n<g;n++)i=h+n,k?l[n]=(new f).init(this,[d[n]].concat(Hb(e[n]))):(b[i]?j=b[i]:b[i]=j=(new f).init(this,a[i],d[n]),l[n]=j);if(b&&(g!==(c=b.length)||k))for(n=0;n<c;n++)n===h&&!k&&(n+=g),b[n]&&b[n].destroyElements();this.data=b;this.points=l},translate:function(){this.processedXData||
164
- this.processData();this.generatePoints();for(var a=this.chart,b=this.options,c=b.stacking,d=this.xAxis,e=d.categories,f=this.yAxis,g=this.points,h=g.length,i=!!this.modifyValue,k,j=f.series,l=j.length;l--;)if(j[l].visible){l===this.index&&(k=!0);break}for(l=0;l<h;l++){var j=g[l],n=j.x,o=j.y,r=j.low,p=f.stacks[(o<b.threshold?"-":"")+this.stackKey];j.plotX=z(d.translate(n,0,0,0,1)*10)/10;if(c&&this.visible&&p&&p[n]){r=p[n];n=r.total;r.cum=r=r.cum-o;o=r+o;if(k)r=b.threshold;c==="percent"&&(r=n?r*100/
165
- n:0,o=n?o*100/n:0);j.percentage=n?j.y*100/n:0;j.stackTotal=n;j.stackY=o}j.yBottom=s(r)?f.translate(r,0,1,0,1):null;i&&(o=this.modifyValue(o,j));j.plotY=typeof o==="number"?z(f.translate(o,0,1,0,1)*10)/10:X;j.clientX=a.inverted?a.plotHeight-j.plotX:j.plotX;j.category=e&&e[j.x]!==X?e[j.x]:j.x}this.getSegments()},setTooltipPoints:function(a){var b=this.chart,c=b.inverted,d=[],b=z((c?b.plotTop:b.plotLeft)+b.plotSizeX),e,f;e=this.xAxis;var g,h,i=[];if(this.options.enableMouseTracking!==!1){if(a)this.tooltipPoints=
166
- null;o(this.segments||this.points,function(a){d=d.concat(a)});e&&e.reversed&&(d=d.reverse());a=d.length;for(h=0;h<a;h++){g=d[h];e=d[h-1]?d[h-1]._high+1:0;for(f=g._high=d[h+1]?Ta((g.plotX+(d[h+1]?d[h+1].plotX:b))/2):b;e<=f;)i[c?b-e++:e++]=g}this.tooltipPoints=i}},tooltipHeaderFormatter:function(a){var b=this.tooltipOptions,c=b.xDateFormat||"%A, %b %e, %Y",d=this.xAxis;return b.headerFormat.replace("{point.key}",d&&d.options.type==="datetime"?ac(c,a):a).replace("{series.name}",this.name).replace("{series.color}",
167
- this.color)},onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(Ga||!a.mouseIsDown){if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&aa(this,"mouseOver");this.setState(ta);a.hoverSeries=this}},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;if(d)d.onMouseOut();this&&a.events.mouseOut&&aa(this,"mouseOut");c&&!a.stickyTracking&&!c.shared&&c.hide();this.setState();b.hoverSeries=null},animate:function(a){var b=this.chart,c=this.clipRect,d=this.options.animation;
168
- d&&!mb(d)&&(d={});if(a){if(!c.isAnimating)c.attr("width",0),c.isAnimating=!0}else c.animate({width:b.plotSizeX},d),this.animate=null},drawPoints:function(){var a,b=this.points,c=this.chart,d,e,f,g,h,i,k,j;if(this.options.marker.enabled)for(f=b.length;f--;)if(g=b[f],d=g.plotX,e=g.plotY,j=g.graphic,e!==X&&!isNaN(e))if(a=g.pointAttr[g.selected?"select":Ka],h=a.r,i=p(g.marker&&g.marker.symbol,this.symbol),k=i.indexOf("url")===0,j)j.animate(L({x:d-h,y:e-h},j.symbolName?{width:2*h,height:2*h}:{}));else if(h>
169
- 0||k)g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h).attr(a).add(this.group)},convertAttribs:function(a,b,c,d){var e=this.pointAttrToOptions,f,g,h={},a=a||{},b=b||{},c=c||{},d=d||{};for(f in e)g=e[f],h[f]=p(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var a=this,b=M[a.type].marker?a.options.marker:a.options,c=b.states,d=c[ta],e,f=a.color,g={stroke:f,fill:f},h=a.points,i=[],k,j=a.pointAttrToOptions,l;a.options.marker?(d.radius=d.radius||b.radius+2,d.lineWidth=d.lineWidth||b.lineWidth+1):d.color=
170
- d.color||ma(d.color||f).brighten(d.brightness).get();i[Ka]=a.convertAttribs(b,g);o([ta,"select"],function(b){i[b]=a.convertAttribs(c[b],i[Ka])});a.pointAttr=i;for(f=h.length;f--;){g=h[f];if((b=g.options&&g.options.marker||g.options)&&b.enabled===!1)b.radius=0;e=!1;if(g.options)for(l in j)s(b[j[l]])&&(e=!0);if(e){k=[];c=b.states||{};e=c[ta]=c[ta]||{};if(!a.options.marker)e.color=ma(e.color||g.options.color).brighten(e.brightness||d.brightness).get();k[Ka]=a.convertAttribs(b,i[Ka]);k[ta]=a.convertAttribs(c[ta],
171
- i[ta],k[Ka]);k.select=a.convertAttribs(c.select,i.select,k[Ka])}else k=i;g.pointAttr=k}},destroy:function(){var a=this,b=a.chart,c=a.clipRect,d=/AppleWebKit\/533/.test(kb),e,f,g=a.data||[],h,i,k;aa(a,"destroy");Qa(a);o(["xAxis","yAxis"],function(b){if(k=a[b])Gb(k.series,a),k.isDirty=!0});a.legendItem&&a.chart.legend.destroyItem(a);for(f=g.length;f--;)(h=g[f])&&h.destroy&&h.destroy();a.points=null;if(c&&c!==b.clipRect)a.clipRect=c.destroy();o(["area","graph","dataLabelsGroup","group","tracker"],function(b){a[b]&&
172
- (e=d&&b==="group"?"hide":"destroy",a[b][e]())});if(b.hoverSeries===a)b.hoverSeries=null;Gb(b.series,a);for(i in a)delete a[i]},drawDataLabels:function(){var a=this,b=a.options,c=b.dataLabels;if(c.enabled||a._hasPointLabels){var d,e,f=a.points,g,h,i,k=a.dataLabelsGroup,j=a.chart,l=a.xAxis,l=l?l.left:j.plotLeft,n=a.yAxis,n=n?n.top:j.plotTop,t=j.renderer,r=j.inverted,Z=a.type,V=b.stacking,v=Z==="column"||Z==="bar",y=c.verticalAlign===null,q=c.y===null,T=t.fontMetrics(c.style.fontSize),A=T.h,x=T.b,w,
173
- ia;v&&(T={top:x,middle:x-A/2,bottom:-A+x},V?(y&&(c=K(c,{verticalAlign:"middle"})),q&&(c=K(c,{y:T[c.verticalAlign]}))):y?c=K(c,{verticalAlign:"top"}):q&&(c=K(c,{y:T[c.verticalAlign]})));k?k.translate(l,n):k=a.dataLabelsGroup=t.g("data-labels").attr({visibility:a.visible?eb:ab,zIndex:6}).translate(l,n).add();h=c;o(f,function(f){w=f.dataLabel;c=h;(g=f.options)&&g.dataLabels&&(c=K(c,g.dataLabels));if(ia=c.enabled){var l=f.barX&&f.barX+f.barW/2||p(f.plotX,-999),n=p(f.plotY,-999),o=c.y===null?f.y>=b.threshold?
174
- -A+x:x:c.y;d=(r?j.plotWidth-n:l)+c.x;e=z((r?j.plotHeight-l:n)+o)}if(w&&a.isCartesian&&(!j.isInsidePlot(d,e)||!ia))f.dataLabel=w.destroy();else if(ia){l=c.align;i=c.formatter.call(f.getLabelConfig(),c);Z==="column"&&(d+={left:-1,right:1}[l]*f.barW/2||0);!V&&r&&f.y<0&&(l="right",d-=10);c.style.color=p(c.color,c.style.color,a.color,"black");if(w)w.attr({text:i}).animate({x:d,y:e});else if(s(i))w=f.dataLabel=t[c.rotation?"text":"label"](i,d,e,null,null,null,c.useHTML,!0).attr({align:l,fill:c.backgroundColor,
175
- stroke:c.borderColor,"stroke-width":c.borderWidth,r:c.borderRadius,rotation:c.rotation,padding:c.padding,zIndex:1}).css(c.style).add(k).shadow(c.shadow);if(v&&b.stacking&&w)l=f.barX,n=f.barY,o=f.barW,f=f.barH,w.align(c,null,{x:r?j.plotWidth-n-f:l,y:r?j.plotHeight-l-o:n,width:r?f:o,height:r?o:f})}})}},drawGraph:function(){var a=this,b=a.options,c=a.graph,d=[],e,f=a.area,g=a.group,h=b.lineColor||a.color,i=b.lineWidth,k=b.dashStyle,j,l=a.chart.renderer,n=a.yAxis.getThreshold(b.threshold),t=/^area/.test(a.type),
176
- r=[],s=[];o(a.segments,function(c){j=[];o(c,function(d,e){a.getPointSpline?j.push.apply(j,a.getPointSpline(c,d,e)):(j.push(e?fa:wa),e&&b.step&&j.push(d.plotX,c[e-1].plotY),j.push(d.plotX,d.plotY))});c.length>1?d=d.concat(j):r.push(c[0]);if(t){var e=[],f,g=j.length;for(f=0;f<g;f++)e.push(j[f]);g===3&&e.push(fa,j[1],j[2]);if(b.stacking&&a.type!=="areaspline")for(f=c.length-1;f>=0;f--)f<c.length-1&&b.step&&e.push(c[f+1].plotX,c[f].yBottom),e.push(c[f].plotX,c[f].yBottom);else e.push(fa,c[c.length-1].plotX,
177
- n,fa,c[0].plotX,n);s=s.concat(e)}});a.graphPath=d;a.singlePoints=r;if(t)e=p(b.fillColor,ma(a.color).setOpacity(b.fillOpacity||0.75).get()),f?f.animate({d:s}):a.area=a.chart.renderer.path(s).attr({fill:e}).add(g);if(c)Ob(c),c.animate({d:d});else if(i){c={stroke:h,"stroke-width":i};if(k)c.dashstyle=k;a.graph=l.path(d).attr(c).add(g).shadow(b.shadow)}},invertGroups:function(){function a(){var a={width:b.yAxis.len,height:b.xAxis.len};c.attr(a).invert();d&&d.attr(a).invert()}var b=this,c=b.group,d=b.trackerGroup,
178
- e=b.chart;ha(e,"resize",a);ha(b,"destroy",function(){Qa(e,"resize",a)});a();b.invertGroups=a},render:function(){var a=this,b=a.chart,c,d=a.options,e=d.clip!==!1,f=d.animation,g=f&&a.animate,f=g?f&&f.duration||500:0,h=a.clipRect,i=b.renderer;if(!h&&(h=a.clipRect=!b.hasRendered&&b.clipRect?b.clipRect:i.clipRect(0,0,b.plotSizeX,b.plotSizeY+1),!b.clipRect))b.clipRect=h;if(!a.group)c=a.group=i.g("series"),c.attr({visibility:a.visible?eb:ab,zIndex:d.zIndex}).translate(a.xAxis.left,a.yAxis.top).add(b.seriesGroup);
179
- a.drawDataLabels();g&&a.animate(!0);a.getAttribs();a.drawGraph&&a.drawGraph();a.drawPoints();a.options.enableMouseTracking!==!1&&a.drawTracker();b.inverted&&a.invertGroups();e&&!a.hasRendered&&(c.clip(h),a.trackerGroup&&a.trackerGroup.clip(b.clipRect));g&&a.animate();setTimeout(function(){h.isAnimating=!1;if((c=a.group)&&h!==b.clipRect&&h.renderer){if(e)c.clip(a.clipRect=b.clipRect);h.destroy()}},f);a.isDirty=a.isDirtyData=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirtyData,
180
- c=this.group;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:this.xAxis.left,translateY:this.yAxis.top}));this.translate();this.setTooltipPoints(!0);this.render();b&&aa(this,"updatedData")},setState:function(a){var b=this.options,c=this.graph,d=b.states,b=b.lineWidth,a=a||Ka;if(this.state!==a)this.state=a,d[a]&&d[a].enabled===!1||(a&&(b=d[a].lineWidth||b+1),c&&!c.dashstyle&&c.attr({"stroke-width":b},a?0:500))},setVisible:function(a,b){var c=this.chart,d=this.legendItem,
181
- e=this.group,f=this.tracker,g=this.dataLabelsGroup,h,i=this.points,k=c.options.chart.ignoreHiddenSeries;h=this.visible;h=(this.visible=a=a===X?!h:a)?"show":"hide";if(e)e[h]();if(f)f[h]();else if(i)for(e=i.length;e--;)if(f=i[e],f.tracker)f.tracker[h]();if(g)g[h]();d&&c.legend.colorizeItem(this,a);this.isDirty=!0;this.options.stacking&&o(c.series,function(a){if(a.options.stacking&&a.visible)a.isDirty=!0});if(k)c.isDirtyBox=!0;b!==!1&&c.redraw();aa(this,h)},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},
182
- select:function(a){this.selected=a=a===X?!this.selected:a;if(this.checkbox)this.checkbox.checked=a;aa(this,a?"select":"unselect")},drawTrackerGroup:function(){var a=this.trackerGroup,b=this.chart;if(this.isCartesian){if(!a)this.trackerGroup=a=b.renderer.g().attr({zIndex:this.options.zIndex||1}).add(b.trackerGroup);a.translate(this.xAxis.left,this.yAxis.top)}return a},drawTracker:function(){var a=this,b=a.options,c=[].concat(a.graphPath),d=c.length,e=a.chart,f=e.renderer,g=e.options.tooltip.snap,h=
183
- a.tracker,i=b.cursor,i=i&&{cursor:i},k=a.singlePoints,j=a.drawTrackerGroup(),l;if(d)for(l=d+1;l--;)c[l]===wa&&c.splice(l+1,0,c[l+1]-g,c[l+2],fa),(l&&c[l]===wa||l===d)&&c.splice(l,0,fa,c[l-2]+g,c[l-1]);for(l=0;l<k.length;l++)d=k[l],c.push(wa,d.plotX-g,d.plotY,fa,d.plotX+g,d.plotY);h?h.attr({d:c}):a.tracker=f.path(c).attr({isTracker:!0,stroke:Gc,fill:Ma,"stroke-linejoin":"bevel","stroke-width":b.lineWidth+2*g,visibility:a.visible?eb:ab}).on(Ga?"touchstart":"mouseover",function(){if(e.hoverSeries!==
184
- a)a.onMouseOver()}).on("mouseout",function(){if(!b.stickyTracking)a.onMouseOut()}).css(i).add(j)}};w=pa($);Ha.line=w;w=pa($,{type:"area"});Ha.area=w;w=pa($,{type:"spline",getPointSpline:function(a,b,c){var d=b.plotX,e=b.plotY,f=a[c-1],g=a[c+1],h,i,k,j;if(c&&c<a.length-1){a=f.plotY;k=g.plotX;var g=g.plotY,l;h=(1.5*d+f.plotX)/2.5;i=(1.5*e+a)/2.5;k=(1.5*d+k)/2.5;j=(1.5*e+g)/2.5;l=(j-i)*(k-d)/(k-h)+e-j;i+=l;j+=l;i>a&&i>e?(i=W(a,e),j=2*e-i):i<a&&i<e&&(i=Ua(a,e),j=2*e-i);j>g&&j>e?(j=W(g,e),i=2*e-j):j<g&&
185
- j<e&&(j=Ua(g,e),i=2*e-j);b.rightContX=k;b.rightContY=j}c?(b=["C",f.rightContX||f.plotX,f.rightContY||f.plotY,h||d,i||e,d,e],f.rightContX=f.rightContY=null):b=[wa,d,e];return b}});Ha.spline=w;w=pa(w,{type:"areaspline"});Ha.areaspline=w;var zb=pa($,{type:"column",tooltipOutsidePlot:!0,pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color",r:"borderRadius"},init:function(){$.prototype.init.apply(this,arguments);var a=this,b=a.chart;b.hasRendered&&o(b.series,function(b){if(b.type===
186
- a.type)b.isDirty=!0})},translate:function(){var a=this,b=a.chart,c=a.options,d=c.stacking,e=c.borderWidth,f=0,g=a.xAxis,h=g.reversed,i={},k,j;$.prototype.translate.apply(a);o(b.series,function(b){if(b.type===a.type&&b.visible&&a.options.group===b.options.group)b.options.stacking?(k=b.stackKey,i[k]===X&&(i[k]=f++),j=i[k]):j=f++,b.columnIndex=j});var b=a.points,g=Ba(g.translationSlope)*(g.ordinalSlope||g.closestPointRange||1),l=g*c.groupPadding,n=(g-2*l)/f,t=c.pointWidth,r=s(t)?(n-t)/2:n*c.pointPadding,
187
- w=Yb(W(p(t,n-2*r),1+2*e)),x=r+(l+((h?f-a.columnIndex:a.columnIndex)||0)*n-g/2)*(h?-1:1),v=a.yAxis.getThreshold(c.threshold),y=p(c.minPointLength,5);o(b,function(b){var f=b.plotY,g=p(b.yBottom,v),h=b.plotX+x,i=Yb(Ua(f,g)),j=Yb(W(f,g)-i),k=a.yAxis.stacks[(b.y<0?"-":"")+a.stackKey];d&&a.visible&&k&&k[b.x]&&k[b.x].setOffset(x,w);Ba(j)<y&&y&&(j=y,i=Ba(i-v)>y?g-y:v-(f<=v?y:0));L(b,{barX:h,barY:i,barW:w,barH:j});b.shapeType="rect";f={x:h,y:i,width:w,height:j,r:c.borderRadius,strokeWidth:e};e%2&&(f.y-=1,
188
- f.height+=1);b.shapeArgs=f;b.trackerArgs=Ba(j)<3&&K(b.shapeArgs,{height:6,y:i-3})})},getSymbol:function(){},drawGraph:function(){},drawPoints:function(){var a=this,b=a.options,c=a.chart.renderer,d,e;o(a.points,function(f){var g=f.plotY;if(g!==X&&!isNaN(g)&&f.y!==null)d=f.graphic,e=f.shapeArgs,d?(Ob(d),d.animate(c.Element.prototype.crisp.apply({},[e.strokeWidth,e.x,e.y,e.width,e.height]))):f.graphic=d=c[f.shapeType](e).attr(f.pointAttr[f.selected?"select":Ka]).add(a.group).shadow(b.shadow)})},drawTracker:function(){var a=
189
- this,b=a.chart,c=b.renderer,d,e,f=+new Date,g=a.options,h=g.cursor,i=h&&{cursor:h},k=a.drawTrackerGroup(),j;o(a.points,function(h){e=h.tracker;d=h.trackerArgs||h.shapeArgs;delete d.strokeWidth;if(h.y!==null)e?e.attr(d):h.tracker=c[h.shapeType](d).attr({isTracker:f,fill:Gc,visibility:a.visible?eb:ab}).on(Ga?"touchstart":"mouseover",function(c){j=c.relatedTarget||c.fromElement;if(b.hoverSeries!==a&&A(j,"isTracker")!==f)a.onMouseOver();h.onMouseOver()}).on("mouseout",function(b){if(!g.stickyTracking&&
190
- (j=b.relatedTarget||b.toElement,A(j,"isTracker")!==f))a.onMouseOut()}).css(i).add(h.group||k)})},animate:function(a){var b=this,c=b.points,d=b.options;if(!a)o(c,function(a){var c=a.graphic,a=a.shapeArgs,g=b.yAxis,h=d.threshold;c&&(c.attr({height:0,y:s(h)?g.getThreshold(h):g.translate(g.getExtremes().min,0,1,0,1)}),c.animate({height:a.height,y:a.y},d.animation))}),b.animate=null},remove:function(){var a=this,b=a.chart;b.hasRendered&&o(b.series,function(b){if(b.type===a.type)b.isDirty=!0});$.prototype.remove.apply(a,
191
- arguments)}});Ha.column=zb;w=pa(zb,{type:"bar",init:function(){this.inverted=!0;zb.prototype.init.apply(this,arguments)}});Ha.bar=w;w=pa($,{type:"scatter",sorted:!1,translate:function(){var a=this;$.prototype.translate.apply(a);o(a.points,function(b){b.shapeType="circle";b.shapeArgs={x:b.plotX,y:b.plotY,r:a.chart.options.tooltip.snap}})},drawTracker:function(){for(var a=this,b=a.options.cursor,b=b&&{cursor:b},c=a.points,d=c.length,e;d--;)if(e=c[d].graphic)e.element._i=d;a._hasTracking?a._hasTracking=
192
- !0:a.group.attr({isTracker:!0}).on(Ga?"touchstart":"mouseover",function(b){a.onMouseOver();if(b.target._i!==X)c[b.target._i].onMouseOver()}).on("mouseout",function(){if(!a.options.stickyTracking)a.onMouseOut()}).css(b)}});Ha.scatter=w;w=pa(lb,{init:function(){lb.prototype.init.apply(this,arguments);var a=this,b;L(a,{visible:a.visible!==!1,name:p(a.name,"Slice")});b=function(){a.slice()};ha(a,"select",b);ha(a,"unselect",b);return a},setVisible:function(a){var b=this.series.chart,c=this.tracker,d=this.dataLabel,
193
- e=this.connector,f=this.shadowGroup,g;g=(this.visible=a=a===X?!this.visible:a)?"show":"hide";this.group[g]();if(c)c[g]();if(d)d[g]();if(e)e[g]();if(f)f[g]();this.legendItem&&b.legend.colorizeItem(this,a)},slice:function(a,b,c){var d=this.series.chart,e=this.slicedTranslation;Kb(c,d);p(b,!0);a=this.sliced=s(a)?a:!this.sliced;a={translateX:a?e[0]:d.plotLeft,translateY:a?e[1]:d.plotTop};this.group.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)}});w=pa($,{type:"pie",isCartesian:!1,pointClass:w,
194
- pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},getColor:function(){this.initialColor=this.chart.counters.color},animate:function(){var a=this;o(a.points,function(b){var c=b.graphic,b=b.shapeArgs,d=-da/2;c&&(c.attr({r:0,start:d,end:d}),c.animate({r:b.r,start:b.start,end:b.end},a.options.animation))});a.animate=null},setData:function(){$.prototype.setData.apply(this,arguments);this.processData();this.generatePoints()},translate:function(){this.generatePoints();var a=
195
- 0,b=-0.25,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,f=c.center.concat([c.size,c.innerSize||0]),g=this.chart,h=g.plotWidth,i=g.plotHeight,k,j,l,n=this.points,p=2*da,r,s=Ua(h,i),w,v,y,q=c.dataLabels.distance,f=Vb(f,function(a,b){return(w=/%$/.test(a))?[h,i,s,s][b]*S(a)/100:a});this.getX=function(a,b){l=oa.asin((a-f[1])/(f[2]/2+q));return f[0]+(b?-1:1)*ja(l)*(f[2]/2+q)};this.center=f;o(n,function(b){a+=b.y});o(n,function(c){r=a?c.y/a:0;k=z(b*p*1E3)/1E3;b+=r;j=z(b*p*1E3)/1E3;c.shapeType="arc";
196
- c.shapeArgs={x:f[0],y:f[1],r:f[2]/2,innerR:f[3]/2,start:k,end:j};l=(j+k)/2;c.slicedTranslation=Vb([ja(l)*d+g.plotLeft,C(l)*d+g.plotTop],z);v=ja(l)*f[2]/2;y=C(l)*f[2]/2;c.tooltipPos=[f[0]+v*0.7,f[1]+y*0.7];c.labelPos=[f[0]+v+ja(l)*q,f[1]+y+C(l)*q,f[0]+v+ja(l)*e,f[1]+y+C(l)*e,f[0]+v,f[1]+y,q<0?"center":l<p/4?"left":"right",l];c.percentage=r*100;c.total=a});this.setTooltipPoints()},render:function(){this.getAttribs();this.drawPoints();this.options.enableMouseTracking!==!1&&this.drawTracker();this.drawDataLabels();
197
- this.options.animation&&this.animate&&this.animate();this.isDirty=!1},drawPoints:function(){var a=this.chart,b=a.renderer,c,d,e,f=this.options.shadow,g,h;o(this.points,function(i){d=i.graphic;h=i.shapeArgs;e=i.group;g=i.shadowGroup;if(f&&!g)g=i.shadowGroup=b.g("shadow").attr({zIndex:4}).add();if(!e)e=i.group=b.g("point").attr({zIndex:5}).add();c=i.sliced?i.slicedTranslation:[a.plotLeft,a.plotTop];e.translate(c[0],c[1]);g&&g.translate(c[0],c[1]);d?d.animate(h):i.graphic=b.arc(h).attr(L(i.pointAttr[Ka],
198
- {"stroke-linejoin":"round"})).add(i.group).shadow(f,g);i.visible===!1&&i.setVisible(!1)})},drawDataLabels:function(){var a=this.data,b,c=this.chart,d=this.options.dataLabels,e=p(d.connectorPadding,10),f=p(d.connectorWidth,1),g,h,i=p(d.softConnector,!0),k=d.distance,j=this.center,l=j[2]/2,j=j[1],n=k>0,t=[[],[]],r,s,w,v,y=2,q;if(d.enabled){$.prototype.drawDataLabels.apply(this);o(a,function(a){a.dataLabel&&t[a.labelPos[7]<da/2?0:1].push(a)});t[1].reverse();v=function(a,b){return b.y-a.y};for(a=t[0][0]&&
199
- t[0][0].dataLabel&&t[0][0].dataLabel.getBBox().height;y--;){var x=[],A=[],z=t[y],E=z.length,C;for(q=j-l-k;q<=j+l+k;q+=a)x.push(q);w=x.length;if(E>w){h=[].concat(z);h.sort(v);for(q=E;q--;)h[q].rank=q;for(q=E;q--;)z[q].rank>=w&&z.splice(q,1);E=z.length}for(q=0;q<E;q++){b=z[q];h=b.labelPos;b=9999;for(s=0;s<w;s++)g=Ba(x[s]-h[1]),g<b&&(b=g,C=s);if(C<q&&x[q]!==null)C=q;else for(w<E-q+C&&x[q]!==null&&(C=w-E+q);x[C]===null;)C++;A.push({i:C,y:x[C]});x[C]=null}A.sort(v);for(q=0;q<E;q++){b=z[q];h=b.labelPos;
200
- g=b.dataLabel;s=A.pop();r=h[1];w=b.visible===!1?ab:eb;C=s.i;s=s.y;if(r>s&&x[C+1]!==null||r<s&&x[C-1]!==null)s=r;r=this.getX(C===0||C===x.length-1?r:s,y);g.attr({visibility:w,align:h[6]})[g.moved?"animate":"attr"]({x:r+d.x+({left:e,right:-e}[h[6]]||0),y:s+d.y});g.moved=!0;if(n&&f)g=b.connector,h=i?[wa,r+(h[6]==="left"?5:-5),s,"C",r,s,2*h[2]-h[4],2*h[3]-h[5],h[2],h[3],fa,h[4],h[5]]:[wa,r+(h[6]==="left"?5:-5),s,fa,h[2],h[3],fa,h[4],h[5]],g?(g.animate({d:h}),g.attr("visibility",w)):b.connector=g=this.chart.renderer.path(h).attr({"stroke-width":f,
201
- stroke:d.connectorColor||b.color||"#606060",visibility:w,zIndex:3}).translate(c.plotLeft,c.plotTop).add()}}}},drawTracker:zb.prototype.drawTracker,getSymbol:function(){}});Ha.pie=w;L(Highcharts,{Chart:wc,dateFormat:ac,pathAnim:La,getOptions:function(){return Ea},hasBidiBug:Qc,numberFormat:dc,Point:lb,Color:ma,Renderer:Xb,SVGRenderer:Eb,VMLRenderer:$a,CanVGRenderer:oc,seriesTypes:Ha,setOptions:function(a){$b=K($b,a.xAxis);kc=K(kc,a.yAxis);a.xAxis=a.yAxis=X;Ea=K(Ea,a);vc();return Ea},Series:$,addEvent:ha,
202
- removeEvent:Qa,createElement:Aa,discardElement:Tb,css:P,each:o,extend:L,map:Vb,merge:K,pick:p,splat:Hb,extendClass:pa,placeBox:uc,product:"Highcharts",version:"2.2.1"})})();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/mandrill.js CHANGED
@@ -50,7 +50,7 @@ function showStats() {
50
  data: {
51
  action: 'get_mandrill_stats',
52
  filter: filter,
53
- display: display,
54
  },
55
  success: function(data, textStatus, XMLHttpRequest){
56
  jQuery('#loading_data').css('display','none');
@@ -72,7 +72,7 @@ function redrawDashboardWidget() {
72
  url: ajaxurl,
73
  data: {
74
  action: 'get_dashboard_widget_stats',
75
- ajax: true,
76
  },
77
  success: function(data, textStatus, XMLHttpRequest){
78
  eval(data);
50
  data: {
51
  action: 'get_mandrill_stats',
52
  filter: filter,
53
+ display: display
54
  },
55
  success: function(data, textStatus, XMLHttpRequest){
56
  jQuery('#loading_data').css('display','none');
72
  url: ajaxurl,
73
  data: {
74
  action: 'get_dashboard_widget_stats',
75
+ ajax: true
76
  },
77
  success: function(data, textStatus, XMLHttpRequest){
78
  eval(data);
js/modules/canvas-tools.js DELETED
@@ -1,133 +0,0 @@
1
- /*
2
- A class to parse color values
3
- @author Stoyan Stefanov <sstoo@gmail.com>
4
- @link http://www.phpied.com/rgb-color-parser-in-javascript/
5
- Use it if you like it
6
-
7
- canvg.js - Javascript SVG parser and renderer on Canvas
8
- MIT Licensed
9
- Gabe Lerner (gabelerner@gmail.com)
10
- http://code.google.com/p/canvg/
11
-
12
- Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/
13
-
14
- Highcharts JS v2.2.1 (2012-03-15)
15
- CanVGRenderer Extension module
16
-
17
- (c) 2011-2012 Torstein H?nsi, Erik Olsson
18
-
19
- License: www.highcharts.com/license
20
- */
21
- function RGBColor(m){this.ok=!1;m.charAt(0)=="#"&&(m=m.substr(1,6));var m=m.replace(/ /g,""),m=m.toLowerCase(),a={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",
22
- darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",
23
- gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",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",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",
24
- lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",
25
- oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",
26
- slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},c;for(c in a)m==c&&(m=a[c]);var d=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(b){return[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,
27
- example:["#00ff00","336699"],process:function(b){return[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(b){return[parseInt(b[1]+b[1],16),parseInt(b[2]+b[2],16),parseInt(b[3]+b[3],16)]}}];for(c=0;c<d.length;c++){var b=d[c].process,k=d[c].re.exec(m);if(k)channels=b(k),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r;this.g=this.g<0||isNaN(this.g)?0:
28
- this.g>255?255:this.g;this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var b=this.r.toString(16),a=this.g.toString(16),d=this.b.toString(16);b.length==1&&(b="0"+b);a.length==1&&(a="0"+a);d.length==1&&(d="0"+d);return"#"+b+a+d};this.getHelpXML=function(){for(var b=[],k=0;k<d.length;k++)for(var c=d[k].example,h=0;h<c.length;h++)b[b.length]=c[h];for(var j in a)b[b.length]=j;c=document.createElement("ul");
29
- c.setAttribute("id","rgbcolor-examples");for(k=0;k<b.length;k++)try{var l=document.createElement("li"),o=new RGBColor(b[k]),n=document.createElement("div");n.style.cssText="margin: 3px; border: 1px solid black; background:"+o.toHex()+"; color:"+o.toHex();n.appendChild(document.createTextNode("test"));var q=document.createTextNode(" "+b[k]+" -> "+o.toRGB()+" -> "+o.toHex());l.appendChild(n);l.appendChild(q);c.appendChild(l)}catch(p){}return c}}
30
- if(!window.console)window.console={},window.console.log=function(){},window.console.dir=function(){};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(m){for(var a=0;a<this.length;a++)if(this[a]==m)return a;return-1};
31
- (function(){function m(){var a={FRAMERATE:30,MAX_VIRTUAL_PIXELS:3E4};a.init=function(c){a.Definitions={};a.Styles={};a.Animations=[];a.Images=[];a.ctx=c;a.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=[]};this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height};
32
- this.ComputeSize=function(a){return a!=null&&typeof a=="number"?a:a=="x"?this.width():a=="y"?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};a.init();a.ImagesLoaded=function(){for(var c=0;c<a.Images.length;c++)if(!a.Images[c].loaded)return!1;return!0};a.trim=function(a){return a.replace(/^\s+|\s+$/g,"")};a.compressSpaces=function(a){return a.replace(/[\s\r\t\n]+/gm," ")};a.ajax=function(a){var d;return(d=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"))?
33
- (d.open("GET",a,!1),d.send(null),d.responseText):null};a.parseXml=function(a){if(window.DOMParser)return(new DOMParser).parseFromString(a,"text/xml");else{var a=a.replace(/<!DOCTYPE svg[^>]*>/,""),d=new ActiveXObject("Microsoft.XMLDOM");d.async="false";d.loadXML(a);return d}};a.Property=function(c,d){this.name=c;this.value=d;this.hasValue=function(){return this.value!=null&&this.value!==""};this.numValue=function(){if(!this.hasValue())return 0;var b=parseFloat(this.value);(this.value+"").match(/%$/)&&
34
- (b/=100);return b};this.valueOrDefault=function(b){return this.hasValue()?this.value:b};this.numValueOrDefault=function(b){return this.hasValue()?this.numValue():b};var b=this;this.Color={addOpacity:function(d){var c=b.value;if(d!=null&&d!=""){var f=new RGBColor(b.value);f.ok&&(c="rgba("+f.r+", "+f.g+", "+f.b+", "+d+")")}return new a.Property(b.name,c)}};this.Definition={getDefinition:function(){var d=b.value.replace(/^(url\()?#([^\)]+)\)?$/,"$2");return a.Definitions[d]},isUrl:function(){return b.value.indexOf("url(")==
35
- 0},getFillStyle:function(b){var d=this.getDefinition();return d!=null&&d.createGradient?d.createGradient(a.ctx,b):d!=null&&d.createPattern?d.createPattern(a.ctx,b):null}};this.Length={DPI:function(){return 96},EM:function(b){var d=12,c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);c.hasValue()&&(d=c.Length.toPixels(b));return d},toPixels:function(d){if(!b.hasValue())return 0;var c=b.value+"";return c.match(/em$/)?b.numValue()*this.EM(d):c.match(/ex$/)?b.numValue()*this.EM(d)/2:c.match(/px$/)?
36
- b.numValue():c.match(/pt$/)?b.numValue()*1.25:c.match(/pc$/)?b.numValue()*15:c.match(/cm$/)?b.numValue()*this.DPI(d)/2.54:c.match(/mm$/)?b.numValue()*this.DPI(d)/25.4:c.match(/in$/)?b.numValue()*this.DPI(d):c.match(/%$/)?b.numValue()*a.ViewPort.ComputeSize(d):b.numValue()}};this.Time={toMilliseconds:function(){if(!b.hasValue())return 0;var a=b.value+"";if(a.match(/s$/))return b.numValue()*1E3;a.match(/ms$/);return b.numValue()}};this.Angle={toRadians:function(){if(!b.hasValue())return 0;var a=b.value+
37
- "";return a.match(/deg$/)?b.numValue()*(Math.PI/180):a.match(/grad$/)?b.numValue()*(Math.PI/200):a.match(/rad$/)?b.numValue():b.numValue()*(Math.PI/180)}}};a.Font=new function(){this.Styles=["normal","italic","oblique","inherit"];this.Variants=["normal","small-caps","inherit"];this.Weights="normal,bold,bolder,lighter,100,200,300,400,500,600,700,800,900,inherit".split(",");this.CreateFont=function(d,b,c,e,f,g){g=g!=null?this.Parse(g):this.CreateFont("","","","","",a.ctx.font);return{fontFamily:f||
38
- g.fontFamily,fontSize:e||g.fontSize,fontStyle:d||g.fontStyle,fontWeight:c||g.fontWeight,fontVariant:b||g.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var c=this;this.Parse=function(d){for(var b={},d=a.trim(a.compressSpaces(d||"")).split(" "),k=!1,e=!1,f=!1,g=!1,h="",j=0;j<d.length;j++)if(!e&&c.Styles.indexOf(d[j])!=-1){if(d[j]!="inherit")b.fontStyle=d[j];e=!0}else if(!g&&c.Variants.indexOf(d[j])!=-1){if(d[j]!="inherit")b.fontVariant=
39
- d[j];e=g=!0}else if(!f&&c.Weights.indexOf(d[j])!=-1){if(d[j]!="inherit")b.fontWeight=d[j];e=g=f=!0}else if(k)d[j]!="inherit"&&(h+=d[j]);else{if(d[j]!="inherit")b.fontSize=d[j].split("/")[0];e=g=f=k=!0}if(h!="")b.fontFamily=h;return b}};a.ToNumberArray=function(c){for(var c=a.trim(a.compressSpaces((c||"").replace(/,/g," "))).split(" "),d=0;d<c.length;d++)c[d]=parseFloat(c[d]);return c};a.Point=function(a,d){this.x=a;this.y=d;this.angleTo=function(b){return Math.atan2(b.y-this.y,b.x-this.x)};this.applyTransform=
40
- function(b){var a=this.x*b[1]+this.y*b[3]+b[5];this.x=this.x*b[0]+this.y*b[2]+b[4];this.y=a}};a.CreatePoint=function(c){c=a.ToNumberArray(c);return new a.Point(c[0],c[1])};a.CreatePath=function(c){for(var c=a.ToNumberArray(c),d=[],b=0;b<c.length;b+=2)d.push(new a.Point(c[b],c[b+1]));return d};a.BoundingBox=function(a,d,b,k){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2-
41
- this.y1};this.addPoint=function(b,a){if(b!=null){if(isNaN(this.x1)||isNaN(this.x2))this.x2=this.x1=b;if(b<this.x1)this.x1=b;if(b>this.x2)this.x2=b}if(a!=null){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=a;if(a<this.y1)this.y1=a;if(a>this.y2)this.y2=a}};this.addX=function(b){this.addPoint(b,null)};this.addY=function(b){this.addPoint(null,b)};this.addBoundingBox=function(b){this.addPoint(b.x1,b.y1);this.addPoint(b.x2,b.y2)};this.addQuadraticCurve=function(b,a,d,c,k,l){d=b+2/3*(d-b);c=a+2/3*(c-
42
- a);this.addBezierCurve(b,a,d,d+1/3*(k-b),c,c+1/3*(l-a),k,l)};this.addBezierCurve=function(b,a,d,c,k,l,o,n){var q=[b,a],p=[d,c],s=[k,l],m=[o,n];this.addPoint(q[0],q[1]);this.addPoint(m[0],m[1]);for(i=0;i<=1;i++)b=function(b){return Math.pow(1-b,3)*q[i]+3*Math.pow(1-b,2)*b*p[i]+3*(1-b)*Math.pow(b,2)*s[i]+Math.pow(b,3)*m[i]},a=6*q[i]-12*p[i]+6*s[i],d=-3*q[i]+9*p[i]-9*s[i]+3*m[i],c=3*p[i]-3*q[i],d==0?a!=0&&(a=-c/a,0<a&&a<1&&(i==0&&this.addX(b(a)),i==1&&this.addY(b(a)))):(c=Math.pow(a,2)-4*c*d,c<0||(k=
43
- (-a+Math.sqrt(c))/(2*d),0<k&&k<1&&(i==0&&this.addX(b(k)),i==1&&this.addY(b(k))),a=(-a-Math.sqrt(c))/(2*d),0<a&&a<1&&(i==0&&this.addX(b(a)),i==1&&this.addY(b(a)))))};this.isPointInBox=function(b,a){return this.x1<=b&&b<=this.x2&&this.y1<=a&&a<=this.y2};this.addPoint(a,d);this.addPoint(b,k)};a.Transform=function(c){var d=this;this.Type={};this.Type.translate=function(b){this.p=a.CreatePoint(b);this.apply=function(b){b.translate(this.p.x||0,this.p.y||0)};this.applyToPoint=function(b){b.applyTransform([1,
44
- 0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(b){b=a.ToNumberArray(b);this.angle=new a.Property("angle",b[0]);this.cx=b[1]||0;this.cy=b[2]||0;this.apply=function(b){b.translate(this.cx,this.cy);b.rotate(this.angle.Angle.toRadians());b.translate(-this.cx,-this.cy)};this.applyToPoint=function(b){var a=this.angle.Angle.toRadians();b.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);b.applyTransform([Math.cos(a),Math.sin(a),-Math.sin(a),Math.cos(a),0,0]);b.applyTransform([1,0,0,1,-this.p.x||
45
- 0,-this.p.y||0])}};this.Type.scale=function(b){this.p=a.CreatePoint(b);this.apply=function(b){b.scale(this.p.x||1,this.p.y||this.p.x||1)};this.applyToPoint=function(b){b.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(b){this.m=a.ToNumberArray(b);this.apply=function(b){b.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.applyToPoint=function(b){b.applyTransform(this.m)}};this.Type.SkewBase=function(b){this.base=d.Type.matrix;this.base(b);this.angle=
46
- new a.Property("angle",b)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(b){this.base=d.Type.SkewBase;this.base(b);this.m=[1,0,Math.tan(this.angle.Angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(b){this.base=d.Type.SkewBase;this.base(b);this.m=[1,Math.tan(this.angle.Angle.toRadians()),0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(b){for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(b)};
47
- this.applyToPoint=function(b){for(var a=0;a<this.transforms.length;a++)this.transforms[a].applyToPoint(b)};for(var c=a.trim(a.compressSpaces(c)).split(/\s(?=[a-z])/),b=0;b<c.length;b++){var k=c[b].split("(")[0],e=c[b].split("(")[1].replace(")","");this.transforms.push(new this.Type[k](e))}};a.AspectRatio=function(c,d,b,k,e,f,g,h,j,l){var d=a.compressSpaces(d),d=d.replace(/^defer\s/,""),o=d.split(" ")[0]||"xMidYMid",d=d.split(" ")[1]||"meet",n=b/k,q=e/f,p=Math.min(n,q),m=Math.max(n,q);d=="meet"&&(k*=
48
- p,f*=p);d=="slice"&&(k*=m,f*=m);j=new a.Property("refX",j);l=new a.Property("refY",l);j.hasValue()&&l.hasValue()?c.translate(-p*j.Length.toPixels("x"),-p*l.Length.toPixels("y")):(o.match(/^xMid/)&&(d=="meet"&&p==q||d=="slice"&&m==q)&&c.translate(b/2-k/2,0),o.match(/YMid$/)&&(d=="meet"&&p==n||d=="slice"&&m==n)&&c.translate(0,e/2-f/2),o.match(/^xMax/)&&(d=="meet"&&p==q||d=="slice"&&m==q)&&c.translate(b-k,0),o.match(/YMax$/)&&(d=="meet"&&p==n||d=="slice"&&m==n)&&c.translate(0,e-f));o=="none"?c.scale(n,
49
- q):d=="meet"?c.scale(p,p):d=="slice"&&c.scale(m,m);c.translate(g==null?0:-g,h==null?0:-h)};a.Element={};a.Element.ElementBase=function(c){this.attributes={};this.styles={};this.children=[];this.attribute=function(b,d){var c=this.attributes[b];if(c!=null)return c;c=new a.Property(b,"");d==!0&&(this.attributes[b]=c);return c};this.style=function(b,d){var c=this.styles[b];if(c!=null)return c;c=this.attribute(b);if(c!=null&&c.hasValue())return c;c=this.parent;if(c!=null&&(c=c.style(b),c!=null&&c.hasValue()))return c;
50
- c=new a.Property(b,"");d==!0&&(this.styles[b]=c);return c};this.render=function(b){if(this.style("display").value!="none"&&this.attribute("visibility").value!="hidden"){b.save();this.setContext(b);if(this.attribute("mask").hasValue()){var a=this.attribute("mask").Definition.getDefinition();a!=null&&a.apply(b,this)}else this.style("filter").hasValue()?(a=this.style("filter").Definition.getDefinition(),a!=null&&a.apply(b,this)):this.renderChildren(b);this.clearContext(b);b.restore()}};this.setContext=
51
- function(){};this.clearContext=function(){};this.renderChildren=function(b){for(var a=0;a<this.children.length;a++)this.children[a].render(b)};this.addChild=function(b,d){var c=b;d&&(c=a.CreateElement(b));c.parent=this;this.children.push(c)};if(c!=null&&c.nodeType==1){for(var d=0;d<c.childNodes.length;d++){var b=c.childNodes[d];b.nodeType==1&&this.addChild(b,!0)}for(d=0;d<c.attributes.length;d++)b=c.attributes[d],this.attributes[b.nodeName]=new a.Property(b.nodeName,b.nodeValue);b=a.Styles[c.nodeName];
52
- if(b!=null)for(var k in b)this.styles[k]=b[k];if(this.attribute("class").hasValue())for(var d=a.compressSpaces(this.attribute("class").value).split(" "),e=0;e<d.length;e++){b=a.Styles["."+d[e]];if(b!=null)for(k in b)this.styles[k]=b[k];b=a.Styles[c.nodeName+"."+d[e]];if(b!=null)for(k in b)this.styles[k]=b[k]}if(this.attribute("style").hasValue()){b=this.attribute("style").value.split(";");for(d=0;d<b.length;d++)a.trim(b[d])!=""&&(c=b[d].split(":"),k=a.trim(c[0]),c=a.trim(c[1]),this.styles[k]=new a.Property(k,
53
- c))}this.attribute("id").hasValue()&&a.Definitions[this.attribute("id").value]==null&&(a.Definitions[this.attribute("id").value]=this)}};a.Element.RenderedElementBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.setContext=function(d){if(this.style("fill").Definition.isUrl()){var b=this.style("fill").Definition.getFillStyle(this);if(b!=null)d.fillStyle=b}else if(this.style("fill").hasValue())b=this.style("fill"),this.style("fill-opacity").hasValue()&&(b=b.Color.addOpacity(this.style("fill-opacity").value)),
54
- d.fillStyle=b.value=="none"?"rgba(0,0,0,0)":b.value;if(this.style("stroke").Definition.isUrl()){if(b=this.style("stroke").Definition.getFillStyle(this),b!=null)d.strokeStyle=b}else if(this.style("stroke").hasValue())b=this.style("stroke"),this.style("stroke-opacity").hasValue()&&(b=b.Color.addOpacity(this.style("stroke-opacity").value)),d.strokeStyle=b.value=="none"?"rgba(0,0,0,0)":b.value;if(this.style("stroke-width").hasValue())d.lineWidth=this.style("stroke-width").Length.toPixels();if(this.style("stroke-linecap").hasValue())d.lineCap=
55
- this.style("stroke-linecap").value;if(this.style("stroke-linejoin").hasValue())d.lineJoin=this.style("stroke-linejoin").value;if(this.style("stroke-miterlimit").hasValue())d.miterLimit=this.style("stroke-miterlimit").value;if(typeof d.font!="undefined")d.font=a.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").Length.toPixels()+"px":"",this.style("font-family").value).toString();
56
- this.attribute("transform").hasValue()&&(new a.Transform(this.attribute("transform").value)).apply(d);this.attribute("clip-path").hasValue()&&(b=this.attribute("clip-path").Definition.getDefinition(),b!=null&&b.apply(d));if(this.style("opacity").hasValue())d.globalAlpha=this.style("opacity").numValue()}};a.Element.RenderedElementBase.prototype=new a.Element.ElementBase;a.Element.PathElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.path=function(d){d!=null&&d.beginPath();
57
- return new a.BoundingBox};this.renderChildren=function(d){this.path(d);a.Mouse.checkPath(this,d);d.fillStyle!=""&&d.fill();d.strokeStyle!=""&&d.stroke();var b=this.getMarkers();if(b!=null){if(this.style("marker-start").Definition.isUrl()){var c=this.style("marker-start").Definition.getDefinition();c.render(d,b[0][0],b[0][1])}if(this.style("marker-mid").Definition.isUrl())for(var c=this.style("marker-mid").Definition.getDefinition(),e=1;e<b.length-1;e++)c.render(d,b[e][0],b[e][1]);this.style("marker-end").Definition.isUrl()&&
58
- (c=this.style("marker-end").Definition.getDefinition(),c.render(d,b[b.length-1][0],b[b.length-1][1]))}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};a.Element.PathElementBase.prototype=new a.Element.RenderedElementBase;a.Element.svg=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseClearContext=this.clearContext;this.clearContext=function(d){this.baseClearContext(d);a.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext;
59
- this.setContext=function(d){d.strokeStyle="rgba(0,0,0,0)";d.lineCap="butt";d.lineJoin="miter";d.miterLimit=4;this.baseSetContext(d);this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&d.translate(this.attribute("x").Length.toPixels("x"),this.attribute("y").Length.toPixels("y"));var b=a.ViewPort.width(),c=a.ViewPort.height();if(typeof this.root=="undefined"&&this.attribute("width").hasValue()&&this.attribute("height").hasValue()){var b=this.attribute("width").Length.toPixels("x"),c=this.attribute("height").Length.toPixels("y"),
60
- e=0,f=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(e=-this.attribute("refX").Length.toPixels("x"),f=-this.attribute("refY").Length.toPixels("y"));d.beginPath();d.moveTo(e,f);d.lineTo(b,f);d.lineTo(b,c);d.lineTo(e,c);d.closePath();d.clip()}a.ViewPort.SetCurrent(b,c);if(this.attribute("viewBox").hasValue()){var e=a.ToNumberArray(this.attribute("viewBox").value),f=e[0],g=e[1],b=e[2],c=e[3];a.AspectRatio(d,this.attribute("preserveAspectRatio").value,a.ViewPort.width(),b,a.ViewPort.height(),
61
- c,f,g,this.attribute("refX").value,this.attribute("refY").value);a.ViewPort.RemoveCurrent();a.ViewPort.SetCurrent(e[2],e[3])}}};a.Element.svg.prototype=new a.Element.RenderedElementBase;a.Element.rect=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(d){var b=this.attribute("x").Length.toPixels("x"),c=this.attribute("y").Length.toPixels("y"),e=this.attribute("width").Length.toPixels("x"),f=this.attribute("height").Length.toPixels("y"),g=this.attribute("rx").Length.toPixels("x"),
62
- h=this.attribute("ry").Length.toPixels("y");this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(h=g);this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(g=h);d!=null&&(d.beginPath(),d.moveTo(b+g,c),d.lineTo(b+e-g,c),d.quadraticCurveTo(b+e,c,b+e,c+h),d.lineTo(b+e,c+f-h),d.quadraticCurveTo(b+e,c+f,b+e-g,c+f),d.lineTo(b+g,c+f),d.quadraticCurveTo(b,c+f,b,c+f-h),d.lineTo(b,c+h),d.quadraticCurveTo(b,c,b+g,c),d.closePath());return new a.BoundingBox(b,c,b+e,c+f)}};a.Element.rect.prototype=
63
- new a.Element.PathElementBase;a.Element.circle=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(d){var b=this.attribute("cx").Length.toPixels("x"),c=this.attribute("cy").Length.toPixels("y"),e=this.attribute("r").Length.toPixels();d!=null&&(d.beginPath(),d.arc(b,c,e,0,Math.PI*2,!0),d.closePath());return new a.BoundingBox(b-e,c-e,b+e,c+e)}};a.Element.circle.prototype=new a.Element.PathElementBase;a.Element.ellipse=function(c){this.base=a.Element.PathElementBase;this.base(c);
64
- this.path=function(d){var b=4*((Math.sqrt(2)-1)/3),c=this.attribute("rx").Length.toPixels("x"),e=this.attribute("ry").Length.toPixels("y"),f=this.attribute("cx").Length.toPixels("x"),g=this.attribute("cy").Length.toPixels("y");d!=null&&(d.beginPath(),d.moveTo(f,g-e),d.bezierCurveTo(f+b*c,g-e,f+c,g-b*e,f+c,g),d.bezierCurveTo(f+c,g+b*e,f+b*c,g+e,f,g+e),d.bezierCurveTo(f-b*c,g+e,f-c,g+b*e,f-c,g),d.bezierCurveTo(f-c,g-b*e,f-b*c,g-e,f,g-e),d.closePath());return new a.BoundingBox(f-c,g-e,f+c,g+e)}};a.Element.ellipse.prototype=
65
- new a.Element.PathElementBase;a.Element.line=function(c){this.base=a.Element.PathElementBase;this.base(c);this.getPoints=function(){return[new a.Point(this.attribute("x1").Length.toPixels("x"),this.attribute("y1").Length.toPixels("y")),new a.Point(this.attribute("x2").Length.toPixels("x"),this.attribute("y2").Length.toPixels("y"))]};this.path=function(d){var b=this.getPoints();d!=null&&(d.beginPath(),d.moveTo(b[0].x,b[0].y),d.lineTo(b[1].x,b[1].y));return new a.BoundingBox(b[0].x,b[0].y,b[1].x,b[1].y)};
66
- this.getMarkers=function(){var a=this.getPoints(),b=a[0].angleTo(a[1]);return[[a[0],b],[a[1],b]]}};a.Element.line.prototype=new a.Element.PathElementBase;a.Element.polyline=function(c){this.base=a.Element.PathElementBase;this.base(c);this.points=a.CreatePath(this.attribute("points").value);this.path=function(d){var b=new a.BoundingBox(this.points[0].x,this.points[0].y);d!=null&&(d.beginPath(),d.moveTo(this.points[0].x,this.points[0].y));for(var c=1;c<this.points.length;c++)b.addPoint(this.points[c].x,
67
- this.points[c].y),d!=null&&d.lineTo(this.points[c].x,this.points[c].y);return b};this.getMarkers=function(){for(var a=[],b=0;b<this.points.length-1;b++)a.push([this.points[b],this.points[b].angleTo(this.points[b+1])]);a.push([this.points[this.points.length-1],a[a.length-1][1]]);return a}};a.Element.polyline.prototype=new a.Element.PathElementBase;a.Element.polygon=function(c){this.base=a.Element.polyline;this.base(c);this.basePath=this.path;this.path=function(a){var b=this.basePath(a);a!=null&&(a.lineTo(this.points[0].x,
68
- this.points[0].y),a.closePath());return b}};a.Element.polygon.prototype=new a.Element.polyline;a.Element.path=function(c){this.base=a.Element.PathElementBase;this.base(c);c=this.attribute("d").value;c=c.replace(/,/gm," ");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");c=c.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([0-9])([+\-])/gm,
69
- "$1 $2");c=c.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");c=c.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");c=a.compressSpaces(c);c=a.trim(c);this.PathParser=new function(d){this.tokens=d.split(" ");this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new a.Point(0,0);this.control=new a.Point(0,0);this.current=new a.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){return this.isEnd()?
70
- !0:this.tokens[this.i+1].match(/^[A-Za-z]$/)!=null};this.isRelativeCommand=function(){return this.command==this.command.toLowerCase()};this.getToken=function(){this.i+=1;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){return this.makeAbsolute(new a.Point(this.getScalar(),this.getScalar()))};this.getAsControlPoint=function(){var b=this.getPoint();
71
- return this.control=b};this.getAsCurrentPoint=function(){var b=this.getPoint();return this.current=b};this.getReflectedControlPoint=function(){return this.previousCommand.toLowerCase()!="c"&&this.previousCommand.toLowerCase()!="s"?this.current:new a.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};this.makeAbsolute=function(b){if(this.isRelativeCommand())b.x=this.current.x+b.x,b.y=this.current.y+b.y;return b};this.addMarker=function(b,a,d){d!=null&&this.angles.length>0&&this.angles[this.angles.length-
72
- 1]==null&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(d));this.addMarkerAngle(b,a==null?null:a.angleTo(b))};this.addMarkerAngle=function(b,a){this.points.push(b);this.angles.push(a)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var b=0;b<this.angles.length;b++)if(this.angles[b]==null)for(var a=b+1;a<this.angles.length;a++)if(this.angles[a]!=null){this.angles[b]=this.angles[a];break}return this.angles}}(c);this.path=function(d){var b=
73
- this.PathParser;b.reset();var c=new a.BoundingBox;for(d!=null&&d.beginPath();!b.isEnd();)switch(b.nextCommand(),b.command.toUpperCase()){case "M":var e=b.getAsCurrentPoint();b.addMarker(e);c.addPoint(e.x,e.y);d!=null&&d.moveTo(e.x,e.y);for(b.start=b.current;!b.isCommandOrEnd();)e=b.getAsCurrentPoint(),b.addMarker(e,b.start),c.addPoint(e.x,e.y),d!=null&&d.lineTo(e.x,e.y);break;case "L":for(;!b.isCommandOrEnd();){var f=b.current,e=b.getAsCurrentPoint();b.addMarker(e,f);c.addPoint(e.x,e.y);d!=null&&
74
- d.lineTo(e.x,e.y)}break;case "H":for(;!b.isCommandOrEnd();)e=new a.Point((b.isRelativeCommand()?b.current.x:0)+b.getScalar(),b.current.y),b.addMarker(e,b.current),b.current=e,c.addPoint(b.current.x,b.current.y),d!=null&&d.lineTo(b.current.x,b.current.y);break;case "V":for(;!b.isCommandOrEnd();)e=new a.Point(b.current.x,(b.isRelativeCommand()?b.current.y:0)+b.getScalar()),b.addMarker(e,b.current),b.current=e,c.addPoint(b.current.x,b.current.y),d!=null&&d.lineTo(b.current.x,b.current.y);break;case "C":for(;!b.isCommandOrEnd();){var g=
75
- b.current,f=b.getPoint(),h=b.getAsControlPoint(),e=b.getAsCurrentPoint();b.addMarker(e,h,f);c.addBezierCurve(g.x,g.y,f.x,f.y,h.x,h.y,e.x,e.y);d!=null&&d.bezierCurveTo(f.x,f.y,h.x,h.y,e.x,e.y)}break;case "S":for(;!b.isCommandOrEnd();)g=b.current,f=b.getReflectedControlPoint(),h=b.getAsControlPoint(),e=b.getAsCurrentPoint(),b.addMarker(e,h,f),c.addBezierCurve(g.x,g.y,f.x,f.y,h.x,h.y,e.x,e.y),d!=null&&d.bezierCurveTo(f.x,f.y,h.x,h.y,e.x,e.y);break;case "Q":for(;!b.isCommandOrEnd();)g=b.current,h=b.getAsControlPoint(),
76
- e=b.getAsCurrentPoint(),b.addMarker(e,h,h),c.addQuadraticCurve(g.x,g.y,h.x,h.y,e.x,e.y),d!=null&&d.quadraticCurveTo(h.x,h.y,e.x,e.y);break;case "T":for(;!b.isCommandOrEnd();)g=b.current,h=b.getReflectedControlPoint(),b.control=h,e=b.getAsCurrentPoint(),b.addMarker(e,h,h),c.addQuadraticCurve(g.x,g.y,h.x,h.y,e.x,e.y),d!=null&&d.quadraticCurveTo(h.x,h.y,e.x,e.y);break;case "A":for(;!b.isCommandOrEnd();){var g=b.current,j=b.getScalar(),l=b.getScalar(),f=b.getScalar()*(Math.PI/180),o=b.getScalar(),h=b.getScalar(),
77
- e=b.getAsCurrentPoint(),n=new a.Point(Math.cos(f)*(g.x-e.x)/2+Math.sin(f)*(g.y-e.y)/2,-Math.sin(f)*(g.x-e.x)/2+Math.cos(f)*(g.y-e.y)/2),q=Math.pow(n.x,2)/Math.pow(j,2)+Math.pow(n.y,2)/Math.pow(l,2);q>1&&(j*=Math.sqrt(q),l*=Math.sqrt(q));o=(o==h?-1:1)*Math.sqrt((Math.pow(j,2)*Math.pow(l,2)-Math.pow(j,2)*Math.pow(n.y,2)-Math.pow(l,2)*Math.pow(n.x,2))/(Math.pow(j,2)*Math.pow(n.y,2)+Math.pow(l,2)*Math.pow(n.x,2)));isNaN(o)&&(o=0);var p=new a.Point(o*j*n.y/l,o*-l*n.x/j),g=new a.Point((g.x+e.x)/2+Math.cos(f)*
78
- p.x-Math.sin(f)*p.y,(g.y+e.y)/2+Math.sin(f)*p.x+Math.cos(f)*p.y),m=function(b,a){return(b[0]*a[0]+b[1]*a[1])/(Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2))*Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)))},t=function(b,a){return(b[0]*a[1]<b[1]*a[0]?-1:1)*Math.acos(m(b,a))},o=t([1,0],[(n.x-p.x)/j,(n.y-p.y)/l]),q=[(n.x-p.x)/j,(n.y-p.y)/l],p=[(-n.x-p.x)/j,(-n.y-p.y)/l],n=t(q,p);if(m(q,p)<=-1)n=Math.PI;m(q,p)>=1&&(n=0);h==0&&n>0&&(n-=2*Math.PI);h==1&&n<0&&(n+=2*Math.PI);q=new a.Point(g.x-j*Math.cos((o+n)/
79
- 2),g.y-l*Math.sin((o+n)/2));b.addMarkerAngle(q,(o+n)/2+(h==0?1:-1)*Math.PI/2);b.addMarkerAngle(e,n+(h==0?1:-1)*Math.PI/2);c.addPoint(e.x,e.y);d!=null&&(m=j>l?j:l,e=j>l?1:j/l,j=j>l?l/j:1,d.translate(g.x,g.y),d.rotate(f),d.scale(e,j),d.arc(0,0,m,o,o+n,1-h),d.scale(1/e,1/j),d.rotate(-f),d.translate(-g.x,-g.y))}break;case "Z":d!=null&&d.closePath(),b.current=b.start}return c};this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],e=0;e<a.length;e++)c.push([a[e],
80
- b[e]]);return c}};a.Element.path.prototype=new a.Element.PathElementBase;a.Element.pattern=function(c){this.base=a.Element.ElementBase;this.base(c);this.createPattern=function(d){var b=new a.Element.svg;b.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);b.attributes.x=new a.Property("x",this.attribute("x").value);b.attributes.y=new a.Property("y",this.attribute("y").value);b.attributes.width=new a.Property("width",this.attribute("width").value);b.attributes.height=new a.Property("height",
81
- this.attribute("height").value);b.children=this.children;var c=document.createElement("canvas");c.width=this.attribute("width").Length.toPixels("x");c.height=this.attribute("height").Length.toPixels("y");b.render(c.getContext("2d"));return d.createPattern(c,"repeat")}};a.Element.pattern.prototype=new a.Element.ElementBase;a.Element.marker=function(c){this.base=a.Element.ElementBase;this.base(c);this.baseRender=this.render;this.render=function(d,b,c){d.translate(b.x,b.y);this.attribute("orient").valueOrDefault("auto")==
82
- "auto"&&d.rotate(c);this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&d.scale(d.lineWidth,d.lineWidth);d.save();var e=new a.Element.svg;e.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);e.attributes.refX=new a.Property("refX",this.attribute("refX").value);e.attributes.refY=new a.Property("refY",this.attribute("refY").value);e.attributes.width=new a.Property("width",this.attribute("markerWidth").value);e.attributes.height=new a.Property("height",
83
- this.attribute("markerHeight").value);e.attributes.fill=new a.Property("fill",this.attribute("fill").valueOrDefault("black"));e.attributes.stroke=new a.Property("stroke",this.attribute("stroke").valueOrDefault("none"));e.children=this.children;e.render(d);d.restore();this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&d.scale(1/d.lineWidth,1/d.lineWidth);this.attribute("orient").valueOrDefault("auto")=="auto"&&d.rotate(-c);d.translate(-b.x,-b.y)}};a.Element.marker.prototype=
84
- new a.Element.ElementBase;a.Element.defs=function(c){this.base=a.Element.ElementBase;this.base(c);this.render=function(){}};a.Element.defs.prototype=new a.Element.ElementBase;a.Element.GradientBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox");this.stops=[];for(c=0;c<this.children.length;c++)this.stops.push(this.children[c]);this.getGradient=function(){};this.createGradient=function(d,b){var c=this;this.attribute("xlink:href").hasValue()&&
85
- (c=this.attribute("xlink:href").Definition.getDefinition());for(var e=this.getGradient(d,b),f=0;f<c.stops.length;f++)e.addColorStop(c.stops[f].offset,c.stops[f].color);if(this.attribute("gradientTransform").hasValue()){c=a.ViewPort.viewPorts[0];f=new a.Element.rect;f.attributes.x=new a.Property("x",-a.MAX_VIRTUAL_PIXELS/3);f.attributes.y=new a.Property("y",-a.MAX_VIRTUAL_PIXELS/3);f.attributes.width=new a.Property("width",a.MAX_VIRTUAL_PIXELS);f.attributes.height=new a.Property("height",a.MAX_VIRTUAL_PIXELS);
86
- var g=new a.Element.g;g.attributes.transform=new a.Property("transform",this.attribute("gradientTransform").value);g.children=[f];f=new a.Element.svg;f.attributes.x=new a.Property("x",0);f.attributes.y=new a.Property("y",0);f.attributes.width=new a.Property("width",c.width);f.attributes.height=new a.Property("height",c.height);f.children=[g];g=document.createElement("canvas");g.width=c.width;g.height=c.height;c=g.getContext("2d");c.fillStyle=e;f.render(c);return c.createPattern(g,"no-repeat")}return e}};
87
- a.Element.GradientBase.prototype=new a.Element.ElementBase;a.Element.linearGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.getGradient=function(a,b){var c=b.getBoundingBox(),e=this.gradientUnits=="objectBoundingBox"?c.x()+c.width()*this.attribute("x1").numValue():this.attribute("x1").Length.toPixels("x"),f=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("y1").numValue():this.attribute("y1").Length.toPixels("y"),g=this.gradientUnits=="objectBoundingBox"?
88
- c.x()+c.width()*this.attribute("x2").numValue():this.attribute("x2").Length.toPixels("x"),c=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("y2").numValue():this.attribute("y2").Length.toPixels("y");return a.createLinearGradient(e,f,g,c)}};a.Element.linearGradient.prototype=new a.Element.GradientBase;a.Element.radialGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.getGradient=function(a,b){var c=b.getBoundingBox(),e=this.gradientUnits=="objectBoundingBox"?
89
- c.x()+c.width()*this.attribute("cx").numValue():this.attribute("cx").Length.toPixels("x"),f=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("cy").numValue():this.attribute("cy").Length.toPixels("y"),g=e,h=f;this.attribute("fx").hasValue()&&(g=this.gradientUnits=="objectBoundingBox"?c.x()+c.width()*this.attribute("fx").numValue():this.attribute("fx").Length.toPixels("x"));this.attribute("fy").hasValue()&&(h=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("fy").numValue():
90
- this.attribute("fy").Length.toPixels("y"));c=this.gradientUnits=="objectBoundingBox"?(c.width()+c.height())/2*this.attribute("r").numValue():this.attribute("r").Length.toPixels();return a.createRadialGradient(g,h,0,e,f,c)}};a.Element.radialGradient.prototype=new a.Element.GradientBase;a.Element.stop=function(c){this.base=a.Element.ElementBase;this.base(c);this.offset=this.attribute("offset").numValue();c=this.style("stop-color");this.style("stop-opacity").hasValue()&&(c=c.Color.addOpacity(this.style("stop-opacity").value));
91
- this.color=c.value};a.Element.stop.prototype=new a.Element.ElementBase;a.Element.AnimateBase=function(c){this.base=a.Element.ElementBase;this.base(c);a.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").Time.toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").Time.toMilliseconds();this.getProperty=function(){var a=this.attribute("attributeType").value,b=this.attribute("attributeName").value;return a=="CSS"?this.parent.style(b,!0):this.parent.attribute(b,!0)};this.initialValue=
92
- null;this.removed=!1;this.calcValue=function(){return""};this.update=function(a){if(this.initialValue==null)this.initialValue=this.getProperty().value;if(this.duration>this.maxDuration)if(this.attribute("repeatCount").value=="indefinite")this.duration=0;else return this.attribute("fill").valueOrDefault("remove")=="remove"&&!this.removed?(this.removed=!0,this.getProperty().value=this.initialValue,!0):!1;this.duration+=a;a=!1;if(this.begin<this.duration)a=this.calcValue(),this.attribute("type").hasValue()&&
93
- (a=this.attribute("type").value+"("+a+")"),this.getProperty().value=a,a=!0;return a};this.progress=function(){return(this.duration-this.begin)/(this.maxDuration-this.begin)}};a.Element.AnimateBase.prototype=new a.Element.ElementBase;a.Element.animate=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.attribute("from").numValue(),b=this.attribute("to").numValue();return a+(b-a)*this.progress()}};a.Element.animate.prototype=new a.Element.AnimateBase;a.Element.animateColor=
94
- function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=new RGBColor(this.attribute("from").value),b=new RGBColor(this.attribute("to").value);if(a.ok&&b.ok){var c=a.r+(b.r-a.r)*this.progress(),e=a.g+(b.g-a.g)*this.progress(),a=a.b+(b.b-a.b)*this.progress();return"rgb("+parseInt(c,10)+","+parseInt(e,10)+","+parseInt(a,10)+")"}return this.attribute("from").value}};a.Element.animateColor.prototype=new a.Element.AnimateBase;a.Element.animateTransform=function(c){this.base=
95
- a.Element.animate;this.base(c)};a.Element.animateTransform.prototype=new a.Element.animate;a.Element.font=function(c){this.base=a.Element.ElementBase;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isArabic=this.isRTL=!1;this.missingGlyph=this.fontFace=null;this.glyphs=[];for(c=0;c<this.children.length;c++){var d=this.children[c];if(d.type=="font-face")this.fontFace=d,d.style("font-family").hasValue()&&(a.Definitions[d.style("font-family").value]=this);else if(d.type=="missing-glyph")this.missingGlyph=
96
- d;else if(d.type=="glyph")d.arabicForm!=""?(this.isArabic=this.isRTL=!0,typeof this.glyphs[d.unicode]=="undefined"&&(this.glyphs[d.unicode]=[]),this.glyphs[d.unicode][d.arabicForm]=d):this.glyphs[d.unicode]=d}};a.Element.font.prototype=new a.Element.ElementBase;a.Element.fontface=function(c){this.base=a.Element.ElementBase;this.base(c);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};a.Element.fontface.prototype=
97
- new a.Element.ElementBase;a.Element.missingglyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=0};a.Element.missingglyph.prototype=new a.Element.path;a.Element.glyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};a.Element.glyph.prototype=new a.Element.path;a.Element.text=function(c){this.base=a.Element.RenderedElementBase;
98
- this.base(c);if(c!=null){this.children=[];for(var d=0;d<c.childNodes.length;d++){var b=c.childNodes[d];b.nodeType==1?this.addChild(b,!0):b.nodeType==3&&this.addChild(new a.Element.tspan(b),!1)}}this.baseSetContext=this.setContext;this.setContext=function(b){this.baseSetContext(b);if(this.style("dominant-baseline").hasValue())b.textBaseline=this.style("dominant-baseline").value;if(this.style("alignment-baseline").hasValue())b.textBaseline=this.style("alignment-baseline").value};this.renderChildren=
99
- function(b){for(var a=this.style("text-anchor").valueOrDefault("start"),c=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),h=0;h<this.children.length;h++){var j=this.children[h];j.attribute("x").hasValue()?j.x=j.attribute("x").Length.toPixels("x"):(j.attribute("dx").hasValue()&&(c+=j.attribute("dx").Length.toPixels("x")),j.x=c);c=j.measureText(b);if(a!="start"&&(h==0||j.attribute("x").hasValue())){for(var l=c,o=h+1;o<this.children.length;o++){var n=this.children[o];
100
- if(n.attribute("x").hasValue())break;l+=n.measureText(b)}j.x-=a=="end"?l:l/2}c=j.x+c;j.attribute("y").hasValue()?j.y=j.attribute("y").Length.toPixels("y"):(j.attribute("dy").hasValue()&&(d+=j.attribute("dy").Length.toPixels("y")),j.y=d);d=j.y;j.render(b)}}};a.Element.text.prototype=new a.Element.RenderedElementBase;a.Element.TextElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getGlyph=function(a,b,c){var e=b[c],f=null;if(a.isArabic){var g="isolated";if((c==0||b[c-
101
- 1]==" ")&&c<b.length-2&&b[c+1]!=" ")g="terminal";c>0&&b[c-1]!=" "&&c<b.length-2&&b[c+1]!=" "&&(g="medial");if(c>0&&b[c-1]!=" "&&(c==b.length-1||b[c+1]==" "))g="initial";typeof a.glyphs[e]!="undefined"&&(f=a.glyphs[e][g],f==null&&a.glyphs[e].type=="glyph"&&(f=a.glyphs[e]))}else f=a.glyphs[e];if(f==null)f=a.missingGlyph;return f};this.renderChildren=function(c){var b=this.parent.style("font-family").Definition.getDefinition();if(b!=null){var k=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize),
102
- e=this.parent.style("font-style").valueOrDefault(a.Font.Parse(a.ctx.font).fontStyle),f=this.getText();b.isRTL&&(f=f.split("").reverse().join(""));for(var g=a.ToNumberArray(this.parent.attribute("dx").value),h=0;h<f.length;h++){var j=this.getGlyph(b,f,h),l=k/b.fontFace.unitsPerEm;c.translate(this.x,this.y);c.scale(l,-l);var o=c.lineWidth;c.lineWidth=c.lineWidth*b.fontFace.unitsPerEm/k;e=="italic"&&c.transform(1,0,0.4,1,0,0);j.render(c);e=="italic"&&c.transform(1,0,-0.4,1,0,0);c.lineWidth=o;c.scale(1/
103
- l,-1/l);c.translate(-this.x,-this.y);this.x+=k*(j.horizAdvX||b.horizAdvX)/b.fontFace.unitsPerEm;typeof g[h]!="undefined"&&!isNaN(g[h])&&(this.x+=g[h])}}else c.strokeStyle!=""&&c.strokeText(a.compressSpaces(this.getText()),this.x,this.y),c.fillStyle!=""&&c.fillText(a.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureText=function(c){var b=this.parent.style("font-family").Definition.getDefinition();if(b!=null){var c=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize),
104
- k=0,e=this.getText();b.isRTL&&(e=e.split("").reverse().join(""));for(var f=a.ToNumberArray(this.parent.attribute("dx").value),g=0;g<e.length;g++){var h=this.getGlyph(b,e,g);k+=(h.horizAdvX||b.horizAdvX)*c/b.fontFace.unitsPerEm;typeof f[g]!="undefined"&&!isNaN(f[g])&&(k+=f[g])}return k}b=a.compressSpaces(this.getText());if(!c.measureText)return b.length*10;c.save();this.setContext(c);b=c.measureText(b).width;c.restore();return b}};a.Element.TextElementBase.prototype=new a.Element.RenderedElementBase;
105
- a.Element.tspan=function(c){this.base=a.Element.TextElementBase;this.base(c);this.text=c.nodeType==3?c.nodeValue:c.childNodes.length>0?c.childNodes[0].nodeValue:c.text;this.getText=function(){return this.text}};a.Element.tspan.prototype=new a.Element.TextElementBase;a.Element.tref=function(c){this.base=a.Element.TextElementBase;this.base(c);this.getText=function(){var a=this.attribute("xlink:href").Definition.getDefinition();if(a!=null)return a.children[0].getText()}};a.Element.tref.prototype=new a.Element.TextElementBase;
106
- a.Element.a=function(c){this.base=a.Element.TextElementBase;this.base(c);this.hasText=!0;for(var d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeType!=3)this.hasText=!1;this.text=this.hasText?c.childNodes[0].nodeValue:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(b){if(this.hasText){this.baseRenderChildren(b);var c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);a.Mouse.checkBoundingBox(this,new a.BoundingBox(this.x,
107
- this.y-c.Length.toPixels("y"),this.x+this.measureText(b),this.y))}else c=new a.Element.g,c.children=this.children,c.parent=this,c.render(b)};this.onclick=function(){window.open(this.attribute("xlink:href").value)};this.onmousemove=function(){a.ctx.canvas.style.cursor="pointer"}};a.Element.a.prototype=new a.Element.TextElementBase;a.Element.image=function(c){this.base=a.Element.RenderedElementBase;this.base(c);a.Images.push(this);this.img=document.createElement("img");this.loaded=!1;var d=this;this.img.onload=
108
- function(){d.loaded=!0};this.img.src=this.attribute("xlink:href").value;this.renderChildren=function(b){var c=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),f=this.attribute("width").Length.toPixels("x"),g=this.attribute("height").Length.toPixels("y");f==0||g==0||(b.save(),b.translate(c,d),a.AspectRatio(b,this.attribute("preserveAspectRatio").value,f,this.img.width,g,this.img.height,0,0),b.drawImage(this.img,0,0),b.restore())}};a.Element.image.prototype=new a.Element.RenderedElementBase;
109
- a.Element.g=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getBoundingBox=function(){for(var c=new a.BoundingBox,b=0;b<this.children.length;b++)c.addBoundingBox(this.children[b].getBoundingBox());return c}};a.Element.g.prototype=new a.Element.RenderedElementBase;a.Element.symbol=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(c){this.baseSetContext(c);if(this.attribute("viewBox").hasValue()){var b=
110
- a.ToNumberArray(this.attribute("viewBox").value),k=b[0],e=b[1];width=b[2];height=b[3];a.AspectRatio(c,this.attribute("preserveAspectRatio").value,this.attribute("width").Length.toPixels("x"),width,this.attribute("height").Length.toPixels("y"),height,k,e);a.ViewPort.SetCurrent(b[2],b[3])}}};a.Element.symbol.prototype=new a.Element.RenderedElementBase;a.Element.style=function(c){this.base=a.Element.ElementBase;this.base(c);for(var c=c.childNodes[0].nodeValue+(c.childNodes.length>1?c.childNodes[1].nodeValue:
111
- ""),c=c.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,""),c=a.compressSpaces(c),c=c.split("}"),d=0;d<c.length;d++)if(a.trim(c[d])!="")for(var b=c[d].split("{"),k=b[0].split(","),b=b[1].split(";"),e=0;e<k.length;e++){var f=a.trim(k[e]);if(f!=""){for(var g={},h=0;h<b.length;h++){var j=b[h].indexOf(":"),l=b[h].substr(0,j),j=b[h].substr(j+1,b[h].length-j);l!=null&&j!=null&&(g[a.trim(l)]=new a.Property(a.trim(l),a.trim(j)))}a.Styles[f]=g;if(f=="@font-face"){f=g["font-family"].value.replace(/"/g,
112
- "");g=g.src.value.split(",");for(h=0;h<g.length;h++)if(g[h].indexOf('format("svg")')>0){l=g[h].indexOf("url");j=g[h].indexOf(")",l);l=g[h].substr(l+5,j-l-6);l=a.parseXml(a.ajax(l)).getElementsByTagName("font");for(j=0;j<l.length;j++){var o=a.CreateElement(l[j]);a.Definitions[f]=o}}}}}};a.Element.style.prototype=new a.Element.ElementBase;a.Element.use=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a);
113
- this.attribute("x").hasValue()&&a.translate(this.attribute("x").Length.toPixels("x"),0);this.attribute("y").hasValue()&&a.translate(0,this.attribute("y").Length.toPixels("y"))};this.getDefinition=function(){var a=this.attribute("xlink:href").Definition.getDefinition();if(this.attribute("width").hasValue())a.attribute("width",!0).value=this.attribute("width").value;if(this.attribute("height").hasValue())a.attribute("height",!0).value=this.attribute("height").value;return a};this.path=function(a){var b=
114
- this.getDefinition();b!=null&&b.path(a)};this.renderChildren=function(a){var b=this.getDefinition();b!=null&&b.render(a)}};a.Element.use.prototype=new a.Element.RenderedElementBase;a.Element.mask=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,b){var c=this.attribute("x").Length.toPixels("x"),e=this.attribute("y").Length.toPixels("y"),f=this.attribute("width").Length.toPixels("x"),g=this.attribute("height").Length.toPixels("y"),h=b.attribute("mask").value;b.attribute("mask").value=
115
- "";var j=document.createElement("canvas");j.width=c+f;j.height=e+g;var l=j.getContext("2d");this.renderChildren(l);var o=document.createElement("canvas");o.width=c+f;o.height=e+g;var n=o.getContext("2d");b.render(n);n.globalCompositeOperation="destination-in";n.fillStyle=l.createPattern(j,"no-repeat");n.fillRect(0,0,c+f,e+g);a.fillStyle=n.createPattern(o,"no-repeat");a.fillRect(0,0,c+f,e+g);b.attribute("mask").value=h};this.render=function(){}};a.Element.mask.prototype=new a.Element.ElementBase;a.Element.clipPath=
116
- function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a){for(var b=0;b<this.children.length;b++)this.children[b].path&&(this.children[b].path(a),a.clip())};this.render=function(){}};a.Element.clipPath.prototype=new a.Element.ElementBase;a.Element.filter=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,b){var c=b.getBoundingBox(),e=this.attribute("x").Length.toPixels("x"),f=this.attribute("y").Length.toPixels("y");if(e==0||f==0)e=c.x1,f=c.y1;var g=
117
- this.attribute("width").Length.toPixels("x"),h=this.attribute("height").Length.toPixels("y");if(g==0||h==0)g=c.width(),h=c.height();c=b.style("filter").value;b.style("filter").value="";var j=0.2*g,l=0.2*h,o=document.createElement("canvas");o.width=g+2*j;o.height=h+2*l;var n=o.getContext("2d");n.translate(-e+j,-f+l);b.render(n);for(var q=0;q<this.children.length;q++)this.children[q].apply(n,0,0,g+2*j,h+2*l);a.drawImage(o,0,0,g+2*j,h+2*l,e-j,f-l,g+2*j,h+2*l);b.style("filter",!0).value=c};this.render=
118
- function(){}};a.Element.filter.prototype=new a.Element.ElementBase;a.Element.feGaussianBlur=function(c){function d(a,c,d,f,g){for(var h=0;h<g;h++)for(var j=0;j<f;j++)for(var l=a[h*f*4+j*4+3]/255,o=0;o<4;o++){for(var n=d[0]*(l==0?255:a[h*f*4+j*4+o])*(l==0||o==3?1:l),q=1;q<d.length;q++){var p=Math.max(j-q,0),m=a[h*f*4+p*4+3]/255,p=Math.min(j+q,f-1),p=a[h*f*4+p*4+3]/255,t=d[q],r;m==0?r=255:(r=Math.max(j-q,0),r=a[h*f*4+r*4+o]);m=r*(m==0||o==3?1:m);p==0?r=255:(r=Math.min(j+q,f-1),r=a[h*f*4+r*4+o]);n+=
119
- t*(m+r*(p==0||o==3?1:p))}c[j*g*4+h*4+o]=n}}this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,e,f,g){var e=this.attribute("stdDeviation").numValue(),c=a.getImageData(0,0,f,g),e=Math.max(e,0.01),h=Math.ceil(e*4)+1;mask=[];for(var j=0;j<h;j++)mask[j]=Math.exp(-0.5*(j/e)*(j/e));e=mask;h=0;for(j=1;j<e.length;j++)h+=Math.abs(e[j]);h=2*h+Math.abs(e[0]);for(j=0;j<e.length;j++)e[j]/=h;tmp=[];d(c.data,tmp,e,f,g);d(tmp,c.data,e,g,f);a.clearRect(0,0,f,g);a.putImageData(c,0,0)}};a.Element.filter.prototype=
120
- new a.Element.feGaussianBlur;a.Element.title=function(){};a.Element.title.prototype=new a.Element.ElementBase;a.Element.desc=function(){};a.Element.desc.prototype=new a.Element.ElementBase;a.Element.MISSING=function(a){console.log("ERROR: Element '"+a.nodeName+"' not yet implemented.")};a.Element.MISSING.prototype=new a.Element.ElementBase;a.CreateElement=function(c){var d=c.nodeName.replace(/^[^:]+:/,""),d=d.replace(/\-/g,""),b=null,b=typeof a.Element[d]!="undefined"?new a.Element[d](c):new a.Element.MISSING(c);
121
- b.type=c.nodeName;return b};a.load=function(c,d){a.loadXml(c,a.ajax(d))};a.loadXml=function(c,d){a.loadXmlDoc(c,a.parseXml(d))};a.loadXmlDoc=function(c,d){a.init(c);var b=function(a){for(var b=c.canvas;b;)a.x-=b.offsetLeft,a.y-=b.offsetTop,b=b.offsetParent;window.scrollX&&(a.x+=window.scrollX);window.scrollY&&(a.y+=window.scrollY);return a};if(a.opts.ignoreMouse!=!0)c.canvas.onclick=function(c){c=b(new a.Point(c!=null?c.clientX:event.clientX,c!=null?c.clientY:event.clientY));a.Mouse.onclick(c.x,c.y)},
122
- c.canvas.onmousemove=function(c){c=b(new a.Point(c!=null?c.clientX:event.clientX,c!=null?c.clientY:event.clientY));a.Mouse.onmousemove(c.x,c.y)};var k=a.CreateElement(d.documentElement),e=k.root=!0,f=function(){a.ViewPort.Clear();c.canvas.parentNode&&a.ViewPort.SetCurrent(c.canvas.parentNode.clientWidth,c.canvas.parentNode.clientHeight);if(a.opts.ignoreDimensions!=!0){if(k.style("width").hasValue())c.canvas.width=k.style("width").Length.toPixels("x"),c.canvas.style.width=c.canvas.width+"px";if(k.style("height").hasValue())c.canvas.height=
123
- k.style("height").Length.toPixels("y"),c.canvas.style.height=c.canvas.height+"px"}var b=c.canvas.clientWidth||c.canvas.width,d=c.canvas.clientHeight||c.canvas.height;a.ViewPort.SetCurrent(b,d);if(a.opts!=null&&a.opts.offsetX!=null)k.attribute("x",!0).value=a.opts.offsetX;if(a.opts!=null&&a.opts.offsetY!=null)k.attribute("y",!0).value=a.opts.offsetY;if(a.opts!=null&&a.opts.scaleWidth!=null&&a.opts.scaleHeight!=null){var f=1,g=1;k.attribute("width").hasValue()&&(f=k.attribute("width").Length.toPixels("x")/
124
- a.opts.scaleWidth);k.attribute("height").hasValue()&&(g=k.attribute("height").Length.toPixels("y")/a.opts.scaleHeight);k.attribute("width",!0).value=a.opts.scaleWidth;k.attribute("height",!0).value=a.opts.scaleHeight;k.attribute("viewBox",!0).value="0 0 "+b*f+" "+d*g;k.attribute("preserveAspectRatio",!0).value="none"}a.opts.ignoreClear!=!0&&c.clearRect(0,0,b,d);k.render(c);e&&(e=!1,a.opts!=null&&typeof a.opts.renderCallback=="function"&&a.opts.renderCallback())},g=!0;a.ImagesLoaded()&&(g=!1,f());
125
- a.intervalID=setInterval(function(){var b=!1;g&&a.ImagesLoaded()&&(g=!1,b=!0);a.opts.ignoreMouse!=!0&&(b|=a.Mouse.hasEvents());if(a.opts.ignoreAnimation!=!0)for(var c=0;c<a.Animations.length;c++)b|=a.Animations[c].update(1E3/a.FRAMERATE);a.opts!=null&&typeof a.opts.forceRedraw=="function"&&a.opts.forceRedraw()==!0&&(b=!0);b&&(f(),a.Mouse.runEvents())},1E3/a.FRAMERATE)};a.stop=function(){a.intervalID&&clearInterval(a.intervalID)};a.Mouse=new function(){this.events=[];this.hasEvents=function(){return this.events.length!=
126
- 0};this.onclick=function(a,d){this.events.push({type:"onclick",x:a,y:d,run:function(a){if(a.onclick)a.onclick()}})};this.onmousemove=function(a,d){this.events.push({type:"onmousemove",x:a,y:d,run:function(a){if(a.onmousemove)a.onmousemove()}})};this.eventElements=[];this.checkPath=function(a,d){for(var b=0;b<this.events.length;b++){var k=this.events[b];d.isPointInPath&&d.isPointInPath(k.x,k.y)&&(this.eventElements[b]=a)}};this.checkBoundingBox=function(a,d){for(var b=0;b<this.events.length;b++){var k=
127
- this.events[b];d.isPointInBox(k.x,k.y)&&(this.eventElements[b]=a)}};this.runEvents=function(){a.ctx.canvas.style.cursor="";for(var c=0;c<this.events.length;c++)for(var d=this.events[c],b=this.eventElements[c];b;)d.run(b),b=b.parent;this.events=[];this.eventElements=[]}};return a}this.canvg=function(a,c,d){if(a==null&&c==null&&d==null)for(var c=document.getElementsByTagName("svg"),b=0;b<c.length;b++){a=c[b];d=document.createElement("canvas");d.width=a.clientWidth;d.height=a.clientHeight;a.parentNode.insertBefore(d,
128
- a);a.parentNode.removeChild(a);var k=document.createElement("div");k.appendChild(a);canvg(d,k.innerHTML)}else d=d||{},typeof a=="string"&&(a=document.getElementById(a)),a.svg==null?(b=m(),a.svg=b):(b=a.svg,b.stop()),b.opts=d,a=a.getContext("2d"),typeof c.documentElement!="undefined"?b.loadXmlDoc(a,c):c.substr(0,1)=="<"?b.loadXml(a,c):b.load(a,c)}})();
129
- if(CanvasRenderingContext2D)CanvasRenderingContext2D.prototype.drawSvg=function(m,a,c,d,b){canvg(this.canvas,m,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:a,offsetY:c,scaleWidth:d,scaleHeight:b})};
130
- (function(m){var a=m.css,c=m.CanVGRenderer,d=m.SVGRenderer,b=m.extend,k=m.merge,e=m.addEvent,f=m.placeBox,g=m.createElement,h=m.discardElement;b(c.prototype,d.prototype);b(c.prototype,{create:function(a,b,c,d){this.setContainer(b,c,d);this.configure(a)},setContainer:function(a,b,c){var d=a.style,e=a.parentNode,f=d.left,d=d.top,h=a.offsetWidth,k=a.offsetHeight,m={visibility:"hidden",position:"absolute"};this.init.apply(this,[a,b,c]);this.canvas=g("canvas",{width:h,height:k},{position:"relative",left:f,
131
- top:d},a);this.ttLine=g("div",null,m,e);this.ttDiv=g("div",null,m,e);this.ttTimer=void 0;this.hiddenSvg=a=g("div",{width:h,height:k},{visibility:"hidden",left:f,top:d},e);a.appendChild(this.box)},configure:function(b){var c=this,d=b.options.tooltip,g=d.borderWidth,h=c.ttDiv,m=d.style,s=c.ttLine,t=parseInt(m.padding,10),m=k(m,{padding:t+"px","background-color":d.backgroundColor,"border-style":"solid","border-width":g+"px","border-radius":d.borderRadius+"px"});d.shadow&&(m=k(m,{"box-shadow":"1px 1px 3px gray",
132
- "-webkit-box-shadow":"1px 1px 3px gray"}));a(h,m);a(s,{"border-left":"1px solid darkgray"});e(b,"tooltipRefresh",function(d){var e=b.container,g=e.offsetLeft,k=e.offsetTop;h.innerHTML=d.text;e=f(h.offsetWidth,h.offsetHeight,g,k,e.offsetWidth,e.offsetHeight,{x:d.x,y:d.y},12);a(h,{visibility:"visible",left:e.x+"px",top:e.y+"px","border-color":d.borderColor});a(s,{visibility:"visible",left:g+d.x+"px",top:k+b.plotTop+"px",height:b.plotHeight+"px"});c.ttTimer!==void 0&&clearTimeout(c.ttTimer);c.ttTimer=
133
- setTimeout(function(){a(h,{visibility:"hidden"});a(s,{visibility:"hidden"})},3E3)})},destroy:function(){h(this.canvas);this.ttTimer!==void 0&&clearTimeout(this.ttTimer);h(this.ttLine);h(this.ttDiv);h(this.hiddenSvg);return d.prototype.destroy.apply(this)},color:function(a,b,c){a&&a.linearGradient&&(a=a.stops[a.stops.length-1][1]);return d.prototype.color.call(this,a,b,c)},draw:function(){window.canvg(this.canvas,this.hiddenSvg.innerHTML)}})})(Highcharts);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/modules/exporting.js DELETED
@@ -1,23 +0,0 @@
1
- /*
2
- Highcharts JS v2.2.1 (2012-03-15)
3
- Exporting module
4
-
5
- (c) 2010-2011 Torstein H?nsi
6
-
7
- License: www.highcharts.com/license
8
- */
9
- (function(){function x(a){for(var b=a.length;b--;)typeof a[b]==="number"&&(a[b]=Math.round(a[b])-0.5);return a}var f=Highcharts,y=f.Chart,z=f.addEvent,B=f.removeEvent,r=f.createElement,u=f.discardElement,t=f.css,s=f.merge,k=f.each,n=f.extend,C=Math.max,h=document,D=window,A=h.documentElement.ontouchstart!==void 0,v=f.getOptions();n(v.lang,{downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",exportButtonTitle:"Export to raster or vector image",
10
- printButtonTitle:"Print the chart"});v.navigation={menuStyle:{border:"1px solid #A0A0A0",background:"#FFFFFF"},menuItemStyle:{padding:"0 5px",background:"none",color:"#303030",fontSize:A?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{align:"right",backgroundColor:{linearGradient:[0,0,0,20],stops:[[0.4,"#F7F7F7"],[0.6,"#E3E3E3"]]},borderColor:"#B0B0B0",borderRadius:3,borderWidth:1,height:20,hoverBorderColor:"#909090",hoverSymbolFill:"#81A7CF",hoverSymbolStroke:"#4572A5",
11
- symbolFill:"#E0E0E0",symbolStroke:"#A0A0A0",symbolX:11.5,symbolY:10.5,verticalAlign:"top",width:24,y:10}};v.exporting={type:"image/png",url:"http://export.highcharts.com/",width:800,buttons:{exportButton:{symbol:"exportIcon",x:-10,symbolFill:"#A8BF77",hoverSymbolFill:"#768F3E",_id:"exportButton",_titleKey:"exportButtonTitle",menuItems:[{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",
12
- onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]},printButton:{symbol:"printIcon",x:-36,symbolFill:"#B5C9DF",hoverSymbolFill:"#779ABF",_id:"printButton",_titleKey:"printButtonTitle",onclick:function(){this.print()}}}};n(y.prototype,{getSVG:function(a){var b=this,c,d,e,g=s(b.options,a);if(!h.createElementNS)h.createElementNS=function(a,b){var c=h.createElement(b);c.getBBox=function(){return f.Renderer.prototype.Element.prototype.getBBox.apply({element:c})};
13
- return c};a=r("div",null,{position:"absolute",top:"-9999em",width:b.chartWidth+"px",height:b.chartHeight+"px"},h.body);n(g.chart,{renderTo:a,forExport:!0});g.exporting.enabled=!1;g.chart.plotBackgroundImage=null;g.series=[];k(b.series,function(a){e=s(a.options,{animation:!1,showCheckbox:!1,visible:a.visible});if(!e.isInternal){if(e&&e.marker&&/^url\(/.test(e.marker.symbol))e.marker.symbol="circle";g.series.push(e)}});c=new Highcharts.Chart(g);k(["xAxis","yAxis"],function(a){k(b[a],function(b,d){var e=
14
- c[a][d],g=b.getExtremes(),f=g.userMin,g=g.userMax;(f!==void 0||g!==void 0)&&e.setExtremes(f,g,!0,!1)})});d=c.container.innerHTML;g=null;c.destroy();u(a);d=d.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/isTracker="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/&nbsp;/g,"\u00a0").replace(/&shy;/g,
15
- "\u00ad").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g,'width="$1"').replace(/hc-svg-href="([^"]+)">/g,'xlink:href="$1"/>').replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" ]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(a){return a.toLowerCase()});d=d.replace(/(url\(#highcharts-[0-9]+)&quot;/g,"$1").replace(/&quot;/g,"'");d.match(/ xmlns="/g).length===2&&(d=d.replace(/xmlns="[^"]+"/,
16
- ""));return d},exportChart:function(a,b){var c,d=this.getSVG(s(this.options.exporting.chartOptions,b)),a=s(this.options.exporting,a);c=r("form",{method:"post",action:a.url},{display:"none"},h.body);k(["filename","type","width","svg"],function(b){r("input",{type:"hidden",name:b,value:{filename:a.filename||"chart",type:a.type,width:a.width,svg:d}[b]},null,c)});c.submit();u(c)},print:function(){var a=this,b=a.container,c=[],d=b.parentNode,e=h.body,g=e.childNodes;if(!a.isPrinting)a.isPrinting=!0,k(g,
17
- function(a,b){if(a.nodeType===1)c[b]=a.style.display,a.style.display="none"}),e.appendChild(b),D.print(),setTimeout(function(){d.appendChild(b);k(g,function(a,b){if(a.nodeType===1)a.style.display=c[b]});a.isPrinting=!1},1E3)},contextMenu:function(a,b,c,d,e,g){var i=this,f=i.options.navigation,h=f.menuItemStyle,o=i.chartWidth,p=i.chartHeight,q="cache-"+a,j=i[q],l=C(e,g),m,w;if(!j)i[q]=j=r("div",{className:"highcharts-"+a},{position:"absolute",zIndex:1E3,padding:l+"px"},i.container),m=r("div",null,
18
- n({MozBoxShadow:"3px 3px 10px #888",WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},f.menuStyle),j),w=function(){t(j,{display:"none"})},z(j,"mouseleave",w),k(b,function(a){if(a){var b=r("div",{onmouseover:function(){t(this,f.menuItemHoverStyle)},onmouseout:function(){t(this,h)},innerHTML:a.text||i.options.lang[a.textKey]},n({cursor:"pointer"},h),m);b[A?"ontouchstart":"onclick"]=function(){w();a.onclick.apply(i,arguments)};i.exportDivElements.push(b)}}),i.exportDivElements.push(m,
19
- j),i.exportMenuWidth=j.offsetWidth,i.exportMenuHeight=j.offsetHeight;a={display:"block"};c+i.exportMenuWidth>o?a.right=o-c-e-l+"px":a.left=c-l+"px";d+g+i.exportMenuHeight>p?a.bottom=p-d-l+"px":a.top=d+g-l+"px";t(j,a)},addButton:function(a){function b(){p.attr(l);o.attr(j)}var c=this,d=c.renderer,e=s(c.options.navigation.buttonOptions,a),g=e.onclick,f=e.menuItems,h=e.width,k=e.height,o,p,q,a=e.borderWidth,j={stroke:e.borderColor},l={stroke:e.symbolStroke,fill:e.symbolFill},m=e.symbolSize||12;if(!c.exportDivElements)c.exportDivElements=
20
- [],c.exportSVGElements=[];e.enabled!==!1&&(o=d.rect(0,0,h,k,e.borderRadius,a).align(e,!0).attr(n({fill:e.backgroundColor,"stroke-width":a,zIndex:19},j)).add(),q=d.rect(0,0,h,k,0).align(e).attr({id:e._id,fill:"rgba(255, 255, 255, 0.001)",title:c.options.lang[e._titleKey],zIndex:21}).css({cursor:"pointer"}).on("mouseover",function(){p.attr({stroke:e.hoverSymbolStroke,fill:e.hoverSymbolFill});o.attr({stroke:e.hoverBorderColor})}).on("mouseout",b).on("click",b).add(),f&&(g=function(){b();var a=q.getBBox();
21
- c.contextMenu("export-menu",f,a.x,a.y,h,k)}),q.on("click",function(){g.apply(c,arguments)}),p=d.symbol(e.symbol,e.symbolX-m/2,e.symbolY-m/2,m,m).align(e,!0).attr(n(l,{"stroke-width":e.symbolStrokeWidth||1,zIndex:20})).add(),c.exportSVGElements.push(o,q,p))},destroyExport:function(){var a,b;for(a=0;a<this.exportSVGElements.length;a++)b=this.exportSVGElements[a],b.onclick=b.ontouchstart=null,this.exportSVGElements[a]=b.destroy();for(a=0;a<this.exportDivElements.length;a++)b=this.exportDivElements[a],
22
- B(b,"mouseleave"),this.exportDivElements[a]=b.onmouseout=b.onmouseover=b.ontouchstart=b.onclick=null,u(b)}});f.Renderer.prototype.symbols.exportIcon=function(a,b,c,d){return x(["M",a,b+c,"L",a+c,b+d,a+c,b+d*0.8,a,b+d*0.8,"Z","M",a+c*0.5,b+d*0.8,"L",a+c*0.8,b+d*0.4,a+c*0.4,b+d*0.4,a+c*0.4,b,a+c*0.6,b,a+c*0.6,b+d*0.4,a+c*0.2,b+d*0.4,"Z"])};f.Renderer.prototype.symbols.printIcon=function(a,b,c,d){return x(["M",a,b+d*0.7,"L",a+c,b+d*0.7,a+c,b+d*0.4,a,b+d*0.4,"Z","M",a+c*0.2,b+d*0.4,"L",a+c*0.2,b,a+c*
23
- 0.8,b,a+c*0.8,b+d*0.4,"Z","M",a+c*0.2,b+d*0.7,"L",a,b+d,a+c,b+d,a+c*0.8,b+d*0.7,"Z"])};y.prototype.callbacks.push(function(a){var b,c=a.options.exporting,d=c.buttons;if(c.enabled!==!1){for(b in d)a.addButton(d[b]);z(a,"destroy",a.destroyExport)}})})();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/themes/dark-blue.js DELETED
@@ -1,263 +0,0 @@
1
- /**
2
- * Dark blue theme for Highcharts JS
3
- * @author Torstein Hønsi
4
- */
5
-
6
- Highcharts.theme = {
7
- colors: ["#DDDF0D", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
8
- "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
9
- chart: {
10
- backgroundColor: {
11
- linearGradient: [0, 0, 250, 500],
12
- stops: [
13
- [0, 'rgb(48, 48, 96)'],
14
- [1, 'rgb(0, 0, 0)']
15
- ]
16
- },
17
- borderColor: '#000000',
18
- borderWidth: 2,
19
- className: 'dark-container',
20
- plotBackgroundColor: 'rgba(255, 255, 255, .1)',
21
- plotBorderColor: '#CCCCCC',
22
- plotBorderWidth: 1
23
- },
24
- title: {
25
- style: {
26
- color: '#C0C0C0',
27
- font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
28
- }
29
- },
30
- subtitle: {
31
- style: {
32
- color: '#666666',
33
- font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
34
- }
35
- },
36
- xAxis: {
37
- gridLineColor: '#333333',
38
- gridLineWidth: 1,
39
- labels: {
40
- style: {
41
- color: '#A0A0A0'
42
- }
43
- },
44
- lineColor: '#A0A0A0',
45
- tickColor: '#A0A0A0',
46
- title: {
47
- style: {
48
- color: '#CCC',
49
- fontWeight: 'bold',
50
- fontSize: '12px',
51
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
52
-
53
- }
54
- }
55
- },
56
- yAxis: {
57
- gridLineColor: '#333333',
58
- labels: {
59
- style: {
60
- color: '#A0A0A0'
61
- }
62
- },
63
- lineColor: '#A0A0A0',
64
- minorTickInterval: null,
65
- tickColor: '#A0A0A0',
66
- tickWidth: 1,
67
- title: {
68
- style: {
69
- color: '#CCC',
70
- fontWeight: 'bold',
71
- fontSize: '12px',
72
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
73
- }
74
- }
75
- },
76
- tooltip: {
77
- backgroundColor: 'rgba(0, 0, 0, 0.75)',
78
- style: {
79
- color: '#F0F0F0'
80
- }
81
- },
82
- toolbar: {
83
- itemStyle: {
84
- color: 'silver'
85
- }
86
- },
87
- plotOptions: {
88
- line: {
89
- dataLabels: {
90
- color: '#CCC'
91
- },
92
- marker: {
93
- lineColor: '#333'
94
- }
95
- },
96
- spline: {
97
- marker: {
98
- lineColor: '#333'
99
- }
100
- },
101
- scatter: {
102
- marker: {
103
- lineColor: '#333'
104
- }
105
- },
106
- candlestick: {
107
- lineColor: 'white'
108
- }
109
- },
110
- legend: {
111
- itemStyle: {
112
- font: '9pt Trebuchet MS, Verdana, sans-serif',
113
- color: '#A0A0A0'
114
- },
115
- itemHoverStyle: {
116
- color: '#FFF'
117
- },
118
- itemHiddenStyle: {
119
- color: '#444'
120
- }
121
- },
122
- credits: {
123
- style: {
124
- color: '#666'
125
- }
126
- },
127
- labels: {
128
- style: {
129
- color: '#CCC'
130
- }
131
- },
132
-
133
- navigation: {
134
- buttonOptions: {
135
- backgroundColor: {
136
- linearGradient: [0, 0, 0, 20],
137
- stops: [
138
- [0.4, '#606060'],
139
- [0.6, '#333333']
140
- ]
141
- },
142
- borderColor: '#000000',
143
- symbolStroke: '#C0C0C0',
144
- hoverSymbolStroke: '#FFFFFF'
145
- }
146
- },
147
-
148
- exporting: {
149
- buttons: {
150
- exportButton: {
151
- symbolFill: '#55BE3B'
152
- },
153
- printButton: {
154
- symbolFill: '#7797BE'
155
- }
156
- }
157
- },
158
-
159
- // scroll charts
160
- rangeSelector: {
161
- buttonTheme: {
162
- fill: {
163
- linearGradient: [0, 0, 0, 20],
164
- stops: [
165
- [0.4, '#888'],
166
- [0.6, '#555']
167
- ]
168
- },
169
- stroke: '#000000',
170
- style: {
171
- color: '#CCC',
172
- fontWeight: 'bold'
173
- },
174
- states: {
175
- hover: {
176
- fill: {
177
- linearGradient: [0, 0, 0, 20],
178
- stops: [
179
- [0.4, '#BBB'],
180
- [0.6, '#888']
181
- ]
182
- },
183
- stroke: '#000000',
184
- style: {
185
- color: 'white'
186
- }
187
- },
188
- select: {
189
- fill: {
190
- linearGradient: [0, 0, 0, 20],
191
- stops: [
192
- [0.1, '#000'],
193
- [0.3, '#333']
194
- ]
195
- },
196
- stroke: '#000000',
197
- style: {
198
- color: 'yellow'
199
- }
200
- }
201
- }
202
- },
203
- inputStyle: {
204
- backgroundColor: '#333',
205
- color: 'silver'
206
- },
207
- labelStyle: {
208
- color: 'silver'
209
- }
210
- },
211
-
212
- navigator: {
213
- handles: {
214
- backgroundColor: '#666',
215
- borderColor: '#AAA'
216
- },
217
- outlineColor: '#CCC',
218
- maskFill: 'rgba(16, 16, 16, 0.5)',
219
- series: {
220
- color: '#7798BF',
221
- lineColor: '#A6C7ED'
222
- }
223
- },
224
-
225
- scrollbar: {
226
- barBackgroundColor: {
227
- linearGradient: [0, 0, 0, 20],
228
- stops: [
229
- [0.4, '#888'],
230
- [0.6, '#555']
231
- ]
232
- },
233
- barBorderColor: '#CCC',
234
- buttonArrowColor: '#CCC',
235
- buttonBackgroundColor: {
236
- linearGradient: [0, 0, 0, 20],
237
- stops: [
238
- [0.4, '#888'],
239
- [0.6, '#555']
240
- ]
241
- },
242
- buttonBorderColor: '#CCC',
243
- rifleColor: '#FFF',
244
- trackBackgroundColor: {
245
- linearGradient: [0, 0, 0, 10],
246
- stops: [
247
- [0, '#000'],
248
- [1, '#333']
249
- ]
250
- },
251
- trackBorderColor: '#666'
252
- },
253
-
254
- // special colors for some of the
255
- legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
256
- legendBackgroundColorSolid: 'rgb(35, 35, 70)',
257
- dataLabelsColor: '#444',
258
- textColor: '#C0C0C0',
259
- maskColor: 'rgba(255,255,255,0.3)'
260
- };
261
-
262
- // Apply the theme
263
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/themes/dark-green.js DELETED
@@ -1,263 +0,0 @@
1
- /**
2
- * Dark blue theme for Highcharts JS
3
- * @author Torstein Hønsi
4
- */
5
-
6
- Highcharts.theme = {
7
- colors: ["#DDDF0D", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
8
- "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
9
- chart: {
10
- backgroundColor: {
11
- linearGradient: [0, 0, 250, 500],
12
- stops: [
13
- [0, 'rgb(48, 96, 48)'],
14
- [1, 'rgb(0, 0, 0)']
15
- ]
16
- },
17
- borderColor: '#000000',
18
- borderWidth: 2,
19
- className: 'dark-container',
20
- plotBackgroundColor: 'rgba(255, 255, 255, .1)',
21
- plotBorderColor: '#CCCCCC',
22
- plotBorderWidth: 1
23
- },
24
- title: {
25
- style: {
26
- color: '#C0C0C0',
27
- font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
28
- }
29
- },
30
- subtitle: {
31
- style: {
32
- color: '#666666',
33
- font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
34
- }
35
- },
36
- xAxis: {
37
- gridLineColor: '#333333',
38
- gridLineWidth: 1,
39
- labels: {
40
- style: {
41
- color: '#A0A0A0'
42
- }
43
- },
44
- lineColor: '#A0A0A0',
45
- tickColor: '#A0A0A0',
46
- title: {
47
- style: {
48
- color: '#CCC',
49
- fontWeight: 'bold',
50
- fontSize: '12px',
51
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
52
-
53
- }
54
- }
55
- },
56
- yAxis: {
57
- gridLineColor: '#333333',
58
- labels: {
59
- style: {
60
- color: '#A0A0A0'
61
- }
62
- },
63
- lineColor: '#A0A0A0',
64
- minorTickInterval: null,
65
- tickColor: '#A0A0A0',
66
- tickWidth: 1,
67
- title: {
68
- style: {
69
- color: '#CCC',
70
- fontWeight: 'bold',
71
- fontSize: '12px',
72
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
73
- }
74
- }
75
- },
76
- tooltip: {
77
- backgroundColor: 'rgba(0, 0, 0, 0.75)',
78
- style: {
79
- color: '#F0F0F0'
80
- }
81
- },
82
- toolbar: {
83
- itemStyle: {
84
- color: 'silver'
85
- }
86
- },
87
- plotOptions: {
88
- line: {
89
- dataLabels: {
90
- color: '#CCC'
91
- },
92
- marker: {
93
- lineColor: '#333'
94
- }
95
- },
96
- spline: {
97
- marker: {
98
- lineColor: '#333'
99
- }
100
- },
101
- scatter: {
102
- marker: {
103
- lineColor: '#333'
104
- }
105
- },
106
- candlestick: {
107
- lineColor: 'white'
108
- }
109
- },
110
- legend: {
111
- itemStyle: {
112
- font: '9pt Trebuchet MS, Verdana, sans-serif',
113
- color: '#A0A0A0'
114
- },
115
- itemHoverStyle: {
116
- color: '#FFF'
117
- },
118
- itemHiddenStyle: {
119
- color: '#444'
120
- }
121
- },
122
- credits: {
123
- style: {
124
- color: '#666'
125
- }
126
- },
127
- labels: {
128
- style: {
129
- color: '#CCC'
130
- }
131
- },
132
-
133
- navigation: {
134
- buttonOptions: {
135
- backgroundColor: {
136
- linearGradient: [0, 0, 0, 20],
137
- stops: [
138
- [0.4, '#606060'],
139
- [0.6, '#333333']
140
- ]
141
- },
142
- borderColor: '#000000',
143
- symbolStroke: '#C0C0C0',
144
- hoverSymbolStroke: '#FFFFFF'
145
- }
146
- },
147
-
148
- exporting: {
149
- buttons: {
150
- exportButton: {
151
- symbolFill: '#55BE3B'
152
- },
153
- printButton: {
154
- symbolFill: '#7797BE'
155
- }
156
- }
157
- },
158
-
159
- // scroll charts
160
- rangeSelector: {
161
- buttonTheme: {
162
- fill: {
163
- linearGradient: [0, 0, 0, 20],
164
- stops: [
165
- [0.4, '#888'],
166
- [0.6, '#555']
167
- ]
168
- },
169
- stroke: '#000000',
170
- style: {
171
- color: '#CCC',
172
- fontWeight: 'bold'
173
- },
174
- states: {
175
- hover: {
176
- fill: {
177
- linearGradient: [0, 0, 0, 20],
178
- stops: [
179
- [0.4, '#BBB'],
180
- [0.6, '#888']
181
- ]
182
- },
183
- stroke: '#000000',
184
- style: {
185
- color: 'white'
186
- }
187
- },
188
- select: {
189
- fill: {
190
- linearGradient: [0, 0, 0, 20],
191
- stops: [
192
- [0.1, '#000'],
193
- [0.3, '#333']
194
- ]
195
- },
196
- stroke: '#000000',
197
- style: {
198
- color: 'yellow'
199
- }
200
- }
201
- }
202
- },
203
- inputStyle: {
204
- backgroundColor: '#333',
205
- color: 'silver'
206
- },
207
- labelStyle: {
208
- color: 'silver'
209
- }
210
- },
211
-
212
- navigator: {
213
- handles: {
214
- backgroundColor: '#666',
215
- borderColor: '#AAA'
216
- },
217
- outlineColor: '#CCC',
218
- maskFill: 'rgba(16, 16, 16, 0.5)',
219
- series: {
220
- color: '#7798BF',
221
- lineColor: '#A6C7ED'
222
- }
223
- },
224
-
225
- scrollbar: {
226
- barBackgroundColor: {
227
- linearGradient: [0, 0, 0, 20],
228
- stops: [
229
- [0.4, '#888'],
230
- [0.6, '#555']
231
- ]
232
- },
233
- barBorderColor: '#CCC',
234
- buttonArrowColor: '#CCC',
235
- buttonBackgroundColor: {
236
- linearGradient: [0, 0, 0, 20],
237
- stops: [
238
- [0.4, '#888'],
239
- [0.6, '#555']
240
- ]
241
- },
242
- buttonBorderColor: '#CCC',
243
- rifleColor: '#FFF',
244
- trackBackgroundColor: {
245
- linearGradient: [0, 0, 0, 10],
246
- stops: [
247
- [0, '#000'],
248
- [1, '#333']
249
- ]
250
- },
251
- trackBorderColor: '#666'
252
- },
253
-
254
- // special colors for some of the
255
- legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
256
- legendBackgroundColorSolid: 'rgb(35, 35, 70)',
257
- dataLabelsColor: '#444',
258
- textColor: '#C0C0C0',
259
- maskColor: 'rgba(255,255,255,0.3)'
260
- };
261
-
262
- // Apply the theme
263
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/themes/gray.js DELETED
@@ -1,262 +0,0 @@
1
- /**
2
- * Gray theme for Highcharts JS
3
- * @author Torstein Hønsi
4
- */
5
-
6
- Highcharts.theme = {
7
- colors: ["#DDDF0D", "#7798BF", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
8
- "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
9
- chart: {
10
- backgroundColor: {
11
- linearGradient: [0, 0, 0, 400],
12
- stops: [
13
- [0, 'rgb(96, 96, 96)'],
14
- [1, 'rgb(16, 16, 16)']
15
- ]
16
- },
17
- borderWidth: 0,
18
- borderRadius: 15,
19
- plotBackgroundColor: null,
20
- plotShadow: false,
21
- plotBorderWidth: 0
22
- },
23
- title: {
24
- style: {
25
- color: '#FFF',
26
- font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
27
- }
28
- },
29
- subtitle: {
30
- style: {
31
- color: '#DDD',
32
- font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
33
- }
34
- },
35
- xAxis: {
36
- gridLineWidth: 0,
37
- lineColor: '#999',
38
- tickColor: '#999',
39
- labels: {
40
- style: {
41
- color: '#999',
42
- fontWeight: 'bold'
43
- }
44
- },
45
- title: {
46
- style: {
47
- color: '#AAA',
48
- font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
49
- }
50
- }
51
- },
52
- yAxis: {
53
- alternateGridColor: null,
54
- minorTickInterval: null,
55
- gridLineColor: 'rgba(255, 255, 255, .1)',
56
- lineWidth: 0,
57
- tickWidth: 0,
58
- labels: {
59
- style: {
60
- color: '#999',
61
- fontWeight: 'bold'
62
- }
63
- },
64
- title: {
65
- style: {
66
- color: '#AAA',
67
- font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
68
- }
69
- }
70
- },
71
- legend: {
72
- itemStyle: {
73
- color: '#CCC'
74
- },
75
- itemHoverStyle: {
76
- color: '#FFF'
77
- },
78
- itemHiddenStyle: {
79
- color: '#333'
80
- }
81
- },
82
- labels: {
83
- style: {
84
- color: '#CCC'
85
- }
86
- },
87
- tooltip: {
88
- backgroundColor: {
89
- linearGradient: [0, 0, 0, 50],
90
- stops: [
91
- [0, 'rgba(96, 96, 96, .8)'],
92
- [1, 'rgba(16, 16, 16, .8)']
93
- ]
94
- },
95
- borderWidth: 0,
96
- style: {
97
- color: '#FFF'
98
- }
99
- },
100
-
101
-
102
- plotOptions: {
103
- line: {
104
- dataLabels: {
105
- color: '#CCC'
106
- },
107
- marker: {
108
- lineColor: '#333'
109
- }
110
- },
111
- spline: {
112
- marker: {
113
- lineColor: '#333'
114
- }
115
- },
116
- scatter: {
117
- marker: {
118
- lineColor: '#333'
119
- }
120
- },
121
- candlestick: {
122
- lineColor: 'white'
123
- }
124
- },
125
-
126
- toolbar: {
127
- itemStyle: {
128
- color: '#CCC'
129
- }
130
- },
131
-
132
- navigation: {
133
- buttonOptions: {
134
- backgroundColor: {
135
- linearGradient: [0, 0, 0, 20],
136
- stops: [
137
- [0.4, '#606060'],
138
- [0.6, '#333333']
139
- ]
140
- },
141
- borderColor: '#000000',
142
- symbolStroke: '#C0C0C0',
143
- hoverSymbolStroke: '#FFFFFF'
144
- }
145
- },
146
-
147
- exporting: {
148
- buttons: {
149
- exportButton: {
150
- symbolFill: '#55BE3B'
151
- },
152
- printButton: {
153
- symbolFill: '#7797BE'
154
- }
155
- }
156
- },
157
-
158
- // scroll charts
159
- rangeSelector: {
160
- buttonTheme: {
161
- fill: {
162
- linearGradient: [0, 0, 0, 20],
163
- stops: [
164
- [0.4, '#888'],
165
- [0.6, '#555']
166
- ]
167
- },
168
- stroke: '#000000',
169
- style: {
170
- color: '#CCC',
171
- fontWeight: 'bold'
172
- },
173
- states: {
174
- hover: {
175
- fill: {
176
- linearGradient: [0, 0, 0, 20],
177
- stops: [
178
- [0.4, '#BBB'],
179
- [0.6, '#888']
180
- ]
181
- },
182
- stroke: '#000000',
183
- style: {
184
- color: 'white'
185
- }
186
- },
187
- select: {
188
- fill: {
189
- linearGradient: [0, 0, 0, 20],
190
- stops: [
191
- [0.1, '#000'],
192
- [0.3, '#333']
193
- ]
194
- },
195
- stroke: '#000000',
196
- style: {
197
- color: 'yellow'
198
- }
199
- }
200
- }
201
- },
202
- inputStyle: {
203
- backgroundColor: '#333',
204
- color: 'silver'
205
- },
206
- labelStyle: {
207
- color: 'silver'
208
- }
209
- },
210
-
211
- navigator: {
212
- handles: {
213
- backgroundColor: '#666',
214
- borderColor: '#AAA'
215
- },
216
- outlineColor: '#CCC',
217
- maskFill: 'rgba(16, 16, 16, 0.5)',
218
- series: {
219
- color: '#7798BF',
220
- lineColor: '#A6C7ED'
221
- }
222
- },
223
-
224
- scrollbar: {
225
- barBackgroundColor: {
226
- linearGradient: [0, 0, 0, 20],
227
- stops: [
228
- [0.4, '#888'],
229
- [0.6, '#555']
230
- ]
231
- },
232
- barBorderColor: '#CCC',
233
- buttonArrowColor: '#CCC',
234
- buttonBackgroundColor: {
235
- linearGradient: [0, 0, 0, 20],
236
- stops: [
237
- [0.4, '#888'],
238
- [0.6, '#555']
239
- ]
240
- },
241
- buttonBorderColor: '#CCC',
242
- rifleColor: '#FFF',
243
- trackBackgroundColor: {
244
- linearGradient: [0, 0, 0, 10],
245
- stops: [
246
- [0, '#000'],
247
- [1, '#333']
248
- ]
249
- },
250
- trackBorderColor: '#666'
251
- },
252
-
253
- // special colors for some of the demo examples
254
- legendBackgroundColor: 'rgba(48, 48, 48, 0.8)',
255
- legendBackgroundColorSolid: 'rgb(70, 70, 70)',
256
- dataLabelsColor: '#444',
257
- textColor: '#E0E0E0',
258
- maskColor: 'rgba(255,255,255,0.3)'
259
- };
260
-
261
- // Apply the theme
262
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/themes/grid.js DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * Grid theme for Highcharts JS
3
- * @author Torstein Hønsi
4
- */
5
-
6
- Highcharts.theme = {
7
- colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
8
- chart: {
9
- backgroundColor: {
10
- linearGradient: [0, 0, 500, 500],
11
- stops: [
12
- [0, 'rgb(255, 255, 255)'],
13
- [1, 'rgb(240, 240, 255)']
14
- ]
15
- },
16
- borderWidth: 2,
17
- plotBackgroundColor: 'rgba(255, 255, 255, .9)',
18
- plotShadow: true,
19
- plotBorderWidth: 1
20
- },
21
- title: {
22
- style: {
23
- color: '#000',
24
- font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
25
- }
26
- },
27
- subtitle: {
28
- style: {
29
- color: '#666666',
30
- font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
31
- }
32
- },
33
- xAxis: {
34
- gridLineWidth: 1,
35
- lineColor: '#000',
36
- tickColor: '#000',
37
- labels: {
38
- style: {
39
- color: '#000',
40
- font: '11px Trebuchet MS, Verdana, sans-serif'
41
- }
42
- },
43
- title: {
44
- style: {
45
- color: '#333',
46
- fontWeight: 'bold',
47
- fontSize: '12px',
48
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
49
-
50
- }
51
- }
52
- },
53
- yAxis: {
54
- minorTickInterval: 'auto',
55
- lineColor: '#000',
56
- lineWidth: 1,
57
- tickWidth: 1,
58
- tickColor: '#000',
59
- labels: {
60
- style: {
61
- color: '#000',
62
- font: '11px Trebuchet MS, Verdana, sans-serif'
63
- }
64
- },
65
- title: {
66
- style: {
67
- color: '#333',
68
- fontWeight: 'bold',
69
- fontSize: '12px',
70
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
71
- }
72
- }
73
- },
74
- legend: {
75
- itemStyle: {
76
- font: '9pt Trebuchet MS, Verdana, sans-serif',
77
- color: 'black'
78
-
79
- },
80
- itemHoverStyle: {
81
- color: '#039'
82
- },
83
- itemHiddenStyle: {
84
- color: 'gray'
85
- }
86
- },
87
- labels: {
88
- style: {
89
- color: '#99b'
90
- }
91
- }
92
- };
93
-
94
- // Apply the theme
95
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/themes/skies.js DELETED
@@ -1,89 +0,0 @@
1
- /**
2
- * Skies theme for Highcharts JS
3
- * @author Torstein Hønsi
4
- */
5
-
6
- Highcharts.theme = {
7
- colors: ["#514F78", "#42A07B", "#9B5E4A", "#72727F", "#1F949A", "#82914E", "#86777F", "#42A07B"],
8
- chart: {
9
- className: 'skies',
10
- borderWidth: 0,
11
- plotShadow: true,
12
- plotBackgroundImage: '/demo/gfx/skies.jpg',
13
- plotBackgroundColor: {
14
- linearGradient: [0, 0, 250, 500],
15
- stops: [
16
- [0, 'rgba(255, 255, 255, 1)'],
17
- [1, 'rgba(255, 255, 255, 0)']
18
- ]
19
- },
20
- plotBorderWidth: 1
21
- },
22
- title: {
23
- style: {
24
- color: '#3E576F',
25
- font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
26
- }
27
- },
28
- subtitle: {
29
- style: {
30
- color: '#6D869F',
31
- font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
32
- }
33
- },
34
- xAxis: {
35
- gridLineWidth: 0,
36
- lineColor: '#C0D0E0',
37
- tickColor: '#C0D0E0',
38
- labels: {
39
- style: {
40
- color: '#666',
41
- fontWeight: 'bold'
42
- }
43
- },
44
- title: {
45
- style: {
46
- color: '#666',
47
- font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
48
- }
49
- }
50
- },
51
- yAxis: {
52
- alternateGridColor: 'rgba(255, 255, 255, .5)',
53
- lineColor: '#C0D0E0',
54
- tickColor: '#C0D0E0',
55
- tickWidth: 1,
56
- labels: {
57
- style: {
58
- color: '#666',
59
- fontWeight: 'bold'
60
- }
61
- },
62
- title: {
63
- style: {
64
- color: '#666',
65
- font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
66
- }
67
- }
68
- },
69
- legend: {
70
- itemStyle: {
71
- font: '9pt Trebuchet MS, Verdana, sans-serif',
72
- color: '#3E576F'
73
- },
74
- itemHoverStyle: {
75
- color: 'black'
76
- },
77
- itemHiddenStyle: {
78
- color: 'silver'
79
- }
80
- },
81
- labels: {
82
- style: {
83
- color: '#3E576F'
84
- }
85
- }
86
- };
87
-
88
- // Apply the theme
89
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/mandrill.class.php CHANGED
@@ -414,11 +414,7 @@ class Mandrill {
414
  if ($sep_changed) {
415
  ini_set("arg_separator.output", $orig_sep);
416
  }
417
-
418
- if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
419
- error_log( "\nMandrill::http_request: URL: $url - Fields: $fields\n" );
420
- }
421
-
422
  if( function_exists('curl_init') && function_exists('curl_exec') ) {
423
 
424
  if( !ini_get('safe_mode') ){
414
  if ($sep_changed) {
415
  ini_set("arg_separator.output", $orig_sep);
416
  }
417
+
 
 
 
 
418
  if( function_exists('curl_init') && function_exists('curl_exec') ) {
419
 
420
  if( !ini_get('safe_mode') ){
readme.txt CHANGED
@@ -84,6 +84,10 @@ If your account has more than 20 senders registered or more than 40 tags used, t
84
 
85
  == Changelog ==
86
 
 
 
 
 
87
  = 1.21 =
88
  * FIXED: Logging wrong error messages when sending emails with no attachments
89
  * FIXED: Attachments that Mandrill doesn't support were discarded instead of sending the email (with attachment) through the native wp_mail function.
84
 
85
  == Changelog ==
86
 
87
+ = 1.22 =
88
+ * UPDATED: Replacing Highcharts in favor of Flot
89
+ * ADD: Cron job to fetch stats
90
+
91
  = 1.21 =
92
  * FIXED: Logging wrong error messages when sending emails with no attachments
93
  * FIXED: Attachments that Mandrill doesn't support were discarded instead of sending the email (with attachment) through the native wp_mail function.
stats.php CHANGED
@@ -84,281 +84,192 @@ $lit['clickrate'] = __('Click Rate',self::WPDOMAIN);
84
  <option value="average"><?php _e('Average Volume per Period', wpMandrill::WPDOMAIN); ?></option>
85
  </select><div id="ajax-icon-container"><span id="loading_data" class="hidden"></span></div>
86
  <div id="filtered_reports_canvas">
87
- <div id="filtered_recent" style="width: 50%;float: left;"></div>
88
- <div id="filtered_oldest" style="width: 50%;float: left;"></div>
89
  </div>
90
  <div style="clear: both;"></div>
91
  </div>
92
  <br/><br/>
93
- <div id="hourly_report">
94
  <script type="text/javascript">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  jQuery(function () {
96
- var chart;
97
- jQuery(document).ready(function() {
98
- chart = new Highcharts.Chart({
99
- chart: {
100
- renderTo: 'hourly_report_canvas',
101
- zoomType: 'xy',
102
- spacingBottom: 30
103
- },
104
- exporting: {
105
- enabled: true,
106
- },
107
- title: {
108
- text: '<?php echo $lit['hourly']['title']; ?>'
109
- },
110
- subtitle: {
111
- text: '<?php echo $lit['subtitle']; ?>'
112
- },
113
- xAxis: [{
114
- categories: [<?=implode(',',array_keys($stats['graph']['hourly']['delivered']));?>],
115
- title: {
116
- enabled: true,
117
- text: '<?php echo $lit['hourly']['Xtitle']; ?>',
118
- style: {
119
- fontWeight: 'normal'
120
- }
121
- }
122
- }],
123
- yAxis: [{
124
- min: 0,
125
- max: 100,
126
- labels: {
127
- formatter: function() {
128
- return this.value +'%';
129
- },
130
- style: {
131
- color: '#666666'
132
- }
133
- },
134
- title: {
135
- text: '<?php echo $lit['Ytitle']; ?>',
136
- style: {
137
- color: '#666666'
138
- }
139
- }
140
- }, {
141
- title: {
142
- text: '<?php echo $lit['SerieName']; ?>',
143
- style: {
144
- color: '#4572A7'
145
- }
146
- },
147
- labels: {
148
- formatter: function() {
149
- return this.value +' <?php echo $lit['emails']; ?>';
150
- },
151
- style: {
152
- color: '#4572A7'
153
- }
154
- },
155
- opposite: true
156
- }],
157
- tooltip: {
158
- formatter: function() {
159
- return '<?php echo $lit['hourly']['tooltip']; ?> '+
160
- this.x +': '+ this.y +
161
- (this.series.name == '<?php echo $lit['SerieName']; ?>' ? ' <?php echo $lit['emails']; ?>' : '%');
162
- }
163
- },
164
- plotOptions: {
165
- column: {
166
- fillOpacity: 0.5
167
- }
168
- },
169
- credits: {
170
- enabled: false,
171
- href: "http://www.mandrillapp.com/",
172
- text: "MandrillApp.com"
173
- },
174
- legend: {
175
- align: 'right',
176
- x: -100,
177
- verticalAlign: 'top',
178
- y: 20,
179
- floating: true,
180
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
181
- borderColor: '#CCC',
182
- borderWidth: 1,
183
- shadow: false
184
- },
185
- series: [{
186
- name: 'Volume',
187
- color: '#4572A7',
188
- type: 'column',
189
- yAxis: 1,
190
- data: [<?=implode(',',$stats['graph']['hourly']['delivered']);?>],
191
- dataLabels: {
192
- enabled: true,
193
- rotation: -90,
194
- color: '#FFFFFF',
195
- align: 'right',
196
- x: -3,
197
- y: 10,
198
- formatter: function() {
199
- return this.y;
200
- },
201
- style: {
202
- font: 'normal 13px Verdana, sans-serif'
203
- }
204
- },
205
- }, {
206
- name: '<?php echo $lit['openrate']; ?>',
207
- color: '#89A54E',
208
- type: 'spline',
209
- data: [<?=implode(',',$stats['graph']['hourly']['open_rate']);?>]
210
- }, {
211
- name: '<?php echo $lit['clickrate']; ?>',
212
- color: '#deA54E',
213
- type: 'spline',
214
- data: [<?=implode(',',$stats['graph']['hourly']['click_rate']);?>]
215
- }]
216
- });
217
- });
218
- chart = new Highcharts.Chart({
219
- chart: {
220
- renderTo: 'daily_report_canvas',
221
- zoomType: 'xy',
222
- spacingBottom: 30
223
- },
224
- title: {
225
- text: '<?php echo $lit['daily']['title']; ?>'
226
- },
227
- subtitle: {
228
- text: '<?php echo $lit['subtitle']; ?>'
229
- },
230
- xAxis: [{
231
- categories: [<?=implode(',',array_keys($stats['graph']['daily']['delivered']));?>],
232
- title: {
233
- enabled: true,
234
- text: '<?php echo $lit['daily']['Xtitle']; ?>',
235
- style: {
236
- fontWeight: 'normal'
237
- }
238
- },
239
- labels: {
240
- rotation: -45,
241
- align: 'right',
242
- style: {
243
- font: 'normal 13px Verdana, sans-serif'
244
- }
245
- }
246
- }],
247
- yAxis: [{
248
- min: 0,
249
- max: 100,
250
- labels: {
251
- formatter: function() {
252
- return this.value +'%';
253
- },
254
- style: {
255
- color: '#666666'
256
- }
257
- },
258
- title: {
259
- text: '<?php echo $lit['Ytitle']; ?>',
260
- style: {
261
- color: '#666666'
262
  }
263
  }
264
- }, {
265
- title: {
266
- text: '<?php echo $lit['SerieName']; ?>',
267
- style: {
268
- color: '#4572A7'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  }
270
- },
271
- dataLabels: {
272
- enabled: true,
273
- rotation: -90,
274
- color: '#FFFFFF',
275
- align: 'right',
276
- x: -3,
277
- y: 10,
278
- formatter: function() {
279
- return this.y;
280
- },
281
- style: {
282
- font: 'normal 13px Verdana, sans-serif'
283
- }
284
- },
285
- labels: {
286
- formatter: function() {
287
- return this.value +' <?php echo $lit['emails']; ?>';
288
- },
289
- style: {
290
- color: '#4572A7'
291
- }
292
- },
293
- opposite: true
294
- }],
295
- tooltip: {
296
- formatter: function() {
297
- return '<?php echo $lit['daily']['tooltip']; ?> '+
298
- this.x +': '+ this.y +
299
- (this.series.name == '<?php echo $lit['SerieName']; ?>' ? ' <?php echo $lit['emails']; ?>' : '%');
300
  }
301
- },
302
- plotOptions: {
303
- column: {
304
- fillOpacity: 0.5
305
- }
306
- },
307
- credits: {
308
- enabled: false,
309
- href: "http://www.mandrillapp.com/",
310
- text: "MandrillApp.com"
311
- },
312
- legend: {
313
- align: 'right',
314
- x: -100,
315
- verticalAlign: 'top',
316
- y: 20,
317
- floating: true,
318
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
319
- borderColor: '#CCC',
320
- borderWidth: 1,
321
- shadow: false
322
- },
323
- series: [{
324
- name: '<?php echo $lit['SerieName']; ?>',
325
- color: '#4572A7',
326
- type: 'column',
327
- yAxis: 1,
328
- data: [<?=implode(',',$stats['graph']['daily']['delivered']);?>],
329
- dataLabels: {
330
- enabled: true,
331
- rotation: -90,
332
- color: '#FFFFFF',
333
- align: 'right',
334
- x: -3,
335
- y: 10,
336
- formatter: function() {
337
- return this.y;
338
- },
339
- style: {
340
- font: 'normal 13px Verdana, sans-serif'
341
- }
342
- },
343
- }, {
344
- name: '<?php echo $lit['openrate']; ?>',
345
- color: '#89A54E',
346
- type: 'spline',
347
- data: [<?=implode(',',$stats['graph']['daily']['open_rate']);?>]
348
- }, {
349
- name: '<?php echo $lit['clickrate']; ?>',
350
- color: '#deA54E',
351
- type: 'spline',
352
- data: [<?=implode(',',$stats['graph']['daily']['click_rate']);?>]
353
- }]
354
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  });
356
  </script>
357
- <div id="hourly_report_canvas"></div><br/><br/>
358
- <div id="daily_report_canvas"></div>
 
 
 
 
359
  <h3><a href="http://mandrillapp.com/" target="_target"><?php _e('For more detailed statistics, please visit your Mandrill Dashboard',self::WPDOMAIN); ?></a>.</h3>
360
- </div>
361
  <?php
362
  wpMandrill::$stats = $stats;
363
-
364
- ?>
84
  <option value="average"><?php _e('Average Volume per Period', wpMandrill::WPDOMAIN); ?></option>
85
  </select><div id="ajax-icon-container"><span id="loading_data" class="hidden"></span></div>
86
  <div id="filtered_reports_canvas">
87
+ <div id="filtered_recent" style="width: 50%;height: 300px; float: left;"></div>
88
+ <div id="filtered_oldest" style="width: 50%;height: 300px; float: left;"></div>
89
  </div>
90
  <div style="clear: both;"></div>
91
  </div>
92
  <br/><br/>
93
+ <div id="hourly_report"></div>
94
  <script type="text/javascript">
95
+ function emailFormatter(v, axis) {
96
+ return v.toFixed(axis.tickDecimals) +" emails";
97
+ }
98
+ function percentageFormatter(v, axis) {
99
+ return v.toFixed(axis.tickDecimals) +"%";
100
+ }
101
+ function wpm_showTooltip(x, y, contents) {
102
+ jQuery('<div id="wpm_tooltip">' + contents + '</div>').css( {
103
+ position: 'absolute',
104
+ display: 'none',
105
+ top: y + 5,
106
+ left: x + 5,
107
+ border: '1px solid #fdd',
108
+ padding: '2px',
109
+ 'background-color': '#fee',
110
+ opacity: 0.80
111
+ }).appendTo("body").fadeIn(200);
112
+ }
113
+ <?php
114
+ // hourly stats data
115
+ $hticks = array_keys($stats['graph']['hourly']['delivered']);
116
+ array_walk($hticks, 'wpMandrill_transformJSArray');
117
+
118
+ $hvolume = $stats['graph']['hourly']['delivered'];
119
+ $horate = $stats['graph']['hourly']['open_rate'];
120
+ $hcrate = $stats['graph']['hourly']['click_rate'];
121
+
122
+ array_walk($hvolume,'wpMandrill_transformJSArray');
123
+ array_walk($horate, 'wpMandrill_transformJSArray');
124
+ array_walk($hcrate, 'wpMandrill_transformJSArray');
125
+
126
+ // daily stats data
127
+ $dticks = array_keys($stats['graph']['daily']['delivered']);
128
+ array_walk($dticks, 'wpMandrill_transformJSArray');
129
+
130
+ $day_keys = array();
131
+ foreach(array_keys($stats['graph']['daily']['delivered']) as $day_index => $day_key) {
132
+ $day_keys[$day_index] = $day_key;
133
+ }
134
+
135
+ $dvolume = $stats['graph']['daily']['delivered'];
136
+ $dorate = $stats['graph']['daily']['open_rate'];
137
+ $dcrate = $stats['graph']['daily']['click_rate'];
138
+
139
+ array_walk($dvolume,'wpMandrill_transformJSArray', array(1, $day_keys));
140
+ array_walk($dorate, 'wpMandrill_transformJSArray', array(1, $day_keys));
141
+ array_walk($dcrate, 'wpMandrill_transformJSArray', array(1, $day_keys));
142
+
143
+
144
+ ?>
145
+ var hvolume = [<?=implode(',',$hvolume);?>];
146
+ var hopenrates = [<?=implode(',',$horate);?>];
147
+ var hclickrates = [<?=implode(',',$hcrate);?>]
148
+
149
+ var dvolume = [<?=implode(',',$dvolume);?>];
150
+ var dopenrates = [<?=implode(',',$dorate);?>];
151
+ var dclickrates = [<?=implode(',',$dcrate);?>]
152
+ var dticks = [<?=implode(',',array_keys($stats['graph']['daily']['delivered']));?>]
153
  jQuery(function () {
154
+ var previousPoint = null;
155
+ jQuery("#hourly_report_canvas").bind("plothover", function (event, pos, item) {
156
+ if (item) {
157
+ if (previousPoint != item.dataIndex) {
158
+ previousPoint = item.dataIndex;
159
+
160
+ jQuery("#wpm_tooltip").remove();
161
+ var x = item.datapoint[0].toFixed(0);
162
+
163
+ if ( item.seriesIndex == 0 ) {
164
+ var y = item.datapoint[1].toFixed(0);
165
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " (at hour " + x + ") = " + y + " emails");
166
+ } else {
167
+ var y = item.datapoint[1].toFixed(2);
168
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " (at hour " + x + ") = " + y + "%");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
  }
171
+ }
172
+ else {
173
+ jQuery("#wpm_tooltip").remove();
174
+ previousPoint = null;
175
+ }
176
+ });
177
+ jQuery("#daily_report_canvas").bind("plothover", function (event, pos, item) {
178
+ if (item) {
179
+ if (previousPoint != item.dataIndex) {
180
+ previousPoint = item.dataIndex;
181
+
182
+ jQuery("#wpm_tooltip").remove();
183
+ var x = dticks[item.dataIndex];
184
+
185
+ if ( item.seriesIndex == 0 ) {
186
+ var y = item.datapoint[1].toFixed(0);
187
+ wpm_showTooltip(item.pageX, item.pageY, "Day " + x + ": " + y + " emails");
188
+ } else {
189
+ var y = item.datapoint[1].toFixed(2);
190
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " for " + x + ": " + y + "%");
191
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
+ }
194
+ else {
195
+ jQuery("#wpm_tooltip").remove();
196
+ previousPoint = null;
197
+ }
198
+ });
199
+ jQuery.plot(jQuery("#hourly_report_canvas"),
200
+ [ { data: hvolume, label: "Volume", yaxis: 2, bars: {show: true, barWidth: 0.6, align: "center"}, lines: { show: true }},
201
+ { data: hopenrates, label: "Open Rate" },
202
+ { data: hclickrates, label: "Click Rate" }],
203
+ {
204
+ series: {
205
+ points: { show: true },
206
+ lines: { show: true },
207
+ shadowSize: 7
208
+ },
209
+ grid: {
210
+ hoverable: true,
211
+ aboveData: true,
212
+ borderWidth: 0,
213
+ minBorderMargin: 10,
214
+ margin: {
215
+ top: 10,
216
+ left: 10,
217
+ bottom: 15,
218
+ right: 100
219
+ }
220
+ },
221
+ xaxes: [ { ticks: [<?=implode(',',$hticks);?>] } ],
222
+ yaxes: [ { min: 0, tickFormatter: percentageFormatter },
223
+ {
224
+ min: 0,
225
+ alignTicksWithAxis: 1, //1=right, null=left
226
+ position: 'sw',
227
+ tickFormatter: emailFormatter
228
+ } ],
229
+ legend: { position: 'ne', margin: [20, 10]}
230
+ });
231
+ jQuery.plot(jQuery("#daily_report_canvas"),
232
+ [ { data: dvolume, label: "Volume", yaxis: 2, bars: {show: true, barWidth: 0.6, align: "center"}, lines: { show: true }},
233
+ { data: dopenrates, label: "Open Rate" },
234
+ { data: dclickrates, label: "Click Rate" }],
235
+ {
236
+ series: {
237
+ points: { show: true },
238
+ lines: { show: true },
239
+ shadowSize: 7
240
+ },
241
+ grid: {
242
+ hoverable: true,
243
+ aboveData: true,
244
+ borderWidth: 0,
245
+ minBorderMargin: 10,
246
+ margin: {
247
+ top: 10,
248
+ left: 10,
249
+ bottom: 15,
250
+ right: 10
251
+ }
252
+ },
253
+ xaxes: [ { ticks: [<?=implode(',', $dticks);?>] } ],
254
+ yaxes: [ { min: 0, tickFormatter: percentageFormatter },
255
+ {
256
+ min: 0,
257
+ alignTicksWithAxis: 1, //1=right, null=left
258
+ position: 'sw',
259
+ tickFormatter: emailFormatter
260
+ } ],
261
+ legend: { position: 'ne', margin: [20, 10]}
262
+ });
263
  });
264
  </script>
265
+ <h3><?=$lit['hourly']['title']; ?></h3>
266
+ <h4><?=$lit['subtitle']; ?></h4>
267
+ <div id="hourly_report_canvas" style="height: 400px;"></div><br/><br/>
268
+ <h3><?=$lit['daily']['title']; ?></h3>
269
+ <h4><?=$lit['subtitle']; ?></h4>
270
+ <div id="daily_report_canvas" style="height: 400px;"></div>
271
  <h3><a href="http://mandrillapp.com/" target="_target"><?php _e('For more detailed statistics, please visit your Mandrill Dashboard',self::WPDOMAIN); ?></a>.</h3>
272
+
273
  <?php
274
  wpMandrill::$stats = $stats;
275
+ ?>
 
uninstall.php CHANGED
@@ -5,5 +5,11 @@ if( !defined( 'WP_UNINSTALL_PLUGIN' ) )
5
 
6
  delete_option( 'wpmandrill' );
7
  delete_option( 'wpmandrill-test' );
 
8
  delete_transient('mandrill-stats');
 
 
 
 
 
9
  ?>
5
 
6
  delete_option( 'wpmandrill' );
7
  delete_option( 'wpmandrill-test' );
8
+ delete_option( 'wpmandrill-stats' );
9
  delete_transient('mandrill-stats');
10
+
11
+ wp_clear_scheduled_hook('wpm_update_stats');
12
+
13
+ if ( function_exists('delete_site_option') ) delete_site_option('wpmandrill_notice_shown');
14
+
15
  ?>
wpmandrill.php CHANGED
@@ -5,7 +5,7 @@ Description: wpMandrill sends emails, generated by WordPress using Mandrill.
5
  Author: Mandrill
6
  Author URI: http://mandrillapp.com/
7
  Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
8
- Version: 1.21
9
  Text Domain: wpmandrill
10
  */
11
  /* Copyright 2012 MailChimp (email : will@mailchimp.com )
@@ -127,8 +127,21 @@ class wpMandrill {
127
  }
128
 
129
  }
 
 
 
 
 
 
 
 
 
130
  }
131
-
 
 
 
 
132
  /**
133
  * Creates option page's entry in Settings section of menu.
134
  */
@@ -151,9 +164,12 @@ class wpMandrill {
151
  array(__CLASS__,'showReportPage')
152
  );
153
  if ( self::isPluginPage('-reports') ) {
154
- wp_register_script('highcharts', plugins_url('/js/highcharts.js', __FILE__), array('jquery'), null, true);
155
- wp_register_script('mandrill-report-export', plugins_url("js/modules/exporting.js", __FILE__), array('highcharts'), null, true);
156
- wp_enqueue_script('highcharts');
 
 
 
157
  wp_enqueue_script('mandrill-report-export');
158
  }
159
  }
@@ -165,13 +181,17 @@ class wpMandrill {
165
  }
166
 
167
  static function network_connect_notice() {
168
- ?>
169
- <div id="message" class="updated wpmandrill-message">
170
- <div class="squeezer">
171
- <h4><?php _e( '<strong>wpMandrill is activated!</strong> Each site on your network must be connected individually by an admin on that site.', self::WPDOMAIN ) ?></h4>
 
 
 
172
  </div>
173
- </div>
174
- <?php
 
175
  }
176
 
177
  static function adminNotices() {
@@ -182,12 +202,8 @@ class wpMandrill {
182
 
183
  static function showAdminEnqueueScripts($hook_suffix) {
184
  if( $hook_suffix == self::$report && self::isConnected() ) {
185
- wp_register_script('mandrill-report-theme', plugins_url("js/themes/gray.js", __FILE__), array(''), null, true);
186
- wp_register_script('mandrill-report-script', plugins_url("js/mandrill.js", __FILE__), array('highcharts'), null, true);
187
- wp_register_script('mandrill-report-export', plugins_url("js/modules/exporting.js", __FILE__), array('highcharts'), null, true);
188
-
189
  wp_enqueue_script('mandrill-report-script');
190
- wp_enqueue_script('mandrill-report-theme');
191
  }
192
  }
193
 
@@ -202,7 +218,7 @@ class wpMandrill {
202
 
203
  $ok = array();
204
  $ok['account'] = ( !wpMandrill::isConnected() ) ? ' class="missing"' : '';
205
- $ok['domains'] = ( $ok['account'] != '' || !self::ListVerifiedDomains() ) ? ' class="missing"' : '';
206
  $ok['email'] = ( $ok['account'] != '' || !self::getFromEmail() ) ? ' class="missing"' : '';
207
 
208
  $requirements = '';
@@ -595,16 +611,17 @@ jQuery(document).bind( 'ready', function() {
595
  * @return array|bool
596
  */
597
  static function listVerifiedDomains() {
 
 
598
  self::getConnected();
 
599
 
600
  try {
601
  $domains = self::$mandrill->senders_domains();
602
- if ( empty($domains) ) throw new Exception('No Domains');
603
- } catch ( Exception $e ) {
604
- return array();
605
- }
606
 
607
- return array_values($domains);
608
  }
609
 
610
 
@@ -712,7 +729,7 @@ jQuery(document).bind( 'ready', function() {
712
  $from_email = self::getFromEmail();
713
 
714
  $domains = self::ListVerifiedDomains();
715
- if ( !$domains ) {
716
 
717
  _e('No domains found.', self::WPDOMAIN);
718
 
@@ -860,7 +877,7 @@ jQuery(document).bind( 'ready', function() {
860
  /**
861
  * @return array
862
  */
863
- static function GetRawStatistics() {
864
  self::getConnected();
865
 
866
  if ( !self::isConnected() ) return array();
@@ -923,7 +940,7 @@ jQuery(document).bind( 'ready', function() {
923
  }
924
 
925
  static function getProcessedStats() {
926
- $stats = self::GetRawStatistics();
927
  if ( empty($stats) ) return $stats;
928
 
929
  $graph_data = array();
@@ -1000,19 +1017,38 @@ jQuery(document).bind( 'ready', function() {
1000
  return $stats;
1001
  }
1002
 
 
 
 
 
1003
  static function getCurrentStats() {
1004
 
1005
  $stats = get_transient(self::WPDOMAIN.'-stats');
1006
  if ( empty($stats) ) {
1007
-
1008
- $stats = self::GetProcessedStats();
1009
- if ( !empty($stats) ) set_transient(self::WPDOMAIN.'-stats', $stats, 60 * 60);
1010
-
1011
  }
1012
 
1013
  return $stats;
1014
  }
1015
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1016
  static function addDashboardWidgets() {
1017
  self::getConnected();
1018
  if ( !self::isConnected() ) return;
@@ -1151,6 +1187,8 @@ jQuery(document).bind( 'ready', function() {
1151
  $lit['bounced'] = __('Bounced or Rejected', self::WPDOMAIN);
1152
  $lit['opened'] = __('Opened', self::WPDOMAIN);
1153
 
 
 
1154
  if ( $display == 'average' ) {
1155
  $lit['title'] = __('Average Sending Volume', self::WPDOMAIN);
1156
  $lit['label_suffix'] .= __('/day', self::WPDOMAIN);
@@ -1161,132 +1199,117 @@ jQuery(document).bind( 'ready', function() {
1161
  $data['bounces'][$period] = number_format($data['bounces'][$period] / $days,2);
1162
  $data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
1163
  }
 
 
1164
  }
1165
  // Filling arrays for recent stats
1166
- $unopens['recent'] = $data['unopens']['today'] . ',' . $data['unopens']['last_7_days'];
1167
- $opens['recent'] = $data['opens']['today'] . ',' . $data['opens']['last_7_days'];
1168
- $bounces['recent'] = $data['bounces']['today'] . ',' . $data['bounces']['last_7_days'];
1169
 
1170
 
1171
  $js = '';
1172
  if ( !$isAjaxCall ) {
1173
- $js .= '<script type="text/javascript" src="'.plugins_url('/js/highcharts.js', __FILE__).'"></script>';
1174
-
 
 
 
1175
  $js .= '
1176
  <div style="height:400px;">
1177
- <div id="filtered_recent">Loading...</div>
1178
  </div>
1179
  <script type="text/javascript">
1180
  jQuery(document).bind( \'ready\', function() {
1181
  ';
1182
  }
1183
  $js .= <<<JS
1184
- jQuery(function () {
1185
- var chart;
1186
- chart = new Highcharts.Chart({
1187
- exporting: {
1188
- enabled: false,
1189
- },
1190
- chart: {
1191
- renderTo: 'filtered_recent',
1192
- zoomType: 'xy',
1193
- type: 'column'
1194
- },
1195
- title: {
1196
- text: '{$lit['title']}'
1197
- },
1198
- subtitle: {
1199
- text: '{$lit['last_few_days']}'
1200
- },
1201
- xAxis: [{
1202
- categories: ['{$lit['today']}','{$lit['last7days']}'],
1203
- title: {
1204
- enabled: true,
1205
- text: '{$lit['periods']}',
1206
- style: {
1207
- fontWeight: 'normal'
1208
- }
1209
- }
1210
- }],
1211
- yAxis: [{
1212
- min: 0,
1213
- title: {
1214
- text: '{$lit['Ylabel']} ',
1215
- style: {
1216
- color: '#4572A7'
1217
- }
1218
- },
1219
- labels: {
1220
- formatter: function() {
1221
- return this.value +' {$lit['label_suffix']}';
1222
- },
1223
- style: {
1224
- color: '#4572A7'
1225
- }
1226
- },
1227
- stackLabels: {
1228
- enabled: true,
1229
- style: {
1230
- fontWeight: 'bold',
1231
- color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
1232
- }
1233
- }
1234
- }],
1235
- tooltip: {
1236
- formatter: function() {
1237
- return '<b>'+ this.x +'</b><br/>'+
1238
- this.series.name +': '+ this.y +'{$lit['label_suffix']}<br/>'+
1239
- '{$lit['total']} '+ this.point.stackTotal+'{$lit['label_suffix']}';
1240
  }
1241
- },
1242
- legend: {
1243
- align: 'right',
1244
- x: -20,
1245
- verticalAlign: 'top',
1246
- y: 40,
1247
- floating: true,
1248
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
1249
- borderColor: '#CCC',
1250
- borderWidth: 1,
1251
- shadow: false
1252
- },
1253
- credits: {
1254
- enabled: false,
1255
- href: 'http://www.mandrillapp.com/',
1256
- text: 'MandrillApp.com'
1257
- },
1258
- plotOptions: {
1259
- column: {
1260
- stacking: 'normal',
1261
- dataLabels: {
1262
- enabled: true,
1263
- color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
1264
- }
1265
- }
1266
- },
1267
- series: [{
1268
- name: '{$lit['bounced']}',
1269
- data: [{$bounces['recent']}]
1270
- }, {
1271
- name: '{$lit['opened']}',
1272
- data: [{$opens['recent']}]
1273
- }, {
1274
- name: '{$lit['unopened']}',
1275
- data: [{$unopens['recent']}]
1276
- }]
1277
- });
 
 
 
1278
  });
1279
  JS;
1280
 
1281
- if ( !$isAjaxCall ) {
1282
- $js .= '
1283
  });
1284
  </script>';
1285
- }
1286
-
1287
- echo $js;
1288
-
1289
- if ( $isAjaxCall ) exit();
1290
 
1291
  }
1292
 
@@ -1408,6 +1431,8 @@ JS;
1408
  $lit['bounced'] = __('Bounced or Rejected', self::WPDOMAIN);
1409
  $lit['opened'] = __('Opened', self::WPDOMAIN);
1410
 
 
 
1411
  if ( $display == 'average' ) {
1412
  $lit['title'] = __('Average Sending Volume', self::WPDOMAIN);
1413
  $lit['label_suffix'] .= __('/day', self::WPDOMAIN);
@@ -1418,222 +1443,141 @@ JS;
1418
  $data['bounces'][$period] = number_format($data['bounces'][$period] / $days,2);
1419
  $data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
1420
  }
 
 
1421
  }
1422
 
1423
  // Filling arrays for recent stats
1424
- $unopens['recent'] = $data['unopens']['today'] . ',' . $data['unopens']['last_7_days'];
1425
- $opens['recent'] = $data['opens']['today'] . ',' . $data['opens']['last_7_days'];
1426
- $bounces['recent'] = $data['bounces']['today'] . ',' . $data['bounces']['last_7_days'];
1427
 
1428
  // Filling arrays for older stats
1429
- $unopens['oldest'] = $data['unopens']['last_30_days'] . ',' . $data['unopens']['last_60_days'] . ',' . $data['unopens']['last_90_days'];
1430
- $opens['oldest'] = $data['opens']['last_30_days'] . ',' . $data['opens']['last_60_days'] . ',' . $data['opens']['last_90_days'];
1431
- $bounces['oldest'] = $data['bounces']['last_30_days'] . ',' . $data['bounces']['last_60_days'] . ',' . $data['bounces']['last_90_days'];
1432
-
 
 
 
 
 
 
 
 
 
 
1433
  $js = <<<JS
 
 
 
 
 
 
 
 
1434
  jQuery(function () {
1435
- var chart;
1436
- chart = new Highcharts.Chart({
1437
- chart: {
1438
- renderTo: 'filtered_recent',
1439
- zoomType: 'xy',
1440
- type: 'column'
1441
- },
1442
- title: {
1443
- text: '{$lit['title']}'
1444
- },
1445
- subtitle: {
1446
- text: '{$lit['last_few_days']}'
1447
- },
1448
- xAxis: [{
1449
- categories: ['{$lit['today']}','{$lit['last7days']}'],
1450
- title: {
1451
- enabled: true,
1452
- text: '{$lit['periods']}',
1453
- style: {
1454
- fontWeight: 'normal'
1455
- }
1456
- }
1457
- }],
1458
- yAxis: [{
1459
- min: 0,
1460
- title: {
1461
- text: '{$lit['Ylabel']} ',
1462
- style: {
1463
- color: '#4572A7'
1464
- }
1465
- },
1466
- labels: {
1467
- formatter: function() {
1468
- return this.value +' {$lit['label_suffix']}';
1469
- },
1470
- style: {
1471
- color: '#4572A7'
1472
- }
1473
- },
1474
- stackLabels: {
1475
- enabled: true,
1476
- style: {
1477
- fontWeight: 'bold',
1478
- color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
1479
- }
1480
- }
1481
- }],
1482
- tooltip: {
1483
- formatter: function() {
1484
- return '<b>'+ this.x +'</b><br/>'+
1485
- this.series.name +': '+ this.y +'{$lit['label_suffix']}<br/>'+
1486
- '{$lit['total']} '+ this.point.stackTotal+'{$lit['label_suffix']}';
1487
- }
1488
- },
1489
- legend: {
1490
- align: 'right',
1491
- x: -20,
1492
- verticalAlign: 'top',
1493
- y: 40,
1494
- floating: true,
1495
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
1496
- borderColor: '#CCC',
1497
- borderWidth: 1,
1498
- shadow: false
1499
- },
1500
- credits: {
1501
- enabled: false,
1502
- href: "http://www.mandrillapp.com/",
1503
- text: "MandrillApp.com"
1504
- },
1505
- plotOptions: {
1506
- column: {
1507
- stacking: 'normal',
1508
- dataLabels: {
1509
- enabled: true,
1510
- color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
1511
- }
1512
- }
1513
- },
1514
- series: [{
1515
- name: '{$lit['bounced']}',
1516
- data: [{$bounces['recent']}]
1517
- }, {
1518
- name: '{$lit['opened']}',
1519
- data: [{$opens['recent']}]
1520
- }, {
1521
- name: '{$lit['unopened']}',
1522
- data: [{$unopens['recent']}]
1523
- }],
1524
- colors: [
1525
- '#AA4643',
1526
- '#89A54E',
1527
- '#4572A7',
1528
- '#80699B',
1529
- '#3D96AE',
1530
- '#DB843D',
1531
- '#92A8CD',
1532
- '#A47D7C',
1533
- '#B5CA92'
1534
- ]
1535
 
1536
- });
1537
- chart = new Highcharts.Chart({
1538
- chart: {
1539
- renderTo: 'filtered_oldest',
1540
- zoomType: 'xy',
1541
- type: 'column'
1542
- },
1543
- title: {
1544
- text: '{$lit['title']}'
1545
- },
1546
- subtitle: {
1547
- text: '{$lit['last_few_months']}'
1548
- },
1549
- xAxis: [{
1550
- categories: ['{$lit['last30days']}','{$lit['last60days']}','{$lit['last90days']}'],
1551
- title: {
1552
- enabled: true,
1553
- text: '{$lit['periods']}',
1554
- style: {
1555
- fontWeight: 'normal'
1556
  }
 
1557
  }
1558
- }],
1559
- yAxis: [{
1560
- min: 0,
1561
- title: {
1562
- text: '{$lit['Ylabel']} ',
1563
- style: {
1564
- color: '#4572A7'
1565
- }
1566
- },
1567
- labels: {
1568
- formatter: function() {
1569
- return this.value +' {$lit['label_suffix']}';
1570
- },
1571
- style: {
1572
- color: '#4572A7'
 
 
 
 
1573
  }
1574
- },
1575
- stackLabels: {
1576
- enabled: true,
1577
- style: {
1578
- fontWeight: 'bold',
1579
- color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
1580
- }
1581
- }
1582
- }],
1583
- tooltip: {
1584
- formatter: function() {
1585
- return '<b>'+ this.x +'</b><br/>'+
1586
- this.series.name +': '+ this.y +'{$lit['label_suffix']}<br/>'+
1587
- '{$lit['total']} '+ this.point.stackTotal+'{$lit['label_suffix']}';
1588
  }
1589
- },
1590
- legend: {
1591
- align: 'right',
1592
- x: -20,
1593
- verticalAlign: 'top',
1594
- y: 40,
1595
- floating: true,
1596
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
1597
- borderColor: '#CCC',
1598
- borderWidth: 1,
1599
- shadow: false
1600
- },
1601
- credits: {
1602
- enabled: false,
1603
- href: "http://www.mandrillapp.com/",
1604
- text: "MandrillApp.com"
1605
- },
1606
- plotOptions: {
1607
- column: {
1608
- stacking: 'normal',
1609
- dataLabels: {
1610
- enabled: true,
1611
- color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
1612
- }
1613
- }
1614
- },
1615
- series: [{
1616
- name: '{$lit['bounced']}',
1617
- data: [{$bounces['oldest']}]
1618
- }, {
1619
- name: '{$lit['opened']}',
1620
- data: [{$opens['oldest']}]
1621
- }, {
1622
- name: '{$lit['unopened']}',
1623
- data: [{$unopens['oldest']}]
1624
- }],
1625
- colors: [
1626
- '#AA4643',
1627
- '#89A54E',
1628
- '#4572A7',
1629
- '#80699B',
1630
- '#3D96AE',
1631
- '#DB843D',
1632
- '#92A8CD',
1633
- '#A47D7C',
1634
- '#B5CA92'
1635
- ]
1636
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1637
  });
1638
  JS;
1639
  echo $js;
@@ -1852,11 +1796,11 @@ JS;
1852
 
1853
  // Letting the user filter/change the message payload
1854
  if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
1855
- error_log( "\nwpMandrill::sendEmail: Before mandrill_payload ".print_r($message,true)."\n" );
1856
  }
1857
  $message = apply_filters('mandrill_payload', $message);
1858
  if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
1859
- error_log( "\nwpMandrill::sendEmail: After mandrill_payload ".print_r($message,true)."\n" );
1860
  }
1861
 
1862
  // Checking that the final From: email address is valid
@@ -1903,6 +1847,20 @@ JS;
1903
 
1904
  return $attachments;
1905
  }
1906
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1907
  }
1908
  ?>
5
  Author: Mandrill
6
  Author URI: http://mandrillapp.com/
7
  Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
8
+ Version: 1.22
9
  Text Domain: wpmandrill
10
  */
11
  /* Copyright 2012 MailChimp (email : will@mailchimp.com )
127
  }
128
 
129
  }
130
+
131
+ // Activate the cron job that will update the stats
132
+ add_action('wpm_update_stats', array(__CLASS__,'saveProcessedStats'));
133
+
134
+ if ( !wp_next_scheduled( 'wpm_update_stats' ) ) {
135
+ wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'wpm_update_stats');
136
+ }
137
+
138
+ register_deactivation_hook( __FILE__, array(__CLASS__,'deactivate') );
139
  }
140
+
141
+ static public function deactivate() {
142
+ wp_clear_scheduled_hook('wpm_update_stats');
143
+ }
144
+
145
  /**
146
  * Creates option page's entry in Settings section of menu.
147
  */
164
  array(__CLASS__,'showReportPage')
165
  );
166
  if ( self::isPluginPage('-reports') ) {
167
+ wp_register_script('flot', plugins_url('/js/flot/jquery.flot.js', __FILE__), array('jquery'), null, true);
168
+ wp_register_script('flotstack', plugins_url('/js/flot/jquery.flot.stack.js', __FILE__), array('flot'), null, true);
169
+ wp_register_script('flotresize', plugins_url('/js/flot/jquery.flot.resize.js', __FILE__), array('flot'), null, true);
170
+ wp_enqueue_script('flot');
171
+ wp_enqueue_script('flotstack');
172
+ wp_enqueue_script('flotresize');
173
  wp_enqueue_script('mandrill-report-export');
174
  }
175
  }
181
  }
182
 
183
  static function network_connect_notice() {
184
+ $shown = get_site_option('wpmandrill_notice_shown');
185
+ if ( empty($shown) ) {
186
+ ?>
187
+ <div id="message" class="updated wpmandrill-message">
188
+ <div class="squeezer">
189
+ <h4><?php _e( '<strong>wpMandrill is activated!</strong> Each site on your network must be connected individually by an admin on that site.', self::WPDOMAIN ) ?></h4>
190
+ </div>
191
  </div>
192
+ <?php
193
+ update_site_option('wpmandrill_notice_shown',true);
194
+ }
195
  }
196
 
197
  static function adminNotices() {
202
 
203
  static function showAdminEnqueueScripts($hook_suffix) {
204
  if( $hook_suffix == self::$report && self::isConnected() ) {
205
+ wp_register_script('mandrill-report-script', plugins_url("js/mandrill.js", __FILE__), array('flot'), null, true);
 
 
 
206
  wp_enqueue_script('mandrill-report-script');
 
207
  }
208
  }
209
 
218
 
219
  $ok = array();
220
  $ok['account'] = ( !wpMandrill::isConnected() ) ? ' class="missing"' : '';
221
+ $ok['domains'] = ( $ok['account'] != '' || !count(self::ListVerifiedDomains()) ) ? ' class="missing"' : '';
222
  $ok['email'] = ( $ok['account'] != '' || !self::getFromEmail() ) ? ' class="missing"' : '';
223
 
224
  $requirements = '';
611
  * @return array|bool
612
  */
613
  static function listVerifiedDomains() {
614
+ $domains = array();
615
+
616
  self::getConnected();
617
+ if ( !self::isConnected() ) return $domains;
618
 
619
  try {
620
  $domains = self::$mandrill->senders_domains();
621
+ if ( !empty($domains) ) $domains = array_values($domains);
622
+ } catch ( Exception $e ) {}
 
 
623
 
624
+ return $domains;
625
  }
626
 
627
 
729
  $from_email = self::getFromEmail();
730
 
731
  $domains = self::ListVerifiedDomains();
732
+ if ( !count($domains) ) {
733
 
734
  _e('No domains found.', self::WPDOMAIN);
735
 
877
  /**
878
  * @return array
879
  */
880
+ static function getRawStatistics() {
881
  self::getConnected();
882
 
883
  if ( !self::isConnected() ) return array();
940
  }
941
 
942
  static function getProcessedStats() {
943
+ $stats = self::getRawStatistics();
944
  if ( empty($stats) ) return $stats;
945
 
946
  $graph_data = array();
1017
  return $stats;
1018
  }
1019
 
1020
+ /**
1021
+ * Try to get the current stats from cache. First, using a transient, if it has expired, it returns the latest
1022
+ * saved stats if found... and if there's none saved, it creates it diretly from Mandrill.
1023
+ */
1024
  static function getCurrentStats() {
1025
 
1026
  $stats = get_transient(self::WPDOMAIN.'-stats');
1027
  if ( empty($stats) ) {
1028
+ $stats = get_option(self::WPDOMAIN.'-stats');
1029
+
1030
+ if ( empty($stats) ) $stats = self::saveProcessedStats();
1031
+
1032
  }
1033
 
1034
  return $stats;
1035
  }
1036
+
1037
+ /**
1038
+ * Creates the stats directly from Mandrill and saves it in a transient and a backup persistent option.
1039
+ *
1040
+ * @return array The saved stats
1041
+ */
1042
+ static function saveProcessedStats() {
1043
+ $stats = self::GetProcessedStats();
1044
+ if ( !empty($stats) ) {
1045
+ set_transient(self::WPDOMAIN.'-stats', $stats, 60 * 60);
1046
+ update_option(self::WPDOMAIN.'-stats', $stats);
1047
+ }
1048
+
1049
+ return $stats;
1050
+ }
1051
+
1052
  static function addDashboardWidgets() {
1053
  self::getConnected();
1054
  if ( !self::isConnected() ) return;
1187
  $lit['bounced'] = __('Bounced or Rejected', self::WPDOMAIN);
1188
  $lit['opened'] = __('Opened', self::WPDOMAIN);
1189
 
1190
+ $tickFormatter = 'emailFormatter';
1191
+ $format_sufix = ' email(s)';
1192
  if ( $display == 'average' ) {
1193
  $lit['title'] = __('Average Sending Volume', self::WPDOMAIN);
1194
  $lit['label_suffix'] .= __('/day', self::WPDOMAIN);
1199
  $data['bounces'][$period] = number_format($data['bounces'][$period] / $days,2);
1200
  $data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
1201
  }
1202
+ $tickFormatter = 'percentageFormatter';
1203
+ $format_sufix = '%';
1204
  }
1205
  // Filling arrays for recent stats
1206
+ $unopens['recent'] = '[0,' . $data['unopens']['today'] . '],[1,' . $data['unopens']['last_7_days'] . ']';
1207
+ $opens['recent'] = '[0,' . $data['opens']['today'] . '],[1,' . $data['opens']['last_7_days'] . ']';
1208
+ $bounces['recent'] = '[0,' . $data['bounces']['today'] . '],[1,' . $data['bounces']['last_7_days'] . ']';
1209
 
1210
 
1211
  $js = '';
1212
  if ( !$isAjaxCall ) {
1213
+ $js .= '
1214
+ <script type="text/javascript" src="'.plugins_url('/js/flot/jquery.flot.js', __FILE__).'"></script>
1215
+ <script type="text/javascript" src="'.plugins_url('/js/flot/jquery.flot.stack.js', __FILE__).'"></script>
1216
+ <script type="text/javascript" src="'.plugins_url('/js/flot/jquery.flot.resize.js', __FILE__).'"></script>';
1217
+
1218
  $js .= '
1219
  <div style="height:400px;">
1220
+ <div id="filtered_recent" style="height:400px;">Loading...</div>
1221
  </div>
1222
  <script type="text/javascript">
1223
  jQuery(document).bind( \'ready\', function() {
1224
  ';
1225
  }
1226
  $js .= <<<JS
1227
+ function emailFormatter(v, axis) {
1228
+ return v.toFixed(axis.tickDecimals) +" emails";
1229
+ }
1230
+ function percentageFormatter(v, axis) {
1231
+ return v.toFixed(axis.tickDecimals) +"%";
1232
+ }
1233
+ function wpm_showTooltip(x, y, contents) {
1234
+ jQuery('<div id="wpm_tooltip">' + contents + '</div>').css( {
1235
+ position: 'absolute',
1236
+ display: 'none',
1237
+ top: y + 5,
1238
+ left: x + 5,
1239
+ border: '1px solid #fdd',
1240
+ padding: '2px',
1241
+ 'background-color': '#fee',
1242
+ opacity: 0.80
1243
+ }).appendTo("body").fadeIn(200);
1244
+ }
1245
+ var previousPoint = null;
1246
+ jQuery("#filtered_recent").bind("plothover", function (event, pos, item) {
1247
+ if (item) {
1248
+ if (previousPoint != item.dataIndex) {
1249
+ previousPoint = item.dataIndex;
1250
+
1251
+ jQuery("#wpm_tooltip").remove();
1252
+ var x = item.datapoint[0].toFixed(0);
1253
+
1254
+ if ( '{$tickFormatter}' == 'emailFormatter' ) {
1255
+ var y = item.datapoint[1].toFixed(0);
1256
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " = " + y + " emails");
1257
+ } else {
1258
+ var y = item.datapoint[1].toFixed(2);
1259
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " = " + y + "%");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1260
  }
1261
+ }
1262
+ }
1263
+ else {
1264
+ jQuery("#wpm_tooltip").remove();
1265
+ previousPoint = null;
1266
+ }
1267
+ });
1268
+ jQuery(function () {
1269
+ var hbounces= [{$bounces['recent']}];
1270
+ var hopens = [{$opens['recent']}];
1271
+ var huopens = [{$unopens['recent']}];
1272
+
1273
+ jQuery.plot(jQuery("#filtered_recent"),
1274
+ [ { data: hbounces, label: "{$lit['bounced']}" },
1275
+ { data: hopens, label: "{$lit['opened']}" },
1276
+ { data: huopens, label: "{$lit['unopened']}" }],
1277
+ {
1278
+ series: {
1279
+ stack: false,
1280
+ bars: {show: true, barWidth: 0.6, align: "center"},
1281
+ points: { show: false },
1282
+ lines: { show: false },
1283
+ shadowSize: 4
1284
+ },
1285
+ grid: {
1286
+ hoverable: true,
1287
+ aboveData: true,
1288
+ borderWidth: 0,
1289
+ minBorderMargin: 10,
1290
+ margin: {
1291
+ top: 10,
1292
+ left: 10,
1293
+ bottom: 15,
1294
+ right: 10
1295
+ }
1296
+ },
1297
+ xaxes: [ { ticks: [[0,"{$lit['today']}"],[1,"{$lit['last7days']}"]] } ],
1298
+ yaxes: [ { min: 0, tickFormatter: {$tickFormatter} } ],
1299
+ legend: { position: 'ne', margin: [20, 10]}
1300
+ });
1301
  });
1302
  JS;
1303
 
1304
+ if ( !$isAjaxCall ) {
1305
+ $js .= '
1306
  });
1307
  </script>';
1308
+ }
1309
+
1310
+ echo $js;
1311
+
1312
+ if ( $isAjaxCall ) exit();
1313
 
1314
  }
1315
 
1431
  $lit['bounced'] = __('Bounced or Rejected', self::WPDOMAIN);
1432
  $lit['opened'] = __('Opened', self::WPDOMAIN);
1433
 
1434
+ $tickFormatter = 'emailFormatter';
1435
+ $format_sufix = ' email(s)';
1436
  if ( $display == 'average' ) {
1437
  $lit['title'] = __('Average Sending Volume', self::WPDOMAIN);
1438
  $lit['label_suffix'] .= __('/day', self::WPDOMAIN);
1443
  $data['bounces'][$period] = number_format($data['bounces'][$period] / $days,2);
1444
  $data['unopens'][$period] = number_format($data['unopens'][$period] / $days,2);
1445
  }
1446
+ $tickFormatter = 'percentageFormatter';
1447
+ $format_sufix = '%';
1448
  }
1449
 
1450
  // Filling arrays for recent stats
1451
+ $unopens['recent'] = '[0,' .$data['unopens']['today'] . '],[1,' . $data['unopens']['last_7_days'] . ']';
1452
+ $opens['recent'] = '[0,' .$data['opens']['today'] . '],[1,' . $data['opens']['last_7_days'] . ']';
1453
+ $bounces['recent'] = '[0,' .$data['bounces']['today'] . '],[1,' . $data['bounces']['last_7_days'] . ']';
1454
 
1455
  // Filling arrays for older stats
1456
+ $unopens['oldest'] = '[0,' .$data['unopens']['last_30_days'] . '],[1,' . $data['unopens']['last_60_days'] . '],[2,' . $data['unopens']['last_90_days'] . ']';
1457
+ $opens['oldest'] = '[0,' .$data['opens']['last_30_days'] . '],[1,' . $data['opens']['last_60_days'] . '],[2,' . $data['opens']['last_90_days'] . ']';
1458
+ $bounces['oldest'] = '[0,' .$data['bounces']['last_30_days'] . '],[1,' . $data['bounces']['last_60_days'] . '],[2,' . $data['bounces']['last_90_days'] . ']';
1459
+
1460
+ // Today and 7-days-old stats data
1461
+
1462
+ $obounced = $bounces['oldest'];
1463
+ $oopened = $opens['oldest'];
1464
+ $ounopened= $unopens['oldest'];
1465
+
1466
+ $rbounced = $bounces['recent'];
1467
+ $ropened = $opens['recent'];
1468
+ $runopened= $unopens['recent'];
1469
+
1470
  $js = <<<JS
1471
+ var rbounced = [{$rbounced}];
1472
+ var ropened = [{$ropened}];
1473
+ var runopened = [{$runopened}]
1474
+
1475
+ var obounced = [{$obounced}];
1476
+ var oopened = [{$oopened}];
1477
+ var ounopened = [{$ounopened}]
1478
+
1479
  jQuery(function () {
1480
+ var previousPoint = null;
1481
+ jQuery("#filtered_recent").bind("plothover", function (event, pos, item) {
1482
+ if (item) {
1483
+ if (previousPoint != item.dataIndex) {
1484
+ previousPoint = item.dataIndex;
1485
+
1486
+ jQuery("#wpm_tooltip").remove();
1487
+ var x = item.datapoint[0].toFixed(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1488
 
1489
+ if ( '{$tickFormatter}' == 'emailFormatter' ) {
1490
+ var y = item.datapoint[1].toFixed(0);
1491
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " = " + y + " emails");
1492
+ } else {
1493
+ var y = item.datapoint[1].toFixed(2);
1494
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " = " + y + "%");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1495
  }
1496
+ }
1497
  }
1498
+ else {
1499
+ jQuery("#wpm_tooltip").remove();
1500
+ previousPoint = null;
1501
+ }
1502
+ });
1503
+ jQuery("#filtered_oldest").bind("plothover", function (event, pos, item) {
1504
+ if (item) {
1505
+ if (previousPoint != item.dataIndex) {
1506
+ previousPoint = item.dataIndex;
1507
+
1508
+ jQuery("#wpm_tooltip").remove();
1509
+ var x = dticks[item.dataIndex];
1510
+
1511
+ if ( '{$tickFormatter}' == 'emailFormatter' ) {
1512
+ var y = item.datapoint[1].toFixed(0);
1513
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " = " + y + " emails");
1514
+ } else {
1515
+ var y = item.datapoint[1].toFixed(2);
1516
+ wpm_showTooltip(item.pageX, item.pageY, item.series.label + " = " + y + "%");
1517
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1518
  }
1519
+ }
1520
+ else {
1521
+ jQuery("#wpm_tooltip").remove();
1522
+ previousPoint = null;
1523
+ }
1524
+ });
1525
+ jQuery.plot(jQuery("#filtered_recent"),
1526
+ [ { data: rbounced, label: "{$lit['bounced']}" },
1527
+ { data: ropened, label: "{$lit['opened']}" },
1528
+ { data: runopened, label: "{$lit['unopened']}" }],
1529
+ {
1530
+ series: {
1531
+ stack: false,
1532
+ bars: {show: true, barWidth: 0.6, align: "center"},
1533
+ points: { show: false },
1534
+ lines: { show: false },
1535
+ shadowSize: 4
1536
+ },
1537
+ grid: {
1538
+ hoverable: true,
1539
+ aboveData: true,
1540
+ borderWidth: 0,
1541
+ minBorderMargin: 10,
1542
+ margin: {
1543
+ top: 10,
1544
+ left: 10,
1545
+ bottom: 15,
1546
+ right: 10
1547
+ }
1548
+ },
1549
+ xaxes: [ { ticks: [[0,"{$lit['today']}"],[1,"{$lit['last7days']}"]] } ],
1550
+ yaxes: [ { min: 0, tickFormatter: {$tickFormatter} } ],
1551
+ legend: { position: 'ne', margin: [20, 10]}
1552
+ });
1553
+ jQuery.plot(jQuery("#filtered_oldest"),
1554
+ [ { data: obounced, label: "{$lit['bounced']}" },
1555
+ { data: oopened, label: "{$lit['opened']}" },
1556
+ { data: ounopened, label: "{$lit['unopened']}" }],
1557
+ {
1558
+ series: {
1559
+ stack: false,
1560
+ bars: {show: true, barWidth: 0.6, align: "center"},
1561
+ points: { show: true },
1562
+ lines: { show: true },
1563
+ shadowSize: 4
1564
+ },
1565
+ grid: {
1566
+ hoverable: true,
1567
+ aboveData: true,
1568
+ borderWidth: 0,
1569
+ minBorderMargin: 10,
1570
+ margin: {
1571
+ top: 10,
1572
+ left: 10,
1573
+ bottom: 15,
1574
+ right: 10
1575
+ }
1576
+ },
1577
+ xaxes: [ { ticks: [[0,"{$lit['last30days']}"],[1,"{$lit['last60days']}"],[2,"{$lit['last90days']}"]] } ],
1578
+ yaxes: [ { min: 0, tickFormatter: {$tickFormatter} }],
1579
+ legend: { position: 'ne', margin: [20, 10]}
1580
+ });
1581
  });
1582
  JS;
1583
  echo $js;
1796
 
1797
  // Letting the user filter/change the message payload
1798
  if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
1799
+ error_log( "\nwpMandrill::sendEmail: Before mandrill_payload ".print_r(array_replace($message,array('html' => '', 'text' => '', 'template' => '')),true)."\n" );
1800
  }
1801
  $message = apply_filters('mandrill_payload', $message);
1802
  if ( defined('WP_DEBUG') && WP_DEBUG !== false ) {
1803
+ error_log( "\nwpMandrill::sendEmail: After mandrill_payload ".print_r(array_replace($message,array('html' => '', 'text' => '', 'template' => '')),true)."\n" );
1804
  }
1805
 
1806
  // Checking that the final From: email address is valid
1847
 
1848
  return $attachments;
1849
  }
1850
+ }
1851
+ function wpMandrill_transformJSArray(&$value, $key, $params = 0) {
1852
+ if ( is_array($params) ) {
1853
+ $format = isset($params[0]) ? $params[0] : 0;
1854
+ $day_keys = isset($params[1]) ? $params[1] : array();
1855
+ }
1856
+ switch ( $format ) {
1857
+ case 0:
1858
+ $value = "[$key,$value]";
1859
+ break;
1860
+ case 1:
1861
+ $key = array_search($key,$day_keys);
1862
+ $value = "[$key,$value]";
1863
+ break;
1864
+ }
1865
  }
1866
  ?>