--- /dev/null
+/*
+ Highstock JS v1.3.9 (2014-01-15)
+
+ (c) 2009-2014 Torstein Honsi
+
+ License: www.highcharts.com/license
+*/
+(function(){function u(a,b){var c;a||(a={});for(c in b)a[c]=b[c];return a}function w(){var a,b=arguments,c,d={},e=function(a,b){var c,d;typeof a!=="object"&&(a={});for(d in b)b.hasOwnProperty(d)&&(c=b[d],a[d]=c&&typeof c==="object"&&Object.prototype.toString.call(c)!=="[object Array]"&&typeof c.nodeType!=="number"?e(a[d]||{},c):b[d]);return a};b[0]===!0&&(d=b[1],b=Array.prototype.slice.call(b,2));c=b.length;for(a=0;a<c;a++)d=e(d,b[a]);return d}function gb(){for(var a=0,b=arguments,c=b.length,d={};a<
+c;a++)d[b[a++]]=b[a];return d}function E(a,b){return parseInt(a,b||10)}function ma(a){return typeof a==="string"}function aa(a){return typeof a==="object"}function Pa(a){return Object.prototype.toString.call(a)==="[object Array]"}function ua(a){return typeof a==="number"}function Ea(a){return T.log(a)/T.LN10}function na(a){return T.pow(10,a)}function oa(a,b){for(var c=a.length;c--;)if(a[c]===b){a.splice(c,1);break}}function t(a){return a!==r&&a!==null}function H(a,b,c){var d,e;if(ma(b))t(c)?a.setAttribute(b,
+c):a&&a.getAttribute&&(e=a.getAttribute(b));else if(t(b)&&aa(b))for(d in b)a.setAttribute(d,b[d]);return e}function ja(a){return Pa(a)?a:[a]}function o(){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 z(a,b){if(Fa&&b&&b.opacity!==r)b.filter="alpha(opacity="+b.opacity*100+")";u(a.style,b)}function Z(a,b,c,d,e){a=F.createElement(a);b&&u(a,b);e&&z(a,{padding:0,border:ba,margin:0});c&&z(a,c);d&&d.appendChild(a);return a}function ea(a,b){var c=
+function(){};c.prototype=new a;u(c.prototype,b);return c}function Ga(a,b,c,d){var e=L.lang,a=+a||0,f=b===-1?(a.toString().split(".")[1]||"").length:isNaN(b=O(b))?2:b,b=c===void 0?e.decimalPoint:c,d=d===void 0?e.thousandsSep:d,e=a<0?"-":"",c=String(E(a=O(a).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+O(a-c).toFixed(f).slice(2):"")}function Qa(a,b){return Array((b||2)+1-String(a).length).join(0)+a}function U(a,b,c){var d=a[b];
+a[b]=function(){var a=Array.prototype.slice.call(arguments);a.unshift(d);return c.apply(this,a)}}function Ha(a,b){for(var c="{",d=!1,e,f,g,h,i,j=[];(c=a.indexOf(c))!==-1;){e=a.slice(0,c);if(d){f=e.split(":");g=f.shift().split(".");i=g.length;e=b;for(h=0;h<i;h++)e=e[g[h]];if(f.length)f=f.join(":"),g=/\.([0-9])/,h=L.lang,i=void 0,/f$/.test(f)?(i=(i=f.match(g))?i[1]:-1,e=Ga(e,i,h.decimalPoint,f.indexOf(",")>-1?h.thousandsSep:"")):e=ra(f,e)}j.push(e);a=a.slice(c+1);c=(d=!d)?"}":"{"}j.push(a);return j.join("")}
+function tb(a){return T.pow(10,Q(T.log(a)/T.LN10))}function ub(a,b,c,d){var e,c=o(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 Kb(){this.symbol=this.color=0}function vb(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 Ra(a){for(var b=a.length,c=a[0];b--;)a[b]<
+c&&(c=a[b]);return c}function va(a){for(var b=a.length,c=a[0];b--;)a[b]>c&&(c=a[b]);return c}function Ia(a,b){for(var c in a)a[c]&&a[c]!==b&&a[c].destroy&&a[c].destroy(),delete a[c]}function Sa(a){hb||(hb=Z(Ta));a&&hb.appendChild(a);hb.innerHTML=""}function pa(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+a;if(b)throw c;else V.console&&console.log(c)}function ga(a){return parseFloat(a.toPrecision(14))}function Xa(a,b){wa=o(a,b.animation)}function Lb(){var a=L.global.useUTC,b=a?
+"getUTC":"get",c=a?"setUTC":"set";Ja=(a&&L.global.timezoneOffset||0)*6E4;ib=a?Date.UTC:function(a,b,c,g,h,i){return(new Date(a,b,o(c,1),o(g,0),o(h,0),o(i,0))).getTime()};wb=b+"Minutes";xb=b+"Hours";yb=b+"Day";Ua=b+"Date";jb=b+"Month";kb=b+"FullYear";Mb=c+"Minutes";Nb=c+"Hours";zb=c+"Date";Ob=c+"Month";Pb=c+"FullYear"}function xa(){}function Ya(a,b,c,d){this.axis=a;this.pos=b;this.type=c||"";this.isNew=!0;!c&&!d&&this.addLabel()}function Qb(a,b,c,d,e,f){var g=a.chart.inverted;this.axis=a;this.isNegative=
+c;this.options=b;this.x=d;this.total=null;this.points={};this.stack=e;this.percent=f==="percent";this.alignOptions={align:b.align||(g?c?"left":"right":"center"),verticalAlign:b.verticalAlign||(g?"middle":c?"bottom":"top"),y:o(b.y,g?4:c?14:-6),x:o(b.x,g?c?-6:6:0)};this.textAlign=b.textAlign||(g?c?"right":"left":"center")}function W(){this.init.apply(this,arguments)}function Ab(){this.init.apply(this,arguments)}function ya(){this.init.apply(this,arguments)}function Bb(a){var b=a.options,c=b.navigator,
+d=c.enabled,b=b.scrollbar,e=b.enabled,f=d?c.height:0,g=e?b.height:0;this.handles=[];this.scrollbarButtons=[];this.elementsToDestroy=[];this.chart=a;this.setBaseSeries();this.height=f;this.scrollbarHeight=g;this.scrollbarEnabled=e;this.navigatorEnabled=d;this.navigatorOptions=c;this.scrollbarOptions=b;this.outlineHeight=f+g;this.init()}function Cb(a){this.init(a)}var r,F=document,V=window,T=Math,v=T.round,Q=T.floor,Va=T.ceil,s=T.max,y=T.min,O=T.abs,ca=T.cos,ha=T.sin,Ka=T.PI,La=Ka*2/360,za=navigator.userAgent,
+Rb=V.opera,Fa=/msie/i.test(za)&&!Rb,lb=F.documentMode===8,mb=/AppleWebKit/.test(za),bb=/Firefox/.test(za),cb=/(Mobile|Android|Windows Phone)/.test(za),Ma="http://www.w3.org/2000/svg",da=!!F.createElementNS&&!!F.createElementNS(Ma,"svg").createSVGRect,Yb=bb&&parseInt(za.split("Firefox/")[1],10)<4,ka=!da&&!Fa&&!!F.createElement("canvas").getContext,Za,db=F.documentElement.ontouchstart!==r,Sb={},Db=0,hb,L,ra,wa,Eb,B,la=function(){},Wa=[],Ta="div",ba="none",Zb=/^[0-9]+$/,Tb="rgba(192,192,192,"+(da?1.0E-4:
+0.002)+")",Ub="stroke-width",ib,Ja,wb,xb,yb,Ua,jb,kb,Mb,Nb,zb,Ob,Pb,D={};V.Highcharts=V.Highcharts?pa(16,!0):{};ra=function(a,b,c){if(!t(b)||isNaN(b))return"Invalid date";var a=o(a,"%Y-%m-%d %H:%M:%S"),d=new Date(b-Ja),e,f=d[xb](),g=d[yb](),h=d[Ua](),i=d[jb](),j=d[kb](),k=L.lang,l=k.weekdays,d=u({a:l[g].substr(0,3),A:l[g],d:Qa(h),e:h,b:k.shortMonths[i],B:k.months[i],m:Qa(i+1),y:j.toString().substr(2,2),Y:j,H:Qa(f),I:Qa(f%12||12),l:f%12||12,M:Qa(d[wb]()),p:f<12?"AM":"PM",P:f<12?"am":"pm",S:Qa(d.getSeconds()),
+L:Qa(v(b%1E3),3)},Highcharts.dateFormats);for(e in d)for(;a.indexOf("%"+e)!==-1;)a=a.replace("%"+e,typeof d[e]==="function"?d[e](b):d[e]);return c?a.substr(0,1).toUpperCase()+a.substr(1):a};Kb.prototype={wrapColor:function(a){if(this.color>=a)this.color=0},wrapSymbol:function(a){if(this.symbol>=a)this.symbol=0}};B=gb("millisecond",1,"second",1E3,"minute",6E4,"hour",36E5,"day",864E5,"week",6048E5,"month",26784E5,"year",31556952E3);Eb={init:function(a,b,c){var b=b||"",d=a.shift,e=b.indexOf("C")>-1,
+f=e?7:3,g,b=b.split(" "),c=[].concat(c),h,i,j=function(a){for(g=a.length;g--;)a[g]==="M"&&a.splice(g+1,0,a[g+1],a[g+2],a[g+1],a[g+2])};e&&(j(b),j(c));a.isArea&&(h=b.splice(b.length-6,6),i=c.splice(c.length-6,6));if(d<=c.length/f&&b.length===c.length)for(;d--;)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=parseFloat(a[f]),e[f]=isNaN(d)?a[f]:c*parseFloat(b[f]-d)+d;else e=b;return e}};(function(a){V.HighchartsAdapter=V.HighchartsAdapter||a&&{init:function(b){var c=a.fx,d=c.step,e,f=a.Tween,g=f&&f.propHooks;e=a.cssHooks.opacity;a.extend(a.easing,{easeOutQuad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c}});a.each(["cur","_default","width","height","opacity"],function(a,b){var e=d,k;b==="cur"?e=c.prototype:b==="_default"&&f&&(e=g[b],b="set");
+(k=e[b])&&(e[b]=function(c){var d,c=a?c:this;if(c.prop!=="align")return d=c.elem,d.attr?d.attr(c.prop,b==="cur"?r:c.now):k.apply(this,arguments)})});U(e,"get",function(a,b,c){return b.attr?b.opacity||0:a.call(this,b,c)});e=function(a){var c=a.elem,d;if(!a.started)d=b.init(c,c.d,c.toD),a.start=d[0],a.end=d[1],a.started=!0;c.attr("d",b.step(a.start,a.end,a.pos,c.toD))};f?g.d={set:e}:d.d=e;this.each=Array.prototype.forEach?function(a,b){return Array.prototype.forEach.call(a,b)}: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};a.fn.highcharts=function(){var a="Chart",b=arguments,c,d;ma(b[0])&&(a=b[0],b=Array.prototype.slice.call(b,1));c=b[0];if(c!==r)c.chart=c.chart||{},c.chart.renderTo=this[0],new Highcharts[a](c,b[1]),d=this;c===r&&(d=Wa[H(this[0],"data-highcharts-chart")]);return d}},getScript:a.getScript,inArray:a.inArray,adapterRun:function(b,c){return a(b)[c]()},grep:a.grep,map:function(a,c){for(var d=[],e=0,f=a.length;e<f;e++)d[e]=c.call(a[e],a[e],e,a);
+return d},offset:function(b){return a(b).offset()},addEvent:function(b,c,d){a(b).bind(c,d)},removeEvent:function(b,c,d){var e=F.removeEventListener?"removeEventListener":"detachEvent";F[e]&&b&&!b[e]&&(b[e]=function(){});a(b).unbind(c,d)},fireEvent:function(b,c,d,e){var f=a.Event(c),g="detached"+c,h;!Fa&&d&&(delete d.layerX,delete d.layerY);u(f,d);b[c]&&(b[g]=b[c],b[c]=null);a.each(["preventDefault","stopPropagation"],function(a,b){var c=f[b];f[b]=function(){try{c.call(f)}catch(a){b==="preventDefault"&&
+(h=!0)}}});a(b).trigger(f);b[g]&&(b[c]=b[g],b[g]=null);e&&!f.isDefaultPrevented()&&!h&&e(f)},washMouseEvent:function(a){var c=a.originalEvent||a;if(c.pageX===r)c.pageX=a.pageX,c.pageY=a.pageY;return c},animate:function(b,c,d){var e=a(b);if(!b.style)b.style={};if(c.d)b.toD=c.d,c.d=1;e.stop();c.opacity!==r&&b.attr&&(c.opacity+="px");e.animate(c,d)},stop:function(b){a(b).stop()}}})(V.jQuery);var R=V.HighchartsAdapter,K=R||{};R&&R.init.call(R,Eb);var nb=K.adapterRun,$b=K.getScript,Aa=K.inArray,q=K.each,
+Fb=K.grep,ac=K.offset,Na=K.map,A=K.addEvent,X=K.removeEvent,N=K.fireEvent,bc=K.washMouseEvent,ob=K.animate,eb=K.stop,K={enabled:!0,x:0,y:15,style:{color:"#666",cursor:"default",fontSize:"11px"}};L={colors:"#2f7ed8,#0d233a,#8bbc21,#910000,#1aadce,#492970,#f28f43,#77a1e5,#c42525,#a6c96a".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(","),decimalPoint:".",numericSymbols:"k,M,G,T,P,E".split(","),resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:","},global:{useUTC:!0,canvasToolsURL:"http://code.highcharts.com/stock/1.3.9/modules/canvas-tools.js",VMLRadialGradientURL:"http://code.highcharts.com/stock/1.3.9/gfx/vml-radial-gradient.png"},chart:{borderColor:"#4572A7",borderRadius:5,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacing:[10,
+10,15,10],style:{fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif',fontSize:"12px"},backgroundColor:"#FFFFFF",plotBorderColor:"#C0C0C0",resetZoomButton:{theme:{zIndex:20},position:{align:"right",x:-10,y:10}}},title:{text:"Chart title",align:"center",margin:15,style:{color:"#274b6d",fontSize:"16px"}},subtitle:{text:"",align:"center",style:{color:"#4d759e"}},plotOptions:{line:{allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},lineWidth:2,
+marker:{enabled:!0,lineWidth:0,radius:4,lineColor:"#FFFFFF",states:{hover:{enabled:!0},select:{fillColor:"#FFFFFF",lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:w(K,{align:"center",enabled:!1,formatter:function(){return this.y===null?"":Ga(this.y,-1)},verticalAlign:"bottom",y:0}),cropThreshold:300,pointRange:0,states:{hover:{marker:{}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3}},labels:{style:{position:"absolute",color:"#3E576F"}},legend:{enabled:!0,align:"center",
+layout:"horizontal",labelFormatter:function(){return this.name},borderWidth:1,borderColor:"#909090",borderRadius:5,navigation:{activeColor:"#274b6d",inactiveColor:"#CCC"},shadow:!1,itemStyle:{cursor:"pointer",color:"#274b6d",fontSize:"12px"},itemHoverStyle:{color:"#000"},itemHiddenStyle:{color:"#CCC"},itemCheckboxStyle:{position:"absolute",width:"13px",height:"13px"},symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",
+top:"1em"},style:{position:"absolute",backgroundColor:"white",opacity:0.5,textAlign:"center"}},tooltip:{enabled:!0,animation:da,backgroundColor:"rgba(255, 255, 255, .85)",borderWidth:1,borderRadius:3,dateTimeLabelFormats:{millisecond:"%A, %b %e, %H:%M:%S.%L",second:"%A, %b %e, %H:%M:%S",minute:"%A, %b %e, %H:%M",hour:"%A, %b %e, %H:%M",day:"%A, %b %e, %Y",week:"Week from %A, %b %e, %Y",month:"%B %Y",year:"%Y"},headerFormat:'<span style="font-size: 10px">{point.key}</span><br/>',pointFormat:'<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>',
+shadow:!0,snap:cb?25:10,style:{color:"#333333",cursor:"default",fontSize:"12px",padding:"8px",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:"9px"}}};var S=L.plotOptions,R=S.line;Lb();var cc=/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*\)/,dc=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,ec=
+/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,Ba=function(a){var b=[],c,d;(function(a){a&&a.stops?d=Na(a.stops,function(a){return Ba(a[1])}):(c=cc.exec(a))?b=[E(c[1]),E(c[2]),E(c[3]),parseFloat(c[4],10)]:(c=dc.exec(a))?b=[E(c[1],16),E(c[2],16),E(c[3],16),1]:(c=ec.exec(a))&&(b=[E(c[1]),E(c[2]),E(c[3]),1])})(a);return{get:function(c){var f;d?(f=w(a),f.stops=[].concat(f.stops),q(d,function(a,b){f.stops[b]=[f.stops[b][0],a.get(c)]})):f=b&&!isNaN(b[0])?c==="rgb"?"rgb("+b[0]+","+b[1]+
+","+b[2]+")":c==="a"?b[3]:"rgba("+b.join(",")+")":a;return f},brighten:function(a){if(d)q(d,function(b){b.brighten(a)});else if(ua(a)&&a!==0){var c;for(c=0;c<3;c++)b[c]+=E(a*255),b[c]<0&&(b[c]=0),b[c]>255&&(b[c]=255)}return this},rgba:b,setOpacity:function(a){b[3]=a;return this}}};xa.prototype={init:function(a,b){this.element=b==="span"?Z(b):F.createElementNS(Ma,b);this.renderer=a;this.attrSetters={}},opacity:1,animate:function(a,b,c){b=o(b,wa,!0);eb(this);if(b){b=w(b);if(c)b.complete=c;ob(this,a,
+b)}else this.attr(a),c&&c()},attr:function(a,b){var c,d,e,f,g=this.element,h=g.nodeName.toLowerCase(),i=this.renderer,j,k=this.attrSetters,l=this.shadows,m,p,n=this;ma(a)&&t(b)&&(c=a,a={},a[c]=b);if(ma(a))c=a,h==="circle"?c={x:"cx",y:"cy"}[c]||c:c==="strokeWidth"&&(c="stroke-width"),n=H(g,c)||this[c]||0,c!=="d"&&c!=="visibility"&&c!=="fill"&&(n=parseFloat(n));else{for(c in a)if(j=!1,d=a[c],e=k[c]&&k[c].call(this,d,c),e!==!1){e!==r&&(d=e);if(c==="d")d&&d.join&&(d=d.join(" ")),/(NaN| {2}|^$)/.test(d)&&
+(d="M 0 0");else if(c==="x"&&h==="text")for(e=0;e<g.childNodes.length;e++)f=g.childNodes[e],H(f,"x")===H(g,"x")&&H(f,"x",d);else if(this.rotation&&(c==="x"||c==="y"))p=!0;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")H(g,{rx:d,ry:d}),j=!0;else if(c==="translateX"||c==="translateY"||c==="rotation"||c==="verticalAlign"||c==="scaleX"||c==="scaleY")j=p=!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=ba;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(",");for(e=d.length;e--;)d[e]=E(d[e])*o(a["stroke-width"],this["stroke-width"]);d=d.join(",")}}else if(c==="width")d=E(d);else if(c==="align")c="text-anchor",d={left:"start",center:"middle",right:"end"}[d];
+else if(c==="title")e=g.getElementsByTagName("title")[0],e||(e=F.createElementNS(Ma,"title"),g.appendChild(e)),e.textContent=d;c==="strokeWidth"&&(c="stroke-width");if(c==="stroke-width"||c==="stroke"){this[c]=d;if(this.stroke&&this["stroke-width"])H(g,"stroke",this.stroke),H(g,"stroke-width",this["stroke-width"]),this.hasStroke=!0;else if(c==="stroke-width"&&d===0&&this.hasStroke)g.removeAttribute("stroke"),this.hasStroke=!1;j=!0}this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)/.test(c)&&
+(m||(this.symbolAttr(a),m=!0),j=!0);if(l&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(c))for(e=l.length;e--;)H(l[e],c,c==="height"?s(d-(l[e].cutHeight||0),0):d);if((c==="width"||c==="height")&&h==="rect"&&d<0)d=0;this[c]=d;c==="text"?(d!==this.textStr&&delete this.bBox,this.textStr=d,this.added&&i.buildText(this)):j||H(g,c,d)}p&&this.updateTransform()}return n},addClass:function(a){var b=this.element,c=H(b,"class")||"";c.indexOf(a)===-1&&H(b,"class",c+" "+a);return this},symbolAttr:function(a){var b=
+this;q("x,y,r,start,end,width,height,innerR,anchorX,anchorY".split(","),function(c){b[c]=o(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",a?"url("+this.renderer.url+"#"+a.id+")":ba)},crisp:function(a,b,c,d,e){var f,g={},h={},i,a=a||this.strokeWidth||this.attr&&this.attr("stroke-width")||0;i=v(a)%2/2;h.x=Q(b||this.x||0)+i;h.y=Q(c||this.y||0)+i;h.width=Q((d||this.width||0)-2*i);h.height=Q((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=this.element,c=this.textWidth=a&&a.width&&b.nodeName.toLowerCase()==="text"&&E(a.width),d,e="",f=function(a,b){return"-"+b.toLowerCase()};if(a&&a.color)a.fill=a.color;this.styles=a=u(this.styles,a);c&&delete a.width;if(Fa&&!da)z(this.element,a);else{for(d in a)e+=d.replace(/([A-Z])/g,f)+":"+a[d]+";";H(b,"style",e)}c&&this.added&&this.renderer.buildText(this);return this},on:function(a,b){var c=this,d=c.element;
+db&&a==="click"?(d.ontouchstart=function(a){c.touchEventFired=Date.now();a.preventDefault();b.call(d,a)},d.onclick=function(a){(za.indexOf("Android")===-1||Date.now()-(c.touchEventFired||0)>1100)&&b.call(d,a)}):d["on"+a]=b;return this},setRadialReference:function(a){this.element.radialReference=a;return this},translate:function(a,b){return this.attr({translateX:a,translateY:b})},invert:function(){this.inverted=!0;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||
+0,b=this.translateY||0,c=this.scaleX,d=this.scaleY,e=this.inverted,f=this.rotation;e&&(a+=this.attr("width"),b+=this.attr("height"));a=["translate("+a+","+b+")"];e?a.push("rotate(90) scale(-1,1)"):f&&a.push("rotate("+f+" "+(this.x||0)+" "+(this.y||0)+")");(t(c)||t(d))&&a.push("scale("+o(c,1)+" "+o(d,1)+")");a.length&&H(this.element,"transform",a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,b,c){var d,e,f,g,h={};e=this.renderer;f=e.alignedObjects;
+if(a){if(this.alignOptions=a,this.alignByTranslate=b,!c||ma(c))this.alignTo=d=c||"renderer",oa(f,this),f.push(this),c=null}else a=this.alignOptions,b=this.alignByTranslate,d=this.alignTo;c=o(c,e[d],e);d=a.align;e=a.verticalAlign;f=(c.x||0)+(a.x||0);g=(c.y||0)+(a.y||0);if(d==="right"||d==="center")f+=(c.width-(a.width||0))/{right:1,center:2}[d];h[b?"translateX":"x"]=v(f);if(e==="bottom"||e==="middle")g+=(c.height-(a.height||0))/({bottom:1,middle:2}[e]||1);h[b?"translateY":"y"]=v(g);this[this.placed?
+"animate":"attr"](h);this.placed=!0;this.alignAttr=h;return this},getBBox:function(){var a=this.bBox,b=this.renderer,c,d,e=this.rotation;c=this.element;var f=this.styles,g=e*La;d=this.textStr;var h;if(d===""||Zb.test(d))h=d.length+"|"+f.fontSize+"|"+f.fontFamily,a=b.cache[h];if(!a){if(c.namespaceURI===Ma||b.forExport){try{a=c.getBBox?u({},c.getBBox()):{width:c.offsetWidth,height:c.offsetHeight}}catch(i){}if(!a||a.width<0)a={width:0,height:0}}else a=this.htmlGetBBox();if(b.isSVG){c=a.width;d=a.height;
+if(Fa&&f&&f.fontSize==="11px"&&d.toPrecision(3)==="16.9")a.height=d=14;if(e)a.width=O(d*ha(g))+O(c*ca(g)),a.height=O(d*ca(g))+O(c*ha(g))}this.bBox=a;h&&(b.cache[h]=a)}return a},show:function(){return this.attr({visibility:"visible"})},hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var b=this;b.animate({opacity:0},{duration:a||150,complete:function(){b.hide()}})},add:function(a){var b=this.renderer,c=a||b,d=c.element||b.box,e=d.childNodes,f=this.element,g=H(f,"zIndex"),
+h;if(a)this.parentGroup=a;this.parentInverted=a&&a.inverted;this.textStr!==void 0&&b.buildText(this);if(g)c.handleZ=!0,g=E(g);if(c.handleZ)for(c=0;c<e.length;c++)if(a=e[c],b=H(a,"zIndex"),a!==f&&(E(b)>g||!t(g)&&t(b))){d.insertBefore(f,a);h=!0;break}h||d.appendChild(f);this.added=!0;N(this,"add");return this},safeRemoveChild:function(a){var b=a.parentNode;b&&b.removeChild(a)},destroy:function(){var a=this,b=a.element||{},c=a.shadows,d=a.renderer.isSVG&&b.nodeName==="SPAN"&&a.parentGroup,e,f;b.onclick=
+b.onmouseout=b.onmouseover=b.onmousemove=b.point=null;eb(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);for(c&&q(c,function(b){a.safeRemoveChild(b)});d&&d.div.childNodes.length===0;)b=d.parentGroup,a.safeRemoveChild(d.div),delete d.div,d=b;a.alignTo&&oa(a.renderer.alignedObjects,a);for(e in a)delete a[e];return null},shadow:function(a,b,c){var d=[],e,f,g=this.element,h,i,j,k;if(a){i=o(a.width,
+3);j=(a.opacity||0.15)/i;k=this.parentInverted?"(-1,-1)":"("+o(a.offsetX,1)+", "+o(a.offsetY,1)+")";for(e=1;e<=i;e++){f=g.cloneNode(0);h=i*2+1-2*e;H(f,{isShadow:"true",stroke:a.color||"black","stroke-opacity":j*e,"stroke-width":h,transform:"translate"+k,fill:ba});if(c)H(f,"height",s(H(f,"height")-h,0)),f.cutHeight=h;b?b.element.appendChild(f):g.parentNode.insertBefore(f,g);d.push(f)}this.shadows=d}return this}};var sa=function(){this.init.apply(this,arguments)};sa.prototype={Element:xa,init:function(a,
+b,c,d){var e=location,f,g;f=this.createElement("svg").attr({version:"1.1"});g=f.element;a.appendChild(g);a.innerHTML.indexOf("xmlns")===-1&&H(g,"xmlns",Ma);this.isSVG=!0;this.box=g;this.boxWrapper=f;this.alignedObjects=[];this.url=(bb||mb)&&F.getElementsByTagName("base").length?e.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(F.createTextNode("Created with Highstock 1.3.9"));this.defs=this.createElement("defs").add();
+this.forExport=d;this.gradients={};this.cache={};this.setSize(b,c,!1);var h;if(bb&&a.getBoundingClientRect)this.subPixelFix=b=function(){z(a,{left:0,top:0});h=a.getBoundingClientRect();z(a,{left:Va(h.left)-h.left+"px",top:Va(h.top)-h.top+"px"})},b(),A(V,"resize",b)},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();Ia(this.gradients||{});this.gradients=null;if(a)this.defs=a.destroy();this.subPixelFix&&
+X(V,"resize",this.subPixelFix);return this.alignedObjects=null},createElement:function(a){var b=new this.Element;b.init(this,a);return b},draw:function(){},buildText:function(a){for(var b=a.element,c=this,d=c.forExport,e=o(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),f=b.childNodes,g=/style="([^"]+)"/,h=/href="(http[^"]+)"/,
+i=H(b,"x"),j=a.styles,k=a.textWidth,l=j&&j.lineHeight,m=f.length,p=function(a){return l?E(l):c.fontMetrics(/px$/.test(a&&a.style.fontSize)?a.style.fontSize:j.fontSize||11).h};m--;)b.removeChild(f[m]);k&&!a.added&&this.box.appendChild(b);e[e.length-1]===""&&e.pop();q(e,function(e,f){var l,m=0,e=e.replace(/<span/g,"|||<span").replace(/<\/span>/g,"</span>|||");l=e.split("|||");q(l,function(e){if(e!==""||l.length===1){var n={},o=F.createElementNS(Ma,"tspan"),q;g.test(e)&&(q=e.match(g)[1].replace(/(;| |^)color([ :])/,
+"$1fill$2"),H(o,"style",q));h.test(e)&&!d&&(H(o,"onclick",'location.href="'+e.match(h)[1]+'"'),z(o,{cursor:"pointer"}));e=(e.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"<").replace(/>/g,">");if(e!==" "&&(o.appendChild(F.createTextNode(e)),m?n.dx=0:n.x=i,H(o,n),!m&&f&&(!da&&d&&z(o,{display:"block"}),H(o,"dy",p(o),mb&&o.offsetHeight)),b.appendChild(o),m++,k))for(var e=e.replace(/([^\^])-/g,"$1- ").split(" "),n=e.length>1&&j.whiteSpace!=="nowrap",r,s,v=a._clipHeight,t=[],u=p(),fa=1;n&&(e.length||
+t.length);)delete a.bBox,r=a.getBBox(),s=r.width,!da&&c.forExport&&(s=c.measureSpanWidth(o.firstChild.data,a.styles)),r=s>k,!r||e.length===1?(e=t,t=[],e.length&&(fa++,v&&fa*u>v?(e=["..."],a.attr("title",a.textStr)):(o=F.createElementNS(Ma,"tspan"),H(o,{dy:u,x:i}),q&&H(o,"style",q),b.appendChild(o),s>k&&(k=s)))):(o.removeChild(o.firstChild),t.unshift(e.pop())),e.length&&o.appendChild(F.createTextNode(e.join(" ").replace(/- /g,"-")))}})})},button:function(a,b,c,d,e,f,g,h,i){var j=this.label(a,b,c,i,
+null,null,null,null,"button"),k=0,l,m,p,n,$,o,a={x1:0,y1:0,x2:0,y2:1},e=w({"stroke-width":1,stroke:"#CCCCCC",fill:{linearGradient:a,stops:[[0,"#FEFEFE"],[1,"#F6F6F6"]]},r:2,padding:5,style:{color:"black"}},e);p=e.style;delete e.style;f=w(e,{stroke:"#68A",fill:{linearGradient:a,stops:[[0,"#FFF"],[1,"#ACF"]]}},f);n=f.style;delete f.style;g=w(e,{stroke:"#68A",fill:{linearGradient:a,stops:[[0,"#9BD"],[1,"#CDF"]]}},g);$=g.style;delete g.style;h=w(e,{style:{color:"#CCC"}},h);o=h.style;delete h.style;A(j.element,
+Fa?"mouseover":"mouseenter",function(){k!==3&&j.attr(f).css(n)});A(j.element,Fa?"mouseout":"mouseleave",function(){k!==3&&(l=[e,f,g][k],m=[p,n,$][k],j.attr(l).css(m))});j.setState=function(a){(j.state=k=a)?a===2?j.attr(g).css($):a===3&&j.attr(h).css(o):j.attr(e).css(p)};return j.on("click",function(){k!==3&&d.call(j)}).attr(e).css(u({cursor:"default"},p))},crispLine:function(a,b){a[1]===a[4]&&(a[1]=a[4]=v(a[1])-b%2/2);a[2]===a[5]&&(a[2]=a[5]=v(a[2])+b%2/2);return a},path:function(a){var b={fill:ba};
+Pa(a)?b.d=a:aa(a)&&u(b,a);return this.createElement("path").attr(b)},circle:function(a,b,c){a=aa(a)?a:{x:a,y:b,r:c};return this.createElement("circle").attr(a)},arc:function(a,b,c,d,e,f){if(aa(a))b=a.y,c=a.r,d=a.innerR,e=a.start,f=a.end,a=a.x;a=this.symbol("arc",a||0,b||0,c||0,c||0,{innerR:d||0,start:e||0,end:f||0});a.r=c;return a},rect:function(a,b,c,d,e,f){e=aa(a)?a.r:e;e=this.createElement("rect").attr({rx:e,ry:e,fill:ba});return e.attr(aa(a)?a:e.crisp(f,a,b,s(c,0),s(d,0)))},setSize:function(a,
+b,c){var d=this.alignedObjects,e=d.length;this.width=a;this.height=b;for(this.boxWrapper[o(c,!0)?"animate":"attr"]({width:a,height:b});e--;)d[e].align()},g:function(a){var b=this.createElement("g");return t(a)?b.attr({"class":"highcharts-"+a}):b},image:function(a,b,c,d,e){var f={preserveAspectRatio:ba};arguments.length>1&&u(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,b,c,d,e,f){var g,h=this.symbols[a],h=h&&h(v(b),v(c),d,e,f),i=/^url\((.*?)\)$/,j,k;if(h)g=this.path(h),u(g,{symbolName:a,x:b,y:c,width:d,height:e}),f&&u(g,f);else if(i.test(a))k=function(a,b){a.element&&(a.attr({width:b[0],height:b[1]}),a.alignByTranslate||a.translate(v((d-b[0])/2),v((e-b[1])/2)))},j=a.match(i)[1],a=Sb[j],g=this.image(j).attr({x:b,y:c}),g.isImg=!0,a?k(g,a):(g.attr({width:0,height:0}),Z("img",{onload:function(){k(g,Sb[j]=[this.width,this.height])},src:j}));
+return g},symbols:{circle:function(a,b,c,d){var e=0.166*c;return["M",a+c/2,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["M",a,b,"L",a+c,b,a+c,b+d,a,b+d,"Z"]},triangle:function(a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d,a,b+d,"Z"]},"triangle-down":function(a,b,c,d){return["M",a,b,"L",a+c,b,a+c/2,b+d,"Z"]},diamond:function(a,b,c,d){return["M",a+c/2,b,"L",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-0.001,
+d=e.innerR,h=e.open,i=ca(f),j=ha(f),k=ca(g),g=ha(g),e=e.end-f<Ka?0:1;return["M",a+c*i,b+c*j,"A",c,c,0,e,1,a+c*k,b+c*g,h?"M":"L",a+d*k,b+d*g,"A",d,d,0,e,0,a+d*i,b+d*j,h?"":"Z"]}},clipRect:function(a,b,c,d){var e="highcharts-"+Db++,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=this,e,f=/^rgba/,g,h,i,j,k,l,m,p=[];a&&a.linearGradient?g="linearGradient":a&&a.radialGradient&&(g="radialGradient");if(g){c=
+a[g];h=d.gradients;j=a.stops;b=b.radialReference;Pa(c)&&(a[g]=c={x1:c[0],y1:c[1],x2:c[2],y2:c[3],gradientUnits:"userSpaceOnUse"});g==="radialGradient"&&b&&!t(c.gradientUnits)&&(c=w(c,{cx:b[0]-b[2]/2+c.cx*b[2],cy:b[1]-b[2]/2+c.cy*b[2],r:c.r*b[2],gradientUnits:"userSpaceOnUse"}));for(m in c)m!=="id"&&p.push(m,c[m]);for(m in j)p.push(j[m]);p=p.join(",");h[p]?a=h[p].id:(c.id=a="highcharts-"+Db++,h[p]=i=d.createElement(g).attr(c).add(d.defs),i.stops=[],q(j,function(a){f.test(a[1])?(e=Ba(a[1]),k=e.get("rgb"),
+l=e.get("a")):(k=a[1],l=1);a=d.createElement("stop").attr({offset:a[0],"stop-color":k,"stop-opacity":l}).add(i);i.stops.push(a)}));return"url("+d.url+"#"+a+")"}else return f.test(a)?(e=Ba(a),H(b,c+"-opacity",e.get("a")),e.get("rgb")):(b.removeAttribute(c+"-opacity"),a)},text:function(a,b,c,d){var e=L.chart.style,f=ka||!da&&this.forExport;if(d&&!this.forExport)return this.html(a,b,c);b=v(o(b,0));c=v(o(c,0));a=this.createElement("text").attr({x:b,y:c,text:a}).css({fontFamily:e.fontFamily,fontSize:e.fontSize});
+f&&a.css({position:"absolute"});a.x=b;a.y=c;return a},fontMetrics:function(a){var a=E(a||11),a=a<24?a+4:v(a*1.2),b=v(a*0.8);return{h:a,b:b}},label:function(a,b,c,d,e,f,g,h,i){function j(){var a,b;a=o.element.style;x=(Ca===void 0||I===void 0||n.styles.textAlign)&&o.getBBox();n.width=(Ca||x.width||0)+2*s+qb;n.height=(I||x.height||0)+2*s;fa=s+p.fontMetrics(a&&a.fontSize).b;if(Hb){if(!J)a=v(-pb*s),b=h?-fa:0,n.box=J=d?p.symbol(d,a,b,n.width,n.height,P):p.rect(a,b,n.width,n.height,0,P[Ub]),J.add(n);J.isImg||
+J.attr(w({width:n.width,height:n.height},P));P=null}}function k(){var a=n.styles,a=a&&a.textAlign,b=qb+s*(1-pb),c;c=h?0:fa;if(t(Ca)&&(a==="center"||a==="right"))b+={center:0.5,right:1}[a]*(Ca-x.width);(b!==o.x||c!==o.y)&&o.attr({x:b,y:c});o.x=b;o.y=c}function l(a,b){J?J.attr(a,b):P[a]=b}function m(){o.add(n);n.attr({text:a,x:b,y:c});J&&t(e)&&n.attr({anchorX:e,anchorY:f})}var p=this,n=p.g(i),o=p.text("",0,0,g).attr({zIndex:1}),J,x,pb=0,s=3,qb=0,Ca,I,Gb,G,C=0,P={},fa,g=n.attrSetters,Hb;A(n,"add",m);
+g.width=function(a){Ca=a;return!1};g.height=function(a){I=a;return!1};g.padding=function(a){t(a)&&a!==s&&(s=a,k());return!1};g.paddingLeft=function(a){t(a)&&a!==qb&&(qb=a,k());return!1};g.align=function(a){pb={left:0,center:0.5,right:1}[a];return!1};g.text=function(a,b){o.attr(b,a);j();k();return!1};g[Ub]=function(a,b){Hb=!0;C=a%2/2;l(b,a);return!1};g.stroke=g.fill=g.r=function(a,b){b==="fill"&&(Hb=!0);l(b,a);return!1};g.anchorX=function(a,b){e=a;l(b,a+C-Gb);return!1};g.anchorY=function(a,b){f=a;
+l(b,a-G);return!1};g.x=function(a){n.x=a;a-=pb*((Ca||x.width)+s);Gb=v(a);n.attr("translateX",Gb);return!1};g.y=function(a){G=n.y=v(a);n.attr("translateY",G);return!1};var y=n.css;return u(n,{css:function(a){if(a){var b={},a=w(a);q("fontSize,fontWeight,fontFamily,color,lineHeight,width,textDecoration,textShadow".split(","),function(c){a[c]!==r&&(b[c]=a[c],delete a[c])});o.css(b)}return y.call(n,a)},getBBox:function(){return{width:x.width+2*s,height:x.height+2*s,x:x.x-s,y:x.y-s}},shadow:function(a){J&&
+J.shadow(a);return n},destroy:function(){X(n,"add",m);X(n.element,"mouseenter");X(n.element,"mouseleave");o&&(o=o.destroy());J&&(J=J.destroy());xa.prototype.destroy.call(n);n=p=j=k=l=m=null}})}};Za=sa;u(xa.prototype,{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=u(this.styles,a);z(this.element,a);return this},htmlGetBBox:function(){var a=this.element,b=this.bBox;if(!b){if(a.nodeName==="text")a.style.position=
+"absolute";b=this.bBox={x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}}return b},htmlUpdateTransform:function(){if(this.added){var a=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=this.shadows;z(b,{marginLeft:c,marginTop:d});i&&q(i,function(a){z(a,{marginLeft:c+1,marginTop:d+1})});this.inverted&&q(b.childNodes,function(c){a.invertChild(c,b)});if(b.tagName==="SPAN"){var j=
+this.rotation,k,l=E(this.textWidth),m=[j,g,b.innerHTML,this.textWidth].join(",");if(m!==this.cTT){k=a.fontMetrics(b.style.fontSize).b;t(j)&&this.setSpanRotation(j,h,k);i=o(this.elemWidth,b.offsetWidth);if(i>l&&/[ \-]/.test(b.textContent||b.innerText))z(b,{width:l+"px",display:"block",whiteSpace:"normal"}),i=l;this.getSpanCorrection(i,k,h,j,g)}z(b,{left:e+(this.xCorr||0)+"px",top:f+(this.yCorr||0)+"px"});if(mb)k=b.offsetHeight;this.cTT=m}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,c){var d=
+{},e=Fa?"-ms-transform":mb?"-webkit-transform":bb?"MozTransform":Rb?"-o-transform":"";d[e]=d.transform="rotate("+a+"deg)";d[e+(bb?"Origin":"-origin")]=b*100+"% "+c+"px";z(this.element,d)},getSpanCorrection:function(a,b,c){this.xCorr=-a*c;this.yCorr=-b}});u(sa.prototype,{html:function(a,b,c){var d=L.chart.style,e=this.createElement("span"),f=e.attrSetters,g=e.element,h=e.renderer;f.text=function(a){a!==g.innerHTML&&delete this.bBox;g.innerHTML=a;return!1};f.x=f.y=f.align=f.rotation=function(a,b){b===
+"align"&&(b="textAlign");e[b]=a;e.htmlUpdateTransform();return!1};e.attr({text:a,x:v(b),y:v(c)}).css({position:"absolute",whiteSpace:"nowrap",fontFamily:d.fontFamily,fontSize:d.fontSize});e.css=e.htmlCss;if(h.isSVG)e.add=function(a){var b,c=h.box.parentNode,d=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)d.push(a),a=a.parentGroup;q(d.reverse(),function(a){var d;b=a.div=a.div||Z(Ta,{className:H(a.element,"class")},{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px"},b||c);
+d=b.style;u(a.attrSetters,{translateX:function(a){d.left=a+"px"},translateY:function(a){d.top=a+"px"},visibility:function(a,b){d[b]=a}})})}}else b=c;b.appendChild(g);e.added=!0;e.alignOnAdd&&e.htmlUpdateTransform();return e};return e}});var rb,qa;if(!da&&!ka)Highcharts.VMLElement=qa={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'],d=["position: ","absolute",";"],e=b===Ta;(b==="shape"||e)&&d.push("left:0;top:0;width:1px;height:1px;");d.push("visibility: ",e?"hidden":"visible");c.push(' style="',
+d.join(""),'"/>');if(b)c=e||b==="span"||b==="img"?c.join(""):a.prepVML(c),this.element=Z(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);d.appendChild(c);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();N(this,"add");return this},updateTransform:xa.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=ca(a*La),c=ha(a*La);z(this.element,{filter:a?
+["progid:DXImageTransform.Microsoft.Matrix(M11=",b,", M12=",-c,", M21=",c,", M22=",b,", sizingMethod='auto expand')"].join(""):ba})},getSpanCorrection:function(a,b,c,d,e){var f=d?ca(d*La):1,g=d?ha(d*La):0,h=o(this.elemHeight,this.element.offsetHeight),i;this.xCorr=f<0&&-a;this.yCorr=g<0&&-h;i=f*g<0;this.xCorr+=g*b*(i?1-c:c);this.yCorr-=f*b*(d?i?c:1-c:1);e&&e!=="left"&&(this.xCorr-=a*c*(f<0?-1:1),d&&(this.yCorr-=h*c*(g<0?-1:1)),z(this.element,{textAlign:e}))},pathToVML:function(a){for(var b=a.length,
+c=[];b--;)if(ua(a[b]))c[b]=v(a[b]*10)-5;else if(a[b]==="Z")c[b]="x";else if(c[b]=a[b],a.isArc&&(a[b]==="wa"||a[b]==="at"))c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1);return c.join(" ")||"x"},attr:function(a,b){var c,d,e,f=this.element||{},g=f.style,h=f.nodeName,i=this.renderer,j=this.symbolName,k,l=this.shadows,m,p=this.attrSetters,n=this;ma(a)&&t(b)&&(c=a,a={},a[c]=b);if(ma(a))c=a,n=c==="strokeWidth"||c==="stroke-width"?this.strokeweight:this[c];else for(c in a)if(d=
+a[c],m=!1,e=p[c]&&p[c].call(this,d,c),e!==!1&&d!==null){e!==r&&(d=e);if(j&&/^(x|y|r|start|end|width|height|innerR|anchorX|anchorY)/.test(c))k||(this.symbolAttr(a),k=!0),m=!0;else if(c==="d"){d=d||[];this.d=d.join(" ");f.path=d=this.pathToVML(d);if(l)for(e=l.length;e--;)l[e].path=l[e].cutOff?this.cutOffPath(d,l[e].cutOff):d;m=!0}else if(c==="visibility"){if(l)for(e=l.length;e--;)l[e].style[c]=d;h==="DIV"&&(d=d==="hidden"?"-999em":0,lb||(g[c]=d?"visible":"hidden"),c="top");g[c]=d;m=!0}else if(c==="zIndex")d&&
+(g[c]=d),m=!0;else if(Aa(c,["x","y","width","height"])!==-1)this[c]=d,c==="x"||c==="y"?c={x:"left",y:"top"}[c]:d=s(0,d),this.updateClipping?(this[c]=d,this.updateClipping()):g[c]=d,m=!0;else if(c==="class"&&h==="DIV")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,ua(d)&&(d+="px");else if(c==="dashstyle")(f.getElementsByTagName("stroke")[0]||Z(i.prepVML(["<stroke/>"]),null,null,f))[c]=d||
+"solid",this.dashstyle=d,m=!0;else if(c==="fill")if(h==="SPAN")g.color=d;else{if(h!=="IMG")f.filled=d!==ba?!0:!1,d=i.color(d,f,c,this),c="fillcolor"}else if(c==="opacity")m=!0;else if(h==="shape"&&c==="rotation")this[c]=f.style[c]=d,f.style.left=-v(ha(d*La)+1)+"px",f.style.top=v(ca(d*La))+"px";else if(c==="translateX"||c==="translateY"||c==="rotation")this[c]=d,this.updateTransform(),m=!0;m||(lb?f[c]=d:H(f,c,d))}return n},clip:function(a){var b=this,c;a?(c=a.members,oa(c,b),c.push(b),b.destroyClip=
+function(){oa(c,b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:lb?"inherit":"rect(auto)"});return b.css(a)},css:xa.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&Sa(a)},destroy:function(){this.destroyClip&&this.destroyClip();return xa.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=V.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var c,a=a.split(/[ ,]/);c=a.length;if(c===9||c===11)a[c-4]=a[c-2]=E(a[c-2])-10*b;
+return a.join(" ")},shadow:function(a,b,c){var d=[],e,f=this.element,g=this.renderer,h,i=f.style,j,k=f.path,l,m,p,n;k&&typeof k.value!=="string"&&(k="x");m=k;if(a){p=o(a.width,3);n=(a.opacity||0.15)/p;for(e=1;e<=3;e++){l=p*2+1-2*e;c&&(m=this.cutOffPath(k.value,l+0.5));j=['<shape isShadow="true" strokeweight="',l,'" filled="false" path="',m,'" coordsize="10 10" style="',f.style.cssText,'" />'];h=Z(g.prepVML(j),null,{left:E(i.left)+o(a.offsetX,1),top:E(i.top)+o(a.offsetY,1)});if(c)h.cutOff=l+1;j=['<stroke color="',
+a.color||"black",'" opacity="',n*e,'"/>'];Z(g.prepVML(j),null,null,h);b?b.element.appendChild(h):f.parentNode.insertBefore(h,f);d.push(h)}this.shadows=d}return this}},qa=ea(xa,qa),qa={Element:qa,isIE8:za.indexOf("MSIE 8.0")>-1,init:function(a,b,c){var d,e;this.alignedObjects=[];d=this.createElement(Ta);e=d.element;e.style.position="relative";a.appendChild(d.element);this.isVML=!0;this.box=e;this.boxWrapper=d;this.cache={};this.setSize(b,c,!1);if(!F.namespaces.hcv){F.namespaces.add("hcv","urn:schemas-microsoft-com:vml");
+try{F.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(f){F.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,c,d){var e=this.createElement(),f=aa(a);return u(e,{members:[],left:(f?a.x:a)+1,top:(f?a.y:b)+1,width:(f?a.width:c)-1,height:(f?a.height:d)-1,getCSS:function(a){var b=
+a.element,c=b.nodeName,a=a.inverted,d=this.top-(c==="shape"?b.offsetTop:0),e=this.left,b=e+this.width,f=d+this.height,d={clip:"rect("+v(a?e:d)+"px,"+v(a?f:b)+"px,"+v(a?b:f)+"px,"+v(a?d:e)+"px)"};!a&&lb&&c==="DIV"&&u(d,{width:b+"px",height:f+"px"});return d},updateClipping:function(){q(e.members,function(a){a.css(e.getCSS(a))})}})},color:function(a,b,c,d){var e=this,f,g=/^rgba/,h,i,j=ba;a&&a.linearGradient?i="gradient":a&&a.radialGradient&&(i="pattern");if(i){var k,l,m=a.linearGradient||a.radialGradient,
+p,n,o,J,x,s="",a=a.stops,r,t=[],v=function(){h=['<fill colors="'+t.join(",")+'" opacity="',o,'" o:opacity2="',n,'" type="',i,'" ',s,'focus="100%" method="any" />'];Z(e.prepVML(h),null,null,b)};p=a[0];r=a[a.length-1];p[0]>0&&a.unshift([0,p[1]]);r[0]<1&&a.push([1,r[1]]);q(a,function(a,b){g.test(a[1])?(f=Ba(a[1]),k=f.get("rgb"),l=f.get("a")):(k=a[1],l=1);t.push(a[0]*100+"% "+k);b?(o=l,J=k):(n=l,x=k)});if(c==="fill")if(i==="gradient")c=m.x1||m[0]||0,a=m.y1||m[1]||0,p=m.x2||m[2]||0,m=m.y2||m[3]||0,s='angle="'+
+(90-T.atan((m-a)/(p-c))*180/Ka)+'"',v();else{var j=m.r,u=j*2,w=j*2,G=m.cx,C=m.cy,P=b.radialReference,fa,j=function(){P&&(fa=d.getBBox(),G+=(P[0]-fa.x)/fa.width-0.5,C+=(P[1]-fa.y)/fa.height-0.5,u*=P[2]/fa.width,w*=P[2]/fa.height);s='src="'+L.global.VMLRadialGradientURL+'" size="'+u+","+w+'" origin="0.5,0.5" position="'+G+","+C+'" color2="'+x+'" ';v()};d.added?j():A(d,"add",j);j=J}else j=k}else if(g.test(a)&&b.tagName!=="IMG")f=Ba(a),h=["<",c,' opacity="',f.get("a"),'"/>'],Z(this.prepVML(h),null,null,
+b),j=f.get("rgb");else{j=b.getElementsByTagName(c);if(j.length)j[0].opacity=1,j[0].type="solid";j=a}return j},prepVML:function(a){var b=this.isIE8,a=a.join("");b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=a.indexOf('style="')===-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:sa.prototype.html,path:function(a){var b={coordsize:"10 10"};
+Pa(a)?b.d=a:aa(a)&&u(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var d=this.symbol("circle");if(aa(a))c=a.r,b=a.y,a=a.x;d.isCircle=!0;d.r=c;return d.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement(Ta).attr(b)},image:function(a,b,c,d,e){var f=this.createElement("img").attr({src:a});arguments.length>1&&f.attr({x:b,y:c,width:d,height:e});return f},rect:function(a,b,c,d,e,f){var g=this.symbol("rect");
+g.r=aa(a)?a.r:e;return g.attr(aa(a)?a:g.crisp(f,a,b,s(c,0),s(d,0)))},invertChild:function(a,b){var c=b.style;z(a,{flip:"x",left:E(c.width)-1,top:E(c.height)-1,rotation:-90})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,h=e.r||c||d,c=e.innerR,d=ca(f),i=ha(f),j=ca(g),k=ha(g);if(g-f===0)return["x"];f=["wa",a-h,b-h,a+h,b+h,a+h*d,b+h*i,a+h*j,b+h*k];e.open&&!c&&f.push("e","M",a,b);f.push("at",a-c,b-c,a+c,b+c,a+c*j,b+c*k,a+c*d,b+c*i,"x","e");f.isArc=!0;return f},circle:function(a,b,c,d,e){e&&
+(c=d=2*e.r);e&&e.isCircle&&(a-=c/2,b-=d/2);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){var f=a+c,g=b+d,h;!t(e)||!e.r?f=sa.prototype.symbols.square.apply(0,arguments):(h=y(e.r,c,d),f=["M",a+h,b,"L",f-h,b,"wa",f-2*h,b,f,b+2*h,f-h,b,f,b+h,"L",f,g-h,"wa",f-2*h,g-2*h,f,g,f,g-h,f-h,g,"L",a+h,g,"wa",a,g-2*h,a+2*h,g,a+h,g,a,g-h,"L",a,b+h,"wa",a,b,a+2*h,b+2*h,a,b+h,a+h,b,"x","e"]);return f}}},Highcharts.VMLRenderer=rb=function(){this.init.apply(this,arguments)},rb.prototype=
+w(sa.prototype,qa),Za=rb;sa.prototype.measureSpanWidth=function(a,b){var c=F.createElement("span"),d;d=F.createTextNode(a);c.appendChild(d);z(c,b);this.box.appendChild(c);d=c.offsetWidth;Sa(c);return d};var Vb;if(ka)Highcharts.CanVGRenderer=qa=function(){Ma="http://www.w3.org/1999/xhtml"},qa.prototype.symbols={},Vb=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&&$b(d,a);b.push(c)}}}(),Za=qa;Ya.prototype={addLabel:function(){var a=
+this.axis,b=a.options,c=a.chart,d=a.horiz,e=a.categories,f=a.names,g=this.pos,h=b.labels,i=a.tickPositions,d=d&&e&&!h.step&&!h.staggerLines&&!h.rotation&&c.plotWidth/i.length||!d&&(c.margin[3]||c.chartWidth*0.33),j=g===i[0],k=g===i[i.length-1],l,f=e?o(e[g],f[g],g):g,e=this.label,m=i.info;a.isDatetimeAxis&&m&&(l=b.dateTimeLabelFormats[m.higherRanks[g]||m.unitName]);this.isFirst=j;this.isLast=k;b=a.labelFormatter.call({axis:a,chart:c,isFirst:j,isLast:k,dateTimeLabelFormat:l,value:a.isLog?ga(na(f)):
+f});g=d&&{width:s(1,v(d-2*(h.padding||10)))+"px"};g=u(g,h.style);if(t(e))e&&e.attr({text:b}).css(g);else{l={align:a.labelAlign};if(ua(h.rotation))l.rotation=h.rotation;if(d&&h.ellipsis)l._clipHeight=a.len/i.length;this.label=t(b)&&h.enabled?c.renderer.text(b,0,0,h.useHTML).attr(l).css(g).add(a.labelGroup):null}},getLabelSize:function(){var a=this.label,b=this.axis;return a?a.getBBox()[b.horiz?"height":"width"]:0},getLabelSides:function(){var a=this.label.getBBox(),b=this.axis,c=b.horiz,d=b.options.labels,
+a=c?a.width:a.height,b=c?a*{left:0,center:0.5,right:1}[b.labelAlign]-d.x:a;return[-b,a-b]},handleOverflow:function(a,b){var x;var c=!0,d=this.axis,e=this.isFirst,f=this.isLast,g=d.horiz?b.x:b.y,h=d.reversed,i=d.tickPositions,j=this.getLabelSides(),k=j[0],j=j[1],l=d.pos,m=l+d.len,p=this.label.line||0,n=d.labelEdge,o=d.justifyLabels&&(e||f);n[p]===r||g+k>n[p]?n[p]=g+j:o||(c=!1);if(o)x=(d=d.ticks[i[a+(e?1:-1)]])&&d.label.xy&&d.label.xy.x+d.getLabelSides()[e?0:1],i=x,e&&!h||f&&h?g+k<l&&(g=l-k,d&&g+j>
+i&&(c=!1)):g+j>m&&(g=m-j,d&&g+k<i&&(c=!1)),b.x=g;return c},getPosition:function(a,b,c,d){var e=this.axis,f=e.chart,g=d&&f.oldChartHeight||f.chartHeight;return{x:a?e.translate(b+c,null,null,d)+e.transB:e.left+e.offset+(e.opposite?(d&&f.oldChartWidth||f.chartWidth)-e.right-e.left:0),y:a?g-e.bottom+e.offset-(e.opposite?e.height:0):g-e.translate(b+c,null,null,d)-e.transB}},getLabelPosition:function(a,b,c,d,e,f,g,h){var i=this.axis,j=i.transA,k=i.reversed,l=i.staggerLines,m=i.chart.renderer.fontMetrics(e.style.fontSize).b,
+p=e.rotation,a=a+e.x-(f&&d?f*j*(k?-1:1):0),b=b+e.y-(f&&!d?f*j*(k?1:-1):0);p&&i.side===2&&(b-=m-m*ca(p*La));!t(e.y)&&!p&&(b+=m-c.getBBox().height/2);if(l)c.line=g/(h||1)%l,b+=c.line*(i.labelOffset/l);return{x:a,y:b}},getMarkPath:function(a,b,c,d,e,f){return f.crispLine(["M",a,b,"L",a+(e?0:-c),b+(e?c:0)],d)},render:function(a,b,c){var d=this.axis,e=d.options,f=d.chart.renderer,g=d.horiz,h=this.type,i=this.label,j=this.pos,k=e.labels,l=this.gridLine,m=h?h+"Grid":"grid",p=h?h+"Tick":"tick",n=e[m+"LineWidth"],
+q=e[m+"LineColor"],J=e[m+"LineDashStyle"],x=e[p+"Length"],m=e[p+"Width"]||0,s=e[p+"Color"],t=e[p+"Position"],p=this.mark,v=k.step,u=!0,I=d.tickmarkOffset,w=this.getPosition(g,j,I,b),G=w.x,w=w.y,C=g&&G===d.pos+d.len||!g&&w===d.pos?-1:1;this.isActive=!0;if(n){j=d.getPlotLinePath(j+I,n*C,b,!0);if(l===r){l={stroke:q,"stroke-width":n};if(J)l.dashstyle=J;if(!h)l.zIndex=1;if(b)l.opacity=0;this.gridLine=l=n?f.path(j).attr(l).add(d.gridGroup):null}if(!b&&l&&j)l[this.isNew?"attr":"animate"]({d:j,opacity:c})}if(m&&
+x)t==="inside"&&(x=-x),d.opposite&&(x=-x),h=this.getMarkPath(G,w,x,m*C,g,f),p?p.animate({d:h,opacity:c}):this.mark=f.path(h).attr({stroke:s,"stroke-width":m,opacity:c}).add(d.axisGroup);if(i&&!isNaN(G))i.xy=w=this.getLabelPosition(G,w,i,g,k,I,a,v),this.isFirst&&!this.isLast&&!o(e.showFirstLabel,1)||this.isLast&&!this.isFirst&&!o(e.showLastLabel,1)?u=!1:!d.isRadial&&!k.step&&!k.rotation&&!b&&c!==0&&(u=this.handleOverflow(a,w)),v&&a%v&&(u=!1),u&&!isNaN(w.y)?(w.opacity=c,i[this.isNew?"attr":"animate"](w),
+this.isNew=!1):i.attr("y",-9999)},destroy:function(){Ia(this,this.axis)}};Qb.prototype={destroy:function(){Ia(this,this.axis)},render:function(a){var b=this.options,c=b.format,c=c?Ha(c,this):b.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,0,0,b.useHTML).css(b.style).attr({align:this.textAlign,rotation:b.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,b){var c=this.axis,d=c.chart,e=d.inverted,f=this.isNegative,g=
+c.translate(this.percent?100:this.total,0,0,0,1),c=c.translate(0),c=O(g-c),h=d.xAxis[0].translate(this.x)+a,i=d.plotHeight,f={x:e?f?g:g-c:h,y:e?i-h-b:f?i-g-c:i-g,width:e?c:b,height:e?b:c};if(e=this.label)e.align(this.alignOptions,null,f),f=e.alignAttr,e.attr({visibility:this.options.crop===!1||d.isInsidePlot(f.x,f.y)?da?"inherit":"visible":"hidden"})}};var Ib=function(a,b){this.axis=a;if(b)this.options=b,this.id=b.id};Ib.prototype={render:function(){var a=this,b=a.axis,c=b.horiz,d=(b.pointRange||
+0)/2,e=a.options,f=e.label,g=a.label,h=e.width,i=e.to,j=e.from,k=t(j)&&t(i),l=e.value,m=e.dashStyle,p=a.svgElem,n=[],q,J=e.color,x=e.zIndex,r=e.events,v=b.chart.renderer;b.isLog&&(j=Ea(j),i=Ea(i),l=Ea(l));if(h){if(n=b.getPlotLinePath(l,h),d={stroke:J,"stroke-width":h},m)d.dashstyle=m}else if(k){if(j=s(j,b.min-d),i=y(i,b.max+d),n=b.getPlotBandPath(j,i,e),d={fill:J},e.borderWidth)d.stroke=e.borderColor,d["stroke-width"]=e.borderWidth}else return;if(t(x))d.zIndex=x;if(p)if(n)p.animate({d:n},null,p.onGetPath);
+else{if(p.hide(),p.onGetPath=function(){p.show()},g)a.label=g=g.destroy()}else if(n&&n.length&&(a.svgElem=p=v.path(n).attr(d).add(),r))for(q in e=function(b){p.on(b,function(c){r[b].apply(a,[c])})},r)e(q);if(f&&t(f.text)&&n&&n.length&&b.width>0&&b.height>0){f=w({align:c&&k&&"center",x:c?!k&&4:10,verticalAlign:!c&&k&&"middle",y:c?k?16:10:k?6:-4,rotation:c&&!k&&90},f);if(!g)a.label=g=v.text(f.text,0,0,f.useHTML).attr({align:f.textAlign||f.align,rotation:f.rotation,zIndex:x}).css(f.style).add();b=[n[1],
+n[4],o(n[6],n[1])];n=[n[2],n[5],o(n[7],n[2])];c=Ra(b);k=Ra(n);g.align(f,!1,{x:c,y:k,width:va(b)-c,height:va(n)-k});g.show()}else g&&g.hide();return a},destroy:function(){oa(this.axis.plotLinesAndBands,this);delete this.axis;Ia(this)}};W.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,gridLineColor:"#C0C0C0",labels:K,lineColor:"#C0D0E0",lineWidth:1,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:"#4d759e",fontWeight:"bold"}},type:"linear"},defaultYAxisOptions:{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8,y:3},lineWidth:0,maxPadding:0.05,minPadding:0.05,
+startOnTick:!0,tickWidth:0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return Ga(this.total,-1)},style:K.style}},defaultLeftAxisOptions:{labels:{x:-8,y:null},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:8,y:null},title:{rotation:90}},defaultBottomAxisOptions:{labels:{x:0,y:14},title:{rotation:0}},defaultTopAxisOptions:{labels:{x:0,y:-5},title:{rotation:0}},init:function(a,b){var c=b.isX;this.horiz=a.inverted?!c:c;this.coll=(this.isXAxis=c)?"xAxis":"yAxis";
+this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var d=this.options,e=d.type;this.labelFormatter=d.labels.formatter||this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.chart=a;this.reversed=d.reversed;this.zoomEnabled=d.zoomEnabled!==!1;this.categories=d.categories||e==="category";this.names=[];this.isLog=e==="logarithmic";this.isDatetimeAxis=e==="datetime";this.isLinked=t(d.linkedTo);this.tickmarkOffset=this.categories&&
+d.tickmarkPlacement==="between"?0.5:0;this.ticks={};this.labelEdge=[];this.minorTicks={};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=d.minRange||d.maxZoom;this.range=d.range;this.offset=d.offset||0;this.stacks={};this.oldStacks={};this.stackExtremes={};this.min=this.max=null;this.crosshair=o(d.crosshair,ja(a.options.tooltip.crosshairs)[c?0:1],!1);var f,d=this.options.events;Aa(this,a.axes)===-1&&(a.axes.push(this),a[this.coll].push(this));this.series=
+this.series||[];if(a.inverted&&c&&this.reversed===r)this.reversed=!0;this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(f in d)A(this,f,d[f]);if(this.isLog)this.val2lin=Ea,this.lin2val=na},setOptions:function(a){this.options=w(this.defaultOptions,this.isXAxis?{}:this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],w(L[this.coll],a))},defaultLabelFormatter:function(){var a=this.axis,
+b=this.value,c=a.categories,d=this.dateTimeLabelFormat,e=L.lang.numericSymbols,f=e&&e.length,g,h=a.options.labels.format,a=a.isLog?b:a.tickInterval;if(h)g=Ha(h,this);else if(c)g=b;else if(d)g=ra(d,b);else if(f&&a>=1E3)for(;f--&&g===r;)c=Math.pow(1E3,f+1),a>=c&&e[f]!==null&&(g=Ga(b/c,-1)+e[f]);g===r&&(g=b>=1E4?Ga(b,0):Ga(b,-1,r,""));return g},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=null;a.stackExtremes={};a.buildStacks();q(a.series,function(c){if(c.visible||
+!b.options.chart.ignoreHiddenSeries){var d;d=c.options.threshold;var e;a.hasVisibleSeries=!0;a.isLog&&d<=0&&(d=null);if(a.isXAxis){if(d=c.xData,d.length)a.dataMin=y(o(a.dataMin,d[0]),Ra(d)),a.dataMax=s(o(a.dataMax,d[0]),va(d))}else{c.getExtremes();e=c.dataMax;c=c.dataMin;if(t(c)&&t(e))a.dataMin=y(o(a.dataMin,c),c),a.dataMax=s(o(a.dataMax,e),e);if(t(d))if(a.dataMin>=d)a.dataMin=d,a.ignoreMinPadding=!0;else if(a.dataMax<d)a.dataMax=d,a.ignoreMaxPadding=!0}}})},translate:function(a,b,c,d,e,f){var g=
+this.len,h=1,i=0,j=d?this.oldTransA:this.transA,d=d?this.oldMin:this.min,k=this.minPixelPadding,e=(this.options.ordinal||this.isLog&&e)&&this.lin2val;if(!j)j=this.transA;c&&(h*=-1,i=g);this.reversed&&(h*=-1,i-=h*g);b?(a=a*h+i,a-=k,a=a/j+d,e&&(a=this.lin2val(a))):(e&&(a=this.val2lin(a)),f==="between"&&(f=0.5),a=h*(a-d)*j+i+h*k+(ua(f)?j*f*this.pointRange:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-
+(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,d,e){var f=this.chart,g=this.left,h=this.top,i,j,k=c&&f.oldChartHeight||f.chartHeight,l=c&&f.oldChartWidth||f.chartWidth,m;i=this.transB;e=o(e,this.translate(a,null,null,c));a=c=v(e+i);i=j=v(k-e-i);if(isNaN(e))m=!0;else if(this.horiz){if(i=h,j=k-this.bottom,a<g||a>g+this.width)m=!0}else if(a=g,c=l-this.right,i<h||i>h+this.height)m=!0;return m&&!d?null:f.renderer.crispLine(["M",a,i,"L",c,j],b||1)},getLinearTickPositions:function(a,
+b,c){for(var d,b=ga(Q(b/a)*a),c=ga(Va(c/a)*a),e=[];b<=c;){e.push(b);b=ga(b+a);if(b===d)break;d=b}return e},getMinorTickPositions:function(){var a=this.options,b=this.tickPositions,c=this.minorTickInterval,d=[],e;if(this.isLog){e=b.length;for(a=1;a<e;a++)d=d.concat(this.getLogTickPositions(c,b[a-1],b[a],!0))}else if(this.isDatetimeAxis&&a.minorTickInterval==="auto")d=d.concat(this.getTimeTicks(this.normalizeTimeTickInterval(c),this.min,this.max,a.startOfWeek)),d[0]<this.min&&d.shift();else for(b=this.min+
+(b[0]-this.min)%c;b<=this.max;b+=c)d.push(b);return d},adjustForMinRange:function(){var a=this.options,b=this.min,c=this.max,d,e=this.dataMax-this.dataMin>=this.minRange,f,g,h,i,j;if(this.isXAxis&&this.minRange===r&&!this.isLog)t(a.min)||t(a.max)?this.minRange=null:(q(this.series,function(a){i=a.xData;for(g=j=a.xIncrement?1:i.length-1;g>0;g--)if(h=i[g]-i[g-1],f===r||h<f)f=h}),this.minRange=y(f*5,this.dataMax-this.dataMin));if(c-b<this.minRange){var k=this.minRange;d=(k-c+b)/2;d=[b-d,o(a.min,b-d)];
+if(e)d[2]=this.dataMin;b=va(d);c=[b+k,o(a.max,b+k)];if(e)c[2]=this.dataMax;c=Ra(c);c-b<k&&(d[0]=c-k,d[1]=o(a.min,c-k),b=va(d))}this.min=b;this.max=c},setAxisTranslation:function(a){var b=this.max-this.min,c=0,d,e=0,f=0,g=this.linkedParent,h=!!this.categories,i=this.transA;if(this.isXAxis||h)g?(e=g.minPointOffset,f=g.pointRangePadding):q(this.series,function(a){var g=s(a.pointRange,+h),i=a.options.pointPlacement,m=a.closestPointRange;g>b&&(g=0);c=s(c,g);e=s(e,ma(i)?0:g/2);f=s(f,i==="on"?0:g);!a.noSharedTooltip&&
+t(m)&&(d=t(d)?y(d,m):m)}),g=this.ordinalSlope&&d?this.ordinalSlope/d:1,this.minPointOffset=e*=g,this.pointRangePadding=f*=g,this.pointRange=y(c,b),this.closestPointRange=d;if(a)this.oldTransA=i;this.translationSlope=this.transA=i=this.len/(b+f||1);this.transB=this.horiz?this.left:this.bottom;this.minPixelPadding=i*e},setTickPositions:function(a){var b=this,c=b.chart,d=b.options,e=b.isLog,f=b.isDatetimeAxis,g=b.isXAxis,h=b.isLinked,i=b.options.tickPositioner,j=d.maxPadding,k=d.minPadding,l=d.tickInterval,
+m=d.minTickInterval,p=d.tickPixelInterval,n,$=b.categories;h?(b.linkedParent=c[b.coll][d.linkedTo],c=b.linkedParent.getExtremes(),b.min=o(c.min,c.dataMin),b.max=o(c.max,c.dataMax),d.type!==b.linkedParent.options.type&&pa(11,1)):(b.min=o(b.userMin,d.min,b.dataMin),b.max=o(b.userMax,d.max,b.dataMax));if(e)!a&&y(b.min,o(b.dataMin,b.min))<=0&&pa(10,1),b.min=ga(Ea(b.min)),b.max=ga(Ea(b.max));if(b.range&&t(b.max))b.userMin=b.min=s(b.min,b.max-b.range),b.userMax=b.max,b.range=null;b.beforePadding&&b.beforePadding();
+b.adjustForMinRange();if(!$&&!b.usePercentage&&!h&&t(b.min)&&t(b.max)&&(c=b.max-b.min)){if(!t(d.min)&&!t(b.userMin)&&k&&(b.dataMin<0||!b.ignoreMinPadding))b.min-=c*k;if(!t(d.max)&&!t(b.userMax)&&j&&(b.dataMax>0||!b.ignoreMaxPadding))b.max+=c*j}b.min===b.max||b.min===void 0||b.max===void 0?b.tickInterval=1:h&&!l&&p===b.linkedParent.options.tickPixelInterval?b.tickInterval=b.linkedParent.tickInterval:(b.tickInterval=o(l,$?1:(b.max-b.min)*p/s(b.len,p)),!t(l)&&b.len<p&&!this.isRadial&&!$&&d.startOnTick&&
+d.endOnTick&&(n=!0,b.tickInterval/=4));g&&!a&&q(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)});b.setAxisTranslation(!0);b.beforeSetTickPositions&&b.beforeSetTickPositions();if(b.postProcessTickInterval)b.tickInterval=b.postProcessTickInterval(b.tickInterval);if(b.pointRange)b.tickInterval=s(b.pointRange,b.tickInterval);if(!l&&b.tickInterval<m)b.tickInterval=m;if(!f&&!e&&!l)b.tickInterval=ub(b.tickInterval,null,tb(b.tickInterval),d);b.minorTickInterval=d.minorTickInterval===
+"auto"&&b.tickInterval?b.tickInterval/5:d.minorTickInterval;b.tickPositions=a=d.tickPositions?[].concat(d.tickPositions):i&&i.apply(b,[b.min,b.max]);if(!a)!b.ordinalPositions&&(b.max-b.min)/b.tickInterval>s(2*b.len,200)&&pa(19,!0),a=f?b.getTimeTicks(b.normalizeTimeTickInterval(b.tickInterval,d.units),b.min,b.max,d.startOfWeek,b.ordinalPositions,b.closestPointRange,!0):e?b.getLogTickPositions(b.tickInterval,b.min,b.max):b.getLinearTickPositions(b.tickInterval,b.min,b.max),n&&a.splice(1,a.length-2),
+b.tickPositions=a;if(!h)e=a[0],f=a[a.length-1],h=b.minPointOffset||0,d.startOnTick?b.min=e:b.min-h>e&&a.shift(),d.endOnTick?b.max=f:b.max+h<f&&a.pop(),a.length===1&&(b.min-=0.001,b.max+=0.001)},setMaxTicks:function(){var a=this.chart,b=a.maxTicks||{},c=this.tickPositions,d=this._maxTicksKey=[this.coll,this.pos,this.len].join("-");if(!this.isLinked&&!this.isDatetimeAxis&&c&&c.length>(b[d]||0)&&this.options.alignTicks!==!1)b[d]=c.length;a.maxTicks=b},adjustTickAmount:function(){var a=this._maxTicksKey,
+b=this.tickPositions,c=this.chart.maxTicks;if(c&&c[a]&&!this.isDatetimeAxis&&!this.categories&&!this.isLinked&&this.options.alignTicks!==!1&&this.min!==r){var d=this.tickAmount,e=b.length;this.tickAmount=a=c[a];if(e<a){for(;b.length<a;)b.push(ga(b[b.length-1]+this.tickInterval));this.transA*=(e-1)/(a-1);this.max=b[b.length-1]}if(t(d)&&a!==d)this.isDirty=!0}},setScale:function(){var a=this.stacks,b,c,d,e;this.oldMin=this.min;this.oldMax=this.max;this.oldAxisLength=this.len;this.setAxisSize();e=this.len!==
+this.oldAxisLength;q(this.series,function(a){if(a.isDirtyData||a.isDirty||a.xAxis.isDirty)d=!0});if(e||d||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax){if(!this.isXAxis)for(b in a)for(c in a[b])a[b][c].total=null,a[b][c].cum=0;this.forceRedraw=!1;this.getSeriesExtremes();this.setTickPositions();this.oldUserMin=this.userMin;this.oldUserMax=this.userMax;if(!this.isDirty)this.isDirty=e||this.min!==this.oldMin||this.max!==this.oldMax}else if(!this.isXAxis){if(this.oldStacks)a=
+this.stacks=this.oldStacks;for(b in a)for(c in a[b])a[b][c].cum=a[b][c].total}this.setMaxTicks()},setExtremes:function(a,b,c,d,e){var f=this,g=f.chart,c=o(c,!0),e=u(e,{min:a,max:b});N(f,"setExtremes",e,function(){f.userMin=a;f.userMax=b;f.eventArgs=e;f.isDirtyExtremes=!0;c&&g.redraw(d)})},zoom:function(a,b){this.allowZoomOutside||(t(this.dataMin)&&a<=this.dataMin&&(a=r),t(this.dataMax)&&b>=this.dataMax&&(b=r));this.displayBtn=a!==r||b!==r;this.setExtremes(a,b,!1,r,{trigger:"zoom"});return!0},setAxisSize:function(){var a=
+this.chart,b=this.options,c=b.offsetLeft||0,d=b.offsetRight||0,e=this.horiz,f,g;this.left=g=o(b.left,a.plotLeft+c);this.top=f=o(b.top,a.plotTop);this.width=c=o(b.width,a.plotWidth-c+d);this.height=b=o(b.height,a.plotHeight);this.bottom=a.chartHeight-b-f;this.right=a.chartWidth-c-g;this.len=s(e?c:b,0);this.pos=e?g:f},getExtremes:function(){var a=this.isLog;return{min:a?ga(na(this.min)):this.min,max:a?ga(na(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},
+getThreshold:function(a){var b=this.isLog,c=b?na(this.min):this.min,b=b?na(this.max):this.max;c>a||a===null?a=c:b<a&&(a=b);return this.translate(a,0,1,0,1)},autoLabelAlign:function(a){a=(o(a,0)-this.side*90+720)%360;return a>15&&a<165?"right":a>195&&a<345?"left":"center"},getOffset:function(){var a=this,b=a.chart,c=b.renderer,d=a.options,e=a.tickPositions,f=a.ticks,g=a.horiz,h=a.side,i=b.inverted?[1,0,3,2][h]:h,j,k=0,l,m=0,p=d.title,n=d.labels,$=0,J=b.axisOffset,x=b.clipOffset,v=[-1,1,1,-1][h],u,
+w=1,Ca=o(n.maxStaggerLines,5),I,y,G,C;a.hasData=j=a.hasVisibleSeries||t(a.min)&&t(a.max)&&!!e;a.showAxis=b=j||o(d.showEmpty,!0);a.staggerLines=a.horiz&&n.staggerLines;if(!a.axisGroup)a.gridGroup=c.g("grid").attr({zIndex:d.gridZIndex||1}).add(),a.axisGroup=c.g("axis").attr({zIndex:d.zIndex||2}).add(),a.labelGroup=c.g("axis-labels").attr({zIndex:n.zIndex||7}).add();if(j||a.isLinked){a.labelAlign=o(n.align||a.autoLabelAlign(n.rotation));q(e,function(b){f[b]?f[b].addLabel():f[b]=new Ya(a,b)});if(a.horiz&&
+!a.staggerLines&&Ca&&!n.rotation){for(u=a.reversed?[].concat(e).reverse():e;w<Ca;){j=[];I=!1;for(n=0;n<u.length;n++)y=u[n],G=(G=f[y].label&&f[y].label.getBBox())?G.width:0,C=n%w,G&&(y=a.translate(y),j[C]!==r&&y<j[C]&&(I=!0),j[C]=y+G);if(I)w++;else break}if(w>1)a.staggerLines=w}q(e,function(b){if(h===0||h===2||{1:"left",3:"right"}[h]===a.labelAlign)$=s(f[b].getLabelSize(),$)});if(a.staggerLines)$*=a.staggerLines,a.labelOffset=$}else for(u in f)f[u].destroy(),delete f[u];if(p&&p.text&&p.enabled!==!1){if(!a.axisTitle)a.axisTitle=
+c.text(p.text,0,0,p.useHTML).attr({zIndex:7,rotation:p.rotation||0,align:p.textAlign||{low:"left",middle:"center",high:"right"}[p.align]}).css(p.style).add(a.axisGroup),a.axisTitle.isNew=!0;if(b)k=a.axisTitle.getBBox()[g?"height":"width"],m=o(p.margin,g?5:10),l=p.offset;a.axisTitle[b?"show":"hide"]()}a.offset=v*o(d.offset,J[h]);a.axisTitleMargin=o(l,$+m+(h!==2&&$&&v*d.labels[g?"y":"x"]));J[h]=s(J[h],a.axisTitleMargin+k+v*a.offset);x[i]=s(x[i],Q(d.lineWidth/2)*2)},getLinePath:function(a){var b=this.chart,
+c=this.opposite,d=this.offset,e=this.horiz,f=this.left+(c?this.width:0)+d,d=b.chartHeight-this.bottom-(c?this.height:0)+d;c&&(a*=-1);return b.renderer.crispLine(["M",e?this.left:f,e?d:this.top,"L",e?b.chartWidth-this.right:f,e?d:b.chartHeight-this.bottom],a)},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,d=this.len,e=this.options.title,f=a?b:c,g=this.opposite,h=this.offset,i=E(e.style.fontSize||12),d={low:f+(a?0:d),middle:f+d/2,high:f+(a?d:0)}[e.align],b=(a?c+this.height:b)+
+(a?1:-1)*(g?-1:1)*this.axisTitleMargin+(this.side===2?i:0);return{x:a?d:b+(g?this.width:0)+h+(e.x||0),y:a?b-(g?this.height:0)+h:d+(e.y||0)}},render:function(){var a=this,b=a.horiz,c=a.reversed,d=a.chart,e=d.renderer,f=a.options,g=a.isLog,h=a.isLinked,i=a.tickPositions,j,k=a.axisTitle,l=a.stacks,m=a.ticks,p=a.minorTicks,n=a.alternateBands,o=f.stackLabels,J=f.alternateGridColor,x=a.tickmarkOffset,s=f.lineWidth,v=d.hasRendered&&t(a.oldMin)&&!isNaN(a.oldMin),u=a.hasData,w=a.showAxis,I,y=a.justifyLabels=
+!a.staggerLines&&b&&f.labels.overflow==="justify",G;a.labelEdge.length=0;q([m,p,n],function(a){for(var b in a)a[b].isActive=!1});if(u||h)if(a.minorTickInterval&&!a.categories&&q(a.getMinorTickPositions(),function(b){p[b]||(p[b]=new Ya(a,b,"minor"));v&&p[b].isNew&&p[b].render(null,!0);p[b].render(null,!1,1)}),i.length&&(j=i.slice(),(b&&c||!b&&!c)&&j.reverse(),y&&(j=j.slice(1).concat([j[0]])),q(j,function(b,c){y&&(c=c===j.length-1?0:c+1);if(!h||b>=a.min&&b<=a.max)m[b]||(m[b]=new Ya(a,b)),v&&m[b].isNew&&
+m[b].render(c,!0,0.1),m[b].render(c,!1,1)}),x&&a.min===0&&(m[-1]||(m[-1]=new Ya(a,-1,null,!0)),m[-1].render(-1))),J&&q(i,function(b,c){if(c%2===0&&b<a.max)n[b]||(n[b]=new Ib(a)),I=b+x,G=i[c+1]!==r?i[c+1]+x:a.max,n[b].options={from:g?na(I):I,to:g?na(G):G,color:J},n[b].render(),n[b].isActive=!0}),!a._addedPlotLB)q((f.plotLines||[]).concat(f.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0;q([m,p,n],function(a){var b,c,e=[],f=wa?wa.duration||500:0,g=function(){for(c=e.length;c--;)a[e[c]]&&
+!a[e[c]].isActive&&(a[e[c]].destroy(),delete a[e[c]])};for(b in a)if(!a[b].isActive)a[b].render(b,!1,0),a[b].isActive=!1,e.push(b);a===n||!d.hasRendered||!f?g():f&&setTimeout(g,f)});if(s)b=a.getLinePath(s),a.axisLine?a.axisLine.animate({d:b}):a.axisLine=e.path(b).attr({stroke:f.lineColor,"stroke-width":s,zIndex:7}).add(a.axisGroup),a.axisLine[w?"show":"hide"]();if(k&&w)k[k.isNew?"attr":"animate"](a.getTitlePosition()),k.isNew=!1;if(o&&o.enabled){var C,P,f=a.stackTotalGroup;if(!f)a.stackTotalGroup=
+f=e.g("stack-labels").attr({visibility:"visible",zIndex:6}).add();f.translate(d.plotLeft,d.plotTop);for(C in l)for(P in e=l[C],e)e[P].render(f)}a.isDirty=!1},redraw:function(){var a=this.chart.pointer;a.reset&&a.reset(!0);this.render();q(this.plotLinesAndBands,function(a){a.render()});q(this.series,function(a){a.isDirty=!0})},buildStacks:function(){var a=this.series,b=a.length;if(!this.isXAxis){for(;b--;)a[b].setStackedPoints();if(this.usePercentage)for(b=0;b<a.length;b++)a[b].setPercentStacks()}},
+destroy:function(a){var b=this,c=b.stacks,d,e=b.plotLinesAndBands;a||X(b);for(d in c)Ia(c[d]),c[d]=null;q([b.ticks,b.minorTicks,b.alternateBands],function(a){Ia(a)});for(a=e.length;a--;)e[a].destroy();q("stackTotalGroup,axisLine,axisTitle,axisGroup,cross,gridGroup,labelGroup".split(","),function(a){b[a]&&(b[a]=b[a].destroy())});this.cross&&this.cross.destroy()},drawCrosshair:function(a,b){if(this.crosshair)if((t(b)||!o(this.crosshair.snap,!0))===!1)this.hideCrosshair();else{var c,d=this.crosshair,
+e=d.animation;o(d.snap,!0)?t(b)&&(c=this.chart.inverted!=this.horiz?b.plotX:this.len-b.plotY):c=this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos;c=this.isRadial?this.getPlotLinePath(this.isXAxis?b.x:o(b.stackY,b.y)):this.getPlotLinePath(null,null,null,null,c);if(c===null)this.hideCrosshair();else if(this.cross)this.cross.attr({visibility:"visible"})[e?"animate":"attr"]({d:c},e);else{e={"stroke-width":d.width||1,stroke:d.color||"#C0C0C0",zIndex:d.zIndex||2};if(d.dashStyle)e.dashstyle=d.dashStyle;
+this.cross=this.chart.renderer.path(c).attr(e).add()}}},hideCrosshair:function(){this.cross&&this.cross.hide()}};u(W.prototype,{getPlotBandPath:function(a,b){var c=this.getPlotLinePath(b),d=this.getPlotLinePath(a);d&&c?d.push(c[4],c[5],c[1],c[2]):d=null;return d},addPlotBand:function(a){this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){this.addPlotBandOrLine(a,"plotLines")},addPlotBandOrLine:function(a,b){var c=(new Ib(this,a)).render(),d=this.userOptions;c&&(b&&(d[b]=d[b]||[],d[b].push(a)),
+this.plotLinesAndBands.push(c));return c},removePlotBandOrLine:function(a){for(var b=this.plotLinesAndBands,c=this.options,d=this.userOptions,e=b.length;e--;)b[e].id===a&&b[e].destroy();q([c.plotLines||[],d.plotLines||[],c.plotBands||[],d.plotBands||[]],function(b){for(e=b.length;e--;)b[e].id===a&&oa(b,b[e])})}});W.prototype.getTimeTicks=function(a,b,c,d){var e=[],f={},g=L.global.useUTC,h,i=new Date(b-Ja),j=a.unitRange,k=a.count;if(t(b)){j>=B.second&&(i.setMilliseconds(0),i.setSeconds(j>=B.minute?
+0:k*Q(i.getSeconds()/k)));if(j>=B.minute)i[Mb](j>=B.hour?0:k*Q(i[wb]()/k));if(j>=B.hour)i[Nb](j>=B.day?0:k*Q(i[xb]()/k));if(j>=B.day)i[zb](j>=B.month?1:k*Q(i[Ua]()/k));j>=B.month&&(i[Ob](j>=B.year?0:k*Q(i[jb]()/k)),h=i[kb]());j>=B.year&&(h-=h%k,i[Pb](h));if(j===B.week)i[zb](i[Ua]()-i[yb]()+o(d,1));b=1;Ja&&(i=new Date(i.getTime()+Ja));h=i[kb]();for(var d=i.getTime(),l=i[jb](),m=i[Ua](),p=g?Ja:(864E5+i.getTimezoneOffset()*6E4)%864E5;d<c;)e.push(d),j===B.year?d=ib(h+b*k,0):j===B.month?d=ib(h,l+b*k):
+!g&&(j===B.day||j===B.week)?d=ib(h,l,m+b*k*(j===B.day?1:7)):d+=j*k,b++;e.push(d);q(Fb(e,function(a){return j<=B.hour&&a%B.day===p}),function(a){f[a]="day"})}e.info=u(a,{higherRanks:f,totalRange:j*k});return e};W.prototype.normalizeTimeTickInterval=function(a,b){var c=b||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],d=c[c.length-1],e=B[d[0]],f=d[1],
+g;for(g=0;g<c.length;g++)if(d=c[g],e=B[d[0]],f=d[1],c[g+1]&&a<=(e*f[f.length-1]+B[c[g+1][0]])/2)break;e===B.year&&a<5*e&&(f=[1,2,5]);c=ub(a/e,f,d[0]==="year"?s(tb(a/e),1):1);return{unitRange:e,count:c,unitName:d[0]}};W.prototype.getLogTickPositions=function(a,b,c,d){var e=this.options,f=this.len,g=[];if(!d)this._minorAutoInterval=null;if(a>=0.5)a=v(a),g=this.getLinearTickPositions(a,b,c);else if(a>=0.08)for(var f=Q(b),h,i,j,k,l,e=a>0.3?[1,2,4]:a>0.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];f<c+1&&!l;f++){i=
+e.length;for(h=0;h<i&&!l;h++)j=Ea(na(f)*e[h]),j>b&&(!d||k<=c)&&g.push(k),k>c&&(l=!0),k=j}else if(b=na(b),c=na(c),a=e[d?"minorTickInterval":"tickInterval"],a=o(a==="auto"?null:a,this._minorAutoInterval,(c-b)*(e.tickPixelInterval/(d?5:1))/((d?f/this.tickPositions.length:f)||1)),a=ub(a,null,tb(a)),g=Na(this.getLinearTickPositions(a,b,c),Ea),!d)this._minorAutoInterval=a/5;if(!d)this.tickInterval=a;return g};Ab.prototype={init:function(a,b){var c=b.borderWidth,d=b.style,e=E(d.padding);this.chart=a;this.options=
+b;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.label=a.renderer.label("",0,0,b.shape,null,null,b.useHTML,null,"tooltip").attr({padding:e,fill:b.backgroundColor,"stroke-width":c,r:b.borderRadius,zIndex:8}).css(d).css({padding:0}).add().attr({y:-999});ka||this.label.shadow(b.shadow);this.shared=b.shared},destroy:function(){if(this.label)this.label=this.label.destroy();clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},move:function(a,b,c,d){var e=this,f=e.now,g=e.options.animation!==
+!1&&!e.isHidden;u(f,{x:g?(2*f.x+a)/3:a,y:g?(f.y+b)/2:b,anchorX:g?(2*f.anchorX+c)/3:c,anchorY:g?(f.anchorY+d)/2:d});e.label.attr(f);if(g&&(O(a-f.x)>1||O(b-f.y)>1))clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){e&&e.move(a,b,c,d)},32)},hide:function(){var a=this,b;clearTimeout(this.hideTimer);if(!this.isHidden)b=this.chart.hoverPoints,this.hideTimer=setTimeout(function(){a.label.fadeOut();a.isHidden=!0},o(this.options.hideDelay,500)),b&&q(b,function(a){a.setState()}),this.chart.hoverPoints=
+null},getAnchor:function(a,b){var c,d=this.chart,e=d.inverted,f=d.plotTop,g=0,h=0,i,a=ja(a);c=a[0].tooltipPos;this.followPointer&&b&&(b.chartX===r&&(b=d.pointer.normalize(b)),c=[b.chartX-d.plotLeft,b.chartY-f]);c||(q(a,function(a){i=a.series.yAxis;g+=a.plotX;h+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!e&&i?i.top-f:0)}),g/=a.length,h/=a.length,c=[e?d.plotWidth-h:g,this.shared&&!e&&a.length>1&&b?b.chartY-f:e?d.plotHeight-g:h]);return Na(c,v)},getPosition:function(a,b,c){var d=this.chart,e=d.plotLeft,
+f=d.plotTop,g=d.plotWidth,h=d.plotHeight,i=o(this.options.distance,12),j=c.plotX,c=c.plotY,d=j+e+(d.inverted?i:-a-i),k=c-b+f+15,l;d<7&&(d=e+s(j,0)+i);d+a>e+g&&(d-=d+a-(e+g),k=c-b+f-i,l=!0);k<f+5&&(k=f+5,l&&c>=k&&c<=k+b&&(k=c+f+i));k+b>f+h&&(k=s(f,f+h-b-i));return{x:d,y:k}},defaultFormatter:function(a){var b=this.points||ja(this),c=b[0].series,d;d=[c.tooltipHeaderFormatter(b[0])];q(b,function(a){c=a.series;d.push(c.tooltipFormatter&&c.tooltipFormatter(a)||a.point.tooltipFormatter(c.tooltipOptions.pointFormat))});
+d.push(a.options.footerFormat||"");return d.join("")},refresh:function(a,b){var c=this.chart,d=this.label,e=this.options,f,g,h={},i,j=[];i=e.formatter||this.defaultFormatter;var h=c.hoverPoints,k,l=this.shared;clearTimeout(this.hideTimer);this.followPointer=ja(a)[0].series.tooltipOptions.followPointer;g=this.getAnchor(a,b);f=g[0];g=g[1];l&&(!a.series||!a.series.noSharedTooltip)?(c.hoverPoints=a,h&&q(h,function(a){a.setState()}),q(a,function(a){a.setState("hover");j.push(a.getLabelConfig())}),h={x:a[0].category,
+y:a[0].y},h.points=j,a=a[0]):h=a.getLabelConfig();i=i.call(h,this);h=a.series;i===!1?this.hide():(this.isHidden&&(eb(d),d.attr("opacity",1).show()),d.attr({text:i}),k=e.borderColor||a.color||h.color||"#606060",d.attr({stroke:k}),this.updatePosition({plotX:f,plotY:g}),this.isHidden=!1);N(c,"tooltipRefresh",{text:i,x:f+c.plotLeft,y:g+c.plotTop,borderColor:k})},updatePosition:function(a){var b=this.chart,c=this.label,c=(this.options.positioner||this.getPosition).call(this,c.width,c.height,a);this.move(v(c.x),
+v(c.y),a.plotX+b.plotLeft,a.plotY+b.plotTop)}};var $a=Highcharts.Pointer=function(a,b){this.init(a,b)};$a.prototype={init:function(a,b){var c=b.chart,d=c.events,e=ka?"":c.zoomType,c=a.inverted,f;this.options=b;this.chart=a;this.zoomX=f=/x/.test(e);this.zoomY=e=/y/.test(e);this.zoomHor=f&&!c||e&&c;this.zoomVert=e&&!c||f&&c;this.runChartClick=d&&!!d.click;this.pinchDown=[];this.lastValidTouch={};if(b.tooltip.enabled)a.tooltip=new Ab(a,b.tooltip);this.setDOMEvents()},normalize:function(a,b){var c,d,
+a=a||V.event;if(!a.target)a.target=a.srcElement;a=bc(a);d=a.touches?a.touches.item(0):a;if(!b)this.chartPosition=b=ac(this.chart.container);d.pageX===r?(c=s(a.x,a.clientX-b.left),d=a.y):(c=d.pageX-b.left,d=d.pageY-b.top);return u(a,{chartX:v(c),chartY:v(d)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};q(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},getIndex:function(a){var b=this.chart;return b.inverted?
+b.plotHeight+b.plotTop-a.chartY:a.chartX-b.plotLeft},runPointActions:function(a){var b=this,c=b.chart,d=c.series,e=c.tooltip,f,g,h=c.hoverPoint,i=c.hoverSeries,j,k,l=c.chartWidth,m=b.getIndex(a);if(e&&b.options.tooltip.shared&&(!i||!i.noSharedTooltip)){g=[];j=d.length;for(k=0;k<j;k++)if(d[k].visible&&d[k].options.enableMouseTracking!==!1&&!d[k].noSharedTooltip&&d[k].tooltipPoints.length&&(f=d[k].tooltipPoints[m])&&f.series)f._dist=O(m-f.clientX),l=y(l,f._dist),g.push(f);for(j=g.length;j--;)g[j]._dist>
+l&&g.splice(j,1);if(g.length&&g[0].clientX!==b.hoverX)e.refresh(g,a),b.hoverX=g[0].clientX}if(i&&i.tracker){if((f=i.tooltipPoints[m])&&f!==h)f.onMouseOver(a)}else e&&e.followPointer&&!e.isHidden&&(d=e.getAnchor([{}],a),e.updatePosition({plotX:d[0],plotY:d[1]}));if(e&&!b._onDocumentMouseMove)b._onDocumentMouseMove=function(a){b.onDocumentMouseMove(a)},A(F,"mousemove",b._onDocumentMouseMove);q(c.axes,function(b){b.drawCrosshair(a,o(f,h))})},reset:function(a){var b=this.chart,c=b.hoverSeries,d=b.hoverPoint,
+e=b.tooltip,f=e&&e.shared?b.hoverPoints:d;(a=a&&e&&f)&&ja(f)[0].plotX===r&&(a=!1);if(a)e.refresh(f),d&&d.setState(d.state,!0);else{if(d)d.onMouseOut();if(c)c.onMouseOut();e&&e.hide();if(this._onDocumentMouseMove)X(F,"mousemove",this._onDocumentMouseMove),this._onDocumentMouseMove=null;q(b.axes,function(a){a.hideCrosshair()});this.hoverX=null}},scaleGroups:function(a,b){var c=this.chart,d;q(c.series,function(e){d=a||e.getPlotBox();e.xAxis&&e.xAxis.zoomEnabled&&(e.group.attr(d),e.markerGroup&&(e.markerGroup.attr(d),
+e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(d))});c.clipRect.attr(b||c.clipBox)},pinchTranslate:function(a,b,c,d,e,f,g,h){a&&this.pinchTranslateDirection(!0,c,d,e,f,g,h);b&&this.pinchTranslateDirection(!1,c,d,e,f,g,h)},pinchTranslateDirection:function(a,b,c,d,e,f,g,h){var i=this.chart,j=a?"x":"y",k=a?"X":"Y",l="chart"+k,m=a?"width":"height",p=i["plot"+(a?"Left":"Top")],n,o,q=h||1,x=i.inverted,s=i.bounds[a?"h":"v"],r=b.length===1,v=b[0][l],t=c[0][l],u=!r&&b[1][l],
+w=!r&&c[1][l],y,c=function(){!r&&O(v-u)>20&&(q=h||O(t-w)/O(v-u));o=(p-t)/q+v;n=i["plot"+(a?"Width":"Height")]/q};c();b=o;b<s.min?(b=s.min,y=!0):b+n>s.max&&(b=s.max-n,y=!0);y?(t-=0.8*(t-g[j][0]),r||(w-=0.8*(w-g[j][1])),c()):g[j]=[t,w];x||(f[j]=o-p,f[m]=n);f=x?1/q:q;e[m]=n;e[j]=b;d[x?a?"scaleY":"scaleX":"scale"+k]=q;d["translate"+k]=f*p+(t-f*v)},pinch:function(a){var b=this,c=b.chart,d=b.pinchDown,e=c.tooltip&&c.tooltip.options.followTouchMove,f=a.touches,g=f.length,h=b.lastValidTouch,i=b.zoomHor||
+b.pinchHor,j=b.zoomVert||b.pinchVert,k=i||j,l=b.selectionMarker,m={},p=g===1&&(b.inClass(a.target,"highcharts-tracker")&&c.runTrackerClick||c.runChartClick),n={};(k||e)&&!p&&a.preventDefault();Na(f,function(a){return b.normalize(a)});if(a.type==="touchstart")q(f,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),h.x=[d[0].chartX,d[1]&&d[1].chartX],h.y=[d[0].chartY,d[1]&&d[1].chartY],q(c.axes,function(a){if(a.zoomEnabled){var b=c.bounds[a.horiz?"h":"v"],d=a.minPixelPadding,e=a.toPixels(a.dataMin),
+f=a.toPixels(a.dataMax),g=y(e,f),e=s(e,f);b.min=y(a.pos,g-d);b.max=s(a.pos+a.len,e+d)}});else if(d.length){if(!l)b.selectionMarker=l=u({destroy:la},c.plotBox);b.pinchTranslate(i,j,d,f,m,l,n,h);b.hasPinched=k;b.scaleGroups(m,n);!k&&e&&g===1&&this.runPointActions(b.normalize(a))}},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,
+f=this.zoomHor,g=this.zoomVert,h=b.plotLeft,i=b.plotTop,j=b.plotWidth,k=b.plotHeight,l,m=this.mouseDownX,p=this.mouseDownY;d<h?d=h:d>h+j&&(d=h+j);e<i?e=i:e>i+k&&(e=i+k);this.hasDragged=Math.sqrt(Math.pow(m-d,2)+Math.pow(p-e,2));if(this.hasDragged>10){l=b.isInsidePlot(m-h,p-i);if(b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!this.selectionMarker)this.selectionMarker=b.renderer.rect(h,i,f?1:j,g?1:k,0).attr({fill:c.selectionMarkerFill||"rgba(69,114,167,0.25)",zIndex:7}).add();this.selectionMarker&&
+f&&(d-=m,this.selectionMarker.attr({width:O(d),x:(d>0?0:d)+m}));this.selectionMarker&&g&&(d=e-p,this.selectionMarker.attr({height:O(d),y:(d>0?0:d)+p}));l&&!this.selectionMarker&&c.panning&&b.pan(a,c.panning)}},drop:function(a){var b=this.chart,c=this.hasPinched;if(this.selectionMarker){var d={xAxis:[],yAxis:[],originalEvent:a.originalEvent||a},e=this.selectionMarker,f=e.x,g=e.y,h;if(this.hasDragged||c)q(b.axes,function(a){if(a.zoomEnabled){var b=a.horiz,c=a.toValue(b?f:g),b=a.toValue(b?f+e.width:
+g+e.height);!isNaN(c)&&!isNaN(b)&&(d[a.coll].push({axis:a,min:y(c,b),max:s(c,b)}),h=!0)}}),h&&N(b,"selection",d,function(a){b.zoom(u(a,c?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();c&&this.scaleGroups()}if(b)z(b.container,{cursor:b._cursor}),b.cancelClick=this.hasDragged>10,b.mouseIsDown=this.hasDragged=this.hasPinched=!1,this.pinchDown=[]},onContainerMouseDown:function(a){a=this.normalize(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(a){this.drop(a)},
+onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition,d=b.hoverSeries,a=this.normalize(a,c);c&&d&&!this.inClass(a.target,"highcharts-tracker")&&!b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)&&this.reset()},onContainerMouseLeave:function(){this.reset();this.chartPosition=null},onContainerMouseMove:function(a){var b=this.chart,a=this.normalize(a);b.mouseIsDown==="mousedown"&&this.drag(a);(this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-
+b.plotTop))&&!b.openMenu&&this.runPointActions(a)},inClass:function(a,b){for(var c;a;){if(c=H(a,"class"))if(c.indexOf(b)!==-1)return!0;else if(c.indexOf("highcharts-container")!==-1)return!1;a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries,c=(a=a.relatedTarget||a.toElement)&&a.point&&a.point.series;if(b&&!b.options.stickyTracking&&!this.inClass(a,"highcharts-tooltip")&&c!==b)b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,d=b.plotLeft,e=b.plotTop,
+f=b.inverted,g,h,i,a=this.normalize(a);a.cancelBubble=!0;if(!b.cancelClick)c&&this.inClass(a.target,"highcharts-tracker")?(g=this.chartPosition,h=c.plotX,i=c.plotY,u(c,{pageX:g.left+d+(f?b.plotWidth-i:h),pageY:g.top+e+(f?b.plotHeight-h:i)}),N(c.series,"click",u(a,{point:c})),b.hoverPoint&&c.firePointEvent("click",a)):(u(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-d,a.chartY-e)&&N(b,"click",a))},onContainerTouchStart:function(a){var b=this.chart;a.touches.length===1?(a=this.normalize(a),b.isInsidePlot(a.chartX-
+b.plotLeft,a.chartY-b.plotTop)?(this.runPointActions(a),this.pinch(a)):this.reset()):a.touches.length===2&&this.pinch(a)},onContainerTouchMove:function(a){(a.touches.length===1||a.touches.length===2)&&this.pinch(a)},onDocumentTouchEnd:function(a){this.drop(a)},setDOMEvents:function(){var a=this,b=a.chart.container,c;this._events=c=[[b,"onmousedown","onContainerMouseDown"],[b,"onmousemove","onContainerMouseMove"],[b,"onclick","onContainerClick"],[b,"mouseleave","onContainerMouseLeave"],[F,"mouseup",
+"onDocumentMouseUp"]];db&&c.push([b,"ontouchstart","onContainerTouchStart"],[b,"ontouchmove","onContainerTouchMove"],[F,"touchend","onDocumentTouchEnd"]);q(c,function(b){a["_"+b[2]]=function(c){a[b[2]](c)};b[1].indexOf("on")===0?b[0][b[1]]=a["_"+b[2]]:A(b[0],b[1],a["_"+b[2]])})},destroy:function(){var a=this;q(a._events,function(b){b[1].indexOf("on")===0?b[0][b[1]]=null:X(b[0],b[1],a["_"+b[2]])});delete a._events;clearInterval(a.tooltipTimeout)}};var fb=Highcharts.TrackerMixin={drawTrackerPoint:function(){var a=
+this,b=a.chart,c=b.pointer,d=a.options.cursor,e=d&&{cursor:d},f=function(c){var d=c.target,e;if(b.hoverSeries!==a)a.onMouseOver();for(;d&&!e;)e=d.point,d=d.parentNode;if(e!==r&&e!==b.hoverPoint)e.onMouseOver(c)};q(a.points,function(a){if(a.graphic)a.graphic.element.point=a;if(a.dataLabel)a.dataLabel.element.point=a});if(!a._hasTracking)q(a.trackerGroups,function(b){if(a[b]&&(a[b].addClass("highcharts-tracker").on("mouseover",f).on("mouseout",function(a){c.onTrackerMouseOut(a)}).css(e),db))a[b].on("touchstart",
+f)}),a._hasTracking=!0},drawTrackerGraph:function(){var a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),e=d.length,f=a.chart,g=f.pointer,h=f.renderer,i=f.options.tooltip.snap,j=a.tracker,k=b.cursor,l=k&&{cursor:k},k=a.singlePoints,m,p=function(){if(f.hoverSeries!==a)a.onMouseOver()};if(e&&!c)for(m=e+1;m--;)d[m]==="M"&&d.splice(m+1,0,d[m+1]-i,d[m+2],"L"),(m&&d[m]==="M"||m===e)&&d.splice(m,0,"L",d[m-2]+i,d[m-1]);for(m=0;m<k.length;m++)e=k[m],d.push("M",e.plotX-i,e.plotY,"L",
+e.plotX+i,e.plotY);j?j.attr({d:d}):(a.tracker=h.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:Tb,fill:c?Tb:ba,"stroke-width":b.lineWidth+(c?0:2*i),zIndex:2}).add(a.group),q([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",p).on("mouseout",function(a){g.onTrackerMouseOut(a)}).css(l);if(db)a.on("touchstart",p)}))}};if(V.PointerEvent||V.MSPointerEvent){var ta={};$a.prototype.getWebkitTouches=function(){var a,b=[];b.item=function(a){return this[a]};
+for(a in ta)ta.hasOwnProperty(a)&&b.push({pageX:ta[a].pageX,pageY:ta[a].pageY,target:ta[a].target});return b};U($a.prototype,"init",function(a,b,c){b.container.style["-ms-touch-action"]=b.container.style["touch-action"]="none";a.call(this,b,c)});U($a.prototype,"setDOMEvents",function(a){var b=this;a.apply(this,Array.prototype.slice.call(arguments,1));q([[this.chart.container,"PointerDown","touchstart","onContainerTouchStart",function(a){ta[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}}],
+[this.chart.container,"PointerMove","touchmove","onContainerTouchMove",function(a){ta[a.pointerId]={pageX:a.pageX,pageY:a.pageY};if(!ta[a.pointerId].target)ta[a.pointerId].target=a.currentTarget}],[document,"PointerUp","touchend","onDocumentTouchEnd",function(a){delete ta[a.pointerId]}]],function(a){A(a[0],window.PointerEvent?a[1].toLowerCase():"MS"+a[1],function(d){d=d.originalEvent;if(d.pointerType==="touch"||d.pointerType===d.MSPOINTER_TYPE_TOUCH)a[4](d),b[a[3]]({type:a[2],target:d.currentTarget,
+preventDefault:la,touches:b.getWebkitTouches()})})})})}var Jb=Highcharts.Legend=function(a,b){this.init(a,b)};Jb.prototype={init:function(a,b){var c=this,d=b.itemStyle,e=o(b.padding,8),f=b.itemMarginTop||0;this.options=b;if(b.enabled)c.baseline=E(d.fontSize)+3+f,c.itemStyle=d,c.itemHiddenStyle=w(d,b.itemHiddenStyle),c.itemMarginTop=f,c.padding=e,c.initialItemX=e,c.initialItemY=e-5,c.maxItemWidth=0,c.chart=a,c.itemHeight=0,c.lastLineHeight=0,c.symbolWidth=o(b.symbolWidth,16),c.pages=[],c.render(),
+A(c.chart,"endResize",function(){c.positionCheckboxes()})},colorizeItem:function(a,b){var c=this.options,d=a.legendItem,e=a.legendLine,f=a.legendSymbol,g=this.itemHiddenStyle.color,c=b?c.itemStyle.color:g,h=b?a.legendColor||a.color:g,g=a.options&&a.options.marker,i={stroke:h,fill:h},j;d&&d.css({fill:c,color:c});e&&e.attr({stroke:h});if(f){if(g&&f.isMarker)for(j in g=a.convertAttribs(g),g)d=g[j],d!==r&&(i[j]=d);f.attr(i)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,
+e=d[0],d=d[1],f=a.checkbox;a.legendGroup&&a.legendGroup.translate(b?e:this.legendWidth-e-2*c-4,d);if(f)f.x=e,f.y=d},destroyItem:function(a){var b=a.checkbox;q(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())});b&&Sa(a.checkbox)},destroy:function(){var a=this.group,b=this.box;if(b)this.box=b.destroy();if(a)this.group=a.destroy()},positionCheckboxes:function(a){var b=this.group.alignAttr,c,d=this.clipHeight||this.legendHeight;if(b)c=b.translateY,q(this.allItems,
+function(e){var f=e.checkbox,g;f&&(g=c+f.y+(a||0)+3,z(f,{left:b.translateX+e.legendItemWidth+f.x-20+"px",top:g+"px",display:g>c-6&&g<c+d-6?"":ba}))})},renderTitle:function(){var a=this.padding,b=this.options.title,c=0;if(b.text){if(!this.title)this.title=this.chart.renderer.label(b.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(b.style).add(this.group);a=this.title.getBBox();c=a.height;this.offsetWidth=a.width;this.contentGroup.attr({translateY:c})}this.titleHeight=c},
+renderItem:function(a){var C;var b=this,c=b.chart,d=c.renderer,e=b.options,f=e.layout==="horizontal",g=b.symbolWidth,h=e.symbolPadding,i=b.itemStyle,j=b.itemHiddenStyle,k=b.padding,l=f?o(e.itemDistance,8):0,m=!e.rtl,p=e.width,n=e.itemMarginBottom||0,q=b.itemMarginTop,J=b.initialItemX,x=a.legendItem,r=a.series&&a.series.drawLegendSymbol?a.series:a,t=r.options,t=t&&t.showCheckbox,u=e.useHTML;if(!x&&(a.legendGroup=d.g("legend-item").attr({zIndex:1}).add(b.scrollGroup),r.drawLegendSymbol(b,a),a.legendItem=
+x=d.text(e.labelFormat?Ha(e.labelFormat,a):e.labelFormatter.call(a),m?g+h:-h,b.baseline,u).css(w(a.visible?i:j)).attr({align:m?"left":"right",zIndex:2}).add(a.legendGroup),(u?x:a.legendGroup).on("mouseover",function(){a.setState("hover");x.css(b.options.itemHoverStyle)}).on("mouseout",function(){x.css(a.visible?i:j);a.setState()}).on("click",function(b){var c=function(){a.setVisible()},b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):N(a,"legendItemClick",b,c)}),b.colorizeItem(a,
+a.visible),t))a.checkbox=Z("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},e.itemCheckboxStyle,c.container),A(a.checkbox,"click",function(b){N(a,"checkboxClick",{checked:b.target.checked},function(){a.select()})});d=x.getBBox();C=a.legendItemWidth=e.itemWidth||a.legendItemWidth||g+h+d.width+l+(t?20:0),e=C;b.itemHeight=g=v(a.legendItemHeight||d.height);if(f&&b.itemX-J+e>(p||c.chartWidth-2*k-J))b.itemX=J,b.itemY+=q+b.lastLineHeight+n,b.lastLineHeight=0;b.maxItemWidth=s(b.maxItemWidth,
+e);b.lastItemY=q+b.itemY+n;b.lastLineHeight=s(g,b.lastLineHeight);a._legendItemPos=[b.itemX,b.itemY];f?b.itemX+=e:(b.itemY+=q+g+n,b.lastLineHeight=g);b.offsetWidth=p||s((f?b.itemX-J-l:e)+k,b.offsetWidth)},getAllItems:function(){var a=[];q(this.chart.series,function(b){var c=b.options;if(o(c.showInLegend,!t(c.linkedTo)?r:!1,!0))a=a.concat(b.legendItems||(c.legendType==="point"?b.data:b))});return a},render:function(){var a=this,b=a.chart,c=b.renderer,d=a.group,e,f,g,h,i=a.box,j=a.options,k=a.padding,
+l=j.borderWidth,m=j.backgroundColor;a.itemX=a.initialItemX;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;if(!d)a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup);a.renderTitle();e=a.getAllItems();vb(e,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});j.reversed&&e.reverse();a.allItems=e;a.display=f=!!e.length;q(e,function(b){a.renderItem(b)});g=j.width||a.offsetWidth;
+h=a.lastItemY+a.lastLineHeight+a.titleHeight;h=a.handleOverflow(h);if(l||m){g+=k;h+=k;if(i){if(g>0&&h>0)i[i.isNew?"attr":"animate"](i.crisp(null,null,null,g,h)),i.isNew=!1}else a.box=i=c.rect(0,0,g,h,j.borderRadius,l||0).attr({stroke:j.borderColor,"stroke-width":l||0,fill:m||ba}).add(d).shadow(j.shadow),i.isNew=!0;i[f?"show":"hide"]()}a.legendWidth=g;a.legendHeight=h;q(e,function(b){a.positionItem(b)});f&&d.align(u({width:g,height:h},j),!0,"spacingBox");b.isResizing||this.positionCheckboxes()},handleOverflow:function(a){var b=
+this,c=this.chart,d=c.renderer,e=this.options,f=e.y,f=c.spacingBox.height+(e.verticalAlign==="top"?-f:f)-this.padding,g=e.maxHeight,h,i=this.clipRect,j=e.navigation,k=o(j.animation,!0),l=j.arrowSize||12,m=this.nav,p=this.pages,n,$=this.allItems;e.layout==="horizontal"&&(f/=2);g&&(f=y(f,g));p.length=0;if(a>f&&!e.useHTML){this.clipHeight=h=f-20-this.titleHeight-this.padding;this.currentPage=o(this.currentPage,1);this.fullHeight=a;q($,function(a,b){var c=a._legendItemPos[1],d=v(a.legendItem.bBox.height),
+e=p.length;if(!e||c-p[e-1]>h)p.push(n||c);b===$.length-1&&c+d-p[e-1]>h&&p.push(c);c!==n&&(n=c)});if(!i)i=b.clipRect=d.clipRect(0,this.padding,9999,0),b.contentGroup.clip(i);i.attr({height:h});if(!m)this.nav=m=d.g().attr({zIndex:1}).add(this.group),this.up=d.symbol("triangle",0,0,l,l).on("click",function(){b.scroll(-1,k)}).add(m),this.pager=d.text("",15,10).css(j.style).add(m),this.down=d.symbol("triangle-down",0,0,l,l).on("click",function(){b.scroll(1,k)}).add(m);b.scroll(0);a=f}else if(m)i.attr({height:c.chartHeight}),
+m.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0;return a},scroll:function(a,b){var c=this.pages,d=c.length,e=this.currentPage+a,f=this.clipHeight,g=this.options.navigation,h=g.activeColor,g=g.inactiveColor,i=this.pager,j=this.padding;e>d&&(e=d);if(e>0)b!==r&&Xa(b,this.chart),this.nav.attr({translateX:j,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({fill:e===1?g:h}).css({cursor:e===1?"default":"pointer"}),i.attr({text:e+"/"+d}),this.down.attr({x:18+
+this.pager.getBBox().width,fill:e===d?g:h}).css({cursor:e===d?"default":"pointer"}),c=-c[e-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=e,this.positionCheckboxes(c)}};K=Highcharts.LegendSymbolMixin={drawRectangle:function(a,b){var c=a.options.symbolHeight||12;b.legendSymbol=this.chart.renderer.rect(0,a.baseline-5-c/2,a.symbolWidth,c,o(a.options.symbolRadius,2)).attr({zIndex:3}).add(b.legendGroup)},drawLineMarker:function(a){var b=this.options,c=b.marker,d;d=a.symbolWidth;
+var e=this.chart.renderer,f=this.legendGroup,a=a.baseline-v(e.fontMetrics(a.options.itemStyle.fontSize).b*0.3),g;if(b.lineWidth){g={"stroke-width":b.lineWidth};if(b.dashStyle)g.dashstyle=b.dashStyle;this.legendLine=e.path(["M",0,a,"L",d,a]).attr(g).add(f)}if(c&&c.enabled)b=c.radius,this.legendSymbol=d=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b).add(f),d.isMarker=!0}};/Trident\/7\.0/.test(za)&&U(Jb.prototype,"positionItem",function(a,b){var c=this,d=function(){b._legendItemPos&&a.call(c,b)};c.chart.renderer.forExport?
+d():setTimeout(d)});ya.prototype={init:function(a,b){var c,d=a.series;a.series=null;c=w(L,a);c.series=a.series=d;this.userOptions=a;d=c.chart;this.margin=this.splashArray("margin",d);this.spacing=this.splashArray("spacing",d);var e=d.events;this.bounds={h:{},v:{}};this.callback=b;this.isResizing=0;this.options=c;this.axes=[];this.series=[];this.hasCartesianSeries=d.showAxes;var f=this,g;f.index=Wa.length;Wa.push(f);d.reflow!==!1&&A(f,"load",function(){f.initReflow()});if(e)for(g in e)A(f,g,e[g]);
+f.xAxis=[];f.yAxis=[];f.animation=ka?!1:o(d.animation,!0);f.pointCount=0;f.counters=new Kb;f.firstRender()},initSeries:function(a){var b=this.options.chart;(b=D[a.type||b.type||b.defaultSeriesType])||pa(17,!0);b=new b;b.init(this,a);return b},isInsidePlot:function(a,b,c){var d=c?b:a,a=c?a:b;return d>=0&&d<=this.plotWidth&&a>=0&&a<=this.plotHeight},adjustTickAmounts:function(){this.options.chart.alignTicks!==!1&&q(this.axes,function(a){a.adjustTickAmount()});this.maxTicks=null},redraw:function(a){var b=
+this.axes,c=this.series,d=this.pointer,e=this.legend,f=this.isDirtyLegend,g,h,i=this.isDirtyBox,j=c.length,k=j,l=this.renderer,m=l.isHidden(),p=[];Xa(a,this);m&&this.cloneRenderTo();for(this.layOutTitles();k--;)if(a=c[k],a.options.stacking&&(g=!0,a.isDirty)){h=!0;break}if(h)for(k=j;k--;)if(a=c[k],a.options.stacking)a.isDirty=!0;q(c,function(a){a.isDirty&&a.options.legendType==="point"&&(f=!0)});if(f&&e.options.enabled)e.render(),this.isDirtyLegend=!1;g&&this.getStacks();if(this.hasCartesianSeries){if(!this.isResizing)this.maxTicks=
+null,q(b,function(a){a.setScale()});this.adjustTickAmounts();this.getMargins();q(b,function(a){a.isDirty&&(i=!0)});q(b,function(a){if(a.isDirtyExtremes)a.isDirtyExtremes=!1,p.push(function(){N(a,"afterSetExtremes",u(a.eventArgs,a.getExtremes()));delete a.eventArgs});(i||g)&&a.redraw()})}i&&this.drawChartBox();q(c,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()});d&&d.reset&&d.reset(!0);l.draw();N(this,"redraw");m&&this.cloneRenderTo(!0);q(p,function(a){a.call()})},get:function(a){var b=
+this.axes,c=this.series,d,e;for(d=0;d<b.length;d++)if(b[d].options.id===a)return b[d];for(d=0;d<c.length;d++)if(c[d].options.id===a)return c[d];for(d=0;d<c.length;d++){e=c[d].points||[];for(b=0;b<e.length;b++)if(e[b].id===a)return e[b]}return null},getAxes:function(){var a=this,b=this.options,c=b.xAxis=ja(b.xAxis||{}),b=b.yAxis=ja(b.yAxis||{});q(c,function(a,b){a.index=b;a.isX=!0});q(b,function(a,b){a.index=b});c=c.concat(b);q(c,function(b){new W(a,b)});a.adjustTickAmounts()},getSelectedPoints:function(){var a=
+[];q(this.series,function(b){a=a.concat(Fb(b.points||[],function(a){return a.selected}))});return a},getSelectedSeries:function(){return Fb(this.series,function(a){return a.selected})},getStacks:function(){var a=this;q(a.yAxis,function(a){if(a.stacks&&a.hasVisibleSeries)a.oldStacks=a.stacks});q(a.series,function(b){if(b.options.stacking&&(b.visible===!0||a.options.chart.ignoreHiddenSeries===!1))b.stackKey=b.type+o(b.options.stack,"")})},showResetZoom:function(){var a=this,b=L.lang,c=a.options.chart.resetZoomButton,
+d=c.theme,e=d.states,f=c.relativeTo==="chart"?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()},d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).add().align(c.position,!1,f)},zoomOut:function(){var a=this;N(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var b,c=this.pointer,d=!1,e;!a||a.resetSelection?q(this.axes,function(a){b=a.zoom()}):q(a.xAxis.concat(a.yAxis),function(a){var e=a.axis,h=e.isXAxis;if(c[h?
+"zoomX":"zoomY"]||c[h?"pinchX":"pinchY"])b=e.zoom(a.min,a.max),e.displayBtn&&(d=!0)});e=this.resetZoomButton;if(d&&!e)this.showResetZoom();else if(!d&&aa(e))this.resetZoomButton=e.destroy();b&&this.redraw(o(this.options.chart.animation,a&&a.animation,this.pointCount<100))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&q(d,function(a){a.setState()});q(b==="xy"?[1,0]:[1],function(b){var d=a[b?"chartX":"chartY"],h=c[b?"xAxis":"yAxis"][0],i=c[b?"mouseDownX":"mouseDownY"],j=(h.pointRange||0)/2,k=h.getExtremes(),
+l=h.toValue(i-d,!0)+j,i=h.toValue(i+c[b?"plotWidth":"plotHeight"]-d,!0)-j;h.series.length&&l>y(k.dataMin,k.min)&&i<s(k.dataMax,k.max)&&(h.setExtremes(l,i,!1,!1,{trigger:"pan"}),e=!0);c[b?"mouseDownX":"mouseDownY"]=d});e&&c.redraw(!1);z(c.container,{cursor:"move"})},setTitle:function(a,b){var f;var c=this,d=c.options,e;e=d.title=w(d.title,a);f=d.subtitle=w(d.subtitle,b),d=f;q([["title",a,e],["subtitle",b,d]],function(a){var b=a[0],d=c[b],e=a[1],a=a[2];d&&e&&(c[b]=d=d.destroy());a&&a.text&&!d&&(c[b]=
+c.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+b,zIndex:a.zIndex||4}).css(a.style).add())});c.layOutTitles()},layOutTitles:function(){var a=0,b=this.title,c=this.subtitle,d=this.options,e=d.title,d=d.subtitle,f=this.spacingBox.width-44;if(b&&(b.css({width:(e.width||f)+"px"}).align(u({y:15},e),!1,"spacingBox"),!e.floating&&!e.verticalAlign))a=b.getBBox().height,a>=18&&a<=25&&(a=15);c&&(c.css({width:(d.width||f)+"px"}).align(u({y:a+e.margin},d),!1,"spacingBox"),!d.floating&&
+!d.verticalAlign&&(a=Va(a+c.getBBox().height)));this.titleOffset=a},getChartSize:function(){var a=this.options.chart,b=this.renderToClone||this.renderTo;this.containerWidth=nb(b,"width");this.containerHeight=nb(b,"height");this.chartWidth=s(0,a.width||this.containerWidth||600);this.chartHeight=s(0,o(a.height,this.containerHeight>19?this.containerHeight:400))},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;a?b&&(this.renderTo.appendChild(c),Sa(b),delete this.renderToClone):(c&&
+c.parentNode===this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),z(b,{position:"absolute",top:"-9999px",display:"block"}),F.body.appendChild(b),c&&b.appendChild(c))},getContainer:function(){var a,b=this.options.chart,c,d,e;this.renderTo=a=b.renderTo;e="highcharts-"+Db++;if(ma(a))this.renderTo=a=F.getElementById(a);a||pa(13,!0);c=E(H(a,"data-highcharts-chart"));!isNaN(c)&&Wa[c]&&Wa[c].destroy();H(a,"data-highcharts-chart",this.index);a.innerHTML="";a.offsetWidth||
+this.cloneRenderTo();this.getChartSize();c=this.chartWidth;d=this.chartHeight;this.container=a=Z(Ta,{className:"highcharts-container"+(b.className?" "+b.className:""),id:e},u({position:"relative",overflow:"hidden",width:c+"px",height:d+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},b.style),this.renderToClone||a);this._cursor=a.style.cursor;this.renderer=b.forExport?new sa(a,c,d,!0):new Za(a,c,d);ka&&this.renderer.create(this,a,c,d)},getMargins:function(){var a=
+this.spacing,b,c=this.legend,d=this.margin,e=this.options.legend,f=o(e.margin,10),g=e.x,h=e.y,i=e.align,j=e.verticalAlign,k=this.titleOffset;this.resetMargins();b=this.axisOffset;if(k&&!t(d[0]))this.plotTop=s(this.plotTop,k+this.options.title.margin+a[0]);if(c.display&&!e.floating)if(i==="right"){if(!t(d[1]))this.marginRight=s(this.marginRight,c.legendWidth-g+f+a[1])}else if(i==="left"){if(!t(d[3]))this.plotLeft=s(this.plotLeft,c.legendWidth+g+f+a[3])}else if(j==="top"){if(!t(d[0]))this.plotTop=s(this.plotTop,
+c.legendHeight+h+f+a[0])}else if(j==="bottom"&&!t(d[2]))this.marginBottom=s(this.marginBottom,c.legendHeight-h+f+a[2]);this.extraBottomMargin&&(this.marginBottom+=this.extraBottomMargin);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);this.hasCartesianSeries&&q(this.axes,function(a){a.getOffset()});t(d[3])||(this.plotLeft+=b[3]);t(d[0])||(this.plotTop+=b[0]);t(d[2])||(this.marginBottom+=b[2]);t(d[1])||(this.marginRight+=b[1]);this.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,
+d=b.renderTo,e=c.width||nb(d,"width"),f=c.height||nb(d,"height"),c=a?a.target:V,d=function(){if(b.container)b.setSize(e,f,!1),b.hasUserSize=null};if(!b.hasUserSize&&e&&f&&(c===V||c===F)){if(e!==b.containerWidth||f!==b.containerHeight)clearTimeout(b.reflowTimeout),a?b.reflowTimeout=setTimeout(d,100):d();b.containerWidth=e;b.containerHeight=f}},initReflow:function(){var a=this,b=function(b){a.reflow(b)};A(V,"resize",b);A(a,"destroy",function(){X(V,"resize",b)})},setSize:function(a,b,c){var d=this,e,
+f,g;d.isResizing+=1;g=function(){d&&N(d,"endResize",null,function(){d.isResizing-=1})};Xa(c,d);d.oldChartHeight=d.chartHeight;d.oldChartWidth=d.chartWidth;if(t(a))d.chartWidth=e=s(0,v(a)),d.hasUserSize=!!e;if(t(b))d.chartHeight=f=s(0,v(b));(wa?ob:z)(d.container,{width:e+"px",height:f+"px"},wa);d.setChartSize(!0);d.renderer.setSize(e,f,c);d.maxTicks=null;q(d.axes,function(a){a.isDirty=!0;a.setScale()});q(d.series,function(a){a.isDirty=!0});d.isDirtyLegend=!0;d.isDirtyBox=!0;d.getMargins();d.redraw(c);
+d.oldChartHeight=null;N(d,"resize");wa===!1?g():setTimeout(g,wa&&wa.duration||500)},setChartSize:function(a){var b=this.inverted,c=this.renderer,d=this.chartWidth,e=this.chartHeight,f=this.options.chart,g=this.spacing,h=this.clipOffset,i,j,k,l;this.plotLeft=i=v(this.plotLeft);this.plotTop=j=v(this.plotTop);this.plotWidth=k=s(0,v(d-i-this.marginRight));this.plotHeight=l=s(0,v(e-j-this.marginBottom));this.plotSizeX=b?l:k;this.plotSizeY=b?k:l;this.plotBorderWidth=f.plotBorderWidth||0;this.spacingBox=
+c.spacingBox={x:g[3],y:g[0],width:d-g[3]-g[1],height:e-g[0]-g[2]};this.plotBox=c.plotBox={x:i,y:j,width:k,height:l};d=2*Q(this.plotBorderWidth/2);b=Va(s(d,h[3])/2);c=Va(s(d,h[0])/2);this.clipBox={x:b,y:c,width:Q(this.plotSizeX-s(d,h[1])/2-b),height:Q(this.plotSizeY-s(d,h[2])/2-c)};a||q(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a=this.spacing,b=this.margin;this.plotTop=o(b[0],a[0]);this.marginRight=o(b[1],a[1]);this.marginBottom=o(b[2],a[2]);this.plotLeft=
+o(b[3],a[3]);this.axisOffset=[0,0,0,0];this.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight,e=this.chartBackground,f=this.plotBackground,g=this.plotBorder,h=this.plotBGImage,i=a.borderWidth||0,j=a.backgroundColor,k=a.plotBackgroundColor,l=a.plotBackgroundImage,m=a.plotBorderWidth||0,p,n=this.plotLeft,o=this.plotTop,q=this.plotWidth,x=this.plotHeight,s=this.plotBox,r=this.clipRect,v=this.clipBox;p=i+(a.shadow?8:0);if(i||j)if(e)e.animate(e.crisp(null,
+null,null,c-p,d-p));else{e={fill:j||ba};if(i)e.stroke=a.borderColor,e["stroke-width"]=i;this.chartBackground=b.rect(p/2,p/2,c-p,d-p,a.borderRadius,i).attr(e).add().shadow(a.shadow)}if(k)f?f.animate(s):this.plotBackground=b.rect(n,o,q,x,0).attr({fill:k}).add().shadow(a.plotShadow);if(l)h?h.animate(s):this.plotBGImage=b.image(l,n,o,q,x).add();r?r.animate({width:v.width,height:v.height}):this.clipRect=b.clipRect(v);if(m)g?g.animate(g.crisp(null,n,o,q,x)):this.plotBorder=b.rect(n,o,q,x,0,-m).attr({stroke:a.plotBorderColor,
+"stroke-width":m,zIndex:1}).add();this.isDirtyBox=!1},propFromSeries:function(){var a=this,b=a.options.chart,c,d=a.options.series,e,f;q(["inverted","angular","polar"],function(g){c=D[b.type||b.defaultSeriesType];f=a[g]||b[g]||c&&c.prototype[g];for(e=d&&d.length;!f&&e--;)(c=D[d[e].type])&&c.prototype[g]&&(f=!0);a[g]=f})},linkSeries:function(){var a=this,b=a.series;q(b,function(a){a.linkedSeries.length=0});q(b,function(b){var d=b.options.linkedTo;if(ma(d)&&(d=d===":previous"?a.series[b.index-1]:a.get(d)))d.linkedSeries.push(b),
+b.linkedParent=d})},render:function(){var a=this,b=a.axes,c=a.renderer,d=a.options,e=d.labels,f=d.credits,g;a.setTitle();a.legend=new Jb(a,d.legend);a.getStacks();q(b,function(a){a.setScale()});a.getMargins();a.maxTicks=null;q(b,function(a){a.setTickPositions(!0);a.setMaxTicks()});a.adjustTickAmounts();a.getMargins();a.drawChartBox();a.hasCartesianSeries&&q(b,function(a){a.render()});if(!a.seriesGroup)a.seriesGroup=c.g("series-group").attr({zIndex:3}).add();q(a.series,function(a){a.translate();a.setTooltipPoints();
+a.render()});e.items&&q(e.items,function(b){var d=u(e.style,b.style),f=E(d.left)+a.plotLeft,g=E(d.top)+a.plotTop+12;delete d.left;delete d.top;c.text(b.html,f,g).attr({zIndex:2}).css(d).add()});if(f.enabled&&!a.credits)g=f.href,a.credits=c.text(f.text,0,0).on("click",function(){if(g)location.href=g}).attr({align:f.position.align,zIndex:8}).css(f.style).add().align(f.position);a.hasRendered=!0},destroy:function(){var a=this,b=a.axes,c=a.series,d=a.container,e,f=d&&d.parentNode;N(a,"destroy");Wa[a.index]=
+r;a.renderTo.removeAttribute("data-highcharts-chart");X(a);for(e=b.length;e--;)b[e]=b[e].destroy();for(e=c.length;e--;)c[e]=c[e].destroy();q("title,subtitle,chartBackground,plotBackground,plotBGImage,plotBorder,seriesGroup,clipRect,credits,pointer,scroller,rangeSelector,legend,resetZoomButton,tooltip,renderer".split(","),function(b){var c=a[b];c&&c.destroy&&(a[b]=c.destroy())});if(d)d.innerHTML="",X(d),f&&Sa(d);for(e in a)delete a[e]},isReadyToRender:function(){var a=this;return!da&&V==V.top&&F.readyState!==
+"complete"||ka&&!V.canvg?(ka?Vb.push(function(){a.firstRender()},a.options.global.canvasToolsURL):F.attachEvent("onreadystatechange",function(){F.detachEvent("onreadystatechange",a.firstRender);F.readyState==="complete"&&a.firstRender()}),!1):!0},firstRender:function(){var a=this,b=a.options,c=a.callback;if(a.isReadyToRender())a.getContainer(),N(a,"init"),a.resetMargins(),a.setChartSize(),a.propFromSeries(),a.getAxes(),q(b.series||[],function(b){a.initSeries(b)}),a.linkSeries(),N(a,"beforeRender"),
+a.pointer=new $a(a,b),a.render(),a.renderer.draw(),c&&c.apply(a,[a]),q(a.callbacks,function(b){b.apply(a,[a])}),a.cloneRenderTo(!0),N(a,"load")},splashArray:function(a,b){var c=b[a],c=aa(c)?c:[c,c,c,c];return[o(b[a+"Top"],c[0]),o(b[a+"Right"],c[1]),o(b[a+"Bottom"],c[2]),o(b[a+"Left"],c[3])]}};ya.prototype.callbacks=[];qa=Highcharts.CenteredSeriesMixin={getCenter:function(){var a=this.options,b=this.chart,c=2*(a.slicedOffset||0),d,e=b.plotWidth-2*c,f=b.plotHeight-2*c,b=a.center,a=[o(b[0],"50%"),o(b[1],
+"50%"),a.size||"100%",a.innerSize||0],g=y(e,f),h;return Na(a,function(a,b){h=/%$/.test(a);d=b<2||b===2&&h;return(h?[e,f,g,g][b]*E(a)/100:a)+(d?c:0)})}};var Da=function(){};Da.prototype={init:function(a,b,c){this.series=a;this.applyOptions(b,c);this.pointAttr={};if(a.options.colorByPoint&&(b=a.options.colors||a.chart.options.colors,this.color=this.color||b[a.colorCounter++],a.colorCounter===b.length))a.colorCounter=0;a.chart.pointCount++;return this},applyOptions:function(a,b){var c=this.series,d=
+c.pointValKey,a=Da.prototype.optionsToObject.call(this,a);u(this,a);this.options=this.options?u(this.options,a):a;if(d)this.y=this[d];if(this.x===r&&c)this.x=b===r?c.autoIncrement():b;return this},optionsToObject:function(a){var b={},c=this.series,d=c.pointArrayMap||["y"],e=d.length,f=0,g=0;if(typeof a==="number"||a===null)b[d[0]]=a;else if(Pa(a)){if(a.length>e){c=typeof a[0];if(c==="string")b.name=a[0];else if(c==="number")b.x=a[0];f++}for(;g<e;)b[d[g++]]=a[f++]}else if(typeof a==="object"){b=a;
+if(a.dataLabels)c._hasPointLabels=!0;if(a.marker)c._hasPointMarkers=!0}return b},destroy:function(){var a=this.series.chart,b=a.hoverPoints,c;a.pointCount--;if(b&&(this.setState(),oa(b,this),!b.length))a.hoverPoints=null;if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)X(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(c in this)this[c]=null},destroyElements:function(){for(var a="graphic,dataLabel,dataLabelUpper,group,connector,shadowGroup".split(","),
+b,c=6;c--;)b=a[c],this[b]&&(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,e=d.chart,a=o(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a;d.options.data[Aa(c,d.data)]=c.options;c.setState(a&&"select");b||q(e.getSelectedPoints(),function(a){if(a.selected&&
+a!==c)a.selected=a.options.selected=!1,d.options.data[Aa(a,d.data)]=a.options,a.setState(""),a.firePointEvent("unselect")})})},onMouseOver:function(a){var b=this.series,c=b.chart,d=c.tooltip,e=c.hoverPoint;if(e&&e!==this)e.onMouseOut();this.firePointEvent("mouseOver");d&&(!d.shared||b.noSharedTooltip)&&d.refresh(this,a);this.setState("hover");c.hoverPoint=this},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;if(!b||Aa(this,b)===-1)this.firePointEvent("mouseOut"),this.setState(),a.hoverPoint=
+null},tooltipFormatter:function(a){var b=this.series,c=b.tooltipOptions,d=o(c.valueDecimals,""),e=c.valuePrefix||"",f=c.valueSuffix||"";q(b.pointArrayMap||["y"],function(b){b="{point."+b;if(e||f)a=a.replace(b+"}",e+b+"}"+f);a=a.replace(b+"}",b+":,."+d+"f}")});return Ha(a,{point:this,series:this.series})},firePointEvent:function(a,b,c){var d=this,e=this.series.options;(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)});N(this,a,b,c)},importEvents:function(){if(!this.hasImportedEvents){var a=w(this.series.options.point,this.options).events,b;this.events=a;for(b in a)A(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var c=this.plotX,d=this.plotY,e=this.series,f=e.options.states,g=S[e.type].marker&&e.options.marker,h=g&&!g.enabled,i=g&&g.states[a],j=i&&i.enabled===!1,k=e.stateMarkerGraphic,l=this.marker||{},m=e.chart,p=this.pointAttr,a=a||"",b=b&&k;if(!(a===this.state&&
+!b||this.selected&&a!=="select"||f[a]&&f[a].enabled===!1||a&&(j||h&&!i.enabled)||a&&l.states&&l.states[a]&&l.states[a].enabled===!1)){if(this.graphic)f=g&&this.graphic.symbolName&&p[a].r,this.graphic.attr(w(p[a],f?{x:c-f,y:d-f,width:2*f,height:2*f}:{}));else{if(a&&i)if(f=i.radius,l=l.symbol||e.symbol,k&&k.currentSymbol!==l&&(k=k.destroy()),k)k[b?"animate":"attr"]({x:c-f,y:d-f});else e.stateMarkerGraphic=k=m.renderer.symbol(l,c-f,d-f,2*f,2*f).attr(p[a]).add(e.markerGroup),k.currentSymbol=l;if(k)k[a&&
+m.isInsidePlot(c,d,m.inverted)?"show":"hide"]()}this.state=a}}};var M=function(){};M.prototype={isCartesian:!0,type:"line",pointClass:Da,sorted:!0,requireSorting:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor",r:"radius"},axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],init:function(a,b){var c=this,d,e,f=a.series,g=function(a,b){return o(a.options.index,a._i)-o(b.options.index,b._i)};c.chart=a;c.options=b=c.setOptions(b);c.linkedSeries=[];
+c.bindAxes();u(c,{name:b.name,state:"",pointAttr:{},visible:b.visible!==!1,selected:b.selected===!0});if(ka)b.animation=!1;e=b.events;for(d in e)A(c,d,e[d]);if(e&&e.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;c.getColor();c.getSymbol();q(c.parallelArrays,function(a){c[a+"Data"]=[]});c.setData(b.data,!1);if(c.isCartesian)a.hasCartesianSeries=!0;f.push(c);c._i=f.length-1;vb(f,g);this.yAxis&&vb(this.yAxis.series,g);q(f,function(a,b){a.index=b;a.name=
+a.name||"Series "+(b+1)})},bindAxes:function(){var a=this,b=a.options,c=a.chart,d;q(a.axisTypes||[],function(e){q(c[e],function(c){d=c.options;if(b[e]===d.index||b[e]!==r&&b[e]===d.id||b[e]===r&&d.index===0)c.series.push(a),a[e]=c,c.isDirty=!0});!a[e]&&a.optionalAxis!==e&&pa(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,d=arguments;q(c.parallelArrays,typeof b==="number"?function(d){var f=d==="y"&&c.toYData?c.toYData(a):a[d];c[d+"Data"][b]=f}:function(a){Array.prototype[b].apply(c[a+
+"Data"],Array.prototype.slice.call(d,2))})},autoIncrement:function(){var a=this.options,b=this.xIncrement,b=o(b,a.pointStart,0);this.pointInterval=o(this.pointInterval,a.pointInterval,1);this.xIncrement=b+this.pointInterval;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 q(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,c=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},e=c[this.type];this.userOptions=a;c=w(e,c.series,a);this.tooltipOptions=w(L.tooltip,L.plotOptions[this.type].tooltip,b.tooltip,d.series&&d.series.tooltip,d[this.type]&&d[this.type].tooltip,a.tooltip);e.marker===null&&delete c.marker;return c},getColor:function(){var a=this.options,b=this.userOptions,c=this.chart.options.colors,d=this.chart.counters,e;e=a.color||S[this.type].color;if(!e&&!a.colorByPoint)t(b._colorIndex)?
+a=b._colorIndex:(b._colorIndex=d.color,a=d.color++),e=c[a];this.color=e;d.wrapColor(c.length)},getSymbol:function(){var a=this.userOptions,b=this.options.marker,c=this.chart,d=c.options.symbols,c=c.counters;this.symbol=b.symbol;if(!this.symbol)t(a._symbolIndex)?a=a._symbolIndex:(a._symbolIndex=c.symbol,a=c.symbol++),this.symbol=d[a];if(/^url/.test(this.symbol))b.radius=0;c.wrapSymbol(d.length)},drawLegendSymbol:K.drawLineMarker,setData:function(a,b){var c=this,d=c.points,e=c.options,f=c.chart,g=null,
+h=c.xAxis,i=h&&!!h.categories,j;c.xIncrement=null;c.pointRange=i?1:e.pointRange;c.colorCounter=0;var a=a||[],k=a.length;j=e.turboThreshold;var l=this.xData,m=this.yData,p=c.pointArrayMap,p=p&&p.length;q(this.parallelArrays,function(a){c[a+"Data"].length=0});if(j&&k>j){for(j=0;g===null&&j<k;)g=a[j],j++;if(ua(g)){i=o(e.pointStart,0);e=o(e.pointInterval,1);for(j=0;j<k;j++)l[j]=i,m[j]=a[j],i+=e;c.xIncrement=i}else if(Pa(g))if(p)for(j=0;j<k;j++)e=a[j],l[j]=e[0],m[j]=e.slice(1,p+1);else for(j=0;j<k;j++)e=
+a[j],l[j]=e[0],m[j]=e[1];else pa(12)}else for(j=0;j<k;j++)if(a[j]!==r&&(e={series:c},c.pointClass.prototype.applyOptions.apply(e,[a[j]]),c.updateParallelArrays(e,j),i&&e.name))h.names[e.x]=e.name;ma(m[0])&&pa(14,!0);c.data=[];c.options.data=a;for(j=d&&d.length||0;j--;)d[j]&&d[j].destroy&&d[j].destroy();if(h)h.minRange=h.userMinRange;c.isDirty=c.isDirtyData=f.isDirtyBox=!0;o(b,!0)&&f.redraw(!1)},processData:function(a){var b=this.xData,c=this.yData,d=b.length,e;e=0;var f,g,h=this.xAxis,i=this.options,
+j=i.cropThreshold,k=this.isCartesian;if(k&&!this.isDirty&&!h.isDirty&&!this.yAxis.isDirty&&!a)return!1;if(k&&this.sorted&&(!j||d>j||this.forceCrop))if(a=h.min,h=h.max,b[d-1]<a||b[0]>h)b=[],c=[];else if(b[0]<a||b[d-1]>h)e=this.cropData(this.xData,this.yData,a,h),b=e.xData,c=e.yData,e=e.start,f=!0;for(h=b.length-1;h>=0;h--)d=b[h]-b[h-1],d>0&&(g===r||d<g)?g=d:d<0&&this.requireSorting&&pa(15);this.cropped=f;this.cropStart=e;this.processedXData=b;this.processedYData=c;if(i.pointRange===null)this.pointRange=
+g||1;this.closestPointRange=g},cropData:function(a,b,c,d){var e=a.length,f=0,g=e,h=o(this.cropShoulder,1),i;for(i=0;i<e;i++)if(a[i]>=c){f=s(0,i-h);break}for(;i<e;i++)if(a[i]>d){g=i+h;break}return{xData:a.slice(f,g),yData:b.slice(f,g),start:f,end:g}},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,j=this.hasGroupedData,k,l=[],m;if(!b&&!j)b=[],b.length=a.length,b=this.data=b;for(m=0;m<g;m++)i=
+h+m,j?l[m]=(new f).init(this,[d[m]].concat(ja(e[m]))):(b[i]?k=b[i]:a[i]!==r&&(b[i]=k=(new f).init(this,a[i],d[m])),l[m]=k);if(b&&(g!==(c=b.length)||j))for(m=0;m<c;m++)if(m===h&&!j&&(m+=g),b[m])b[m].destroyElements(),b[m].plotX=r;this.data=b;this.points=l},setStackedPoints:function(){if(this.options.stacking&&!(this.visible!==!0&&this.chart.options.chart.ignoreHiddenSeries!==!1)){var a=this.processedXData,b=this.processedYData,c=[],d=b.length,e=this.options,f=e.threshold,g=e.stack,e=e.stacking,h=this.stackKey,
+i="-"+h,j=this.negStacks,k=this.yAxis,l=k.stacks,m=k.oldStacks,p,n,o,q,x;for(o=0;o<d;o++){q=a[o];x=b[o];n=(p=j&&x<f)?i:h;l[n]||(l[n]={});if(!l[n][q])m[n]&&m[n][q]?(l[n][q]=m[n][q],l[n][q].total=null):l[n][q]=new Qb(k,k.options.stackLabels,p,q,g,e);n=l[n][q];n.points[this.index]=[n.cum||0];e==="percent"?(p=p?h:i,j&&l[p]&&l[p][q]?(p=l[p][q],n.total=p.total=s(p.total,n.total)+O(x)||0):n.total=ga(n.total+(O(x)||0))):n.total=ga(n.total+(x||0));n.cum=(n.cum||0)+(x||0);n.points[this.index].push(n.cum);c[o]=
+n.cum}if(e==="percent")k.usePercentage=!0;this.stackedYData=c;k.oldStacks={}}},setPercentStacks:function(){var a=this,b=a.stackKey,c=a.yAxis.stacks;q([b,"-"+b],function(b){var d;for(var e=a.xData.length,f,g;e--;)if(f=a.xData[e],d=(g=c[b]&&c[b][f])&&g.points[a.index],f=d)g=g.total?100/g.total:0,f[0]=ga(f[0]*g),f[1]=ga(f[1]*g),a.stackedYData[e]=f[1]})},getExtremes:function(a){var b=this.yAxis,c=this.processedXData,d,e=[],f=0;d=this.xAxis.getExtremes();var g=d.min,h=d.max,i,j,k,l,a=a||this.stackedYData||
+this.processedYData;d=a.length;for(l=0;l<d;l++)if(j=c[l],k=a[l],i=k!==null&&k!==r&&(!b.isLog||k.length||k>0),j=this.getExtremesFromAll||this.cropped||(c[l+1]||j)>=g&&(c[l-1]||j)<=h,i&&j)if(i=k.length)for(;i--;)k[i]!==null&&(e[f++]=k[i]);else e[f++]=k;this.dataMin=o(void 0,Ra(e));this.dataMax=o(void 0,va(e))},translate:function(){this.processedXData||this.processData();this.generatePoints();for(var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,e=this.yAxis,f=this.points,g=f.length,h=!!this.modifyValue,
+i=a.pointPlacement,j=i==="between"||ua(i),k=a.threshold,a=0;a<g;a++){var l=f[a],m=l.x,p=l.y,n=l.low,q=b&&e.stacks[(this.negStacks&&p<k?"-":"")+this.stackKey];if(e.isLog&&p<=0)l.y=p=null;l.plotX=c.translate(m,0,0,0,1,i,this.type==="flags");if(b&&this.visible&&q&&q[m])q=q[m],p=q.points[this.index],n=p[0],p=p[1],n===0&&(n=o(k,e.min)),e.isLog&&n<=0&&(n=null),l.total=l.stackTotal=q.total,l.percentage=b==="percent"&&l.y/q.total*100,l.stackY=p,q.setOffset(this.pointXOffset||0,this.barW||0);l.yBottom=t(n)?
+e.translate(n,0,1,0,1):null;h&&(p=this.modifyValue(p,l));l.plotY=typeof p==="number"&&p!==Infinity?e.translate(p,0,1,0,1):r;l.clientX=j?c.translate(m,0,0,0,1):l.plotX;l.negative=l.y<(k||0);l.category=d&&d[l.x]!==r?d[l.x]:l.x}this.getSegments()},setTooltipPoints:function(a){var b=[],c,d,e=this.xAxis,f=e&&e.getExtremes(),g=e?e.tooltipLen||e.len:this.chart.plotSizeX,h,i,j=[];if(this.options.enableMouseTracking!==!1){if(a)this.tooltipPoints=null;q(this.segments||this.points,function(a){b=b.concat(a)});
+e&&e.reversed&&(b=b.reverse());this.orderTooltipPoints&&this.orderTooltipPoints(b);a=b.length;for(i=0;i<a;i++)if(e=b[i],c=e.x,c>=f.min&&c<=f.max){h=b[i+1];c=d===r?0:d+1;for(d=b[i+1]?y(s(0,Q((e.clientX+(h?h.wrappedClientX||h.clientX:g))/2)),g):g;c>=0&&c<=d;)j[c++]=e}this.tooltipPoints=j}},tooltipHeaderFormatter:function(a){var b=this.tooltipOptions,c=b.dateTimeLabelFormats,d=b.xDateFormat,e=this.xAxis,f=e&&e.options.type==="datetime",b=b.headerFormat,e=e&&e.closestPointRange,g;if(f&&!d){if(e)for(g in B){if(B[g]>=
+e){d=c[g];break}}else d=c.day;d=d||c.year}f&&d&&ua(a.key)&&(b=b.replace("{point.key}","{point.key:"+d+"}"));return Ha(b,{point:a,series:this})},onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&N(this,"mouseOver");this.setState("hover");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&&N(this,"mouseOut");c&&!a.stickyTracking&&(!c.shared||
+this.noSharedTooltip)&&c.hide();this.setState();b.hoverSeries=null},animate:function(a){var b=this,c=b.chart,d=c.renderer,e;e=b.options.animation;var f=c.clipBox,g=c.inverted,h;if(e&&!aa(e))e=S[b.type].animation;h="_sharedClip"+e.duration+e.easing;if(a)a=c[h],e=c[h+"m"],a||(c[h]=a=d.clipRect(u(f,{width:0})),c[h+"m"]=e=d.clipRect(-99,g?-c.plotLeft:-c.plotTop,99,g?c.chartWidth:c.chartHeight)),b.group.clip(a),b.markerGroup.clip(e),b.sharedClipKey=h;else{if(a=c[h])a.animate({width:c.plotSizeX},e),c[h+
+"m"].animate({width:c.plotSizeX+99},e);b.animate=null;b.animationTimeout=setTimeout(function(){b.afterAnimate()},e.duration)}},afterAnimate:function(){var a=this.chart,b=this.sharedClipKey,c=this.group;c&&this.options.clip!==!1&&(c.clip(a.clipRect),this.markerGroup.clip());setTimeout(function(){b&&a[b]&&(a[b]=a[b].destroy(),a[b+"m"]=a[b+"m"].destroy())},100)},drawPoints:function(){var a,b=this.points,c=this.chart,d,e,f,g,h,i,j,k,l=this.options.marker,m,p=this.markerGroup;if(l.enabled||this._hasPointMarkers)for(f=
+b.length;f--;)if(g=b[f],d=Q(g.plotX),e=g.plotY,k=g.graphic,i=g.marker||{},a=l.enabled&&i.enabled===r||i.enabled,m=c.isInsidePlot(v(d),e,c.inverted),a&&e!==r&&!isNaN(e)&&g.y!==null)if(a=g.pointAttr[g.selected?"select":""],h=a.r,i=o(i.symbol,this.symbol),j=i.indexOf("url")===0,k)k.attr({visibility:m?da?"inherit":"visible":"hidden"}).animate(u({x:d-h,y:e-h},k.symbolName?{width:2*h,height:2*h}:{}));else{if(m&&(h>0||j))g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h).attr(a).add(p)}else if(k)g.graphic=k.destroy()},
+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]=o(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var a=this,b=a.options,c=S[a.type].marker?b.marker:b,d=c.states,e=d.hover,f,g=a.color,h={stroke:g,fill:g},i=a.points||[],j=[],k,l=a.pointAttrToOptions,m=b.negativeColor,p=c.lineColor,n=c.fillColor,o;b.marker?(e.radius=e.radius||c.radius+2,e.lineWidth=e.lineWidth||c.lineWidth+1):e.color=e.color||Ba(e.color||g).brighten(e.brightness).get();
+j[""]=a.convertAttribs(c,h);q(["hover","select"],function(b){j[b]=a.convertAttribs(d[b],j[""])});a.pointAttr=j;for(g=i.length;g--;){h=i[g];if((c=h.options&&h.options.marker||h.options)&&c.enabled===!1)c.radius=0;if(h.negative&&m)h.color=h.fillColor=m;k=b.colorByPoint||h.color;if(h.options)for(o in l)t(c[l[o]])&&(k=!0);if(k){c=c||{};k=[];d=c.states||{};f=d.hover=d.hover||{};if(!b.marker)f.color=Ba(f.color||h.color).brighten(f.brightness||e.brightness).get();f={color:h.color};if(!n)f.fillColor=h.color;
+if(!p)f.lineColor=h.color;k[""]=a.convertAttribs(u(f,c),j[""]);k.hover=a.convertAttribs(d.hover,j.hover,k[""]);k.select=a.convertAttribs(d.select,j.select,k[""])}else k=j;h.pointAttr=k}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(za),d,e,f=a.data||[],g,h,i;N(a,"destroy");X(a);q(a.axisTypes||[],function(b){if(i=a[b])oa(i.series,a),i.isDirty=i.forceRedraw=!0});a.legendItem&&a.chart.legend.destroyItem(a);for(e=f.length;e--;)(g=f[e])&&g.destroy&&g.destroy();a.points=null;clearTimeout(a.animationTimeout);
+q("area,graph,dataLabelsGroup,group,markerGroup,tracker,graphNeg,areaNeg,posClip,negClip".split(","),function(b){a[b]&&(d=c&&b==="group"?"hide":"destroy",a[b][d]())});if(b.hoverSeries===a)b.hoverSeries=null;oa(b.series,a);for(h in a)delete a[h]},getSegmentPath:function(a){var b=this,c=[],d=b.options.step;q(a,function(e,f){var g=e.plotX,h=e.plotY,i;b.getPointSpline?c.push.apply(c,b.getPointSpline(a,e,f)):(c.push(f?"L":"M"),d&&f&&(i=a[f-1],d==="right"?c.push(i.plotX,h):d==="center"?c.push((i.plotX+
+g)/2,i.plotY,(i.plotX+g)/2,h):c.push(g,i.plotY)),c.push(e.plotX,e.plotY))});return c},getGraphPath:function(){var a=this,b=[],c,d=[];q(a.segments,function(e){c=a.getSegmentPath(e);e.length>1?b=b.concat(c):d.push(e[0])});a.singlePoints=d;return a.graphPath=b},drawGraph:function(){var a=this,b=this.options,c=[["graph",b.lineColor||this.color]],d=b.lineWidth,e=b.dashStyle,f=b.linecap!=="square",g=this.getGraphPath(),h=b.negativeColor;h&&c.push(["graphNeg",h]);q(c,function(c,h){var k=c[0],l=a[k];if(l)eb(l),
+l.animate({d:g});else if(d&&g.length)l={stroke:c[1],"stroke-width":d,zIndex:1},e?l.dashstyle=e:f&&(l["stroke-linecap"]=l["stroke-linejoin"]="round"),a[k]=a.chart.renderer.path(g).attr(l).add(a.group).shadow(!h&&b.shadow)})},clipNeg:function(){var a=this.options,b=this.chart,c=b.renderer,d=a.negativeColor||a.negativeFillColor,e,f=this.graph,g=this.area,h=this.posClip,i=this.negClip;e=b.chartWidth;var j=b.chartHeight,k=s(e,j),l=this.yAxis;if(d&&(f||g)){d=v(l.toPixels(a.threshold||0,!0));d<0&&(k-=d);
+a={x:0,y:0,width:k,height:d};k={x:0,y:d,width:k,height:k};if(b.inverted)a.height=k.y=b.plotWidth-d,c.isVML&&(a={x:b.plotWidth-d-b.plotLeft,y:0,width:e,height:j},k={x:d+b.plotLeft-e,y:0,width:b.plotLeft+d,height:e});l.reversed?(b=k,e=a):(b=a,e=k);h?(h.animate(b),i.animate(e)):(this.posClip=h=c.clipRect(b),this.negClip=i=c.clipRect(e),f&&this.graphNeg&&(f.clip(h),this.graphNeg.clip(i)),g&&(g.clip(h),this.areaNeg.clip(i)))}},invertGroups:function(){function a(){var a={width:b.yAxis.len,height:b.xAxis.len};
+q(["group","markerGroup"],function(c){b[c]&&b[c].attr(a).invert()})}var b=this,c=b.chart;if(b.xAxis)A(c,"resize",a),A(b,"destroy",function(){X(c,"resize",a)}),a(),b.invertGroups=a},plotGroup:function(a,b,c,d,e){var f=this[a],g=!f;g&&(this[a]=f=this.chart.renderer.g(b).attr({visibility:c,zIndex:d||0.1}).add(e));f[g?"attr":"animate"](this.getPlotBox());return f},getPlotBox:function(){return{translateX:this.xAxis?this.xAxis.left:this.chart.plotLeft,translateY:this.yAxis?this.yAxis.top:this.chart.plotTop,
+scaleX:1,scaleY:1}},render:function(){var a=this.chart,b,c=this.options,d=c.animation&&!!this.animate&&a.renderer.isSVG,e=this.visible?"visible":"hidden",f=c.zIndex,g=this.hasRendered,h=a.seriesGroup;b=this.plotGroup("group","series",e,f,h);this.markerGroup=this.plotGroup("markerGroup","markers",e,f,h);d&&this.animate(!0);this.getAttribs();b.inverted=this.isCartesian?a.inverted:!1;this.drawGraph&&(this.drawGraph(),this.clipNeg());this.drawDataLabels&&this.drawDataLabels();this.visible&&this.drawPoints();
+this.options.enableMouseTracking!==!1&&this.drawTracker();a.inverted&&this.invertGroups();c.clip!==!1&&!this.sharedClipKey&&!g&&b.clip(a.clipRect);d?this.animate():g||this.afterAnimate();this.isDirty=this.isDirtyData=!1;this.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:o(d&&d.left,a.plotLeft),translateY:o(e&&e.top,a.plotTop)}));this.translate();this.setTooltipPoints(!0);
+this.render();b&&N(this,"updatedData")},setState:function(a){var b=this.options,c=this.graph,d=this.graphNeg,e=b.states,b=b.lineWidth,a=a||"";if(this.state!==a)this.state=a,e[a]&&e[a].enabled===!1||(a&&(b=e[a].lineWidth||b+1),c&&!c.dashstyle&&(a={"stroke-width":b},c.attr(a),d&&d.attr(a)))},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,g=d.options.chart.ignoreHiddenSeries,h=c.visible;f=(c.visible=a=c.userOptions.visible=a===r?!h:a)?"show":"hide";q(["group","dataLabelsGroup","markerGroup",
+"tracker"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&q(d.series,function(a){if(a.options.stacking&&a.visible)a.isDirty=!0});q(c.linkedSeries,function(b){b.setVisible(a,!1)});if(g)d.isDirtyBox=!0;b!==!1&&d.redraw();N(c,f)},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=a===r?!this.selected:a;if(this.checkbox)this.checkbox.checked=a;N(this,a?"select":
+"unselect")},drawTracker:fb.drawTrackerGraph};u(ya.prototype,{addSeries:function(a,b,c){var d,e=this;a&&(b=o(b,!0),N(e,"addSeries",{options:a},function(){d=e.initSeries(a);e.isDirtyLegend=!0;e.linkSeries();b&&e.redraw(c)}));return d},addAxis:function(a,b,c,d){var e=b?"xAxis":"yAxis",f=this.options;new W(this,w(a,{index:this[e].length,isX:b}));f[e]=ja(f[e]||{});f[e].push(a);o(c,!0)&&this.redraw(d)},showLoading:function(a){var b=this.options,c=this.loadingDiv,d=b.loading;if(!c)this.loadingDiv=c=Z(Ta,
+{className:"highcharts-loading"},u(d.style,{zIndex:10,display:ba}),this.container),this.loadingSpan=Z("span",null,d.labelStyle,c);this.loadingSpan.innerHTML=a||b.lang.loading;if(!this.loadingShown)z(c,{opacity:0,display:"",left:this.plotLeft+"px",top:this.plotTop+"px",width:this.plotWidth+"px",height:this.plotHeight+"px"}),ob(c,{opacity:d.style.opacity},{duration:d.showDuration||0}),this.loadingShown=!0},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&ob(b,{opacity:0},{duration:a.loading.hideDuration||
+100,complete:function(){z(b,{display:ba})}});this.loadingShown=!1}});u(Da.prototype,{update:function(a,b,c){var d=this,e=d.series,f=d.graphic,g,h=e.data,i=e.chart,j=e.options,b=o(b,!0);d.firePointEvent("update",{options:a},function(){d.applyOptions(a);if(aa(a)){e.getAttribs();if(f)a&&a.marker&&a.marker.symbol?d.graphic=f.destroy():f.attr(d.pointAttr[d.state||""]);if(a&&a.dataLabels&&d.dataLabel)d.dataLabel=d.dataLabel.destroy()}g=Aa(d,h);e.updateParallelArrays(d,g);j.data[g]=d.options;e.isDirty=e.isDirtyData=
+!0;if(!e.fixedBox&&e.hasCartesianSeries)i.isDirtyBox=!0;j.legendType==="point"&&i.legend.destroyItem(d);b&&i.redraw(c)})},remove:function(a,b){var c=this,d=c.series,e=d.points,f=d.chart,g,h=d.data;Xa(b,f);a=o(a,!0);c.firePointEvent("remove",null,function(){g=Aa(c,h);h.length===e.length&&e.splice(g,1);h.splice(g,1);d.options.data.splice(g,1);d.updateParallelArrays(c,"splice",g,1);c.destroy();d.isDirty=!0;d.isDirtyData=!0;a&&f.redraw()})}});u(M.prototype,{addPoint:function(a,b,c,d){var e=this.options,
+f=this.data,g=this.graph,h=this.area,i=this.chart,j=this.xAxis&&this.xAxis.names,k=g&&g.shift||0,l=e.data,m,p=this.xData;Xa(d,i);c&&q([g,h,this.graphNeg,this.areaNeg],function(a){if(a)a.shift=k+1});if(h)h.isArea=!0;b=o(b,!0);d={series:this};this.pointClass.prototype.applyOptions.apply(d,[a]);g=d.x;h=p.length;if(this.requireSorting&&g<p[h-1])for(m=!0;h&&p[h-1]>g;)h--;this.updateParallelArrays(d,"splice",h,0,0);this.updateParallelArrays(d,h);if(j)j[g]=d.name;l.splice(h,0,a);m&&(this.data.splice(h,0,
+null),this.processData());e.legendType==="point"&&this.generatePoints();c&&(f[0]&&f[0].remove?f[0].remove(!1):(f.shift(),this.updateParallelArrays(d,"shift"),l.shift()));this.isDirtyData=this.isDirty=!0;b&&(this.getAttribs(),i.redraw())},remove:function(a,b){var c=this,d=c.chart,a=o(a,!0);if(!c.isRemoving)c.isRemoving=!0,N(c,"remove",null,function(){c.destroy();d.isDirtyLegend=d.isDirtyBox=!0;d.linkSeries();a&&d.redraw(b)});c.isRemoving=!1},update:function(a,b){var c=this.chart,d=this.type,e=D[d].prototype,
+f,a=w(this.userOptions,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1);for(f in e)e.hasOwnProperty(f)&&(this[f]=r);u(this,D[a.type||d].prototype);this.init(c,a);o(b,!0)&&c.redraw(!1)}});u(W.prototype,{update:function(a,b){var c=this.chart,a=c.options[this.coll][this.options.index]=w(this.userOptions,a);this.destroy(!0);this._addedPlotLB=this.userMin=this.userMax=r;this.init(c,u(a,{events:r}));c.isDirtyBox=!0;o(b,!0)&&c.redraw()},remove:function(a){var b=
+this.chart,c=this.coll;q(this.series,function(a){a.remove(!1)});oa(b.axes,this);oa(b[c],this);b.options[c].splice(this.options.index,1);q(b[c],function(a,b){a.options.index=b});this.destroy();b.isDirtyBox=!0;o(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}});var ia=ea(M);D.line=ia;S.area=w(R,{threshold:0});var ab=ea(M,{type:"area",getSegments:function(){var a=[],b=[],c=[],d=this.xAxis,e=this.yAxis,f=e.stacks[this.stackKey],
+g={},h,i,j=this.points,k=this.options.connectNulls,l,m,p;if(this.options.stacking&&!this.cropped){for(m=0;m<j.length;m++)g[j[m].x]=j[m];for(p in f)f[p].total!==null&&c.push(+p);c.sort(function(a,b){return a-b});q(c,function(a){if(!k||g[a]&&g[a].y!==null)g[a]?b.push(g[a]):(h=d.translate(a),l=f[a].percent?f[a].total?f[a].cum*100/f[a].total:0:f[a].cum,i=e.toPixels(l,!0),b.push({y:null,plotX:h,clientX:h,plotY:i,yBottom:i,onMouseOver:la}))});b.length&&a.push(b)}else M.prototype.getSegments.call(this),
+a=this.segments;this.segments=a},getSegmentPath:function(a){var b=M.prototype.getSegmentPath.call(this,a),c=[].concat(b),d,e=this.options;d=b.length;var f=this.yAxis.getThreshold(e.threshold),g;d===3&&c.push("L",b[1],b[2]);if(e.stacking&&!this.closedStacks)for(d=a.length-1;d>=0;d--)g=o(a[d].yBottom,f),d<a.length-1&&e.step&&c.push(a[d+1].plotX,g),c.push(a[d].plotX,g);else this.closeSegment(c,a,f);this.areaPath=this.areaPath.concat(c);return b},closeSegment:function(a,b,c){a.push("L",b[b.length-1].plotX,
+c,"L",b[0].plotX,c)},drawGraph:function(){this.areaPath=[];M.prototype.drawGraph.apply(this);var a=this,b=this.areaPath,c=this.options,d=c.negativeColor,e=c.negativeFillColor,f=[["area",this.color,c.fillColor]];(d||e)&&f.push(["areaNeg",d,e]);q(f,function(d){var e=d[0],f=a[e];f?f.animate({d:b}):a[e]=a.chart.renderer.path(b).attr({fill:o(d[2],Ba(d[1]).setOpacity(o(c.fillOpacity,0.75)).get()),zIndex:0}).add(a.group)})},drawLegendSymbol:K.drawRectangle});D.area=ab;S.spline=w(R);ia=ea(M,{type:"spline",
+getPointSpline:function(a,b,c){var d=b.plotX,e=b.plotY,f=a[c-1],g=a[c+1],h,i,j,k;if(f&&g){a=f.plotY;j=g.plotX;var g=g.plotY,l;h=(1.5*d+f.plotX)/2.5;i=(1.5*e+a)/2.5;j=(1.5*d+j)/2.5;k=(1.5*e+g)/2.5;l=(k-i)*(j-d)/(j-h)+e-k;i+=l;k+=l;i>a&&i>e?(i=s(a,e),k=2*e-i):i<a&&i<e&&(i=y(a,e),k=2*e-i);k>g&&k>e?(k=s(g,e),i=2*e-k):k<g&&k<e&&(k=y(g,e),i=2*e-k);b.rightContX=j;b.rightContY=k}c?(b=["C",f.rightContX||f.plotX,f.rightContY||f.plotY,h||d,i||e,d,e],f.rightContX=f.rightContY=null):b=["M",d,e];return b}});D.spline=
+ia;S.areaspline=w(S.area);ab=ab.prototype;ia=ea(ia,{type:"areaspline",closedStacks:!0,getSegmentPath:ab.getSegmentPath,closeSegment:ab.closeSegment,drawGraph:ab.drawGraph,drawLegendSymbol:K.drawRectangle});D.areaspline=ia;S.column=w(R,{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:{align:null,
+verticalAlign:null,y:null},stickyTracking:!1,threshold:0});ia=ea(M,{type:"column",pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color",r:"borderRadius"},cropShoulder:0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){M.prototype.init.apply(this,arguments);var a=this,b=a.chart;b.hasRendered&&q(b.series,function(b){if(b.type===a.type)b.isDirty=!0})},getColumnMetrics:function(){var a=this,b=a.options,c=a.xAxis,d=a.yAxis,e=c.reversed,f,g={},h,i=0;b.grouping===
+!1?i=1:q(a.chart.series,function(b){var c=b.options,e=b.yAxis;if(b.type===a.type&&b.visible&&d.len===e.len&&d.pos===e.pos)c.stacking?(f=b.stackKey,g[f]===r&&(g[f]=i++),h=g[f]):c.grouping!==!1&&(h=i++),b.columnIndex=h});var c=y(O(c.transA)*(c.ordinalSlope||b.pointRange||c.closestPointRange||1),c.len),j=c*b.groupPadding,k=(c-2*j)/i,l=b.pointWidth,b=t(l)?(k-l)/2:k*b.pointPadding,l=o(l,k-2*b);return a.columnMetrics={width:l,offset:b+(j+((e?i-(a.columnIndex||0):a.columnIndex)||0)*k-c/2)*(e?-1:1)}},translate:function(){var a=
+this.chart,b=this.options,c=b.borderWidth,d=this.yAxis,e=this.translatedThreshold=d.getThreshold(b.threshold),f=o(b.minPointLength,5),b=this.getColumnMetrics(),g=b.width,h=this.barW=Va(s(g,1+2*c)),i=this.pointXOffset=b.offset,j=-(c%2?0.5:0),k=c%2?0.5:1;a.renderer.isVML&&a.inverted&&(k+=1);M.prototype.translate.apply(this);q(this.points,function(a){var b=o(a.yBottom,e),c=y(s(-999-b,a.plotY),d.len+999+b),n=a.plotX+i,q=h,r=y(c,b),x,c=s(c,b)-r;O(c)<f&&f&&(c=f,r=v(O(r-e)>f?b-f:e-(d.translate(a.y,0,1,0,
+1)<=e?f:0)));a.barX=n;a.pointWidth=g;b=O(n)<0.5;q=v(n+q)+j;n=v(n)+j;q-=n;x=O(r)<0.5;c=v(r+c)+k;r=v(r)+k;c-=r;b&&(n+=1,q-=1);x&&(r-=1,c+=1);a.shapeType="rect";a.shapeArgs={x:n,y:r,width:q,height:c}})},getSymbol:la,drawLegendSymbol:K.drawRectangle,drawGraph:la,drawPoints:function(){var a=this,b=this.chart,c=a.options,d=b.renderer,e=b.options.animationLimit||250,f;q(a.points,function(g){var h=g.plotY,i=g.graphic;if(h!==r&&!isNaN(h)&&g.y!==null)f=g.shapeArgs,i?(eb(i),i[b.pointCount<e?"animate":"attr"](w(f))):
+g.graphic=d[g.shapeType](f).attr(g.pointAttr[g.selected?"select":""]).add(a.group).shadow(c.shadow,null,c.stacking&&!c.borderRadius);else if(i)g.graphic=i.destroy()})},drawTracker:fb.drawTrackerPoint,animate:function(a){var b=this.yAxis,c=this.options,d=this.chart.inverted,e={};if(da)a?(e.scaleY=0.001,a=y(b.pos+b.len,s(b.pos,b.toPixels(c.threshold))),d?e.translateX=a-b.len:e.translateY=a,this.group.attr(e)):(e.scaleY=1,e[d?"translateX":"translateY"]=b.pos,this.group.animate(e,this.options.animation),
+this.animate=null)},remove:function(){var a=this,b=a.chart;b.hasRendered&&q(b.series,function(b){if(b.type===a.type)b.isDirty=!0});M.prototype.remove.apply(a,arguments)}});D.column=ia;S.bar=w(S.column);ia=ea(ia,{type:"bar",inverted:!0});D.bar=ia;S.scatter=w(R,{lineWidth:0,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/>",followPointer:!0},stickyTracking:!1});ia=ea(M,{type:"scatter",sorted:!1,
+requireSorting:!1,noSharedTooltip:!0,trackerGroups:["markerGroup"],takeOrdinalPosition:!1,drawTracker:fb.drawTrackerPoint,drawGraph:function(){this.options.lineWidth&&M.prototype.drawGraph.call(this)},setTooltipPoints:la});D.scatter=ia;S.pie=w(R,{borderColor:"#FFFFFF",borderWidth:1,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.point.name}},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,
+states:{hover:{brightness:0.1,shadow:!1}},stickyTracking:!1,tooltip:{followPointer:!0}});R={type:"pie",isCartesian:!1,pointClass:ea(Da,{init:function(){Da.prototype.init.apply(this,arguments);var a=this,b;if(a.y<0)a.y=null;u(a,{visible:a.visible!==!1,name:o(a.name,"Slice")});b=function(b){a.slice(b.type==="select")};A(a,"select",b);A(a,"unselect",b);return a},setVisible:function(a){var b=this,c=b.series,d=c.chart,e;b.visible=b.options.visible=a=a===r?!b.visible:a;c.options.data[Aa(b,c.data)]=b.options;
+e=a?"show":"hide";q(["graphic","dataLabel","connector","shadowGroup"],function(a){if(b[a])b[a][e]()});b.legendItem&&d.legend.colorizeItem(b,a);if(!c.isDirty&&c.options.ignoreHiddenPoint)c.isDirty=!0,d.redraw()},slice:function(a,b,c){var d=this.series;Xa(c,d.chart);o(b,!0);this.sliced=this.options.sliced=a=t(a)?a:!this.sliced;d.options.data[Aa(this,d.data)]=this.options;a=a?this.slicedTranslation:{translateX:0,translateY:0};this.graphic.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)}}),requireSorting:!1,
+noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},getColor:la,animate:function(a){var b=this,c=b.points,d=b.startAngleRad;if(!a)q(c,function(a){var c=a.graphic,a=a.shapeArgs;c&&(c.attr({r:b.center[3]/2,start:d,end:d}),c.animate({r:a.r,start:a.start,end:a.end},b.options.animation))}),b.animate=null},setData:function(a,b){M.prototype.setData.call(this,a,!1);this.processData();this.generatePoints();
+o(b,!0)&&this.chart.redraw()},generatePoints:function(){var a,b=0,c,d,e,f=this.options.ignoreHiddenPoint;M.prototype.generatePoints.call(this);c=this.points;d=c.length;for(a=0;a<d;a++)e=c[a],b+=f&&!e.visible?0:e.y;this.total=b;for(a=0;a<d;a++)e=c[a],e.percentage=b>0?e.y/b*100:0,e.total=b},translate:function(a){this.generatePoints();var b=0,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,f,g,h,i=c.startAngle||0,j=this.startAngleRad=Ka/180*(i-90),i=(this.endAngleRad=Ka/180*((c.endAngle||i+360)-90))-
+j,k=this.points,l=c.dataLabels.distance,c=c.ignoreHiddenPoint,m,p=k.length,n;if(!a)this.center=a=this.getCenter();this.getX=function(b,c){h=T.asin((b-a[1])/(a[2]/2+l));return a[0]+(c?-1:1)*ca(h)*(a[2]/2+l)};for(m=0;m<p;m++){n=k[m];f=j+b*i;if(!c||n.visible)b+=n.percentage/100;g=j+b*i;n.shapeType="arc";n.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:v(f*1E3)/1E3,end:v(g*1E3)/1E3};h=(g+f)/2;h>0.75*i&&(h-=2*Ka);n.slicedTranslation={translateX:v(ca(h)*d),translateY:v(ha(h)*d)};f=ca(h)*a[2]/2;g=
+ha(h)*a[2]/2;n.tooltipPos=[a[0]+f*0.7,a[1]+g*0.7];n.half=h<-Ka/2||h>Ka/2?1:0;n.angle=h;e=y(e,l/2);n.labelPos=[a[0]+f+ca(h)*l,a[1]+g+ha(h)*l,a[0]+f+ca(h)*e,a[1]+g+ha(h)*e,a[0]+f,a[1]+g,l<0?"center":n.half?"right":"left",h]}},setTooltipPoints:la,drawGraph:null,drawPoints:function(){var a=this,b=a.chart.renderer,c,d,e=a.options.shadow,f,g;if(e&&!a.shadowGroup)a.shadowGroup=b.g("shadow").add(a.group);q(a.points,function(h){d=h.graphic;g=h.shapeArgs;f=h.shadowGroup;if(e&&!f)f=h.shadowGroup=b.g("shadow").add(a.shadowGroup);
+c=h.sliced?h.slicedTranslation:{translateX:0,translateY:0};f&&f.attr(c);d?d.animate(u(g,c)):h.graphic=d=b.arc(g).setRadialReference(a.center).attr(h.pointAttr[h.selected?"select":""]).attr({"stroke-linejoin":"round"}).attr(c).add(a.group).shadow(e,f);h.visible!==void 0&&h.setVisible(h.visible)})},sortByAngle:function(a,b){a.sort(function(a,d){return a.angle!==void 0&&(d.angle-a.angle)*b})},drawTracker:fb.drawTrackerPoint,drawLegendSymbol:K.drawRectangle,getCenter:qa.getCenter,getSymbol:la};R=ea(M,
+R);D.pie=R;M.prototype.drawDataLabels=function(){var a=this,b=a.options,c=b.cursor,d=b.dataLabels,b=a.points,e,f,g,h;if(d.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(d),h=a.plotGroup("dataLabelsGroup","data-labels",a.visible?"visible":"hidden",d.zIndex||6),f=d,q(b,function(b){var j,k=b.dataLabel,l,m,p=b.connector,n=!0;e=b.options&&b.options.dataLabels;j=o(e&&e.enabled,f.enabled);if(k&&!j)b.dataLabel=k.destroy();else if(j){d=w(f,e);j=d.rotation;l=b.getLabelConfig();g=d.format?
+Ha(d.format,l):d.formatter.call(l,d);d.style.color=o(d.color,d.style.color,a.color,"black");if(k)if(t(g))k.attr({text:g}),n=!1;else{if(b.dataLabel=k=k.destroy(),p)b.connector=p.destroy()}else if(t(g)){k={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:j,padding:d.padding,zIndex:1};for(m in k)k[m]===r&&delete k[m];k=b.dataLabel=a.chart.renderer[j?"text":"label"](g,0,-999,null,null,null,d.useHTML).attr(k).css(u(d.style,c&&{cursor:c})).add(h).shadow(d.shadow)}k&&
+a.alignDataLabel(b,k,d,null,n)}})};M.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=o(a.plotX,-999),i=o(a.plotY,-999),j=b.getBBox();if(a=this.visible&&(a.series.forceDL||f.isInsidePlot(a.plotX,a.plotY,g)))d=u({x:g?f.plotWidth-i:h,y:v(g?f.plotHeight-h:i),width:0,height:0},d),u(c,{width:j.width,height:j.height}),c.rotation?(g={align:c.align,x:d.x+c.x+d.width/2,y:d.y+c.y+d.height/2},b[e?"attr":"animate"](g)):(b.align(c,null,d),g=b.alignAttr,o(c.overflow,"justify")==="justify"?
+this.justifyDataLabel(b,c,g,j,d,e):o(c.crop,!0)&&(a=f.isInsidePlot(g.x,g.y)&&f.isInsidePlot(g.x+j.width,g.y+j.height)));if(!a)b.attr({y:-999}),b.placed=!1};M.prototype.justifyDataLabel=function(a,b,c,d,e,f){var g=this.chart,h=b.align,i=b.verticalAlign,j,k;j=c.x;if(j<0)h==="right"?b.align="left":b.x=-j,k=!0;j=c.x+d.width;if(j>g.plotWidth)h==="left"?b.align="right":b.x=g.plotWidth-j,k=!0;j=c.y;if(j<0)i==="bottom"?b.verticalAlign="top":b.y=-j,k=!0;j=c.y+d.height;if(j>g.plotHeight)i==="top"?b.verticalAlign=
+"bottom":b.y=g.plotHeight-j,k=!0;if(k)a.placed=!f,a.align(b,null,e)};if(D.pie)D.pie.prototype.drawDataLabels=function(){var a=this,b=a.data,c,d=a.chart,e=a.options.dataLabels,f=o(e.connectorPadding,10),g=o(e.connectorWidth,1),h=d.plotWidth,d=d.plotHeight,i,j,k=o(e.softConnector,!0),l=e.distance,m=a.center,p=m[2]/2,n=m[1],r=l>0,t,x,u,w,y=[[],[]],A,I,E,G,C,P=[0,0,0,0],H=function(a,b){return b.y-a.y};if(a.visible&&(e.enabled||a._hasPointLabels)){M.prototype.drawDataLabels.apply(a);q(b,function(a){a.dataLabel&&
+a.visible&&y[a.half].push(a)});for(G=0;!w&&b[G];)w=b[G]&&b[G].dataLabel&&(b[G].dataLabel.getBBox().height||21),G++;for(G=2;G--;){var b=[],F=[],D=y[G],B=D.length,z;a.sortByAngle(D,G-0.5);if(l>0){for(C=n-p-l;C<=n+p+l;C+=w)b.push(C);x=b.length;if(B>x){c=[].concat(D);c.sort(H);for(C=B;C--;)c[C].rank=C;for(C=B;C--;)D[C].rank>=x&&D.splice(C,1);B=D.length}for(C=0;C<B;C++){c=D[C];u=c.labelPos;c=9999;var L,K;for(K=0;K<x;K++)L=O(b[K]-u[1]),L<c&&(c=L,z=K);if(z<C&&b[C]!==null)z=C;else for(x<B-C+z&&b[C]!==null&&
+(z=x-B+C);b[z]===null;)z++;F.push({i:z,y:b[z]});b[z]=null}F.sort(H)}for(C=0;C<B;C++){c=D[C];u=c.labelPos;t=c.dataLabel;E=c.visible===!1?"hidden":"visible";c=u[1];if(l>0){if(x=F.pop(),z=x.i,I=x.y,c>I&&b[z+1]!==null||c<I&&b[z-1]!==null)I=c}else I=c;A=e.justify?m[0]+(G?-1:1)*(p+l):a.getX(z===0||z===b.length-1?c:I,G);t._attr={visibility:E,align:u[6]};t._pos={x:A+e.x+({left:f,right:-f}[u[6]]||0),y:I+e.y-10};t.connX=A;t.connY=I;if(this.options.size===null)x=t.width,A-x<f?P[3]=s(v(x-A+f),P[3]):A+x>h-f&&
+(P[1]=s(v(A+x-h+f),P[1])),I-w/2<0?P[0]=s(v(-I+w/2),P[0]):I+w/2>d&&(P[2]=s(v(I+w/2-d),P[2]))}}if(va(P)===0||this.verifyDataLabelOverflow(P))this.placeDataLabels(),r&&g&&q(this.points,function(b){i=b.connector;u=b.labelPos;if((t=b.dataLabel)&&t._pos)E=t._attr.visibility,A=t.connX,I=t.connY,j=k?["M",A+(u[6]==="left"?5:-5),I,"C",A,I,2*u[2]-u[4],2*u[3]-u[5],u[2],u[3],"L",u[4],u[5]]:["M",A+(u[6]==="left"?5:-5),I,"L",u[2],u[3],"L",u[4],u[5]],i?(i.animate({d:j}),i.attr("visibility",E)):b.connector=i=a.chart.renderer.path(j).attr({"stroke-width":g,
+stroke:e.connectorColor||b.color||"#606060",visibility:E}).add(a.group);else if(i)b.connector=i.destroy()})}},D.pie.prototype.placeDataLabels=function(){q(this.points,function(a){var a=a.dataLabel,b;if(a)(b=a._pos)?(a.attr(a._attr),a[a.moved?"animate":"attr"](b),a.moved=!0):a&&a.attr({y:-999})})},D.pie.prototype.alignDataLabel=la,D.pie.prototype.verifyDataLabelOverflow=function(a){var b=this.center,c=this.options,d=c.center,e=c=c.minSize||80,f;d[0]!==null?e=s(b[2]-s(a[1],a[3]),c):(e=s(b[2]-a[1]-a[3],
+c),b[0]+=(a[3]-a[1])/2);d[1]!==null?e=s(y(e,b[2]-s(a[0],a[2])),c):(e=s(y(e,b[2]-a[0]-a[2]),c),b[1]+=(a[0]-a[2])/2);e<b[2]?(b[2]=e,this.translate(b),q(this.points,function(a){if(a.dataLabel)a.dataLabel._pos=null}),this.drawDataLabels&&this.drawDataLabels()):f=!0;return f};if(D.column)D.column.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=a.dlBox||a.shapeArgs,i=a.below||a.plotY>o(this.translatedThreshold,f.plotSizeY),j=o(c.inside,!!this.options.stacking);if(h&&(d=w(h),
+g&&(d={x:f.plotWidth-d.y-d.height,y:f.plotHeight-d.x-d.width,width:d.height,height:d.width}),!j))g?(d.x+=i?0:d.width,d.width=0):(d.y+=i?d.height:0,d.height=0);c.align=o(c.align,!g||j?"center":i?"right":"left");c.verticalAlign=o(c.verticalAlign,g||j?"middle":i?"top":"bottom");M.prototype.alignDataLabel.call(this,a,b,c,d,e)};U(M.prototype,"init",function(a){var b;a.apply(this,Array.prototype.slice.call(arguments,1));(b=this.xAxis)&&b.options.ordinal&&A(this,"updatedData",function(){delete b.ordinalIndex})});
+U(W.prototype,"getTimeTicks",function(a,b,c,d,e,f,g,h){var i=0,j=0,k,l={},m,p,n,o=[],q=-Number.MAX_VALUE,x=this.options.tickPixelInterval;if(!this.options.ordinal||!f||f.length<3||c===r)return a.call(this,b,c,d,e);for(p=f.length;j<p;j++){n=j&&f[j-1]>d;f[j]<c&&(i=j);if(j===p-1||f[j+1]-f[j]>g*5||n){if(f[j]>q){for(k=a.call(this,b,f[i],f[j],e);k.length&&k[0]<=q;)k.shift();k.length&&(q=k[k.length-1]);o=o.concat(k)}i=j+1}if(n)break}a=k.info;if(h&&a.unitRange<=B.hour){j=o.length-1;for(i=1;i<j;i++)(new Date(o[i]-
+Ja))[Ua]()!==(new Date(o[i-1]-Ja))[Ua]()&&(l[o[i]]="day",m=!0);m&&(l[o[0]]="day");a.higherRanks=l}o.info=a;if(h&&t(x)){var h=a=o.length,j=[],s;for(m=[];h--;)i=this.translate(o[h]),s&&(m[h]=s-i),j[h]=s=i;m.sort();m=m[Q(m.length/2)];m<x*0.6&&(m=null);h=o[a-1]>d?a-1:a;for(s=void 0;h--;)i=j[h],d=s-i,s&&d<x*0.8&&(m===null||d<m*0.8)?(l[o[h]]&&!l[o[h+1]]?(d=h+1,s=i):d=h,o.splice(d,1)):s=i}return o});u(W.prototype,{beforeSetTickPositions:function(){var a,b=[],c=!1,d,e=this.getExtremes(),f=e.min,e=e.max,g;
+if(this.options.ordinal){q(this.series,function(c,d){if(c.visible!==!1&&c.takeOrdinalPosition!==!1&&(b=b.concat(c.processedXData),a=b.length,b.sort(function(a,b){return a-b}),a))for(d=a-1;d--;)b[d]===b[d+1]&&b.splice(d,1)});a=b.length;if(a>2){d=b[1]-b[0];for(g=a-1;g--&&!c;)b[g+1]-b[g]!==d&&(c=!0);if(!this.options.keepOrdinalPadding&&(b[0]-f>d||e-b[b.length-1]>d))c=!0}c?(this.ordinalPositions=b,c=this.val2lin(s(f,b[0]),!0),d=this.val2lin(y(e,b[b.length-1]),!0),this.ordinalSlope=e=(e-f)/(d-c),this.ordinalOffset=
+f-c*e):this.ordinalPositions=this.ordinalSlope=this.ordinalOffset=r}this.groupIntervalFactor=null},val2lin:function(a,b){var c=this.ordinalPositions;if(c){var d=c.length,e,f;for(e=d;e--;)if(c[e]===a){f=e;break}for(e=d-1;e--;)if(a>c[e]||e===0){c=(a-c[e])/(c[e+1]-c[e]);f=e+c;break}return b?f:this.ordinalSlope*(f||0)+this.ordinalOffset}else return a},lin2val:function(a,b){var c=this.ordinalPositions;if(c){var d=this.ordinalSlope,e=this.ordinalOffset,f=c.length-1,g,h;if(b)a<0?a=c[0]:a>f?a=c[f]:(f=Q(a),
+h=a-f);else for(;f--;)if(g=d*f+e,a>=g){d=d*(f+1)+e;h=(a-g)/(d-g);break}return h!==r&&c[f]!==r?c[f]+(h?h*(c[f+1]-c[f]):0):a}else return a},getExtendedPositions:function(){var a=this.chart,b=this.series[0].currentDataGrouping,c=this.ordinalIndex,d=b?b.count+b.unitName:"raw",e=this.getExtremes(),f,g;if(!c)c=this.ordinalIndex={};if(!c[d])f={series:[],getExtremes:function(){return{min:e.dataMin,max:e.dataMax}},options:{ordinal:!0},val2lin:W.prototype.val2lin},q(this.series,function(c){g={xAxis:f,xData:c.xData,
+chart:a,destroyGroupedData:la};g.options={dataGrouping:b?{enabled:!0,forced:!0,approximation:"open",units:[[b.unitName,[b.count]]]}:{enabled:!1}};c.processData.apply(g);f.series.push(g)}),this.beforeSetTickPositions.apply(f),c[d]=f.ordinalPositions;return c[d]},getGroupIntervalFactor:function(a,b,c){var d=0,c=c.processedXData,e=c.length,f=[],g=this.groupIntervalFactor;if(!g){for(;d<e-1;d++)f[d]=c[d+1]-c[d];f.sort(function(a,b){return a-b});d=f[Q(e/2)];a=s(a,c[0]);b=y(b,c[e-1]);this.groupIntervalFactor=
+g=e*d/(b-a)}return g},postProcessTickInterval:function(a){var b=this.ordinalSlope;return b?a/(b/this.closestPointRange):a}});U(ya.prototype,"pan",function(a,b){var c=this.xAxis[0],d=b.chartX,e=!1;if(c.options.ordinal&&c.series.length){var f=this.mouseDownX,g=c.getExtremes(),h=g.dataMax,i=g.min,j=g.max,k=this.hoverPoints,l=c.closestPointRange,f=(f-d)/(c.translationSlope*(c.ordinalSlope||l)),m={ordinalPositions:c.getExtendedPositions()},l=c.lin2val,p=c.val2lin,n;if(m.ordinalPositions){if(O(f)>1)k&&
+q(k,function(a){a.setState()}),f<0?(k=m,n=c.ordinalPositions?c:m):(k=c.ordinalPositions?c:m,n=m),m=n.ordinalPositions,h>m[m.length-1]&&m.push(h),f=c.toFixedRange(null,null,l.apply(k,[p.apply(k,[i,!0])+f,!0]),l.apply(n,[p.apply(n,[j,!0])+f,!0])),f.min>=y(g.dataMin,i)&&f.max<=s(h,j)&&c.setExtremes(f.min,f.max,!0,!1,{trigger:"pan"}),this.mouseDownX=d,z(this.container,{cursor:"move"})}else e=!0}else e=!0;e&&a.apply(this,Array.prototype.slice.call(arguments,1))});U(M.prototype,"getSegments",function(a){var b,
+c=this.options.gapSize,d=this.xAxis;a.apply(this,Array.prototype.slice.call(arguments,1));if(c)b=this.segments,q(b,function(a,f){for(var g=a.length-1;g--;)a[g+1].x-a[g].x>d.closestPointRange*c&&b.splice(f+1,0,a.splice(g+1,a.length-g))})});var Y=M.prototype,fc=Y.processData,gc=Y.generatePoints,hc=Y.destroy,ic=Y.tooltipHeaderFormatter,jc={approximation:"average",groupPixelWidth:2,dateTimeLabelFormats:gb("millisecond",["%A, %b %e, %H:%M:%S.%L","%A, %b %e, %H:%M:%S.%L","-%H:%M:%S.%L"],"second",["%A, %b %e, %H:%M:%S",
+"%A, %b %e, %H:%M:%S","-%H:%M:%S"],"minute",["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],"hour",["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],"day",["%A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],"week",["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],"month",["%B %Y","%B","-%B %Y"],"year",["%Y","%Y","-%Y"])},Wb={line:{},spline:{},area:{},areaspline:{},column:{approximation:"sum",groupPixelWidth:10},arearange:{approximation:"range"},areasplinerange:{approximation:"range"},columnrange:{approximation:"range",
+groupPixelWidth:10},candlestick:{approximation:"ohlc",groupPixelWidth:10},ohlc:{approximation:"ohlc",groupPixelWidth:5}},Xb=[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1]],["week",[1]],["month",[1,3,6]],["year",null]],Oa={sum:function(a){var b=a.length,c;if(!b&&a.hasNulls)c=null;else if(b)for(c=0;b--;)c+=a[b];return c},average:function(a){var b=a.length,a=Oa.sum(a);typeof a==="number"&&b&&(a/=b);return a},
+open:function(a){return a.length?a[0]:a.hasNulls?null:r},high:function(a){return a.length?va(a):a.hasNulls?null:r},low:function(a){return a.length?Ra(a):a.hasNulls?null:r},close:function(a){return a.length?a[a.length-1]:a.hasNulls?null:r},ohlc:function(a,b,c,d){a=Oa.open(a);b=Oa.high(b);c=Oa.low(c);d=Oa.close(d);if(typeof a==="number"||typeof b==="number"||typeof c==="number"||typeof d==="number")return[a,b,c,d]},range:function(a,b){a=Oa.low(a);b=Oa.high(b);if(typeof a==="number"||typeof b==="number")return[a,
+b]}};Y.groupData=function(a,b,c,d){var e=this.data,f=this.options.data,g=[],h=[],i=a.length,j,k,l=!!b,m=[[],[],[],[]],d=typeof d==="function"?d:Oa[d],p=this.pointArrayMap,n=p&&p.length,o;for(o=0;o<=i;o++){for(;c[1]!==r&&a[o]>=c[1]||o===i;)if(j=c.shift(),k=d.apply(0,m),k!==r&&(g.push(j),h.push(k)),m[0]=[],m[1]=[],m[2]=[],m[3]=[],o===i)break;if(o===i)break;if(p){j=this.cropStart+o;j=e&&e[j]||this.pointClass.prototype.applyOptions.apply({series:this},[f[j]]);var q;for(k=0;k<n;k++)if(q=j[p[k]],typeof q===
+"number")m[k].push(q);else if(q===null)m[k].hasNulls=!0}else if(j=l?b[o]:null,typeof j==="number")m[0].push(j);else if(j===null)m[0].hasNulls=!0}return[g,h]};Y.processData=function(){var a=this.chart,b=this.options,c=b.dataGrouping,d=c&&o(c.enabled,a.options._stock),e;this.forceCrop=d;this.groupPixelWidth=null;if(fc.apply(this,arguments)!==!1&&d){this.destroyGroupedData();var f=this.processedXData,g=this.processedYData,h=a.plotSizeX,i=this.xAxis,j=i.options.ordinal,k=this.groupPixelWidth=i.getGroupPixelWidth&&
+i.getGroupPixelWidth(),a=this.pointRange;if(k){e=!0;this.points=null;d=i.getExtremes();a=d.min;d=d.max;j=j&&i.getGroupIntervalFactor(a,d,this)||1;h=k*(d-a)/h*j;i=i.getTimeTicks(i.normalizeTimeTickInterval(h,c.units||Xb),a,d,null,f,this.closestPointRange);g=Y.groupData.apply(this,[f,g,i,c.approximation]);f=g[0];g=g[1];if(c.smoothed){c=f.length-1;for(f[c]=d;c--&&c>0;)f[c]+=h/2;f[0]=a}this.currentDataGrouping=i.info;if(b.pointRange===null)this.pointRange=i.info.totalRange;this.closestPointRange=i.info.totalRange;
+this.processedXData=f;this.processedYData=g}else this.currentDataGrouping=null,this.pointRange=a;this.hasGroupedData=e}};Y.destroyGroupedData=function(){var a=this.groupedData;q(a||[],function(b,c){b&&(a[c]=b.destroy?b.destroy():null)});this.groupedData=null};Y.generatePoints=function(){gc.apply(this);this.destroyGroupedData();this.groupedData=this.hasGroupedData?this.points:null};Y.tooltipHeaderFormatter=function(a){var b=this.tooltipOptions,c=this.options.dataGrouping,d=b.xDateFormat,e,f=this.xAxis,
+g,h;if(f&&f.options.type==="datetime"&&c&&ua(a.key)){g=this.currentDataGrouping;c=c.dateTimeLabelFormats;if(g)f=c[g.unitName],g.count===1?d=f[0]:(d=f[1],e=f[2]);else if(!d&&c)for(h in B)if(B[h]>=f.closestPointRange){d=c[h][0];break}d=ra(d,a.key);e&&(d+=ra(e,a.key+g.totalRange-1));a=b.headerFormat.replace("{point.key}",d)}else a=ic.call(this,a);return a};Y.destroy=function(){for(var a=this.groupedData||[],b=a.length;b--;)a[b]&&a[b].destroy();hc.apply(this)};U(Y,"setOptions",function(a,b){var c=a.call(this,
+b),d=this.type,e=this.chart.options.plotOptions,f=S[d].dataGrouping;if(Wb[d])f||(f=w(jc,Wb[d])),c.dataGrouping=w(f,e.series&&e.series.dataGrouping,e[d].dataGrouping,b.dataGrouping);if(this.chart.options._stock)this.requireSorting=!0;return c});W.prototype.getGroupPixelWidth=function(){var a=this.series,b=a.length,c,d=0,e=!1,f;for(c=b;c--;)(f=a[c].options.dataGrouping)&&(d=s(d,f.groupPixelWidth));for(c=b;c--;)if(f=a[c].options.dataGrouping)if(b=(a[c].processedXData||a[c].data).length,a[c].groupPixelWidth||
+b>this.chart.plotSizeX/d||b&&f.forced)e=!0;return e?d:0};S.ohlc=w(S.column,{lineWidth:1,tooltip:{pointFormat:'<span style="color:{series.color};font-weight:bold">{series.name}</span><br/>Open: {point.open}<br/>High: {point.high}<br/>Low: {point.low}<br/>Close: {point.close}<br/>'},states:{hover:{lineWidth:3}},threshold:null});R=ea(D.column,{type:"ohlc",pointArrayMap:["open","high","low","close"],toYData:function(a){return[a.open,a.high,a.low,a.close]},pointValKey:"high",pointAttrToOptions:{stroke:"color",
+"stroke-width":"lineWidth"},upColorProp:"stroke",getAttribs:function(){D.column.prototype.getAttribs.apply(this,arguments);var a=this.options,b=a.states,a=a.upColor||this.color,c=w(this.pointAttr),d=this.upColorProp;c[""][d]=a;c.hover[d]=b.hover.upColor||a;c.select[d]=b.select.upColor||a;q(this.points,function(a){if(a.open<a.close)a.pointAttr=c})},translate:function(){var a=this.yAxis;D.column.prototype.translate.apply(this);q(this.points,function(b){if(b.open!==null)b.plotOpen=a.translate(b.open,
+0,1,0,1);if(b.close!==null)b.plotClose=a.translate(b.close,0,1,0,1)})},drawPoints:function(){var a=this,b=a.chart,c,d,e,f,g,h,i,j;q(a.points,function(k){if(k.plotY!==r)i=k.graphic,c=k.pointAttr[k.selected?"selected":""],f=c["stroke-width"]%2/2,j=v(k.plotX)+f,g=v(k.shapeArgs.width/2),h=["M",j,v(k.yBottom),"L",j,v(k.plotY)],k.open!==null&&(d=v(k.plotOpen)+f,h.push("M",j,d,"L",j-g,d)),k.close!==null&&(e=v(k.plotClose)+f,h.push("M",j,e,"L",j+g,e)),i?i.animate({d:h}):k.graphic=b.renderer.path(h).attr(c).add(a.group)})},
+animate:null});D.ohlc=R;S.candlestick=w(S.column,{lineColor:"black",lineWidth:1,states:{hover:{lineWidth:2}},tooltip:S.ohlc.tooltip,threshold:null,upColor:"white"});R=ea(R,{type:"candlestick",pointAttrToOptions:{fill:"color",stroke:"lineColor","stroke-width":"lineWidth"},upColorProp:"fill",getAttribs:function(){D.ohlc.prototype.getAttribs.apply(this,arguments);var a=this.options,b=a.states,c=a.upLineColor||a.lineColor,d=b.hover.upLineColor||c,e=b.select.upLineColor||c;q(this.points,function(a){if(a.open<
+a.close)a.pointAttr[""].stroke=c,a.pointAttr.hover.stroke=d,a.pointAttr.select.stroke=e})},drawPoints:function(){var a=this,b=a.chart,c,d,e,f,g,h,i,j,k,l,m,p;q(a.points,function(n){l=n.graphic;if(n.plotY!==r)c=n.pointAttr[n.selected?"selected":""],j=c["stroke-width"]%2/2,k=v(n.plotX)+j,d=n.plotOpen,e=n.plotClose,f=T.min(d,e),g=T.max(d,e),p=v(n.shapeArgs.width/2),h=v(f)!==v(n.plotY),i=g!==n.yBottom,f=v(f)+j,g=v(g)+j,m=["M",k-p,g,"L",k-p,f,"L",k+p,f,"L",k+p,g,"L",k-p,g,"M",k,f,"L",k,h?v(n.plotY):f,
+"M",k,g,"L",k,i?v(n.yBottom):g,"Z"],l?l.animate({d:m}):n.graphic=b.renderer.path(m).attr(c).add(a.group).shadow(a.options.shadow)})}});D.candlestick=R;var sb=sa.prototype.symbols;S.flags=w(S.column,{dataGrouping:null,fillColor:"white",lineWidth:1,pointRange:0,shape:"flag",stackDistance:12,states:{hover:{lineColor:"black",fillColor:"#FCFFC5"}},style:{fontSize:"11px",fontWeight:"bold",textAlign:"center"},tooltip:{pointFormat:"{point.text}<br/>"},threshold:null,y:-30});D.flags=ea(D.column,{type:"flags",
+sorted:!1,noSharedTooltip:!0,takeOrdinalPosition:!1,trackerGroups:["markerGroup"],forceCrop:!0,init:M.prototype.init,pointAttrToOptions:{fill:"fillColor",stroke:"color","stroke-width":"lineWidth",r:"radius"},translate:function(){D.column.prototype.translate.apply(this);var a=this.chart,b=this.points,c=b.length-1,d,e,f=this.options.onSeries,f=(d=f&&a.get(f))&&d.options.step,g=d&&d.points,h=g&&g.length,i=this.xAxis,j=i.getExtremes(),k,l,m;if(d&&d.visible&&h){d=d.currentDataGrouping;l=g[h-1].x+(d?d.totalRange:
+0);for(b.sort(function(a,b){return a.x-b.x});h--&&b[c];)if(d=b[c],k=g[h],k.x<=d.x&&k.plotY!==r){if(d.x<=l)d.plotY=k.plotY,k.x<d.x&&!f&&(m=g[h+1])&&m.plotY!==r&&(d.plotY+=(d.x-k.x)/(m.x-k.x)*(m.plotY-k.plotY));c--;h++;if(c<0)break}}q(b,function(c,d){if(c.plotY===r)c.x>=j.min&&c.x<=j.max?c.plotY=a.chartHeight-i.bottom-(i.opposite?i.height:0)+i.offset-a.plotTop:c.shapeArgs={};if((e=b[d-1])&&e.plotX===c.plotX){if(e.stackIndex===r)e.stackIndex=0;c.stackIndex=e.stackIndex+1}})},drawPoints:function(){var a,
+b=this.points,c=this.chart.renderer,d,e,f=this.options,g=f.y,h,i,j,k,l=f.lineWidth%2/2,m,p;for(i=b.length;i--;)if(j=b[i],a=j.plotX>this.xAxis.len,d=j.plotX+(a?l:-l),k=j.stackIndex,h=j.options.shape||f.shape,e=j.plotY,e!==r&&(e=j.plotY+g+l-(k!==r&&k*f.stackDistance)),m=k?r:j.plotX+l,p=k?r:j.plotY,k=j.graphic,e!==r&&d>=0&&!a)a=j.pointAttr[j.selected?"select":""],k?k.attr({x:d,y:e,r:a.r,anchorX:m,anchorY:p}):j.graphic=c.label(j.options.title||f.title||"A",d,e,h,m,p,f.useHTML).css(w(f.style,j.style)).attr(a).attr({align:h===
+"flag"?"left":"center",width:f.width,height:f.height}).add(this.markerGroup).shadow(f.shadow),j.tooltipPos=[d,e];else if(k)j.graphic=k.destroy()},drawTracker:function(){var a=this.points;fb.drawTrackerPoint.apply(this);q(a,function(b){var c=b.graphic;c&&A(c.element,"mouseover",function(){if(b.stackIndex>0&&!b.raised)b._y=c.y,c.attr({y:b._y-8}),b.raised=!0;q(a,function(a){if(a!==b&&a.raised&&a.graphic)a.graphic.attr({y:a._y}),a.raised=!1})})})},animate:la});sb.flag=function(a,b,c,d,e){var f=e&&e.anchorX||
+a,e=e&&e.anchorY||b;return["M",f,e,"L",a,b+d,a,b,a+c,b,a+c,b+d,a,b+d,"M",f,e,"Z"]};q(["circle","square"],function(a){sb[a+"pin"]=function(b,c,d,e,f){var g=f&&f.anchorX,f=f&&f.anchorY,b=sb[a](b,c,d,e);g&&f&&b.push("M",g,c>f?c:c+e,"L",g,f);return b}});Za===Highcharts.VMLRenderer&&q(["flag","circlepin","squarepin"],function(a){rb.prototype.symbols[a]=sb[a]});R=gb("linearGradient",{x1:0,y1:0,x2:0,y2:1},"stops",[[0,"#FFF"],[1,"#CCC"]]);K=[].concat(Xb);K[4]=["day",[1,2,3,4]];K[5]=["week",[1,2,3]];u(L,{navigator:{handles:{backgroundColor:"#FFF",
+borderColor:"#666"},height:40,margin:10,maskFill:"rgba(255, 255, 255, 0.75)",outlineColor:"#444",outlineWidth:1,series:{type:D.areaspline===r?"line":"areaspline",color:"#4572A7",compare:null,fillOpacity:0.4,dataGrouping:{approximation:"average",enabled:!0,groupPixelWidth:2,smoothed:!0,units:K},dataLabels:{enabled:!1,zIndex:2},id:"highcharts-navigator-series",lineColor:"#4572A7",lineWidth:1,marker:{enabled:!1},pointRange:0,shadow:!1,threshold:null},xAxis:{tickWidth:0,lineWidth:0,gridLineWidth:1,tickPixelInterval:200,
+labels:{align:"left",x:3,y:-4},crosshair:{label:{enabled:!1}}},yAxis:{gridLineWidth:0,startOnTick:!1,endOnTick:!1,minPadding:0.1,maxPadding:0.1,labels:{enabled:!1},crosshair:{enabled:!1,label:{enabled:!1}},title:{text:null},tickWidth:0}},scrollbar:{height:cb?20:14,barBackgroundColor:R,barBorderRadius:2,barBorderWidth:1,barBorderColor:"#666",buttonArrowColor:"#666",buttonBackgroundColor:R,buttonBorderColor:"#666",buttonBorderRadius:2,buttonBorderWidth:1,minWidth:6,rifleColor:"#666",trackBackgroundColor:gb("linearGradient",
+{x1:0,y1:0,x2:0,y2:1},"stops",[[0,"#EEE"],[1,"#FFF"]]),trackBorderColor:"#CCC",trackBorderWidth:1,liveRedraw:da&&!cb}});Bb.prototype={drawHandle:function(a,b){var c=this.chart,d=c.renderer,e=this.elementsToDestroy,f=this.handles,g=this.navigatorOptions.handles,g={fill:g.backgroundColor,stroke:g.borderColor,"stroke-width":1},h;this.rendered||(f[b]=d.g().css({cursor:"e-resize"}).attr({zIndex:4-b}).add(),h=d.rect(-4.5,0,9,16,3,1).attr(g).add(f[b]),e.push(h),h=d.path(["M",-1.5,4,"L",-1.5,12,"M",0.5,4,
+"L",0.5,12]).attr(g).add(f[b]),e.push(h));f[b][c.isResizing?"animate":"attr"]({translateX:this.scrollerLeft+this.scrollbarHeight+parseInt(a,10),translateY:this.top+this.height/2-8})},drawScrollbarButton:function(a){var b=this.chart.renderer,c=this.elementsToDestroy,d=this.scrollbarButtons,e=this.scrollbarHeight,f=this.scrollbarOptions,g;this.rendered||(d[a]=b.g().add(this.scrollbarGroup),g=b.rect(-0.5,-0.5,e+1,e+1,f.buttonBorderRadius,f.buttonBorderWidth).attr({stroke:f.buttonBorderColor,"stroke-width":f.buttonBorderWidth,
+fill:f.buttonBackgroundColor}).add(d[a]),c.push(g),g=b.path(["M",e/2+(a?-1:1),e/2-3,"L",e/2+(a?-1:1),e/2+3,e/2+(a?2:-2),e/2]).attr({fill:f.buttonArrowColor}).add(d[a]),c.push(g));a&&d[a].attr({translateX:this.scrollerWidth-e})},render:function(a,b,c,d){var e=this.chart,f=e.renderer,g,h,i,j,k=this.scrollbarGroup,l=this.navigatorGroup,m=this.scrollbar,l=this.xAxis,p=this.scrollbarTrack,n=this.scrollbarHeight,q=this.scrollbarEnabled,r=this.navigatorOptions,x=this.scrollbarOptions,t=x.minWidth,u=this.height,
+w=this.top,A=this.navigatorEnabled,I=r.outlineWidth,z=I/2,G=0,C=this.outlineHeight,E=x.barBorderRadius,D=x.barBorderWidth,B=w+z,F;if(!isNaN(a)){this.navigatorLeft=g=o(l.left,e.plotLeft+n);this.navigatorWidth=h=o(l.len,e.plotWidth-2*n);this.scrollerLeft=i=g-n;this.scrollerWidth=j=j=h+2*n;l.getExtremes&&(F=this.getUnionExtremes(!0))&&(F.dataMin!==l.min||F.dataMax!==l.max)&&l.setExtremes(F.dataMin,F.dataMax,!0,!1);c=o(c,l.translate(a));d=o(d,l.translate(b));if(isNaN(c)||O(c)===Infinity)c=0,d=j;this.zoomedMax=
+y(s(c,d),h);this.zoomedMin=s(this.fixedWidth?this.zoomedMax-this.fixedWidth:y(c,d),0);this.range=this.zoomedMax-this.zoomedMin;c=v(this.zoomedMax);b=v(this.zoomedMin);a=c-b;if(!this.rendered){if(A)this.navigatorGroup=l=f.g("navigator").attr({zIndex:3}).add(),this.leftShade=f.rect().attr({fill:r.maskFill}).add(l),this.rightShade=f.rect().attr({fill:r.maskFill}).add(l),this.outline=f.path().attr({"stroke-width":I,stroke:r.outlineColor}).add(l);if(q)this.scrollbarGroup=k=f.g("scrollbar").add(),m=x.trackBorderWidth,
+this.scrollbarTrack=p=f.rect().attr({y:-m%2/2,fill:x.trackBackgroundColor,stroke:x.trackBorderColor,"stroke-width":m,r:x.trackBorderRadius||0,height:n}).add(k),this.scrollbar=m=f.rect().attr({y:-D%2/2,height:n,fill:x.barBackgroundColor,stroke:x.barBorderColor,"stroke-width":D,r:E}).add(k),this.scrollbarRifles=f.path().attr({stroke:x.rifleColor,"stroke-width":1}).add(k)}e=e.isResizing?"animate":"attr";A&&(this.leftShade[e]({x:g,y:w,width:b,height:u}),this.rightShade[e]({x:g+c,y:w,width:h-c,height:u}),
+this.outline[e]({d:["M",i,B,"L",g+b+z,B,g+b+z,B+C-n,"M",g+c-z,B+C-n,"L",g+c-z,B,i+j,B]}),this.drawHandle(b+z,0),this.drawHandle(c+z,1));if(q&&k)this.drawScrollbarButton(0),this.drawScrollbarButton(1),k[e]({translateX:i,translateY:v(B+u)}),p[e]({width:j}),g=n+b,h=a-D,h<t&&(G=(t-h)/2,h=t,g-=G),this.scrollbarPad=G,m[e]({x:Q(g)+D%2/2,width:h}),t=n+b+a/2-0.5,this.scrollbarRifles.attr({visibility:a>12?"visible":"hidden"})[e]({d:["M",t-3,n/4,"L",t-3,2*n/3,"M",t,n/4,"L",t,2*n/3,"M",t+3,n/4,"L",t+3,2*n/3]});
+this.scrollbarPad=G;this.rendered=!0}},addEvents:function(){var a=this.chart.container,b=this.mouseDownHandler,c=this.mouseMoveHandler,d=this.mouseUpHandler,e;e=[[a,"mousedown",b],[a,"mousemove",c],[document,"mouseup",d]];db&&e.push([a,"touchstart",b],[a,"touchmove",c],[document,"touchend",d]);q(e,function(a){A.apply(null,a)});this._events=e},removeEvents:function(){q(this._events,function(a){X.apply(null,a)});this._events=r;this.navigatorEnabled&&this.baseSeries&&X(this.baseSeries,"updatedData",
+this.updatedDataHandler)},init:function(){var a=this,b=a.chart,c,d,e=a.scrollbarHeight,f=a.navigatorOptions,g=a.height,h=a.top,i,j,k=document.body.style,l,m=a.baseSeries;a.mouseDownHandler=function(d){var d=b.pointer.normalize(d),e=a.zoomedMin,f=a.zoomedMax,h=a.top,j=a.scrollbarHeight,m=a.scrollerLeft,n=a.scrollerWidth,p=a.navigatorLeft,o=a.navigatorWidth,q=a.scrollbarPad,r=a.range,s=d.chartX,t=d.chartY,d=b.xAxis[0],u,v=cb?10:7;if(t>h&&t<h+g+j)if((h=!a.scrollbarEnabled||t<h+g)&&T.abs(s-e-p)<v)a.grabbedLeft=
+!0,a.otherHandlePos=f,a.fixedExtreme=d.max,b.fixedRange=null;else if(h&&T.abs(s-f-p)<v)a.grabbedRight=!0,a.otherHandlePos=e,a.fixedExtreme=d.min,b.fixedRange=null;else if(s>p+e-q&&s<p+f+q){a.grabbedCenter=s;a.fixedWidth=r;if(b.renderer.isSVG)l=k.cursor,k.cursor="ew-resize";i=s-e}else if(s>m&&s<m+n){f=h?s-p-r/2:s<p?e-r*0.2:s>m+n-j?e+r*0.2:s<p+e?e-r:f;if(f<0)f=0;else if(f+r>=o)f=o-r,u=c.dataMax;if(f!==e)a.fixedWidth=r,e=c.toFixedRange(f,f+r,null,u),d.setExtremes(e.min,e.max,!0,!1,{trigger:"navigator"})}};
+a.mouseMoveHandler=function(c){var d=a.scrollbarHeight,e=a.navigatorLeft,f=a.navigatorWidth,g=a.scrollerLeft,h=a.scrollerWidth,k=a.range,l;if(c.pageX!==0)c=b.pointer.normalize(c),l=c.chartX,l<e?l=e:l>g+h-d&&(l=g+h-d),a.grabbedLeft?(j=!0,a.render(0,0,l-e,a.otherHandlePos)):a.grabbedRight?(j=!0,a.render(0,0,a.otherHandlePos,l-e)):a.grabbedCenter&&(j=!0,l<i?l=i:l>f+i-k&&(l=f+i-k),a.render(0,0,l-i,l-i+k)),j&&a.scrollbarOptions.liveRedraw&&setTimeout(function(){a.mouseUpHandler(c)},0)};a.mouseUpHandler=
+function(d){var e,f;if(j){if(a.zoomedMin===a.otherHandlePos)e=a.fixedExtreme;else if(a.zoomedMax===a.otherHandlePos)f=a.fixedExtreme;if(a.zoomedMax===a.navigatorWidth)f=c.dataMax;e=c.toFixedRange(a.zoomedMin,a.zoomedMax,e,f);b.xAxis[0].setExtremes(e.min,e.max,!0,!1,{trigger:"navigator",triggerOp:"navigator-drag",DOMEvent:d})}if(d.type!=="mousemove")a.grabbedLeft=a.grabbedRight=a.grabbedCenter=a.fixedWidth=a.fixedExtreme=a.otherHandlePos=j=i=null,k.cursor=l||""};var p=b.xAxis.length,n=b.yAxis.length;
+b.extraBottomMargin=a.outlineHeight+f.margin;a.navigatorEnabled?(a.xAxis=c=new W(b,w({ordinal:m&&m.xAxis.options.ordinal},f.xAxis,{id:"navigator-x-axis",isX:!0,type:"datetime",index:p,height:g,offset:0,offsetLeft:e,offsetRight:-e,keepOrdinalPadding:!0,startOnTick:!1,endOnTick:!1,minPadding:0,maxPadding:0,zoomEnabled:!1})),a.yAxis=d=new W(b,w(f.yAxis,{id:"navigator-y-axis",alignTicks:!1,height:g,offset:0,index:n,zoomEnabled:!1})),m||f.series.data?a.addBaseSeries():b.series.length===0&&U(b,"redraw",
+function(c,d){if(b.series.length>0&&!a.series)a.setBaseSeries(),b.redraw=c;c.call(b,d)})):a.xAxis=c={translate:function(a,c){var d=b.xAxis[0].getExtremes(),f=b.plotWidth-2*e,g=d.dataMin,d=d.dataMax-g;return c?a*d/f+g:f*(a-g)/d},toFixedRange:W.prototype.toFixedRange};U(b,"getMargins",function(b){var e=this.legend,f=e.options;b.call(this);a.top=h=a.navigatorOptions.top||this.chartHeight-a.height-a.scrollbarHeight-this.spacing[2]-(f.verticalAlign==="bottom"&&f.enabled&&!f.floating?e.legendHeight+o(f.margin,
+10):0);if(c&&d)c.options.top=d.options.top=h,c.setAxisSize(),d.setAxisSize()});a.addEvents()},getUnionExtremes:function(a){var b=this.chart.xAxis[0],c=this.xAxis,d=c.options;if(!a||b.dataMin!==null)return{dataMin:o(d&&d.min,(t(b.dataMin)&&t(c.dataMin)?y:o)(b.dataMin,c.dataMin)),dataMax:o(d&&d.max,(t(b.dataMax)&&t(c.dataMax)?s:o)(b.dataMax,c.dataMax))}},setBaseSeries:function(a){var b=this.chart,a=a||b.options.navigator.baseSeries;this.series&&this.series.remove();this.baseSeries=b.series[a]||typeof a===
+"string"&&b.get(a)||b.series[0];this.xAxis&&this.addBaseSeries()},addBaseSeries:function(){var a=this.baseSeries,b=a?a.options:{},c=b.data,d=this.navigatorOptions.series,e;e=d.data;this.hasNavigatorData=!!e;b=w(b,d,{clip:!1,enableMouseTracking:!1,group:"nav",padXAxis:!1,xAxis:"navigator-x-axis",yAxis:"navigator-y-axis",name:"Navigator",showInLegend:!1,isInternal:!0,visible:!0});b.data=e||c;this.series=this.chart.initSeries(b);if(a&&this.navigatorOptions.adaptToUpdatedData!==!1)A(a,"updatedData",this.updatedDataHandler),
+a.userOptions.events=u(a.userOptions.event,{updatedData:this.updatedDataHandler})},updatedDataHandler:function(){var a=this.chart.scroller,b=a.baseSeries,c=b.xAxis,d=c.getExtremes(),e=d.min,f=d.max,g=d.dataMin,d=d.dataMax,h=f-e,i,j,k,l,m,p=a.series;i=p.xData;var n=!!c.setExtremes;j=f>=i[i.length-1]-(this.closestPointRange||0);i=e<=g;if(!a.hasNavigatorData)p.options.pointStart=b.xData[0],p.setData(b.options.data,!1),m=!0;i&&(l=g,k=l+h);j&&(k=d,i||(l=s(k-h,p.xData[0])));n&&(i||j)?isNaN(l)||c.setExtremes(l,
+k,!0,!1,{trigger:"updatedData"}):(m&&this.chart.redraw(!1),a.render(s(e,g),y(f,d)))},destroy:function(){this.removeEvents();q([this.xAxis,this.yAxis,this.leftShade,this.rightShade,this.outline,this.scrollbarTrack,this.scrollbarRifles,this.scrollbarGroup,this.scrollbar],function(a){a&&a.destroy&&a.destroy()});this.xAxis=this.yAxis=this.leftShade=this.rightShade=this.outline=this.scrollbarTrack=this.scrollbarRifles=this.scrollbarGroup=this.scrollbar=null;q([this.scrollbarButtons,this.handles,this.elementsToDestroy],
+function(a){Ia(a)})}};Highcharts.Scroller=Bb;U(W.prototype,"zoom",function(a,b,c){var d=this.chart,e=d.options,f=e.chart.zoomType,g=e.navigator,e=e.rangeSelector,h;if(this.isXAxis&&(g&&g.enabled||e&&e.enabled))if(f==="x")d.resetZoomButton="blocked";else if(f==="y")h=!1;else if(f==="xy")d=this.previousZoom,t(b)?this.previousZoom=[this.min,this.max]:d&&(b=d[0],c=d[1],delete this.previousZoom);return h!==r?h:a.call(this,b,c)});U(ya.prototype,"init",function(a,b,c){A(this,"beforeRender",function(){var a=
+this.options;if(a.navigator.enabled||a.scrollbar.enabled)this.scroller=new Bb(this)});a.call(this,b,c)});U(M.prototype,"addPoint",function(a,b,c,d,e){var f=this.options.turboThreshold;f&&this.xData.length>f&&aa(b)&&!Pa(b)&&this.chart.scroller&&pa(20,!0);a.call(this,b,c,d,e)});u(L,{rangeSelector:{buttonTheme:{width:28,height:16,padding:1,r:0,stroke:"#68A",zIndex:7},inputPosition:{align:"right"},labelStyle:{color:"#666"}}});L.lang=w(L.lang,{rangeSelectorZoom:"Zoom",rangeSelectorFrom:"From",rangeSelectorTo:"To"});
+Cb.prototype={clickButton:function(a,b){var c=this,d=c.selected,e=c.chart,f=c.buttons,g=c.buttonOptions[a],h=e.xAxis[0],i=e.scroller&&e.scroller.getUnionExtremes()||h||{},j=i.dataMin,k=i.dataMax,l,m=h&&v(y(h.max,o(k,h.max))),p=new Date(m),n=g.type,t=g.count,i=g._range,u;if(!(j===null||k===null||a===c.selected)){if(n==="month"||n==="year")l={month:"Month",year:"FullYear"}[n],p["set"+l](p["get"+l]()-t),l=p.getTime(),j=o(j,Number.MIN_VALUE),isNaN(l)||l<j?(l=j,m=y(l+i,k)):i=m-l;else if(i)l=s(m-i,j),m=
+y(l+i,k);else if(n==="ytd")if(h){if(k===r)j=Number.MAX_VALUE,k=Number.MIN_VALUE,q(e.series,function(a){a=a.xData;j=y(a[0],j);k=s(a[a.length-1],k)}),b=!1;m=new Date(k);u=m.getFullYear();l=u=s(j||0,Date.UTC(u,0,1));m=m.getTime();m=y(k||m,m)}else{A(e,"beforeRender",function(){c.clickButton(a)});return}else n==="all"&&h&&(l=j,m=k);f[d]&&f[d].setState(0);f[a]&&f[a].setState(2);e.fixedRange=i;h?h.setExtremes(l,m,o(b,1),0,{trigger:"rangeSelectorButton",rangeSelectorButton:g}):(d=e.options.xAxis,d[0]=w(d[0],
+{range:i,min:u}));c.setSelected(a)}},setSelected:function(a){this.selected=this.options.selected=a},defaultButtons:[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],init:function(a){var b=this,c=a.options.rangeSelector,d=c.buttons||[].concat(b.defaultButtons),e=c.selected,f=b.blurInputs=function(){var a=b.minInput,c=b.maxInput;a&&a.blur();c&&c.blur()};b.chart=a;b.options=
+c;b.buttons=[];a.extraTopMargin=25;b.buttonOptions=d;A(a.container,"mousedown",f);A(a,"resize",f);q(d,b.computeButtonRange);e!==r&&d[e]&&this.clickButton(e,!1);A(a,"load",function(){A(a.xAxis[0],"afterSetExtremes",function(){b.updateButtonStates(!0)})})},updateButtonStates:function(a){var b=this,c=this.chart,d=c.xAxis[0],e=c.scroller&&c.scroller.getUnionExtremes()||d,f=e.dataMin,g=e.dataMax,h=b.selected,i=b.buttons;a&&c.fixedRange!==v(d.max-d.min)&&(i[h]&&i[h].setState(0),b.setSelected(null));q(b.buttonOptions,
+function(a,c){var e=a._range,m=e>g-f,p=e<d.minRange,n=a.type==="all"&&d.max-d.min>=g-f&&i[c].state!==2,o=a.type==="ytd"&&ra("%Y",f)===ra("%Y",g);e===v(d.max-d.min)&&c!==h?(b.setSelected(c),i[c].setState(2)):m||p||n||o?i[c].setState(3):i[c].state===3&&i[c].setState(0)})},computeButtonRange:function(a){var b=a.type,c=a.count||1,d={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5};if(d[b])a._range=d[b]*c;else if(b==="month"||b==="year")a._range={month:30,year:365}[b]*864E5*c},setInputValue:function(a,
+b){var c=this.chart.options.rangeSelector;if(t(b))this[a+"Input"].HCTime=b;this[a+"Input"].value=ra(c.inputEditDateFormat||"%Y-%m-%d",this[a+"Input"].HCTime);this[a+"DateBox"].attr({text:ra(c.inputDateFormat||"%b %e, %Y",this[a+"Input"].HCTime)})},drawInput:function(a){var b=this,c=b.chart,d=c.options.chart.style,e=c.renderer,f=c.options.rangeSelector,g=b.div,h=a==="min",i,j,k,l=this.inputGroup;this[a+"Label"]=j=e.label(L.lang[h?"rangeSelectorFrom":"rangeSelectorTo"],this.inputGroup.offset).attr({padding:1}).css(w(d,
+f.labelStyle)).add(l);l.offset+=j.width+5;this[a+"DateBox"]=k=e.label("",l.offset).attr({padding:1,width:f.inputBoxWidth||90,height:f.inputBoxHeight||16,stroke:f.inputBoxBorderColor||"silver","stroke-width":1}).css(w({textAlign:"center"},d,f.inputStyle)).on("click",function(){b[a+"Input"].focus()}).add(l);l.offset+=k.width+(h?10:0);this[a+"Input"]=i=Z("input",{name:a,className:"highcharts-range-selector",type:"text"},u({position:"absolute",border:0,width:"1px",height:"1px",padding:0,textAlign:"center",
+fontSize:d.fontSize,fontFamily:d.fontFamily,top:c.plotTop+"px"},f.inputStyle),g);i.onfocus=function(){z(this,{left:l.translateX+k.x+"px",top:l.translateY+"px",width:k.width-2+"px",height:k.height-2+"px",border:"2px solid silver"})};i.onblur=function(){z(this,{border:0,width:"1px",height:"1px"});b.setInputValue(a)};i.onchange=function(){var a=i.value,d=(f.inputDateParser||Date.parse)(a),e=c.xAxis[0],g=e.dataMin,j=e.dataMax;isNaN(d)&&(d=a.split("-"),d=Date.UTC(E(d[0]),E(d[1])-1,E(d[2])));isNaN(d)||
+(L.global.useUTC||(d+=(new Date).getTimezoneOffset()*6E4),h?d>b.maxInput.HCTime?d=r:d<g&&(d=g):d<b.minInput.HCTime?d=r:d>j&&(d=j),d!==r&&c.xAxis[0].setExtremes(h?d:e.min,h?e.max:d,r,r,{trigger:"rangeSelectorInput"}))}},render:function(a,b){var c=this,d=c.chart,e=d.renderer,f=d.container,g=d.options,h=g.exporting&&g.navigation&&g.navigation.buttonOptions,i=g.rangeSelector,j=c.buttons,g=L.lang,k=c.div,k=c.inputGroup,l=i.buttonTheme,m=i.inputEnabled!==!1,o=l&&l.states,n=d.plotLeft,r;if(!c.rendered&&
+(c.zoomText=e.text(g.rangeSelectorZoom,n,d.plotTop-10).css(i.labelStyle).add(),r=n+c.zoomText.getBBox().width+5,q(c.buttonOptions,function(a,b){j[b]=e.button(a.text,r,d.plotTop-25,function(){c.clickButton(b);c.isActive=!0},l,o&&o.hover,o&&o.select).css({textAlign:"center"}).add();r+=j[b].width+(i.buttonSpacing||0);c.selected===b&&j[b].setState(2)}),c.updateButtonStates(),m))c.div=k=Z("div",null,{position:"relative",height:0,zIndex:1}),f.parentNode.insertBefore(k,f),c.inputGroup=k=e.g("input-group").add(),
+k.offset=0,c.drawInput("min"),c.drawInput("max");m&&(f=d.plotTop-35,k.align(u({y:f,width:k.offset,x:h&&f<(h.y||0)+h.height-d.spacing[0]?-40:0},i.inputPosition),!0,d.spacingBox),c.setInputValue("min",a),c.setInputValue("max",b));c.rendered=!0},destroy:function(){var a=this.minInput,b=this.maxInput,c=this.chart,d=this.blurInputs,e;X(c.container,"mousedown",d);X(c,"resize",d);Ia(this.buttons);if(a)a.onfocus=a.onblur=a.onchange=null;if(b)b.onfocus=b.onblur=b.onchange=null;for(e in this)this[e]&&e!=="chart"&&
+(this[e].destroy?this[e].destroy():this[e].nodeType&&Sa(this[e])),this[e]=null}};W.prototype.toFixedRange=function(a,b,c,d){var e=this.chart&&this.chart.fixedRange,a=o(c,this.translate(a,!0)),b=o(d,this.translate(b,!0)),c=e&&(b-a)/e;c>0.7&&c<1.3&&(d?a=b-e:b=a+e);return{min:a,max:b}};U(ya.prototype,"init",function(a,b,c){A(this,"init",function(){if(this.options.rangeSelector.enabled)this.rangeSelector=new Cb(this)});a.call(this,b,c)});Highcharts.RangeSelector=Cb;ya.prototype.callbacks.push(function(a){function b(){f=
+a.xAxis[0].getExtremes();g.render(f.min,f.max)}function c(){f=a.xAxis[0].getExtremes();isNaN(f.min)||h.render(f.min,f.max)}function d(a){a.triggerOp!=="navigator-drag"&&g.render(a.min,a.max)}function e(a){h.render(a.min,a.max)}var f,g=a.scroller,h=a.rangeSelector;g&&(A(a.xAxis[0],"afterSetExtremes",d),U(a,"drawChartBox",function(a){var c=this.isDirtyBox;a.call(this);c&&b()}),b());h&&(A(a.xAxis[0],"afterSetExtremes",e),A(a,"resize",c),c());A(a,"destroy",function(){g&&X(a.xAxis[0],"afterSetExtremes",
+d);h&&(X(a,"resize",c),X(a.xAxis[0],"afterSetExtremes",e))})});Highcharts.StockChart=function(a,b){var c=a.series,d,e=o(a.navigator&&a.navigator.enabled,!0)?{startOnTick:!1,endOnTick:!1}:null,f={marker:{enabled:!1,states:{hover:{radius:5}}},states:{hover:{lineWidth:2}}},g={shadow:!1,borderWidth:0};a.xAxis=Na(ja(a.xAxis||{}),function(a){return w({minPadding:0,maxPadding:0,ordinal:!0,title:{text:null},labels:{overflow:"justify"},showLastLabel:!0},a,{type:"datetime",categories:null},e)});a.yAxis=Na(ja(a.yAxis||
+{}),function(a){d=a.opposite;return w({labels:{align:d?"right":"left",x:d?-2:2,y:-2},showLastLabel:!1,title:{text:null}},a)});a.series=null;a=w({chart:{panning:!0,pinchType:"x"},navigator:{enabled:!0},scrollbar:{enabled:!0},rangeSelector:{enabled:!0},title:{text:null},tooltip:{shared:!0,crosshairs:!0},legend:{enabled:!1},plotOptions:{line:f,spline:f,area:f,areaspline:f,arearange:f,areasplinerange:f,column:g,columnrange:g,candlestick:g,ohlc:g}},a,{_stock:!0,chart:{inverted:!1}});a.series=c;return new ya(a,
+b)};U($a.prototype,"init",function(a,b,c){var d=c.chart.pinchType||"";a.call(this,b,c);this.pinchX=this.pinchHor=d.indexOf("x")!==-1;this.pinchY=this.pinchVert=d.indexOf("y")!==-1});U(W.prototype,"hideCrosshair",function(a,b,c){a.call(this,b,c);this.crossLabel&&this.crossLabel.hide()});U(W.prototype,"drawCrosshair",function(a,b,c){var d,e;a.call(this,b,c);if(t(this.crosshair.label)&&this.crosshair.label.enabled&&t(c)){var a=this.chart,f=this.options.crosshair.label,g=this.isXAxis?"x":"y",b=this.horiz,
+h=this.opposite,i=this.left,j=this.top,k=this.crossLabel,l,m,p=f.format,n="";if(!k)k=this.crossLabel=a.renderer.label().attr({align:f.align||b?"center":h?this.labelAlign==="right"?"right":"center":this.labelAlign==="left"?"left":"center",zIndex:12,height:b?16:r,fill:f.backgroundColor||this.series[0]&&this.series[0].color||"gray",padding:o(f.padding,2),stroke:f.borderColor||null,"stroke-width":f.borderWidth||0}).css(u({color:"white",fontWeight:"normal",fontSize:"11px",textAlign:"center"},f.style)).add();
+b?(l=c.plotX+i,m=j+(h?0:this.height)):(l=h?this.width+i:0,m=c.plotY+j);if(m<j||m>j+this.height)this.hideCrosshair();else{!p&&!f.formatter&&(this.isDatetimeAxis&&(n="%b %d, %Y"),p="{value"+(n?":"+n:"")+"}");k.attr({x:l,y:m,text:p?Ha(p,{value:c[g]}):f.formatter.call(this,c[g]),visibility:"visible"});c=k.box;if(b){if(this.options.tickPosition==="inside"&&!h||this.options.tickPosition!=="inside"&&h)m=k.y-c.height}else m=k.y-c.height/2;b?(d=i-c.x,e=i+this.width-c.x):(d=this.labelAlign==="left"?i:0,e=this.labelAlign===
+"right"?i+this.width:a.chartWidth);k.translateX<d&&(l+=d-k.translateX);k.translateX+c.width>=e&&(l-=k.translateX+c.width-e);k.attr({x:l,y:m,visibility:"visible"})}}});var kc=Y.init,lc=Y.processData,mc=Da.prototype.tooltipFormatter;Y.init=function(){kc.apply(this,arguments);this.setCompare(this.options.compare)};Y.setCompare=function(a){this.modifyValue=a==="value"||a==="percent"?function(b,c){var d=this.compareValue,b=a==="value"?b-d:b=100*(b/d)-100;if(c)c.change=b;return b}:null;if(this.chart.hasRendered)this.isDirty=
+!0};Y.processData=function(){var a=0,b,c,d;lc.apply(this,arguments);if(this.xAxis&&this.processedYData){b=this.processedXData;c=this.processedYData;for(d=c.length;a<d;a++)if(typeof c[a]==="number"&&b[a]>=this.xAxis.min){this.compareValue=c[a];break}}};U(Y,"getExtremes",function(a){a.call(this);if(this.modifyValue)this.dataMax=this.modifyValue(this.dataMax),this.dataMin=this.modifyValue(this.dataMin)});W.prototype.setCompare=function(a,b){this.isXAxis||(q(this.series,function(b){b.setCompare(a)}),
+o(b,!0)&&this.chart.redraw())};Da.prototype.tooltipFormatter=function(a){a=a.replace("{point.change}",(this.change>0?"+":"")+Ga(this.change,o(this.series.tooltipOptions.changeDecimals,2)));return mc.apply(this,[a])};u(Highcharts,{Axis:W,Chart:ya,Color:Ba,Point:Da,Tick:Ya,Tooltip:Ab,Renderer:Za,Series:M,SVGElement:xa,SVGRenderer:sa,arrayMin:Ra,arrayMax:va,charts:Wa,dateFormat:ra,format:Ha,pathAnim:Eb,getOptions:function(){return L},hasBidiBug:Yb,isTouchDevice:cb,numberFormat:Ga,seriesTypes:D,setOptions:function(a){L=
+w(!0,L,a);Lb();return L},addEvent:A,removeEvent:X,createElement:Z,discardElement:Sa,css:z,each:q,extend:u,map:Na,merge:w,pick:o,splat:ja,extendClass:ea,pInt:E,wrap:U,svg:da,canvas:ka,vml:!da&&!ka,product:"Highstock",version:"1.3.9"})})();
--- /dev/null
+// ==ClosureCompiler==
+// @compilation_level SIMPLE_OPTIMIZATIONS
+
+/**
+ * @license Highstock JS v1.1.4 (2012-02-15)
+ *
+ * (c) 2009-2011 Torstein Hønsi
+ *
+ * License: www.highcharts.com/license
+ */
+
+// JSLint options:
+/*global Highcharts, document, window, navigator, setInterval, clearInterval, clearTimeout, setTimeout, location, jQuery, $ */
+
+(function () {
+// encapsulated variables
+var UNDEFINED,
+ doc = document,
+ win = window,
+ math = Math,
+ mathRound = math.round,
+ mathFloor = math.floor,
+ mathCeil = math.ceil,
+ mathMax = math.max,
+ mathMin = math.min,
+ mathAbs = math.abs,
+ mathCos = math.cos,
+ mathSin = math.sin,
+ mathPI = math.PI,
+ deg2rad = mathPI * 2 / 360,
+
+
+ // some variables
+ userAgent = navigator.userAgent,
+ isIE = /msie/i.test(userAgent) && !win.opera,
+ docMode8 = doc.documentMode === 8,
+ isWebKit = /AppleWebKit/.test(userAgent),
+ isFirefox = /Firefox/.test(userAgent),
+ SVG_NS = 'http://www.w3.org/2000/svg',
+ hasSVG = !!doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect,
+ hasRtlBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4, // issue #38
+ Renderer,
+ hasTouch = doc.documentElement.ontouchstart !== UNDEFINED,
+ symbolSizes = {},
+ idCounter = 0,
+ garbageBin,
+ defaultOptions,
+ dateFormat, // function
+ globalAnimation,
+ pathAnim,
+ timeUnits,
+
+ // some constants for frequently used strings
+ DIV = 'div',
+ ABSOLUTE = 'absolute',
+ RELATIVE = 'relative',
+ HIDDEN = 'hidden',
+ PREFIX = 'highcharts-',
+ VISIBLE = 'visible',
+ PX = 'px',
+ NONE = 'none',
+ M = 'M',
+ L = 'L',
+ /*
+ * Empirical lowest possible opacities for TRACKER_FILL
+ * IE6: 0.002
+ * IE7: 0.002
+ * IE8: 0.002
+ * IE9: 0.00000000001 (unlimited)
+ * FF: 0.00000000001 (unlimited)
+ * Chrome: 0.000001
+ * Safari: 0.000001
+ * Opera: 0.00000000001 (unlimited)
+ */
+ TRACKER_FILL = 'rgba(192,192,192,' + (hasSVG ? 0.000001 : 0.002) + ')', // invisible but clickable
+ //TRACKER_FILL = 'rgba(192,192,192,0.5)',
+ NORMAL_STATE = '',
+ HOVER_STATE = 'hover',
+ SELECT_STATE = 'select',
+ MILLISECOND = 'millisecond',
+ SECOND = 'second',
+ MINUTE = 'minute',
+ HOUR = 'hour',
+ DAY = 'day',
+ WEEK = 'week',
+ MONTH = 'month',
+ YEAR = 'year',
+
+ // constants for attributes
+ FILL = 'fill',
+ LINEAR_GRADIENT = 'linearGradient',
+ STOPS = 'stops',
+ STROKE = 'stroke',
+ STROKE_WIDTH = 'stroke-width',
+
+ // time methods, changed based on whether or not UTC is used
+ makeTime,
+ getMinutes,
+ getHours,
+ getDay,
+ getDate,
+ getMonth,
+ getFullYear,
+ setMinutes,
+ setHours,
+ setDate,
+ setMonth,
+ setFullYear,
+
+ // check for a custom HighchartsAdapter defined prior to this file
+ globalAdapter = win.HighchartsAdapter,
+ adapter = globalAdapter || {},
+
+ // Utility functions. If the HighchartsAdapter is not defined, adapter is an empty object
+ // and all the utility functions will be null. In that case they are populated by the
+ // default adapters below.
+ each = adapter.each,
+ grep = adapter.grep,
+ offset = adapter.offset,
+ map = adapter.map,
+ merge = adapter.merge,
+ addEvent = adapter.addEvent,
+ removeEvent = adapter.removeEvent,
+ fireEvent = adapter.fireEvent,
+ animate = adapter.animate,
+ stop = adapter.stop,
+
+ // lookup over the types and the associated classes
+ seriesTypes = {};
+
+// The Highcharts namespace
+win.Highcharts = {};
+
+/**
+ * Extend an object with the members of another
+ * @param {Object} a The object to be extended
+ * @param {Object} b The object to add to the first one
+ */
+function extend(a, b) {
+ var n;
+ if (!a) {
+ a = {};
+ }
+ for (n in b) {
+ a[n] = b[n];
+ }
+ return a;
+}
+
+/**
+ * Take an array and turn into a hash with even number arguments as keys and odd numbers as
+ * values. Allows creating constants for commonly used style properties, attributes etc.
+ * Avoid it in performance critical situations like looping
+ */
+function hash() {
+ var i = 0,
+ args = arguments,
+ length = args.length,
+ obj = {};
+ for (; i < length; i++) {
+ obj[args[i++]] = args[i];
+ }
+ return obj;
+}
+
+/**
+ * Shortcut for parseInt
+ * @param {Object} s
+ * @param {Number} mag Magnitude
+ */
+function pInt(s, mag) {
+ return parseInt(s, mag || 10);
+}
+
+/**
+ * Check for string
+ * @param {Object} s
+ */
+function isString(s) {
+ return typeof s === 'string';
+}
+
+/**
+ * Check for object
+ * @param {Object} obj
+ */
+function isObject(obj) {
+ return typeof obj === 'object';
+}
+
+/**
+ * Check for array
+ * @param {Object} obj
+ */
+function isArray(obj) {
+ return Object.prototype.toString.call(obj) === '[object Array]';
+}
+
+/**
+ * Check for number
+ * @param {Object} n
+ */
+function isNumber(n) {
+ return typeof n === 'number';
+}
+
+function log2lin(num) {
+ return math.log(num) / math.LN10;
+}
+function lin2log(num) {
+ return math.pow(10, num);
+}
+
+/**
+ * Remove last occurence of an item from an array
+ * @param {Array} arr
+ * @param {Mixed} item
+ */
+function erase(arr, item) {
+ var i = arr.length;
+ while (i--) {
+ if (arr[i] === item) {
+ arr.splice(i, 1);
+ break;
+ }
+ }
+ //return arr;
+}
+
+/**
+ * Returns true if the object is not null or undefined. Like MooTools' $.defined.
+ * @param {Object} obj
+ */
+function defined(obj) {
+ return obj !== UNDEFINED && obj !== null;
+}
+
+/**
+ * Set or get an attribute or an object of attributes. Can't use jQuery attr because
+ * it attempts to set expando properties on the SVG element, which is not allowed.
+ *
+ * @param {Object} elem The DOM element to receive the attribute(s)
+ * @param {String|Object} prop The property or an abject of key-value pairs
+ * @param {String} value The value if a single property is set
+ */
+function attr(elem, prop, value) {
+ var key,
+ setAttribute = 'setAttribute',
+ ret;
+
+ // if the prop is a string
+ if (isString(prop)) {
+ // set the value
+ if (defined(value)) {
+
+ elem[setAttribute](prop, value);
+
+ // get the value
+ } else if (elem && elem.getAttribute) { // elem not defined when printing pie demo...
+ ret = elem.getAttribute(prop);
+ }
+
+ // else if prop is defined, it is a hash of key/value pairs
+ } else if (defined(prop) && isObject(prop)) {
+ for (key in prop) {
+ elem[setAttribute](key, prop[key]);
+ }
+ }
+ return ret;
+}
+/**
+ * Check if an element is an array, and if not, make it into an array. Like
+ * MooTools' $.splat.
+ */
+function splat(obj) {
+ return isArray(obj) ? obj : [obj];
+}
+
+
+/**
+ * Return the first value that is defined. Like MooTools' $.pick.
+ */
+function pick() {
+ var args = arguments,
+ i,
+ arg,
+ length = args.length;
+ for (i = 0; i < length; i++) {
+ arg = args[i];
+ if (typeof arg !== 'undefined' && arg !== null) {
+ return arg;
+ }
+ }
+}
+
+/**
+ * Set CSS on a given element
+ * @param {Object} el
+ * @param {Object} styles Style object with camel case property names
+ */
+function css(el, styles) {
+ if (isIE) {
+ if (styles && styles.opacity !== UNDEFINED) {
+ styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
+ }
+ }
+ extend(el.style, styles);
+}
+
+/**
+ * Utility function to create element with attributes and styles
+ * @param {Object} tag
+ * @param {Object} attribs
+ * @param {Object} styles
+ * @param {Object} parent
+ * @param {Object} nopad
+ */
+function createElement(tag, attribs, styles, parent, nopad) {
+ var el = doc.createElement(tag);
+ if (attribs) {
+ extend(el, attribs);
+ }
+ if (nopad) {
+ css(el, {padding: 0, border: NONE, margin: 0});
+ }
+ if (styles) {
+ css(el, styles);
+ }
+ if (parent) {
+ parent.appendChild(el);
+ }
+ return el;
+}
+
+/**
+ * Extend a prototyped class by new members
+ * @param {Object} parent
+ * @param {Object} members
+ */
+function extendClass(parent, members) {
+ var object = function () {};
+ object.prototype = new parent();
+ extend(object.prototype, members);
+ return object;
+}
+
+/**
+ * Format a number and return a string based on input settings
+ * @param {Number} number The input number to format
+ * @param {Number} decimals The amount of decimals
+ * @param {String} decPoint The decimal point, defaults to the one given in the lang options
+ * @param {String} thousandsSep The thousands separator, defaults to the one given in the lang options
+ */
+function numberFormat(number, decimals, decPoint, thousandsSep) {
+ var lang = defaultOptions.lang,
+ // http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_number_format/
+ n = number,
+ c = isNaN(decimals = mathAbs(decimals)) ? 2 : decimals,
+ d = decPoint === undefined ? lang.decimalPoint : decPoint,
+ t = thousandsSep === undefined ? lang.thousandsSep : thousandsSep,
+ s = n < 0 ? "-" : "",
+ i = String(pInt(n = mathAbs(+n || 0).toFixed(c))),
+ j = i.length > 3 ? i.length % 3 : 0;
+
+ return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) +
+ (c ? d + mathAbs(n - i).toFixed(c).slice(2) : "");
+}
+
+/**
+ * Based on http://www.php.net/manual/en/function.strftime.php
+ * @param {String} format
+ * @param {Number} timestamp
+ * @param {Boolean} capitalize
+ */
+dateFormat = function (format, timestamp, capitalize) {
+ function pad(number, length) {
+ // two digits
+ number = number.toString().replace(/^([0-9])$/, '0$1');
+ // three digits
+ if (length === 3) {
+ number = number.toString().replace(/^([0-9]{2})$/, '0$1');
+ }
+ return number;
+ }
+
+ if (!defined(timestamp) || isNaN(timestamp)) {
+ return 'Invalid date';
+ }
+ format = pick(format, '%Y-%m-%d %H:%M:%S');
+
+ var date = new Date(timestamp),
+ key, // used in for constuct below
+ // get the basic time values
+ hours = date[getHours](),
+ day = date[getDay](),
+ dayOfMonth = date[getDate](),
+ month = date[getMonth](),
+ fullYear = date[getFullYear](),
+ lang = defaultOptions.lang,
+ langWeekdays = lang.weekdays,
+ /* // uncomment this and the 'W' format key below to enable week numbers
+ weekNumber = function () {
+ var clone = new Date(date.valueOf()),
+ day = clone[getDay]() == 0 ? 7 : clone[getDay](),
+ dayNumber;
+ clone.setDate(clone[getDate]() + 4 - day);
+ dayNumber = mathFloor((clone.getTime() - new Date(clone[getFullYear](), 0, 1, -6)) / 86400000);
+ return 1 + mathFloor(dayNumber / 7);
+ },
+ */
+
+ // list all format keys
+ replacements = {
+
+ // Day
+ 'a': langWeekdays[day].substr(0, 3), // Short weekday, like 'Mon'
+ 'A': langWeekdays[day], // Long weekday, like 'Monday'
+ 'd': pad(dayOfMonth), // Two digit day of the month, 01 to 31
+ 'e': dayOfMonth, // Day of the month, 1 through 31
+
+ // Week (none implemented)
+ //'W': weekNumber(),
+
+ // Month
+ 'b': lang.shortMonths[month], // Short month, like 'Jan'
+ 'B': lang.months[month], // Long month, like 'January'
+ 'm': pad(month + 1), // Two digit month number, 01 through 12
+
+ // Year
+ 'y': fullYear.toString().substr(2, 2), // Two digits year, like 09 for 2009
+ 'Y': fullYear, // Four digits year, like 2009
+
+ // Time
+ 'H': pad(hours), // Two digits hours in 24h format, 00 through 23
+ 'I': pad((hours % 12) || 12), // Two digits hours in 12h format, 00 through 11
+ 'l': (hours % 12) || 12, // Hours in 12h format, 1 through 12
+ 'M': pad(date[getMinutes]()), // Two digits minutes, 00 through 59
+ 'p': hours < 12 ? 'AM' : 'PM', // Upper case AM or PM
+ 'P': hours < 12 ? 'am' : 'pm', // Lower case AM or PM
+ 'S': pad(date.getSeconds()), // Two digits seconds, 00 through 59
+ 'L': pad(timestamp % 1000, 3) // Milliseconds (naming from Ruby)
+ };
+
+
+ // do the replaces
+ for (key in replacements) {
+ format = format.replace('%' + key, replacements[key]);
+ }
+
+ // Optionally capitalize the string and return
+ return capitalize ? format.substr(0, 1).toUpperCase() + format.substr(1) : format;
+};
+
+/**
+ * Take an interval and normalize it to multiples of 1, 2, 2.5 and 5
+ * @param {Number} interval
+ * @param {Array} multiples
+ * @param {Number} magnitude
+ * @param {Object} options
+ */
+function normalizeTickInterval(interval, multiples, magnitude, options) {
+ var normalized, i;
+
+ // round to a tenfold of 1, 2, 2.5 or 5
+ //magnitude = multiples ? 1 : math.pow(10, mathFloor(math.log(interval) / math.LN10));
+ magnitude = pick(magnitude, 1);
+ normalized = interval / magnitude;
+
+ // multiples for a linear scale
+ if (!multiples) {
+ multiples = [1, 2, 2.5, 5, 10];
+ //multiples = [1, 2, 2.5, 4, 5, 7.5, 10];
+
+ // the allowDecimals option
+ if (options && (options.allowDecimals === false || options.type === 'logarithmic')) {
+ if (magnitude === 1) {
+ multiples = [1, 2, 5, 10];
+ } else if (magnitude <= 0.1) {
+ multiples = [1 / magnitude];
+ }
+ }
+ }
+
+ // normalize the interval to the nearest multiple
+ for (i = 0; i < multiples.length; i++) {
+ interval = multiples[i];
+ if (normalized <= (multiples[i] + (multiples[i + 1] || multiples[i])) / 2) {
+ break;
+ }
+ }
+
+ // multiply back to the correct magnitude
+ interval *= magnitude;
+
+ return interval;
+}
+
+/**
+ * Get a normalized tick interval for dates. Returns a configuration object with
+ * unit range (interval), count and name. Used to prepare data for getTimeTicks.
+ * Previously this logic was part of getTimeTicks, but as getTimeTicks now runs
+ * of segments in stock charts, the normalizing logic was extracted in order to
+ * prevent it for running over again for each segment having the same interval.
+ * #662, #697.
+ */
+function normalizeTimeTickInterval(tickInterval, unitsOption) {
+ var units = unitsOption || [[
+ MILLISECOND, // unit name
+ [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
+ ], [
+ SECOND,
+ [1, 2, 5, 10, 15, 30]
+ ], [
+ MINUTE,
+ [1, 2, 5, 10, 15, 30]
+ ], [
+ HOUR,
+ [1, 2, 3, 4, 6, 8, 12]
+ ], [
+ DAY,
+ [1, 2]
+ ], [
+ WEEK,
+ [1, 2]
+ ], [
+ MONTH,
+ [1, 2, 3, 4, 6]
+ ], [
+ YEAR,
+ null
+ ]],
+ unit = units[units.length - 1], // default unit is years
+ interval = timeUnits[unit[0]],
+ multiples = unit[1],
+ count,
+ i;
+
+ // loop through the units to find the one that best fits the tickInterval
+ for (i = 0; i < units.length; i++) {
+ unit = units[i];
+ interval = timeUnits[unit[0]];
+ multiples = unit[1];
+
+
+ if (units[i + 1]) {
+ // lessThan is in the middle between the highest multiple and the next unit.
+ var lessThan = (interval * multiples[multiples.length - 1] +
+ timeUnits[units[i + 1][0]]) / 2;
+
+ // break and keep the current unit
+ if (tickInterval <= lessThan) {
+ break;
+ }
+ }
+ }
+
+ // prevent 2.5 years intervals, though 25, 250 etc. are allowed
+ if (interval === timeUnits[YEAR] && tickInterval < 5 * interval) {
+ multiples = [1, 2, 5];
+ }
+
+ // prevent 2.5 years intervals, though 25, 250 etc. are allowed
+ if (interval === timeUnits[YEAR] && tickInterval < 5 * interval) {
+ multiples = [1, 2, 5];
+ }
+
+ // get the count
+ count = normalizeTickInterval(tickInterval / interval, multiples);
+
+ return {
+ unitRange: interval,
+ count: count,
+ unitName: unit[0]
+ };
+}
+
+/**
+ * Set the tick positions to a time unit that makes sense, for example
+ * on the first of each month or on every Monday. Return an array
+ * with the time positions. Used in datetime axes as well as for grouping
+ * data on a datetime axis.
+ *
+ * @param {Object} normalizedInterval The interval in axis values (ms) and the count
+ * @param {Number} min The minimum in axis values
+ * @param {Number} max The maximum in axis values
+ * @param {Number} startOfWeek
+ */
+function getTimeTicks(normalizedInterval, min, max, startOfWeek) {
+ var tickPositions = [],
+ i,
+ higherRanks = {},
+ useUTC = defaultOptions.global.useUTC,
+ minYear, // used in months and years as a basis for Date.UTC()
+ minDate = new Date(min),
+ interval = normalizedInterval.unitRange,
+ count = normalizedInterval.count;
+
+ minDate.setMilliseconds(0);
+
+ if (interval >= timeUnits[SECOND]) { // second
+ minDate.setSeconds(interval >= timeUnits[MINUTE] ? 0 :
+ count * mathFloor(minDate.getSeconds() / count));
+ }
+
+ if (interval >= timeUnits[MINUTE]) { // minute
+ minDate[setMinutes](interval >= timeUnits[HOUR] ? 0 :
+ count * mathFloor(minDate[getMinutes]() / count));
+ }
+
+ if (interval >= timeUnits[HOUR]) { // hour
+ minDate[setHours](interval >= timeUnits[DAY] ? 0 :
+ count * mathFloor(minDate[getHours]() / count));
+ }
+
+ if (interval >= timeUnits[DAY]) { // day
+ minDate[setDate](interval >= timeUnits[MONTH] ? 1 :
+ count * mathFloor(minDate[getDate]() / count));
+ }
+
+ if (interval >= timeUnits[MONTH]) { // month
+ minDate[setMonth](interval >= timeUnits[YEAR] ? 0 :
+ count * mathFloor(minDate[getMonth]() / count));
+ minYear = minDate[getFullYear]();
+ }
+
+ if (interval >= timeUnits[YEAR]) { // year
+ minYear -= minYear % count;
+ minDate[setFullYear](minYear);
+ }
+
+ // week is a special case that runs outside the hierarchy
+ if (interval === timeUnits[WEEK]) {
+ // get start of current week, independent of count
+ minDate[setDate](minDate[getDate]() - minDate[getDay]() +
+ pick(startOfWeek, 1));
+ }
+
+
+ // get tick positions
+ i = 1;
+ minYear = minDate[getFullYear]();
+ var time = minDate.getTime(),
+ minMonth = minDate[getMonth](),
+ minDateDate = minDate[getDate]();
+
+ // iterate and add tick positions at appropriate values
+ while (time < max) {
+ tickPositions.push(time);
+
+ // if the interval is years, use Date.UTC to increase years
+ if (interval === timeUnits[YEAR]) {
+ time = makeTime(minYear + i * count, 0);
+
+ // if the interval is months, use Date.UTC to increase months
+ } else if (interval === timeUnits[MONTH]) {
+ time = makeTime(minYear, minMonth + i * count);
+
+ // if we're using global time, the interval is not fixed as it jumps
+ // one hour at the DST crossover
+ } else if (!useUTC && (interval === timeUnits[DAY] || interval === timeUnits[WEEK])) {
+ time = makeTime(minYear, minMonth, minDateDate +
+ i * count * (interval === timeUnits[DAY] ? 1 : 7));
+
+ // else, the interval is fixed and we use simple addition
+ } else {
+ time += interval * count;
+
+ // mark new days if the time is dividable by day
+ if (interval <= timeUnits[HOUR] && time % timeUnits[DAY] === 0) {
+ higherRanks[time] = DAY;
+ }
+ }
+
+ i++;
+ }
+
+ // push the last time
+ tickPositions.push(time);
+
+ // record information on the chosen unit - for dynamic label formatter
+ tickPositions.info = extend(normalizedInterval, {
+ higherRanks: higherRanks,
+ totalRange: interval * count
+ });
+
+ return tickPositions;
+}
+
+/**
+ * Helper class that contains variuos counters that are local to the chart.
+ */
+function ChartCounters() {
+ this.color = 0;
+ this.symbol = 0;
+}
+
+ChartCounters.prototype = {
+ /**
+ * Wraps the color counter if it reaches the specified length.
+ */
+ wrapColor: function (length) {
+ if (this.color >= length) {
+ this.color = 0;
+ }
+ },
+
+ /**
+ * Wraps the symbol counter if it reaches the specified length.
+ */
+ wrapSymbol: function (length) {
+ if (this.symbol >= length) {
+ this.symbol = 0;
+ }
+ }
+};
+
+/**
+ * Utility method extracted from Tooltip code that places a tooltip in a chart without spilling over
+ * and not covering the point it self.
+ */
+function placeBox(boxWidth, boxHeight, outerLeft, outerTop, outerWidth, outerHeight, point, distance, preferRight) {
+
+ // keep the box within the chart area
+ var pointX = point.x,
+ pointY = point.y,
+ x = pointX + outerLeft + (preferRight ? distance : -boxWidth - distance),
+ y = pointY - boxHeight + outerTop + 15, // 15 means the point is 15 pixels up from the bottom of the tooltip
+ alignedRight;
+
+ // it is too far to the left, adjust it
+ if (x < 7) {
+ x = outerLeft + pointX + distance;
+ }
+
+ // Test to see if the tooltip is too far to the right,
+ // if it is, move it back to be inside and then up to not cover the point.
+ if ((x + boxWidth) > (outerLeft + outerWidth)) {
+ x -= (x + boxWidth) - (outerLeft + outerWidth);
+ y = pointY - boxHeight + outerTop - distance;
+ alignedRight = true;
+ }
+
+ // if it is now above the plot area, align it to the top of the plot area
+ if (y < outerTop + 5) {
+ y = outerTop + 5;
+
+ // If the tooltip is still covering the point, move it below instead
+ if (alignedRight && pointY >= y && pointY <= (y + boxHeight)) {
+ y = pointY + outerTop + distance; // below
+ }
+ } else if (y + boxHeight > outerTop + outerHeight) {
+ y = outerTop + outerHeight - boxHeight - distance; // below
+ }
+
+ return {x: x, y: y};
+}
+
+/**
+ * Utility method that sorts an object array and keeping the order of equal items.
+ * ECMA script standard does not specify the behaviour when items are equal.
+ */
+function stableSort(arr, sortFunction) {
+ var length = arr.length,
+ sortValue,
+ i;
+
+ // Add index to each item
+ for (i = 0; i < length; i++) {
+ arr[i].ss_i = i; // stable sort index
+ }
+
+ arr.sort(function (a, b) {
+ sortValue = sortFunction(a, b);
+ return sortValue === 0 ? a.ss_i - b.ss_i : sortValue;
+ });
+
+ // Remove index from items
+ for (i = 0; i < length; i++) {
+ delete arr[i].ss_i; // stable sort index
+ }
+}
+
+/**
+ * Non-recursive method to find the lowest member of an array. Math.min raises a maximum
+ * call stack size exceeded error in Chrome when trying to apply more than 150.000 points. This
+ * method is slightly slower, but safe.
+ */
+function arrayMin(data) {
+ var i = data.length,
+ min = data[0];
+
+ while (i--) {
+ if (data[i] < min) {
+ min = data[i];
+ }
+ }
+ return min;
+}
+
+/**
+ * Non-recursive method to find the lowest member of an array. Math.min raises a maximum
+ * call stack size exceeded error in Chrome when trying to apply more than 150.000 points. This
+ * method is slightly slower, but safe.
+ */
+function arrayMax(data) {
+ var i = data.length,
+ max = data[0];
+
+ while (i--) {
+ if (data[i] > max) {
+ max = data[i];
+ }
+ }
+ return max;
+}
+
+/**
+ * Utility method that destroys any SVGElement or VMLElement that are properties on the given object.
+ * It loops all properties and invokes destroy if there is a destroy method. The property is
+ * then delete'ed.
+ */
+function destroyObjectProperties(obj) {
+ var n;
+ for (n in obj) {
+ // If the object is non-null and destroy is defined
+ if (obj[n] && obj[n].destroy) {
+ // Invoke the destroy
+ obj[n].destroy();
+ }
+
+ // Delete the property from the object.
+ delete obj[n];
+ }
+}
+
+
+/**
+ * Discard an element by moving it to the bin and delete
+ * @param {Object} The HTML node to discard
+ */
+function discardElement(element) {
+ // create a garbage bin element, not part of the DOM
+ if (!garbageBin) {
+ garbageBin = createElement(DIV);
+ }
+
+ // move the node and empty bin
+ if (element) {
+ garbageBin.appendChild(element);
+ }
+ garbageBin.innerHTML = '';
+}
+
+/**
+ * The time unit lookup
+ */
+/*jslint white: true*/
+timeUnits = hash(
+ MILLISECOND, 1,
+ SECOND, 1000,
+ MINUTE, 60000,
+ HOUR, 3600000,
+ DAY, 24 * 3600000,
+ WEEK, 7 * 24 * 3600000,
+ MONTH, 30 * 24 * 3600000,
+ YEAR, 31556952000
+);
+/*jslint white: false*/
+/**
+ * Path interpolation algorithm used across adapters
+ */
+pathAnim = {
+ /**
+ * Prepare start and end values so that the path can be animated one to one
+ */
+ init: function (elem, fromD, toD) {
+ fromD = fromD || '';
+ var shift = elem.shift,
+ bezier = fromD.indexOf('C') > -1,
+ numParams = bezier ? 7 : 3,
+ endLength,
+ slice,
+ i,
+ start = fromD.split(' '),
+ end = [].concat(toD), // copy
+ startBaseLine,
+ endBaseLine,
+ sixify = function (arr) { // in splines make move points have six parameters like bezier curves
+ i = arr.length;
+ while (i--) {
+ if (arr[i] === M) {
+ arr.splice(i + 1, 0, arr[i + 1], arr[i + 2], arr[i + 1], arr[i + 2]);
+ }
+ }
+ };
+
+ if (bezier) {
+ sixify(start);
+ sixify(end);
+ }
+
+ // pull out the base lines before padding
+ if (elem.isArea) {
+ startBaseLine = start.splice(start.length - 6, 6);
+ endBaseLine = end.splice(end.length - 6, 6);
+ }
+
+ // if shifting points, prepend a dummy point to the end path
+ if (shift === 1) {
+
+ end = [].concat(end).splice(0, numParams).concat(end);
+ }
+ elem.shift = 0; // reset for following animations
+
+ // copy and append last point until the length matches the end length
+ if (start.length) {
+ endLength = end.length;
+ while (start.length < endLength) {
+
+ //bezier && sixify(start);
+ slice = [].concat(start).splice(start.length - numParams, numParams);
+ if (bezier) { // disable first control point
+ slice[numParams - 6] = slice[numParams - 2];
+ slice[numParams - 5] = slice[numParams - 1];
+ }
+ start = start.concat(slice);
+ }
+ }
+
+ if (startBaseLine) { // append the base lines for areas
+ start = start.concat(startBaseLine);
+ end = end.concat(endBaseLine);
+ }
+ return [start, end];
+ },
+
+ /**
+ * Interpolate each value of the path and return the array
+ */
+ step: function (start, end, pos, complete) {
+ var ret = [],
+ i = start.length,
+ startVal;
+
+ if (pos === 1) { // land on the final path without adjustment points appended in the ends
+ ret = complete;
+
+ } else if (i === end.length && pos < 1) {
+ while (i--) {
+ startVal = parseFloat(start[i]);
+ ret[i] =
+ isNaN(startVal) ? // a letter instruction like M or L
+ start[i] :
+ pos * (parseFloat(end[i] - startVal)) + startVal;
+
+ }
+ } else { // if animation is finished or length not matching, land on right value
+ ret = end;
+ }
+ return ret;
+ }
+};
+
+
+/**
+ * Set the global animation to either a given value, or fall back to the
+ * given chart's animation option
+ * @param {Object} animation
+ * @param {Object} chart
+ */
+function setAnimation(animation, chart) {
+ globalAnimation = pick(animation, chart.animation);
+}
+
+/*
+ * Define the adapter for frameworks. If an external adapter is not defined,
+ * Highcharts reverts to the built-in jQuery adapter.
+ */
+if (globalAdapter && globalAdapter.init) {
+ // Initialize the adapter with the pathAnim object that takes care
+ // of path animations.
+ globalAdapter.init(pathAnim);
+}
+if (!globalAdapter && win.jQuery) {
+ var jQ = jQuery;
+
+ /**
+ * Utility for iterating over an array. Parameters are reversed compared to jQuery.
+ * @param {Array} arr
+ * @param {Function} fn
+ */
+ each = function (arr, fn) {
+ var i = 0,
+ len = arr.length;
+ for (; i < len; i++) {
+ if (fn.call(arr[i], arr[i], i, arr) === false) {
+ return i;
+ }
+ }
+ };
+
+ /**
+ * Filter an array
+ */
+ grep = jQ.grep;
+
+ /**
+ * Map an array
+ * @param {Array} arr
+ * @param {Function} fn
+ */
+ map = function (arr, fn) {
+ //return jQuery.map(arr, fn);
+ var results = [],
+ i = 0,
+ len = arr.length;
+ for (; i < len; i++) {
+ results[i] = fn.call(arr[i], arr[i], i, arr);
+ }
+ return results;
+
+ };
+
+ /**
+ * Deep merge two objects and return a third object
+ */
+ merge = function () {
+ var args = arguments;
+ return jQ.extend(true, null, args[0], args[1], args[2], args[3]);
+ };
+
+ /**
+ * Get the position of an element relative to the top left of the page
+ */
+ offset = function (el) {
+ return jQ(el).offset();
+ };
+
+ /**
+ * Add an event listener
+ * @param {Object} el A HTML element or custom object
+ * @param {String} event The event type
+ * @param {Function} fn The event handler
+ */
+ addEvent = function (el, event, fn) {
+ jQ(el).bind(event, fn);
+ };
+
+ /**
+ * Remove event added with addEvent
+ * @param {Object} el The object
+ * @param {String} eventType The event type. Leave blank to remove all events.
+ * @param {Function} handler The function to remove
+ */
+ removeEvent = function (el, eventType, handler) {
+ // workaround for jQuery issue with unbinding custom events:
+ // http://forum.jquery.com/topic/javascript-error-when-unbinding-a-custom-event-using-jquery-1-4-2
+ var func = doc.removeEventListener ? 'removeEventListener' : 'detachEvent';
+ if (doc[func] && !el[func]) {
+ el[func] = function () {};
+ }
+
+ jQ(el).unbind(eventType, handler);
+ };
+
+ /**
+ * Fire an event on a custom object
+ * @param {Object} el
+ * @param {String} type
+ * @param {Object} eventArguments
+ * @param {Function} defaultFunction
+ */
+ fireEvent = function (el, type, eventArguments, defaultFunction) {
+ var event = jQ.Event(type),
+ detachedType = 'detached' + type,
+ defaultPrevented;
+
+ extend(event, eventArguments);
+
+ // Prevent jQuery from triggering the object method that is named the
+ // same as the event. For example, if the event is 'select', jQuery
+ // attempts calling el.select and it goes into a loop.
+ if (el[type]) {
+ el[detachedType] = el[type];
+ el[type] = null;
+ }
+
+ // Wrap preventDefault and stopPropagation in try/catch blocks in
+ // order to prevent JS errors when cancelling events on non-DOM
+ // objects. #615.
+ each(['preventDefault', 'stopPropagation'], function (fn) {
+ var base = event[fn];
+ event[fn] = function () {
+ try {
+ base.call(event);
+ } catch (e) {
+ if (fn === 'preventDefault') {
+ defaultPrevented = true;
+ }
+ }
+ };
+ });
+
+ // trigger it
+ jQ(el).trigger(event);
+
+ // attach the method
+ if (el[detachedType]) {
+ el[type] = el[detachedType];
+ el[detachedType] = null;
+ }
+
+ if (defaultFunction && !event.isDefaultPrevented() && !defaultPrevented) {
+ defaultFunction(event);
+ }
+ };
+
+ /**
+ * Animate a HTML element or SVG element wrapper
+ * @param {Object} el
+ * @param {Object} params
+ * @param {Object} options jQuery-like animation options: duration, easing, callback
+ */
+ animate = function (el, params, options) {
+ var $el = jQ(el);
+ if (params.d) {
+ el.toD = params.d; // keep the array form for paths, used in jQ.fx.step.d
+ params.d = 1; // because in jQuery, animating to an array has a different meaning
+ }
+
+ $el.stop();
+ $el.animate(params, options);
+
+ };
+ /**
+ * Stop running animation
+ */
+ stop = function (el) {
+ jQ(el).stop();
+ };
+
+
+ //=== Extend jQuery on init
+
+ /*jslint unparam: true*//* allow unused param x in this function */
+ jQ.extend(jQ.easing, {
+ easeOutQuad: function (x, t, b, c, d) {
+ return -c * (t /= d) * (t - 2) + b;
+ }
+ });
+ /*jslint unparam: false*/
+
+ // extend the animate function to allow SVG animations
+ var jFx = jQuery.fx,
+ jStep = jFx.step;
+
+ // extend some methods to check for elem.attr, which means it is a Highcharts SVG object
+ each(['cur', '_default', 'width', 'height'], function (fn, i) {
+ var obj = i ? jStep : jFx.prototype, // 'cur', the getter' relates to jFx.prototype
+ base = obj[fn],
+ elem;
+
+ if (base) { // step.width and step.height don't exist in jQuery < 1.7
+
+ // create the extended function replacement
+ obj[fn] = function (fx) {
+
+ // jFx.prototype.cur does not use fx argument
+ fx = i ? fx : this;
+
+ // shortcut
+ elem = fx.elem;
+
+ // jFX.prototype.cur returns the current value. The other ones are setters
+ // and returning a value has no effect.
+ return elem.attr ? // is SVG element wrapper
+ elem.attr(fx.prop, fx.now) : // apply the SVG wrapper's method
+ base.apply(this, arguments); // use jQuery's built-in method
+ };
+ }
+ });
+
+ // animate paths
+ jStep.d = function (fx) {
+ var elem = fx.elem;
+
+
+ // Normally start and end should be set in state == 0, but sometimes,
+ // for reasons unknown, this doesn't happen. Perhaps state == 0 is skipped
+ // in these cases
+ if (!fx.started) {
+ var ends = pathAnim.init(elem, elem.d, elem.toD);
+ fx.start = ends[0];
+ fx.end = ends[1];
+ fx.started = true;
+ }
+
+
+ // interpolate each value of the path
+ elem.attr('d', pathAnim.step(fx.start, fx.end, fx.pos, elem.toD));
+
+ };
+}
+
+/* ****************************************************************************
+ * Handle the options *
+ *****************************************************************************/
+var
+
+defaultLabelOptions = {
+ enabled: true,
+ // rotation: 0,
+ align: 'center',
+ x: 0,
+ y: 15,
+ /*formatter: function () {
+ return this.value;
+ },*/
+ style: {
+ color: '#666',
+ fontSize: '11px',
+ lineHeight: '14px'
+ }
+};
+
+defaultOptions = {
+ colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
+ '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92'],
+ symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
+ lang: {
+ loading: 'Loading...',
+ months: ['January', 'February', 'March', 'April', 'May', 'June', 'July',
+ 'August', 'September', 'October', 'November', 'December'],
+ shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+ weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
+ decimalPoint: '.',
+ resetZoom: 'Reset zoom',
+ resetZoomTitle: 'Reset zoom level 1:1',
+ thousandsSep: ','
+ },
+ global: {
+ useUTC: true
+ },
+ chart: {
+ //animation: true,
+ //alignTicks: false,
+ //reflow: true,
+ //className: null,
+ //events: { load, selection },
+ //margin: [null],
+ //marginTop: null,
+ //marginRight: null,
+ //marginBottom: null,
+ //marginLeft: null,
+ borderColor: '#4572A7',
+ //borderWidth: 0,
+ borderRadius: 5,
+ defaultSeriesType: 'line',
+ ignoreHiddenSeries: true,
+ //inverted: false,
+ //shadow: false,
+ spacingTop: 10,
+ spacingRight: 10,
+ spacingBottom: 15,
+ spacingLeft: 10,
+ style: {
+ fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif', // default font
+ fontSize: '12px'
+ },
+ backgroundColor: '#FFFFFF',
+ //plotBackgroundColor: null,
+ plotBorderColor: '#C0C0C0',
+ //plotBorderWidth: 0,
+ //plotShadow: false,
+ //zoomType: ''
+ resetZoomButton: { // docs
+ theme: {
+ zIndex: 20
+ },
+ position: {
+ align: 'right',
+ x: -10,
+ //verticalAlign: 'top',
+ y: 10
+ },
+ relativeTo: 'plot'
+ }
+ },
+ title: {
+ text: 'Chart title',
+ align: 'center',
+ // floating: false,
+ // margin: 15,
+ // x: 0,
+ // verticalAlign: 'top',
+ y: 15,
+ style: {
+ color: '#3E576F',
+ fontSize: '16px'
+ }
+
+ },
+ subtitle: {
+ text: '',
+ align: 'center',
+ // floating: false
+ // x: 0,
+ // verticalAlign: 'top',
+ y: 30,
+ style: {
+ color: '#6D869F'
+ }
+ },
+
+ plotOptions: {
+ line: { // base series options
+ allowPointSelect: false,
+ showCheckbox: false,
+ animation: {
+ duration: 1000
+ },
+ //connectNulls: false,
+ //cursor: 'default',
+ //clip: true,
+ //dashStyle: null,
+ //enableMouseTracking: true,
+ events: {},
+ //legendIndex: 0,
+ lineWidth: 2,
+ shadow: true,
+ // stacking: null,
+ marker: {
+ enabled: true,
+ //symbol: null,
+ lineWidth: 0,
+ radius: 4,
+ lineColor: '#FFFFFF',
+ //fillColor: null,
+ states: { // states for a single point
+ hover: {
+ //radius: base + 2
+ },
+ select: {
+ fillColor: '#FFFFFF',
+ lineColor: '#000000',
+ lineWidth: 2
+ }
+ }
+ },
+ point: {
+ events: {}
+ },
+ dataLabels: merge(defaultLabelOptions, {
+ enabled: false,
+ y: -6,
+ formatter: function () {
+ return this.y;
+ }
+ }),
+ cropThreshold: 300, // draw points outside the plot area when the number of points is less than this
+ pointRange: 0,
+ //pointStart: 0,
+ //pointInterval: 1,
+ showInLegend: true,
+ states: { // states for the entire series
+ hover: {
+ //enabled: false,
+ //lineWidth: base + 1,
+ marker: {
+ // lineWidth: base + 1,
+ // radius: base + 1
+ }
+ },
+ select: {
+ marker: {}
+ }
+ },
+ stickyTracking: true
+ //tooltip: {
+ //pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b>'
+ //valueDecimals: null,
+ //xDateFormat: '%A, %b %e, %Y',
+ //valuePrefix: '',
+ //ySuffix: ''
+ //}
+ // turboThreshold: 1000
+ // zIndex: null
+ }
+ },
+ labels: {
+ //items: [],
+ style: {
+ //font: defaultFont,
+ position: ABSOLUTE,
+ color: '#3E576F'
+ }
+ },
+ legend: {
+ enabled: true,
+ align: 'center',
+ //floating: false,
+ layout: 'horizontal',
+ labelFormatter: function () {
+ return this.name;
+ },
+ borderWidth: 1,
+ borderColor: '#909090',
+ borderRadius: 5,
+ // margin: 10,
+ // reversed: false,
+ shadow: false,
+ // backgroundColor: null,
+ style: {
+ padding: '5px'
+ },
+ itemStyle: {
+ cursor: 'pointer',
+ color: '#3E576F'
+ },
+ itemHoverStyle: {
+ //cursor: 'pointer', removed as of #601
+ color: '#000000'
+ },
+ itemHiddenStyle: {
+ color: '#C0C0C0'
+ },
+ itemCheckboxStyle: {
+ position: ABSOLUTE,
+ width: '13px', // for IE precision
+ height: '13px'
+ },
+ // itemWidth: undefined,
+ symbolWidth: 16,
+ symbolPadding: 5,
+ verticalAlign: 'bottom',
+ // width: undefined,
+ x: 0,
+ y: 0
+ },
+
+ loading: {
+ // hideDuration: 100,
+ labelStyle: {
+ fontWeight: 'bold',
+ position: RELATIVE,
+ top: '1em'
+ },
+ // showDuration: 0,
+ style: {
+ position: ABSOLUTE,
+ backgroundColor: 'white',
+ opacity: 0.5,
+ textAlign: 'center'
+ }
+ },
+
+ tooltip: {
+ enabled: true,
+ //crosshairs: null,
+ backgroundColor: 'rgba(255, 255, 255, .85)',
+ borderWidth: 2,
+ borderRadius: 5,
+ //formatter: defaultFormatter,
+ headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
+ pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>',
+ shadow: true,
+ //shared: false,
+ snap: hasTouch ? 25 : 10,
+ style: {
+ color: '#333333',
+ fontSize: '12px',
+ padding: '5px',
+ whiteSpace: 'nowrap'
+ }
+ //xDateFormat: '%A, %b %e, %Y',
+ //valueDecimals: null,
+ //valuePrefix: '',
+ //ySuffix: ''
+ },
+
+ credits: {
+ enabled: true,
+ text: 'Highcharts.com',
+ href: 'http://www.highcharts.com',
+ position: {
+ align: 'right',
+ x: -10,
+ verticalAlign: 'bottom',
+ y: -5
+ },
+ style: {
+ cursor: 'pointer',
+ color: '#909090',
+ fontSize: '10px'
+ }
+ }
+};
+
+// Axis defaults
+/*jslint white: true*/
+var defaultXAxisOptions = {
+ // allowDecimals: null,
+ // alternateGridColor: null,
+ // categories: [],
+ dateTimeLabelFormats: hash(
+ MILLISECOND, '%H:%M:%S.%L',
+ SECOND, '%H:%M:%S',
+ MINUTE, '%H:%M',
+ HOUR, '%H:%M',
+ DAY, '%e. %b',
+ WEEK, '%e. %b',
+ MONTH, '%b \'%y',
+ YEAR, '%Y'
+ ),
+ endOnTick: false,
+ gridLineColor: '#C0C0C0',
+ // gridLineDashStyle: 'solid',
+ // gridLineWidth: 0,
+ // reversed: false,
+
+ labels: defaultLabelOptions,
+ // { step: null },
+ lineColor: '#C0D0E0',
+ lineWidth: 1,
+ //linkedTo: null,
+ max: null,
+ min: null,
+ minPadding: 0.01,
+ maxPadding: 0.01,
+ //minRange: null,
+ minorGridLineColor: '#E0E0E0',
+ // minorGridLineDashStyle: null,
+ minorGridLineWidth: 1,
+ minorTickColor: '#A0A0A0',
+ //minorTickInterval: null,
+ minorTickLength: 2,
+ minorTickPosition: 'outside', // inside or outside
+ //minorTickWidth: 0,
+ //opposite: false,
+ //offset: 0,
+ //plotBands: [{
+ // events: {},
+ // zIndex: 1,
+ // labels: { align, x, verticalAlign, y, style, rotation, textAlign }
+ //}],
+ //plotLines: [{
+ // events: {}
+ // dashStyle: {}
+ // zIndex:
+ // labels: { align, x, verticalAlign, y, style, rotation, textAlign }
+ //}],
+ //reversed: false,
+ // showFirstLabel: true,
+ // showLastLabel: true,
+ startOfWeek: 1,
+ startOnTick: false,
+ tickColor: '#C0D0E0',
+ //tickInterval: null,
+ tickLength: 5,
+ tickmarkPlacement: 'between', // on or between
+ tickPixelInterval: 100,
+ tickPosition: 'outside',
+ tickWidth: 1,
+ title: {
+ //text: null,
+ align: 'middle', // low, middle or high
+ //margin: 0 for horizontal, 10 for vertical axes,
+ //rotation: 0,
+ //side: 'outside',
+ style: {
+ color: '#6D869F',
+ //font: defaultFont.replace('normal', 'bold')
+ fontWeight: 'bold'
+ }
+ //x: 0,
+ //y: 0
+ },
+ type: 'linear' // linear, logarithmic or datetime
+},
+
+defaultYAxisOptions = merge(defaultXAxisOptions, {
+ endOnTick: true,
+ gridLineWidth: 1,
+ tickPixelInterval: 72,
+ showLastLabel: true,
+ labels: {
+ align: 'right',
+ x: -8,
+ y: 3
+ },
+ lineWidth: 0,
+ maxPadding: 0.05,
+ minPadding: 0.05,
+ startOnTick: true,
+ tickWidth: 0,
+ title: {
+ rotation: 270,
+ text: 'Y-values'
+ },
+ stackLabels: {
+ enabled: false,
+ //align: dynamic,
+ //y: dynamic,
+ //x: dynamic,
+ //verticalAlign: dynamic,
+ //textAlign: dynamic,
+ //rotation: 0,
+ formatter: function () {
+ return this.total;
+ },
+ style: defaultLabelOptions.style
+ }
+}),
+
+defaultLeftAxisOptions = {
+ labels: {
+ align: 'right',
+ x: -8,
+ y: null
+ },
+ title: {
+ rotation: 270
+ }
+},
+defaultRightAxisOptions = {
+ labels: {
+ align: 'left',
+ x: 8,
+ y: null
+ },
+ title: {
+ rotation: 90
+ }
+},
+defaultBottomAxisOptions = { // horizontal axis
+ labels: {
+ align: 'center',
+ x: 0,
+ y: 14
+ // staggerLines: null
+ },
+ title: {
+ rotation: 0
+ }
+},
+defaultTopAxisOptions = merge(defaultBottomAxisOptions, {
+ labels: {
+ y: -5
+ // staggerLines: null
+ }
+});
+/*jslint white: false*/
+
+
+
+// Series defaults
+var defaultPlotOptions = defaultOptions.plotOptions,
+ defaultSeriesOptions = defaultPlotOptions.line;
+//defaultPlotOptions.line = merge(defaultSeriesOptions);
+defaultPlotOptions.spline = merge(defaultSeriesOptions);
+defaultPlotOptions.scatter = merge(defaultSeriesOptions, {
+ lineWidth: 0,
+ states: {
+ hover: {
+ lineWidth: 0
+ }
+ },
+ 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/>'
+ }
+});
+defaultPlotOptions.area = merge(defaultSeriesOptions, {
+ threshold: 0
+ // lineColor: null, // overrides color, but lets fillColor be unaltered
+ // fillOpacity: 0.75,
+ // fillColor: null
+
+});
+defaultPlotOptions.areaspline = merge(defaultPlotOptions.area);
+defaultPlotOptions.column = merge(defaultSeriesOptions, {
+ borderColor: '#FFFFFF',
+ borderWidth: 1,
+ borderRadius: 0,
+ //colorByPoint: undefined,
+ groupPadding: 0.2,
+ marker: null, // point options are specified in the base options
+ pointPadding: 0.1,
+ //pointWidth: null,
+ minPointLength: 0,
+ cropThreshold: 50, // when there are more points, they will not animate out of the chart on xAxis.setExtremes
+ pointRange: null, // null means auto, meaning 1 in a categorized axis and least distance between points if not categories
+ states: {
+ hover: {
+ brightness: 0.1,
+ shadow: false
+ },
+ select: {
+ color: '#C0C0C0',
+ borderColor: '#000000',
+ shadow: false
+ }
+ },
+ dataLabels: {
+ y: null,
+ verticalAlign: null
+ },
+ threshold: 0
+});
+defaultPlotOptions.bar = merge(defaultPlotOptions.column, {
+ dataLabels: {
+ align: 'left',
+ x: 5,
+ y: 0
+ }
+});
+defaultPlotOptions.pie = merge(defaultSeriesOptions, {
+ //dragType: '', // n/a
+ borderColor: '#FFFFFF',
+ borderWidth: 1,
+ center: ['50%', '50%'],
+ colorByPoint: true, // always true for pies
+ dataLabels: {
+ // align: null,
+ // connectorWidth: 1,
+ // connectorColor: point.color,
+ // connectorPadding: 5,
+ distance: 30,
+ enabled: true,
+ formatter: function () {
+ return this.point.name;
+ },
+ // softConnector: true,
+ y: 5
+ },
+ //innerSize: 0,
+ legendType: 'point',
+ marker: null, // point options are specified in the base options
+ size: '75%',
+ showInLegend: false,
+ slicedOffset: 10,
+ states: {
+ hover: {
+ brightness: 0.1,
+ shadow: false
+ }
+ }
+
+});
+
+// set the default time methods
+setTimeMethods();
+
+
+
+/**
+ * Set the time methods globally based on the useUTC option. Time method can be either
+ * local time or UTC (default).
+ */
+function setTimeMethods() {
+ var useUTC = defaultOptions.global.useUTC,
+ GET = useUTC ? 'getUTC' : 'get',
+ SET = useUTC ? 'setUTC' : 'set';
+
+ makeTime = useUTC ? Date.UTC : function (year, month, date, hours, minutes, seconds) {
+ return new Date(
+ year,
+ month,
+ pick(date, 1),
+ pick(hours, 0),
+ pick(minutes, 0),
+ pick(seconds, 0)
+ ).getTime();
+ };
+ getMinutes = GET + 'Minutes';
+ getHours = GET + 'Hours';
+ getDay = GET + 'Day';
+ getDate = GET + 'Date';
+ getMonth = GET + 'Month';
+ getFullYear = GET + 'FullYear';
+ setMinutes = SET + 'Minutes';
+ setHours = SET + 'Hours';
+ setDate = SET + 'Date';
+ setMonth = SET + 'Month';
+ setFullYear = SET + 'FullYear';
+
+}
+
+/**
+ * Merge the default options with custom options and return the new options structure
+ * @param {Object} options The new custom options
+ */
+function setOptions(options) {
+
+ // Pull out axis options and apply them to the respective default axis options
+ defaultXAxisOptions = merge(defaultXAxisOptions, options.xAxis);
+ defaultYAxisOptions = merge(defaultYAxisOptions, options.yAxis);
+ options.xAxis = options.yAxis = UNDEFINED;
+
+ // Merge in the default options
+ defaultOptions = merge(defaultOptions, options);
+
+ // Apply UTC
+ setTimeMethods();
+
+ return defaultOptions;
+}
+
+/**
+ * Get the updated default options. Merely exposing defaultOptions for outside modules
+ * isn't enough because the setOptions method creates a new object.
+ */
+function getOptions() {
+ return defaultOptions;
+}
+
+
+
+/**
+ * Handle color operations. The object methods are chainable.
+ * @param {String} input The input color in either rbga or hex format
+ */
+var Color = function (input) {
+ // declare variables
+ var rgba = [], result;
+
+ /**
+ * Parse the input color to rgba array
+ * @param {String} input
+ */
+ function init(input) {
+
+ // rgba
+ result = /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(input);
+ if (result) {
+ rgba = [pInt(result[1]), pInt(result[2]), pInt(result[3]), parseFloat(result[4], 10)];
+ } else { // hex
+ result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(input);
+ if (result) {
+ rgba = [pInt(result[1], 16), pInt(result[2], 16), pInt(result[3], 16), 1];
+ }
+ }
+
+ }
+ /**
+ * Return the color a specified format
+ * @param {String} format
+ */
+ function get(format) {
+ var ret;
+
+ // it's NaN if gradient colors on a column chart
+ if (rgba && !isNaN(rgba[0])) {
+ if (format === 'rgb') {
+ ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
+ } else if (format === 'a') {
+ ret = rgba[3];
+ } else {
+ ret = 'rgba(' + rgba.join(',') + ')';
+ }
+ } else {
+ ret = input;
+ }
+ return ret;
+ }
+
+ /**
+ * Brighten the color
+ * @param {Number} alpha
+ */
+ function brighten(alpha) {
+ if (isNumber(alpha) && alpha !== 0) {
+ var i;
+ for (i = 0; i < 3; i++) {
+ rgba[i] += pInt(alpha * 255);
+
+ if (rgba[i] < 0) {
+ rgba[i] = 0;
+ }
+ if (rgba[i] > 255) {
+ rgba[i] = 255;
+ }
+ }
+ }
+ return this;
+ }
+ /**
+ * Set the color's opacity to a given alpha value
+ * @param {Number} alpha
+ */
+ function setOpacity(alpha) {
+ rgba[3] = alpha;
+ return this;
+ }
+
+ // initialize: parse the input
+ init(input);
+
+ // public methods
+ return {
+ get: get,
+ brighten: brighten,
+ setOpacity: setOpacity
+ };
+};
+
+
+/**
+ * A wrapper object for SVG elements
+ */
+function SVGElement() {}
+
+SVGElement.prototype = {
+ /**
+ * Initialize the SVG renderer
+ * @param {Object} renderer
+ * @param {String} nodeName
+ */
+ init: function (renderer, nodeName) {
+ var wrapper = this;
+ wrapper.element = doc.createElementNS(SVG_NS, nodeName);
+ wrapper.renderer = renderer;
+ /**
+ * A collection of attribute setters. These methods, if defined, are called right before a certain
+ * attribute is set on an element wrapper. Returning false prevents the default attribute
+ * setter to run. Returning a value causes the default setter to set that value. Used in
+ * Renderer.label.
+ */
+ wrapper.attrSetters = {};
+ },
+ /**
+ * Animate a given attribute
+ * @param {Object} params
+ * @param {Number} options The same options as in jQuery animation
+ * @param {Function} complete Function to perform at the end of animation
+ */
+ animate: function (params, options, complete) {
+ var animOptions = pick(options, globalAnimation, true);
+ stop(this); // stop regardless of animation actually running, or reverting to .attr (#607)
+ if (animOptions) {
+ animOptions = merge(animOptions);
+ if (complete) { // allows using a callback with the global animation without overwriting it
+ animOptions.complete = complete;
+ }
+ animate(this, params, animOptions);
+ } else {
+ this.attr(params);
+ if (complete) {
+ complete();
+ }
+ }
+ },
+ /**
+ * Set or get a given attribute
+ * @param {Object|String} hash
+ * @param {Mixed|Undefined} val
+ */
+ attr: function (hash, val) {
+ var wrapper = this,
+ key,
+ value,
+ result,
+ i,
+ child,
+ element = wrapper.element,
+ nodeName = element.nodeName,
+ renderer = wrapper.renderer,
+ skipAttr,
+ attrSetters = wrapper.attrSetters,
+ shadows = wrapper.shadows,
+ htmlNode = wrapper.htmlNode,
+ hasSetSymbolSize,
+ ret = wrapper;
+
+ // single key-value pair
+ if (isString(hash) && defined(val)) {
+ key = hash;
+ hash = {};
+ hash[key] = val;
+ }
+
+ // used as a getter: first argument is a string, second is undefined
+ if (isString(hash)) {
+ key = hash;
+ if (nodeName === 'circle') {
+ key = { x: 'cx', y: 'cy' }[key] || key;
+ } else if (key === 'strokeWidth') {
+ key = 'stroke-width';
+ }
+ ret = attr(element, key) || wrapper[key] || 0;
+
+ if (key !== 'd' && key !== 'visibility') { // 'd' is string in animation step
+ ret = parseFloat(ret);
+ }
+
+ // setter
+ } else {
+
+ for (key in hash) {
+ skipAttr = false; // reset
+ value = hash[key];
+
+ // check for a specific attribute setter
+ result = attrSetters[key] && attrSetters[key](value, key);
+
+ if (result !== false) {
+
+ if (result !== UNDEFINED) {
+ value = result; // the attribute setter has returned a new value to set
+ }
+
+ // paths
+ if (key === 'd') {
+ if (value && value.join) { // join path
+ value = value.join(' ');
+ }
+ if (/(NaN| {2}|^$)/.test(value)) {
+ value = 'M 0 0';
+ }
+ wrapper.d = value; // shortcut for animations
+
+ // update child tspans x values
+ } else if (key === 'x' && nodeName === 'text') {
+ for (i = 0; i < element.childNodes.length; i++) {
+ child = element.childNodes[i];
+ // if the x values are equal, the tspan represents a linebreak
+ if (attr(child, 'x') === attr(element, 'x')) {
+ //child.setAttribute('x', value);
+ attr(child, 'x', value);
+ }
+ }
+
+ if (wrapper.rotation) {
+ attr(element, 'transform', 'rotate(' + wrapper.rotation + ' ' + value + ' ' +
+ pInt(hash.y || attr(element, 'y')) + ')');
+ }
+
+ // apply gradients
+ } else if (key === 'fill') {
+ value = renderer.color(value, element, key);
+
+ // circle x and y
+ } else if (nodeName === 'circle' && (key === 'x' || key === 'y')) {
+ key = { x: 'cx', y: 'cy' }[key] || key;
+
+ // rectangle border radius
+ } else if (nodeName === 'rect' && key === 'r') {
+ attr(element, {
+ rx: value,
+ ry: value
+ });
+ skipAttr = true;
+
+ // translation and text rotation
+ } else if (key === 'translateX' || key === 'translateY' || key === 'rotation' || key === 'verticalAlign') {
+ wrapper[key] = value;
+ wrapper.updateTransform();
+ skipAttr = true;
+
+ // apply opacity as subnode (required by legacy WebKit and Batik)
+ } else if (key === 'stroke') {
+ value = renderer.color(value, element, key);
+
+ // emulate VML's dashstyle implementation
+ } else if (key === 'dashstyle') {
+ key = 'stroke-dasharray';
+ value = value && value.toLowerCase();
+ if (value === 'solid') {
+ value = NONE;
+ } else if (value) {
+ value = value
+ .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(','); // ending comma
+
+ i = value.length;
+ while (i--) {
+ value[i] = pInt(value[i]) * hash['stroke-width'];
+ }
+ value = value.join(',');
+ }
+
+ // special
+ } else if (key === 'isTracker') {
+ wrapper[key] = value;
+
+ // IE9/MooTools combo: MooTools returns objects instead of numbers and IE9 Beta 2
+ // is unable to cast them. Test again with final IE9.
+ } else if (key === 'width') {
+ value = pInt(value);
+
+ // Text alignment
+ } else if (key === 'align') {
+ key = 'text-anchor';
+ value = { left: 'start', center: 'middle', right: 'end' }[value];
+
+ // Title requires a subnode, #431
+ } else if (key === 'title') {
+ var title = doc.createElementNS(SVG_NS, 'title');
+ title.appendChild(doc.createTextNode(value));
+ element.appendChild(title);
+ }
+
+ // jQuery animate changes case
+ if (key === 'strokeWidth') {
+ key = 'stroke-width';
+ }
+
+ // Chrome/Win < 6 bug (http://code.google.com/p/chromium/issues/detail?id=15461)
+ if (isWebKit && key === 'stroke-width' && value === 0) {
+ value = 0.000001;
+ }
+
+ // symbols
+ if (wrapper.symbolName && /^(x|y|r|start|end|innerR|anchorX|anchorY)/.test(key)) {
+
+
+ if (!hasSetSymbolSize) {
+ wrapper.symbolAttr(hash);
+ hasSetSymbolSize = true;
+ }
+ skipAttr = true;
+ }
+
+ // let the shadow follow the main element
+ if (shadows && /^(width|height|visibility|x|y|d|transform)$/.test(key)) {
+ i = shadows.length;
+ while (i--) {
+ attr(shadows[i], key, value);
+ }
+ }
+
+ // validate heights
+ if ((key === 'width' || key === 'height') && nodeName === 'rect' && value < 0) {
+ value = 0;
+ }
+
+
+
+
+ if (key === 'text') {
+ // only one node allowed
+ wrapper.textStr = value;
+ if (wrapper.added) {
+ renderer.buildText(wrapper);
+ }
+ } else if (!skipAttr) {
+ attr(element, key, value);
+ }
+
+ }
+
+ // Issue #38
+ if (htmlNode && (key === 'x' || key === 'y' ||
+ key === 'translateX' || key === 'translateY' || key === 'visibility')) {
+ var bBox,
+ arr = htmlNode.length ? htmlNode : [this],
+ length = arr.length,
+ itemWrapper,
+ j;
+
+ for (j = 0; j < length; j++) {
+ itemWrapper = arr[j];
+ bBox = itemWrapper.getBBox();
+ htmlNode = itemWrapper.htmlNode; // reassign to child item
+ css(htmlNode, extend(wrapper.styles, {
+ left: (bBox.x + (wrapper.translateX || 0)) + PX,
+ top: (bBox.y + (wrapper.translateY || 0)) + PX
+ }));
+
+ if (key === 'visibility') {
+ css(htmlNode, {
+ visibility: value
+ });
+ }
+ }
+ }
+
+ }
+
+ }
+
+ // Workaround for our #732, WebKit's issue https://bugs.webkit.org/show_bug.cgi?id=78385
+ // TODO: If the WebKit team fix this bug before the final release of Chrome 18, remove the workaround.
+ if (isWebKit && /Chrome\/(18|19)/.test(userAgent)) {
+ if (nodeName === 'text' && (hash.x !== UNDEFINED || hash.y !== UNDEFINED)) {
+ var parent = element.parentNode,
+ next = element.nextSibling;
+
+ if (parent) {
+ parent.removeChild(element);
+ if (next) {
+ parent.insertBefore(element, next);
+ } else {
+ parent.appendChild(element);
+ }
+ }
+ }
+ }
+ // End of workaround for #732
+
+ return ret;
+ },
+
+ /**
+ * If one of the symbol size affecting parameters are changed,
+ * check all the others only once for each call to an element's
+ * .attr() method
+ * @param {Object} hash
+ */
+ symbolAttr: function (hash) {
+ var wrapper = this;
+
+ each(['x', 'y', 'r', 'start', 'end', 'width', 'height', 'innerR', 'anchorX', 'anchorY'], function (key) {
+ wrapper[key] = pick(hash[key], wrapper[key]);
+ });
+
+ wrapper.attr({
+ d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
+ });
+ },
+
+ /**
+ * Apply a clipping path to this object
+ * @param {String} id
+ */
+ clip: function (clipRect) {
+ return this.attr('clip-path', 'url(' + this.renderer.url + '#' + clipRect.id + ')');
+ },
+
+ /**
+ * Calculate the coordinates needed for drawing a rectangle crisply and return the
+ * calculated attributes
+ * @param {Number} strokeWidth
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} width
+ * @param {Number} height
+ */
+ crisp: function (strokeWidth, x, y, width, height) {
+
+ var wrapper = this,
+ key,
+ attribs = {},
+ values = {},
+ normalizer;
+
+ strokeWidth = strokeWidth || wrapper.strokeWidth || (wrapper.attr && wrapper.attr('stroke-width')) || 0;
+ normalizer = mathRound(strokeWidth) % 2 / 2; // mathRound because strokeWidth can sometimes have roundoff errors
+
+ // normalize for crisp edges
+ values.x = mathFloor(x || wrapper.x || 0) + normalizer;
+ values.y = mathFloor(y || wrapper.y || 0) + normalizer;
+ values.width = mathFloor((width || wrapper.width || 0) - 2 * normalizer);
+ values.height = mathFloor((height || wrapper.height || 0) - 2 * normalizer);
+ values.strokeWidth = strokeWidth;
+
+ for (key in values) {
+ if (wrapper[key] !== values[key]) { // only set attribute if changed
+ wrapper[key] = attribs[key] = values[key];
+ }
+ }
+
+ return attribs;
+ },
+
+ /**
+ * Set styles for the element
+ * @param {Object} styles
+ */
+ css: function (styles) {
+ /*jslint unparam: true*//* allow unused param a in the regexp function below */
+ var elemWrapper = this,
+ elem = elemWrapper.element,
+ textWidth = styles && styles.width && elem.nodeName === 'text',
+ n,
+ serializedCss = '',
+ hyphenate = function (a, b) { return '-' + b.toLowerCase(); };
+ /*jslint unparam: false*/
+
+ // convert legacy
+ if (styles && styles.color) {
+ styles.fill = styles.color;
+ }
+
+ // Merge the new styles with the old ones
+ styles = extend(
+ elemWrapper.styles,
+ styles
+ );
+
+ // store object
+ elemWrapper.styles = styles;
+
+ // serialize and set style attribute
+ if (isIE && !hasSVG) { // legacy IE doesn't support setting style attribute
+ if (textWidth) {
+ delete styles.width;
+ }
+ css(elemWrapper.element, styles);
+ } else {
+ for (n in styles) {
+ serializedCss += n.replace(/([A-Z])/g, hyphenate) + ':' + styles[n] + ';';
+ }
+ elemWrapper.attr({
+ style: serializedCss
+ });
+ }
+
+
+ // re-build text
+ if (textWidth && elemWrapper.added) {
+ elemWrapper.renderer.buildText(elemWrapper);
+ }
+
+ return elemWrapper;
+ },
+
+ /**
+ * Add an event listener
+ * @param {String} eventType
+ * @param {Function} handler
+ */
+ on: function (eventType, handler) {
+ var fn = handler;
+ // touch
+ if (hasTouch && eventType === 'click') {
+ eventType = 'touchstart';
+ fn = function (e) {
+ e.preventDefault();
+ handler();
+ };
+ }
+ // simplest possible event model for internal use
+ this.element['on' + eventType] = fn;
+ return this;
+ },
+
+
+ /**
+ * Move an object and its children by x and y values
+ * @param {Number} x
+ * @param {Number} y
+ */
+ translate: function (x, y) {
+ return this.attr({
+ translateX: x,
+ translateY: y
+ });
+ },
+
+ /**
+ * Invert a group, rotate and flip
+ */
+ invert: function () {
+ var wrapper = this;
+ wrapper.inverted = true;
+ wrapper.updateTransform();
+ return wrapper;
+ },
+
+ /**
+ * Private method to update the transform attribute based on internal
+ * properties
+ */
+ updateTransform: function () {
+ var wrapper = this,
+ translateX = wrapper.translateX || 0,
+ translateY = wrapper.translateY || 0,
+ inverted = wrapper.inverted,
+ rotation = wrapper.rotation,
+ transform = [];
+
+ // flipping affects translate as adjustment for flipping around the group's axis
+ if (inverted) {
+ translateX += wrapper.attr('width');
+ translateY += wrapper.attr('height');
+ }
+
+ // apply translate
+ if (translateX || translateY) {
+ transform.push('translate(' + translateX + ',' + translateY + ')');
+ }
+
+ // apply rotation
+ if (inverted) {
+ transform.push('rotate(90) scale(-1,1)');
+ } else if (rotation) { // text rotation
+ transform.push('rotate(' + rotation + ' ' + wrapper.x + ' ' + wrapper.y + ')');
+ }
+
+ if (transform.length) {
+ attr(wrapper.element, 'transform', transform.join(' '));
+ }
+ },
+ /**
+ * Bring the element to the front
+ */
+ toFront: function () {
+ var element = this.element;
+ element.parentNode.appendChild(element);
+ return this;
+ },
+
+
+ /**
+ * Break down alignment options like align, verticalAlign, x and y
+ * to x and y relative to the chart.
+ *
+ * @param {Object} alignOptions
+ * @param {Boolean} alignByTranslate
+ * @param {Object} box The box to align to, needs a width and height
+ *
+ */
+ align: function (alignOptions, alignByTranslate, box) {
+ var elemWrapper = this;
+
+ if (!alignOptions) { // called on resize
+ alignOptions = elemWrapper.alignOptions;
+ alignByTranslate = elemWrapper.alignByTranslate;
+ } else { // first call on instanciate
+ elemWrapper.alignOptions = alignOptions;
+ elemWrapper.alignByTranslate = alignByTranslate;
+ if (!box) { // boxes other than renderer handle this internally
+ elemWrapper.renderer.alignedObjects.push(elemWrapper);
+ }
+ }
+
+ box = pick(box, elemWrapper.renderer);
+
+ var align = alignOptions.align,
+ vAlign = alignOptions.verticalAlign,
+ x = (box.x || 0) + (alignOptions.x || 0), // default: left align
+ y = (box.y || 0) + (alignOptions.y || 0), // default: top align
+ attribs = {};
+
+
+ // align
+ if (/^(right|center)$/.test(align)) {
+ x += (box.width - (alignOptions.width || 0)) /
+ { right: 1, center: 2 }[align];
+ }
+ attribs[alignByTranslate ? 'translateX' : 'x'] = mathRound(x);
+
+
+ // vertical align
+ if (/^(bottom|middle)$/.test(vAlign)) {
+ y += (box.height - (alignOptions.height || 0)) /
+ ({ bottom: 1, middle: 2 }[vAlign] || 1);
+
+ }
+ attribs[alignByTranslate ? 'translateY' : 'y'] = mathRound(y);
+
+ // animate only if already placed
+ elemWrapper[elemWrapper.placed ? 'animate' : 'attr'](attribs);
+ elemWrapper.placed = true;
+ elemWrapper.alignAttr = attribs;
+
+ return elemWrapper;
+ },
+
+ /**
+ * Get the bounding box (width, height, x and y) for the element
+ */
+ getBBox: function () {
+ var bBox,
+ width,
+ height,
+ rotation = this.rotation,
+ rad = rotation * deg2rad;
+
+ try { // fails in Firefox if the container has display: none
+ // use extend because IE9 is not allowed to change width and height in case
+ // of rotation (below)
+ bBox = extend({}, this.element.getBBox());
+ } catch (e) {
+ bBox = { width: 0, height: 0 };
+ }
+ width = bBox.width;
+ height = bBox.height;
+
+ // adjust for rotated text
+ if (rotation) {
+ bBox.width = mathAbs(height * mathSin(rad)) + mathAbs(width * mathCos(rad));
+ bBox.height = mathAbs(height * mathCos(rad)) + mathAbs(width * mathSin(rad));
+ }
+
+ return bBox;
+ },
+
+ /**
+ * Show the element
+ */
+ show: function () {
+ return this.attr({ visibility: VISIBLE });
+ },
+
+ /**
+ * Hide the element
+ */
+ hide: function () {
+ return this.attr({ visibility: HIDDEN });
+ },
+
+ /**
+ * Add the element
+ * @param {Object|Undefined} parent Can be an element, an element wrapper or undefined
+ * to append the element to the renderer.box.
+ */
+ add: function (parent) {
+
+ var renderer = this.renderer,
+ parentWrapper = parent || renderer,
+ parentNode = parentWrapper.element || renderer.box,
+ childNodes = parentNode.childNodes,
+ element = this.element,
+ zIndex = attr(element, 'zIndex'),
+ otherElement,
+ otherZIndex,
+ i,
+ inserted;
+
+ // mark as inverted
+ this.parentInverted = parent && parent.inverted;
+
+ // build formatted text
+ if (this.textStr !== undefined) {
+ renderer.buildText(this);
+ }
+
+ // register html spans in groups
+ if (parent && this.htmlNode) {
+ if (!parent.htmlNode) {
+ parent.htmlNode = [];
+ }
+ parent.htmlNode.push(this);
+ }
+
+ // mark the container as having z indexed children
+ if (zIndex) {
+ parentWrapper.handleZ = true;
+ zIndex = pInt(zIndex);
+ }
+
+ // insert according to this and other elements' zIndex
+ if (parentWrapper.handleZ) { // this element or any of its siblings has a z index
+ for (i = 0; i < childNodes.length; i++) {
+ otherElement = childNodes[i];
+ otherZIndex = attr(otherElement, 'zIndex');
+ if (otherElement !== element && (
+ // insert before the first element with a higher zIndex
+ pInt(otherZIndex) > zIndex ||
+ // if no zIndex given, insert before the first element with a zIndex
+ (!defined(zIndex) && defined(otherZIndex))
+
+ )) {
+ parentNode.insertBefore(element, otherElement);
+ inserted = true;
+ break;
+ }
+ }
+ }
+
+ // default: append at the end
+ if (!inserted) {
+ parentNode.appendChild(element);
+ }
+
+ // mark as added
+ this.added = true;
+
+ // fire an event for internal hooks
+ fireEvent(this, 'add');
+
+ return this;
+ },
+
+ /**
+ * Removes a child either by removeChild or move to garbageBin.
+ * Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not.
+ */
+ safeRemoveChild: function (element) {
+ var parentNode = element.parentNode;
+ if (parentNode) {
+ parentNode.removeChild(element);
+ }
+ },
+
+ /**
+ * Destroy the element and element wrapper
+ */
+ destroy: function () {
+ var wrapper = this,
+ element = wrapper.element || {},
+ shadows = wrapper.shadows,
+ box = wrapper.box,
+ key,
+ i;
+
+ // remove events
+ element.onclick = element.onmouseout = element.onmouseover = element.onmousemove = null;
+ stop(wrapper); // stop running animations
+
+ if (wrapper.clipPath) {
+ wrapper.clipPath = wrapper.clipPath.destroy();
+ }
+
+ // Destroy stops in case this is a gradient object
+ if (wrapper.stops) {
+ for (i = 0; i < wrapper.stops.length; i++) {
+ wrapper.stops[i] = wrapper.stops[i].destroy();
+ }
+ wrapper.stops = null;
+ }
+
+ // remove element
+ wrapper.safeRemoveChild(element);
+
+ // destroy shadows
+ if (shadows) {
+ each(shadows, function (shadow) {
+ wrapper.safeRemoveChild(shadow);
+ });
+ }
+
+ // destroy label box
+ if (box) {
+ box.destroy();
+ }
+
+ // remove from alignObjects
+ erase(wrapper.renderer.alignedObjects, wrapper);
+
+ for (key in wrapper) {
+ delete wrapper[key];
+ }
+
+ return null;
+ },
+
+ /**
+ * Empty a group element
+ */
+ empty: function () {
+ var element = this.element,
+ childNodes = element.childNodes,
+ i = childNodes.length;
+
+ while (i--) {
+ element.removeChild(childNodes[i]);
+ }
+ },
+
+ /**
+ * Add a shadow to the element. Must be done after the element is added to the DOM
+ * @param {Boolean} apply
+ */
+ shadow: function (apply, group) {
+ var shadows = [],
+ i,
+ shadow,
+ element = this.element,
+
+ // compensate for inverted plot area
+ transform = this.parentInverted ? '(-1,-1)' : '(1,1)';
+
+
+ if (apply) {
+ for (i = 1; i <= 3; i++) {
+ shadow = element.cloneNode(0);
+ attr(shadow, {
+ 'isShadow': 'true',
+ 'stroke': 'rgb(0, 0, 0)',
+ 'stroke-opacity': 0.05 * i,
+ 'stroke-width': 7 - 2 * i,
+ 'transform': 'translate' + transform,
+ 'fill': NONE
+ });
+
+ if (group) {
+ group.element.appendChild(shadow);
+ } else {
+ element.parentNode.insertBefore(shadow, element);
+ }
+
+ shadows.push(shadow);
+ }
+
+ this.shadows = shadows;
+ }
+ return this;
+
+ }
+};
+
+
+/**
+ * The default SVG renderer
+ */
+var SVGRenderer = function () {
+ this.init.apply(this, arguments);
+};
+SVGRenderer.prototype = {
+
+ Element: SVGElement,
+
+ /**
+ * Initialize the SVGRenderer
+ * @param {Object} container
+ * @param {Number} width
+ * @param {Number} height
+ * @param {Boolean} forExport
+ */
+ init: function (container, width, height, forExport) {
+ var renderer = this,
+ loc = location,
+ boxWrapper;
+
+ boxWrapper = renderer.createElement('svg')
+ .attr({
+ xmlns: SVG_NS,
+ version: '1.1'
+ });
+ container.appendChild(boxWrapper.element);
+
+ // object properties
+ renderer.box = boxWrapper.element;
+ renderer.boxWrapper = boxWrapper;
+ renderer.alignedObjects = [];
+ renderer.url = isIE ? '' : loc.href.replace(/#.*?$/, '')
+ .replace(/\(/g, '\\(').replace(/\)/g, '\\)'); // Page url used for internal references. #24, #672.
+ renderer.defs = this.createElement('defs').add();
+ renderer.forExport = forExport;
+ renderer.gradients = {}; // Object where gradient SvgElements are stored
+
+ renderer.setSize(width, height, false);
+ },
+
+ /**
+ * Destroys the renderer and its allocated members.
+ */
+ destroy: function () {
+ var renderer = this,
+ rendererDefs = renderer.defs;
+ renderer.box = null;
+ renderer.boxWrapper = renderer.boxWrapper.destroy();
+
+ // Call destroy on all gradient elements
+ destroyObjectProperties(renderer.gradients || {});
+ renderer.gradients = null;
+
+ // Defs are null in VMLRenderer
+ // Otherwise, destroy them here.
+ if (rendererDefs) {
+ renderer.defs = rendererDefs.destroy();
+ }
+
+ renderer.alignedObjects = null;
+
+ return null;
+ },
+
+ /**
+ * Create a wrapper for an SVG element
+ * @param {Object} nodeName
+ */
+ createElement: function (nodeName) {
+ var wrapper = new this.Element();
+ wrapper.init(this, nodeName);
+ return wrapper;
+ },
+
+
+ /**
+ * Parse a simple HTML string into SVG tspans
+ *
+ * @param {Object} textNode The parent text SVG node
+ */
+ buildText: function (wrapper) {
+ var textNode = wrapper.element,
+ lines = pick(wrapper.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),
+ childNodes = textNode.childNodes,
+ styleRegex = /style="([^"]+)"/,
+ hrefRegex = /href="([^"]+)"/,
+ parentX = attr(textNode, 'x'),
+ textStyles = wrapper.styles,
+ renderAsHtml = textStyles && wrapper.useHTML && !this.forExport,
+ htmlNode = wrapper.htmlNode,
+ //arr, issue #38 workaround
+ width = textStyles && pInt(textStyles.width),
+ textLineHeight = textStyles && textStyles.lineHeight,
+ lastLine,
+ GET_COMPUTED_STYLE = 'getComputedStyle',
+ i = childNodes.length;
+
+ // remove old text
+ while (i--) {
+ textNode.removeChild(childNodes[i]);
+ }
+
+ if (width && !wrapper.added) {
+ this.box.appendChild(textNode); // attach it to the DOM to read offset width
+ }
+
+ // remove empty line at end
+ if (lines[lines.length - 1] === '') {
+ lines.pop();
+ }
+
+ // build the lines
+ each(lines, function (line, lineNo) {
+ var spans, spanNo = 0, lineHeight;
+
+ line = line.replace(/<span/g, '|||<span').replace(/<\/span>/g, '</span>|||');
+ spans = line.split('|||');
+
+ each(spans, function (span) {
+ if (span !== '' || spans.length === 1) {
+ var attributes = {},
+ tspan = doc.createElementNS(SVG_NS, 'tspan');
+ if (styleRegex.test(span)) {
+ attr(
+ tspan,
+ 'style',
+ span.match(styleRegex)[1].replace(/(;| |^)color([ :])/, '$1fill$2')
+ );
+ }
+ if (hrefRegex.test(span)) {
+ attr(tspan, 'onclick', 'location.href=\"' + span.match(hrefRegex)[1] + '\"');
+ css(tspan, { cursor: 'pointer' });
+ }
+
+ span = (span.replace(/<(.|\n)*?>/g, '') || ' ')
+ .replace(/</g, '<')
+ .replace(/>/g, '>');
+
+ // issue #38 workaround.
+ /*if (reverse) {
+ arr = [];
+ i = span.length;
+ while (i--) {
+ arr.push(span.charAt(i));
+ }
+ span = arr.join('');
+ }*/
+
+ // add the text node
+ tspan.appendChild(doc.createTextNode(span));
+
+ if (!spanNo) { // first span in a line, align it to the left
+ attributes.x = parentX;
+ } else {
+ // Firefox ignores spaces at the front or end of the tspan
+ attributes.dx = 3; // space
+ }
+
+ // first span on subsequent line, add the line height
+ if (!spanNo) {
+ if (lineNo) {
+
+ // allow getting the right offset height in exporting in IE
+ if (!hasSVG && wrapper.renderer.forExport) {
+ css(tspan, { display: 'block' });
+ }
+
+ // Webkit and opera sometimes return 'normal' as the line height. In that
+ // case, webkit uses offsetHeight, while Opera falls back to 18
+ lineHeight = win[GET_COMPUTED_STYLE] &&
+ pInt(win[GET_COMPUTED_STYLE](lastLine, null).getPropertyValue('line-height'));
+
+ if (!lineHeight || isNaN(lineHeight)) {
+ lineHeight = textLineHeight || lastLine.offsetHeight || 18;
+ }
+ attr(tspan, 'dy', lineHeight);
+ }
+ lastLine = tspan; // record for use in next line
+ }
+
+ // add attributes
+ attr(tspan, attributes);
+
+ // append it
+ textNode.appendChild(tspan);
+
+ spanNo++;
+
+ // check width and apply soft breaks
+ if (width) {
+ var words = span.replace(/-/g, '- ').split(' '),
+ tooLong,
+ actualWidth,
+ rest = [];
+
+ while (words.length || rest.length) {
+ actualWidth = wrapper.getBBox().width;
+ tooLong = actualWidth > width;
+ if (!tooLong || words.length === 1) { // new line needed
+ words = rest;
+ rest = [];
+ if (words.length) {
+ tspan = doc.createElementNS(SVG_NS, 'tspan');
+ attr(tspan, {
+ dy: textLineHeight || 16,
+ x: parentX
+ });
+ textNode.appendChild(tspan);
+
+ if (actualWidth > width) { // a single word is pressing it out
+ width = actualWidth;
+ }
+ }
+ } else { // append to existing line tspan
+ tspan.removeChild(tspan.firstChild);
+ rest.unshift(words.pop());
+ }
+ if (words.length) {
+ tspan.appendChild(doc.createTextNode(words.join(' ').replace(/- /g, '-')));
+ }
+ }
+ }
+ }
+ });
+ });
+
+ // Fix issue #38 and allow HTML in tooltips and other labels
+ if (renderAsHtml) {
+ if (!htmlNode) {
+ htmlNode = wrapper.htmlNode = createElement('span', null, extend(textStyles, {
+ position: ABSOLUTE,
+ top: 0,
+ left: 0
+ }), this.box.parentNode);
+ }
+ htmlNode.innerHTML = wrapper.textStr;
+
+ i = childNodes.length;
+ while (i--) {
+ childNodes[i].style.visibility = HIDDEN;
+ }
+ }
+ },
+
+ /**
+ * Create a button with preset states
+ * @param {String} text
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Function} callback
+ * @param {Object} normalState
+ * @param {Object} hoverState
+ * @param {Object} pressedState
+ */
+ button: function (text, x, y, callback, normalState, hoverState, pressedState) {
+ var label = this.label(text, x, y),
+ curState = 0,
+ stateOptions,
+ stateStyle,
+ normalStyle,
+ hoverStyle,
+ pressedStyle,
+ STYLE = 'style',
+ verticalGradient = { x1: 0, y1: 0, x2: 0, y2: 1 };
+
+ // prepare the attributes
+ /*jslint white: true*/
+ normalState = merge(hash(
+ STROKE_WIDTH, 1,
+ STROKE, '#999',
+ FILL, hash(
+ LINEAR_GRADIENT, verticalGradient,
+ STOPS, [
+ [0, '#FFF'],
+ [1, '#DDD']
+ ]
+ ),
+ 'r', 3,
+ 'padding', 3,
+ STYLE, hash(
+ 'color', 'black'
+ )
+ ), normalState);
+ /*jslint white: false*/
+ normalStyle = normalState[STYLE];
+ delete normalState[STYLE];
+
+ /*jslint white: true*/
+ hoverState = merge(normalState, hash(
+ STROKE, '#68A',
+ FILL, hash(
+ LINEAR_GRADIENT, verticalGradient,
+ STOPS, [
+ [0, '#FFF'],
+ [1, '#ACF']
+ ]
+ )
+ ), hoverState);
+ /*jslint white: false*/
+ hoverStyle = hoverState[STYLE];
+ delete hoverState[STYLE];
+
+ /*jslint white: true*/
+ pressedState = merge(normalState, hash(
+ STROKE, '#68A',
+ FILL, hash(
+ LINEAR_GRADIENT, verticalGradient,
+ STOPS, [
+ [0, '#9BD'],
+ [1, '#CDF']
+ ]
+ )
+ ), pressedState);
+ /*jslint white: false*/
+ pressedStyle = pressedState[STYLE];
+ delete pressedState[STYLE];
+
+ // add the events
+ addEvent(label.element, 'mouseenter', function () {
+ label.attr(hoverState)
+ .css(hoverStyle);
+ });
+ addEvent(label.element, 'mouseleave', function () {
+ stateOptions = [normalState, hoverState, pressedState][curState];
+ stateStyle = [normalStyle, hoverStyle, pressedStyle][curState];
+ label.attr(stateOptions)
+ .css(stateStyle);
+ });
+
+ label.setState = function (state) {
+ curState = state;
+ if (!state) {
+ label.attr(normalState)
+ .css(normalStyle);
+ } else if (state === 2) {
+ label.attr(pressedState)
+ .css(pressedStyle);
+ }
+ };
+
+ return label
+ .on('click', function () {
+ callback.call(label);
+ })
+ .attr(normalState)
+ .css(extend({ cursor: 'default' }, normalStyle));
+ },
+
+ /**
+ * Make a straight line crisper by not spilling out to neighbour pixels
+ * @param {Array} points
+ * @param {Number} width
+ */
+ crispLine: function (points, width) {
+ // points format: [M, 0, 0, L, 100, 0]
+ // normalize to a crisp line
+ if (points[1] === points[4]) {
+ points[1] = points[4] = mathRound(points[1]) + (width % 2 / 2);
+ }
+ if (points[2] === points[5]) {
+ points[2] = points[5] = mathRound(points[2]) + (width % 2 / 2);
+ }
+ return points;
+ },
+
+
+ /**
+ * Draw a path
+ * @param {Array} path An SVG path in array form
+ */
+ path: function (path) {
+ return this.createElement('path').attr({
+ d: path,
+ fill: NONE
+ });
+ },
+
+ /**
+ * Draw and return an SVG circle
+ * @param {Number} x The x position
+ * @param {Number} y The y position
+ * @param {Number} r The radius
+ */
+ circle: function (x, y, r) {
+ var attr = isObject(x) ?
+ x :
+ {
+ x: x,
+ y: y,
+ r: r
+ };
+
+ return this.createElement('circle').attr(attr);
+ },
+
+ /**
+ * Draw and return an arc
+ * @param {Number} x X position
+ * @param {Number} y Y position
+ * @param {Number} r Radius
+ * @param {Number} innerR Inner radius like used in donut charts
+ * @param {Number} start Starting angle
+ * @param {Number} end Ending angle
+ */
+ arc: function (x, y, r, innerR, start, end) {
+ // arcs are defined as symbols for the ability to set
+ // attributes in attr and animate
+
+ if (isObject(x)) {
+ y = x.y;
+ r = x.r;
+ innerR = x.innerR;
+ start = x.start;
+ end = x.end;
+ x = x.x;
+ }
+ return this.symbol('arc', x || 0, y || 0, r || 0, r || 0, {
+ innerR: innerR || 0,
+ start: start || 0,
+ end: end || 0
+ });
+ },
+
+ /**
+ * Draw and return a rectangle
+ * @param {Number} x Left position
+ * @param {Number} y Top position
+ * @param {Number} width
+ * @param {Number} height
+ * @param {Number} r Border corner radius
+ * @param {Number} strokeWidth A stroke width can be supplied to allow crisp drawing
+ */
+ rect: function (x, y, width, height, r, strokeWidth) {
+ if (isObject(x)) {
+ y = x.y;
+ width = x.width;
+ height = x.height;
+ r = x.r;
+ strokeWidth = x.strokeWidth;
+ x = x.x;
+ }
+ var wrapper = this.createElement('rect').attr({
+ rx: r,
+ ry: r,
+ fill: NONE
+ });
+
+ return wrapper.attr(wrapper.crisp(strokeWidth, x, y, mathMax(width, 0), mathMax(height, 0)));
+ },
+
+ /**
+ * Resize the box and re-align all aligned elements
+ * @param {Object} width
+ * @param {Object} height
+ * @param {Boolean} animate
+ *
+ */
+ setSize: function (width, height, animate) {
+ var renderer = this,
+ alignedObjects = renderer.alignedObjects,
+ i = alignedObjects.length;
+
+ renderer.width = width;
+ renderer.height = height;
+
+ renderer.boxWrapper[pick(animate, true) ? 'animate' : 'attr']({
+ width: width,
+ height: height
+ });
+
+ while (i--) {
+ alignedObjects[i].align();
+ }
+ },
+
+ /**
+ * Create a group
+ * @param {String} name The group will be given a class name of 'highcharts-{name}'.
+ * This can be used for styling and scripting.
+ */
+ g: function (name) {
+ var elem = this.createElement('g');
+ return defined(name) ? elem.attr({ 'class': PREFIX + name }) : elem;
+ },
+
+ /**
+ * Display an image
+ * @param {String} src
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} width
+ * @param {Number} height
+ */
+ image: function (src, x, y, width, height) {
+ var attribs = {
+ preserveAspectRatio: NONE
+ },
+ elemWrapper;
+
+ // optional properties
+ if (arguments.length > 1) {
+ extend(attribs, {
+ x: x,
+ y: y,
+ width: width,
+ height: height
+ });
+ }
+
+ elemWrapper = this.createElement('image').attr(attribs);
+
+ // set the href in the xlink namespace
+ if (elemWrapper.element.setAttributeNS) {
+ elemWrapper.element.setAttributeNS('http://www.w3.org/1999/xlink',
+ 'href', src);
+ } else {
+ // could be exporting in IE
+ // using href throws "not supported" in ie7 and under, requries regex shim to fix later
+ elemWrapper.element.setAttribute('hc-svg-href', src);
+ }
+
+ return elemWrapper;
+ },
+
+ /**
+ * Draw a symbol out of pre-defined shape paths from the namespace 'symbol' object.
+ *
+ * @param {Object} symbol
+ * @param {Object} x
+ * @param {Object} y
+ * @param {Object} radius
+ * @param {Object} options
+ */
+ symbol: function (symbol, x, y, width, height, options) {
+
+ var obj,
+
+ // get the symbol definition function
+ symbolFn = this.symbols[symbol],
+
+ // check if there's a path defined for this symbol
+ path = symbolFn && symbolFn(
+ mathRound(x),
+ mathRound(y),
+ width,
+ height,
+ options
+ ),
+
+ imageRegex = /^url\((.*?)\)$/,
+ imageSrc,
+ imageSize;
+
+ if (path) {
+
+ obj = this.path(path);
+ // expando properties for use in animate and attr
+ extend(obj, {
+ symbolName: symbol,
+ x: x,
+ y: y,
+ width: width,
+ height: height
+ });
+ if (options) {
+ extend(obj, options);
+ }
+
+
+ // image symbols
+ } else if (imageRegex.test(symbol)) {
+
+ var centerImage = function (img, size) {
+ img.attr({
+ width: size[0],
+ height: size[1]
+ }).translate(
+ -mathRound(size[0] / 2),
+ -mathRound(size[1] / 2)
+ );
+ };
+
+ imageSrc = symbol.match(imageRegex)[1];
+ imageSize = symbolSizes[imageSrc];
+
+ // create the image synchronously, add attribs async
+ obj = this.image(imageSrc)
+ .attr({
+ x: x,
+ y: y
+ });
+
+ if (imageSize) {
+ centerImage(obj, imageSize);
+ } else {
+ // initialize image to be 0 size so export will still function if there's no cached sizes
+ obj.attr({ width: 0, height: 0 });
+
+ // create a dummy JavaScript image to get the width and height
+ createElement('img', {
+ onload: function () {
+ var img = this;
+
+ centerImage(obj, symbolSizes[imageSrc] = [img.width, img.height]);
+ },
+ src: imageSrc
+ });
+ }
+ }
+
+ return obj;
+ },
+
+ /**
+ * An extendable collection of functions for defining symbol paths.
+ */
+ symbols: {
+ 'circle': function (x, y, w, h) {
+ var cpw = 0.166 * w;
+ return [
+ M, x + w / 2, y,
+ 'C', x + w + cpw, y, x + w + cpw, y + h, x + w / 2, y + h,
+ 'C', x - cpw, y + h, x - cpw, y, x + w / 2, y,
+ 'Z'
+ ];
+ },
+
+ 'square': function (x, y, w, h) {
+ return [
+ M, x, y,
+ L, x + w, y,
+ x + w, y + h,
+ x, y + h,
+ 'Z'
+ ];
+ },
+
+ 'triangle': function (x, y, w, h) {
+ return [
+ M, x + w / 2, y,
+ L, x + w, y + h,
+ x, y + h,
+ 'Z'
+ ];
+ },
+
+ 'triangle-down': function (x, y, w, h) {
+ return [
+ M, x, y,
+ L, x + w, y,
+ x + w / 2, y + h,
+ 'Z'
+ ];
+ },
+ 'diamond': function (x, y, w, h) {
+ return [
+ M, x + w / 2, y,
+ L, x + w, y + h / 2,
+ x + w / 2, y + h,
+ x, y + h / 2,
+ 'Z'
+ ];
+ },
+ 'arc': function (x, y, w, h, options) {
+ var start = options.start,
+ radius = options.r || w || h,
+ end = options.end - 0.000001, // to prevent cos and sin of start and end from becoming equal on 360 arcs
+ innerRadius = options.innerR,
+ cosStart = mathCos(start),
+ sinStart = mathSin(start),
+ cosEnd = mathCos(end),
+ sinEnd = mathSin(end),
+ longArc = options.end - start < mathPI ? 0 : 1;
+
+ return [
+ M,
+ x + radius * cosStart,
+ y + radius * sinStart,
+ 'A', // arcTo
+ radius, // x radius
+ radius, // y radius
+ 0, // slanting
+ longArc, // long or short arc
+ 1, // clockwise
+ x + radius * cosEnd,
+ y + radius * sinEnd,
+ L,
+ x + innerRadius * cosEnd,
+ y + innerRadius * sinEnd,
+ 'A', // arcTo
+ innerRadius, // x radius
+ innerRadius, // y radius
+ 0, // slanting
+ longArc, // long or short arc
+ 0, // clockwise
+ x + innerRadius * cosStart,
+ y + innerRadius * sinStart,
+
+ 'Z' // close
+ ];
+ }
+ },
+
+ /**
+ * Define a clipping rectangle
+ * @param {String} id
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} width
+ * @param {Number} height
+ */
+ clipRect: function (x, y, width, height) {
+ var wrapper,
+ id = PREFIX + idCounter++,
+
+ clipPath = this.createElement('clipPath').attr({
+ id: id
+ }).add(this.defs);
+
+ wrapper = this.rect(x, y, width, height, 0).add(clipPath);
+ wrapper.id = id;
+ wrapper.clipPath = clipPath;
+
+ return wrapper;
+ },
+
+
+ /**
+ * Take a color and return it if it's a string, make it a gradient if it's a
+ * gradient configuration object. Prior to Highstock, an array was used to define
+ * a linear gradient with pixel positions relative to the SVG. In newer versions
+ * we change the coordinates to apply relative to the shape, using coordinates
+ * 0-1 within the shape. To preserve backwards compatibility, linearGradient
+ * in this definition is an object of x1, y1, x2 and y2.
+ *
+ * @param {Object} color The color or config object
+ */
+ color: function (color, elem, prop) {
+ var colorObject,
+ regexRgba = /^rgba/;
+ if (color && color.linearGradient) {
+ var renderer = this,
+ linearGradient = color[LINEAR_GRADIENT],
+ relativeToShape = !isArray(linearGradient), // keep backwards compatibility
+ id,
+ gradients = renderer.gradients,
+ gradientObject,
+ x1 = linearGradient.x1 || linearGradient[0] || 0,
+ y1 = linearGradient.y1 || linearGradient[1] || 0,
+ x2 = linearGradient.x2 || linearGradient[2] || 0,
+ y2 = linearGradient.y2 || linearGradient[3] || 0,
+ stopColor,
+ stopOpacity,
+ // Create a unique key in order to reuse gradient objects. #671.
+ key = [relativeToShape, x1, y1, x2, y2, color.stops.join(',')].join(',');
+
+ // If the gradient with the same setup is already created, reuse it
+ if (gradients[key]) {
+ id = attr(gradients[key].element, 'id');
+
+ // If not, create a new one and keep the reference.
+ } else {
+ id = PREFIX + idCounter++;
+ gradientObject = renderer.createElement(LINEAR_GRADIENT)
+ .attr(extend({
+ id: id,
+ x1: x1,
+ y1: y1,
+ x2: x2,
+ y2: y2
+ }, relativeToShape ? null : { gradientUnits: 'userSpaceOnUse' }))
+ .add(renderer.defs);
+
+ // The gradient needs to keep a list of stops to be able to destroy them
+ gradientObject.stops = [];
+ each(color.stops, function (stop) {
+ var stopObject;
+ if (regexRgba.test(stop[1])) {
+ colorObject = Color(stop[1]);
+ stopColor = colorObject.get('rgb');
+ stopOpacity = colorObject.get('a');
+ } else {
+ stopColor = stop[1];
+ stopOpacity = 1;
+ }
+ stopObject = renderer.createElement('stop').attr({
+ offset: stop[0],
+ 'stop-color': stopColor,
+ 'stop-opacity': stopOpacity
+ }).add(gradientObject);
+
+ // Add the stop element to the gradient
+ gradientObject.stops.push(stopObject);
+ });
+
+ // Keep a reference to the gradient object so it is possible to reuse it and
+ // destroy it later
+ gradients[key] = gradientObject;
+ }
+
+ return 'url(' + this.url + '#' + id + ')';
+
+ // Webkit and Batik can't show rgba.
+ } else if (regexRgba.test(color)) {
+ colorObject = Color(color);
+ attr(elem, prop + '-opacity', colorObject.get('a'));
+
+ return colorObject.get('rgb');
+
+
+ } else {
+ // Remove the opacity attribute added above. Does not throw if the attribute is not there.
+ elem.removeAttribute(prop + '-opacity');
+
+ return color;
+ }
+
+ },
+
+
+ /**
+ * Add text to the SVG object
+ * @param {String} str
+ * @param {Number} x Left position
+ * @param {Number} y Top position
+ * @param {Boolean} useHTML Use HTML to render the text
+ */
+ text: function (str, x, y, useHTML) {
+
+ // declare variables
+ var renderer = this,
+ defaultChartStyle = defaultOptions.chart.style,
+ wrapper;
+
+ x = mathRound(pick(x, 0));
+ y = mathRound(pick(y, 0));
+
+ wrapper = renderer.createElement('text')
+ .attr({
+ x: x,
+ y: y,
+ text: str
+ })
+ .css({
+ fontFamily: defaultChartStyle.fontFamily,
+ fontSize: defaultChartStyle.fontSize
+ });
+
+ wrapper.x = x;
+ wrapper.y = y;
+ wrapper.useHTML = useHTML;
+ return wrapper;
+ },
+
+ /**
+ * Add a label, a text item that can hold a colored or gradient background
+ * as well as a border and shadow.
+ * @param {string} str
+ * @param {Number} x
+ * @param {Number} y
+ * @param {String} shape
+ * @param {Number} anchorX In case the shape has a pointer, like a flag, this is the
+ * coordinates it should be pinned to
+ * @param {Number} anchorY
+ */
+ label: function (str, x, y, shape, anchorX, anchorY) {
+
+ var renderer = this,
+ wrapper = renderer.g(),
+ text = renderer.text()
+ .attr({
+ zIndex: 1
+ })
+ .add(wrapper),
+ box,
+ bBox,
+ align = 'left',
+ padding = 3,
+ width,
+ height,
+ wrapperX,
+ wrapperY,
+ crispAdjust = 0,
+ deferredAttr = {},
+ attrSetters = wrapper.attrSetters;
+
+ /**
+ * This function runs after the label is added to the DOM (when the bounding box is
+ * available), and after the text of the label is updated to detect the new bounding
+ * box and reflect it in the border box.
+ */
+ function updateBoxSize() {
+ bBox = (width === undefined || height === undefined || wrapper.styles.textAlign) &&
+ text.getBBox(true);
+ wrapper.width = (width || bBox.width) + 2 * padding;
+ wrapper.height = (height || bBox.height) + 2 * padding;
+
+ // create the border box if it is not already present
+ if (!box) {
+ wrapper.box = box = shape ?
+ renderer.symbol(shape, 0, 0, wrapper.width, wrapper.height) :
+ renderer.rect(0, 0, wrapper.width, wrapper.height, 0, deferredAttr[STROKE_WIDTH]);
+ box.add(wrapper);
+ }
+
+ // apply the box attributes
+ box.attr(merge({
+ width: wrapper.width,
+ height: wrapper.height
+ }, deferredAttr));
+ deferredAttr = null;
+ }
+
+ /**
+ * This function runs after setting text or padding, but only if padding is changed
+ */
+ function updateTextPadding() {
+ var styles = wrapper.styles,
+ textAlign = styles && styles.textAlign,
+ x = padding,
+ y = padding + mathRound(pInt(wrapper.element.style.fontSize || 11) * 1.2);
+
+ // compensate for alignment
+ if (defined(width) && (textAlign === 'center' || textAlign === 'right')) {
+ x += { center: 0.5, right: 1 }[textAlign] * (width - bBox.width);
+ }
+
+ // update if anything changed
+ if (x !== text.x || y !== text.y) {
+ text.attr({
+ x: x,
+ y: y
+ });
+ }
+
+ // record current values
+ text.x = x;
+ text.y = y;
+ }
+
+ /**
+ * Set a box attribute, or defer it if the box is not yet created
+ * @param {Object} key
+ * @param {Object} value
+ */
+ function boxAttr(key, value) {
+ if (box) {
+ box.attr(key, value);
+ } else {
+ deferredAttr[key] = value;
+ }
+ }
+
+ function getSizeAfterAdd() {
+ wrapper.attr({
+ text: str, // alignment is available now
+ x: x,
+ y: y,
+ anchorX: anchorX,
+ anchorY: anchorY
+ });
+ }
+
+ /**
+ * After the text element is added, get the desired size of the border box
+ * and add it before the text in the DOM.
+ */
+ addEvent(wrapper, 'add', getSizeAfterAdd);
+
+ /*
+ * Add specific attribute setters.
+ */
+
+ // only change local variables
+ attrSetters.width = function (value) {
+ width = value;
+ return false;
+ };
+ attrSetters.height = function (value) {
+ height = value;
+ return false;
+ };
+ attrSetters.padding = function (value) {
+ padding = value;
+ updateTextPadding();
+
+ return false;
+ };
+
+ // change local variable and set attribue as well
+ attrSetters.align = function (value) {
+ align = value;
+ return false; // prevent setting text-anchor on the group
+ };
+
+ // apply these to the box and the text alike
+ attrSetters.text = function (value, key) {
+ text.attr(key, value);
+ updateBoxSize();
+ updateTextPadding();
+ return false;
+ };
+
+ // apply these to the box but not to the text
+ attrSetters[STROKE_WIDTH] = function (value, key) {
+ crispAdjust = value % 2 / 2;
+ boxAttr(key, value);
+ return false;
+ };
+ attrSetters.stroke = attrSetters.fill = attrSetters.r = function (value, key) {
+ boxAttr(key, value);
+ return false;
+ };
+ attrSetters.anchorX = function (value, key) {
+ anchorX = value;
+ boxAttr(key, value + crispAdjust - wrapperX);
+ return false;
+ };
+ attrSetters.anchorY = function (value, key) {
+ anchorY = value;
+ boxAttr(key, value - wrapperY);
+ return false;
+ };
+
+ // rename attributes
+ attrSetters.x = function (value) {
+ wrapperX = value;
+ wrapperX -= { left: 0, center: 0.5, right: 1 }[align] * ((width || bBox.width) + padding);
+
+ wrapper.attr('translateX', mathRound(wrapperX));
+ return false;
+ };
+ attrSetters.y = function (value) {
+ wrapperY = value;
+ wrapper.attr('translateY', mathRound(value));
+ return false;
+ };
+
+ // Redirect certain methods to either the box or the text
+ var baseCss = wrapper.css;
+ return extend(wrapper, {
+ /**
+ * Pick up some properties and apply them to the text instead of the wrapper
+ */
+ css: function (styles) {
+ if (styles) {
+ var textStyles = {};
+ styles = merge({}, styles); // create a copy to avoid altering the original object (#537)
+ each(['fontSize', 'fontWeight', 'fontFamily', 'color', 'lineHeight', 'width'], function (prop) {
+ if (styles[prop] !== UNDEFINED) {
+ textStyles[prop] = styles[prop];
+ delete styles[prop];
+ }
+ });
+ text.css(textStyles);
+ }
+ return baseCss.call(wrapper, styles);
+ },
+ /**
+ * Return the bounding box of the box, not the group
+ */
+ getBBox: function () {
+ return box.getBBox();
+ },
+ /**
+ * Apply the shadow to the box
+ */
+ shadow: function (b) {
+ box.shadow(b);
+ return wrapper;
+ },
+ /**
+ * Destroy and release memory.
+ */
+ destroy: function () {
+ removeEvent(wrapper, 'add', getSizeAfterAdd);
+
+ // Added by button implementation
+ removeEvent(wrapper.element, 'mouseenter');
+ removeEvent(wrapper.element, 'mouseleave');
+
+ if (text) {
+ // Destroy the text element
+ text = text.destroy();
+ }
+ // Call base implementation to destroy the rest
+ SVGElement.prototype.destroy.call(wrapper);
+ }
+ });
+ }
+}; // end SVGRenderer
+
+
+// general renderer
+Renderer = SVGRenderer;
+
+
+/* ****************************************************************************
+ * *
+ * START OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
+ * *
+ * For applications and websites that don't need IE support, like platform *
+ * targeted mobile apps and web apps, this code can be removed. *
+ * *
+ *****************************************************************************/
+
+/**
+ * @constructor
+ */
+var VMLRenderer;
+if (!hasSVG) {
+
+/**
+ * The VML element wrapper.
+ */
+var VMLElement = extendClass(SVGElement, {
+
+ /**
+ * Initialize a new VML element wrapper. It builds the markup as a string
+ * to minimize DOM traffic.
+ * @param {Object} renderer
+ * @param {Object} nodeName
+ */
+ init: function (renderer, nodeName) {
+ var wrapper = this,
+ markup = ['<', nodeName, ' filled="f" stroked="f"'],
+ style = ['position: ', ABSOLUTE, ';'];
+
+ // divs and shapes need size
+ if (nodeName === 'shape' || nodeName === DIV) {
+ style.push('left:0;top:0;width:10px;height:10px;');
+ }
+ if (docMode8) {
+ style.push('visibility: ', nodeName === DIV ? HIDDEN : VISIBLE);
+ }
+
+ markup.push(' style="', style.join(''), '"/>');
+
+ // create element with default attributes and style
+ if (nodeName) {
+ markup = nodeName === DIV || nodeName === 'span' || nodeName === 'img' ?
+ markup.join('')
+ : renderer.prepVML(markup);
+ wrapper.element = createElement(markup);
+ }
+
+ wrapper.renderer = renderer;
+ wrapper.attrSetters = {};
+ },
+
+ /**
+ * Add the node to the given parent
+ * @param {Object} parent
+ */
+ add: function (parent) {
+ var wrapper = this,
+ renderer = wrapper.renderer,
+ element = wrapper.element,
+ box = renderer.box,
+ inverted = parent && parent.inverted,
+
+ // get the parent node
+ parentNode = parent ?
+ parent.element || parent :
+ box;
+
+
+ // if the parent group is inverted, apply inversion on all children
+ if (inverted) { // only on groups
+ renderer.invertChild(element, parentNode);
+ }
+
+ // issue #140 workaround - related to #61 and #74
+ if (docMode8 && parentNode.gVis === HIDDEN) {
+ css(element, { visibility: HIDDEN });
+ }
+
+ // append it
+ parentNode.appendChild(element);
+
+ // align text after adding to be able to read offset
+ wrapper.added = true;
+ if (wrapper.alignOnAdd && !wrapper.deferUpdateTransform) {
+ wrapper.updateTransform();
+ }
+
+ // fire an event for internal hooks
+ fireEvent(wrapper, 'add');
+
+ return wrapper;
+ },
+
+ /**
+ * In IE8 documentMode 8, we need to recursively set the visibility down in the DOM
+ * tree for nested groups. Related to #61, #586.
+ */
+ toggleChildren: function (element, visibility) {
+ var childNodes = element.childNodes,
+ i = childNodes.length;
+
+ while (i--) {
+
+ // apply the visibility
+ css(childNodes[i], { visibility: visibility });
+
+ // we have a nested group, apply it to its children again
+ if (childNodes[i].nodeName === 'DIV') {
+ this.toggleChildren(childNodes[i], visibility);
+ }
+ }
+ },
+
+ /**
+ * Get or set attributes
+ */
+ attr: function (hash, val) {
+ var wrapper = this,
+ key,
+ value,
+ i,
+ result,
+ element = wrapper.element || {},
+ elemStyle = element.style,
+ nodeName = element.nodeName,
+ renderer = wrapper.renderer,
+ symbolName = wrapper.symbolName,
+ hasSetSymbolSize,
+ shadows = wrapper.shadows,
+ skipAttr,
+ attrSetters = wrapper.attrSetters,
+ ret = wrapper;
+
+ // single key-value pair
+ if (isString(hash) && defined(val)) {
+ key = hash;
+ hash = {};
+ hash[key] = val;
+ }
+
+ // used as a getter, val is undefined
+ if (isString(hash)) {
+ key = hash;
+ if (key === 'strokeWidth' || key === 'stroke-width') {
+ ret = wrapper.strokeweight;
+ } else {
+ ret = wrapper[key];
+ }
+
+ // setter
+ } else {
+ for (key in hash) {
+ value = hash[key];
+ skipAttr = false;
+
+ // check for a specific attribute setter
+ result = attrSetters[key] && attrSetters[key](value, key);
+
+ if (result !== false && value !== null) { // #620
+
+ if (result !== UNDEFINED) {
+ value = result; // the attribute setter has returned a new value to set
+ }
+
+
+ // prepare paths
+ // symbols
+ if (symbolName && /^(x|y|r|start|end|width|height|innerR|anchorX|anchorY)/.test(key)) {
+ // if one of the symbol size affecting parameters are changed,
+ // check all the others only once for each call to an element's
+ // .attr() method
+ if (!hasSetSymbolSize) {
+
+ wrapper.symbolAttr(hash);
+
+ hasSetSymbolSize = true;
+ }
+ skipAttr = true;
+
+ } else if (key === 'd') {
+ value = value || [];
+ wrapper.d = value.join(' '); // used in getter for animation
+
+ // convert paths
+ i = value.length;
+ var convertedPath = [];
+ while (i--) {
+
+ // Multiply by 10 to allow subpixel precision.
+ // Substracting half a pixel seems to make the coordinates
+ // align with SVG, but this hasn't been tested thoroughly
+ if (isNumber(value[i])) {
+ convertedPath[i] = mathRound(value[i] * 10) - 5;
+ } else if (value[i] === 'Z') { // close the path
+ convertedPath[i] = 'x';
+ } else {
+ convertedPath[i] = value[i];
+ }
+
+ }
+ value = convertedPath.join(' ') || 'x';
+ element.path = value;
+
+ // update shadows
+ if (shadows) {
+ i = shadows.length;
+ while (i--) {
+ shadows[i].path = value;
+ }
+ }
+ skipAttr = true;
+
+ // directly mapped to css
+ } else if (key === 'zIndex' || key === 'visibility') {
+
+ // workaround for #61 and #586
+ if (docMode8 && key === 'visibility' && nodeName === 'DIV') {
+ element.gVis = value;
+ wrapper.toggleChildren(element, value);
+ if (value === VISIBLE) { // #74
+ value = null;
+ }
+ }
+
+ if (value) {
+ elemStyle[key] = value;
+ }
+
+
+
+ skipAttr = true;
+
+ // width and height
+ } else if (key === 'width' || key === 'height') {
+
+ value = mathMax(0, value); // don't set width or height below zero (#311)
+
+ this[key] = value; // used in getter
+
+ // clipping rectangle special
+ if (wrapper.updateClipping) {
+ wrapper[key] = value;
+ wrapper.updateClipping();
+ } else {
+ // normal
+ elemStyle[key] = value;
+ }
+
+ skipAttr = true;
+
+ // x and y
+ } else if (/^(x|y)$/.test(key)) {
+
+ wrapper[key] = value; // used in getter
+
+ if (element.tagName === 'SPAN') {
+ wrapper.updateTransform();
+
+ } else {
+ elemStyle[{ x: 'left', y: 'top' }[key]] = value;
+ }
+
+ // class name
+ } else if (key === 'class') {
+ // IE8 Standards mode has problems retrieving the className
+ element.className = value;
+
+ // stroke
+ } else if (key === 'stroke') {
+
+ value = renderer.color(value, element, key);
+
+ key = 'strokecolor';
+
+ // stroke width
+ } else if (key === 'stroke-width' || key === 'strokeWidth') {
+ element.stroked = value ? true : false;
+ key = 'strokeweight';
+ wrapper[key] = value; // used in getter, issue #113
+ if (isNumber(value)) {
+ value += PX;
+ }
+
+ // dashStyle
+ } else if (key === 'dashstyle') {
+ var strokeElem = element.getElementsByTagName('stroke')[0] ||
+ createElement(renderer.prepVML(['<stroke/>']), null, null, element);
+ strokeElem[key] = value || 'solid';
+ wrapper.dashstyle = value; /* because changing stroke-width will change the dash length
+ and cause an epileptic effect */
+ skipAttr = true;
+
+ // fill
+ } else if (key === 'fill') {
+
+ if (nodeName === 'SPAN') { // text color
+ elemStyle.color = value;
+ } else {
+ element.filled = value !== NONE ? true : false;
+
+ value = renderer.color(value, element, key);
+
+ key = 'fillcolor';
+ }
+
+ // translation for animation
+ } else if (key === 'translateX' || key === 'translateY' || key === 'rotation' || key === 'align') {
+ if (key === 'align') {
+ key = 'textAlign';
+ }
+ wrapper[key] = value;
+ wrapper.updateTransform();
+
+ skipAttr = true;
+
+ // text for rotated and non-rotated elements
+ } else if (key === 'text') {
+ this.bBox = null;
+ element.innerHTML = value;
+ skipAttr = true;
+ }
+
+ // let the shadow follow the main element
+ if (shadows && key === 'visibility') {
+ i = shadows.length;
+ while (i--) {
+ shadows[i].style[key] = value;
+ }
+ }
+
+
+
+ if (!skipAttr) {
+ if (docMode8) { // IE8 setAttribute bug
+ element[key] = value;
+ } else {
+ attr(element, key, value);
+ }
+ }
+
+ }
+ }
+ }
+ return ret;
+ },
+
+ /**
+ * Set the element's clipping to a predefined rectangle
+ *
+ * @param {String} id The id of the clip rectangle
+ */
+ clip: function (clipRect) {
+ var wrapper = this,
+ clipMembers = clipRect.members;
+
+ clipMembers.push(wrapper);
+ wrapper.destroyClip = function () {
+ erase(clipMembers, wrapper);
+ };
+ return wrapper.css(clipRect.getCSS(wrapper.inverted));
+ },
+
+ /**
+ * Set styles for the element
+ * @param {Object} styles
+ */
+ css: function (styles) {
+ var wrapper = this,
+ element = wrapper.element,
+ textWidth = styles && element.tagName === 'SPAN' && styles.width;
+
+ if (textWidth) {
+ delete styles.width;
+ wrapper.textWidth = textWidth;
+ wrapper.updateTransform();
+ }
+
+ wrapper.styles = extend(wrapper.styles, styles);
+ css(wrapper.element, styles);
+
+ return wrapper;
+ },
+
+ /**
+ * Removes a child either by removeChild or move to garbageBin.
+ * Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not.
+ */
+ safeRemoveChild: function (element) {
+ // discardElement will detach the node from its parent before attaching it
+ // to the garbage bin. Therefore it is important that the node is attached and have parent.
+ var parentNode = element.parentNode;
+ if (parentNode) {
+ discardElement(element);
+ }
+ },
+
+ /**
+ * Extend element.destroy by removing it from the clip members array
+ */
+ destroy: function () {
+ var wrapper = this;
+
+ if (wrapper.destroyClip) {
+ wrapper.destroyClip();
+ }
+
+ return SVGElement.prototype.destroy.apply(wrapper);
+ },
+
+ /**
+ * Remove all child nodes of a group, except the v:group element
+ */
+ empty: function () {
+ var element = this.element,
+ childNodes = element.childNodes,
+ i = childNodes.length,
+ node;
+
+ while (i--) {
+ node = childNodes[i];
+ node.parentNode.removeChild(node);
+ }
+ },
+
+ /**
+ * VML override for calculating the bounding box based on offsets
+ * @param {Boolean} refresh Whether to force a fresh value from the DOM or to
+ * use the cached value
+ *
+ * @return {Object} A hash containing values for x, y, width and height
+ */
+
+ getBBox: function (refresh) {
+ var wrapper = this,
+ element = wrapper.element,
+ bBox = wrapper.bBox;
+
+ // faking getBBox in exported SVG in legacy IE
+ if (!bBox || refresh) {
+ // faking getBBox in exported SVG in legacy IE
+ if (element.nodeName === 'text') {
+ element.style.position = ABSOLUTE;
+ }
+
+ bBox = wrapper.bBox = {
+ x: element.offsetLeft,
+ y: element.offsetTop,
+ width: element.offsetWidth,
+ height: element.offsetHeight
+ };
+ }
+
+ return bBox;
+ },
+
+ /**
+ * Add an event listener. VML override for normalizing event parameters.
+ * @param {String} eventType
+ * @param {Function} handler
+ */
+ on: function (eventType, handler) {
+ // simplest possible event model for internal use
+ this.element['on' + eventType] = function () {
+ var evt = win.event;
+ evt.target = evt.srcElement;
+ handler(evt);
+ };
+ return this;
+ },
+
+
+ /**
+ * VML override private method to update elements based on internal
+ * properties based on SVG transform
+ */
+ updateTransform: function () {
+ // aligning non added elements is expensive
+ if (!this.added) {
+ this.alignOnAdd = true;
+ return;
+ }
+
+ var wrapper = this,
+ elem = wrapper.element,
+ translateX = wrapper.translateX || 0,
+ translateY = wrapper.translateY || 0,
+ x = wrapper.x || 0,
+ y = wrapper.y || 0,
+ align = wrapper.textAlign || 'left',
+ alignCorrection = { left: 0, center: 0.5, right: 1 }[align],
+ nonLeft = align && align !== 'left',
+ shadows = wrapper.shadows;
+
+ // apply translate
+ if (translateX || translateY) {
+ css(elem, {
+ marginLeft: translateX,
+ marginTop: translateY
+ });
+ if (shadows) { // used in labels/tooltip
+ each(shadows, function (shadow) {
+ css(shadow, {
+ marginLeft: translateX + 1,
+ marginTop: translateY + 1
+ });
+ });
+ }
+ }
+
+ // apply inversion
+ if (wrapper.inverted) { // wrapper is a group
+ each(elem.childNodes, function (child) {
+ wrapper.renderer.invertChild(child, elem);
+ });
+ }
+
+ if (elem.tagName === 'SPAN') {
+
+ var width, height,
+ rotation = wrapper.rotation,
+ lineHeight,
+ radians = 0,
+ costheta = 1,
+ sintheta = 0,
+ quad,
+ textWidth = pInt(wrapper.textWidth),
+ xCorr = wrapper.xCorr || 0,
+ yCorr = wrapper.yCorr || 0,
+ currentTextTransform = [rotation, align, elem.innerHTML, wrapper.textWidth].join(',');
+
+ if (currentTextTransform !== wrapper.cTT) { // do the calculations and DOM access only if properties changed
+
+ if (defined(rotation)) {
+ radians = rotation * deg2rad; // deg to rad
+ costheta = mathCos(radians);
+ sintheta = mathSin(radians);
+
+ // Adjust for alignment and rotation.
+ // Test case: http://highcharts.com/tests/?file=text-rotation
+ css(elem, {
+ filter: rotation ? ['progid:DXImageTransform.Microsoft.Matrix(M11=', costheta,
+ ', M12=', -sintheta, ', M21=', sintheta, ', M22=', costheta,
+ ', sizingMethod=\'auto expand\')'].join('') : NONE
+ });
+ }
+
+ width = pick(wrapper.elemWidth, elem.offsetWidth);
+ height = pick(wrapper.elemHeight, elem.offsetHeight);
+
+ // update textWidth
+ if (width > textWidth) {
+ css(elem, {
+ width: textWidth + PX,
+ display: 'block',
+ whiteSpace: 'normal'
+ });
+ width = textWidth;
+ }
+
+ // correct x and y
+ lineHeight = mathRound((pInt(elem.style.fontSize) || 12) * 1.2);
+ xCorr = costheta < 0 && -width;
+ yCorr = sintheta < 0 && -height;
+
+ // correct for lineHeight and corners spilling out after rotation
+ quad = costheta * sintheta < 0;
+ xCorr += sintheta * lineHeight * (quad ? 1 - alignCorrection : alignCorrection);
+ yCorr -= costheta * lineHeight * (rotation ? (quad ? alignCorrection : 1 - alignCorrection) : 1);
+
+ // correct for the length/height of the text
+ if (nonLeft) {
+ xCorr -= width * alignCorrection * (costheta < 0 ? -1 : 1);
+ if (rotation) {
+ yCorr -= height * alignCorrection * (sintheta < 0 ? -1 : 1);
+ }
+ css(elem, {
+ textAlign: align
+ });
+ }
+
+ // record correction
+ wrapper.xCorr = xCorr;
+ wrapper.yCorr = yCorr;
+ }
+
+ // apply position with correction
+ css(elem, {
+ left: x + xCorr,
+ top: y + yCorr
+ });
+
+ // record current text transform
+ wrapper.cTT = currentTextTransform;
+ }
+ },
+
+ /**
+ * Apply a drop shadow by copying elements and giving them different strokes
+ * @param {Boolean} apply
+ */
+ shadow: function (apply, group) {
+ var shadows = [],
+ i,
+ element = this.element,
+ renderer = this.renderer,
+ shadow,
+ elemStyle = element.style,
+ markup,
+ path = element.path;
+
+ // some times empty paths are not strings
+ if (path && typeof path.value !== 'string') {
+ path = 'x';
+ }
+
+ if (apply) {
+ for (i = 1; i <= 3; i++) {
+ markup = ['<shape isShadow="true" strokeweight="', (7 - 2 * i),
+ '" filled="false" path="', path,
+ '" coordsize="100,100" style="', element.style.cssText, '" />'];
+ shadow = createElement(renderer.prepVML(markup),
+ null, {
+ left: pInt(elemStyle.left) + 1,
+ top: pInt(elemStyle.top) + 1
+ }
+ );
+
+ // apply the opacity
+ markup = ['<stroke color="black" opacity="', (0.05 * i), '"/>'];
+ createElement(renderer.prepVML(markup), null, null, shadow);
+
+
+ // insert it
+ if (group) {
+ group.element.appendChild(shadow);
+ } else {
+ element.parentNode.insertBefore(shadow, element);
+ }
+
+ // record it
+ shadows.push(shadow);
+
+ }
+
+ this.shadows = shadows;
+ }
+ return this;
+
+ }
+});
+
+/**
+ * The VML renderer
+ */
+VMLRenderer = function () {
+ this.init.apply(this, arguments);
+};
+VMLRenderer.prototype = merge(SVGRenderer.prototype, { // inherit SVGRenderer
+
+ Element: VMLElement,
+ isIE8: userAgent.indexOf('MSIE 8.0') > -1,
+
+
+ /**
+ * Initialize the VMLRenderer
+ * @param {Object} container
+ * @param {Number} width
+ * @param {Number} height
+ */
+ init: function (container, width, height) {
+ var renderer = this,
+ boxWrapper;
+
+ renderer.alignedObjects = [];
+
+ boxWrapper = renderer.createElement(DIV);
+ container.appendChild(boxWrapper.element);
+
+
+ // generate the containing box
+ renderer.box = boxWrapper.element;
+ renderer.boxWrapper = boxWrapper;
+
+
+ renderer.setSize(width, height, false);
+
+ // The only way to make IE6 and IE7 print is to use a global namespace. However,
+ // with IE8 the only way to make the dynamic shapes visible in screen and print mode
+ // seems to be to add the xmlns attribute and the behaviour style inline.
+ if (!doc.namespaces.hcv) {
+
+ doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');
+
+ // setup default css
+ doc.createStyleSheet().cssText =
+ 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
+ '{ behavior:url(#default#VML); display: inline-block; } ';
+
+ }
+ },
+
+ /**
+ * Define a clipping rectangle. In VML it is accomplished by storing the values
+ * for setting the CSS style to all associated members.
+ *
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} width
+ * @param {Number} height
+ */
+ clipRect: function (x, y, width, height) {
+
+ // create a dummy element
+ var clipRect = this.createElement();
+
+ // mimic a rectangle with its style object for automatic updating in attr
+ return extend(clipRect, {
+ members: [],
+ left: x,
+ top: y,
+ width: width,
+ height: height,
+ getCSS: function (inverted) {
+ var rect = this,//clipRect.element.style,
+ top = rect.top,
+ left = rect.left,
+ right = left + rect.width,
+ bottom = top + rect.height,
+ ret = {
+ clip: 'rect(' +
+ mathRound(inverted ? left : top) + 'px,' +
+ mathRound(inverted ? bottom : right) + 'px,' +
+ mathRound(inverted ? right : bottom) + 'px,' +
+ mathRound(inverted ? top : left) + 'px)'
+ };
+
+ // issue 74 workaround
+ if (!inverted && docMode8) {
+ extend(ret, {
+ width: right + PX,
+ height: bottom + PX
+ });
+ }
+ return ret;
+ },
+
+ // used in attr and animation to update the clipping of all members
+ updateClipping: function () {
+ each(clipRect.members, function (member) {
+ member.css(clipRect.getCSS(member.inverted));
+ });
+ }
+ });
+
+ },
+
+
+ /**
+ * Take a color and return it if it's a string, make it a gradient if it's a
+ * gradient configuration object, and apply opacity.
+ *
+ * @param {Object} color The color or config object
+ */
+ color: function (color, elem, prop) {
+ var colorObject,
+ regexRgba = /^rgba/,
+ markup;
+
+ if (color && color[LINEAR_GRADIENT]) {
+
+ var stopColor,
+ stopOpacity,
+ linearGradient = color[LINEAR_GRADIENT],
+ x1 = linearGradient.x1 || linearGradient[0] || 0,
+ y1 = linearGradient.y1 || linearGradient[1] || 0,
+ x2 = linearGradient.x2 || linearGradient[2] || 0,
+ y2 = linearGradient.y2 || linearGradient[3] || 0,
+ angle,
+ color1,
+ opacity1,
+ color2,
+ opacity2;
+
+ each(color.stops, function (stop, i) {
+ if (regexRgba.test(stop[1])) {
+ colorObject = Color(stop[1]);
+ stopColor = colorObject.get('rgb');
+ stopOpacity = colorObject.get('a');
+ } else {
+ stopColor = stop[1];
+ stopOpacity = 1;
+ }
+
+ if (!i) { // first
+ color1 = stopColor;
+ opacity1 = stopOpacity;
+ } else {
+ color2 = stopColor;
+ opacity2 = stopOpacity;
+ }
+ });
+
+ // Apply the gradient to fills only.
+ if (prop === 'fill') {
+ // calculate the angle based on the linear vector
+ angle = 90 - math.atan(
+ (y2 - y1) / // y vector
+ (x2 - x1) // x vector
+ ) * 180 / mathPI;
+
+
+ // when colors attribute is used, the meanings of opacity and o:opacity2
+ // are reversed.
+ markup = ['<fill colors="0% ', color1, ',100% ', color2, '" angle="', angle,
+ '" opacity="', opacity2, '" o:opacity2="', opacity1,
+ '" type="gradient" focus="100%" method="any" />'];
+ createElement(this.prepVML(markup), null, null, elem);
+
+ // Gradients are not supported for VML stroke, return the first color. #722.
+ } else {
+ return stopColor;
+ }
+
+
+ // if the color is an rgba color, split it and add a fill node
+ // to hold the opacity component
+ } else if (regexRgba.test(color) && elem.tagName !== 'IMG') {
+
+ colorObject = Color(color);
+
+ markup = ['<', prop, ' opacity="', colorObject.get('a'), '"/>'];
+ createElement(this.prepVML(markup), null, null, elem);
+
+ return colorObject.get('rgb');
+
+
+ } else {
+ var strokeNodes = elem.getElementsByTagName(prop);
+ if (strokeNodes.length) {
+ strokeNodes[0].opacity = 1;
+ }
+ return color;
+ }
+
+ },
+
+ /**
+ * Take a VML string and prepare it for either IE8 or IE6/IE7.
+ * @param {Array} markup A string array of the VML markup to prepare
+ */
+ prepVML: function (markup) {
+ var vmlStyle = 'display:inline-block;behavior:url(#default#VML);',
+ isIE8 = this.isIE8;
+
+ markup = markup.join('');
+
+ if (isIE8) { // add xmlns and style inline
+ markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />');
+ if (markup.indexOf('style="') === -1) {
+ markup = markup.replace('/>', ' style="' + vmlStyle + '" />');
+ } else {
+ markup = markup.replace('style="', 'style="' + vmlStyle);
+ }
+
+ } else { // add namespace
+ markup = markup.replace('<', '<hcv:');
+ }
+
+ return markup;
+ },
+
+ /**
+ * Create rotated and aligned text
+ * @param {String} str
+ * @param {Number} x
+ * @param {Number} y
+ */
+ text: function (str, x, y) {
+
+ var defaultChartStyle = defaultOptions.chart.style;
+
+ return this.createElement('span')
+ .attr({
+ text: str,
+ x: mathRound(x),
+ y: mathRound(y)
+ })
+ .css({
+ whiteSpace: 'nowrap',
+ fontFamily: defaultChartStyle.fontFamily,
+ fontSize: defaultChartStyle.fontSize
+ });
+ },
+
+ /**
+ * Create and return a path element
+ * @param {Array} path
+ */
+ path: function (path) {
+ // create the shape
+ return this.createElement('shape').attr({
+ // subpixel precision down to 0.1 (width and height = 10px)
+ coordsize: '100 100',
+ d: path
+ });
+ },
+
+ /**
+ * Create and return a circle element. In VML circles are implemented as
+ * shapes, which is faster than v:oval
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} r
+ */
+ circle: function (x, y, r) {
+ return this.symbol('circle').attr({ x: x, y: y, r: r});
+ },
+
+ /**
+ * Create a group using an outer div and an inner v:group to allow rotating
+ * and flipping. A simple v:group would have problems with positioning
+ * child HTML elements and CSS clip.
+ *
+ * @param {String} name The name of the group
+ */
+ g: function (name) {
+ var wrapper,
+ attribs;
+
+ // set the class name
+ if (name) {
+ attribs = { 'className': PREFIX + name, 'class': PREFIX + name };
+ }
+
+ // the div to hold HTML and clipping
+ wrapper = this.createElement(DIV).attr(attribs);
+
+ return wrapper;
+ },
+
+ /**
+ * VML override to create a regular HTML image
+ * @param {String} src
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} width
+ * @param {Number} height
+ */
+ image: function (src, x, y, width, height) {
+ var obj = this.createElement('img')
+ .attr({ src: src });
+
+ if (arguments.length > 1) {
+ obj.css({
+ left: x,
+ top: y,
+ width: width,
+ height: height
+ });
+ }
+ return obj;
+ },
+
+ /**
+ * VML uses a shape for rect to overcome bugs and rotation problems
+ */
+ rect: function (x, y, width, height, r, strokeWidth) {
+
+ if (isObject(x)) {
+ y = x.y;
+ width = x.width;
+ height = x.height;
+ strokeWidth = x.strokeWidth;
+ x = x.x;
+ }
+ var wrapper = this.symbol('rect');
+ wrapper.r = r;
+
+ return wrapper.attr(wrapper.crisp(strokeWidth, x, y, mathMax(width, 0), mathMax(height, 0)));
+ },
+
+ /**
+ * In the VML renderer, each child of an inverted div (group) is inverted
+ * @param {Object} element
+ * @param {Object} parentNode
+ */
+ invertChild: function (element, parentNode) {
+ var parentStyle = parentNode.style;
+
+ css(element, {
+ flip: 'x',
+ left: pInt(parentStyle.width) - 10,
+ top: pInt(parentStyle.height) - 10,
+ rotation: -90
+ });
+ },
+
+ /**
+ * Symbol definitions that override the parent SVG renderer's symbols
+ *
+ */
+ symbols: {
+ // VML specific arc function
+ arc: function (x, y, w, h, options) {
+ var start = options.start,
+ end = options.end,
+ radius = options.r || w || h,
+ cosStart = mathCos(start),
+ sinStart = mathSin(start),
+ cosEnd = mathCos(end),
+ sinEnd = mathSin(end),
+ innerRadius = options.innerR,
+ circleCorrection = 0.07 / radius,
+ innerCorrection = (innerRadius && 0.1 / innerRadius) || 0;
+
+ if (end - start === 0) { // no angle, don't show it.
+ return ['x'];
+
+ //} else if (end - start == 2 * mathPI) { // full circle
+ } else if (2 * mathPI - end + start < circleCorrection) { // full circle
+ // empirical correction found by trying out the limits for different radii
+ cosEnd = -circleCorrection;
+ } else if (end - start < innerCorrection) { // issue #186, another mysterious VML arc problem
+ cosEnd = mathCos(start + innerCorrection);
+ }
+
+ return [
+ 'wa', // clockwise arc to
+ x - radius, // left
+ y - radius, // top
+ x + radius, // right
+ y + radius, // bottom
+ x + radius * cosStart, // start x
+ y + radius * sinStart, // start y
+ x + radius * cosEnd, // end x
+ y + radius * sinEnd, // end y
+
+
+ 'at', // anti clockwise arc to
+ x - innerRadius, // left
+ y - innerRadius, // top
+ x + innerRadius, // right
+ y + innerRadius, // bottom
+ x + innerRadius * cosEnd, // start x
+ y + innerRadius * sinEnd, // start y
+ x + innerRadius * cosStart, // end x
+ y + innerRadius * sinStart, // end y
+
+ 'x', // finish path
+ 'e' // close
+ ];
+
+ },
+ // Add circle symbol path. This performs significantly faster than v:oval.
+ circle: function (x, y, w, h) {
+
+ return [
+ 'wa', // clockwisearcto
+ x, // left
+ y, // top
+ x + w, // right
+ y + h, // bottom
+ x + w, // start x
+ y + h / 2, // start y
+ x + w, // end x
+ y + h / 2, // end y
+ //'x', // finish path
+ 'e' // close
+ ];
+ },
+ /**
+ * Add rectangle symbol path which eases rotation and omits arcsize problems
+ * compared to the built-in VML roundrect shape
+ *
+ * @param {Number} left Left position
+ * @param {Number} top Top position
+ * @param {Number} r Border radius
+ * @param {Object} options Width and height
+ */
+
+ rect: function (left, top, width, height, options) {
+ /*for (var n in r) {
+ logTime && console .log(n)
+ }*/
+
+ if (!defined(options)) {
+ return [];
+ }
+ var right = left + width,
+ bottom = top + height,
+ r = mathMin(options.r || 0, width, height);
+
+ return [
+ M,
+ left + r, top,
+
+ L,
+ right - r, top,
+ 'wa',
+ right - 2 * r, top,
+ right, top + 2 * r,
+ right - r, top,
+ right, top + r,
+
+ L,
+ right, bottom - r,
+ 'wa',
+ right - 2 * r, bottom - 2 * r,
+ right, bottom,
+ right, bottom - r,
+ right - r, bottom,
+
+ L,
+ left + r, bottom,
+ 'wa',
+ left, bottom - 2 * r,
+ left + 2 * r, bottom,
+ left + r, bottom,
+ left, bottom - r,
+
+ L,
+ left, top + r,
+ 'wa',
+ left, top,
+ left + 2 * r, top + 2 * r,
+ left, top + r,
+ left + r, top,
+
+
+ 'x',
+ 'e'
+ ];
+
+ }
+ }
+});
+
+ // general renderer
+ Renderer = VMLRenderer;
+}
+
+/* ****************************************************************************
+ * *
+ * END OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
+ * *
+ *****************************************************************************/
+
+/**
+ * The chart class
+ * @param {Object} options
+ * @param {Function} callback Function to run when the chart has loaded
+ */
+function Chart(options, callback) {
+
+ // Handle regular options
+ var seriesOptions = options.series; // skip merging data points to increase performance
+ options.series = null;
+ options = merge(defaultOptions, options); // do the merge
+ options.series = seriesOptions; // set back the series data
+
+ // Define chart variables
+ var optionsChart = options.chart,
+ optionsMargin = optionsChart.margin,
+ margin = isObject(optionsMargin) ?
+ optionsMargin :
+ [optionsMargin, optionsMargin, optionsMargin, optionsMargin],
+ optionsMarginTop = pick(optionsChart.marginTop, margin[0]),
+ optionsMarginRight = pick(optionsChart.marginRight, margin[1]),
+ optionsMarginBottom = pick(optionsChart.marginBottom, margin[2]),
+ optionsMarginLeft = pick(optionsChart.marginLeft, margin[3]),
+ spacingTop = optionsChart.spacingTop,
+ spacingRight = optionsChart.spacingRight,
+ spacingBottom = optionsChart.spacingBottom,
+ spacingLeft = optionsChart.spacingLeft,
+ spacingBox,
+ chartTitleOptions,
+ chartSubtitleOptions,
+ plotTop,
+ marginRight,
+ marginBottom,
+ plotLeft,
+ axisOffset,
+ renderTo,
+ renderToClone,
+ container,
+ containerId,
+ containerWidth,
+ containerHeight,
+ chartWidth,
+ chartHeight,
+ oldChartWidth,
+ oldChartHeight,
+ chartBackground,
+ plotBackground,
+ plotBGImage,
+ plotBorder,
+ chart = this,
+ chartEvents = optionsChart.events,
+ runChartClick = chartEvents && !!chartEvents.click,
+ eventType,
+ isInsidePlot, // function
+ tooltip,
+ mouseIsDown,
+ loadingDiv,
+ loadingSpan,
+ loadingShown,
+ plotHeight,
+ plotWidth,
+ tracker,
+ trackerGroup,
+ placeTrackerGroup,
+ legend,
+ legendWidth,
+ legendHeight,
+ chartPosition,
+ hasCartesianSeries = optionsChart.showAxes,
+ isResizing = 0,
+ axes = [],
+ maxTicks, // handle the greatest amount of ticks on grouped axes
+ series = [],
+ inverted,
+ renderer,
+ tooltipTick,
+ tooltipInterval,
+ hoverX,
+ drawChartBox, // function
+ getMargins, // function
+ resetMargins, // function
+ setChartSize, // function
+ resize,
+ zoom, // function
+ zoomOut; // function
+
+
+ /**
+ * Create a new axis object
+ * @param {Object} options
+ */
+ function Axis(userOptions) {
+
+ // Define variables
+ var isXAxis = userOptions.isX,
+ opposite = userOptions.opposite, // needed in setOptions
+ horiz = inverted ? !isXAxis : isXAxis,
+ side = horiz ?
+ (opposite ? 0 : 2) : // top : bottom
+ (opposite ? 1 : 3), // right : left
+ stacks = {},
+
+ options = merge(
+ isXAxis ? defaultXAxisOptions : defaultYAxisOptions,
+ [defaultTopAxisOptions, defaultRightAxisOptions,
+ defaultBottomAxisOptions, defaultLeftAxisOptions][side],
+ userOptions
+ ),
+
+ axis = this,
+ axisTitle,
+ type = options.type,
+ isDatetimeAxis = type === 'datetime',
+ isLog = type === 'logarithmic',
+ offset = options.offset || 0,
+ xOrY = isXAxis ? 'x' : 'y',
+ axisLength = 0,
+ oldAxisLength,
+ transA, // translation factor
+ transB, // translation addend
+ oldTransA, // used for prerendering
+ axisLeft,
+ axisTop,
+ axisWidth,
+ axisHeight,
+ axisBottom,
+ axisRight,
+ translate, // fn
+ setAxisTranslation, // fn
+ getPlotLinePath, // fn
+ axisGroup,
+ gridGroup,
+ axisLine,
+ dataMin,
+ dataMax,
+ minRange = options.minRange || options.maxZoom,
+ range = options.range,
+ userMin,
+ userMax,
+ oldUserMin,
+ oldUserMax,
+ max = null,
+ min = null,
+ oldMin,
+ oldMax,
+ minPadding = options.minPadding,
+ maxPadding = options.maxPadding,
+ minPixelPadding = 0,
+ isLinked = defined(options.linkedTo),
+ ignoreMinPadding, // can be set to true by a column or bar series
+ ignoreMaxPadding,
+ usePercentage,
+ events = options.events,
+ eventType,
+ plotLinesAndBands = [],
+ tickInterval,
+ minorTickInterval,
+ magnitude,
+ tickPositions, // array containing predefined positions
+ tickPositioner = options.tickPositioner,
+ ticks = {},
+ minorTicks = {},
+ alternateBands = {},
+ tickAmount,
+ labelOffset,
+ axisTitleMargin,// = options.title.margin,
+ categories = options.categories,
+ labelFormatter = options.labels.formatter || // can be overwritten by dynamic format
+ function () {
+ var value = this.value,
+ dateTimeLabelFormat = this.dateTimeLabelFormat,
+ ret;
+
+ if (dateTimeLabelFormat) { // datetime axis
+ ret = dateFormat(dateTimeLabelFormat, value);
+
+ } else if (tickInterval % 1000000 === 0) { // use M abbreviation
+ ret = (value / 1000000) + 'M';
+
+ } else if (tickInterval % 1000 === 0) { // use k abbreviation
+ ret = (value / 1000) + 'k';
+
+ } else if (!categories && value >= 1000) { // add thousands separators
+ ret = numberFormat(value, 0);
+
+ } else { // strings (categories) and small numbers
+ ret = value;
+ }
+ return ret;
+ },
+
+ staggerLines = horiz && options.labels.staggerLines,
+ reversed = options.reversed,
+ tickmarkOffset = (categories && options.tickmarkPlacement === 'between') ? 0.5 : 0;
+
+ /**
+ * The Tick class
+ */
+ function Tick(pos, type) {
+ var tick = this;
+ tick.pos = pos;
+ tick.type = type || '';
+ tick.isNew = true;
+
+ if (!type) {
+ tick.addLabel();
+ }
+ }
+ Tick.prototype = {
+
+ /**
+ * Write the tick label
+ */
+ addLabel: function () {
+ var tick = this,
+ pos = tick.pos,
+ labelOptions = options.labels,
+ str,
+ width = (categories && horiz && categories.length &&
+ !labelOptions.step && !labelOptions.staggerLines &&
+ !labelOptions.rotation &&
+ plotWidth / categories.length) ||
+ (!horiz && plotWidth / 2),
+ isFirst = pos === tickPositions[0],
+ isLast = pos === tickPositions[tickPositions.length - 1],
+ css,
+ value = categories && defined(categories[pos]) ? categories[pos] : pos,
+ label = tick.label,
+ tickPositionInfo = tickPositions.info,
+ dateTimeLabelFormat;
+
+ // Set the datetime label format. If a higher rank is set for this position, use that. If not,
+ // use the general format.
+ if (isDatetimeAxis && tickPositionInfo) {
+ dateTimeLabelFormat = options.dateTimeLabelFormats[tickPositionInfo.higherRanks[pos] || tickPositionInfo.unitName];
+ }
+
+ // set properties for access in render method
+ tick.isFirst = isFirst;
+ tick.isLast = isLast;
+
+ // get the string
+ str = labelFormatter.call({
+ axis: axis, // docs
+ chart: chart, // docs
+ isFirst: isFirst,
+ isLast: isLast,
+ dateTimeLabelFormat: dateTimeLabelFormat,
+ value: isLog ? lin2log(value) : value
+ });
+
+
+ // prepare CSS
+ css = width && { width: mathMax(1, mathRound(width - 2 * (labelOptions.padding || 10))) + PX };
+ css = extend(css, labelOptions.style);
+
+ // first call
+ if (!defined(label)) {
+ tick.label =
+ defined(str) && labelOptions.enabled ?
+ renderer.text(
+ str,
+ 0,
+ 0,
+ labelOptions.useHTML
+ )
+ .attr({
+ align: labelOptions.align,
+ rotation: labelOptions.rotation
+ })
+ // without position absolute, IE export sometimes is wrong
+ .css(css)
+ .add(axisGroup) :
+ null;
+
+ // update
+ } else if (label) {
+ label.attr({
+ text: str
+ })
+ .css(css);
+ }
+ },
+ /**
+ * Get the offset height or width of the label
+ */
+ getLabelSize: function () {
+ var label = this.label;
+ return label ?
+ ((this.labelBBox = label.getBBox()))[horiz ? 'height' : 'width'] :
+ 0;
+ },
+ /**
+ * Put everything in place
+ *
+ * @param index {Number}
+ * @param old {Boolean} Use old coordinates to prepare an animation into new position
+ */
+ render: function (index, old) {
+ var tick = this,
+ type = tick.type,
+ label = tick.label,
+ pos = tick.pos,
+ labelOptions = options.labels,
+ gridLine = tick.gridLine,
+ gridPrefix = type ? type + 'Grid' : 'grid',
+ tickPrefix = type ? type + 'Tick' : 'tick',
+ gridLineWidth = options[gridPrefix + 'LineWidth'],
+ gridLineColor = options[gridPrefix + 'LineColor'],
+ dashStyle = options[gridPrefix + 'LineDashStyle'],
+ tickLength = options[tickPrefix + 'Length'],
+ tickWidth = options[tickPrefix + 'Width'] || 0,
+ tickColor = options[tickPrefix + 'Color'],
+ tickPosition = options[tickPrefix + 'Position'],
+ gridLinePath,
+ mark = tick.mark,
+ markPath,
+ step = labelOptions.step,
+ cHeight = (old && oldChartHeight) || chartHeight,
+ attribs,
+ x,
+ y;
+
+ // get x and y position for ticks and labels
+ x = horiz ?
+ translate(pos + tickmarkOffset, null, null, old) + transB :
+ axisLeft + offset + (opposite ? ((old && oldChartWidth) || chartWidth) - axisRight - axisLeft : 0);
+
+ y = horiz ?
+ cHeight - axisBottom + offset - (opposite ? axisHeight : 0) :
+ cHeight - translate(pos + tickmarkOffset, null, null, old) - transB;
+
+ // create the grid line
+ if (gridLineWidth) {
+ gridLinePath = getPlotLinePath(pos + tickmarkOffset, gridLineWidth, old);
+
+ if (gridLine === UNDEFINED) {
+ attribs = {
+ stroke: gridLineColor,
+ 'stroke-width': gridLineWidth
+ };
+ if (dashStyle) {
+ attribs.dashstyle = dashStyle;
+ }
+ if (!type) {
+ attribs.zIndex = 1;
+ }
+ tick.gridLine = gridLine =
+ gridLineWidth ?
+ renderer.path(gridLinePath)
+ .attr(attribs).add(gridGroup) :
+ null;
+ }
+
+ // If the parameter 'old' is set, the current call will be followed
+ // by another call, therefore do not do any animations this time
+ if (!old && gridLine && gridLinePath) {
+ gridLine.animate({
+ d: gridLinePath
+ });
+ }
+ }
+
+ // create the tick mark
+ if (tickWidth) {
+
+ // negate the length
+ if (tickPosition === 'inside') {
+ tickLength = -tickLength;
+ }
+ if (opposite) {
+ tickLength = -tickLength;
+ }
+
+ markPath = renderer.crispLine([
+ M,
+ x,
+ y,
+ L,
+ x + (horiz ? 0 : -tickLength),
+ y + (horiz ? tickLength : 0)
+ ], tickWidth);
+
+ if (mark) { // updating
+ mark.animate({
+ d: markPath
+ });
+ } else { // first time
+ tick.mark = renderer.path(
+ markPath
+ ).attr({
+ stroke: tickColor,
+ 'stroke-width': tickWidth
+ }).add(axisGroup);
+ }
+ }
+
+ // the label is created on init - now move it into place
+ if (label && !isNaN(x)) {
+ x = x + labelOptions.x - (tickmarkOffset && horiz ?
+ tickmarkOffset * transA * (reversed ? -1 : 1) : 0);
+ y = y + labelOptions.y - (tickmarkOffset && !horiz ?
+ tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
+
+ // vertically centered
+ if (!defined(labelOptions.y)) {
+ y += pInt(label.styles.lineHeight) * 0.9 - label.getBBox().height / 2;
+ }
+
+
+ // correct for staggered labels
+ if (staggerLines) {
+ y += (index / (step || 1) % staggerLines) * 16;
+ }
+
+ // apply show first and show last
+ if ((tick.isFirst && !pick(options.showFirstLabel, 1)) ||
+ (tick.isLast && !pick(options.showLastLabel, 1))) {
+ label.hide();
+ } else {
+ // show those that may have been previously hidden, either by show first/last, or by step
+ label.show();
+ }
+
+ // apply step
+ if (step && index % step) {
+ // show those indices dividable by step
+ label.hide();
+ }
+
+ label[tick.isNew ? 'attr' : 'animate']({
+ x: x,
+ y: y
+ });
+ }
+
+ tick.isNew = false;
+ },
+ /**
+ * Destructor for the tick prototype
+ */
+ destroy: function () {
+ destroyObjectProperties(this);
+ }
+ };
+
+ /**
+ * The object wrapper for plot lines and plot bands
+ * @param {Object} options
+ */
+ function PlotLineOrBand(options) {
+ var plotLine = this;
+ if (options) {
+ plotLine.options = options;
+ plotLine.id = options.id;
+ }
+
+ //plotLine.render()
+ return plotLine;
+ }
+
+ PlotLineOrBand.prototype = {
+
+ /**
+ * Render the plot line or plot band. If it is already existing,
+ * move it.
+ */
+ render: function () {
+ var plotLine = this,
+ halfPointRange = (axis.pointRange || 0) / 2,
+ options = plotLine.options,
+ optionsLabel = options.label,
+ label = plotLine.label,
+ width = options.width,
+ to = options.to,
+ from = options.from,
+ value = options.value,
+ toPath, // bands only
+ dashStyle = options.dashStyle,
+ svgElem = plotLine.svgElem,
+ path = [],
+ addEvent,
+ eventType,
+ xs,
+ ys,
+ x,
+ y,
+ color = options.color,
+ zIndex = options.zIndex,
+ events = options.events,
+ attribs;
+
+ // logarithmic conversion
+ if (isLog) {
+ from = log2lin(from);
+ to = log2lin(to);
+ value = log2lin(value);
+ }
+
+ // plot line
+ if (width) {
+ path = getPlotLinePath(value, width);
+ attribs = {
+ stroke: color,
+ 'stroke-width': width
+ };
+ if (dashStyle) {
+ attribs.dashstyle = dashStyle;
+ }
+ } else if (defined(from) && defined(to)) { // plot band
+ // keep within plot area
+ from = mathMax(from, min - halfPointRange);
+ to = mathMin(to, max + halfPointRange);
+
+ toPath = getPlotLinePath(to);
+ path = getPlotLinePath(from);
+ if (path && toPath) {
+ path.push(
+ toPath[4],
+ toPath[5],
+ toPath[1],
+ toPath[2]
+ );
+ } else { // outside the axis area
+ path = null;
+ }
+ attribs = {
+ fill: color
+ };
+ } else {
+ return;
+ }
+ // zIndex
+ if (defined(zIndex)) {
+ attribs.zIndex = zIndex;
+ }
+
+ // common for lines and bands
+ if (svgElem) {
+ if (path) {
+ svgElem.animate({
+ d: path
+ }, null, svgElem.onGetPath);
+ } else {
+ svgElem.hide();
+ svgElem.onGetPath = function () {
+ svgElem.show();
+ };
+ }
+ } else if (path && path.length) {
+ plotLine.svgElem = svgElem = renderer.path(path)
+ .attr(attribs).add();
+
+ // events
+ if (events) {
+ addEvent = function (eventType) {
+ svgElem.on(eventType, function (e) {
+ events[eventType].apply(plotLine, [e]);
+ });
+ };
+ for (eventType in events) {
+ addEvent(eventType);
+ }
+ }
+ }
+
+ // the plot band/line label
+ if (optionsLabel && defined(optionsLabel.text) && path && path.length && axisWidth > 0 && axisHeight > 0) {
+ // apply defaults
+ optionsLabel = merge({
+ align: horiz && toPath && 'center',
+ x: horiz ? !toPath && 4 : 10,
+ verticalAlign : !horiz && toPath && 'middle',
+ y: horiz ? toPath ? 16 : 10 : toPath ? 6 : -4,
+ rotation: horiz && !toPath && 90
+ }, optionsLabel);
+
+ // add the SVG element
+ if (!label) {
+ plotLine.label = label = renderer.text(
+ optionsLabel.text,
+ 0,
+ 0
+ )
+ .attr({
+ align: optionsLabel.textAlign || optionsLabel.align,
+ rotation: optionsLabel.rotation,
+ zIndex: zIndex
+ })
+ .css(optionsLabel.style)
+ .add();
+ }
+
+ // get the bounding box and align the label
+ xs = [path[1], path[4], pick(path[6], path[1])];
+ ys = [path[2], path[5], pick(path[7], path[2])];
+ x = arrayMin(xs);
+ y = arrayMin(ys);
+
+ label.align(optionsLabel, false, {
+ x: x,
+ y: y,
+ width: arrayMax(xs) - x,
+ height: arrayMax(ys) - y
+ });
+ label.show();
+
+ } else if (label) { // move out of sight
+ label.hide();
+ }
+
+ // chainable
+ return plotLine;
+ },
+
+ /**
+ * Remove the plot line or band
+ */
+ destroy: function () {
+ var obj = this;
+
+ destroyObjectProperties(obj);
+
+ // remove it from the lookup
+ erase(plotLinesAndBands, obj);
+ }
+ };
+
+ /**
+ * The class for stack items
+ */
+ function StackItem(options, isNegative, x, stackOption) {
+ var stackItem = this;
+
+ // Tells if the stack is negative
+ stackItem.isNegative = isNegative;
+
+ // Save the options to be able to style the label
+ stackItem.options = options;
+
+ // Save the x value to be able to position the label later
+ stackItem.x = x;
+
+ // Save the stack option on the series configuration object
+ stackItem.stack = stackOption;
+
+ // The align options and text align varies on whether the stack is negative and
+ // if the chart is inverted or not.
+ // First test the user supplied value, then use the dynamic.
+ stackItem.alignOptions = {
+ align: options.align || (inverted ? (isNegative ? 'left' : 'right') : 'center'),
+ verticalAlign: options.verticalAlign || (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
+ y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)),
+ x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0)
+ };
+
+ stackItem.textAlign = options.textAlign || (inverted ? (isNegative ? 'right' : 'left') : 'center');
+ }
+
+ StackItem.prototype = {
+ destroy: function () {
+ destroyObjectProperties(this);
+ },
+
+ /**
+ * Sets the total of this stack. Should be called when a serie is hidden or shown
+ * since that will affect the total of other stacks.
+ */
+ setTotal: function (total) {
+ this.total = total;
+ this.cum = total;
+ },
+
+ /**
+ * Renders the stack total label and adds it to the stack label group.
+ */
+ render: function (group) {
+ var stackItem = this, // aliased this
+ str = stackItem.options.formatter.call(stackItem); // format the text in the label
+
+ // Change the text to reflect the new total and set visibility to hidden in case the serie is hidden
+ if (stackItem.label) {
+ stackItem.label.attr({text: str, visibility: HIDDEN});
+ // Create new label
+ } else {
+ stackItem.label =
+ chart.renderer.text(str, 0, 0) // dummy positions, actual position updated with setOffset method in columnseries
+ .css(stackItem.options.style) // apply style
+ .attr({align: stackItem.textAlign, // fix the text-anchor
+ rotation: stackItem.options.rotation, // rotation
+ visibility: HIDDEN }) // hidden until setOffset is called
+ .add(group); // add to the labels-group
+ }
+ },
+
+ /**
+ * Sets the offset that the stack has from the x value and repositions the label.
+ */
+ setOffset: function (xOffset, xWidth) {
+ var stackItem = this, // aliased this
+ neg = stackItem.isNegative, // special treatment is needed for negative stacks
+ y = axis.translate(stackItem.total), // stack value translated mapped to chart coordinates
+ yZero = axis.translate(0), // stack origin
+ h = mathAbs(y - yZero), // stack height
+ x = chart.xAxis[0].translate(stackItem.x) + xOffset, // stack x position
+ plotHeight = chart.plotHeight,
+ stackBox = { // this is the box for the complete stack
+ x: inverted ? (neg ? y : y - h) : x,
+ y: inverted ? plotHeight - x - xWidth : (neg ? (plotHeight - y - h) : plotHeight - y),
+ width: inverted ? h : xWidth,
+ height: inverted ? xWidth : h
+ };
+
+ if (stackItem.label) {
+ stackItem.label
+ .align(stackItem.alignOptions, null, stackBox) // align the label to the box
+ .attr({visibility: VISIBLE}); // set visibility
+ }
+ }
+ };
+
+ /**
+ * Get the minimum and maximum for the series of each axis
+ */
+ function getSeriesExtremes() {
+ var posStack = [],
+ negStack = [],
+ i;
+
+ // reset dataMin and dataMax in case we're redrawing
+ dataMin = dataMax = null;
+
+ // loop through this axis' series
+ each(axis.series, function (series) {
+
+ if (series.visible || !optionsChart.ignoreHiddenSeries) {
+
+ var seriesOptions = series.options,
+ stacking,
+ posPointStack,
+ negPointStack,
+ stackKey,
+ stackOption,
+ negKey,
+ xData,
+ yData,
+ x,
+ y,
+ threshold = seriesOptions.threshold,
+ yDataLength,
+ activeYData = [],
+ activeCounter = 0;
+
+ // Get dataMin and dataMax for X axes
+ if (isXAxis) {
+ xData = series.xData;
+ if (xData.length) {
+ dataMin = mathMin(pick(dataMin, xData[0]), arrayMin(xData));
+ dataMax = mathMax(pick(dataMax, xData[0]), arrayMax(xData));
+ }
+
+ // Get dataMin and dataMax for Y axes, as well as handle stacking and processed data
+ } else {
+ var isNegative,
+ pointStack,
+ key,
+ cropped = series.cropped,
+ xExtremes = series.xAxis.getExtremes(),
+ //findPointRange,
+ //pointRange,
+ j,
+ hasModifyValue = !!series.modifyValue;
+
+
+ // Handle stacking
+ stacking = seriesOptions.stacking;
+ usePercentage = stacking === 'percent';
+
+ // create a stack for this particular series type
+ if (stacking) {
+ stackOption = seriesOptions.stack;
+ stackKey = series.type + pick(stackOption, '');
+ negKey = '-' + stackKey;
+ series.stackKey = stackKey; // used in translate
+
+ posPointStack = posStack[stackKey] || []; // contains the total values for each x
+ posStack[stackKey] = posPointStack;
+
+ negPointStack = negStack[negKey] || [];
+ negStack[negKey] = negPointStack;
+ }
+ if (usePercentage) {
+ dataMin = 0;
+ dataMax = 99;
+ }
+
+
+ // processData can alter series.pointRange, so this goes after
+ //findPointRange = series.pointRange === null;
+
+ xData = series.processedXData;
+ yData = series.processedYData;
+ yDataLength = yData.length;
+
+
+ // loop over the non-null y values and read them into a local array
+ for (i = 0; i < yDataLength; i++) {
+ x = xData[i];
+ y = yData[i];
+ if (y !== null && y !== UNDEFINED) {
+
+ // read stacked values into a stack based on the x value,
+ // the sign of y and the stack key
+ if (stacking) {
+ isNegative = y < threshold;
+ pointStack = isNegative ? negPointStack : posPointStack;
+ key = isNegative ? negKey : stackKey;
+
+ y = pointStack[x] =
+ defined(pointStack[x]) ?
+ pointStack[x] + y : y;
+
+
+ // add the series
+ if (!stacks[key]) {
+ stacks[key] = {};
+ }
+
+ // If the StackItem is there, just update the values,
+ // if not, create one first
+ if (!stacks[key][x]) {
+ stacks[key][x] = new StackItem(options.stackLabels, isNegative, x, stackOption);
+ }
+ stacks[key][x].setTotal(y);
+
+
+ // general hook, used for Highstock compare values feature
+ } else if (hasModifyValue) {
+ y = series.modifyValue(y);
+ }
+
+ // get the smallest distance between points
+ /*if (i) {
+ distance = mathAbs(xData[i] - xData[i - 1]);
+ pointRange = pointRange === UNDEFINED ? distance : mathMin(distance, pointRange);
+ }*/
+
+ // for points within the visible range, including the first point outside the
+ // visible range, consider y extremes
+ if (cropped || ((xData[i + 1] || x) >= xExtremes.min && (xData[i - 1] || x) <= xExtremes.max)) {
+
+ j = y.length;
+ if (j) { // array, like ohlc data
+ while (j--) {
+ if (y[j] !== null) {
+ activeYData[activeCounter++] = y[j];
+ }
+ }
+ } else {
+ activeYData[activeCounter++] = y;
+ }
+ }
+ }
+ }
+
+ // record the least unit distance
+ /*if (findPointRange) {
+ series.pointRange = pointRange || 1;
+ }
+ series.closestPointRange = pointRange;*/
+
+
+ // Get the dataMin and dataMax so far. If percentage is used, the min and max are
+ // always 0 and 100. If the length of activeYData is 0, continue with null values.
+ if (!usePercentage && activeYData.length) {
+ dataMin = mathMin(pick(dataMin, activeYData[0]), arrayMin(activeYData));
+ dataMax = mathMax(pick(dataMax, activeYData[0]), arrayMax(activeYData));
+ }
+
+
+ // todo: instead of checking useThreshold, just set the threshold to 0
+ // in area and column-like chart types
+ if (series.useThreshold && threshold !== null) {
+ if (dataMin >= threshold) {
+ dataMin = threshold;
+ ignoreMinPadding = true;
+ } else if (dataMax < threshold) {
+ dataMax = threshold;
+ ignoreMaxPadding = true;
+ }
+ }
+ }
+ }
+ });
+
+ }
+
+ /**
+ * Translate from axis value to pixel position on the chart, or back
+ *
+ */
+ translate = function (val, backwards, cvsCoord, old, handleLog) {
+ var sign = 1,
+ cvsOffset = 0,
+ localA = old ? oldTransA : transA,
+ localMin = old ? oldMin : min,
+ returnValue,
+ postTranslate = options.ordinal || (isLog && handleLog);
+
+ if (!localA) {
+ localA = transA;
+ }
+
+ if (cvsCoord) {
+ sign *= -1; // canvas coordinates inverts the value
+ cvsOffset = axisLength;
+ }
+ if (reversed) { // reversed axis
+ sign *= -1;
+ cvsOffset -= sign * axisLength;
+ }
+
+ if (backwards) { // reverse translation
+ if (reversed) {
+ val = axisLength - val;
+ }
+ returnValue = val / localA + localMin; // from chart pixel to value
+ if (postTranslate) { // log and ordinal axes
+ returnValue = axis.lin2val(returnValue);
+ }
+
+ } else { // normal translation, from axis value to pixel, relative to plot
+ if (postTranslate) { // log and ordinal axes
+ val = axis.val2lin(val);
+ }
+
+ returnValue = sign * (val - localMin) * localA + cvsOffset + (sign * minPixelPadding);
+ }
+
+ return returnValue;
+ };
+
+ /**
+ * Create the path for a plot line that goes from the given value on
+ * this axis, across the plot to the opposite side
+ * @param {Number} value
+ * @param {Number} lineWidth Used for calculation crisp line
+ * @param {Number] old Use old coordinates (for resizing and rescaling)
+ */
+ getPlotLinePath = function (value, lineWidth, old) {
+ var x1,
+ y1,
+ x2,
+ y2,
+ translatedValue = translate(value, null, null, old),
+ cHeight = (old && oldChartHeight) || chartHeight,
+ cWidth = (old && oldChartWidth) || chartWidth,
+ skip;
+
+ x1 = x2 = mathRound(translatedValue + transB);
+ y1 = y2 = mathRound(cHeight - translatedValue - transB);
+
+ if (isNaN(translatedValue)) { // no min or max
+ skip = true;
+
+ } else if (horiz) {
+ y1 = axisTop;
+ y2 = cHeight - axisBottom;
+ if (x1 < axisLeft || x1 > axisLeft + axisWidth) {
+ skip = true;
+ }
+ } else {
+ x1 = axisLeft;
+ x2 = cWidth - axisRight;
+
+ if (y1 < axisTop || y1 > axisTop + axisHeight) {
+ skip = true;
+ }
+ }
+ return skip ?
+ null :
+ renderer.crispLine([M, x1, y1, L, x2, y2], lineWidth || 0);
+ };
+
+ /**
+ * Fix JS round off float errors
+ * @param {Number} num
+ */
+ function correctFloat(num) {
+ var invMag, ret = num;
+ magnitude = pick(magnitude, math.pow(10, mathFloor(math.log(tickInterval) / math.LN10)));
+
+ if (magnitude < 1) {
+ invMag = mathRound(1 / magnitude) * 10;
+ ret = mathRound(num * invMag) / invMag;
+ }
+ return ret;
+ }
+
+ /**
+ * Set the tick positions of a linear axis to round values like whole tens or every five.
+ */
+ function setLinearTickPositions() {
+
+ var pos,
+ lastPos,
+ roundedMin = correctFloat(mathFloor(min / tickInterval) * tickInterval),
+ roundedMax = correctFloat(mathCeil(max / tickInterval) * tickInterval);
+
+ tickPositions = [];
+
+ // Populate the intermediate values
+ pos = roundedMin;
+ while (pos <= roundedMax) {
+
+ // Place the tick on the rounded value
+ tickPositions.push(pos);
+
+ // Always add the raw tickInterval, not the corrected one.
+ pos = correctFloat(pos + tickInterval);
+
+ // If the interval is not big enough in the current min - max range to actually increase
+ // the loop variable, we need to break out to prevent endless loop. Issue #619
+ if (pos === lastPos) {
+ break;
+ }
+
+ // Record the last value
+ lastPos = pos;
+ }
+ }
+
+ /**
+ * Adjust the min and max for the minimum range. Keep in mind that the series data is
+ * not yet processed, so we don't have information on data cropping and grouping, or
+ * updated axis.pointRange or series.pointRange. The data can't be processed until
+ * we have finally established min and max.
+ */
+ function adjustForMinRange() {
+ var zoomOffset,
+ spaceAvailable = dataMax - dataMin >= minRange,
+ closestDataRange,
+ i,
+ distance,
+ xData,
+ loopLength,
+ minArgs,
+ maxArgs;
+
+ // Set the automatic minimum range based on the closest point distance
+ if (isXAxis && minRange === UNDEFINED) {
+
+ if (defined(options.min) || defined(options.max)) {
+ minRange = null; // don't do this again
+
+ } else {
+
+ // Find the closest distance between raw data points, as opposed to
+ // closestPointRange that applies to processed points (cropped and grouped)
+ each(axis.series, function (series) {
+ xData = series.xData;
+ loopLength = series.xIncrement ? 1 : xData.length - 1;
+ for (i = loopLength; i > 0; i--) {
+ distance = xData[i] - xData[i - 1];
+ if (closestDataRange === UNDEFINED || distance < closestDataRange) {
+ closestDataRange = distance;
+ }
+ }
+ });
+ minRange = mathMin(closestDataRange * 5, dataMax - dataMin);
+ }
+ }
+
+ // if minRange is exceeded, adjust
+ if (max - min < minRange) {
+
+ zoomOffset = (minRange - max + min) / 2;
+
+ // if min and max options have been set, don't go beyond it
+ minArgs = [min - zoomOffset, pick(options.min, min - zoomOffset)];
+ if (spaceAvailable) { // if space is available, stay within the data range
+ minArgs[2] = dataMin;
+ }
+ min = arrayMax(minArgs);
+
+ maxArgs = [min + minRange, pick(options.max, min + minRange)];
+ if (spaceAvailable) { // if space is availabe, stay within the data range
+ maxArgs[2] = dataMax;
+ }
+
+ max = arrayMin(maxArgs);
+
+ // now if the max is adjusted, adjust the min back
+ if (max - min < minRange) {
+ minArgs[0] = max - minRange;
+ minArgs[1] = pick(options.min, max - minRange);
+ min = arrayMax(minArgs);
+ }
+ }
+ }
+
+ /**
+ * Set the tick positions to round values and optionally extend the extremes
+ * to the nearest tick
+ */
+ function setTickPositions(secondPass) {
+
+ var length,
+ linkedParent,
+ linkedParentExtremes,
+ tickIntervalOption = options.tickInterval,
+ tickPixelIntervalOption = options.tickPixelInterval;
+
+ // linked axis gets the extremes from the parent axis
+ if (isLinked) {
+ linkedParent = chart[isXAxis ? 'xAxis' : 'yAxis'][options.linkedTo];
+ linkedParentExtremes = linkedParent.getExtremes();
+ min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
+ max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
+ } else { // initial min and max from the extreme data values
+ min = pick(userMin, options.min, dataMin);
+ max = pick(userMax, options.max, dataMax);
+ }
+
+ if (isLog) {
+ min = log2lin(min);
+ max = log2lin(max);
+ }
+
+ // handle zoomed range
+ if (range) {
+ userMin = min = mathMax(min, max - range); // #618
+ userMax = max;
+ if (secondPass) {
+ range = null; // don't use it when running setExtremes
+ }
+ }
+
+ // adjust min and max for the minimum range
+ adjustForMinRange();
+
+ // pad the values to get clear of the chart's edges
+ if (!categories && !usePercentage && !isLinked && defined(min) && defined(max)) {
+ length = (max - min) || 1;
+ if (!defined(options.min) && !defined(userMin) && minPadding && (dataMin < 0 || !ignoreMinPadding)) {
+ min -= length * minPadding;
+ }
+ if (!defined(options.max) && !defined(userMax) && maxPadding && (dataMax > 0 || !ignoreMaxPadding)) {
+ max += length * maxPadding;
+ }
+ }
+
+ // get tickInterval
+ if (min === max || min === undefined || max === undefined) {
+ tickInterval = 1;
+ } else if (isLinked && !tickIntervalOption &&
+ tickPixelIntervalOption === linkedParent.options.tickPixelInterval) {
+ tickInterval = linkedParent.tickInterval;
+ } else {
+ tickInterval = pick(
+ tickIntervalOption,
+ categories ? // for categoried axis, 1 is default, for linear axis use tickPix
+ 1 :
+ (max - min) * tickPixelIntervalOption / (axisLength || 1)
+ );
+ }
+
+ // Now we're finished detecting min and max, crop and group series data. This
+ // is in turn needed in order to find tick positions in ordinal axes.
+ if (isXAxis && !secondPass) {
+ each(axis.series, function (series) {
+ series.processData(min !== oldMin || max !== oldMax);
+ });
+ }
+
+
+ // set the translation factor used in translate function
+ setAxisTranslation();
+
+ // hook for ordinal axes. To do: merge with below
+ if (axis.beforeSetTickPositions) {
+ axis.beforeSetTickPositions();
+ }
+
+ // hook for extensions, used in Highstock ordinal axes
+ if (axis.postProcessTickInterval) {
+ tickInterval = axis.postProcessTickInterval(tickInterval);
+ }
+
+ // for linear axes, get magnitude and normalize the interval
+ if (!isDatetimeAxis) { // linear
+ magnitude = math.pow(10, mathFloor(math.log(tickInterval) / math.LN10));
+ if (!defined(options.tickInterval)) {
+ tickInterval = normalizeTickInterval(tickInterval, null, magnitude, options);
+ }
+ }
+
+ // record the tick interval for linked axis
+ axis.tickInterval = tickInterval;
+
+ // get minorTickInterval
+ minorTickInterval = options.minorTickInterval === 'auto' && tickInterval ?
+ tickInterval / 5 : options.minorTickInterval;
+
+ // find the tick positions
+ tickPositions = options.tickPositions || (tickPositioner && tickPositioner.apply(axis, [min, max]));
+ if (!tickPositions) {
+ if (isDatetimeAxis) {
+ tickPositions = (axis.getNonLinearTimeTicks || getTimeTicks)(
+ normalizeTimeTickInterval(tickInterval, options.units),
+ min,
+ max,
+ options.startOfWeek,
+ axis.ordinalPositions,
+ axis.closestPointRange,
+ true
+ );
+ } else {
+ setLinearTickPositions();
+ }
+ }
+
+ // post process positions, used in ordinal axes in Highstock.
+ // TODO: combine with getNonLinearTimeTicks
+ fireEvent(axis, 'afterSetTickPositions', {
+ tickPositions: tickPositions
+ });
+
+
+ if (!isLinked) {
+
+ // reset min/max or remove extremes based on start/end on tick
+ var roundedMin = tickPositions[0],
+ roundedMax = tickPositions[tickPositions.length - 1];
+
+ if (options.startOnTick) {
+ min = roundedMin;
+ } else if (min > roundedMin) {
+ tickPositions.shift();
+ }
+
+ if (options.endOnTick) {
+ max = roundedMax;
+ } else if (max < roundedMax) {
+ tickPositions.pop();
+ }
+
+ // record the greatest number of ticks for multi axis
+ if (!maxTicks) { // first call, or maxTicks have been reset after a zoom operation
+ maxTicks = {
+ x: 0,
+ y: 0
+ };
+ }
+
+ if (!isDatetimeAxis && tickPositions.length > maxTicks[xOrY] && options.alignTicks !== false) {
+ maxTicks[xOrY] = tickPositions.length;
+ }
+ }
+ }
+
+ /**
+ * When using multiple axes, adjust the number of ticks to match the highest
+ * number of ticks in that group
+ */
+ function adjustTickAmount() {
+
+ if (maxTicks && maxTicks[xOrY] && !isDatetimeAxis && !categories && !isLinked && options.alignTicks !== false) { // only apply to linear scale
+ var oldTickAmount = tickAmount,
+ calculatedTickAmount = tickPositions.length;
+
+ // set the axis-level tickAmount to use below
+ tickAmount = maxTicks[xOrY];
+
+ if (calculatedTickAmount < tickAmount) {
+ while (tickPositions.length < tickAmount) {
+ tickPositions.push(correctFloat(
+ tickPositions[tickPositions.length - 1] + tickInterval
+ ));
+ }
+ transA *= (calculatedTickAmount - 1) / (tickAmount - 1);
+ max = tickPositions[tickPositions.length - 1];
+
+ }
+ if (defined(oldTickAmount) && tickAmount !== oldTickAmount) {
+ axis.isDirty = true;
+ }
+ }
+
+
+ }
+
+ /**
+ * Set the scale based on data min and max, user set min and max or options
+ *
+ */
+ function setScale() {
+ var type,
+ i,
+ isDirtyData;
+
+ oldMin = min;
+ oldMax = max;
+ oldAxisLength = axisLength;
+
+ // set the new axisLength
+ axisLength = horiz ? axisWidth : axisHeight;
+
+ // is there new data?
+ each(axis.series, function (series) {
+ if (series.isDirtyData || series.isDirty ||
+ series.xAxis.isDirty) { // when x axis is dirty, we need new data extremes for y as well
+ isDirtyData = true;
+ }
+ });
+
+ // do we really need to go through all this?
+ if (axisLength !== oldAxisLength || isDirtyData || isLinked ||
+ userMin !== oldUserMin || userMax !== oldUserMax) {
+
+ // get data extremes if needed
+ getSeriesExtremes();
+
+ // get fixed positions based on tickInterval
+ setTickPositions();
+
+ // record old values to decide whether a rescale is necessary later on (#540)
+ oldUserMin = userMin;
+ oldUserMax = userMax;
+
+ // reset stacks
+ if (!isXAxis) {
+ for (type in stacks) {
+ for (i in stacks[type]) {
+ stacks[type][i].cum = stacks[type][i].total;
+ }
+ }
+ }
+
+ // Mark as dirty if it is not already set to dirty and extremes have changed. #595.
+ if (!axis.isDirty) {
+ axis.isDirty = chart.isDirtyBox || min !== oldMin || max !== oldMax;
+ }
+ }
+ }
+
+ /**
+ * Set the extremes and optionally redraw
+ * @param {Number} newMin
+ * @param {Number} newMax
+ * @param {Boolean} redraw
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ *
+ */
+ function setExtremes(newMin, newMax, redraw, animation) {
+
+ redraw = pick(redraw, true); // defaults to true
+
+ fireEvent(axis, 'setExtremes', { // fire an event to enable syncing of multiple charts
+ min: newMin,
+ max: newMax
+ }, function () { // the default event handler
+
+ userMin = newMin;
+ userMax = newMax;
+
+ // redraw
+ if (redraw) {
+ chart.redraw(animation);
+ }
+ });
+ }
+
+ /**
+ * Update translation information
+ */
+ setAxisTranslation = function () {
+ var range = max - min,
+ pointRange = 0,
+ closestPointRange,
+ seriesClosestPointRange;
+
+ // adjust translation for padding
+ if (isXAxis) {
+ each(axis.series, function (series) {
+ pointRange = mathMax(pointRange, series.pointRange);
+ seriesClosestPointRange = series.closestPointRange;
+ if (!series.noSharedTooltip && defined(seriesClosestPointRange)) {
+ closestPointRange = defined(closestPointRange) ?
+ mathMin(closestPointRange, seriesClosestPointRange) :
+ seriesClosestPointRange;
+ }
+ });
+ // pointRange means the width reserved for each point, like in a column chart
+ axis.pointRange = pointRange;
+
+ // closestPointRange means the closest distance between points. In columns
+ // it is mostly equal to pointRange, but in lines pointRange is 0 while closestPointRange
+ // is some other value
+ axis.closestPointRange = closestPointRange;
+ }
+
+ // secondary values
+ oldTransA = transA;
+ axis.translationSlope = transA = axisLength / ((range + pointRange) || 1);
+ transB = horiz ? axisLeft : axisBottom; // translation addend
+ minPixelPadding = transA * (pointRange / 2);
+ };
+
+ /**
+ * Update the axis metrics
+ */
+ function setAxisSize() {
+
+ var offsetLeft = options.offsetLeft || 0,
+ offsetRight = options.offsetRight || 0;
+
+ // basic values
+ axisLeft = pick(options.left, plotLeft + offsetLeft);
+ axisTop = pick(options.top, plotTop);
+ axisWidth = pick(options.width, plotWidth - offsetLeft + offsetRight);
+ axisHeight = pick(options.height, plotHeight);
+ axisBottom = chartHeight - axisHeight - axisTop;
+ axisRight = chartWidth - axisWidth - axisLeft;
+ axisLength = horiz ? axisWidth : axisHeight;
+
+ // expose to use in Series object and navigator
+ axis.left = axisLeft;
+ axis.top = axisTop;
+ axis.len = axisLength;
+
+ }
+
+ /**
+ * Get the actual axis extremes
+ */
+ function getExtremes() {
+ return {
+ min: min,
+ max: max,
+ dataMin: dataMin,
+ dataMax: dataMax,
+ userMin: userMin,
+ userMax: userMax
+ };
+ }
+
+ /**
+ * Get the zero plane either based on zero or on the min or max value.
+ * Used in bar and area plots
+ */
+ function getThreshold(threshold) {
+ if (min > threshold || threshold === null) {
+ threshold = min;
+ } else if (max < threshold) {
+ threshold = max;
+ }
+
+ return translate(threshold, 0, 1);
+ }
+
+ /**
+ * Add a plot band or plot line after render time
+ *
+ * @param options {Object} The plotBand or plotLine configuration object
+ */
+ function addPlotBandOrLine(options) {
+ var obj = new PlotLineOrBand(options).render();
+ plotLinesAndBands.push(obj);
+ return obj;
+ }
+
+ /**
+ * Render the tick labels to a preliminary position to get their sizes
+ */
+ function getOffset() {
+
+ var hasData = axis.series.length && defined(min) && defined(max),
+ showAxis = hasData || pick(options.showEmpty, true),
+ titleOffset = 0,
+ titleMargin = 0,
+ axisTitleOptions = options.title,
+ labelOptions = options.labels,
+ directionFactor = [-1, 1, 1, -1][side],
+ n;
+
+ if (!axisGroup) {
+ axisGroup = renderer.g('axis')
+ .attr({ zIndex: 7 })
+ .add();
+ gridGroup = renderer.g('grid')
+ .attr({ zIndex: options.gridZIndex || 1 })
+ .add();
+ }
+
+ labelOffset = 0; // reset
+
+ if (hasData || isLinked) {
+ each(tickPositions, function (pos) {
+ if (!ticks[pos]) {
+ ticks[pos] = new Tick(pos);
+ } else {
+ ticks[pos].addLabel(); // update labels depending on tick interval
+ }
+
+ });
+
+ each(tickPositions, function (pos) {
+ // left side must be align: right and right side must have align: left for labels
+ if (side === 0 || side === 2 || { 1: 'left', 3: 'right' }[side] === labelOptions.align) {
+
+ // get the highest offset
+ labelOffset = mathMax(
+ ticks[pos].getLabelSize(),
+ labelOffset
+ );
+ }
+
+ });
+
+ if (staggerLines) {
+ labelOffset += (staggerLines - 1) * 16;
+ }
+
+ } else { // doesn't have data
+ for (n in ticks) {
+ ticks[n].destroy();
+ delete ticks[n];
+ }
+ }
+
+ if (axisTitleOptions && axisTitleOptions.text) {
+ if (!axisTitle) {
+ axisTitle = axis.axisTitle = renderer.text(
+ axisTitleOptions.text,
+ 0,
+ 0,
+ axisTitleOptions.useHTML
+ )
+ .attr({
+ zIndex: 7,
+ rotation: axisTitleOptions.rotation || 0,
+ align:
+ axisTitleOptions.textAlign ||
+ { low: 'left', middle: 'center', high: 'right' }[axisTitleOptions.align]
+ })
+ .css(axisTitleOptions.style)
+ .add();
+ axisTitle.isNew = true;
+ }
+
+ if (showAxis) {
+ titleOffset = axisTitle.getBBox()[horiz ? 'height' : 'width'];
+ titleMargin = pick(axisTitleOptions.margin, horiz ? 5 : 10);
+ }
+
+ // hide or show the title depending on whether showEmpty is set
+ axisTitle[showAxis ? 'show' : 'hide']();
+
+
+ }
+
+ // handle automatic or user set offset
+ offset = directionFactor * pick(options.offset, axisOffset[side]);
+
+ axisTitleMargin =
+ pick(axisTitleOptions.offset,
+ labelOffset + titleMargin +
+ (side !== 2 && labelOffset && directionFactor * options.labels[horiz ? 'y' : 'x'])
+ );
+
+ axisOffset[side] = mathMax(
+ axisOffset[side],
+ axisTitleMargin + titleOffset + directionFactor * offset
+ );
+
+ }
+
+ /**
+ * Render the axis
+ */
+ function render() {
+ var axisTitleOptions = options.title,
+ stackLabelOptions = options.stackLabels,
+ alternateGridColor = options.alternateGridColor,
+ lineWidth = options.lineWidth,
+ lineLeft,
+ lineTop,
+ linePath,
+ hasRendered = chart.hasRendered,
+ slideInTicks = hasRendered && defined(oldMin) && !isNaN(oldMin),
+ hasData = axis.series.length && defined(min) && defined(max),
+ showAxis = hasData || pick(options.showEmpty, true);
+
+ // If the series has data draw the ticks. Else only the line and title
+ if (hasData || isLinked) {
+
+ // minor ticks
+ if (minorTickInterval && !categories) {
+ var pos = min + (tickPositions[0] - min) % minorTickInterval;
+ for (; pos <= max; pos += minorTickInterval) {
+ if (!minorTicks[pos]) {
+ minorTicks[pos] = new Tick(pos, 'minor');
+ }
+
+ // render new ticks in old position
+ if (slideInTicks && minorTicks[pos].isNew) {
+ minorTicks[pos].render(null, true);
+ }
+
+
+ minorTicks[pos].isActive = true;
+ minorTicks[pos].render();
+ }
+ }
+
+ // major ticks
+ each(tickPositions, function (pos, i) {
+ // linked axes need an extra check to find out if
+ if (!isLinked || (pos >= min && pos <= max)) {
+
+ if (!ticks[pos]) {
+ ticks[pos] = new Tick(pos);
+ }
+
+ // render new ticks in old position
+ if (slideInTicks && ticks[pos].isNew) {
+ ticks[pos].render(i, true);
+ }
+
+ ticks[pos].isActive = true;
+ ticks[pos].render(i);
+ }
+
+ });
+
+ // alternate grid color
+ if (alternateGridColor) {
+ each(tickPositions, function (pos, i) {
+ if (i % 2 === 0 && pos < max) {
+ if (!alternateBands[pos]) {
+ alternateBands[pos] = new PlotLineOrBand();
+ }
+ alternateBands[pos].options = {
+ from: pos,
+ to: tickPositions[i + 1] !== UNDEFINED ? tickPositions[i + 1] : max,
+ color: alternateGridColor
+ };
+ alternateBands[pos].render();
+ alternateBands[pos].isActive = true;
+ }
+ });
+ }
+
+ // custom plot lines and bands
+ if (!axis._addedPlotLB) { // only first time
+ each((options.plotLines || []).concat(options.plotBands || []), function (plotLineOptions) {
+ //plotLinesAndBands.push(new PlotLineOrBand(plotLineOptions).render());
+ addPlotBandOrLine(plotLineOptions);
+ });
+ axis._addedPlotLB = true;
+ }
+
+
+
+ } // end if hasData
+
+ // remove inactive ticks
+ each([ticks, minorTicks, alternateBands], function (coll) {
+ var pos;
+ for (pos in coll) {
+ if (!coll[pos].isActive) {
+ coll[pos].destroy();
+ delete coll[pos];
+ } else {
+ coll[pos].isActive = false; // reset
+ }
+ }
+ });
+
+
+
+
+ // Static items. As the axis group is cleared on subsequent calls
+ // to render, these items are added outside the group.
+ // axis line
+ if (lineWidth) {
+ lineLeft = axisLeft + (opposite ? axisWidth : 0) + offset;
+ lineTop = chartHeight - axisBottom - (opposite ? axisHeight : 0) + offset;
+
+ linePath = renderer.crispLine([
+ M,
+ horiz ?
+ axisLeft :
+ lineLeft,
+ horiz ?
+ lineTop :
+ axisTop,
+ L,
+ horiz ?
+ chartWidth - axisRight :
+ lineLeft,
+ horiz ?
+ lineTop :
+ chartHeight - axisBottom
+ ], lineWidth);
+ if (!axisLine) {
+ axisLine = renderer.path(linePath)
+ .attr({
+ stroke: options.lineColor,
+ 'stroke-width': lineWidth,
+ zIndex: 7
+ })
+ .add();
+ } else {
+ axisLine.animate({ d: linePath });
+ }
+
+ // show or hide the line depending on options.showEmpty
+ axisLine[showAxis ? 'show' : 'hide']();
+
+ }
+
+ if (axisTitle && showAxis) {
+ // compute anchor points for each of the title align options
+ var margin = horiz ? axisLeft : axisTop,
+ fontSize = pInt(axisTitleOptions.style.fontSize || 12),
+ // the position in the length direction of the axis
+ alongAxis = {
+ low: margin + (horiz ? 0 : axisLength),
+ middle: margin + axisLength / 2,
+ high: margin + (horiz ? axisLength : 0)
+ }[axisTitleOptions.align],
+
+ // the position in the perpendicular direction of the axis
+ offAxis = (horiz ? axisTop + axisHeight : axisLeft) +
+ (horiz ? 1 : -1) * // horizontal axis reverses the margin
+ (opposite ? -1 : 1) * // so does opposite axes
+ axisTitleMargin +
+ (side === 2 ? fontSize : 0);
+
+ axisTitle[axisTitle.isNew ? 'attr' : 'animate']({
+ x: horiz ?
+ alongAxis :
+ offAxis + (opposite ? axisWidth : 0) + offset +
+ (axisTitleOptions.x || 0), // x
+ y: horiz ?
+ offAxis - (opposite ? axisHeight : 0) + offset :
+ alongAxis + (axisTitleOptions.y || 0) // y
+ });
+ axisTitle.isNew = false;
+ }
+
+ // Stacked totals:
+ if (stackLabelOptions && stackLabelOptions.enabled) {
+ var stackKey, oneStack, stackCategory,
+ stackTotalGroup = axis.stackTotalGroup;
+
+ // Create a separate group for the stack total labels
+ if (!stackTotalGroup) {
+ axis.stackTotalGroup = stackTotalGroup =
+ renderer.g('stack-labels')
+ .attr({
+ visibility: VISIBLE,
+ zIndex: 6
+ })
+ .translate(plotLeft, plotTop)
+ .add();
+ }
+
+ // Render each stack total
+ for (stackKey in stacks) {
+ oneStack = stacks[stackKey];
+ for (stackCategory in oneStack) {
+ oneStack[stackCategory].render(stackTotalGroup);
+ }
+ }
+ }
+ // End stacked totals
+
+ axis.isDirty = false;
+ }
+
+ /**
+ * Remove a plot band or plot line from the chart by id
+ * @param {Object} id
+ */
+ function removePlotBandOrLine(id) {
+ var i = plotLinesAndBands.length;
+ while (i--) {
+ if (plotLinesAndBands[i].id === id) {
+ plotLinesAndBands[i].destroy();
+ }
+ }
+ }
+
+ /**
+ * Redraw the axis to reflect changes in the data or axis extremes
+ */
+ function redraw() {
+
+ // hide tooltip and hover states
+ if (tracker.resetTracker) {
+ tracker.resetTracker();
+ }
+
+ // render the axis
+ render();
+
+ // move plot lines and bands
+ each(plotLinesAndBands, function (plotLine) {
+ plotLine.render();
+ });
+
+ // mark associated series as dirty and ready for redraw
+ each(axis.series, function (series) {
+ series.isDirty = true;
+ });
+
+ }
+
+ /**
+ * Set new axis categories and optionally redraw
+ * @param {Array} newCategories
+ * @param {Boolean} doRedraw
+ */
+ function setCategories(newCategories, doRedraw) {
+ // set the categories
+ axis.categories = userOptions.categories = categories = newCategories;
+
+ // force reindexing tooltips
+ each(axis.series, function (series) {
+ series.translate();
+ series.setTooltipPoints(true);
+ });
+
+
+ // optionally redraw
+ axis.isDirty = true;
+
+ if (pick(doRedraw, true)) {
+ chart.redraw();
+ }
+ }
+
+ /**
+ * Destroys an Axis instance.
+ */
+ function destroy() {
+ var stackKey;
+
+ // Remove the events
+ removeEvent(axis);
+
+ // Destroy each stack total
+ for (stackKey in stacks) {
+ destroyObjectProperties(stacks[stackKey]);
+
+ stacks[stackKey] = null;
+ }
+
+ // Destroy stack total group
+ if (axis.stackTotalGroup) {
+ axis.stackTotalGroup = axis.stackTotalGroup.destroy();
+ }
+
+ // Destroy collections
+ each([ticks, minorTicks, alternateBands, plotLinesAndBands], function (coll) {
+ destroyObjectProperties(coll);
+ });
+
+ // Destroy local variables
+ each([axisLine, axisGroup, gridGroup, axisTitle], function (obj) {
+ if (obj) {
+ obj.destroy();
+ }
+ });
+ axisLine = axisGroup = gridGroup = axisTitle = null;
+ }
+
+
+ // Run Axis
+
+ // Register
+ axes.push(axis);
+ chart[isXAxis ? 'xAxis' : 'yAxis'].push(axis);
+
+ // inverted charts have reversed xAxes as default
+ if (inverted && isXAxis && reversed === UNDEFINED) {
+ reversed = true;
+ }
+
+
+ // expose some variables
+ extend(axis, {
+ addPlotBand: addPlotBandOrLine,
+ addPlotLine: addPlotBandOrLine,
+ adjustTickAmount: adjustTickAmount,
+ categories: categories,
+ getExtremes: getExtremes,
+ getPlotLinePath: getPlotLinePath,
+ getThreshold: getThreshold,
+ isXAxis: isXAxis,
+ options: options,
+ plotLinesAndBands: plotLinesAndBands,
+ getOffset: getOffset,
+ render: render,
+ setAxisSize: setAxisSize,
+ setAxisTranslation: setAxisTranslation,
+ setCategories: setCategories,
+ setExtremes: setExtremes,
+ setScale: setScale,
+ setTickPositions: setTickPositions,
+ translate: translate,
+ redraw: redraw,
+ removePlotBand: removePlotBandOrLine,
+ removePlotLine: removePlotBandOrLine,
+ reversed: reversed,
+ series: [], // populated by Series
+ stacks: stacks,
+ destroy: destroy
+ });
+
+ // register event listeners
+ for (eventType in events) {
+ addEvent(axis, eventType, events[eventType]);
+ }
+
+ // extend logarithmic axis
+ if (isLog) {
+ axis.val2lin = log2lin;
+ axis.lin2val = lin2log;
+ }
+
+ } // end Axis
+
+
+ /**
+ * The tooltip object
+ * @param {Object} options Tooltip options
+ */
+ function Tooltip(options) {
+ var currentSeries,
+ borderWidth = options.borderWidth,
+ crosshairsOptions = options.crosshairs,
+ crosshairs = [],
+ style = options.style,
+ shared = options.shared,
+ padding = pInt(style.padding),
+ tooltipIsHidden = true,
+ currentX = 0,
+ currentY = 0;
+
+ // remove padding CSS and apply padding on box instead
+ style.padding = 0;
+
+ // create the label
+ var label = renderer.label('', 0, 0)
+ .attr({
+ padding: padding,
+ fill: options.backgroundColor,
+ 'stroke-width': borderWidth,
+ r: options.borderRadius,
+ zIndex: 8
+ })
+ .css(style)
+ .hide()
+ .add()
+ .shadow(options.shadow);
+
+ /**
+ * Destroy the tooltip and its elements.
+ */
+ function destroy() {
+ each(crosshairs, function (crosshair) {
+ if (crosshair) {
+ crosshair.destroy();
+ }
+ });
+
+ // Destroy and clear local variables
+ if (label) {
+ label = label.destroy();
+ }
+ }
+
+ /**
+ * In case no user defined formatter is given, this will be used
+ */
+ function defaultFormatter() {
+ var pThis = this,
+ items = pThis.points || splat(pThis),
+ series = items[0].series,
+ s;
+
+ // build the header
+ s = [series.tooltipHeaderFormatter(items[0].key)];
+
+ // build the values
+ each(items, function (item) {
+ series = item.series;
+ s.push((series.tooltipFormatter && series.tooltipFormatter(item)) ||
+ item.point.tooltipFormatter(series.tooltipOptions.pointFormat));
+ });
+ return s.join('');
+ }
+
+ /**
+ * Provide a soft movement for the tooltip
+ *
+ * @param {Number} finalX
+ * @param {Number} finalY
+ */
+ function move(finalX, finalY) {
+
+ // get intermediate values for animation
+ currentX = tooltipIsHidden ? finalX : (2 * currentX + finalX) / 3;
+ currentY = tooltipIsHidden ? finalY : (currentY + finalY) / 2;
+
+ // move to the intermediate value
+ label.attr({ x: currentX, y: currentY });
+
+ // run on next tick of the mouse tracker
+ if (mathAbs(finalX - currentX) > 1 || mathAbs(finalY - currentY) > 1) {
+ tooltipTick = function () {
+ move(finalX, finalY);
+ };
+ } else {
+ tooltipTick = null;
+ }
+ }
+
+ /**
+ * Hide the tooltip
+ */
+ function hide() {
+ if (!tooltipIsHidden) {
+ var hoverPoints = chart.hoverPoints;
+
+ label.hide();
+
+ // hide previous hoverPoints and set new
+ if (hoverPoints) {
+ each(hoverPoints, function (point) {
+ point.setState();
+ });
+ }
+ chart.hoverPoints = null;
+
+
+ tooltipIsHidden = true;
+ }
+
+ }
+
+ /**
+ * Hide the crosshairs
+ */
+ function hideCrosshairs() {
+ each(crosshairs, function (crosshair) {
+ if (crosshair) {
+ crosshair.hide();
+ }
+ });
+ }
+
+ /**
+ * Refresh the tooltip's text and position.
+ * @param {Object} point
+ *
+ */
+ function refresh(point) {
+ var x,
+ y,
+ show,
+ plotX,
+ plotY,
+ textConfig = {},
+ text,
+ pointConfig = [],
+ tooltipPos = point.tooltipPos,
+ formatter = options.formatter || defaultFormatter,
+ hoverPoints = chart.hoverPoints,
+ placedTooltipPoint;
+
+ // shared tooltip, array is sent over
+ if (shared && !(point.series && point.series.noSharedTooltip)) {
+ plotY = 0;
+
+ // hide previous hoverPoints and set new
+ if (hoverPoints) {
+ each(hoverPoints, function (point) {
+ point.setState();
+ });
+ }
+ chart.hoverPoints = point;
+
+ each(point, function (item) {
+ item.setState(HOVER_STATE);
+ plotY += item.plotY; // for average
+
+ pointConfig.push(item.getLabelConfig());
+ });
+
+ plotX = point[0].plotX;
+ plotY = mathRound(plotY) / point.length; // mathRound because Opera 10 has problems here
+
+ textConfig = {
+ x: point[0].category
+ };
+ textConfig.points = pointConfig;
+ point = point[0];
+
+ // single point tooltip
+ } else {
+ textConfig = point.getLabelConfig();
+ }
+ text = formatter.call(textConfig);
+
+ // register the current series
+ currentSeries = point.series;
+
+ // get the reference point coordinates (pie charts use tooltipPos)
+ plotX = pick(plotX, point.plotX);
+ plotY = pick(plotY, point.plotY);
+
+ x = mathRound(tooltipPos ? tooltipPos[0] : (inverted ? plotWidth - plotY : plotX));
+ y = mathRound(tooltipPos ? tooltipPos[1] : (inverted ? plotHeight - plotX : plotY));
+
+
+ // For line type series, hide tooltip if the point falls outside the plot
+ show = shared || !currentSeries.isCartesian || currentSeries.tooltipOutsidePlot || isInsidePlot(x, y);
+
+ // update the inner HTML
+ if (text === false || !show) {
+ hide();
+ } else {
+
+ // show it
+ if (tooltipIsHidden) {
+ label.show();
+ tooltipIsHidden = false;
+ }
+
+ // update text
+ label.attr({
+ text: text
+ });
+
+ // set the stroke color of the box
+ label.attr({
+ stroke: options.borderColor || point.color || currentSeries.color || '#606060'
+ });
+
+ placedTooltipPoint = placeBox(
+ label.width,
+ label.height,
+ plotLeft,
+ plotTop,
+ plotWidth,
+ plotHeight,
+ {x: x, y: y},
+ pick(options.distance, 12),
+ inverted
+ );
+
+ // do the move
+ move(mathRound(placedTooltipPoint.x), mathRound(placedTooltipPoint.y));
+ }
+
+
+ // crosshairs
+ if (crosshairsOptions) {
+ crosshairsOptions = splat(crosshairsOptions); // [x, y]
+
+ var path,
+ i = crosshairsOptions.length,
+ attribs,
+ axis;
+
+ while (i--) {
+ axis = point.series[i ? 'yAxis' : 'xAxis'];
+ if (crosshairsOptions[i] && axis) {
+ path = axis
+ .getPlotLinePath(point[i ? 'y' : 'x'], 1);
+ if (crosshairs[i]) {
+ crosshairs[i].attr({ d: path, visibility: VISIBLE });
+
+ } else {
+ attribs = {
+ 'stroke-width': crosshairsOptions[i].width || 1,
+ stroke: crosshairsOptions[i].color || '#C0C0C0',
+ zIndex: crosshairsOptions[i].zIndex || 2
+ };
+ if (crosshairsOptions[i].dashStyle) {
+ attribs.dashstyle = crosshairsOptions[i].dashStyle;
+ }
+ crosshairs[i] = renderer.path(path)
+ .attr(attribs)
+ .add();
+ }
+ }
+ }
+ }
+ }
+
+
+
+ // public members
+ return {
+ shared: shared,
+ refresh: refresh,
+ hide: hide,
+ hideCrosshairs: hideCrosshairs,
+ destroy: destroy
+ };
+ }
+
+ /**
+ * The mouse tracker object
+ * @param {Object} options
+ */
+ function MouseTracker(options) {
+
+
+ var mouseDownX,
+ mouseDownY,
+ hasDragged,
+ selectionMarker,
+ zoomType = optionsChart.zoomType,
+ zoomX = /x/.test(zoomType),
+ zoomY = /y/.test(zoomType),
+ zoomHor = (zoomX && !inverted) || (zoomY && inverted),
+ zoomVert = (zoomY && !inverted) || (zoomX && inverted);
+
+ /**
+ * Add crossbrowser support for chartX and chartY
+ * @param {Object} e The event object in standard browsers
+ */
+ function normalizeMouseEvent(e) {
+ var ePos,
+ chartPosLeft,
+ chartPosTop,
+ chartX,
+ chartY;
+
+ // common IE normalizing
+ e = e || win.event;
+ if (!e.target) {
+ e.target = e.srcElement;
+ }
+
+ // jQuery only copies over some properties. IE needs e.x and iOS needs touches.
+ if (e.originalEvent) {
+ e = e.originalEvent;
+ }
+
+ // The same for MooTools. It renames e.pageX to e.page.x. #445.
+ if (e.event) {
+ e = e.event;
+ }
+
+ // iOS
+ ePos = e.touches ? e.touches.item(0) : e;
+
+ // get mouse position
+ chartPosition = offset(container);
+ chartPosLeft = chartPosition.left;
+ chartPosTop = chartPosition.top;
+
+ // chartX and chartY
+ if (isIE) { // IE including IE9 that has pageX but in a different meaning
+ chartX = e.x;
+ chartY = e.y;
+ } else {
+ chartX = ePos.pageX - chartPosLeft;
+ chartY = ePos.pageY - chartPosTop;
+ }
+
+ return extend(e, {
+ chartX: mathRound(chartX),
+ chartY: mathRound(chartY)
+ });
+ }
+
+ /**
+ * Get the click position in terms of axis values.
+ *
+ * @param {Object} e A mouse event
+ */
+ function getMouseCoordinates(e) {
+ var coordinates = {
+ xAxis: [],
+ yAxis: []
+ };
+ each(axes, function (axis) {
+ var translate = axis.translate,
+ isXAxis = axis.isXAxis,
+ isHorizontal = inverted ? !isXAxis : isXAxis;
+
+ coordinates[isXAxis ? 'xAxis' : 'yAxis'].push({
+ axis: axis,
+ value: translate(
+ isHorizontal ?
+ e.chartX - plotLeft :
+ plotHeight - e.chartY + plotTop,
+ true
+ )
+ });
+ });
+ return coordinates;
+ }
+
+ /**
+ * With line type charts with a single tracker, get the point closest to the mouse
+ */
+ function onmousemove(e) {
+ var point,
+ points,
+ hoverPoint = chart.hoverPoint,
+ hoverSeries = chart.hoverSeries,
+ i,
+ j,
+ distance = chartWidth,
+ index = inverted ? e.chartY : e.chartX - plotLeft; // wtf?
+
+ // shared tooltip
+ if (tooltip && options.shared && !(hoverSeries && hoverSeries.noSharedTooltip)) {
+ points = [];
+
+ // loop over all series and find the ones with points closest to the mouse
+ i = series.length;
+ for (j = 0; j < i; j++) {
+ if (series[j].visible &&
+ series[j].options.enableMouseTracking !== false &&
+ !series[j].noSharedTooltip && series[j].tooltipPoints.length) {
+ point = series[j].tooltipPoints[index];
+ point._dist = mathAbs(index - point.plotX);
+ distance = mathMin(distance, point._dist);
+ points.push(point);
+ }
+ }
+ // remove furthest points
+ i = points.length;
+ while (i--) {
+ if (points[i]._dist > distance) {
+ points.splice(i, 1);
+ }
+ }
+ // refresh the tooltip if necessary
+ if (points.length && (points[0].plotX !== hoverX)) {
+ tooltip.refresh(points);
+ hoverX = points[0].plotX;
+ }
+ }
+
+ // separate tooltip and general mouse events
+ if (hoverSeries && hoverSeries.tracker) { // only use for line-type series with common tracker
+
+ // get the point
+ point = hoverSeries.tooltipPoints[index];
+
+ // a new point is hovered, refresh the tooltip
+ if (point && point !== hoverPoint) {
+
+ // trigger the events
+ point.onMouseOver();
+
+ }
+ }
+ }
+
+
+
+ /**
+ * Reset the tracking by hiding the tooltip, the hover series state and the hover point
+ */
+ function resetTracker() {
+ var hoverSeries = chart.hoverSeries,
+ hoverPoint = chart.hoverPoint;
+
+ if (hoverPoint) {
+ hoverPoint.onMouseOut();
+ }
+
+ if (hoverSeries) {
+ hoverSeries.onMouseOut();
+ }
+
+ if (tooltip) {
+ tooltip.hide();
+ tooltip.hideCrosshairs();
+ }
+
+ hoverX = null;
+ }
+
+ /**
+ * Mouse up or outside the plot area
+ */
+ function drop() {
+ if (selectionMarker) {
+ var selectionData = {
+ xAxis: [],
+ yAxis: []
+ },
+ selectionBox = selectionMarker.getBBox(),
+ selectionLeft = selectionBox.x - plotLeft,
+ selectionTop = selectionBox.y - plotTop;
+
+
+ // a selection has been made
+ if (hasDragged) {
+
+ // record each axis' min and max
+ each(axes, function (axis) {
+ if (axis.options.zoomEnabled !== false) {
+ var translate = axis.translate,
+ isXAxis = axis.isXAxis,
+ isHorizontal = inverted ? !isXAxis : isXAxis,
+ selectionMin = translate(
+ isHorizontal ?
+ selectionLeft :
+ plotHeight - selectionTop - selectionBox.height,
+ true,
+ 0,
+ 0,
+ 1
+ ),
+ selectionMax = translate(
+ isHorizontal ?
+ selectionLeft + selectionBox.width :
+ plotHeight - selectionTop,
+ true,
+ 0,
+ 0,
+ 1
+ );
+
+ selectionData[isXAxis ? 'xAxis' : 'yAxis'].push({
+ axis: axis,
+ min: mathMin(selectionMin, selectionMax), // for reversed axes,
+ max: mathMax(selectionMin, selectionMax)
+ });
+ }
+ });
+ fireEvent(chart, 'selection', selectionData, zoom);
+
+ }
+ selectionMarker = selectionMarker.destroy();
+ }
+
+ css(container, { cursor: 'auto' });
+
+ chart.mouseIsDown = mouseIsDown = hasDragged = false;
+ removeEvent(doc, hasTouch ? 'touchend' : 'mouseup', drop);
+
+ }
+
+ /**
+ * Special handler for mouse move that will hide the tooltip when the mouse leaves the plotarea.
+ */
+ function hideTooltipOnMouseMove(e) {
+ var pageX = defined(e.pageX) ? e.pageX : e.page.x, // In mootools the event is wrapped and the page x/y position is named e.page.x
+ pageY = defined(e.pageX) ? e.pageY : e.page.y; // Ref: http://mootools.net/docs/core/Types/DOMEvent
+
+ if (chartPosition &&
+ !isInsidePlot(pageX - chartPosition.left - plotLeft,
+ pageY - chartPosition.top - plotTop)) {
+ resetTracker();
+ }
+ }
+
+ /**
+ * When mouse leaves the container, hide the tooltip.
+ */
+ function hideTooltipOnMouseLeave() {
+ resetTracker();
+ chartPosition = null; // also reset the chart position, used in #149 fix
+ }
+
+ /**
+ * Set the JS events on the container element
+ */
+ function setDOMEvents() {
+ var lastWasOutsidePlot = true;
+ /*
+ * Record the starting position of a dragoperation
+ */
+ container.onmousedown = function (e) {
+ e = normalizeMouseEvent(e);
+
+ // issue #295, dragging not always working in Firefox
+ if (!hasTouch && e.preventDefault) {
+ e.preventDefault();
+ }
+
+ // record the start position
+ chart.mouseIsDown = mouseIsDown = true;
+ chart.mouseDownX = mouseDownX = e.chartX;
+ mouseDownY = e.chartY;
+
+ addEvent(doc, hasTouch ? 'touchend' : 'mouseup', drop);
+ };
+
+ // The mousemove, touchmove and touchstart event handler
+ var mouseMove = function (e) {
+
+ // let the system handle multitouch operations like two finger scroll
+ // and pinching
+ if (e && e.touches && e.touches.length > 1) {
+ return;
+ }
+
+ // normalize
+ e = normalizeMouseEvent(e);
+ if (!hasTouch) { // not for touch devices
+ e.returnValue = false;
+ }
+
+ var chartX = e.chartX,
+ chartY = e.chartY,
+ isOutsidePlot = !isInsidePlot(chartX - plotLeft, chartY - plotTop);
+
+ // on touch devices, only trigger click if a handler is defined
+ if (hasTouch && e.type === 'touchstart') {
+ if (attr(e.target, 'isTracker')) {
+ if (!chart.runTrackerClick) {
+ e.preventDefault();
+ }
+ } else if (!runChartClick && !isOutsidePlot) {
+ e.preventDefault();
+ }
+ }
+
+ // cancel on mouse outside
+ if (isOutsidePlot) {
+
+ /*if (!lastWasOutsidePlot) {
+ // reset the tracker
+ resetTracker();
+ }*/
+
+ // drop the selection if any and reset mouseIsDown and hasDragged
+ //drop();
+ if (chartX < plotLeft) {
+ chartX = plotLeft;
+ } else if (chartX > plotLeft + plotWidth) {
+ chartX = plotLeft + plotWidth;
+ }
+
+ if (chartY < plotTop) {
+ chartY = plotTop;
+ } else if (chartY > plotTop + plotHeight) {
+ chartY = plotTop + plotHeight;
+ }
+
+ }
+
+ if (mouseIsDown && e.type !== 'touchstart') { // make selection
+
+ // determine if the mouse has moved more than 10px
+ hasDragged = Math.sqrt(
+ Math.pow(mouseDownX - chartX, 2) +
+ Math.pow(mouseDownY - chartY, 2)
+ );
+ if (hasDragged > 10) {
+ var clickedInside = isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
+
+ // make a selection
+ if (hasCartesianSeries && (zoomX || zoomY) && clickedInside) {
+ if (!selectionMarker) {
+ selectionMarker = renderer.rect(
+ plotLeft,
+ plotTop,
+ zoomHor ? 1 : plotWidth,
+ zoomVert ? 1 : plotHeight,
+ 0
+ )
+ .attr({
+ fill: optionsChart.selectionMarkerFill || 'rgba(69,114,167,0.25)',
+ zIndex: 7
+ })
+ .add();
+ }
+ }
+
+ // adjust the width of the selection marker
+ if (selectionMarker && zoomHor) {
+ var xSize = chartX - mouseDownX;
+ selectionMarker.attr({
+ width: mathAbs(xSize),
+ x: (xSize > 0 ? 0 : xSize) + mouseDownX
+ });
+ }
+ // adjust the height of the selection marker
+ if (selectionMarker && zoomVert) {
+ var ySize = chartY - mouseDownY;
+ selectionMarker.attr({
+ height: mathAbs(ySize),
+ y: (ySize > 0 ? 0 : ySize) + mouseDownY
+ });
+ }
+
+ // panning
+ if (clickedInside && !selectionMarker && optionsChart.panning) {
+ chart.pan(chartX);
+ }
+ }
+
+ } else if (!isOutsidePlot) {
+ // show the tooltip
+ onmousemove(e);
+ }
+
+ lastWasOutsidePlot = isOutsidePlot;
+
+ // when outside plot, allow touch-drag by returning true
+ return isOutsidePlot || !hasCartesianSeries;
+ };
+
+ /*
+ * When the mouse enters the container, run mouseMove
+ */
+ container.onmousemove = mouseMove;
+
+ /*
+ * When the mouse leaves the container, hide the tracking (tooltip).
+ */
+ addEvent(container, 'mouseleave', hideTooltipOnMouseLeave);
+
+ // issue #149 workaround
+ // The mouseleave event above does not always fire. Whenever the mouse is moving
+ // outside the plotarea, hide the tooltip
+ addEvent(doc, 'mousemove', hideTooltipOnMouseMove);
+
+ container.ontouchstart = function (e) {
+ // For touch devices, use touchmove to zoom
+ if (zoomX || zoomY) {
+ container.onmousedown(e);
+ }
+ // Show tooltip and prevent the lower mouse pseudo event
+ mouseMove(e);
+ };
+
+ /*
+ * Allow dragging the finger over the chart to read the values on touch
+ * devices
+ */
+ container.ontouchmove = mouseMove;
+
+ /*
+ * Allow dragging the finger over the chart to read the values on touch
+ * devices
+ */
+ container.ontouchend = function () {
+ if (hasDragged) {
+ resetTracker();
+ }
+ };
+
+
+ // MooTools 1.2.3 doesn't fire this in IE when using addEvent
+ container.onclick = function (e) {
+ var hoverPoint = chart.hoverPoint;
+ e = normalizeMouseEvent(e);
+
+ e.cancelBubble = true; // IE specific
+
+
+ if (!hasDragged) {
+ if (hoverPoint && attr(e.target, 'isTracker')) {
+ var plotX = hoverPoint.plotX,
+ plotY = hoverPoint.plotY;
+
+ // add page position info
+ extend(hoverPoint, {
+ pageX: chartPosition.left + plotLeft +
+ (inverted ? plotWidth - plotY : plotX),
+ pageY: chartPosition.top + plotTop +
+ (inverted ? plotHeight - plotX : plotY)
+ });
+
+ // the series click event
+ fireEvent(hoverPoint.series, 'click', extend(e, {
+ point: hoverPoint
+ }));
+
+ // the point click event
+ hoverPoint.firePointEvent('click', e);
+
+ } else {
+ extend(e, getMouseCoordinates(e));
+
+ // fire a click event in the chart
+ if (isInsidePlot(e.chartX - plotLeft, e.chartY - plotTop)) {
+ fireEvent(chart, 'click', e);
+ }
+ }
+
+
+ }
+ // reset mouseIsDown and hasDragged
+ hasDragged = false;
+ };
+
+ }
+
+ /**
+ * Destroys the MouseTracker object and disconnects DOM events.
+ */
+ function destroy() {
+ // Destroy the tracker group element
+ if (chart.trackerGroup) {
+ chart.trackerGroup = trackerGroup = chart.trackerGroup.destroy();
+ }
+
+ removeEvent(container, 'mouseleave', hideTooltipOnMouseLeave);
+ removeEvent(doc, 'mousemove', hideTooltipOnMouseMove);
+ container.onclick = container.onmousedown = container.onmousemove = container.ontouchstart = container.ontouchend = container.ontouchmove = null;
+ }
+
+ /**
+ * Create the image map that listens for mouseovers
+ */
+ placeTrackerGroup = function () {
+
+ // first create - plot positions is not final at this stage
+ if (!trackerGroup) {
+ chart.trackerGroup = trackerGroup = renderer.g('tracker')
+ .attr({ zIndex: 9 })
+ .add();
+
+ // then position - this happens on load and after resizing and changing
+ // axis or box positions
+ } else {
+ trackerGroup.translate(plotLeft, plotTop);
+ if (inverted) {
+ trackerGroup.attr({
+ width: chart.plotWidth,
+ height: chart.plotHeight
+ }).invert();
+ }
+ }
+ };
+
+
+ // Run MouseTracker
+ placeTrackerGroup();
+ if (options.enabled) {
+ chart.tooltip = tooltip = Tooltip(options);
+
+ // set the fixed interval ticking for the smooth tooltip
+ tooltipInterval = setInterval(function () {
+ if (tooltipTick) {
+ tooltipTick();
+ }
+ }, 32);
+ }
+
+ setDOMEvents();
+
+ // expose properties
+ extend(this, {
+ zoomX: zoomX,
+ zoomY: zoomY,
+ resetTracker: resetTracker,
+ normalizeMouseEvent: normalizeMouseEvent,
+ destroy: destroy
+ });
+ }
+
+
+
+ /**
+ * The overview of the chart's series
+ */
+ var Legend = function () {
+
+ var options = chart.options.legend;
+
+ if (!options.enabled) {
+ return;
+ }
+
+ var horizontal = options.layout === 'horizontal',
+ symbolWidth = options.symbolWidth,
+ symbolPadding = options.symbolPadding,
+ allItems,
+ style = options.style,
+ itemStyle = options.itemStyle,
+ itemHoverStyle = options.itemHoverStyle,
+ itemHiddenStyle = merge(itemStyle, options.itemHiddenStyle),
+ padding = options.padding || pInt(style.padding),
+ y = 18,
+ initialItemX = 4 + padding + symbolWidth + symbolPadding,
+ itemX,
+ itemY,
+ lastItemY,
+ itemHeight = 0,
+ itemMarginTop = options.itemMarginTop || 0,
+ itemMarginBottom = options.itemMarginBottom || 0,
+ box,
+ legendBorderWidth = options.borderWidth,
+ legendBackgroundColor = options.backgroundColor,
+ legendGroup,
+ offsetWidth,
+ widthOption = options.width,
+ series = chart.series,
+ reversedLegend = options.reversed;
+
+
+
+ /**
+ * Set the colors for the legend item
+ * @param {Object} item A Series or Point instance
+ * @param {Object} visible Dimmed or colored
+ */
+ function colorizeItem(item, visible) {
+ var legendItem = item.legendItem,
+ legendLine = item.legendLine,
+ legendSymbol = item.legendSymbol,
+ hiddenColor = itemHiddenStyle.color,
+ textColor = visible ? options.itemStyle.color : hiddenColor,
+ symbolColor = visible ? item.color : hiddenColor;
+
+ if (legendItem) {
+ legendItem.css({ fill: textColor });
+ }
+ if (legendLine) {
+ legendLine.attr({ stroke: symbolColor });
+ }
+ if (legendSymbol) {
+ legendSymbol.attr({
+ stroke: symbolColor,
+ fill: symbolColor
+ });
+ }
+ }
+
+ /**
+ * Position the legend item
+ * @param {Object} item A Series or Point instance
+ * @param {Object} visible Dimmed or colored
+ */
+ function positionItem(item, itemX, itemY) {
+ var legendItem = item.legendItem,
+ legendLine = item.legendLine,
+ legendSymbol = item.legendSymbol,
+ checkbox = item.checkbox;
+ if (legendItem) {
+ legendItem.attr({
+ x: itemX,
+ y: itemY
+ });
+ }
+ if (legendLine) {
+ legendLine.translate(itemX, itemY - 4);
+ }
+ if (legendSymbol) {
+ legendSymbol.attr({
+ x: itemX + legendSymbol.xOff,
+ y: itemY + legendSymbol.yOff
+ });
+ }
+ if (checkbox) {
+ checkbox.x = itemX;
+ checkbox.y = itemY;
+ }
+ }
+
+ /**
+ * Destroy a single legend item
+ * @param {Object} item The series or point
+ */
+ function destroyItem(item) {
+ var checkbox = item.checkbox;
+
+ // destroy SVG elements
+ each(['legendItem', 'legendLine', 'legendSymbol'], function (key) {
+ if (item[key]) {
+ item[key].destroy();
+ }
+ });
+
+ if (checkbox) {
+ discardElement(item.checkbox);
+ }
+
+
+ }
+
+ /**
+ * Destroys the legend.
+ */
+ function destroy() {
+ if (box) {
+ box = box.destroy();
+ }
+
+ if (legendGroup) {
+ legendGroup = legendGroup.destroy();
+ }
+ }
+
+ /**
+ * Position the checkboxes after the width is determined
+ */
+ function positionCheckboxes() {
+ each(allItems, function (item) {
+ var checkbox = item.checkbox,
+ alignAttr = legendGroup.alignAttr;
+ if (checkbox) {
+ css(checkbox, {
+ left: (alignAttr.translateX + item.legendItemWidth + checkbox.x - 40) + PX,
+ top: (alignAttr.translateY + checkbox.y - 11) + PX
+ });
+ }
+ });
+ }
+
+ /**
+ * Render a single specific legend item
+ * @param {Object} item A series or point
+ */
+ function renderItem(item) {
+ var bBox,
+ itemWidth,
+ legendSymbol,
+ symbolX,
+ symbolY,
+ simpleSymbol,
+ radius,
+ li = item.legendItem,
+ series = item.series || item,
+ itemOptions = series.options,
+ strokeWidth = (itemOptions && itemOptions.borderWidth) || 0;
+
+
+ if (!li) { // generate it once, later move it
+
+ // let these series types use a simple symbol
+ simpleSymbol = /^(bar|pie|area|column)$/.test(series.type);
+
+ // generate the list item text
+ item.legendItem = li = renderer.text(
+ options.labelFormatter.call(item),
+ 0,
+ 0
+ )
+ .css(item.visible ? itemStyle : itemHiddenStyle)
+ .on('mouseover', function () {
+ item.setState(HOVER_STATE);
+ li.css(itemHoverStyle);
+ })
+ .on('mouseout', function () {
+ li.css(item.visible ? itemStyle : itemHiddenStyle);
+ item.setState();
+ })
+ .on('click', function () {
+ var strLegendItemClick = 'legendItemClick',
+ fnLegendItemClick = function () {
+ item.setVisible();
+ };
+
+ // click the name or symbol
+ if (item.firePointEvent) { // point
+ item.firePointEvent(strLegendItemClick, null, fnLegendItemClick);
+ } else {
+ fireEvent(item, strLegendItemClick, null, fnLegendItemClick);
+ }
+ })
+ .attr({ zIndex: 2 })
+ .add(legendGroup);
+
+ // draw the line
+ if (!simpleSymbol && itemOptions && itemOptions.lineWidth) {
+ var attrs = {
+ 'stroke-width': itemOptions.lineWidth,
+ zIndex: 2
+ };
+ if (itemOptions.dashStyle) {
+ attrs.dashstyle = itemOptions.dashStyle;
+ }
+ item.legendLine = renderer.path([
+ M,
+ -symbolWidth - symbolPadding,
+ 0,
+ L,
+ -symbolPadding,
+ 0
+ ])
+ .attr(attrs)
+ .add(legendGroup);
+ }
+
+ // draw a simple symbol
+ if (simpleSymbol) { // bar|pie|area|column
+
+ legendSymbol = renderer.rect(
+ (symbolX = -symbolWidth - symbolPadding),
+ (symbolY = -11),
+ symbolWidth,
+ 12,
+ 2
+ ).attr({
+ //'stroke-width': 0,
+ zIndex: 3
+ }).add(legendGroup);
+ } else if (itemOptions && itemOptions.marker && itemOptions.marker.enabled) { // draw the marker
+ radius = itemOptions.marker.radius;
+ legendSymbol = renderer.symbol(
+ item.symbol,
+ (symbolX = -symbolWidth / 2 - symbolPadding - radius),
+ (symbolY = -4 - radius),
+ 2 * radius,
+ 2 * radius
+ )
+ .attr(item.pointAttr[NORMAL_STATE])
+ .attr({ zIndex: 3 })
+ .add(legendGroup);
+
+ }
+ if (legendSymbol) {
+ legendSymbol.xOff = symbolX + (strokeWidth % 2 / 2);
+ legendSymbol.yOff = symbolY + (strokeWidth % 2 / 2);
+ }
+
+ item.legendSymbol = legendSymbol;
+
+ // colorize the items
+ colorizeItem(item, item.visible);
+
+
+ // add the HTML checkbox on top
+ if (itemOptions && itemOptions.showCheckbox) {
+ item.checkbox = createElement('input', {
+ type: 'checkbox',
+ checked: item.selected,
+ defaultChecked: item.selected // required by IE7
+ }, options.itemCheckboxStyle, container);
+
+ addEvent(item.checkbox, 'click', function (event) {
+ var target = event.target;
+ fireEvent(item, 'checkboxClick', {
+ checked: target.checked
+ },
+ function () {
+ item.select();
+ }
+ );
+ });
+ }
+ }
+
+
+ // calculate the positions for the next line
+ bBox = li.getBBox();
+
+ itemWidth = item.legendItemWidth =
+ options.itemWidth || symbolWidth + symbolPadding + bBox.width + padding;
+ itemHeight = bBox.height;
+
+ // if the item exceeds the width, start a new line
+ if (horizontal && itemX - initialItemX + itemWidth >
+ (widthOption || (chartWidth - 2 * padding - initialItemX))) {
+ itemX = initialItemX;
+ itemY += itemMarginTop + itemHeight + itemMarginBottom;
+ }
+ lastItemY = itemY + itemMarginBottom;
+
+ // position the newly generated or reordered items
+ positionItem(item, itemX, itemY);
+
+ // advance
+ if (horizontal) {
+ itemX += itemWidth;
+ } else {
+ itemY += itemMarginTop + itemHeight + itemMarginBottom;
+ }
+
+ // the width of the widest item
+ offsetWidth = widthOption || mathMax(
+ horizontal ? itemX - initialItemX : itemWidth,
+ offsetWidth
+ );
+
+ }
+
+ /**
+ * Render the legend. This method can be called both before and after
+ * chart.render. If called after, it will only rearrange items instead
+ * of creating new ones.
+ */
+ function renderLegend() {
+ itemX = initialItemX;
+ itemY = padding + itemMarginTop + y - 5; // 5 is the number of pixels above the text
+ offsetWidth = 0;
+ lastItemY = 0;
+
+ if (!legendGroup) {
+ legendGroup = renderer.g('legend')
+ .attr({ zIndex: 10 }) // in front of trackers, #414
+ .add();
+ }
+
+
+ // add each series or point
+ allItems = [];
+ each(series, function (serie) {
+ var seriesOptions = serie.options;
+
+ if (!seriesOptions.showInLegend) {
+ return;
+ }
+
+ // use points or series for the legend item depending on legendType
+ allItems = allItems.concat(
+ serie.legendItems ||
+ (seriesOptions.legendType === 'point' ?
+ serie.data :
+ serie)
+ );
+
+ });
+
+ // sort by legendIndex
+ stableSort(allItems, function (a, b) {
+ return (a.options.legendIndex || 0) - (b.options.legendIndex || 0);
+ });
+
+ // reversed legend
+ if (reversedLegend) {
+ allItems.reverse();
+ }
+
+ // render the items
+ each(allItems, renderItem);
+
+
+ // Draw the border
+ legendWidth = widthOption || offsetWidth;
+ legendHeight = lastItemY - y + itemHeight;
+
+ if (legendBorderWidth || legendBackgroundColor) {
+ legendWidth += 2 * padding;
+ legendHeight += 2 * padding;
+
+ if (!box) {
+ box = renderer.rect(
+ 0,
+ 0,
+ legendWidth,
+ legendHeight,
+ options.borderRadius,
+ legendBorderWidth || 0
+ ).attr({
+ stroke: options.borderColor,
+ 'stroke-width': legendBorderWidth || 0,
+ fill: legendBackgroundColor || NONE
+ })
+ .add(legendGroup)
+ .shadow(options.shadow);
+ box.isNew = true;
+
+ } else if (legendWidth > 0 && legendHeight > 0) {
+ box[box.isNew ? 'attr' : 'animate'](
+ box.crisp(null, null, null, legendWidth, legendHeight)
+ );
+ box.isNew = false;
+ }
+
+ // hide the border if no items
+ box[allItems.length ? 'show' : 'hide']();
+ }
+
+ // 1.x compatibility: positioning based on style
+ var props = ['left', 'right', 'top', 'bottom'],
+ prop,
+ i = 4;
+ while (i--) {
+ prop = props[i];
+ if (style[prop] && style[prop] !== 'auto') {
+ options[i < 2 ? 'align' : 'verticalAlign'] = prop;
+ options[i < 2 ? 'x' : 'y'] = pInt(style[prop]) * (i % 2 ? -1 : 1);
+ }
+ }
+
+ if (allItems.length) {
+ legendGroup.align(extend(options, {
+ width: legendWidth,
+ height: legendHeight
+ }), true, spacingBox);
+ }
+
+ if (!isResizing) {
+ positionCheckboxes();
+ }
+ }
+
+
+ // run legend
+ renderLegend();
+
+ // move checkboxes
+ addEvent(chart, 'endResize', positionCheckboxes);
+
+ // expose
+ return {
+ colorizeItem: colorizeItem,
+ destroyItem: destroyItem,
+ renderLegend: renderLegend,
+ destroy: destroy
+ };
+ };
+
+
+
+
+
+
+ /**
+ * Initialize an individual series, called internally before render time
+ */
+ function initSeries(options) {
+ var type = options.type || optionsChart.type || optionsChart.defaultSeriesType,
+ typeClass = seriesTypes[type],
+ serie,
+ hasRendered = chart.hasRendered;
+
+ // an inverted chart can't take a column series and vice versa
+ if (hasRendered) {
+ if (inverted && type === 'column') {
+ typeClass = seriesTypes.bar;
+ } else if (!inverted && type === 'bar') {
+ typeClass = seriesTypes.column;
+ }
+ }
+
+ serie = new typeClass();
+
+ serie.init(chart, options);
+
+ // set internal chart properties
+ if (!hasRendered && serie.inverted) {
+ inverted = true;
+ }
+ if (serie.isCartesian) {
+ hasCartesianSeries = serie.isCartesian;
+ }
+
+ series.push(serie);
+
+ return serie;
+ }
+
+ /**
+ * Add a series dynamically after time
+ *
+ * @param {Object} options The config options
+ * @param {Boolean} redraw Whether to redraw the chart after adding. Defaults to true.
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ *
+ * @return {Object} series The newly created series object
+ */
+ function addSeries(options, redraw, animation) {
+ var series;
+
+ if (options) {
+ setAnimation(animation, chart);
+ redraw = pick(redraw, true); // defaults to true
+
+ fireEvent(chart, 'addSeries', { options: options }, function () {
+ series = initSeries(options);
+ series.isDirty = true;
+
+ chart.isDirtyLegend = true; // the series array is out of sync with the display
+ if (redraw) {
+ chart.redraw();
+ }
+ });
+ }
+
+ return series;
+ }
+
+ /**
+ * Check whether a given point is within the plot area
+ *
+ * @param {Number} x Pixel x relative to the plot area
+ * @param {Number} y Pixel y relative to the plot area
+ */
+ isInsidePlot = function (x, y) {
+ return x >= 0 &&
+ x <= plotWidth &&
+ y >= 0 &&
+ y <= plotHeight;
+ };
+
+ /**
+ * Adjust all axes tick amounts
+ */
+ function adjustTickAmounts() {
+ if (optionsChart.alignTicks !== false) {
+ each(axes, function (axis) {
+ axis.adjustTickAmount();
+ });
+ }
+ maxTicks = null;
+ }
+
+ /**
+ * Redraw legend, axes or series based on updated data
+ *
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ */
+ function redraw(animation) {
+ var redrawLegend = chart.isDirtyLegend,
+ hasStackedSeries,
+ isDirtyBox = chart.isDirtyBox, // todo: check if it has actually changed?
+ seriesLength = series.length,
+ i = seriesLength,
+ clipRect = chart.clipRect,
+ serie;
+
+ setAnimation(animation, chart);
+
+ // link stacked series
+ while (i--) {
+ serie = series[i];
+ if (serie.isDirty && serie.options.stacking) {
+ hasStackedSeries = true;
+ break;
+ }
+ }
+ if (hasStackedSeries) { // mark others as dirty
+ i = seriesLength;
+ while (i--) {
+ serie = series[i];
+ if (serie.options.stacking) {
+ serie.isDirty = true;
+ }
+ }
+ }
+
+ // handle updated data in the series
+ each(series, function (serie) {
+ if (serie.isDirty) { // prepare the data so axis can read it
+ if (serie.options.legendType === 'point') {
+ redrawLegend = true;
+ }
+ }
+ });
+
+ // handle added or removed series
+ if (redrawLegend && legend.renderLegend) { // series or pie points are added or removed
+ // draw legend graphics
+ legend.renderLegend();
+
+ chart.isDirtyLegend = false;
+ }
+
+
+ if (hasCartesianSeries) {
+ if (!isResizing) {
+
+ // reset maxTicks
+ maxTicks = null;
+
+ // set axes scales
+ each(axes, function (axis) {
+ axis.setScale();
+ });
+ }
+ adjustTickAmounts();
+ getMargins();
+
+ // redraw axes
+ each(axes, function (axis) {
+ fireEvent(axis, 'afterSetExtremes', axis.getExtremes()); // #747, #751
+ if (axis.isDirty) {
+ axis.redraw();
+ }
+ });
+
+
+ }
+
+ // the plot areas size has changed
+ if (isDirtyBox) {
+ drawChartBox();
+ placeTrackerGroup();
+
+ // move clip rect
+ if (clipRect) {
+ stop(clipRect);
+ clipRect.animate({ // for chart resize
+ width: chart.plotSizeX,
+ height: chart.plotSizeY + 1
+ });
+ }
+
+ }
+
+
+ // redraw affected series
+ each(series, function (serie) {
+ if (serie.isDirty && serie.visible &&
+ (!serie.isCartesian || serie.xAxis)) { // issue #153
+ serie.redraw();
+ }
+ });
+
+
+ // hide tooltip and hover states
+ if (tracker && tracker.resetTracker) {
+ tracker.resetTracker();
+ }
+
+ // fire the event
+ fireEvent(chart, 'redraw'); // jQuery breaks this when calling it from addEvent. Overwrites chart.redraw
+ }
+
+
+
+ /**
+ * Dim the chart and show a loading text or symbol
+ * @param {String} str An optional text to show in the loading label instead of the default one
+ */
+ function showLoading(str) {
+ var loadingOptions = options.loading;
+
+ // create the layer at the first call
+ if (!loadingDiv) {
+ loadingDiv = createElement(DIV, {
+ className: PREFIX + 'loading'
+ }, extend(loadingOptions.style, {
+ left: plotLeft + PX,
+ top: plotTop + PX,
+ width: plotWidth + PX,
+ height: plotHeight + PX,
+ zIndex: 10,
+ display: NONE
+ }), container);
+
+ loadingSpan = createElement(
+ 'span',
+ null,
+ loadingOptions.labelStyle,
+ loadingDiv
+ );
+
+ }
+
+ // update text
+ loadingSpan.innerHTML = str || options.lang.loading;
+
+ // show it
+ if (!loadingShown) {
+ css(loadingDiv, { opacity: 0, display: '' });
+ animate(loadingDiv, {
+ opacity: loadingOptions.style.opacity
+ }, {
+ duration: loadingOptions.showDuration || 0
+ });
+ loadingShown = true;
+ }
+ }
+ /**
+ * Hide the loading layer
+ */
+ function hideLoading() {
+ if (loadingDiv) {
+ animate(loadingDiv, {
+ opacity: 0
+ }, {
+ duration: options.loading.hideDuration || 100,
+ complete: function () {
+ css(loadingDiv, { display: NONE });
+ }
+ });
+ }
+ loadingShown = false;
+ }
+
+ /**
+ * Get an axis, series or point object by id.
+ * @param id {String} The id as given in the configuration options
+ */
+ function get(id) {
+ var i,
+ j,
+ points;
+
+ // search axes
+ for (i = 0; i < axes.length; i++) {
+ if (axes[i].options.id === id) {
+ return axes[i];
+ }
+ }
+
+ // search series
+ for (i = 0; i < series.length; i++) {
+ if (series[i].options.id === id) {
+ return series[i];
+ }
+ }
+
+ // search points
+ for (i = 0; i < series.length; i++) {
+ points = series[i].points || [];
+ for (j = 0; j < points.length; j++) {
+ if (points[j].id === id) {
+ return points[j];
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Create the Axis instances based on the config options
+ */
+ function getAxes() {
+ var xAxisOptions = options.xAxis || {},
+ yAxisOptions = options.yAxis || {},
+ optionsArray,
+ axis;
+
+ // make sure the options are arrays and add some members
+ xAxisOptions = splat(xAxisOptions);
+ each(xAxisOptions, function (axis, i) {
+ axis.index = i;
+ axis.isX = true;
+ });
+
+ yAxisOptions = splat(yAxisOptions);
+ each(yAxisOptions, function (axis, i) {
+ axis.index = i;
+ });
+
+ // concatenate all axis options into one array
+ optionsArray = xAxisOptions.concat(yAxisOptions);
+
+ each(optionsArray, function (axisOptions) {
+ axis = new Axis(axisOptions);
+ });
+
+ adjustTickAmounts();
+ }
+
+
+ /**
+ * Get the currently selected points from all series
+ */
+ function getSelectedPoints() {
+ var points = [];
+ each(series, function (serie) {
+ points = points.concat(grep(serie.points, function (point) {
+ return point.selected;
+ }));
+ });
+ return points;
+ }
+
+ /**
+ * Get the currently selected series
+ */
+ function getSelectedSeries() {
+ return grep(series, function (serie) {
+ return serie.selected;
+ });
+ }
+
+ /**
+ * Display the zoom button
+ */
+ function showResetZoom() {
+ var lang = defaultOptions.lang,
+ btnOptions = optionsChart.resetZoomButton,
+ box = btnOptions.relativeTo === 'plot' && {
+ x: plotLeft,
+ y: plotTop,
+ width: plotWidth,
+ height: plotHeight
+ };
+
+ chart.resetZoomButton = renderer.button(lang.resetZoom, null, null, zoomOut, btnOptions.theme)
+ .attr({
+ align: btnOptions.position.align,
+ title: lang.resetZoomTitle
+ })
+ .add()
+ .align(btnOptions.position, false, box);
+ }
+
+ /**
+ * Zoom out to 1:1
+ */
+ zoomOut = function () {
+ var resetZoomButton = chart.resetZoomButton;
+
+ fireEvent(chart, 'selection', { resetSelection: true }, zoom);
+ if (resetZoomButton) {
+ chart.resetZoomButton = resetZoomButton.destroy();
+ }
+ };
+ /**
+ * Zoom into a given portion of the chart given by axis coordinates
+ * @param {Object} event
+ */
+ zoom = function (event) {
+
+ // add button to reset selection
+ var animate = chart.pointCount < 100,
+ hasZoomed;
+
+ if (chart.resetZoomEnabled !== false && !chart.resetZoomButton) { // hook for Stock charts etc.
+ showResetZoom();
+ }
+
+ // if zoom is called with no arguments, reset the axes
+ if (!event || event.resetSelection) {
+ each(axes, function (axis) {
+ if (axis.options.zoomEnabled !== false) {
+ axis.setExtremes(null, null, false);
+ hasZoomed = true;
+ }
+ });
+ } else { // else, zoom in on all axes
+ each(event.xAxis.concat(event.yAxis), function (axisData) {
+ var axis = axisData.axis;
+
+ // don't zoom more than minRange
+ if (chart.tracker[axis.isXAxis ? 'zoomX' : 'zoomY']) {
+ axis.setExtremes(axisData.min, axisData.max, false);
+ hasZoomed = true;
+ }
+ });
+ }
+
+ // Redraw
+ if (hasZoomed) {
+ redraw(true, animate);
+ }
+ };
+
+ /**
+ * Pan the chart by dragging the mouse across the pane. This function is called
+ * on mouse move, and the distance to pan is computed from chartX compared to
+ * the first chartX position in the dragging operation.
+ */
+ chart.pan = function (chartX) {
+
+ var xAxis = chart.xAxis[0],
+ mouseDownX = chart.mouseDownX,
+ halfPointRange = xAxis.pointRange / 2,
+ extremes = xAxis.getExtremes(),
+ newMin = xAxis.translate(mouseDownX - chartX, true) + halfPointRange,
+ newMax = xAxis.translate(mouseDownX + plotWidth - chartX, true) - halfPointRange,
+ hoverPoints = chart.hoverPoints;
+
+ // remove active points for shared tooltip
+ if (hoverPoints) {
+ each(hoverPoints, function (point) {
+ point.setState();
+ });
+ }
+
+ if (newMin > mathMin(extremes.dataMin, extremes.min) && newMax < mathMax(extremes.dataMax, extremes.max)) {
+ xAxis.setExtremes(newMin, newMax, true, false);
+ }
+
+ chart.mouseDownX = chartX; // set new reference for next run
+ css(container, { cursor: 'move' });
+ };
+
+ /**
+ * Show the title and subtitle of the chart
+ *
+ * @param titleOptions {Object} New title options
+ * @param subtitleOptions {Object} New subtitle options
+ *
+ */
+ function setTitle(titleOptions, subtitleOptions) {
+
+ chartTitleOptions = merge(options.title, titleOptions);
+ chartSubtitleOptions = merge(options.subtitle, subtitleOptions);
+
+ // add title and subtitle
+ each([
+ ['title', titleOptions, chartTitleOptions],
+ ['subtitle', subtitleOptions, chartSubtitleOptions]
+ ], function (arr) {
+ var name = arr[0],
+ title = chart[name],
+ titleOptions = arr[1],
+ chartTitleOptions = arr[2];
+
+ if (title && titleOptions) {
+ title = title.destroy(); // remove old
+ }
+ if (chartTitleOptions && chartTitleOptions.text && !title) {
+ chart[name] = renderer.text(
+ chartTitleOptions.text,
+ 0,
+ 0,
+ chartTitleOptions.useHTML
+ )
+ .attr({
+ align: chartTitleOptions.align,
+ 'class': PREFIX + name,
+ zIndex: 1
+ })
+ .css(chartTitleOptions.style)
+ .add()
+ .align(chartTitleOptions, false, spacingBox);
+ }
+ });
+
+ }
+
+ /**
+ * Get chart width and height according to options and container size
+ */
+ function getChartSize() {
+
+ containerWidth = (renderToClone || renderTo).offsetWidth;
+ containerHeight = (renderToClone || renderTo).offsetHeight;
+ chart.chartWidth = chartWidth = optionsChart.width || containerWidth || 600;
+ chart.chartHeight = chartHeight = optionsChart.height ||
+ // the offsetHeight of an empty container is 0 in standard browsers, but 19 in IE7:
+ (containerHeight > 19 ? containerHeight : 400);
+ }
+
+
+ /**
+ * Get the containing element, determine the size and create the inner container
+ * div to hold the chart
+ */
+ function getContainer() {
+ renderTo = optionsChart.renderTo;
+ containerId = PREFIX + idCounter++;
+
+ if (isString(renderTo)) {
+ renderTo = doc.getElementById(renderTo);
+ }
+
+ // remove previous chart
+ renderTo.innerHTML = '';
+
+ // If the container doesn't have an offsetWidth, it has or is a child of a node
+ // that has display:none. We need to temporarily move it out to a visible
+ // state to determine the size, else the legend and tooltips won't render
+ // properly
+ if (!renderTo.offsetWidth) {
+ renderToClone = renderTo.cloneNode(0);
+ css(renderToClone, {
+ position: ABSOLUTE,
+ top: '-9999px',
+ display: ''
+ });
+ doc.body.appendChild(renderToClone);
+ }
+
+ // get the width and height
+ getChartSize();
+
+ // create the inner container
+ chart.container = container = createElement(DIV, {
+ className: PREFIX + 'container' +
+ (optionsChart.className ? ' ' + optionsChart.className : ''),
+ id: containerId
+ }, extend({
+ position: RELATIVE,
+ overflow: HIDDEN, // needed for context menu (avoid scrollbars) and
+ // content overflow in IE
+ width: chartWidth + PX,
+ height: chartHeight + PX,
+ textAlign: 'left',
+ lineHeight: 'normal' // #427
+ }, optionsChart.style),
+ renderToClone || renderTo
+ );
+
+ chart.renderer = renderer =
+ optionsChart.forExport ? // force SVG, used for SVG export
+ new SVGRenderer(container, chartWidth, chartHeight, true) :
+ new Renderer(container, chartWidth, chartHeight);
+
+ // Issue 110 workaround:
+ // In Firefox, if a div is positioned by percentage, its pixel position may land
+ // between pixels. The container itself doesn't display this, but an SVG element
+ // inside this container will be drawn at subpixel precision. In order to draw
+ // sharp lines, this must be compensated for. This doesn't seem to work inside
+ // iframes though (like in jsFiddle).
+ var subPixelFix, rect;
+ if (isFirefox && container.getBoundingClientRect) {
+ subPixelFix = function () {
+ css(container, { left: 0, top: 0 });
+ rect = container.getBoundingClientRect();
+ css(container, {
+ left: (-(rect.left - pInt(rect.left))) + PX,
+ top: (-(rect.top - pInt(rect.top))) + PX
+ });
+ };
+
+ // run the fix now
+ subPixelFix();
+
+ // run it on resize
+ addEvent(win, 'resize', subPixelFix);
+
+ // remove it on chart destroy
+ addEvent(chart, 'destroy', function () {
+ removeEvent(win, 'resize', subPixelFix);
+ });
+ }
+ }
+
+ /**
+ * Calculate margins by rendering axis labels in a preliminary position. Title,
+ * subtitle and legend have already been rendered at this stage, but will be
+ * moved into their final positions
+ */
+ getMargins = function () {
+ var legendOptions = options.legend,
+ legendMargin = pick(legendOptions.margin, 10),
+ legendX = legendOptions.x,
+ legendY = legendOptions.y,
+ align = legendOptions.align,
+ verticalAlign = legendOptions.verticalAlign,
+ titleOffset;
+
+ resetMargins();
+
+ // adjust for title and subtitle
+ if ((chart.title || chart.subtitle) && !defined(optionsMarginTop)) {
+ titleOffset = mathMax(
+ (chart.title && !chartTitleOptions.floating && !chartTitleOptions.verticalAlign && chartTitleOptions.y) || 0,
+ (chart.subtitle && !chartSubtitleOptions.floating && !chartSubtitleOptions.verticalAlign && chartSubtitleOptions.y) || 0
+ );
+ if (titleOffset) {
+ plotTop = mathMax(plotTop, titleOffset + pick(chartTitleOptions.margin, 15) + spacingTop);
+ }
+ }
+ // adjust for legend
+ if (legendOptions.enabled && !legendOptions.floating) {
+ if (align === 'right') { // horizontal alignment handled first
+ if (!defined(optionsMarginRight)) {
+ marginRight = mathMax(
+ marginRight,
+ legendWidth - legendX + legendMargin + spacingRight
+ );
+ }
+ } else if (align === 'left') {
+ if (!defined(optionsMarginLeft)) {
+ plotLeft = mathMax(
+ plotLeft,
+ legendWidth + legendX + legendMargin + spacingLeft
+ );
+ }
+
+ } else if (verticalAlign === 'top') {
+ if (!defined(optionsMarginTop)) {
+ plotTop = mathMax(
+ plotTop,
+ legendHeight + legendY + legendMargin + spacingTop
+ );
+ }
+
+ } else if (verticalAlign === 'bottom') {
+ if (!defined(optionsMarginBottom)) {
+ marginBottom = mathMax(
+ marginBottom,
+ legendHeight - legendY + legendMargin + spacingBottom
+ );
+ }
+ }
+ }
+
+ // adjust for scroller
+ if (chart.extraBottomMargin) {
+ marginBottom += chart.extraBottomMargin;
+ }
+ if (chart.extraTopMargin) {
+ plotTop += chart.extraTopMargin;
+ }
+
+ // pre-render axes to get labels offset width
+ if (hasCartesianSeries) {
+ each(axes, function (axis) {
+ axis.getOffset();
+ });
+ }
+
+ if (!defined(optionsMarginLeft)) {
+ plotLeft += axisOffset[3];
+ }
+ if (!defined(optionsMarginTop)) {
+ plotTop += axisOffset[0];
+ }
+ if (!defined(optionsMarginBottom)) {
+ marginBottom += axisOffset[2];
+ }
+ if (!defined(optionsMarginRight)) {
+ marginRight += axisOffset[1];
+ }
+
+ setChartSize();
+
+ };
+
+ /**
+ * Add the event handlers necessary for auto resizing
+ *
+ */
+ function initReflow() {
+ var reflowTimeout;
+ function reflow(e) {
+ var width = optionsChart.width || renderTo.offsetWidth,
+ height = optionsChart.height || renderTo.offsetHeight,
+ target = e.target;
+
+ // Width and height checks for display:none. Target is doc in IE8 and Opera,
+ // win in Firefox, Chrome and IE9.
+ if (width && height && (target === win || target === doc)) {
+
+ if (width !== containerWidth || height !== containerHeight) {
+ clearTimeout(reflowTimeout);
+ reflowTimeout = setTimeout(function () {
+ resize(width, height, false);
+ }, 100);
+ }
+ containerWidth = width;
+ containerHeight = height;
+ }
+ }
+ addEvent(win, 'resize', reflow);
+ addEvent(chart, 'destroy', function () {
+ removeEvent(win, 'resize', reflow);
+ });
+ }
+
+ /**
+ * Fires endResize event on chart instance.
+ */
+ function fireEndResize() {
+ if (chart) {
+ fireEvent(chart, 'endResize', null, function () {
+ isResizing -= 1;
+ });
+ }
+ }
+
+ /**
+ * Resize the chart to a given width and height
+ * @param {Number} width
+ * @param {Number} height
+ * @param {Object|Boolean} animation
+ */
+ resize = function (width, height, animation) {
+ var chartTitle = chart.title,
+ chartSubtitle = chart.subtitle;
+
+ isResizing += 1;
+
+ // set the animation for the current process
+ setAnimation(animation, chart);
+
+ oldChartHeight = chartHeight;
+ oldChartWidth = chartWidth;
+ if (defined(width)) {
+ chart.chartWidth = chartWidth = mathRound(width);
+ }
+ if (defined(height)) {
+ chart.chartHeight = chartHeight = mathRound(height);
+ }
+
+ css(container, {
+ width: chartWidth + PX,
+ height: chartHeight + PX
+ });
+ renderer.setSize(chartWidth, chartHeight, animation);
+
+ // update axis lengths for more correct tick intervals:
+ plotWidth = chartWidth - plotLeft - marginRight;
+ plotHeight = chartHeight - plotTop - marginBottom;
+
+ // handle axes
+ maxTicks = null;
+ each(axes, function (axis) {
+ axis.isDirty = true;
+ axis.setScale();
+ });
+
+ // make sure non-cartesian series are also handled
+ each(series, function (serie) {
+ serie.isDirty = true;
+ });
+
+ chart.isDirtyLegend = true; // force legend redraw
+ chart.isDirtyBox = true; // force redraw of plot and chart border
+
+ getMargins();
+
+ // move titles
+ if (chartTitle) {
+ chartTitle.align(null, null, spacingBox);
+ }
+ if (chartSubtitle) {
+ chartSubtitle.align(null, null, spacingBox);
+ }
+
+ redraw(animation);
+
+
+ oldChartHeight = null;
+ fireEvent(chart, 'resize');
+
+ // fire endResize and set isResizing back
+ // If animation is disabled, fire without delay
+ if (globalAnimation === false) {
+ fireEndResize();
+ } else { // else set a timeout with the animation duration
+ setTimeout(fireEndResize, (globalAnimation && globalAnimation.duration) || 500);
+ }
+ };
+
+ /**
+ * Set the public chart properties. This is done before and after the pre-render
+ * to determine margin sizes
+ */
+ setChartSize = function () {
+
+ chart.plotLeft = plotLeft = mathRound(plotLeft);
+ chart.plotTop = plotTop = mathRound(plotTop);
+ chart.plotWidth = plotWidth = mathRound(chartWidth - plotLeft - marginRight);
+ chart.plotHeight = plotHeight = mathRound(chartHeight - plotTop - marginBottom);
+
+ chart.plotSizeX = inverted ? plotHeight : plotWidth;
+ chart.plotSizeY = inverted ? plotWidth : plotHeight;
+
+ spacingBox = {
+ x: spacingLeft,
+ y: spacingTop,
+ width: chartWidth - spacingLeft - spacingRight,
+ height: chartHeight - spacingTop - spacingBottom
+ };
+
+ each(axes, function (axis) {
+ axis.setAxisSize();
+ axis.setAxisTranslation();
+ });
+ };
+
+ /**
+ * Initial margins before auto size margins are applied
+ */
+ resetMargins = function () {
+ plotTop = pick(optionsMarginTop, spacingTop);
+ marginRight = pick(optionsMarginRight, spacingRight);
+ marginBottom = pick(optionsMarginBottom, spacingBottom);
+ plotLeft = pick(optionsMarginLeft, spacingLeft);
+ axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
+ };
+
+ /**
+ * Draw the borders and backgrounds for chart and plot area
+ */
+ drawChartBox = function () {
+ var chartBorderWidth = optionsChart.borderWidth || 0,
+ chartBackgroundColor = optionsChart.backgroundColor,
+ plotBackgroundColor = optionsChart.plotBackgroundColor,
+ plotBackgroundImage = optionsChart.plotBackgroundImage,
+ mgn,
+ plotSize = {
+ x: plotLeft,
+ y: plotTop,
+ width: plotWidth,
+ height: plotHeight
+ };
+
+ // Chart area
+ mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
+
+ if (chartBorderWidth || chartBackgroundColor) {
+ if (!chartBackground) {
+ chartBackground = renderer.rect(mgn / 2, mgn / 2, chartWidth - mgn, chartHeight - mgn,
+ optionsChart.borderRadius, chartBorderWidth)
+ .attr({
+ stroke: optionsChart.borderColor,
+ 'stroke-width': chartBorderWidth,
+ fill: chartBackgroundColor || NONE
+ })
+ .add()
+ .shadow(optionsChart.shadow);
+ } else { // resize
+ chartBackground.animate(
+ chartBackground.crisp(null, null, null, chartWidth - mgn, chartHeight - mgn)
+ );
+ }
+ }
+
+
+ // Plot background
+ if (plotBackgroundColor) {
+ if (!plotBackground) {
+ plotBackground = renderer.rect(plotLeft, plotTop, plotWidth, plotHeight, 0)
+ .attr({
+ fill: plotBackgroundColor
+ })
+ .add()
+ .shadow(optionsChart.plotShadow);
+ } else {
+ plotBackground.animate(plotSize);
+ }
+ }
+ if (plotBackgroundImage) {
+ if (!plotBGImage) {
+ plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight)
+ .add();
+ } else {
+ plotBGImage.animate(plotSize);
+ }
+ }
+
+ // Plot area border
+ if (optionsChart.plotBorderWidth) {
+ if (!plotBorder) {
+ plotBorder = renderer.rect(plotLeft, plotTop, plotWidth, plotHeight, 0, optionsChart.plotBorderWidth)
+ .attr({
+ stroke: optionsChart.plotBorderColor,
+ 'stroke-width': optionsChart.plotBorderWidth,
+ zIndex: 4
+ })
+ .add();
+ } else {
+ plotBorder.animate(
+ plotBorder.crisp(null, plotLeft, plotTop, plotWidth, plotHeight)
+ );
+ }
+ }
+
+ // reset
+ chart.isDirtyBox = false;
+ };
+
+ /**
+ * Detect whether the chart is inverted, either by setting the chart.inverted option
+ * or adding a bar series to the configuration options
+ */
+ function setInverted() {
+ var BAR = 'bar',
+ isInverted = (
+ inverted || // it is set before
+ optionsChart.inverted ||
+ optionsChart.type === BAR || // default series type
+ optionsChart.defaultSeriesType === BAR // backwards compatible
+ ),
+ seriesOptions = options.series,
+ i = seriesOptions && seriesOptions.length;
+
+ // check if a bar series is present in the config options
+ while (!isInverted && i--) {
+ if (seriesOptions[i].type === BAR) {
+ isInverted = true;
+ }
+ }
+
+ // set the chart property and the chart scope variable
+ chart.inverted = inverted = isInverted;
+ }
+
+ /**
+ * Render all graphics for the chart
+ */
+ function render() {
+ var labels = options.labels,
+ credits = options.credits,
+ creditsHref;
+
+ // Title
+ setTitle();
+
+
+ // Legend
+ legend = chart.legend = new Legend();
+
+ // Get margins by pre-rendering axes
+ // set axes scales
+ each(axes, function (axis) {
+ axis.setScale();
+ });
+ getMargins();
+ each(axes, function (axis) {
+ axis.setTickPositions(true); // update to reflect the new margins
+ });
+ adjustTickAmounts();
+ getMargins(); // second pass to check for new labels
+
+
+ // Draw the borders and backgrounds
+ drawChartBox();
+
+ // Axes
+ if (hasCartesianSeries) {
+ each(axes, function (axis) {
+ axis.render();
+ });
+ }
+
+
+ // The series
+ if (!chart.seriesGroup) {
+ chart.seriesGroup = renderer.g('series-group')
+ .attr({ zIndex: 3 })
+ .add();
+ }
+ each(series, function (serie) {
+ serie.translate();
+ serie.setTooltipPoints();
+ serie.render();
+ });
+
+
+ // Labels
+ if (labels.items) {
+ each(labels.items, function () {
+ var style = extend(labels.style, this.style),
+ x = pInt(style.left) + plotLeft,
+ y = pInt(style.top) + plotTop + 12;
+
+ // delete to prevent rewriting in IE
+ delete style.left;
+ delete style.top;
+
+ renderer.text(
+ this.html,
+ x,
+ y
+ )
+ .attr({ zIndex: 2 })
+ .css(style)
+ .add();
+
+ });
+ }
+
+ // Credits
+ if (credits.enabled && !chart.credits) {
+ creditsHref = credits.href;
+ chart.credits = renderer.text(
+ credits.text,
+ 0,
+ 0
+ )
+ .on('click', function () {
+ if (creditsHref) {
+ location.href = creditsHref;
+ }
+ })
+ .attr({
+ align: credits.position.align,
+ zIndex: 8
+ })
+ .css(credits.style)
+ .add()
+ .align(credits.position);
+ }
+
+ placeTrackerGroup();
+
+ // Set flag
+ chart.hasRendered = true;
+
+ // If the chart was rendered outside the top container, put it back in
+ if (renderToClone) {
+ renderTo.appendChild(container);
+ discardElement(renderToClone);
+ //updatePosition(container);
+ }
+ }
+
+ /**
+ * Clean up memory usage
+ */
+ function destroy() {
+ var i,
+ parentNode = container && container.parentNode;
+
+ // If the chart is destroyed already, do nothing.
+ // This will happen if if a script invokes chart.destroy and
+ // then it will be called again on win.unload
+ if (chart === null) {
+ return;
+ }
+
+ // fire the chart.destoy event
+ fireEvent(chart, 'destroy');
+
+ // remove events
+ removeEvent(chart);
+
+ // ==== Destroy collections:
+ // Destroy axes
+ i = axes.length;
+ while (i--) {
+ axes[i] = axes[i].destroy();
+ }
+
+ // Destroy each series
+ i = series.length;
+ while (i--) {
+ series[i] = series[i].destroy();
+ }
+
+ // ==== Destroy chart properties:
+ each(['title', 'subtitle', 'seriesGroup', 'clipRect', 'credits', 'tracker', 'scroller', 'rangeSelector'], function (name) {
+ var prop = chart[name];
+
+ if (prop) {
+ chart[name] = prop.destroy();
+ }
+ });
+
+ // ==== Destroy local variables:
+ each([chartBackground, plotBorder, plotBackground, legend, tooltip, renderer, tracker], function (obj) {
+ if (obj && obj.destroy) {
+ obj.destroy();
+ }
+ });
+ chartBackground = plotBorder = plotBackground = legend = tooltip = renderer = tracker = null;
+
+ // remove container and all SVG
+ if (container) { // can break in IE when destroyed before finished loading
+ container.innerHTML = '';
+ removeEvent(container);
+ if (parentNode) {
+ discardElement(container);
+ }
+
+ // IE6 leak
+ container = null;
+ }
+
+ // memory and CPU leak
+ clearInterval(tooltipInterval);
+
+ // clean it all up
+ for (i in chart) {
+ delete chart[i];
+ }
+
+ chart = null;
+ options = null;
+ }
+ /**
+ * Prepare for first rendering after all data are loaded
+ */
+ function firstRender() {
+
+ // VML namespaces can't be added until after complete. Listening
+ // for Perini's doScroll hack is not enough.
+ var ONREADYSTATECHANGE = 'onreadystatechange',
+ COMPLETE = 'complete';
+ // Note: in spite of JSLint's complaints, win == win.top is required
+ /*jslint eqeq: true*/
+ if (!hasSVG && win == win.top && doc.readyState !== COMPLETE) {
+ /*jslint eqeq: false*/
+ doc.attachEvent(ONREADYSTATECHANGE, function () {
+ doc.detachEvent(ONREADYSTATECHANGE, firstRender);
+ if (doc.readyState === COMPLETE) {
+ firstRender();
+ }
+ });
+ return;
+ }
+
+ // create the container
+ getContainer();
+
+ // Run an early event after the container and renderer are established
+ fireEvent(chart, 'init');
+
+ // Initialize range selector for stock charts
+ if (Highcharts.RangeSelector && options.rangeSelector.enabled) {
+ chart.rangeSelector = new Highcharts.RangeSelector(chart);
+ }
+
+ resetMargins();
+ setChartSize();
+
+ // Set the common inversion and transformation for inverted series after initSeries
+ setInverted();
+
+ // get axes
+ getAxes();
+
+ // Initialize the series
+ each(options.series || [], function (serieOptions) {
+ initSeries(serieOptions);
+ });
+
+ // Run an event where series and axes can be added
+ //fireEvent(chart, 'beforeRender');
+
+ // Initialize scroller for stock charts
+ if (Highcharts.Scroller && (options.navigator.enabled || options.scrollbar.enabled)) {
+ chart.scroller = new Highcharts.Scroller(chart);
+ }
+
+ chart.render = render;
+
+ // depends on inverted and on margins being set
+ chart.tracker = tracker = new MouseTracker(options.tooltip);
+
+
+ render();
+
+ // run callbacks
+ if (callback) {
+ callback.apply(chart, [chart]);
+ }
+ each(chart.callbacks, function (fn) {
+ fn.apply(chart, [chart]);
+ });
+
+ fireEvent(chart, 'load');
+
+ }
+
+ // Run chart
+
+ // Set up auto resize
+ if (optionsChart.reflow !== false) {
+ addEvent(chart, 'load', initReflow);
+ }
+
+ // Chart event handlers
+ if (chartEvents) {
+ for (eventType in chartEvents) {
+ addEvent(chart, eventType, chartEvents[eventType]);
+ }
+ }
+
+
+ chart.options = options;
+ chart.series = series;
+
+
+ chart.xAxis = [];
+ chart.yAxis = [];
+
+
+
+
+ // Expose methods and variables
+ chart.addSeries = addSeries;
+ chart.animation = pick(optionsChart.animation, true);
+ chart.Axis = Axis;
+ chart.destroy = destroy;
+ chart.get = get;
+ chart.getSelectedPoints = getSelectedPoints;
+ chart.getSelectedSeries = getSelectedSeries;
+ chart.hideLoading = hideLoading;
+ chart.initSeries = initSeries;
+ chart.isInsidePlot = isInsidePlot;
+ chart.redraw = redraw;
+ chart.setSize = resize;
+ chart.setTitle = setTitle;
+ chart.showLoading = showLoading;
+ chart.pointCount = 0;
+ chart.counters = new ChartCounters();
+ /*
+ if ($) $(function () {
+ $container = $('#container');
+ var origChartWidth,
+ origChartHeight;
+ if ($container) {
+ $('<button>+</button>')
+ .insertBefore($container)
+ .click(function () {
+ if (origChartWidth === UNDEFINED) {
+ origChartWidth = chartWidth;
+ origChartHeight = chartHeight;
+ }
+ chart.resize(chartWidth *= 1.1, chartHeight *= 1.1);
+ });
+ $('<button>-</button>')
+ .insertBefore($container)
+ .click(function () {
+ if (origChartWidth === UNDEFINED) {
+ origChartWidth = chartWidth;
+ origChartHeight = chartHeight;
+ }
+ chart.resize(chartWidth *= 0.9, chartHeight *= 0.9);
+ });
+ $('<button>1:1</button>')
+ .insertBefore($container)
+ .click(function () {
+ if (origChartWidth === UNDEFINED) {
+ origChartWidth = chartWidth;
+ origChartHeight = chartHeight;
+ }
+ chart.resize(origChartWidth, origChartHeight);
+ });
+ }
+ })
+ */
+
+
+
+
+ firstRender();
+
+
+} // end Chart
+
+// Hook for exporting module
+Chart.prototype.callbacks = [];
+/**
+ * The Point object and prototype. Inheritable and used as base for PiePoint
+ */
+var Point = function () {};
+Point.prototype = {
+
+ /**
+ * Initialize the point
+ * @param {Object} series The series object containing this point
+ * @param {Object} options The data in either number, array or object format
+ */
+ init: function (series, options, x) {
+ var point = this,
+ counters = series.chart.counters,
+ defaultColors;
+ point.series = series;
+ point.applyOptions(options, x);
+ point.pointAttr = {};
+
+ if (series.options.colorByPoint) {
+ defaultColors = series.chart.options.colors;
+ if (!point.options) {
+ point.options = {};
+ }
+ point.color = point.options.color = point.color || defaultColors[counters.color++];
+
+ // loop back to zero
+ counters.wrapColor(defaultColors.length);
+ }
+
+ series.chart.pointCount++;
+ return point;
+ },
+ /**
+ * Apply the options containing the x and y data and possible some extra properties.
+ * This is called on point init or from point.update.
+ *
+ * @param {Object} options
+ */
+ applyOptions: function (options, x) {
+ var point = this,
+ series = point.series,
+ optionsType = typeof options;
+
+ point.config = options;
+
+ // onedimensional array input
+ if (optionsType === 'number' || options === null) {
+ point.y = options;
+ } else if (typeof options[0] === 'number') { // two-dimentional array
+ point.x = options[0];
+ point.y = options[1];
+ } else if (optionsType === 'object' && typeof options.length !== 'number') { // object input
+ // copy options directly to point
+ extend(point, options);
+ point.options = options;
+ } else if (typeof options[0] === 'string') { // categorized data with name in first position
+ point.name = options[0];
+ point.y = options[1];
+ }
+
+ /*
+ * If no x is set by now, get auto incremented value. All points must have an
+ * x value, however the y value can be null to create a gap in the series
+ */
+
+ // todo: skip this? It is only used in applyOptions, in translate it should not be used
+ if (point.x === UNDEFINED) {
+ point.x = x === UNDEFINED ? series.autoIncrement() : x;
+ }
+
+ },
+
+ /**
+ * Destroy a point to clear memory. Its reference still stays in series.data.
+ */
+ destroy: function () {
+ var point = this,
+ series = point.series,
+ hoverPoints = series.chart.hoverPoints,
+ prop;
+
+ series.chart.pointCount--;
+
+ if (hoverPoints) {
+ point.setState();
+ erase(hoverPoints, point);
+ }
+ if (point === series.chart.hoverPoint) {
+ point.onMouseOut();
+ }
+ series.chart.hoverPoints = null;
+
+ // remove all events
+ if (point.graphic || point.dataLabel) { // removeEvent and destroyElements are performance expensive
+ removeEvent(point);
+ point.destroyElements();
+ }
+
+ if (point.legendItem) { // pies have legend items
+ point.series.chart.legend.destroyItem(point);
+ }
+
+ for (prop in point) {
+ point[prop] = null;
+ }
+
+
+ },
+
+ /**
+ * Destroy SVG elements associated with the point
+ */
+ destroyElements: function () {
+ var point = this,
+ props = ['graphic', 'tracker', 'dataLabel', 'group', 'connector', 'shadowGroup'],
+ prop,
+ i = 6;
+ while (i--) {
+ prop = props[i];
+ if (point[prop]) {
+ point[prop] = point[prop].destroy();
+ }
+ }
+ },
+
+ /**
+ * Return the configuration hash needed for the data label and tooltip formatters
+ */
+ getLabelConfig: function () {
+ var point = this;
+ return {
+ x: point.category,
+ y: point.y,
+ key: point.name || point.category,
+ series: point.series,
+ point: point,
+ percentage: point.percentage,
+ total: point.total || point.stackTotal
+ };
+ },
+
+ /**
+ * Toggle the selection status of a point
+ * @param {Boolean} selected Whether to select or unselect the point.
+ * @param {Boolean} accumulate Whether to add to the previous selection. By default,
+ * this happens if the control key (Cmd on Mac) was pressed during clicking.
+ */
+ select: function (selected, accumulate) {
+ var point = this,
+ series = point.series,
+ chart = series.chart;
+
+ selected = pick(selected, !point.selected);
+
+ // fire the event with the defalut handler
+ point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
+ point.selected = selected;
+ point.setState(selected && SELECT_STATE);
+
+ // unselect all other points unless Ctrl or Cmd + click
+ if (!accumulate) {
+ each(chart.getSelectedPoints(), function (loopPoint) {
+ if (loopPoint.selected && loopPoint !== point) {
+ loopPoint.selected = false;
+ loopPoint.setState(NORMAL_STATE);
+ loopPoint.firePointEvent('unselect');
+ }
+ });
+ }
+ });
+ },
+
+ onMouseOver: function () {
+ var point = this,
+ series = point.series,
+ chart = series.chart,
+ tooltip = chart.tooltip,
+ hoverPoint = chart.hoverPoint;
+
+ // set normal state to previous series
+ if (hoverPoint && hoverPoint !== point) {
+ hoverPoint.onMouseOut();
+ }
+
+ // trigger the event
+ point.firePointEvent('mouseOver');
+
+ // update the tooltip
+ if (tooltip && (!tooltip.shared || series.noSharedTooltip)) {
+ tooltip.refresh(point);
+ }
+
+ // hover this
+ point.setState(HOVER_STATE);
+ chart.hoverPoint = point;
+ },
+
+ onMouseOut: function () {
+ var point = this;
+ point.firePointEvent('mouseOut');
+
+ point.setState();
+ point.series.chart.hoverPoint = null;
+ },
+
+ /**
+ * Extendable method for formatting each point's tooltip line
+ *
+ * @return {String} A string to be concatenated in to the common tooltip text
+ */
+ tooltipFormatter: function (pointFormat) {
+ var point = this,
+ series = point.series,
+ seriesTooltipOptions = series.tooltipOptions,
+ split = String(point.y).split('.'),
+ originalDecimals = split[1] ? split[1].length : 0,
+ match = pointFormat.match(/\{(series|point)\.[a-zA-Z]+\}/g),
+ splitter = /[\.}]/,
+ obj,
+ key,
+ replacement,
+ i;
+
+ // loop over the variables defined on the form {series.name}, {point.y} etc
+ for (i in match) {
+ key = match[i];
+
+ if (isString(key) && key !== pointFormat) { // IE matches more than just the variables
+ obj = key.indexOf('point') === 1 ? point : series;
+
+ if (key === '{point.y}') { // add some preformatting
+ replacement = (seriesTooltipOptions.valuePrefix || seriesTooltipOptions.yPrefix || '') +
+ numberFormat(point.y, pick(seriesTooltipOptions.valueDecimals, seriesTooltipOptions.yDecimals, originalDecimals)) +
+ (seriesTooltipOptions.valueSuffix || seriesTooltipOptions.ySuffix || '');
+
+ } else { // automatic replacement
+ replacement = obj[match[i].split(splitter)[1]];
+ }
+
+ pointFormat = pointFormat.replace(match[i], replacement);
+ }
+ }
+
+ return pointFormat;
+ },
+
+ /**
+ * Update the point with new options (typically x/y data) and optionally redraw the series.
+ *
+ * @param {Object} options Point options as defined in the series.data array
+ * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ *
+ */
+ update: function (options, redraw, animation) {
+ var point = this,
+ series = point.series,
+ graphic = point.graphic,
+ i,
+ data = series.data,
+ dataLength = data.length,
+ chart = series.chart;
+
+ redraw = pick(redraw, true);
+
+ // fire the event with a default handler of doing the update
+ point.firePointEvent('update', { options: options }, function () {
+
+ point.applyOptions(options);
+
+ // update visuals
+ if (isObject(options)) {
+ series.getAttribs();
+ if (graphic) {
+ graphic.attr(point.pointAttr[series.state]);
+ }
+ }
+
+ // record changes in the parallel arrays
+ for (i = 0; i < dataLength; i++) {
+ if (data[i] === point) {
+ series.xData[i] = point.x;
+ series.yData[i] = point.y;
+ series.options.data[i] = options;
+ break;
+ }
+ }
+
+ // redraw
+ series.isDirty = true;
+ series.isDirtyData = true;
+ if (redraw) {
+ chart.redraw(animation);
+ }
+ });
+ },
+
+ /**
+ * Remove a point and optionally redraw the series and if necessary the axes
+ * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ */
+ remove: function (redraw, animation) {
+ var point = this,
+ series = point.series,
+ chart = series.chart,
+ i,
+ data = series.data,
+ dataLength = data.length;
+
+ setAnimation(animation, chart);
+ redraw = pick(redraw, true);
+
+ // fire the event with a default handler of removing the point
+ point.firePointEvent('remove', null, function () {
+
+ //erase(series.data, point);
+
+ for (i = 0; i < dataLength; i++) {
+ if (data[i] === point) {
+
+ // splice all the parallel arrays
+ data.splice(i, 1);
+ series.options.data.splice(i, 1);
+ series.xData.splice(i, 1);
+ series.yData.splice(i, 1);
+ break;
+ }
+ }
+
+ point.destroy();
+
+
+ // redraw
+ series.isDirty = true;
+ series.isDirtyData = true;
+ if (redraw) {
+ chart.redraw();
+ }
+ });
+
+
+ },
+
+ /**
+ * Fire an event on the Point object. Must not be renamed to fireEvent, as this
+ * causes a name clash in MooTools
+ * @param {String} eventType
+ * @param {Object} eventArgs Additional event arguments
+ * @param {Function} defaultFunction Default event handler
+ */
+ firePointEvent: function (eventType, eventArgs, defaultFunction) {
+ var point = this,
+ series = this.series,
+ seriesOptions = series.options;
+
+ // load event handlers on demand to save time on mouseover/out
+ if (seriesOptions.point.events[eventType] || (point.options && point.options.events && point.options.events[eventType])) {
+ this.importEvents();
+ }
+
+ // add default handler if in selection mode
+ if (eventType === 'click' && seriesOptions.allowPointSelect) {
+ defaultFunction = function (event) {
+ // Control key is for Windows, meta (= Cmd key) for Mac, Shift for Opera
+ point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
+ };
+ }
+
+ fireEvent(this, eventType, eventArgs, defaultFunction);
+ },
+ /**
+ * Import events from the series' and point's options. Only do it on
+ * demand, to save processing time on hovering.
+ */
+ importEvents: function () {
+ if (!this.hasImportedEvents) {
+ var point = this,
+ options = merge(point.series.options.point, point.options),
+ events = options.events,
+ eventType;
+
+ point.events = events;
+
+ for (eventType in events) {
+ addEvent(point, eventType, events[eventType]);
+ }
+ this.hasImportedEvents = true;
+
+ }
+ },
+
+ /**
+ * Set the point's state
+ * @param {String} state
+ */
+ setState: function (state) {
+ var point = this,
+ plotX = point.plotX,
+ plotY = point.plotY,
+ series = point.series,
+ stateOptions = series.options.states,
+ markerOptions = defaultPlotOptions[series.type].marker && series.options.marker,
+ normalDisabled = markerOptions && !markerOptions.enabled,
+ markerStateOptions = markerOptions && markerOptions.states[state],
+ stateDisabled = markerStateOptions && markerStateOptions.enabled === false,
+ stateMarkerGraphic = series.stateMarkerGraphic,
+ chart = series.chart,
+ radius,
+ pointAttr = point.pointAttr;
+
+ state = state || NORMAL_STATE; // empty string
+
+ if (
+ // already has this state
+ state === point.state ||
+ // selected points don't respond to hover
+ (point.selected && state !== SELECT_STATE) ||
+ // series' state options is disabled
+ (stateOptions[state] && stateOptions[state].enabled === false) ||
+ // point marker's state options is disabled
+ (state && (stateDisabled || (normalDisabled && !markerStateOptions.enabled)))
+
+ ) {
+ return;
+ }
+
+ // apply hover styles to the existing point
+ if (point.graphic) {
+ radius = point.graphic.symbolName && pointAttr[state].r;
+ point.graphic.attr(merge(
+ pointAttr[state],
+ radius ? { // new symbol attributes (#507, #612)
+ x: plotX - radius,
+ y: plotY - radius,
+ width: 2 * radius,
+ height: 2 * radius
+ } : {}
+ ));
+ } else {
+ // if a graphic is not applied to each point in the normal state, create a shared
+ // graphic for the hover state
+ if (state) {
+ if (!stateMarkerGraphic) {
+ radius = markerOptions.radius;
+ series.stateMarkerGraphic = stateMarkerGraphic = chart.renderer.symbol(
+ series.symbol,
+ -radius,
+ -radius,
+ 2 * radius,
+ 2 * radius
+ )
+ .attr(pointAttr[state])
+ .add(series.group);
+ }
+
+ stateMarkerGraphic.translate(
+ plotX,
+ plotY
+ );
+ }
+
+ if (stateMarkerGraphic) {
+ stateMarkerGraphic[state ? 'show' : 'hide']();
+ }
+ }
+
+ point.state = state;
+ }
+};
+
+/**
+ * @classDescription The base function which all other series types inherit from. The data in the series is stored
+ * in various arrays.
+ *
+ * - First, series.options.data contains all the original config options for
+ * each point whether added by options or methods like series.addPoint.
+ * - Next, series.data contains those values converted to points, but in case the series data length
+ * exceeds the cropThreshold, or if the data is grouped, series.data doesn't contain all the points. It
+ * only contains the points that have been created on demand.
+ * - Then there's series.points that contains all currently visible point objects. In case of cropping,
+ * the cropped-away points are not part of this array. The series.points array starts at series.cropStart
+ * compared to series.data and series.options.data. If however the series data is grouped, these can't
+ * be correlated one to one.
+ * - series.xData and series.processedXData contain clean x values, equivalent to series.data and series.points.
+ * - series.yData and series.processedYData contain clean x values, equivalent to series.data and series.points.
+ *
+ * @param {Object} chart
+ * @param {Object} options
+ */
+var Series = function () {};
+
+Series.prototype = {
+
+ isCartesian: true,
+ type: 'line',
+ pointClass: Point,
+ pointAttrToOptions: { // mapping between SVG attributes and the corresponding options
+ stroke: 'lineColor',
+ 'stroke-width': 'lineWidth',
+ fill: 'fillColor',
+ r: 'radius'
+ },
+ init: function (chart, options) {
+ var series = this,
+ eventType,
+ events,
+ //pointEvent,
+ index = chart.series.length;
+
+ series.chart = chart;
+ series.options = options = series.setOptions(options); // merge with plotOptions
+
+ // bind the axes
+ series.bindAxes();
+
+ // set some variables
+ extend(series, {
+ index: index,
+ name: options.name || 'Series ' + (index + 1),
+ state: NORMAL_STATE,
+ pointAttr: {},
+ visible: options.visible !== false, // true by default
+ selected: options.selected === true // false by default
+ });
+
+ // register event listeners
+ events = options.events;
+ for (eventType in events) {
+ addEvent(series, eventType, events[eventType]);
+ }
+ if (
+ (events && events.click) ||
+ (options.point && options.point.events && options.point.events.click) ||
+ options.allowPointSelect
+ ) {
+ chart.runTrackerClick = true;
+ }
+
+ series.getColor();
+ series.getSymbol();
+
+ // set the data
+ series.setData(options.data, false);
+
+ },
+
+
+
+ /**
+ * Set the xAxis and yAxis properties of cartesian series, and register the series
+ * in the axis.series array
+ */
+ bindAxes: function () {
+ var series = this,
+ seriesOptions = series.options,
+ chart = series.chart,
+ axisOptions;
+
+ if (series.isCartesian) {
+
+ each(['xAxis', 'yAxis'], function (AXIS) { // repeat for xAxis and yAxis
+
+ each(chart[AXIS], function (axis) { // loop through the chart's axis objects
+
+ axisOptions = axis.options;
+
+ // apply if the series xAxis or yAxis option mathches the number of the
+ // axis, or if undefined, use the first axis
+ if ((seriesOptions[AXIS] === axisOptions.index) ||
+ (seriesOptions[AXIS] === UNDEFINED && axisOptions.index === 0)) {
+
+ // register this series in the axis.series lookup
+ axis.series.push(series);
+
+ // set this series.xAxis or series.yAxis reference
+ series[AXIS] = axis;
+
+ // mark dirty for redraw
+ axis.isDirty = true;
+ }
+ });
+
+ });
+ }
+ },
+
+
+ /**
+ * Return an auto incremented x value based on the pointStart and pointInterval options.
+ * This is only used if an x value is not given for the point that calls autoIncrement.
+ */
+ autoIncrement: function () {
+ var series = this,
+ options = series.options,
+ xIncrement = series.xIncrement;
+
+ xIncrement = pick(xIncrement, options.pointStart, 0);
+
+ series.pointInterval = pick(series.pointInterval, options.pointInterval, 1);
+
+ series.xIncrement = xIncrement + series.pointInterval;
+ return xIncrement;
+ },
+
+ /**
+ * Divide the series data into segments divided by null values.
+ */
+ getSegments: function () {
+ var series = this,
+ lastNull = -1,
+ segments = [],
+ i,
+ points = series.points,
+ pointsLength = points.length;
+
+ if (pointsLength) { // no action required for []
+
+ // if connect nulls, just remove null points
+ if (series.options.connectNulls) {
+ i = pointsLength;
+ while (i--) {
+ if (points[i].y === null) {
+ points.splice(i, 1);
+ }
+ }
+ segments = [points];
+
+ // else, split on null points
+ } else {
+ each(points, function (point, i) {
+ if (point.y === null) {
+ if (i > lastNull + 1) {
+ segments.push(points.slice(lastNull + 1, i));
+ }
+ lastNull = i;
+ } else if (i === pointsLength - 1) { // last value
+ segments.push(points.slice(lastNull + 1, i + 1));
+ }
+ });
+ }
+ }
+
+ // register it
+ series.segments = segments;
+ },
+ /**
+ * Set the series options by merging from the options tree
+ * @param {Object} itemOptions
+ */
+ setOptions: function (itemOptions) {
+ var series = this,
+ chart = series.chart,
+ chartOptions = chart.options,
+ plotOptions = chartOptions.plotOptions,
+ data = itemOptions.data,
+ options;
+
+ itemOptions.data = null; // remove from merge to prevent looping over the data set
+
+ options = merge(
+ plotOptions[this.type],
+ plotOptions.series,
+ itemOptions
+ );
+
+ // Re-insert the data array to the options and the original config (#717)
+ options.data = itemOptions.data = data;
+
+ // the tooltip options are merged between global and series specific options
+ series.tooltipOptions = merge(chartOptions.tooltip, options.tooltip);
+
+ return options;
+
+ },
+ /**
+ * Get the series' color
+ */
+ getColor: function () {
+ var defaultColors = this.chart.options.colors,
+ counters = this.chart.counters;
+ this.color = this.options.color || defaultColors[counters.color++] || '#0000ff';
+ counters.wrapColor(defaultColors.length);
+ },
+ /**
+ * Get the series' symbol
+ */
+ getSymbol: function () {
+ var series = this,
+ seriesMarkerOption = series.options.marker,
+ chart = series.chart,
+ defaultSymbols = chart.options.symbols,
+ counters = chart.counters;
+ series.symbol = seriesMarkerOption.symbol || defaultSymbols[counters.symbol++];
+
+ // don't substract radius in image symbols (#604)
+ if (/^url/.test(series.symbol)) {
+ seriesMarkerOption.radius = 0;
+ }
+ counters.wrapSymbol(defaultSymbols.length);
+ },
+
+ /**
+ * Add a point dynamically after chart load time
+ * @param {Object} options Point options as given in series.data
+ * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
+ * @param {Boolean} shift If shift is true, a point is shifted off the start
+ * of the series as one is appended to the end.
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ */
+ addPoint: function (options, redraw, shift, animation) {
+ var series = this,
+ data = series.data,
+ graph = series.graph,
+ area = series.area,
+ chart = series.chart,
+ xData = series.xData,
+ yData = series.yData,
+ currentShift = (graph && graph.shift) || 0,
+ dataOptions = series.options.data,
+ point;
+ //point = (new series.pointClass()).init(series, options);
+
+ setAnimation(animation, chart);
+
+ if (graph && shift) { // make graph animate sideways
+ graph.shift = currentShift + 1;
+ }
+ if (area) {
+ area.shift = currentShift + 1;
+ area.isArea = true;
+ }
+ redraw = pick(redraw, true);
+
+
+ // Get options and push the point to xData, yData and series.options. In series.generatePoints
+ // the Point instance will be created on demand and pushed to the series.data array.
+ point = { series: series };
+ series.pointClass.prototype.applyOptions.apply(point, [options]);
+ xData.push(point.x);
+ yData.push(series.valueCount === 4 ? [point.open, point.high, point.low, point.close] : point.y);
+ dataOptions.push(options);
+
+
+ // Shift the first point off the parallel arrays
+ // todo: consider series.removePoint(i) method
+ if (shift) {
+ if (data[0]) {
+ data[0].remove(false);
+ } else {
+ data.shift();
+ xData.shift();
+ yData.shift();
+ dataOptions.shift();
+ }
+ }
+ series.getAttribs();
+
+ // redraw
+ series.isDirty = true;
+ series.isDirtyData = true;
+ if (redraw) {
+ chart.redraw();
+ }
+ },
+
+ /**
+ * Replace the series data with a new set of data
+ * @param {Object} data
+ * @param {Object} redraw
+ */
+ setData: function (data, redraw) {
+ var series = this,
+ oldData = series.points,
+ options = series.options,
+ initialColor = series.initialColor,
+ chart = series.chart,
+ firstPoint = null,
+ i;
+
+ // reset properties
+ series.xIncrement = null;
+ series.pointRange = (series.xAxis && series.xAxis.categories && 1) || options.pointRange;
+
+ if (defined(initialColor)) { // reset colors for pie
+ chart.counters.color = initialColor;
+ }
+
+ // parallel arrays
+ var xData = [],
+ yData = [],
+ dataLength = data ? data.length : [],
+ turboThreshold = options.turboThreshold || 1000,
+ pt,
+ ohlc = series.valueCount === 4;
+
+ // In turbo mode, only one- or twodimensional arrays of numbers are allowed. The
+ // first value is tested, and we assume that all the rest are defined the same
+ // way. Although the 'for' loops are similar, they are repeated inside each
+ // if-else conditional for max performance.
+ if (dataLength > turboThreshold) {
+
+ // find the first non-null point
+ i = 0;
+ while (firstPoint === null && i < dataLength) {
+ firstPoint = data[i];
+ i++;
+ }
+
+
+ if (isNumber(firstPoint)) { // assume all points are numbers
+ var x = pick(options.pointStart, 0),
+ pointInterval = pick(options.pointInterval, 1);
+
+ for (i = 0; i < dataLength; i++) {
+ xData[i] = x;
+ yData[i] = data[i];
+ x += pointInterval;
+ }
+ series.xIncrement = x;
+ } else if (isArray(firstPoint)) { // assume all points are arrays
+ if (ohlc) { // [x, o, h, l, c]
+ for (i = 0; i < dataLength; i++) {
+ pt = data[i];
+ xData[i] = pt[0];
+ yData[i] = pt.slice(1, 5);
+ }
+ } else { // [x, y]
+ for (i = 0; i < dataLength; i++) {
+ pt = data[i];
+ xData[i] = pt[0];
+ yData[i] = pt[1];
+ }
+ }
+ } /* else {
+ error(12); // Highcharts expects configs to be numbers or arrays in turbo mode
+ }*/
+ } else {
+ for (i = 0; i < dataLength; i++) {
+ pt = { series: series };
+ series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
+ xData[i] = pt.x;
+ yData[i] = ohlc ? [pt.open, pt.high, pt.low, pt.close] : pt.y;
+ }
+ }
+
+ series.data = [];
+ series.options.data = data;
+ series.xData = xData;
+ series.yData = yData;
+
+ // destroy old points
+ i = (oldData && oldData.length) || 0;
+ while (i--) {
+ if (oldData[i] && oldData[i].destroy) {
+ oldData[i].destroy();
+ }
+ }
+
+ // redraw
+ series.isDirty = series.isDirtyData = chart.isDirtyBox = true;
+ if (pick(redraw, true)) {
+ chart.redraw(false);
+ }
+ },
+
+ /**
+ * Remove a series and optionally redraw the chart
+ *
+ * @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
+ * @param {Boolean|Object} animation Whether to apply animation, and optionally animation
+ * configuration
+ */
+
+ remove: function (redraw, animation) {
+ var series = this,
+ chart = series.chart;
+ redraw = pick(redraw, true);
+
+ if (!series.isRemoving) { /* prevent triggering native event in jQuery
+ (calling the remove function from the remove event) */
+ series.isRemoving = true;
+
+ // fire the event with a default handler of removing the point
+ fireEvent(series, 'remove', null, function () {
+
+
+ // destroy elements
+ series.destroy();
+
+
+ // redraw
+ chart.isDirtyLegend = chart.isDirtyBox = true;
+ if (redraw) {
+ chart.redraw(animation);
+ }
+ });
+
+ }
+ series.isRemoving = false;
+ },
+
+ /**
+ * Process the data by cropping away unused data points if the series is longer
+ * than the crop threshold. This saves computing time for lage series.
+ */
+ processData: function (force) {
+ var series = this,
+ processedXData = series.xData, // copied during slice operation below
+ processedYData = series.yData,
+ dataLength = processedXData.length,
+ cropStart = 0,
+ cropEnd = dataLength,
+ cropped,
+ distance,
+ closestPointRange,
+ xAxis = series.xAxis,
+ i, // loop variable
+ options = series.options,
+ cropThreshold = options.cropThreshold;
+
+ // If the series data or axes haven't changed, don't go through this. Return false to pass
+ // the message on to override methods like in data grouping.
+ if (series.isCartesian && !series.isDirty && !xAxis.isDirty && !series.yAxis.isDirty && !force) {
+ return false;
+ }
+
+ // optionally filter out points outside the plot area
+ if (!cropThreshold || dataLength > cropThreshold || series.forceCrop) {
+ var extremes = xAxis.getExtremes(),
+ min = extremes.min,
+ max = extremes.max;
+
+ // it's outside current extremes
+ if (processedXData[dataLength - 1] < min || processedXData[0] > max) {
+ processedXData = [];
+ processedYData = [];
+
+ // only crop if it's actually spilling out
+ } else if (processedXData[0] < min || processedXData[dataLength - 1] > max) {
+
+ // iterate up to find slice start
+ for (i = 0; i < dataLength; i++) {
+ if (processedXData[i] >= min) {
+ cropStart = mathMax(0, i - 1);
+ break;
+ }
+ }
+ // proceed to find slice end
+ for (; i < dataLength; i++) {
+ if (processedXData[i] > max) {
+ cropEnd = i + 1;
+ break;
+ }
+
+ }
+ processedXData = processedXData.slice(cropStart, cropEnd);
+ processedYData = processedYData.slice(cropStart, cropEnd);
+ cropped = true;
+ }
+ }
+
+
+ // Find the closest distance between processed points
+ for (i = processedXData.length - 1; i > 0; i--) {
+ distance = processedXData[i] - processedXData[i - 1];
+ if (closestPointRange === UNDEFINED || distance < closestPointRange) {
+ closestPointRange = distance;
+ }
+ }
+
+ // Record the properties
+ series.cropped = cropped; // undefined or true
+ series.cropStart = cropStart;
+ series.processedXData = processedXData;
+ series.processedYData = processedYData;
+
+ if (options.pointRange === null) { // null means auto, as for columns, candlesticks and OHLC
+ series.pointRange = closestPointRange || 1;
+ }
+ series.closestPointRange = closestPointRange;
+
+ },
+
+ /**
+ * Generate the data point after the data has been processed by cropping away
+ * unused points and optionally grouped in Highcharts Stock.
+ */
+ generatePoints: function () {
+ var series = this,
+ options = series.options,
+ dataOptions = options.data,
+ data = series.data,
+ dataLength,
+ processedXData = series.processedXData,
+ processedYData = series.processedYData,
+ pointClass = series.pointClass,
+ processedDataLength = processedXData.length,
+ cropStart = series.cropStart || 0,
+ cursor,
+ hasGroupedData = series.hasGroupedData,
+ point,
+ points = [],
+ i;
+
+ if (!data && !hasGroupedData) {
+ var arr = [];
+ arr.length = dataOptions.length;
+ data = series.data = arr;
+ }
+
+ for (i = 0; i < processedDataLength; i++) {
+ cursor = cropStart + i;
+ if (!hasGroupedData) {
+ if (data[cursor]) {
+ point = data[cursor];
+ } else {
+ data[cursor] = point = (new pointClass()).init(series, dataOptions[cursor], processedXData[i]);
+ }
+ points[i] = point;
+ } else {
+ // splat the y data in case of ohlc data array
+ points[i] = (new pointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
+ }
+ }
+
+ // Hide cropped-away points - this only runs when the number of points is above cropThreshold, or when
+ // swithching view from non-grouped data to grouped data (#637)
+ if (data && (processedDataLength !== (dataLength = data.length) || hasGroupedData)) {
+ for (i = 0; i < dataLength; i++) {
+ if (i === cropStart && !hasGroupedData) { // when has grouped data, clear all points
+ i += processedDataLength;
+ }
+ if (data[i]) {
+ data[i].destroyElements();
+ }
+ }
+ }
+
+ series.data = data;
+ series.points = points;
+ },
+
+ /**
+ * Translate data points from raw data values to chart specific positioning data
+ * needed later in drawPoints, drawGraph and drawTracker.
+ */
+ translate: function () {
+ if (!this.processedXData) { // hidden series
+ this.processData();
+ }
+ this.generatePoints();
+ var series = this,
+ chart = series.chart,
+ options = series.options,
+ stacking = options.stacking,
+ xAxis = series.xAxis,
+ categories = xAxis.categories,
+ yAxis = series.yAxis,
+ points = series.points,
+ dataLength = points.length,
+ hasModifyValue = !!series.modifyValue,
+ isLastSeries = series.index === yAxis.series.length - 1,
+ i;
+
+ for (i = 0; i < dataLength; i++) {
+ var point = points[i],
+ xValue = point.x,
+ yValue = point.y,
+ yBottom = point.low,
+ stack = yAxis.stacks[(yValue < options.threshold ? '-' : '') + series.stackKey],
+ pointStack,
+ pointStackTotal;
+
+ // get the plotX translation
+ point.plotX = mathRound(xAxis.translate(xValue) * 10) / 10; // Math.round fixes #591
+
+ // calculate the bottom y value for stacked series
+ if (stacking && series.visible && stack && stack[xValue]) {
+ pointStack = stack[xValue];
+ pointStackTotal = pointStack.total;
+ pointStack.cum = yBottom = pointStack.cum - yValue; // start from top
+ yValue = yBottom + yValue;
+
+ if (isLastSeries) {
+ yBottom = options.threshold;
+ }
+
+ if (stacking === 'percent') {
+ yBottom = pointStackTotal ? yBottom * 100 / pointStackTotal : 0;
+ yValue = pointStackTotal ? yValue * 100 / pointStackTotal : 0;
+ }
+
+ point.percentage = pointStackTotal ? point.y * 100 / pointStackTotal : 0;
+ point.stackTotal = pointStackTotal;
+ }
+
+ if (defined(yBottom)) {
+ point.yBottom = yAxis.translate(yBottom, 0, 1, 0, 1);
+ }
+
+ // general hook, used for Highstock compare mode
+ if (hasModifyValue) {
+ yValue = series.modifyValue(yValue, point);
+ }
+
+ // set the y value
+ if (yValue !== null) {
+ point.plotY = mathRound(yAxis.translate(yValue, 0, 1, 0, 1) * 10) / 10; // Math.round fixes #591
+ }
+
+ // set client related positions for mouse tracking
+ point.clientX = chart.inverted ?
+ chart.plotHeight - point.plotX :
+ point.plotX; // for mouse tracking
+
+ // some API data
+ point.category = categories && categories[point.x] !== UNDEFINED ?
+ categories[point.x] : point.x;
+
+
+ }
+
+ // now that we have the cropped data, build the segments
+ series.getSegments();
+ },
+ /**
+ * Memoize tooltip texts and positions
+ */
+ setTooltipPoints: function (renew) {
+ var series = this,
+ chart = series.chart,
+ inverted = chart.inverted,
+ points = [],
+ pointsLength,
+ plotSize = mathRound((inverted ? chart.plotTop : chart.plotLeft) + chart.plotSizeX),
+ low,
+ high,
+ xAxis = series.xAxis,
+ point,
+ i,
+ tooltipPoints = []; // a lookup array for each pixel in the x dimension
+
+ // don't waste resources if tracker is disabled
+ if (series.options.enableMouseTracking === false) {
+ return;
+ }
+
+ // renew
+ if (renew) {
+ series.tooltipPoints = null;
+ }
+
+ // concat segments to overcome null values
+ each(series.segments || series.points, function (segment) {
+ points = points.concat(segment);
+ });
+
+ // loop the concatenated points and apply each point to all the closest
+ // pixel positions
+ if (xAxis && xAxis.reversed) {
+ points = points.reverse();//reverseArray(points);
+ }
+
+ //each(points, function (point, i) {
+ pointsLength = points.length;
+ for (i = 0; i < pointsLength; i++) {
+ point = points[i];
+ low = points[i - 1] ? points[i - 1]._high + 1 : 0;
+ high = point._high = points[i + 1] ?
+ (mathFloor((point.plotX + (points[i + 1] ? points[i + 1].plotX : plotSize)) / 2)) :
+ plotSize;
+
+ while (low <= high) {
+ tooltipPoints[inverted ? plotSize - low++ : low++] = point;
+ }
+ }
+ series.tooltipPoints = tooltipPoints;
+ },
+
+ /**
+ * Format the header of the tooltip
+ */
+ tooltipHeaderFormatter: function (key) {
+ var series = this,
+ tooltipOptions = series.tooltipOptions,
+ xDateFormat = tooltipOptions.xDateFormat || '%A, %b %e, %Y',
+ xAxis = series.xAxis,
+ isDateTime = xAxis && xAxis.options.type === 'datetime';
+
+ return tooltipOptions.headerFormat
+ .replace('{point.key}', isDateTime ? dateFormat(xDateFormat, key) : key)
+ .replace('{series.name}', series.name)
+ .replace('{series.color}', series.color);
+ },
+
+ /**
+ * Series mouse over handler
+ */
+ onMouseOver: function () {
+ var series = this,
+ chart = series.chart,
+ hoverSeries = chart.hoverSeries;
+
+ if (!hasTouch && chart.mouseIsDown) {
+ return;
+ }
+
+ // set normal state to previous series
+ if (hoverSeries && hoverSeries !== series) {
+ hoverSeries.onMouseOut();
+ }
+
+ // trigger the event, but to save processing time,
+ // only if defined
+ if (series.options.events.mouseOver) {
+ fireEvent(series, 'mouseOver');
+ }
+
+ // hover this
+ series.setState(HOVER_STATE);
+ chart.hoverSeries = series;
+ },
+
+ /**
+ * Series mouse out handler
+ */
+ onMouseOut: function () {
+ // trigger the event only if listeners exist
+ var series = this,
+ options = series.options,
+ chart = series.chart,
+ tooltip = chart.tooltip,
+ hoverPoint = chart.hoverPoint;
+
+ // trigger mouse out on the point, which must be in this series
+ if (hoverPoint) {
+ hoverPoint.onMouseOut();
+ }
+
+ // fire the mouse out event
+ if (series && options.events.mouseOut) {
+ fireEvent(series, 'mouseOut');
+ }
+
+
+ // hide the tooltip
+ if (tooltip && !options.stickyTracking && !tooltip.shared) {
+ tooltip.hide();
+ }
+
+ // set normal state
+ series.setState();
+ chart.hoverSeries = null;
+ },
+
+ /**
+ * Animate in the series
+ */
+ animate: function (init) {
+ var series = this,
+ chart = series.chart,
+ clipRect = series.clipRect,
+ animation = series.options.animation;
+
+ if (animation && !isObject(animation)) {
+ animation = {};
+ }
+
+ if (init) { // initialize the animation
+ if (!clipRect.isAnimating) { // apply it only for one of the series
+ clipRect.attr('width', 0);
+ clipRect.isAnimating = true;
+ }
+
+ } else { // run the animation
+ clipRect.animate({
+ width: chart.plotSizeX
+ }, animation);
+
+ // delete this function to allow it only once
+ this.animate = null;
+ }
+ },
+
+
+ /**
+ * Draw the markers
+ */
+ drawPoints: function () {
+ var series = this,
+ pointAttr,
+ points = series.points,
+ chart = series.chart,
+ plotX,
+ plotY,
+ i,
+ point,
+ radius,
+ symbol,
+ isImage,
+ graphic;
+
+ if (series.options.marker.enabled) {
+ i = points.length;
+ while (i--) {
+ point = points[i];
+ plotX = point.plotX;
+ plotY = point.plotY;
+ graphic = point.graphic;
+
+ // only draw the point if y is defined
+ if (plotY !== UNDEFINED && !isNaN(plotY)) {
+
+ // shortcuts
+ pointAttr = point.pointAttr[point.selected ? SELECT_STATE : NORMAL_STATE];
+ radius = pointAttr.r;
+ symbol = pick(point.marker && point.marker.symbol, series.symbol);
+ isImage = symbol.indexOf('url') === 0;
+
+ if (graphic) { // update
+ graphic.animate(extend({
+ x: plotX - radius,
+ y: plotY - radius
+ }, graphic.symbolName ? { // don't apply to image symbols #507
+ width: 2 * radius,
+ height: 2 * radius
+ } : {}));
+ } else if (radius > 0 || isImage) {
+ point.graphic = chart.renderer.symbol(
+ symbol,
+ plotX - radius,
+ plotY - radius,
+ 2 * radius,
+ 2 * radius
+ )
+ .attr(pointAttr)
+ .add(series.group);
+ }
+ }
+ }
+ }
+
+ },
+
+ /**
+ * Convert state properties from API naming conventions to SVG attributes
+ *
+ * @param {Object} options API options object
+ * @param {Object} base1 SVG attribute object to inherit from
+ * @param {Object} base2 Second level SVG attribute object to inherit from
+ */
+ convertAttribs: function (options, base1, base2, base3) {
+ var conversion = this.pointAttrToOptions,
+ attr,
+ option,
+ obj = {};
+
+ options = options || {};
+ base1 = base1 || {};
+ base2 = base2 || {};
+ base3 = base3 || {};
+
+ for (attr in conversion) {
+ option = conversion[attr];
+ obj[attr] = pick(options[option], base1[attr], base2[attr], base3[attr]);
+ }
+ return obj;
+ },
+
+ /**
+ * Get the state attributes. Each series type has its own set of attributes
+ * that are allowed to change on a point's state change. Series wide attributes are stored for
+ * all series, and additionally point specific attributes are stored for all
+ * points with individual marker options. If such options are not defined for the point,
+ * a reference to the series wide attributes is stored in point.pointAttr.
+ */
+ getAttribs: function () {
+ var series = this,
+ normalOptions = defaultPlotOptions[series.type].marker ? series.options.marker : series.options,
+ stateOptions = normalOptions.states,
+ stateOptionsHover = stateOptions[HOVER_STATE],
+ pointStateOptionsHover,
+ seriesColor = series.color,
+ normalDefaults = {
+ stroke: seriesColor,
+ fill: seriesColor
+ },
+ points = series.points,
+ i,
+ point,
+ seriesPointAttr = [],
+ pointAttr,
+ pointAttrToOptions = series.pointAttrToOptions,
+ hasPointSpecificOptions,
+ key;
+
+ // series type specific modifications
+ if (series.options.marker) { // line, spline, area, areaspline, scatter
+
+ // if no hover radius is given, default to normal radius + 2
+ stateOptionsHover.radius = stateOptionsHover.radius || normalOptions.radius + 2;
+ stateOptionsHover.lineWidth = stateOptionsHover.lineWidth || normalOptions.lineWidth + 1;
+
+ } else { // column, bar, pie
+
+ // if no hover color is given, brighten the normal color
+ stateOptionsHover.color = stateOptionsHover.color ||
+ Color(stateOptionsHover.color || seriesColor)
+ .brighten(stateOptionsHover.brightness).get();
+ }
+
+ // general point attributes for the series normal state
+ seriesPointAttr[NORMAL_STATE] = series.convertAttribs(normalOptions, normalDefaults);
+
+ // HOVER_STATE and SELECT_STATE states inherit from normal state except the default radius
+ each([HOVER_STATE, SELECT_STATE], function (state) {
+ seriesPointAttr[state] =
+ series.convertAttribs(stateOptions[state], seriesPointAttr[NORMAL_STATE]);
+ });
+
+ // set it
+ series.pointAttr = seriesPointAttr;
+
+
+ // Generate the point-specific attribute collections if specific point
+ // options are given. If not, create a referance to the series wide point
+ // attributes
+ i = points.length;
+ while (i--) {
+ point = points[i];
+ normalOptions = (point.options && point.options.marker) || point.options;
+ if (normalOptions && normalOptions.enabled === false) {
+ normalOptions.radius = 0;
+ }
+ hasPointSpecificOptions = false;
+
+ // check if the point has specific visual options
+ if (point.options) {
+ for (key in pointAttrToOptions) {
+ if (defined(normalOptions[pointAttrToOptions[key]])) {
+ hasPointSpecificOptions = true;
+ }
+ }
+ }
+
+
+
+ // a specific marker config object is defined for the individual point:
+ // create it's own attribute collection
+ if (hasPointSpecificOptions) {
+
+ pointAttr = [];
+ stateOptions = normalOptions.states || {}; // reassign for individual point
+ pointStateOptionsHover = stateOptions[HOVER_STATE] = stateOptions[HOVER_STATE] || {};
+
+ // if no hover color is given, brighten the normal color
+ if (!series.options.marker) { // column, bar, point
+ pointStateOptionsHover.color =
+ Color(pointStateOptionsHover.color || point.options.color)
+ .brighten(pointStateOptionsHover.brightness ||
+ stateOptionsHover.brightness).get();
+
+ }
+
+ // normal point state inherits series wide normal state
+ pointAttr[NORMAL_STATE] = series.convertAttribs(normalOptions, seriesPointAttr[NORMAL_STATE]);
+
+ // inherit from point normal and series hover
+ pointAttr[HOVER_STATE] = series.convertAttribs(
+ stateOptions[HOVER_STATE],
+ seriesPointAttr[HOVER_STATE],
+ pointAttr[NORMAL_STATE]
+ );
+ // inherit from point normal and series hover
+ pointAttr[SELECT_STATE] = series.convertAttribs(
+ stateOptions[SELECT_STATE],
+ seriesPointAttr[SELECT_STATE],
+ pointAttr[NORMAL_STATE]
+ );
+
+
+
+ // no marker config object is created: copy a reference to the series-wide
+ // attribute collection
+ } else {
+ pointAttr = seriesPointAttr;
+ }
+
+ point.pointAttr = pointAttr;
+
+ }
+
+ },
+
+
+ /**
+ * Clear DOM objects and free up memory
+ */
+ destroy: function () {
+ var series = this,
+ chart = series.chart,
+ seriesClipRect = series.clipRect,
+ issue134 = /AppleWebKit\/533/.test(userAgent),
+ destroy,
+ i,
+ data = series.data || [],
+ point,
+ prop,
+ axis;
+
+ // add event hook
+ fireEvent(series, 'destroy');
+
+ // remove all events
+ removeEvent(series);
+
+ // erase from axes
+ each(['xAxis', 'yAxis'], function (AXIS) {
+ axis = series[AXIS];
+ if (axis) {
+ erase(axis.series, series);
+ axis.isDirty = true;
+ }
+ });
+
+ // remove legend items
+ if (series.legendItem) {
+ series.chart.legend.destroyItem(series);
+ }
+
+ // destroy all points with their elements
+ i = data.length;
+ while (i--) {
+ point = data[i];
+ if (point && point.destroy) {
+ point.destroy();
+ }
+ }
+ series.points = null;
+
+ // If this series clipRect is not the global one (which is removed on chart.destroy) we
+ // destroy it here.
+ if (seriesClipRect && seriesClipRect !== chart.clipRect) {
+ series.clipRect = seriesClipRect.destroy();
+ }
+
+ // destroy all SVGElements associated to the series
+ each(['area', 'graph', 'dataLabelsGroup', 'group', 'tracker'], function (prop) {
+ if (series[prop]) {
+
+ // issue 134 workaround
+ destroy = issue134 && prop === 'group' ?
+ 'hide' :
+ 'destroy';
+
+ series[prop][destroy]();
+ }
+ });
+
+ // remove from hoverSeries
+ if (chart.hoverSeries === series) {
+ chart.hoverSeries = null;
+ }
+ erase(chart.series, series);
+
+ // clear all members
+ for (prop in series) {
+ delete series[prop];
+ }
+ },
+
+ /**
+ * Draw the data labels
+ */
+ drawDataLabels: function () {
+ if (this.options.dataLabels.enabled) {
+ var series = this,
+ x,
+ y,
+ points = series.points,
+ seriesOptions = series.options,
+ options = seriesOptions.dataLabels,
+ pointOptions,
+ generalOptions,
+ str,
+ dataLabelsGroup = series.dataLabelsGroup,
+ chart = series.chart,
+ xAxis = series.xAxis,
+ groupLeft = xAxis ? xAxis.left : chart.plotLeft,
+ yAxis = series.yAxis,
+ groupTop = yAxis ? yAxis.top : chart.plotTop,
+ renderer = chart.renderer,
+ inverted = chart.inverted,
+ seriesType = series.type,
+ stacking = seriesOptions.stacking,
+ isBarLike = seriesType === 'column' || seriesType === 'bar',
+ vAlignIsNull = options.verticalAlign === null,
+ yIsNull = options.y === null,
+ dataLabel;
+
+ if (isBarLike) {
+ if (stacking) {
+ // In stacked series the default label placement is inside the bars
+ if (vAlignIsNull) {
+ options = merge(options, {verticalAlign: 'middle'});
+ }
+
+ // If no y delta is specified, try to create a good default
+ if (yIsNull) {
+ options = merge(options, {y: {top: 14, middle: 4, bottom: -6}[options.verticalAlign]});
+ }
+ } else {
+ // In non stacked series the default label placement is on top of the bars
+ if (vAlignIsNull) {
+ options = merge(options, {verticalAlign: 'top'});
+ }
+ }
+ }
+
+
+ // create a separate group for the data labels to avoid rotation
+ if (!dataLabelsGroup) {
+ dataLabelsGroup = series.dataLabelsGroup =
+ renderer.g('data-labels')
+ .attr({
+ visibility: series.visible ? VISIBLE : HIDDEN,
+ zIndex: 6
+ })
+ .translate(groupLeft, groupTop)
+ .add();
+ } else {
+ dataLabelsGroup.translate(groupLeft, groupTop);
+ }
+
+ // make the labels for each point
+ generalOptions = options;
+ each(points, function (point) {
+
+ dataLabel = point.dataLabel;
+
+ // Merge in individual options from point // docs
+ options = generalOptions; // reset changes from previous points
+ pointOptions = point.options;
+ if (pointOptions && pointOptions.dataLabels) {
+ options = merge(options, pointOptions.dataLabels);
+ }
+
+ // If the point is outside the plot area, destroy it. #678
+ if (dataLabel && series.isCartesian && !chart.isInsidePlot(point.plotX, point.plotY)) {
+ point.dataLabel = dataLabel.destroy();
+
+ // Individual labels are disabled if the are explicitly disabled
+ // in the point options, or if they fall outside the plot area.
+ } else if (options.enabled) {
+
+ // Get the string
+ str = options.formatter.call(point.getLabelConfig(), options);
+
+ var barX = point.barX,
+ plotX = (barX && barX + point.barW / 2) || point.plotX || -999,
+ plotY = pick(point.plotY, -999),
+ align = options.align,
+ individualYDelta = yIsNull ? (point.y >= 0 ? -6 : 12) : options.y;
+
+ // Postprocess the positions
+ x = (inverted ? chart.plotWidth - plotY : plotX) + options.x;
+ y = (inverted ? chart.plotHeight - plotX : plotY) + individualYDelta;
+
+ // in columns, align the string to the column
+ if (seriesType === 'column') {
+ x += { left: -1, right: 1 }[align] * point.barW / 2 || 0;
+ }
+
+ if (!stacking && inverted && point.y < 0) {
+ align = 'right';
+ x -= 10;
+ }
+
+ // Determine the color
+ options.style.color = pick(options.color, options.style.color, series.color, 'black');
+
+
+ // update existing label
+ if (dataLabel) {
+ // vertically centered
+ if (inverted && !options.y) {
+ y = y + pInt(dataLabel.styles.lineHeight) * 0.9 - dataLabel.getBBox().height / 2;
+ }
+ dataLabel
+ .attr({
+ text: str
+ }).animate({
+ x: x,
+ y: y
+ });
+ // create new label
+ } else if (defined(str)) {
+ dataLabel = point.dataLabel = renderer.text(
+ str,
+ x,
+ y
+ )
+ .attr({
+ align: align,
+ rotation: options.rotation,
+ zIndex: 1
+ })
+ .css(options.style)
+ .add(dataLabelsGroup);
+ // vertically centered
+ if (inverted && !options.y) {
+ dataLabel.attr({
+ y: y + pInt(dataLabel.styles.lineHeight) * 0.9 - dataLabel.getBBox().height / 2
+ });
+ }
+ }
+
+ if (isBarLike && seriesOptions.stacking && dataLabel) {
+ var barY = point.barY,
+ barW = point.barW,
+ barH = point.barH;
+
+ dataLabel.align(options, null,
+ {
+ x: inverted ? chart.plotWidth - barY - barH : barX,
+ y: inverted ? chart.plotHeight - barX - barW : barY,
+ width: inverted ? barH : barW,
+ height: inverted ? barW : barH
+ });
+ }
+
+
+ }
+ });
+ }
+ },
+
+ /**
+ * Draw the actual graph
+ */
+ drawGraph: function () {
+ var series = this,
+ options = series.options,
+ chart = series.chart,
+ graph = series.graph,
+ graphPath = [],
+ fillColor,
+ area = series.area,
+ group = series.group,
+ color = options.lineColor || series.color,
+ lineWidth = options.lineWidth,
+ dashStyle = options.dashStyle,
+ segmentPath,
+ renderer = chart.renderer,
+ translatedThreshold = series.yAxis.getThreshold(options.threshold),
+ useArea = /^area/.test(series.type),
+ singlePoints = [], // used in drawTracker
+ areaPath = [],
+ attribs;
+
+
+ // divide into segments and build graph and area paths
+ each(series.segments, function (segment) {
+ segmentPath = [];
+
+ // build the segment line
+ each(segment, function (point, i) {
+
+ if (series.getPointSpline) { // generate the spline as defined in the SplineSeries object
+ segmentPath.push.apply(segmentPath, series.getPointSpline(segment, point, i));
+
+ } else {
+
+ // moveTo or lineTo
+ segmentPath.push(i ? L : M);
+
+ // step line?
+ if (i && options.step) {
+ var lastPoint = segment[i - 1];
+ segmentPath.push(
+ point.plotX,
+ lastPoint.plotY
+ );
+ }
+
+ // normal line to next point
+ segmentPath.push(
+ point.plotX,
+ point.plotY
+ );
+ }
+ });
+
+ // add the segment to the graph, or a single point for tracking
+ if (segment.length > 1) {
+ graphPath = graphPath.concat(segmentPath);
+ } else {
+ singlePoints.push(segment[0]);
+ }
+
+ // build the area
+ if (useArea) {
+ var areaSegmentPath = [],
+ i,
+ segLength = segmentPath.length;
+ for (i = 0; i < segLength; i++) {
+ areaSegmentPath.push(segmentPath[i]);
+ }
+ if (segLength === 3) { // for animation from 1 to two points
+ areaSegmentPath.push(L, segmentPath[1], segmentPath[2]);
+ }
+ if (options.stacking && series.type !== 'areaspline') {
+
+ // Follow stack back. Todo: implement areaspline. A general solution could be to
+ // reverse the entire graphPath of the previous series, though may be hard with
+ // splines and with series with different extremes
+ for (i = segment.length - 1; i >= 0; i--) {
+
+ // step line?
+ if (i < segment.length - 1 && options.step) {
+ areaSegmentPath.push(segment[i + 1].plotX, segment[i].yBottom);
+ }
+
+ areaSegmentPath.push(segment[i].plotX, segment[i].yBottom);
+ }
+
+ } else { // follow zero line back
+ areaSegmentPath.push(
+ L,
+ segment[segment.length - 1].plotX,
+ translatedThreshold,
+ L,
+ segment[0].plotX,
+ translatedThreshold
+ );
+ }
+ areaPath = areaPath.concat(areaSegmentPath);
+ }
+ });
+
+ // used in drawTracker:
+ series.graphPath = graphPath;
+ series.singlePoints = singlePoints;
+
+ // draw the area if area series or areaspline
+ if (useArea) {
+ fillColor = pick(
+ options.fillColor,
+ Color(series.color).setOpacity(options.fillOpacity || 0.75).get()
+ );
+ if (area) {
+ area.animate({ d: areaPath });
+
+ } else {
+ // draw the area
+ series.area = series.chart.renderer.path(areaPath)
+ .attr({
+ fill: fillColor
+ }).add(group);
+ }
+ }
+
+ // draw the graph
+ if (graph) {
+ stop(graph); // cancel running animations, #459
+ graph.animate({ d: graphPath });
+
+ } else {
+ if (lineWidth) {
+ attribs = {
+ 'stroke': color,
+ 'stroke-width': lineWidth
+ };
+ if (dashStyle) {
+ attribs.dashstyle = dashStyle;
+ }
+
+ series.graph = renderer.path(graphPath)
+ .attr(attribs).add(group).shadow(options.shadow);
+ }
+ }
+ },
+
+
+ /**
+ * Render the graph and markers
+ */
+ render: function () {
+ var series = this,
+ chart = series.chart,
+ group,
+ setInvert,
+ options = series.options,
+ doClip = options.clip !== false,
+ animation = options.animation,
+ doAnimation = animation && series.animate,
+ duration = doAnimation ? (animation && animation.duration) || 500 : 0,
+ clipRect = series.clipRect,
+ renderer = chart.renderer;
+
+
+ // Add plot area clipping rectangle. If this is before chart.hasRendered,
+ // create one shared clipRect.
+
+ // Todo: since creating the clip property, the clipRect is created but
+ // never used when clip is false. A better way would be that the animation
+ // would run, then the clipRect destroyed.
+ if (!clipRect) {
+ clipRect = series.clipRect = !chart.hasRendered && chart.clipRect ?
+ chart.clipRect :
+ renderer.clipRect(0, 0, chart.plotSizeX, chart.plotSizeY + 1);
+ if (!chart.clipRect) {
+ chart.clipRect = clipRect;
+ }
+ }
+
+
+ // the group
+ if (!series.group) {
+ group = series.group = renderer.g('series');
+
+ if (chart.inverted) {
+ setInvert = function () {
+ group.attr({
+ width: chart.plotWidth,
+ height: chart.plotHeight
+ }).invert();
+ };
+
+ setInvert(); // do it now
+ addEvent(chart, 'resize', setInvert); // do it on resize
+ addEvent(series, 'destroy', function () {
+ removeEvent(chart, 'resize', setInvert);
+ });
+ }
+
+ if (doClip) {
+ group.clip(clipRect);
+ }
+ group.attr({
+ visibility: series.visible ? VISIBLE : HIDDEN,
+ zIndex: options.zIndex
+ })
+ .translate(series.xAxis.left, series.yAxis.top)
+ .add(chart.seriesGroup);
+ }
+
+ series.drawDataLabels();
+
+ // initiate the animation
+ if (doAnimation) {
+ series.animate(true);
+ }
+
+ // cache attributes for shapes
+ series.getAttribs();
+
+ // draw the graph if any
+ if (series.drawGraph) {
+ series.drawGraph();
+ }
+
+ // draw the points
+ series.drawPoints();
+
+ // draw the mouse tracking area
+ if (series.options.enableMouseTracking !== false) {
+ series.drawTracker();
+ }
+
+ // run the animation
+ if (doAnimation) {
+ series.animate();
+ }
+
+ // finish the individual clipRect
+ setTimeout(function () {
+ clipRect.isAnimating = false;
+ group = series.group; // can be destroyed during the timeout
+ if (group && clipRect !== chart.clipRect && clipRect.renderer) {
+ if (doClip) {
+ group.clip((series.clipRect = chart.clipRect));
+ }
+ clipRect.destroy();
+ }
+ }, duration);
+
+ series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see
+ // (See #322) series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see
+
+ },
+
+ /**
+ * Redraw the series after an update in the axes.
+ */
+ redraw: function () {
+ var series = this,
+ chart = series.chart,
+ wasDirtyData = series.isDirtyData, // cache it here as it is set to false in render, but used after
+ group = series.group;
+
+ // reposition on resize
+ if (group) {
+ if (chart.inverted) {
+ group.attr({
+ width: chart.plotWidth,
+ height: chart.plotHeight
+ });
+ }
+
+ group.animate({
+ translateX: series.xAxis.left,
+ translateY: series.yAxis.top
+ });
+ }
+
+ series.translate();
+ series.setTooltipPoints(true);
+
+ series.render();
+ if (wasDirtyData) {
+ fireEvent(series, 'updatedData');
+ }
+ },
+
+ /**
+ * Set the state of the graph
+ */
+ setState: function (state) {
+ var series = this,
+ options = series.options,
+ graph = series.graph,
+ stateOptions = options.states,
+ lineWidth = options.lineWidth;
+
+ state = state || NORMAL_STATE;
+
+ if (series.state !== state) {
+ series.state = state;
+
+ if (stateOptions[state] && stateOptions[state].enabled === false) {
+ return;
+ }
+
+ if (state) {
+ lineWidth = stateOptions[state].lineWidth || lineWidth + 1;
+ }
+
+ if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
+ graph.attr({ // use attr because animate will cause any other animation on the graph to stop
+ 'stroke-width': lineWidth
+ }, state ? 0 : 500);
+ }
+ }
+ },
+
+ /**
+ * Set the visibility of the graph
+ *
+ * @param vis {Boolean} True to show the series, false to hide. If UNDEFINED,
+ * the visibility is toggled.
+ */
+ setVisible: function (vis, redraw) {
+ var series = this,
+ chart = series.chart,
+ legendItem = series.legendItem,
+ seriesGroup = series.group,
+ seriesTracker = series.tracker,
+ dataLabelsGroup = series.dataLabelsGroup,
+ showOrHide,
+ i,
+ points = series.points,
+ point,
+ ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
+ oldVisibility = series.visible;
+
+ // if called without an argument, toggle visibility
+ series.visible = vis = vis === UNDEFINED ? !oldVisibility : vis;
+ showOrHide = vis ? 'show' : 'hide';
+
+ // show or hide series
+ if (seriesGroup) { // pies don't have one
+ seriesGroup[showOrHide]();
+ }
+
+ // show or hide trackers
+ if (seriesTracker) {
+ seriesTracker[showOrHide]();
+ } else if (points) {
+ i = points.length;
+ while (i--) {
+ point = points[i];
+ if (point.tracker) {
+ point.tracker[showOrHide]();
+ }
+ }
+ }
+
+
+ if (dataLabelsGroup) {
+ dataLabelsGroup[showOrHide]();
+ }
+
+ if (legendItem) {
+ chart.legend.colorizeItem(series, vis);
+ }
+
+
+ // rescale or adapt to resized chart
+ series.isDirty = true;
+ // in a stack, all other series are affected
+ if (series.options.stacking) {
+ each(chart.series, function (otherSeries) {
+ if (otherSeries.options.stacking && otherSeries.visible) {
+ otherSeries.isDirty = true;
+ }
+ });
+ }
+
+ if (ignoreHiddenSeries) {
+ chart.isDirtyBox = true;
+ }
+ if (redraw !== false) {
+ chart.redraw();
+ }
+
+ fireEvent(series, showOrHide);
+ },
+
+ /**
+ * Show the graph
+ */
+ show: function () {
+ this.setVisible(true);
+ },
+
+ /**
+ * Hide the graph
+ */
+ hide: function () {
+ this.setVisible(false);
+ },
+
+
+ /**
+ * Set the selected state of the graph
+ *
+ * @param selected {Boolean} True to select the series, false to unselect. If
+ * UNDEFINED, the selection state is toggled.
+ */
+ select: function (selected) {
+ var series = this;
+ // if called without an argument, toggle
+ series.selected = selected = (selected === UNDEFINED) ? !series.selected : selected;
+
+ if (series.checkbox) {
+ series.checkbox.checked = selected;
+ }
+
+ fireEvent(series, selected ? 'select' : 'unselect');
+ },
+
+
+ /**
+ * Draw the tracker object that sits above all data labels and markers to
+ * track mouse events on the graph or points. For the line type charts
+ * the tracker uses the same graphPath, but with a greater stroke width
+ * for better control.
+ */
+ drawTracker: function () {
+ var series = this,
+ options = series.options,
+ trackerPath = [].concat(series.graphPath),
+ trackerPathLength = trackerPath.length,
+ chart = series.chart,
+ renderer = chart.renderer,
+ snap = chart.options.tooltip.snap,
+ tracker = series.tracker,
+ cursor = options.cursor,
+ css = cursor && { cursor: cursor },
+ singlePoints = series.singlePoints,
+ group,
+ singlePoint,
+ i;
+
+ // Extend end points. A better way would be to use round linecaps,
+ // but those are not clickable in VML.
+ if (trackerPathLength) {
+ i = trackerPathLength + 1;
+ while (i--) {
+ if (trackerPath[i] === M) { // extend left side
+ trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], L);
+ }
+ if ((i && trackerPath[i] === M) || i === trackerPathLength) { // extend right side
+ trackerPath.splice(i, 0, L, trackerPath[i - 2] + snap, trackerPath[i - 1]);
+ }
+ }
+ }
+
+ // handle single points
+ for (i = 0; i < singlePoints.length; i++) {
+ singlePoint = singlePoints[i];
+ trackerPath.push(M, singlePoint.plotX - snap, singlePoint.plotY,
+ L, singlePoint.plotX + snap, singlePoint.plotY);
+ }
+
+
+
+ // draw the tracker
+ if (tracker) {
+ tracker.attr({ d: trackerPath });
+
+ } else { // create
+ group = renderer.g()
+ .clip(chart.clipRect)
+ .add(chart.trackerGroup);
+
+ series.tracker = renderer.path(trackerPath)
+ .attr({
+ isTracker: true,
+ stroke: TRACKER_FILL,
+ fill: NONE,
+ 'stroke-linejoin': 'bevel',
+ 'stroke-width' : options.lineWidth + 2 * snap,
+ visibility: series.visible ? VISIBLE : HIDDEN,
+ zIndex: options.zIndex || 1
+ })
+ .on(hasTouch ? 'touchstart' : 'mouseover', function () {
+ if (chart.hoverSeries !== series) {
+ series.onMouseOver();
+ }
+ })
+ .on('mouseout', function () {
+ if (!options.stickyTracking) {
+ series.onMouseOut();
+ }
+ })
+ .css(css)
+ .add(group);
+ }
+
+ }
+
+}; // end Series prototype
+
+
+/**
+ * LineSeries object
+ */
+var LineSeries = extendClass(Series);
+seriesTypes.line = LineSeries;
+
+/**
+ * AreaSeries object
+ */
+var AreaSeries = extendClass(Series, {
+ type: 'area',
+ useThreshold: true
+});
+seriesTypes.area = AreaSeries;
+
+
+
+
+/**
+ * SplineSeries object
+ */
+var SplineSeries = extendClass(Series, {
+ type: 'spline',
+
+ /**
+ * Draw the actual graph
+ */
+ getPointSpline: function (segment, point, i) {
+ var smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc
+ denom = smoothing + 1,
+ plotX = point.plotX,
+ plotY = point.plotY,
+ lastPoint = segment[i - 1],
+ nextPoint = segment[i + 1],
+ leftContX,
+ leftContY,
+ rightContX,
+ rightContY,
+ ret;
+
+ // find control points
+ if (i && i < segment.length - 1) {
+ var lastX = lastPoint.plotX,
+ lastY = lastPoint.plotY,
+ nextX = nextPoint.plotX,
+ nextY = nextPoint.plotY,
+ correction;
+
+ leftContX = (smoothing * plotX + lastX) / denom;
+ leftContY = (smoothing * plotY + lastY) / denom;
+ rightContX = (smoothing * plotX + nextX) / denom;
+ rightContY = (smoothing * plotY + nextY) / denom;
+
+ // have the two control points make a straight line through main point
+ correction = ((rightContY - leftContY) * (rightContX - plotX)) /
+ (rightContX - leftContX) + plotY - rightContY;
+
+ leftContY += correction;
+ rightContY += correction;
+
+ // to prevent false extremes, check that control points are between
+ // neighbouring points' y values
+ if (leftContY > lastY && leftContY > plotY) {
+ leftContY = mathMax(lastY, plotY);
+ rightContY = 2 * plotY - leftContY; // mirror of left control point
+ } else if (leftContY < lastY && leftContY < plotY) {
+ leftContY = mathMin(lastY, plotY);
+ rightContY = 2 * plotY - leftContY;
+ }
+ if (rightContY > nextY && rightContY > plotY) {
+ rightContY = mathMax(nextY, plotY);
+ leftContY = 2 * plotY - rightContY;
+ } else if (rightContY < nextY && rightContY < plotY) {
+ rightContY = mathMin(nextY, plotY);
+ leftContY = 2 * plotY - rightContY;
+ }
+
+ // record for drawing in next point
+ point.rightContX = rightContX;
+ point.rightContY = rightContY;
+
+ }
+
+ // moveTo or lineTo
+ if (!i) {
+ ret = [M, plotX, plotY];
+ } else { // curve from last point to this
+ ret = [
+ 'C',
+ lastPoint.rightContX || lastPoint.plotX,
+ lastPoint.rightContY || lastPoint.plotY,
+ leftContX || plotX,
+ leftContY || plotY,
+ plotX,
+ plotY
+ ];
+ lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later
+ }
+ return ret;
+ }
+});
+seriesTypes.spline = SplineSeries;
+
+
+
+/**
+ * AreaSplineSeries object
+ */
+var AreaSplineSeries = extendClass(SplineSeries, {
+ type: 'areaspline',
+ useThreshold: true
+});
+seriesTypes.areaspline = AreaSplineSeries;
+
+/**
+ * ColumnSeries object
+ */
+var ColumnSeries = extendClass(Series, {
+ type: 'column',
+ useThreshold: true,
+ tooltipOutsidePlot: true,
+ pointAttrToOptions: { // mapping between SVG attributes and the corresponding options
+ stroke: 'borderColor',
+ 'stroke-width': 'borderWidth',
+ fill: 'color',
+ r: 'borderRadius'
+ },
+ init: function () {
+ Series.prototype.init.apply(this, arguments);
+
+ var series = this,
+ chart = series.chart;
+
+ // if the series is added dynamically, force redraw of other
+ // series affected by a new column
+ if (chart.hasRendered) {
+ each(chart.series, function (otherSeries) {
+ if (otherSeries.type === series.type) {
+ otherSeries.isDirty = true;
+ }
+ });
+ }
+ },
+
+ /**
+ * Translate each point to the plot area coordinate system and find shape positions
+ */
+ translate: function () {
+ var series = this,
+ chart = series.chart,
+ options = series.options,
+ stacking = options.stacking,
+ borderWidth = options.borderWidth,
+ columnCount = 0,
+ xAxis = series.xAxis,
+ reversedXAxis = xAxis.reversed,
+ stackGroups = {},
+ stackKey,
+ columnIndex;
+
+ Series.prototype.translate.apply(series);
+
+ // Get the total number of column type series.
+ // This is called on every series. Consider moving this logic to a
+ // chart.orderStacks() function and call it on init, addSeries and removeSeries
+ each(chart.series, function (otherSeries) {
+ if (otherSeries.type === series.type && otherSeries.visible &&
+ series.options.group === otherSeries.options.group) { // used in Stock charts navigator series
+ if (otherSeries.options.stacking) {
+ stackKey = otherSeries.stackKey;
+ if (stackGroups[stackKey] === UNDEFINED) {
+ stackGroups[stackKey] = columnCount++;
+ }
+ columnIndex = stackGroups[stackKey];
+ } else {
+ columnIndex = columnCount++;
+ }
+ otherSeries.columnIndex = columnIndex;
+ }
+ });
+
+ // calculate the width and position of each column based on
+ // the number of column series in the plot, the groupPadding
+ // and the pointPadding options
+ var points = series.points,
+ categoryWidth = mathAbs(xAxis.translationSlope) * (xAxis.ordinalSlope || xAxis.closestPointRange || 1),
+ groupPadding = categoryWidth * options.groupPadding,
+ groupWidth = categoryWidth - 2 * groupPadding,
+ pointOffsetWidth = groupWidth / columnCount,
+ optionPointWidth = options.pointWidth,
+ pointPadding = defined(optionPointWidth) ? (pointOffsetWidth - optionPointWidth) / 2 :
+ pointOffsetWidth * options.pointPadding,
+ pointWidth = mathCeil(mathMax(pick(optionPointWidth, pointOffsetWidth - 2 * pointPadding), 1)),
+ colIndex = (reversedXAxis ? columnCount -
+ series.columnIndex : series.columnIndex) || 0,
+ pointXOffset = pointPadding + (groupPadding + colIndex *
+ pointOffsetWidth - (categoryWidth / 2)) *
+ (reversedXAxis ? -1 : 1),
+ threshold = options.threshold,
+ translatedThreshold = series.yAxis.getThreshold(threshold),
+ minPointLength = pick(options.minPointLength, 5);
+
+ // record the new values
+ each(points, function (point) {
+ var plotY = point.plotY,
+ yBottom = point.yBottom || translatedThreshold,
+ barX = point.plotX + pointXOffset,
+ barY = mathCeil(mathMin(plotY, yBottom)),
+ barH = mathCeil(mathMax(plotY, yBottom) - barY),
+ stack = series.yAxis.stacks[(point.y < 0 ? '-' : '') + series.stackKey],
+ shapeArgs;
+
+ // Record the offset'ed position and width of the bar to be able to align the stacking total correctly
+ if (stacking && series.visible && stack && stack[point.x]) {
+ stack[point.x].setOffset(pointXOffset, pointWidth);
+ }
+
+ // handle options.minPointLength
+ if (mathAbs(barH) < minPointLength) {
+ if (minPointLength) {
+ barH = minPointLength;
+ barY =
+ mathAbs(barY - translatedThreshold) > minPointLength ? // stacked
+ yBottom - minPointLength : // keep position
+ translatedThreshold - (plotY <= translatedThreshold ? minPointLength : 0);
+ }
+ }
+
+ extend(point, {
+ barX: barX,
+ barY: barY,
+ barW: pointWidth,
+ barH: barH
+ });
+
+ // create shape type and shape args that are reused in drawPoints and drawTracker
+ point.shapeType = 'rect';
+ shapeArgs = extend(chart.renderer.Element.prototype.crisp.apply({}, [
+ borderWidth,
+ barX,
+ barY,
+ pointWidth,
+ barH
+ ]), {
+ r: options.borderRadius
+ });
+ if (borderWidth % 2) { // correct for shorting in crisp method, visible in stacked columns with 1px border
+ shapeArgs.y -= 1;
+ shapeArgs.height += 1;
+ }
+ point.shapeArgs = shapeArgs;
+
+ // make small columns responsive to mouse
+ point.trackerArgs = mathAbs(barH) < 3 && merge(point.shapeArgs, {
+ height: 6,
+ y: barY - 3
+ });
+ });
+
+ },
+
+ getSymbol: function () {
+ },
+
+ /**
+ * Columns have no graph
+ */
+ drawGraph: function () {},
+
+ /**
+ * Draw the columns. For bars, the series.group is rotated, so the same coordinates
+ * apply for columns and bars. This method is inherited by scatter series.
+ *
+ */
+ drawPoints: function () {
+ var series = this,
+ options = series.options,
+ renderer = series.chart.renderer,
+ graphic,
+ shapeArgs;
+
+
+ // draw the columns
+ each(series.points, function (point) {
+ var plotY = point.plotY;
+ if (plotY !== UNDEFINED && !isNaN(plotY) && point.y !== null) {
+ graphic = point.graphic;
+ shapeArgs = point.shapeArgs;
+ if (graphic) { // update
+ stop(graphic);
+ graphic.animate(shapeArgs);
+
+ } else {
+ point.graphic = graphic = renderer[point.shapeType](shapeArgs)
+ .attr(point.pointAttr[point.selected ? SELECT_STATE : NORMAL_STATE])
+ .add(series.group)
+ .shadow(options.shadow);
+ }
+
+ }
+ });
+ },
+ /**
+ * Draw the individual tracker elements.
+ * This method is inherited by scatter and pie charts too.
+ */
+ drawTracker: function () {
+ var series = this,
+ chart = series.chart,
+ renderer = chart.renderer,
+ shapeArgs,
+ tracker,
+ trackerLabel = +new Date(),
+ options = series.options,
+ cursor = options.cursor,
+ css = cursor && { cursor: cursor },
+ group,
+ rel;
+
+ // Add a series specific group to allow clipping the trackers
+ if (series.isCartesian) {
+ group = renderer.g()
+ .clip(chart.clipRect)
+ .add(chart.trackerGroup);
+ }
+
+ each(series.points, function (point) {
+ tracker = point.tracker;
+ shapeArgs = point.trackerArgs || point.shapeArgs;
+ delete shapeArgs.strokeWidth;
+ if (point.y !== null) {
+ if (tracker) {// update
+ tracker.attr(shapeArgs);
+
+ } else {
+ point.tracker =
+ renderer[point.shapeType](shapeArgs)
+ .attr({
+ isTracker: trackerLabel,
+ fill: TRACKER_FILL,
+ visibility: series.visible ? VISIBLE : HIDDEN,
+ zIndex: options.zIndex || 1
+ })
+ .on(hasTouch ? 'touchstart' : 'mouseover', function (event) {
+ rel = event.relatedTarget || event.fromElement;
+ if (chart.hoverSeries !== series && attr(rel, 'isTracker') !== trackerLabel) {
+ series.onMouseOver();
+ }
+ point.onMouseOver();
+
+ })
+ .on('mouseout', function (event) {
+ if (!options.stickyTracking) {
+ rel = event.relatedTarget || event.toElement;
+ if (attr(rel, 'isTracker') !== trackerLabel) {
+ series.onMouseOut();
+ }
+ }
+ })
+ .css(css)
+ .add(point.group || group); // pies have point group - see issue #118
+ }
+ }
+ });
+ },
+
+
+ /**
+ * Animate the column heights one by one from zero
+ * @param {Boolean} init Whether to initialize the animation or run it
+ */
+ animate: function (init) {
+ var series = this,
+ points = series.points;
+
+ if (!init) { // run the animation
+ /*
+ * Note: Ideally the animation should be initialized by calling
+ * series.group.hide(), and then calling series.group.show()
+ * after the animation was started. But this rendered the shadows
+ * invisible in IE8 standards mode. If the columns flicker on large
+ * datasets, this is the cause.
+ */
+
+ each(points, function (point) {
+ var graphic = point.graphic,
+ shapeArgs = point.shapeArgs;
+
+ if (graphic) {
+ // start values
+ graphic.attr({
+ height: 0,
+ y: series.yAxis.translate(0, 0, 1)
+ });
+
+ // animate
+ graphic.animate({
+ height: shapeArgs.height,
+ y: shapeArgs.y
+ }, series.options.animation);
+ }
+ });
+
+
+ // delete this function to allow it only once
+ series.animate = null;
+ }
+
+ },
+ /**
+ * Remove this series from the chart
+ */
+ remove: function () {
+ var series = this,
+ chart = series.chart;
+
+ // column and bar series affects other series of the same type
+ // as they are either stacked or grouped
+ if (chart.hasRendered) {
+ each(chart.series, function (otherSeries) {
+ if (otherSeries.type === series.type) {
+ otherSeries.isDirty = true;
+ }
+ });
+ }
+
+ Series.prototype.remove.apply(series, arguments);
+ }
+});
+seriesTypes.column = ColumnSeries;
+
+var BarSeries = extendClass(ColumnSeries, {
+ type: 'bar',
+ init: function () {
+ this.inverted = true;
+ ColumnSeries.prototype.init.apply(this, arguments);
+ }
+});
+seriesTypes.bar = BarSeries;
+
+/**
+ * The scatter series class
+ */
+var ScatterSeries = extendClass(Series, {
+ type: 'scatter',
+
+ /**
+ * Extend the base Series' translate method by adding shape type and
+ * arguments for the point trackers
+ */
+ translate: function () {
+ var series = this;
+
+ Series.prototype.translate.apply(series);
+
+ each(series.points, function (point) {
+ point.shapeType = 'circle';
+ point.shapeArgs = {
+ x: point.plotX,
+ y: point.plotY,
+ r: series.chart.options.tooltip.snap
+ };
+ });
+ },
+
+ /**
+ * Add tracking event listener to the series group, so the point graphics
+ * themselves act as trackers
+ */
+ drawTracker: function () {
+ var series = this,
+ cursor = series.options.cursor,
+ css = cursor && { cursor: cursor },
+ points = series.points,
+ i = points.length,
+ graphic;
+
+ // Set an expando property for the point index, used below
+ while (i--) {
+ graphic = points[i].graphic;
+ if (graphic) { // doesn't exist for null points
+ graphic.element._index = i;
+ }
+ }
+
+ // Add the event listeners, we need to do this only once
+ if (!series._hasTracking) {
+ series.group
+ .on(hasTouch ? 'touchstart' : 'mouseover', function (e) {
+ series.onMouseOver();
+ points[e.target._index].onMouseOver();
+ })
+ .on('mouseout', function () {
+ if (!series.options.stickyTracking) {
+ series.onMouseOut();
+ }
+ })
+ .css(css);
+ } else {
+ series._hasTracking = true;
+ }
+
+ }
+});
+seriesTypes.scatter = ScatterSeries;
+
+/**
+ * Extended point object for pies
+ */
+var PiePoint = extendClass(Point, {
+ /**
+ * Initiate the pie slice
+ */
+ init: function () {
+
+ Point.prototype.init.apply(this, arguments);
+
+ var point = this,
+ toggleSlice;
+
+ //visible: options.visible !== false,
+ extend(point, {
+ visible: point.visible !== false,
+ name: pick(point.name, 'Slice')
+ });
+
+ // add event listener for select
+ toggleSlice = function () {
+ point.slice();
+ };
+ addEvent(point, 'select', toggleSlice);
+ addEvent(point, 'unselect', toggleSlice);
+
+ return point;
+ },
+
+ /**
+ * Toggle the visibility of the pie slice
+ * @param {Boolean} vis Whether to show the slice or not. If undefined, the
+ * visibility is toggled
+ */
+ setVisible: function (vis) {
+ var point = this,
+ chart = point.series.chart,
+ tracker = point.tracker,
+ dataLabel = point.dataLabel,
+ connector = point.connector,
+ shadowGroup = point.shadowGroup,
+ method;
+
+ // if called without an argument, toggle visibility
+ point.visible = vis = vis === UNDEFINED ? !point.visible : vis;
+
+ method = vis ? 'show' : 'hide';
+
+ point.group[method]();
+ if (tracker) {
+ tracker[method]();
+ }
+ if (dataLabel) {
+ dataLabel[method]();
+ }
+ if (connector) {
+ connector[method]();
+ }
+ if (shadowGroup) {
+ shadowGroup[method]();
+ }
+ if (point.legendItem) {
+ chart.legend.colorizeItem(point, vis);
+ }
+ },
+
+ /**
+ * Set or toggle whether the slice is cut out from the pie
+ * @param {Boolean} sliced When undefined, the slice state is toggled
+ * @param {Boolean} redraw Whether to redraw the chart. True by default.
+ */
+ slice: function (sliced, redraw, animation) {
+ var point = this,
+ series = point.series,
+ chart = series.chart,
+ slicedTranslation = point.slicedTranslation,
+ translation;
+
+ setAnimation(animation, chart);
+
+ // redraw is true by default
+ redraw = pick(redraw, true);
+
+ // if called without an argument, toggle
+ sliced = point.sliced = defined(sliced) ? sliced : !point.sliced;
+
+ translation = {
+ translateX: (sliced ? slicedTranslation[0] : chart.plotLeft),
+ translateY: (sliced ? slicedTranslation[1] : chart.plotTop)
+ };
+ point.group.animate(translation);
+ if (point.shadowGroup) {
+ point.shadowGroup.animate(translation);
+ }
+
+ }
+});
+
+/**
+ * The Pie series class
+ */
+var PieSeries = extendClass(Series, {
+ type: 'pie',
+ isCartesian: false,
+ pointClass: PiePoint,
+ pointAttrToOptions: { // mapping between SVG attributes and the corresponding options
+ stroke: 'borderColor',
+ 'stroke-width': 'borderWidth',
+ fill: 'color'
+ },
+
+ /**
+ * Pies have one color each point
+ */
+ getColor: function () {
+ // record first color for use in setData
+ this.initialColor = this.chart.counters.color;
+ },
+
+ /**
+ * Animate the column heights one by one from zero
+ */
+ animate: function () {
+ var series = this,
+ points = series.points;
+
+ each(points, function (point) {
+ var graphic = point.graphic,
+ args = point.shapeArgs,
+ up = -mathPI / 2;
+
+ if (graphic) {
+ // start values
+ graphic.attr({
+ r: 0,
+ start: up,
+ end: up
+ });
+
+ // animate
+ graphic.animate({
+ r: args.r,
+ start: args.start,
+ end: args.end
+ }, series.options.animation);
+ }
+ });
+
+ // delete this function to allow it only once
+ series.animate = null;
+
+ },
+
+ /**
+ * Extend the basic setData method by running processData and generatePoints immediately,
+ * in order to access the points from the legend.
+ */
+ setData: function () {
+ Series.prototype.setData.apply(this, arguments);
+ this.processData();
+ this.generatePoints();
+ },
+ /**
+ * Do translation for pie slices
+ */
+ translate: function () {
+ this.generatePoints();
+
+ var total = 0,
+ series = this,
+ cumulative = -0.25, // start at top
+ precision = 1000, // issue #172
+ options = series.options,
+ slicedOffset = options.slicedOffset,
+ connectorOffset = slicedOffset + options.borderWidth,
+ positions = options.center.concat([options.size, options.innerSize || 0]),
+ chart = series.chart,
+ plotWidth = chart.plotWidth,
+ plotHeight = chart.plotHeight,
+ start,
+ end,
+ angle,
+ points = series.points,
+ circ = 2 * mathPI,
+ fraction,
+ smallestSize = mathMin(plotWidth, plotHeight),
+ isPercent,
+ radiusX, // the x component of the radius vector for a given point
+ radiusY,
+ labelDistance = options.dataLabels.distance;
+
+ // get positions - either an integer or a percentage string must be given
+ positions = map(positions, function (length, i) {
+
+ isPercent = /%$/.test(length);
+ return isPercent ?
+ // i == 0: centerX, relative to width
+ // i == 1: centerY, relative to height
+ // i == 2: size, relative to smallestSize
+ // i == 4: innerSize, relative to smallestSize
+ [plotWidth, plotHeight, smallestSize, smallestSize][i] *
+ pInt(length) / 100 :
+ length;
+ });
+
+ // utility for getting the x value from a given y, used for anticollision logic in data labels
+ series.getX = function (y, left) {
+
+ angle = math.asin((y - positions[1]) / (positions[2] / 2 + labelDistance));
+
+ return positions[0] +
+ (left ? -1 : 1) *
+ (mathCos(angle) * (positions[2] / 2 + labelDistance));
+ };
+
+ // set center for later use
+ series.center = positions;
+
+ // get the total sum
+ each(points, function (point) {
+ total += point.y;
+ });
+
+ each(points, function (point) {
+ // set start and end angle
+ fraction = total ? point.y / total : 0;
+ start = mathRound(cumulative * circ * precision) / precision;
+ cumulative += fraction;
+ end = mathRound(cumulative * circ * precision) / precision;
+
+ // set the shape
+ point.shapeType = 'arc';
+ point.shapeArgs = {
+ x: positions[0],
+ y: positions[1],
+ r: positions[2] / 2,
+ innerR: positions[3] / 2,
+ start: start,
+ end: end
+ };
+
+ // center for the sliced out slice
+ angle = (end + start) / 2;
+ point.slicedTranslation = map([
+ mathCos(angle) * slicedOffset + chart.plotLeft,
+ mathSin(angle) * slicedOffset + chart.plotTop
+ ], mathRound);
+
+ // set the anchor point for tooltips
+ radiusX = mathCos(angle) * positions[2] / 2;
+ radiusY = mathSin(angle) * positions[2] / 2;
+ point.tooltipPos = [
+ positions[0] + radiusX * 0.7,
+ positions[1] + radiusY * 0.7
+ ];
+
+ // set the anchor point for data labels
+ point.labelPos = [
+ positions[0] + radiusX + mathCos(angle) * labelDistance, // first break of connector
+ positions[1] + radiusY + mathSin(angle) * labelDistance, // a/a
+ positions[0] + radiusX + mathCos(angle) * connectorOffset, // second break, right outside pie
+ positions[1] + radiusY + mathSin(angle) * connectorOffset, // a/a
+ positions[0] + radiusX, // landing point for connector
+ positions[1] + radiusY, // a/a
+ labelDistance < 0 ? // alignment
+ 'center' :
+ angle < circ / 4 ? 'left' : 'right', // alignment
+ angle // center angle
+ ];
+
+ // API properties
+ point.percentage = fraction * 100;
+ point.total = total;
+
+ });
+
+
+ this.setTooltipPoints();
+ },
+
+ /**
+ * Render the slices
+ */
+ render: function () {
+ var series = this;
+
+ // cache attributes for shapes
+ series.getAttribs();
+
+ this.drawPoints();
+
+ // draw the mouse tracking area
+ if (series.options.enableMouseTracking !== false) {
+ series.drawTracker();
+ }
+
+ this.drawDataLabels();
+
+ if (series.options.animation && series.animate) {
+ series.animate();
+ }
+
+ // (See #322) series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see
+ series.isDirty = false; // means data is in accordance with what you see
+ },
+
+ /**
+ * Draw the data points
+ */
+ drawPoints: function () {
+ var series = this,
+ chart = series.chart,
+ renderer = chart.renderer,
+ groupTranslation,
+ //center,
+ graphic,
+ group,
+ shadow = series.options.shadow,
+ shadowGroup,
+ shapeArgs;
+
+ // draw the slices
+ each(series.points, function (point) {
+ graphic = point.graphic;
+ shapeArgs = point.shapeArgs;
+ group = point.group;
+ shadowGroup = point.shadowGroup;
+
+ // put the shadow behind all points
+ if (shadow && !shadowGroup) {
+ shadowGroup = point.shadowGroup = renderer.g('shadow')
+ .attr({ zIndex: 4 })
+ .add();
+ }
+
+ // create the group the first time
+ if (!group) {
+ group = point.group = renderer.g('point')
+ .attr({ zIndex: 5 })
+ .add();
+ }
+
+ // if the point is sliced, use special translation, else use plot area traslation
+ groupTranslation = point.sliced ? point.slicedTranslation : [chart.plotLeft, chart.plotTop];
+ group.translate(groupTranslation[0], groupTranslation[1]);
+ if (shadowGroup) {
+ shadowGroup.translate(groupTranslation[0], groupTranslation[1]);
+ }
+
+ // draw the slice
+ if (graphic) {
+ graphic.animate(shapeArgs);
+ } else {
+ point.graphic =
+ renderer.arc(shapeArgs)
+ .attr(extend(
+ point.pointAttr[NORMAL_STATE],
+ { 'stroke-linejoin': 'round' }
+ ))
+ .add(point.group)
+ .shadow(shadow, shadowGroup);
+ }
+
+ // detect point specific visibility
+ if (point.visible === false) {
+ point.setVisible(false);
+ }
+
+ });
+
+ },
+
+ /**
+ * Override the base drawDataLabels method by pie specific functionality
+ */
+ drawDataLabels: function () {
+ var series = this,
+ data = series.data,
+ point,
+ chart = series.chart,
+ options = series.options.dataLabels,
+ connectorPadding = pick(options.connectorPadding, 10),
+ connectorWidth = pick(options.connectorWidth, 1),
+ connector,
+ connectorPath,
+ softConnector = pick(options.softConnector, true),
+ distanceOption = options.distance,
+ seriesCenter = series.center,
+ radius = seriesCenter[2] / 2,
+ centerY = seriesCenter[1],
+ outside = distanceOption > 0,
+ dataLabel,
+ labelPos,
+ labelHeight,
+ halves = [// divide the points into right and left halves for anti collision
+ [], // right
+ [] // left
+ ],
+ x,
+ y,
+ visibility,
+ rankArr,
+ sort,
+ i = 2,
+ j;
+
+ // get out if not enabled
+ if (!options.enabled) {
+ return;
+ }
+
+ // run parent method
+ Series.prototype.drawDataLabels.apply(series);
+
+ // arrange points for detection collision
+ each(data, function (point) {
+ if (point.dataLabel) { // it may have been cancelled in the base method (#407)
+ halves[
+ point.labelPos[7] < mathPI / 2 ? 0 : 1
+ ].push(point);
+ }
+ });
+ halves[1].reverse();
+
+ // define the sorting algorithm
+ sort = function (a, b) {
+ return b.y - a.y;
+ };
+
+ // assume equal label heights
+ labelHeight = halves[0][0] && halves[0][0].dataLabel && pInt(halves[0][0].dataLabel.styles.lineHeight);
+
+ /* Loop over the points in each quartile, starting from the top and bottom
+ * of the pie to detect overlapping labels.
+ */
+ while (i--) {
+
+ var slots = [],
+ slotsLength,
+ usedSlots = [],
+ points = halves[i],
+ pos,
+ length = points.length,
+ slotIndex;
+
+
+ // build the slots
+ for (pos = centerY - radius - distanceOption; pos <= centerY + radius + distanceOption; pos += labelHeight) {
+ slots.push(pos);
+ // visualize the slot
+ /*
+ var slotX = series.getX(pos, i) + chart.plotLeft - (i ? 100 : 0),
+ slotY = pos + chart.plotTop;
+ if (!isNaN(slotX)) {
+ chart.renderer.rect(slotX, slotY - 7, 100, labelHeight)
+ .attr({
+ 'stroke-width': 1,
+ stroke: 'silver'
+ })
+ .add();
+ chart.renderer.text('Slot '+ (slots.length - 1), slotX, slotY + 4)
+ .attr({
+ fill: 'silver'
+ }).add();
+ }
+ // */
+ }
+ slotsLength = slots.length;
+
+ // if there are more values than available slots, remove lowest values
+ if (length > slotsLength) {
+ // create an array for sorting and ranking the points within each quarter
+ rankArr = [].concat(points);
+ rankArr.sort(sort);
+ j = length;
+ while (j--) {
+ rankArr[j].rank = j;
+ }
+ j = length;
+ while (j--) {
+ if (points[j].rank >= slotsLength) {
+ points.splice(j, 1);
+ }
+ }
+ length = points.length;
+ }
+
+ // The label goes to the nearest open slot, but not closer to the edge than
+ // the label's index.
+ for (j = 0; j < length; j++) {
+
+ point = points[j];
+ labelPos = point.labelPos;
+
+ var closest = 9999,
+ distance,
+ slotI;
+
+ // find the closest slot index
+ for (slotI = 0; slotI < slotsLength; slotI++) {
+ distance = mathAbs(slots[slotI] - labelPos[1]);
+ if (distance < closest) {
+ closest = distance;
+ slotIndex = slotI;
+ }
+ }
+
+ // if that slot index is closer to the edges of the slots, move it
+ // to the closest appropriate slot
+ if (slotIndex < j && slots[j] !== null) { // cluster at the top
+ slotIndex = j;
+ } else if (slotsLength < length - j + slotIndex && slots[j] !== null) { // cluster at the bottom
+ slotIndex = slotsLength - length + j;
+ while (slots[slotIndex] === null) { // make sure it is not taken
+ slotIndex++;
+ }
+ } else {
+ // Slot is taken, find next free slot below. In the next run, the next slice will find the
+ // slot above these, because it is the closest one
+ while (slots[slotIndex] === null) { // make sure it is not taken
+ slotIndex++;
+ }
+ }
+
+ usedSlots.push({ i: slotIndex, y: slots[slotIndex] });
+ slots[slotIndex] = null; // mark as taken
+ }
+ // sort them in order to fill in from the top
+ usedSlots.sort(sort);
+
+
+ // now the used slots are sorted, fill them up sequentially
+ for (j = 0; j < length; j++) {
+
+ point = points[j];
+ labelPos = point.labelPos;
+ dataLabel = point.dataLabel;
+ var slot = usedSlots.pop(),
+ naturalY = labelPos[1];
+
+ visibility = point.visible === false ? HIDDEN : VISIBLE;
+ slotIndex = slot.i;
+
+ // if the slot next to currrent slot is free, the y value is allowed
+ // to fall back to the natural position
+ y = slot.y;
+ if ((naturalY > y && slots[slotIndex + 1] !== null) ||
+ (naturalY < y && slots[slotIndex - 1] !== null)) {
+ y = naturalY;
+ }
+
+ // get the x - use the natural x position for first and last slot, to prevent the top
+ // and botton slice connectors from touching each other on either side
+ x = series.getX(slotIndex === 0 || slotIndex === slots.length - 1 ? naturalY : y, i);
+
+ // move or place the data label
+ dataLabel
+ .attr({
+ visibility: visibility,
+ align: labelPos[6]
+ })[dataLabel.moved ? 'animate' : 'attr']({
+ x: x + options.x +
+ ({ left: connectorPadding, right: -connectorPadding }[labelPos[6]] || 0),
+ y: y + options.y
+ });
+ dataLabel.moved = true;
+
+ // draw the connector
+ if (outside && connectorWidth) {
+ connector = point.connector;
+
+ connectorPath = softConnector ? [
+ M,
+ x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
+ 'C',
+ x, y, // first break, next to the label
+ 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
+ labelPos[2], labelPos[3], // second break
+ L,
+ labelPos[4], labelPos[5] // base
+ ] : [
+ M,
+ x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
+ L,
+ labelPos[2], labelPos[3], // second break
+ L,
+ labelPos[4], labelPos[5] // base
+ ];
+
+ if (connector) {
+ connector.animate({ d: connectorPath });
+ connector.attr('visibility', visibility);
+
+ } else {
+ point.connector = connector = series.chart.renderer.path(connectorPath).attr({
+ 'stroke-width': connectorWidth,
+ stroke: options.connectorColor || point.color || '#606060',
+ visibility: visibility,
+ zIndex: 3
+ })
+ .translate(chart.plotLeft, chart.plotTop)
+ .add();
+ }
+ }
+ }
+ }
+ },
+
+ /**
+ * Draw point specific tracker objects. Inherit directly from column series.
+ */
+ drawTracker: ColumnSeries.prototype.drawTracker,
+
+ /**
+ * Pies don't have point marker symbols
+ */
+ getSymbol: function () {}
+
+});
+seriesTypes.pie = PieSeries;
+
+/* ****************************************************************************
+ * Start data grouping module *
+ ******************************************************************************/
+/*jslint white:true */
+var DATA_GROUPING = 'dataGrouping',
+ seriesProto = Series.prototype,
+ baseProcessData = seriesProto.processData,
+ baseGeneratePoints = seriesProto.generatePoints,
+ baseDestroy = seriesProto.destroy,
+ baseTooltipHeaderFormatter = seriesProto.tooltipHeaderFormatter,
+ NUMBER = 'number',
+
+ commonOptions = {
+ approximation: 'average', // average, open, high, low, close, sum
+ //forced: undefined,
+ groupPixelWidth: 2,
+ // the first one is the point or start value, the second is the start value if we're dealing with range,
+ // the third one is the end value if dealing with a range
+ dateTimeLabelFormats: hash(
+ MILLISECOND, ['%A, %b %e, %H:%M:%S.%L', '%A, %b %e, %H:%M:%S.%L', '-%H:%M:%S.%L'],
+ SECOND, ['%A, %b %e, %H:%M:%S', '%A, %b %e, %H:%M:%S', '-%H:%M:%S'],
+ MINUTE, ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
+ HOUR, ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
+ DAY, ['%A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
+ WEEK, ['Week from %A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
+ MONTH, ['%B %Y', '%B', '-%B %Y'],
+ YEAR, ['%Y', '%Y', '-%Y']
+ )
+ // smoothed = false, // enable this for navigator series only
+ },
+
+ // units are defined in a separate array to allow complete overriding in case of a user option
+ defaultDataGroupingUnits = [[
+ MILLISECOND, // unit name
+ [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
+ ], [
+ SECOND,
+ [1, 2, 5, 10, 15, 30]
+ ], [
+ MINUTE,
+ [1, 2, 5, 10, 15, 30]
+ ], [
+ HOUR,
+ [1, 2, 3, 4, 6, 8, 12]
+ ], [
+ DAY,
+ [1]
+ ], [
+ WEEK,
+ [1]
+ ], [
+ MONTH,
+ [1, 3, 6]
+ ], [
+ YEAR,
+ null
+ ]
+ ],
+
+ /**
+ * Define the available approximation types. The data grouping approximations takes an array
+ * or numbers as the first parameter. In case of ohlc, four arrays are sent in as four parameters.
+ * Each array consists only of numbers. In case null values belong to the group, the property
+ * .hasNulls will be set to true on the array.
+ */
+ approximations = {
+ sum: function (arr) {
+ var len = arr.length,
+ ret;
+
+ // 1. it consists of nulls exclusively
+ if (!len && arr.hasNulls) {
+ ret = null;
+ // 2. it has a length and real values
+ } else if (len) {
+ ret = 0;
+ while (len--) {
+ ret += arr[len];
+ }
+ }
+ // 3. it has zero length, so just return undefined
+ // => doNothing()
+
+ return ret;
+ },
+ average: function (arr) {
+ var len = arr.length,
+ ret = approximations.sum(arr);
+
+ // If we have a number, return it divided by the length. If not, return
+ // null or undefined based on what the sum method finds.
+ if (typeof ret === NUMBER && len) {
+ ret = ret / len;
+ }
+
+ return ret;
+ },
+ open: function (arr) {
+ return arr.length ? arr[0] : (arr.hasNulls ? null : UNDEFINED);
+ },
+ high: function (arr) {
+ return arr.length ? arrayMax(arr) : (arr.hasNulls ? null : UNDEFINED);
+ },
+ low: function (arr) {
+ return arr.length ? arrayMin(arr) : (arr.hasNulls ? null : UNDEFINED);
+ },
+ close: function (arr) {
+ return arr.length ? arr[arr.length - 1] : (arr.hasNulls ? null : UNDEFINED);
+ },
+ // ohlc is a special case where a multidimensional array is input and an array is output
+ ohlc: function (open, high, low, close) {
+ open = approximations.open(open);
+ high = approximations.high(high);
+ low = approximations.low(low);
+ close = approximations.close(close);
+
+ if (typeof open === NUMBER || typeof high === NUMBER || typeof low === NUMBER || typeof close === NUMBER) {
+ return [open, high, low, close];
+ }
+ // else, return is undefined
+ }
+ };
+
+/*jslint white:false */
+
+/**
+ * Takes parallel arrays of x and y data and groups the data into intervals defined by groupPositions, a collection
+ * of starting x values for each group.
+ */
+seriesProto.groupData = function (xData, yData, groupPositions, approximation) {
+ var series = this,
+ data = series.data,
+ dataOptions = series.options.data,
+ groupedXData = [],
+ groupedYData = [],
+ dataLength = xData.length,
+ pointX,
+ pointY,
+ groupedY,
+ handleYData = !!yData, // when grouping the fake extended axis for panning, we don't need to consider y
+ values1 = [],
+ values2 = [],
+ values3 = [],
+ values4 = [],
+ approximationFn = typeof approximation === 'function' ? approximation : approximations[approximation],
+ i;
+
+ for (i = 0; i <= dataLength; i++) {
+
+ // when a new group is entered, summarize and initiate the previous group
+ while ((groupPositions[1] !== UNDEFINED && xData[i] >= groupPositions[1]) ||
+ i === dataLength) { // get the last group
+
+ // get group x and y
+ pointX = groupPositions.shift();
+ groupedY = approximationFn(values1, values2, values3, values4);
+
+ // push the grouped data
+ if (groupedY !== UNDEFINED) {
+ groupedXData.push(pointX);
+ groupedYData.push(groupedY);
+ }
+
+ // reset the aggregate arrays
+ values1 = [];
+ values2 = [];
+ values3 = [];
+ values4 = [];
+
+ // don't loop beyond the last group
+ if (i === dataLength) {
+ break;
+ }
+ }
+
+ // break out
+ if (i === dataLength) {
+ break;
+ }
+
+ // for each raw data point, push it to an array that contains all values for this specific group
+ pointY = handleYData ? yData[i] : null;
+ if (approximation === 'ohlc') {
+
+ var index = series.cropStart + i,
+ point = (data && data[index]) || series.pointClass.prototype.applyOptions.apply({}, [dataOptions[index]]),
+ open = point.open,
+ high = point.high,
+ low = point.low,
+ close = point.close;
+
+
+ if (typeof open === NUMBER) {
+ values1.push(open);
+ } else if (open === null) {
+ values1.hasNulls = true;
+ }
+
+ if (typeof high === NUMBER) {
+ values2.push(high);
+ } else if (high === null) {
+ values2.hasNulls = true;
+ }
+
+ if (typeof low === NUMBER) {
+ values3.push(low);
+ } else if (low === null) {
+ values3.hasNulls = true;
+ }
+
+ if (typeof close === NUMBER) {
+ values4.push(close);
+ } else if (close === null) {
+ values4.hasNulls = true;
+ }
+ } else {
+ if (typeof pointY === NUMBER) {
+ values1.push(pointY);
+ } else if (pointY === null) {
+ values1.hasNulls = true;
+ }
+ }
+
+ }
+ return [groupedXData, groupedYData];
+};
+
+/**
+ * Extend the basic processData method, that crops the data to the current zoom
+ * range, with data grouping logic.
+ */
+seriesProto.processData = function () {
+ var series = this,
+ options = series.options,
+ dataGroupingOptions = options[DATA_GROUPING],
+ groupingEnabled = dataGroupingOptions && dataGroupingOptions.enabled,
+ groupedData = series.groupedData,
+ hasGroupedData;
+
+ // run base method
+ series.forceCrop = groupingEnabled; // #334
+
+ // skip if processData returns false or if grouping is disabled (in that order)
+ if (baseProcessData.apply(series, arguments) === false || !groupingEnabled) {
+ return;
+
+ } else {
+ // clear previous groups, #622, #740
+ each(groupedData || [], function (point, i) {
+ if (point) {
+ groupedData[i] = point.destroy ? point.destroy() : null;
+ }
+ });
+ }
+
+ var i,
+ chart = series.chart,
+ processedXData = series.processedXData,
+ processedYData = series.processedYData,
+ plotSizeX = chart.plotSizeX,
+ xAxis = series.xAxis,
+ groupPixelWidth = pick(xAxis.groupPixelWidth, dataGroupingOptions.groupPixelWidth),
+ dataLength = processedXData.length,
+ chartSeries = chart.series,
+ nonGroupedPointRange = series.pointRange;
+
+ // attempt to solve #334: if multiple series are compared on the same x axis, give them the same
+ // group pixel width
+ if (!xAxis.groupPixelWidth) {
+ i = chartSeries.length;
+ while (i--) {
+ if (chartSeries[i].xAxis === xAxis && chartSeries[i].options[DATA_GROUPING]) {
+ groupPixelWidth = mathMax(groupPixelWidth, chartSeries[i].options[DATA_GROUPING].groupPixelWidth);
+ }
+ }
+ xAxis.groupPixelWidth = groupPixelWidth;
+
+ }
+
+ // Execute grouping if the amount of points is greater than the limit defined in groupPixelWidth
+ if (dataLength > (plotSizeX / groupPixelWidth) || dataGroupingOptions.forced) {
+ hasGroupedData = true;
+
+ series.points = null; // force recreation of point instances in series.translate
+
+ var extremes = xAxis.getExtremes(),
+ xMin = extremes.min,
+ xMax = extremes.max,
+ groupIntervalFactor = (xAxis.getGroupIntervalFactor && xAxis.getGroupIntervalFactor(xMin, xMax, processedXData)) || 1,
+ interval = (groupPixelWidth * (xMax - xMin) / plotSizeX) * groupIntervalFactor,
+ groupPositions = (xAxis.getNonLinearTimeTicks || getTimeTicks)(
+ normalizeTimeTickInterval(interval, dataGroupingOptions.units || defaultDataGroupingUnits),
+ xMin,
+ xMax,
+ null,
+ processedXData,
+ series.closestPointRange
+ ),
+ groupedXandY = seriesProto.groupData.apply(series, [processedXData, processedYData, groupPositions, dataGroupingOptions.approximation]),
+ groupedXData = groupedXandY[0],
+ groupedYData = groupedXandY[1];
+
+ // prevent the smoothed data to spill out left and right, and make
+ // sure data is not shifted to the left
+ if (dataGroupingOptions.smoothed) {
+ i = groupedXData.length - 1;
+ groupedXData[i] = xMax;
+ while (i-- && i > 0) {
+ groupedXData[i] += interval / 2;
+ }
+ groupedXData[0] = xMin;
+ }
+
+ // record what data grouping values were used
+ series.currentDataGrouping = groupPositions.info;
+ if (options.pointRange === null) { // null means auto, as for columns, candlesticks and OHLC
+ series.pointRange = groupPositions.info.totalRange;
+ }
+ series.closestPointRange = groupPositions.info.totalRange;
+
+ // set series props
+ series.processedXData = groupedXData;
+ series.processedYData = groupedYData;
+ } else {
+ series.currentDataGrouping = null;
+ series.pointRange = nonGroupedPointRange;
+ }
+
+ series.hasGroupedData = hasGroupedData;
+};
+
+seriesProto.generatePoints = function () {
+ var series = this;
+
+ baseGeneratePoints.apply(series);
+
+ // record grouped data in order to let it be destroyed the next time processData runs
+ series.groupedData = series.hasGroupedData ? series.points : null;
+};
+
+/**
+ * Make the tooltip's header reflect the grouped range
+ */
+seriesProto.tooltipHeaderFormatter = function (key) {
+ var series = this,
+ options = series.options,
+ tooltipOptions = series.tooltipOptions,
+ dataGroupingOptions = options.dataGrouping,
+ xDateFormat = tooltipOptions.xDateFormat,
+ xDateFormatEnd,
+ xAxis = series.xAxis,
+ currentDataGrouping,
+ dateTimeLabelFormats,
+ labelFormats,
+ formattedKey,
+ n,
+ ret;
+
+ // apply only to grouped series
+ if (xAxis && xAxis.options.type === 'datetime' && dataGroupingOptions) {
+
+ // set variables
+ currentDataGrouping = series.currentDataGrouping;
+ dateTimeLabelFormats = dataGroupingOptions.dateTimeLabelFormats;
+
+ // if we have grouped data, use the grouping information to get the right format
+ if (currentDataGrouping) {
+ labelFormats = dateTimeLabelFormats[currentDataGrouping.unitName];
+ if (currentDataGrouping.count === 1) {
+ xDateFormat = labelFormats[0];
+ } else {
+ xDateFormat = labelFormats[1];
+ xDateFormatEnd = labelFormats[2];
+ }
+ // if not grouped, and we don't have set the xDateFormat option, get the best fit,
+ // so if the least distance between points is one minute, show it, but if the
+ // least distance is one day, skip hours and minutes etc.
+ } else if (!xDateFormat) {
+ for (n in timeUnits) {
+ if (timeUnits[n] >= xAxis.closestPointRange) {
+ xDateFormat = dateTimeLabelFormats[n][0];
+ break;
+ }
+ }
+ }
+
+ // now format the key
+ formattedKey = dateFormat(xDateFormat, key);
+ if (xDateFormatEnd) {
+ formattedKey += dateFormat(xDateFormatEnd, key + currentDataGrouping.totalRange - 1);
+ }
+
+ // return the replaced format
+ ret = tooltipOptions.headerFormat.replace('{point.key}', formattedKey);
+
+ // else, fall back to the regular formatter
+ } else {
+ ret = baseTooltipHeaderFormatter.apply(series, [key]);
+ }
+
+ return ret;
+};
+
+/**
+ * Extend the series destroyer
+ */
+seriesProto.destroy = function () {
+ var series = this,
+ groupedData = series.groupedData || [],
+ i = groupedData.length;
+
+ while (i--) {
+ if (groupedData[i]) {
+ groupedData[i].destroy();
+ }
+ }
+ baseDestroy.apply(series);
+};
+
+
+// Extend the plot options
+
+// line types
+defaultPlotOptions.line[DATA_GROUPING] =
+ defaultPlotOptions.spline[DATA_GROUPING] =
+ defaultPlotOptions.area[DATA_GROUPING] =
+ defaultPlotOptions.areaspline[DATA_GROUPING] = commonOptions;
+
+// bar-like types (OHLC and candleticks inherit this as the classes are not yet built)
+defaultPlotOptions.column[DATA_GROUPING] = merge(commonOptions, {
+ approximation: 'sum',
+ groupPixelWidth: 10
+});
+/* ****************************************************************************
+ * End data grouping module *
+ ******************************************************************************//* ****************************************************************************
+ * Start OHLC series code *
+ *****************************************************************************/
+
+// 1 - Set default options
+defaultPlotOptions.ohlc = merge(defaultPlotOptions.column, {
+ lineWidth: 1,
+ dataGrouping: {
+ approximation: 'ohlc',
+ enabled: true,
+ groupPixelWidth: 5 // allows to be packed tighter than candlesticks
+ },
+ states: {
+ hover: {
+ lineWidth: 3
+ }
+ }
+});
+
+// 2- Create the OHLCPoint object
+var OHLCPoint = extendClass(Point, {
+ /**
+ * Apply the options containing the x and OHLC data and possible some extra properties.
+ * This is called on point init or from point.update. Extends base Point by adding
+ * multiple y-like values.
+ *
+ * @param {Object} options
+ */
+ applyOptions: function (options) {
+ var point = this,
+ series = point.series,
+ i = 0;
+
+
+ // object input for example:
+ // { x: Date(2010, 0, 1), open: 7.88, high: 7.99, low: 7.02, close: 7.65 }
+ if (typeof options === 'object' && typeof options.length !== 'number') {
+
+ // copy options directly to point
+ extend(point, options);
+
+ point.options = options;
+ } else if (options.length) { // array
+ // with leading x value
+ if (options.length === 5) {
+ if (typeof options[0] === 'string') {
+ point.name = options[0];
+ } else if (typeof options[0] === 'number') {
+ point.x = options[0];
+ }
+ i++;
+ }
+ point.open = options[i++];
+ point.high = options[i++];
+ point.low = options[i++];
+ point.close = options[i++];
+ }
+
+ /*
+ * If no x is set by now, get auto incremented value. All points must have an
+ * x value, however the y value can be null to create a gap in the series
+ */
+ point.y = point.high;
+ if (point.x === UNDEFINED && series) {
+ point.x = series.autoIncrement();
+ }
+ return point;
+ },
+
+ /**
+ * A specific OHLC tooltip formatter
+ */
+ tooltipFormatter: function () {
+ var point = this,
+ series = point.series;
+
+ return ['<span style="color:' + series.color + ';font-weight:bold">', (point.name || series.name), '</span><br/>',
+ 'Open: ', point.open, '<br/>',
+ 'High: ', point.high, '<br/>',
+ 'Low: ', point.low, '<br/>',
+ 'Close: ', point.close, '<br/>'].join('');
+
+ }
+
+});
+
+// 3 - Create the OHLCSeries object
+var OHLCSeries = extendClass(seriesTypes.column, {
+ type: 'ohlc',
+ valueCount: 4, // four values per point
+ pointClass: OHLCPoint,
+ useThreshold: false,
+
+ pointAttrToOptions: { // mapping between SVG attributes and the corresponding options
+ stroke: 'color',
+ 'stroke-width': 'lineWidth'
+ },
+
+
+ /**
+ * Translate data points from raw values x and y to plotX and plotY
+ */
+ translate: function () {
+ var series = this,
+ yAxis = series.yAxis;
+
+ seriesTypes.column.prototype.translate.apply(series);
+
+ // do the translation
+ each(series.points, function (point) {
+ // the graphics
+ if (point.open !== null) {
+ point.plotOpen = yAxis.translate(point.open, 0, 1, 0, 1);
+ }
+ if (point.close !== null) {
+ point.plotClose = yAxis.translate(point.close, 0, 1, 0, 1);
+ }
+
+ });
+ },
+
+ /**
+ * Draw the data points
+ */
+ drawPoints: function () {
+ var series = this,
+ points = series.points,
+ chart = series.chart,
+ pointAttr,
+ plotOpen,
+ plotClose,
+ crispCorr,
+ halfWidth,
+ path,
+ graphic,
+ crispX;
+
+
+ each(points, function (point) {
+ if (point.plotY !== UNDEFINED) {
+
+ graphic = point.graphic;
+ pointAttr = point.pointAttr[point.selected ? 'selected' : ''];
+
+ // crisp vector coordinates
+ crispCorr = (pointAttr['stroke-width'] % 2) / 2;
+ crispX = mathRound(point.plotX) + crispCorr;
+ halfWidth = mathRound(point.barW / 2);
+
+ // the vertical stem
+ path = [
+ 'M',
+ crispX, mathRound(point.yBottom),
+ 'L',
+ crispX, mathRound(point.plotY)
+ ];
+
+ // open
+ if (point.open !== null) {
+ plotOpen = mathRound(point.plotOpen) + crispCorr;
+ path.push(
+ 'M',
+ crispX,
+ plotOpen,
+ 'L',
+ crispX - halfWidth,
+ plotOpen
+ );
+ }
+
+ // close
+ if (point.close !== null) {
+ plotClose = mathRound(point.plotClose) + crispCorr;
+ path.push(
+ 'M',
+ crispX,
+ plotClose,
+ 'L',
+ crispX + halfWidth,
+ plotClose
+ );
+ }
+
+ // create and/or update the graphic
+ if (graphic) {
+ graphic.animate({ d: path });
+ } else {
+ point.graphic = chart.renderer.path(path)
+ .attr(pointAttr)
+ .add(series.group);
+ }
+
+ }
+
+
+ });
+
+ },
+
+ /**
+ * Disable animation
+ */
+ animate: null
+
+
+});
+seriesTypes.ohlc = OHLCSeries;
+/* ****************************************************************************
+ * End OHLC series code *
+ *****************************************************************************/
+/* ****************************************************************************
+ * Start Candlestick series code *
+ *****************************************************************************/
+
+// 1 - set default options
+defaultPlotOptions.candlestick = merge(defaultPlotOptions.column, {
+ dataGrouping: {
+ approximation: 'ohlc',
+ enabled: true
+ },
+ lineColor: 'black',
+ lineWidth: 1,
+ upColor: 'white',
+ states: {
+ hover: {
+ lineWidth: 2
+ }
+ }
+});
+
+// 2 - Create the CandlestickSeries object
+var CandlestickSeries = extendClass(OHLCSeries, {
+ type: 'candlestick',
+
+ /**
+ * One-to-one mapping from options to SVG attributes
+ */
+ pointAttrToOptions: { // mapping between SVG attributes and the corresponding options
+ fill: 'color',
+ stroke: 'lineColor',
+ 'stroke-width': 'lineWidth'
+ },
+
+ /**
+ * Postprocess mapping between options and SVG attributes
+ */
+ getAttribs: function () {
+ OHLCSeries.prototype.getAttribs.apply(this, arguments);
+ var series = this,
+ options = series.options,
+ stateOptions = options.states,
+ upColor = options.upColor,
+ seriesDownPointAttr = merge(series.pointAttr);
+
+ seriesDownPointAttr[''].fill = upColor;
+ seriesDownPointAttr.hover.fill = stateOptions.hover.upColor || upColor;
+ seriesDownPointAttr.select.fill = stateOptions.select.upColor || upColor;
+
+ each(series.points, function (point) {
+ if (point.open < point.close) {
+ point.pointAttr = seriesDownPointAttr;
+ }
+ });
+ },
+
+ /**
+ * Draw the data points
+ */
+ drawPoints: function () {
+ var series = this, //state = series.state,
+ points = series.points,
+ chart = series.chart,
+ pointAttr,
+ plotOpen,
+ plotClose,
+ topBox,
+ bottomBox,
+ crispCorr,
+ crispX,
+ graphic,
+ path,
+ halfWidth;
+
+
+ each(points, function (point) {
+
+ graphic = point.graphic;
+ if (point.plotY !== UNDEFINED) {
+
+ pointAttr = point.pointAttr[point.selected ? 'selected' : ''];
+
+ // crisp vector coordinates
+ crispCorr = (pointAttr['stroke-width'] % 2) / 2;
+ crispX = mathRound(point.plotX) + crispCorr;
+ plotOpen = mathRound(point.plotOpen) + crispCorr;
+ plotClose = mathRound(point.plotClose) + crispCorr;
+ topBox = math.min(plotOpen, plotClose);
+ bottomBox = math.max(plotOpen, plotClose);
+ halfWidth = mathRound(point.barW / 2);
+
+ // create the path
+ path = [
+ 'M',
+ crispX - halfWidth, bottomBox,
+ 'L',
+ crispX - halfWidth, topBox,
+ 'L',
+ crispX + halfWidth, topBox,
+ 'L',
+ crispX + halfWidth, bottomBox,
+ 'L',
+ crispX - halfWidth, bottomBox,
+ 'M',
+ crispX, bottomBox,
+ 'L',
+ crispX, mathRound(point.yBottom),
+ 'M',
+ crispX, topBox,
+ 'L',
+ crispX, mathRound(point.plotY),
+ 'Z'
+ ];
+
+ if (graphic) {
+ graphic.animate({ d: path });
+ } else {
+ point.graphic = chart.renderer.path(path)
+ .attr(pointAttr)
+ .add(series.group);
+ }
+
+ }
+ });
+
+ }
+
+
+});
+
+seriesTypes.candlestick = CandlestickSeries;
+
+/* ****************************************************************************
+ * End Candlestick series code *
+ *****************************************************************************/
+/* ****************************************************************************
+ * Start Flags series code *
+ *****************************************************************************/
+
+var symbols = SVGRenderer.prototype.symbols;
+
+// 1 - set default options
+defaultPlotOptions.flags = merge(defaultPlotOptions.column, {
+ dataGrouping: null,
+ fillColor: 'white',
+ lineWidth: 1,
+ pointRange: 0, // #673
+ //radius: 2,
+ shape: 'flag',
+ stackDistance: 7,
+ states: {
+ hover: {
+ lineColor: 'black',
+ fillColor: '#FCFFC5'
+ }
+ },
+ style: {
+ fontSize: '11px',
+ fontWeight: 'bold',
+ textAlign: 'center'
+ },
+ y: -30
+});
+
+// 2 - Create the CandlestickSeries object
+seriesTypes.flags = extendClass(seriesTypes.column, {
+ type: 'flags',
+ noSharedTooltip: true,
+ useThreshold: false,
+ /**
+ * Inherit the initialization from base Series
+ */
+ init: Series.prototype.init,
+
+ /**
+ * One-to-one mapping from options to SVG attributes
+ */
+ pointAttrToOptions: { // mapping between SVG attributes and the corresponding options
+ fill: 'fillColor',
+ stroke: 'color',
+ 'stroke-width': 'lineWidth',
+ r: 'radius'
+ },
+
+ /**
+ * Extend the translate method by placing the point on the related series
+ */
+ translate: function () {
+
+ seriesTypes.column.prototype.translate.apply(this);
+
+ var series = this,
+ options = series.options,
+ chart = series.chart,
+ points = series.points,
+ cursor = points.length - 1,
+ i,
+ point,
+ lastPoint,
+ optionsOnSeries = options.onSeries,
+ onSeries = optionsOnSeries && chart.get(optionsOnSeries),
+ onData,
+ leftPoint,
+ rightPoint;
+
+
+ // relate to a master series
+ if (onSeries) {
+ onData = onSeries.points;
+ i = onData.length;
+
+ // sort the data points
+ points.sort(function (a, b) {
+ return (a.x - b.x);
+ });
+
+ while (i-- && points[cursor]) {
+ point = points[cursor];
+ leftPoint = onData[i];
+ if (leftPoint.x <= point.x) {
+ point.plotY = leftPoint.plotY;
+
+ // interpolate between points, #666
+ if (leftPoint.x < point.x) {
+ rightPoint = onData[i + 1];
+ if (rightPoint) {
+ point.plotY +=
+ ((point.x - leftPoint.x) / (rightPoint.x - leftPoint.x)) * // the distance ratio, between 0 and 1
+ (rightPoint.plotY - leftPoint.plotY); // the y distance
+ }
+ }
+
+ cursor--;
+ i++; // check again for points in the same x position
+ if (cursor < 0) {
+ break;
+ }
+ }
+ }
+ }
+
+ each(points, function (point, i) {
+ // place on y axis or custom position
+ if (!onSeries) {
+ point.plotY = point.y === UNDEFINED ? chart.plotHeight : point.plotY;
+ }
+ // if multiple flags appear at the same x, order them into a stack
+ lastPoint = points[i - 1];
+ if (lastPoint && lastPoint.plotX === point.plotX) {
+ if (lastPoint.stackIndex === UNDEFINED) {
+ lastPoint.stackIndex = 0;
+ }
+ point.stackIndex = lastPoint.stackIndex + 1;
+ }
+
+ });
+
+
+ },
+
+ /**
+ * Draw the markers
+ */
+ drawPoints: function () {
+ var series = this,
+ pointAttr,
+ points = series.points,
+ chart = series.chart,
+ renderer = chart.renderer,
+ plotX,
+ plotY,
+ options = series.options,
+ optionsY = options.y,
+ shape = options.shape,
+ box,
+ bBox,
+ i,
+ point,
+ graphic,
+ connector,
+ stackIndex,
+ crisp = (options.lineWidth % 2 / 2),
+ anchorX,
+ anchorY;
+
+ i = points.length;
+ while (i--) {
+ point = points[i];
+ plotX = point.plotX + crisp;
+ stackIndex = point.stackIndex;
+ plotY = point.plotY + optionsY + crisp - (stackIndex !== UNDEFINED && stackIndex * options.stackDistance);
+ // outside to the left, on series but series is clipped
+ if (isNaN(plotY)) {
+ plotY = 0;
+ }
+ anchorX = stackIndex ? UNDEFINED : point.plotX + crisp; // skip connectors for higher level stacked points
+ anchorY = stackIndex ? UNDEFINED : point.plotY;
+
+ graphic = point.graphic;
+ connector = point.connector;
+
+ // only draw the point if y is defined
+ if (plotY !== UNDEFINED) {
+ // shortcuts
+ pointAttr = point.pointAttr[point.selected ? 'select' : ''];
+ if (graphic) { // update
+ graphic.attr({
+ x: plotX,
+ y: plotY,
+ r: pointAttr.r,
+ anchorX: anchorX,
+ anchorY: anchorY
+ });
+ } else {
+ graphic = point.graphic = renderer.label(
+ point.options.title || options.title || 'A',
+ plotX,
+ plotY,
+ shape,
+ anchorX,
+ anchorY
+ )
+ .css(merge(options.style, point.style))
+ .attr(pointAttr)
+ .attr({
+ align: shape === 'flag' ? 'left' : 'center',
+ width: options.width,
+ height: options.height
+ })
+ .add(series.group)
+ .shadow(options.shadow);
+
+ }
+
+ // get the bounding box
+ box = graphic.box;
+ bBox = box.getBBox();
+
+ // set the shape arguments for the tracker element
+ point.shapeArgs = extend(
+ bBox,
+ {
+ x: plotX - (shape === 'flag' ? 0 : box.attr('width') / 2), // flags align left, else align center
+ y: plotY
+ }
+ );
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Extend the column trackers with listeners to expand and contract stacks
+ */
+ drawTracker: function () {
+ var series = this;
+
+ seriesTypes.column.prototype.drawTracker.apply(series);
+
+ // put each point in front on mouse over, this allows readability of vertically
+ // stacked elements as well as tight points on the x axis
+ each(series.points, function (point) {
+ addEvent(point.tracker.element, 'mouseover', function () {
+ point.graphic.toFront();
+ });
+ });
+ },
+
+ /**
+ * Override the regular tooltip formatter by returning the point text given
+ * in the options
+ */
+ tooltipFormatter: function (item) {
+ return item.point.text;
+ },
+
+ /**
+ * Disable animation
+ */
+ animate: function () {}
+
+});
+
+// create the flag icon with anchor
+symbols.flag = function (x, y, w, h, options) {
+ var anchorX = (options && options.anchorX) || x,
+ anchorY = (options && options.anchorY) || y;
+
+ return [
+ 'M', anchorX, anchorY,
+ 'L', x, y + h,
+ x, y,
+ x + w, y,
+ x + w, y + h,
+ x, y + h,
+ 'M', anchorX, anchorY,
+ 'Z'
+ ];
+};
+
+// create the circlepin and squarepin icons with anchor
+each(['circle', 'square'], function (shape) {
+ symbols[shape + 'pin'] = function (x, y, w, h, options) {
+
+ var anchorX = options && options.anchorX,
+ anchorY = options && options.anchorY,
+ path = symbols[shape](x, y, w, h);
+
+ if (anchorX && anchorY) {
+ path.push('M', anchorX, y + h, 'L', anchorX, anchorY);
+ }
+
+ return path;
+ };
+});
+
+// The symbol callbacks are generated on the SVGRenderer object in all browsers. Even
+// VML browsers need this in order to generate shapes in export. Now share
+// them with the VMLRenderer.
+if (Renderer === VMLRenderer) {
+ each(['flag', 'circlepin', 'squarepin'], function (shape) {
+ VMLRenderer.prototype.symbols[shape] = symbols[shape];
+ });
+}
+
+/* ****************************************************************************
+ * End Flags series code *
+ *****************************************************************************/
+
+// constants
+var MOUSEDOWN = hasTouch ? 'touchstart' : 'mousedown',
+ MOUSEMOVE = hasTouch ? 'touchmove' : 'mousemove',
+ MOUSEUP = hasTouch ? 'touchend' : 'mouseup';
+
+
+
+
+/* ****************************************************************************
+ * Start Scroller code *
+ *****************************************************************************/
+/*jslint white:true */
+var buttonGradient = hash(
+ LINEAR_GRADIENT, { x1: 0, y1: 0, x2: 0, y2: 1 },
+ STOPS, [
+ [0, '#FFF'],
+ [1, '#CCC']
+ ]
+ ),
+ units = [].concat(defaultDataGroupingUnits); // copy
+
+// add more resolution to units
+units[4] = [DAY, [1, 2, 3, 4]]; // allow more days
+units[5] = [WEEK, [1, 2, 3]]; // allow more weeks
+
+extend(defaultOptions, {
+ navigator: {
+ //enabled: true,
+ handles: {
+ backgroundColor: '#FFF',
+ borderColor: '#666'
+ },
+ height: 40,
+ margin: 10,
+ maskFill: 'rgba(255, 255, 255, 0.75)',
+ outlineColor: '#444',
+ outlineWidth: 1,
+ series: {
+ type: 'areaspline',
+ color: '#4572A7',
+ compare: null,
+ fillOpacity: 0.4,
+ dataGrouping: {
+ approximation: 'average',
+ groupPixelWidth: 2,
+ smoothed: true,
+ units: units
+ },
+ dataLabels: {
+ enabled: false
+ },
+ id: PREFIX + 'navigator-series',
+ lineColor: '#4572A7',
+ lineWidth: 1,
+ marker: {
+ enabled: false
+ },
+ pointRange: 0,
+ shadow: false
+ },
+ //top: undefined, // docs
+ xAxis: {
+ tickWidth: 0,
+ lineWidth: 0,
+ gridLineWidth: 1,
+ tickPixelInterval: 200,
+ labels: {
+ align: 'left',
+ x: 3,
+ y: -4
+ }
+ },
+ yAxis: {
+ gridLineWidth: 0,
+ startOnTick: false,
+ endOnTick: false,
+ minPadding: 0.1,
+ maxPadding: 0.1,
+ labels: {
+ enabled: false
+ },
+ title: {
+ text: null
+ },
+ tickWidth: 0
+ }
+ },
+ scrollbar: {
+ //enabled: true
+ height: hasTouch ? 20 : 14,
+ barBackgroundColor: buttonGradient,
+ barBorderRadius: 2,
+ barBorderWidth: 1,
+ barBorderColor: '#666',
+ buttonArrowColor: '#666',
+ buttonBackgroundColor: buttonGradient,
+ buttonBorderColor: '#666',
+ buttonBorderRadius: 2,
+ buttonBorderWidth: 1,
+ rifleColor: '#666',
+ trackBackgroundColor: hash(
+ LINEAR_GRADIENT, { x1: 0, y1: 0, x2: 0, y2: 1 },
+ STOPS, [
+ [0, '#EEE'],
+ [1, '#FFF']
+ ]
+ ),
+ trackBorderColor: '#CCC',
+ trackBorderWidth: 1
+ // trackBorderRadius: 0
+ }
+});
+/*jslint white:false */
+
+/**
+ * The Scroller class
+ * @param {Object} chart
+ */
+Highcharts.Scroller = function (chart) {
+
+ var renderer = chart.renderer,
+ chartOptions = chart.options,
+ navigatorOptions = chartOptions.navigator,
+ navigatorEnabled = navigatorOptions.enabled,
+ navigatorLeft,
+ navigatorWidth,
+ navigatorSeries,
+ navigatorData,
+ scrollbarOptions = chartOptions.scrollbar,
+ scrollbarEnabled = scrollbarOptions.enabled,
+ grabbedLeft,
+ grabbedRight,
+ grabbedCenter,
+ otherHandlePos,
+ dragOffset,
+ hasDragged,
+ xAxis,
+ yAxis,
+ zoomedMin,
+ zoomedMax,
+ range,
+
+ bodyStyle = document.body.style,
+ defaultBodyCursor,
+
+ handlesOptions = navigatorOptions.handles,
+ height = navigatorEnabled ? navigatorOptions.height : 0,
+ outlineWidth = navigatorOptions.outlineWidth,
+ scrollbarHeight = scrollbarEnabled ? scrollbarOptions.height : 0,
+ outlineHeight = height + scrollbarHeight,
+ barBorderRadius = scrollbarOptions.barBorderRadius,
+ top,
+ halfOutline = outlineWidth / 2,
+ outlineTop,
+ scrollerLeft,
+ scrollerWidth,
+ rendered,
+ baseSeriesOption = navigatorOptions.baseSeries,
+ baseSeries = chart.series[baseSeriesOption] ||
+ (typeof baseSeriesOption === 'string' && chart.get(baseSeriesOption)) ||
+ chart.series[0],
+
+ // element wrappers
+ leftShade,
+ rightShade,
+ outline,
+ handles = [],
+ scrollbarGroup,
+ scrollbarTrack,
+ scrollbar,
+ scrollbarRifles,
+ scrollbarButtons = [],
+ elementsToDestroy = []; // Array containing the elements to destroy when Scroller is destroyed
+
+ chart.resetZoomEnabled = false;
+
+ /**
+ * Return the top of the navigation
+ */
+ function getAxisTop(chartHeight) {
+ return navigatorOptions.top || chartHeight - height - scrollbarHeight - chartOptions.chart.spacingBottom;
+ }
+
+ /**
+ * Draw one of the handles on the side of the zoomed range in the navigator
+ * @param {Number} x The x center for the handle
+ * @param {Number} index 0 for left and 1 for right
+ */
+ function drawHandle(x, index) {
+
+ var attr = {
+ fill: handlesOptions.backgroundColor,
+ stroke: handlesOptions.borderColor,
+ 'stroke-width': 1
+ },
+ tempElem;
+
+ // create the elements
+ if (!rendered) {
+
+ // the group
+ handles[index] = renderer.g()
+ .css({ cursor: 'e-resize' })
+ .attr({ zIndex: 4 - index }) // zIndex = 3 for right handle, 4 for left
+ .add();
+
+ // the rectangle
+ tempElem = renderer.rect(-4.5, 0, 9, 16, 3, 1)
+ .attr(attr)
+ .add(handles[index]);
+ elementsToDestroy.push(tempElem);
+
+ // the rifles
+ tempElem = renderer.path([
+ 'M',
+ -1.5, 4,
+ 'L',
+ -1.5, 12,
+ 'M',
+ 0.5, 4,
+ 'L',
+ 0.5, 12
+ ]).attr(attr)
+ .add(handles[index]);
+ elementsToDestroy.push(tempElem);
+ }
+
+ handles[index].translate(scrollerLeft + scrollbarHeight + parseInt(x, 10), top + height / 2 - 8);
+ }
+
+ /**
+ * Draw the scrollbar buttons with arrows
+ * @param {Number} index 0 is left, 1 is right
+ */
+ function drawScrollbarButton(index) {
+ var tempElem;
+ if (!rendered) {
+
+ scrollbarButtons[index] = renderer.g().add(scrollbarGroup);
+
+ tempElem = renderer.rect(
+ -0.5,
+ -0.5,
+ scrollbarHeight + 1, // +1 to compensate for crispifying in rect method
+ scrollbarHeight + 1,
+ scrollbarOptions.buttonBorderRadius,
+ scrollbarOptions.buttonBorderWidth
+ ).attr({
+ stroke: scrollbarOptions.buttonBorderColor,
+ 'stroke-width': scrollbarOptions.buttonBorderWidth,
+ fill: scrollbarOptions.buttonBackgroundColor
+ }).add(scrollbarButtons[index]);
+ elementsToDestroy.push(tempElem);
+
+ tempElem = renderer.path([
+ 'M',
+ scrollbarHeight / 2 + (index ? -1 : 1), scrollbarHeight / 2 - 3,
+ 'L',
+ scrollbarHeight / 2 + (index ? -1 : 1), scrollbarHeight / 2 + 3,
+ scrollbarHeight / 2 + (index ? 2 : -2), scrollbarHeight / 2
+ ]).attr({
+ fill: scrollbarOptions.buttonArrowColor
+ }).add(scrollbarButtons[index]);
+ elementsToDestroy.push(tempElem);
+ }
+
+ // adjust the right side button to the varying length of the scroll track
+ if (index) {
+ scrollbarButtons[index].attr({
+ translateX: scrollerWidth - scrollbarHeight
+ });
+ }
+ }
+
+ /**
+ * Render the navigator and scroll bar
+ * @param {Number} min X axis value minimum
+ * @param {Number} max X axis value maximum
+ * @param {Number} pxMin Pixel value minimum
+ * @param {Number} pxMax Pixel value maximum
+ */
+ function render(min, max, pxMin, pxMax) {
+
+ // don't render the navigator until we have data (#486)
+ if (isNaN(min)) {
+ return;
+ }
+
+ var strokeWidth,
+ scrollbarStrokeWidth = scrollbarOptions.barBorderWidth,
+ centerBarX;
+
+ outlineTop = top + halfOutline;
+ navigatorLeft = pick(
+ xAxis.left,
+ chart.plotLeft + scrollbarHeight // in case of scrollbar only, without navigator
+ );
+ navigatorWidth = pick(xAxis.len, chart.plotWidth - 2 * scrollbarHeight);
+ scrollerLeft = navigatorLeft - scrollbarHeight;
+ scrollerWidth = navigatorWidth + 2 * scrollbarHeight;
+
+ // Set the scroller x axis extremes to reflect the total. The navigator extremes
+ // should always be the extremes of the union of all series in the chart as
+ // well as the navigator series.
+ if (xAxis.getExtremes) {
+ var baseExtremes = chart.xAxis[0].getExtremes(), // the base
+ noBase = baseExtremes.dataMin === null,
+ navExtremes = xAxis.getExtremes(),
+ newMin = mathMin(baseExtremes.dataMin, navExtremes.dataMin),
+ newMax = mathMax(baseExtremes.dataMax, navExtremes.dataMax);
+
+ if (!noBase && (newMin !== navExtremes.min || newMax !== navExtremes.max)) {
+ xAxis.setExtremes(newMin, newMax, true, false);
+ }
+ }
+
+ // get the pixel position of the handles
+ pxMin = pick(pxMin, xAxis.translate(min));
+ pxMax = pick(pxMax, xAxis.translate(max));
+
+
+ // handles are allowed to cross
+ zoomedMin = pInt(mathMin(pxMin, pxMax));
+ zoomedMax = pInt(mathMax(pxMin, pxMax));
+ range = zoomedMax - zoomedMin;
+
+ // on first render, create all elements
+ if (!rendered) {
+
+ if (navigatorEnabled) {
+
+ leftShade = renderer.rect()
+ .attr({
+ fill: navigatorOptions.maskFill,
+ zIndex: 3
+ }).add();
+ rightShade = renderer.rect()
+ .attr({
+ fill: navigatorOptions.maskFill,
+ zIndex: 3
+ }).add();
+ outline = renderer.path()
+ .attr({
+ 'stroke-width': outlineWidth,
+ stroke: navigatorOptions.outlineColor,
+ zIndex: 3
+ })
+ .add();
+ }
+
+ if (scrollbarEnabled) {
+
+ // draw the scrollbar group
+ scrollbarGroup = renderer.g().add();
+
+ // the scrollbar track
+ strokeWidth = scrollbarOptions.trackBorderWidth;
+ scrollbarTrack = renderer.rect().attr({
+ y: -strokeWidth % 2 / 2,
+ fill: scrollbarOptions.trackBackgroundColor,
+ stroke: scrollbarOptions.trackBorderColor,
+ 'stroke-width': strokeWidth,
+ r: scrollbarOptions.trackBorderRadius || 0,
+ height: scrollbarHeight
+ }).add(scrollbarGroup);
+
+ // the scrollbar itself
+ scrollbar = renderer.rect()
+ .attr({
+ y: -scrollbarStrokeWidth % 2 / 2,
+ height: scrollbarHeight,
+ fill: scrollbarOptions.barBackgroundColor,
+ stroke: scrollbarOptions.barBorderColor,
+ 'stroke-width': scrollbarStrokeWidth,
+ r: barBorderRadius
+ })
+ .add(scrollbarGroup);
+
+ scrollbarRifles = renderer.path()
+ .attr({
+ stroke: scrollbarOptions.rifleColor,
+ 'stroke-width': 1
+ })
+ .add(scrollbarGroup);
+ }
+ }
+
+ // place elements
+ if (navigatorEnabled) {
+ leftShade.attr({
+ x: navigatorLeft,
+ y: top,
+ width: zoomedMin,
+ height: height
+ });
+ rightShade.attr({
+ x: navigatorLeft + zoomedMax,
+ y: top,
+ width: navigatorWidth - zoomedMax,
+ height: height
+ });
+ outline.attr({ d: [
+ M,
+ scrollerLeft, outlineTop, // left
+ L,
+ navigatorLeft + zoomedMin + halfOutline, outlineTop, // upper left of zoomed range
+ navigatorLeft + zoomedMin + halfOutline, outlineTop + outlineHeight - scrollbarHeight, // lower left of z.r.
+ M,
+ navigatorLeft + zoomedMax - halfOutline, outlineTop + outlineHeight - scrollbarHeight, // lower right of z.r.
+ L,
+ navigatorLeft + zoomedMax - halfOutline, outlineTop, // upper right of z.r.
+ scrollerLeft + scrollerWidth, outlineTop // right
+ ]});
+ // draw handles
+ drawHandle(zoomedMin + halfOutline, 0);
+ drawHandle(zoomedMax + halfOutline, 1);
+ }
+
+ // draw the scrollbar
+ if (scrollbarEnabled) {
+
+ // draw the buttons
+ drawScrollbarButton(0);
+ drawScrollbarButton(1);
+
+ scrollbarGroup.translate(scrollerLeft, mathRound(outlineTop + height));
+
+ scrollbarTrack.attr({
+ width: scrollerWidth
+ });
+
+ scrollbar.attr({
+ x: mathRound(scrollbarHeight + zoomedMin) + (scrollbarStrokeWidth % 2 / 2),
+ width: range - scrollbarStrokeWidth
+ });
+
+ centerBarX = scrollbarHeight + zoomedMin + range / 2 - 0.5;
+
+ scrollbarRifles.attr({ d: [
+ M,
+ centerBarX - 3, scrollbarHeight / 4,
+ L,
+ centerBarX - 3, 2 * scrollbarHeight / 3,
+ M,
+ centerBarX, scrollbarHeight / 4,
+ L,
+ centerBarX, 2 * scrollbarHeight / 3,
+ M,
+ centerBarX + 3, scrollbarHeight / 4,
+ L,
+ centerBarX + 3, 2 * scrollbarHeight / 3
+ ],
+ visibility: range > 12 ? VISIBLE : HIDDEN
+ });
+ }
+
+ rendered = true;
+ }
+
+ /**
+ * Event handler for the mouse down event.
+ */
+ function mouseDownHandler(e) {
+ e = chart.tracker.normalizeMouseEvent(e);
+ var chartX = e.chartX,
+ chartY = e.chartY,
+ handleSensitivity = hasTouch ? 10 : 7,
+ left,
+ isOnNavigator;
+
+ if (chartY > top && chartY < top + height + scrollbarHeight) { // we're vertically inside the navigator
+ isOnNavigator = !scrollbarEnabled || chartY < top + height;
+
+ // grab the left handle
+ if (isOnNavigator && math.abs(chartX - zoomedMin - navigatorLeft) < handleSensitivity) {
+ grabbedLeft = true;
+ otherHandlePos = zoomedMax;
+
+ // grab the right handle
+ } else if (isOnNavigator && math.abs(chartX - zoomedMax - navigatorLeft) < handleSensitivity) {
+ grabbedRight = true;
+ otherHandlePos = zoomedMin;
+
+ // grab the zoomed range
+ } else if (chartX > navigatorLeft + zoomedMin && chartX < navigatorLeft + zoomedMax) {
+ grabbedCenter = chartX;
+ defaultBodyCursor = bodyStyle.cursor;
+ bodyStyle.cursor = 'ew-resize';
+
+ dragOffset = chartX - zoomedMin;
+
+ // shift the range by clicking on shaded areas, scrollbar track or scrollbar buttons
+ } else if (chartX > scrollerLeft && chartX < scrollerLeft + scrollerWidth) {
+
+ if (isOnNavigator) { // center around the clicked point
+ left = chartX - navigatorLeft - range / 2;
+ } else { // click on scrollbar
+ if (chartX < navigatorLeft) { // click left scrollbar button
+ left = zoomedMin - mathMin(10, range);
+ } else if (chartX > scrollerLeft + scrollerWidth - scrollbarHeight) {
+ left = zoomedMin + mathMin(10, range);
+ } else {
+ // click on scrollbar track, shift the scrollbar by one range
+ left = chartX < navigatorLeft + zoomedMin ? // on the left
+ zoomedMin - range :
+ zoomedMax;
+ }
+ }
+ if (left < 0) {
+ left = 0;
+ } else if (left + range > navigatorWidth) {
+ left = navigatorWidth - range;
+ }
+ if (left !== zoomedMin) { // it has actually moved
+ chart.xAxis[0].setExtremes(
+ xAxis.translate(left, true),
+ xAxis.translate(left + range, true),
+ true,
+ false
+ );
+ }
+ }
+ }
+ if (e.preventDefault) { // tries to drag object when clicking on the shades
+ e.preventDefault();
+ }
+ }
+
+ /**
+ * Event handler for the mouse move event.
+ */
+ function mouseMoveHandler(e) {
+ e = chart.tracker.normalizeMouseEvent(e);
+ var chartX = e.chartX;
+
+ // validation for handle dragging
+ if (chartX < navigatorLeft) {
+ chartX = navigatorLeft;
+ } else if (chartX > scrollerLeft + scrollerWidth - scrollbarHeight) {
+ chartX = scrollerLeft + scrollerWidth - scrollbarHeight;
+ }
+
+ // drag left handle
+ if (grabbedLeft) {
+ hasDragged = true;
+ render(0, 0, chartX - navigatorLeft, otherHandlePos);
+
+ // drag right handle
+ } else if (grabbedRight) {
+ hasDragged = true;
+ render(0, 0, otherHandlePos, chartX - navigatorLeft);
+
+ // drag scrollbar or open area in navigator
+ } else if (grabbedCenter) {
+ hasDragged = true;
+ if (chartX < dragOffset) { // outside left
+ chartX = dragOffset;
+ } else if (chartX > navigatorWidth + dragOffset - range) { // outside right
+ chartX = navigatorWidth + dragOffset - range;
+ }
+
+ render(0, 0, chartX - dragOffset, chartX - dragOffset + range);
+ }
+ }
+
+ /**
+ * Event handler for the mouse up event.
+ */
+ function mouseUpHandler() {
+ if (hasDragged) {
+ chart.xAxis[0].setExtremes(
+ xAxis.translate(zoomedMin, true),
+ xAxis.translate(zoomedMax, true),
+ true,
+ false
+ );
+ }
+ grabbedLeft = grabbedRight = grabbedCenter = hasDragged = dragOffset = null;
+ bodyStyle.cursor = defaultBodyCursor;
+ }
+
+ function updatedDataHandler() {
+ var baseXAxis = baseSeries.xAxis,
+ baseExtremes = baseXAxis.getExtremes(),
+ baseMin = baseExtremes.min,
+ baseMax = baseExtremes.max,
+ baseDataMin = baseExtremes.dataMin,
+ baseDataMax = baseExtremes.dataMax,
+ range = baseMax - baseMin,
+ stickToMin,
+ stickToMax,
+ newMax,
+ newMin,
+ doRedraw,
+ navXData = navigatorSeries.xData,
+ hasSetExtremes = !!baseXAxis.setExtremes;
+
+ // detect whether to move the range
+ stickToMax = baseMax >= navXData[navXData.length - 1];
+ stickToMin = baseMin <= baseDataMin;
+
+ // set the navigator series data to the new data of the base series
+ if (!navigatorData) {
+ navigatorSeries.options.pointStart = baseSeries.xData[0];
+ navigatorSeries.setData(baseSeries.options.data, false);
+ doRedraw = true;
+ }
+
+ // if the zoomed range is already at the min, move it to the right as new data
+ // comes in
+ if (stickToMin) {
+ newMin = baseDataMin;
+ newMax = newMin + range;
+ }
+
+ // if the zoomed range is already at the max, move it to the right as new data
+ // comes in
+ if (stickToMax) {
+ newMax = baseDataMax;
+ if (!stickToMin) { // if stickToMin is true, the new min value is set above
+ newMin = mathMax(newMax - range, navigatorSeries.xData[0]);
+ }
+ }
+
+ // update the extremes
+ if (hasSetExtremes && (stickToMin || stickToMax)) {
+ baseXAxis.setExtremes(newMin, newMax, true, false);
+ // if it is not at any edge, just move the scroller window to reflect the new series data
+ } else {
+ if (doRedraw) {
+ chart.redraw(false);
+ }
+
+ render(
+ mathMax(baseMin, baseDataMin),
+ mathMin(baseMax, baseDataMax)
+ );
+ }
+ }
+
+ /**
+ * Set up the mouse and touch events for the navigator and scrollbar
+ */
+ function addEvents() {
+ addEvent(chart.container, MOUSEDOWN, mouseDownHandler);
+ addEvent(chart.container, MOUSEMOVE, mouseMoveHandler);
+ addEvent(document, MOUSEUP, mouseUpHandler);
+ }
+
+ /**
+ * Removes the event handlers attached previously with addEvents.
+ */
+ function removeEvents() {
+ removeEvent(chart.container, MOUSEDOWN, mouseDownHandler);
+ removeEvent(chart.container, MOUSEMOVE, mouseMoveHandler);
+ removeEvent(document, MOUSEUP, mouseUpHandler);
+ if (navigatorEnabled) {
+ removeEvent(baseSeries, 'updatedData', updatedDataHandler);
+ }
+ }
+
+ /**
+ * Initiate the Scroller object
+ */
+ function init() {
+ var xAxisIndex = chart.xAxis.length,
+ yAxisIndex = chart.yAxis.length,
+ baseChartSetSize = chart.setSize;
+
+ // make room below the chart
+ chart.extraBottomMargin = outlineHeight + navigatorOptions.margin;
+ // get the top offset
+ top = getAxisTop(chart.chartHeight);
+
+ if (navigatorEnabled) {
+ var baseOptions = baseSeries.options,
+ mergedNavSeriesOptions,
+ baseData = baseOptions.data,
+ navigatorSeriesOptions = navigatorOptions.series;
+
+ // remove it to prevent merging one by one
+ navigatorData = navigatorSeriesOptions.data;
+ baseOptions.data = navigatorSeriesOptions.data = null;
+
+
+ // an x axis is required for scrollbar also
+ xAxis = new chart.Axis(merge({
+ ordinal: baseSeries.xAxis.options.ordinal // inherit base xAxis' ordinal option
+ }, navigatorOptions.xAxis, {
+ isX: true,
+ type: 'datetime',
+ index: xAxisIndex,
+ height: height, // docs + width
+ top: top, // docs + left
+ offset: 0,
+ offsetLeft: scrollbarHeight, // docs
+ offsetRight: -scrollbarHeight, // docs
+ startOnTick: false,
+ endOnTick: false,
+ minPadding: 0,
+ maxPadding: 0,
+ zoomEnabled: false
+ }));
+
+ yAxis = new chart.Axis(merge(navigatorOptions.yAxis, {
+ alignTicks: false, // docs
+ height: height,
+ top: top,
+ offset: 0,
+ index: yAxisIndex,
+ zoomEnabled: false
+ }));
+
+ // dmerge the series options
+ mergedNavSeriesOptions = merge(baseSeries.options, navigatorSeriesOptions, {
+ threshold: null, // docs
+ clip: false, // docs
+ enableMouseTracking: false,
+ group: 'nav', // for columns
+ padXAxis: false,
+ xAxis: xAxisIndex,
+ yAxis: yAxisIndex,
+ name: 'Navigator',
+ showInLegend: false,
+ isInternal: true,
+ visible: true
+ });
+
+ // set the data back
+ baseOptions.data = baseData;
+ navigatorSeriesOptions.data = navigatorData;
+ mergedNavSeriesOptions.data = navigatorData || baseData;
+
+ // add the series
+ navigatorSeries = chart.initSeries(mergedNavSeriesOptions);
+
+ // respond to updated data in the base series
+ // todo: use similiar hook when base series is not yet initialized
+ addEvent(baseSeries, 'updatedData', updatedDataHandler);
+
+ // in case of scrollbar only, fake an x axis to get translation
+ } else {
+ xAxis = {
+ translate: function (value, reverse) {
+ var ext = baseSeries.xAxis.getExtremes(),
+ scrollTrackWidth = chart.plotWidth - 2 * scrollbarHeight,
+ dataMin = ext.dataMin,
+ valueRange = ext.dataMax - dataMin;
+
+ return reverse ?
+ // from pixel to value
+ (value * valueRange / scrollTrackWidth) + dataMin :
+ // from value to pixel
+ scrollTrackWidth * (value - dataMin) / valueRange;
+ }
+ };
+ }
+
+
+ // Override the chart.setSize method to adjust the xAxis and yAxis top option as well.
+ // This needs to be done prior to chart.resize
+ chart.setSize = function (width, height, animation) {
+ xAxis.options.top = yAxis.options.top = top = getAxisTop(height);
+ baseChartSetSize.call(chart, width, height, animation);
+ };
+
+ addEvents();
+ }
+
+ /**
+ * Destroys allocated elements.
+ */
+ function destroy() {
+ // Disconnect events added in addEvents
+ removeEvents();
+
+ // Destroy local variables
+ each([xAxis, yAxis, leftShade, rightShade, outline, scrollbarTrack, scrollbar, scrollbarRifles, scrollbarGroup], function (obj) {
+ if (obj && obj.destroy) {
+ obj.destroy();
+ }
+ });
+ xAxis = yAxis = leftShade = rightShade = outline = scrollbarTrack = scrollbar = scrollbarRifles = scrollbarGroup = null;
+
+ // Destroy elements in collection
+ each([scrollbarButtons, handles, elementsToDestroy], function (coll) {
+ destroyObjectProperties(coll);
+ });
+ }
+
+ // Run scroller
+ init();
+
+ // Expose
+ return {
+ render: render,
+ destroy: destroy
+ };
+
+};
+
+/* ****************************************************************************
+ * End Scroller code *
+ *****************************************************************************/
+
+/* ****************************************************************************
+ * Start Range Selector code *
+ *****************************************************************************/
+extend(defaultOptions, {
+ rangeSelector: {
+ // enabled: true,
+ // buttons: {Object}
+ // buttonSpacing: 0,
+ buttonTheme: {
+ width: 28,
+ height: 16,
+ padding: 1,
+ r: 0,
+ zIndex: 10 // #484
+ // states: {
+ // hover: {},
+ // select: {}
+ // }
+ }
+ // inputDateFormat: '%b %e, %Y',
+ // inputEditDateFormat: '%Y-%m-%d',
+ // inputEnabled: true,
+ // inputStyle: {}
+ // labelStyle: {}
+ // selected: undefined
+ // todo:
+ // - button styles for normal, hover and select state
+ // - CSS text styles
+ // - styles for the inputs and labels
+ }
+});
+defaultOptions.lang = merge(defaultOptions.lang, {
+ rangeSelectorZoom: 'Zoom',
+ rangeSelectorFrom: 'From:',
+ rangeSelectorTo: 'To:'
+});
+
+/**
+ * The object constructor for the range selector
+ * @param {Object} chart
+ */
+Highcharts.RangeSelector = function (chart) {
+ var renderer = chart.renderer,
+ rendered,
+ container = chart.container,
+ lang = defaultOptions.lang,
+ div,
+ leftBox,
+ rightBox,
+ boxSpanElements = {},
+ divAbsolute,
+ divRelative,
+ selected,
+ zoomText,
+ buttons = [],
+ buttonOptions,
+ options,
+ defaultButtons = [{
+ type: 'month',
+ count: 1,
+ text: '1m'
+ }, {
+ type: 'month',
+ count: 3,
+ text: '3m'
+ }, {
+ type: 'month',
+ count: 6,
+ text: '6m'
+ }, {
+ type: 'ytd',
+ text: 'YTD'
+ }, {
+ type: 'year',
+ count: 1,
+ text: '1y'
+ }, {
+ type: 'all',
+ text: 'All'
+ }];
+ chart.resetZoomEnabled = false;
+
+ /**
+ * The method to run when one of the buttons in the range selectors is clicked
+ * @param {Number} i The index of the button
+ * @param {Object} rangeOptions
+ * @param {Boolean} redraw
+ */
+ function clickButton(i, rangeOptions, redraw) {
+
+ var baseAxis = chart.xAxis[0],
+ extremes = baseAxis && baseAxis.getExtremes(),
+ now,
+ dataMin = extremes && extremes.dataMin,
+ dataMax = extremes && extremes.dataMax,
+ newMin,
+ newMax = baseAxis && mathMin(extremes.max, dataMax),
+ date = new Date(newMax),
+ type = rangeOptions.type,
+ count = rangeOptions.count,
+ baseXAxisOptions,
+ range,
+ rangeMin,
+ year,
+ // these time intervals have a fixed number of milliseconds, as opposed
+ // to month, ytd and year
+ fixedTimes = {
+ millisecond: 1,
+ second: 1000,
+ minute: 60 * 1000,
+ hour: 3600 * 1000,
+ day: 24 * 3600 * 1000,
+ week: 7 * 24 * 3600 * 1000
+ };
+
+ if (dataMin === null || dataMax === null || // chart has no data, base series is removed
+ i === selected) { // same button is clicked twice
+ return;
+ }
+
+ if (fixedTimes[type]) {
+ range = fixedTimes[type] * count;
+ newMin = mathMax(newMax - range, dataMin);
+ } else if (type === 'month') {
+ date.setMonth(date.getMonth() - count);
+ newMin = mathMax(date.getTime(), dataMin);
+ range = 30 * 24 * 3600 * 1000 * count;
+ } else if (type === 'ytd') {
+ date = new Date(0);
+ now = new Date();
+ year = now.getFullYear();
+ date.setFullYear(year);
+
+ // workaround for IE6 bug, which sets year to next year instead of current
+ if (String(year) !== dateFormat('%Y', date)) {
+ date.setFullYear(year - 1);
+ }
+
+ newMin = rangeMin = mathMax(dataMin || 0, date.getTime());
+ now = now.getTime();
+ newMax = mathMin(dataMax || now, now);
+ } else if (type === 'year') {
+ date.setFullYear(date.getFullYear() - count);
+ newMin = mathMax(dataMin, date.getTime());
+ range = 365 * 24 * 3600 * 1000 * count;
+ } else if (type === 'all' && baseAxis) {
+ newMin = dataMin;
+ newMax = dataMax;
+ }
+
+ // mark the button pressed
+ if (buttons[i]) {
+ buttons[i].setState(2);
+ }
+
+ // update the chart
+ if (!baseAxis) { // axis not yet instanciated
+ baseXAxisOptions = chart.options.xAxis;
+ baseXAxisOptions[0] = merge(
+ baseXAxisOptions[0],
+ {
+ range: range,
+ min: rangeMin
+ }
+ );
+ selected = i;
+
+ } else { // existing axis object; after render time
+ setTimeout(function () { // make sure the visual state is set before the heavy process begins
+ baseAxis.setExtremes(
+ newMin,
+ newMax,
+ pick(redraw, 1),
+ 0
+ );
+ selected = i;
+ }, 1);
+ }
+
+ }
+
+ /**
+ * The handler connected to container that handles mousedown.
+ */
+ function mouseDownHandler() {
+ if (leftBox) {
+ leftBox.blur();
+ }
+ if (rightBox) {
+ rightBox.blur();
+ }
+ }
+
+ /**
+ * Initialize the range selector
+ */
+ function init() {
+ chart.extraTopMargin = 25;
+ options = chart.options.rangeSelector;
+ buttonOptions = options.buttons || defaultButtons;
+
+
+ var selectedOption = options.selected;
+
+ addEvent(container, MOUSEDOWN, mouseDownHandler);
+
+ // zoomed range based on a pre-selected button index
+ if (selectedOption !== UNDEFINED && buttonOptions[selectedOption]) {
+ clickButton(selectedOption, buttonOptions[selectedOption], false);
+ }
+
+ // normalize the pressed button whenever a new range is selected
+ addEvent(chart, 'load', function () {
+ addEvent(chart.xAxis[0], 'afterSetExtremes', function () {
+ if (buttons[selected]) {
+ buttons[selected].setState(0);
+ }
+ selected = null;
+ });
+ });
+ }
+
+
+ /**
+ * Set the internal and displayed value of a HTML input for the dates
+ * @param {Object} input
+ * @param {Number} time
+ */
+ function setInputValue(input, time) {
+ var format = input.hasFocus ? options.inputEditDateFormat || '%Y-%m-%d' : options.inputDateFormat || '%b %e, %Y';
+ if (time) {
+ input.HCTime = time;
+ }
+ input.value = dateFormat(format, input.HCTime);
+ }
+
+ /**
+ * Draw either the 'from' or the 'to' HTML input box of the range selector
+ * @param {Object} name
+ */
+ function drawInput(name) {
+ var isMin = name === 'min',
+ input;
+
+ // create the text label
+ boxSpanElements[name] = createElement('span', {
+ innerHTML: lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo']
+ }, options.labelStyle, div);
+
+ // create the input element
+ input = createElement('input', {
+ name: name,
+ className: PREFIX + 'range-selector',
+ type: 'text'
+ }, extend({
+ width: '80px',
+ height: '16px',
+ border: '1px solid silver',
+ marginLeft: '5px',
+ marginRight: isMin ? '5px' : '0',
+ textAlign: 'center'
+ }, options.inputStyle), div);
+
+
+ input.onfocus = input.onblur = function (e) {
+ e = e || window.event;
+ input.hasFocus = e.type === 'focus';
+ setInputValue(input);
+ };
+
+ // handle changes in the input boxes
+ input.onchange = function () {
+ var inputValue = input.value,
+ value = Date.parse(inputValue),
+ extremes = chart.xAxis[0].getExtremes();
+
+ // if the value isn't parsed directly to a value by the browser's Date.parse method,
+ // like YYYY-MM-DD in IE, try parsing it a different way
+ if (isNaN(value)) {
+ value = inputValue.split('-');
+ value = Date.UTC(pInt(value[0]), pInt(value[1]) - 1, pInt(value[2]));
+ }
+
+ if (!isNaN(value) &&
+ ((isMin && (value >= extremes.dataMin && value <= rightBox.HCTime)) ||
+ (!isMin && (value <= extremes.dataMax && value >= leftBox.HCTime)))
+ ) {
+ chart.xAxis[0].setExtremes(
+ isMin ? value : extremes.min,
+ isMin ? extremes.max : value
+ );
+ }
+ };
+
+ return input;
+ }
+
+ /**
+ * Render the range selector including the buttons and the inputs. The first time render
+ * is called, the elements are created and positioned. On subsequent calls, they are
+ * moved and updated.
+ * @param {Number} min X axis minimum
+ * @param {Number} max X axis maximum
+ */
+ function render(min, max) {
+ var chartStyle = chart.options.chart.style,
+ buttonTheme = options.buttonTheme,
+ inputEnabled = options.inputEnabled !== false,
+ states = buttonTheme && buttonTheme.states,
+ plotLeft = chart.plotLeft,
+ buttonLeft;
+
+ // create the elements
+ if (!rendered) {
+ zoomText = renderer.text(lang.rangeSelectorZoom, plotLeft, chart.plotTop - 10)
+ .css(options.labelStyle)
+ .add();
+
+ // button starting position
+ buttonLeft = plotLeft + zoomText.getBBox().width + 5;
+
+ each(buttonOptions, function (rangeOptions, i) {
+ buttons[i] = renderer.button(
+ rangeOptions.text,
+ buttonLeft,
+ chart.plotTop - 25,
+ function () {
+ clickButton(i, rangeOptions);
+ this.isActive = true;
+ },
+ buttonTheme,
+ states && states.hover,
+ states && states.select
+ )
+ .css({
+ textAlign: 'center'
+ })
+ .add();
+
+ // increase button position for the next button
+ buttonLeft += buttons[i].width + (options.buttonSpacing || 0);
+
+ if (selected === i) {
+ buttons[i].setState(2);
+ }
+
+ });
+
+ // first create a wrapper outside the container in order to make
+ // the inputs work and make export correct
+ if (inputEnabled) {
+ divRelative = div = createElement('div', null, {
+ position: 'relative',
+ height: 0,
+ fontFamily: chartStyle.fontFamily,
+ fontSize: chartStyle.fontSize,
+ zIndex: 1 // above container
+ });
+
+ container.parentNode.insertBefore(div, container);
+
+ // create an absolutely positionied div to keep the inputs
+ divAbsolute = div = createElement('div', null, extend({
+ position: 'absolute',
+ top: (chart.plotTop - 25) + 'px',
+ right: (chart.chartWidth - chart.plotLeft - chart.plotWidth) + 'px'
+ }, options.inputBoxStyle), div);
+
+ leftBox = drawInput('min');
+
+ rightBox = drawInput('max');
+ }
+ }
+
+ if (inputEnabled) {
+ setInputValue(leftBox, min);
+ setInputValue(rightBox, max);
+ }
+
+
+ rendered = true;
+ }
+
+ /**
+ * Destroys allocated elements.
+ */
+ function destroy() {
+ removeEvent(container, MOUSEDOWN, mouseDownHandler);
+
+ // Destroy elements in collections
+ each([buttons], function (coll) {
+ destroyObjectProperties(coll);
+ });
+
+ // Destroy zoomText
+ if (zoomText) {
+ zoomText = zoomText.destroy();
+ }
+
+ // Clear input element events
+ if (leftBox) {
+ leftBox.onfocus = leftBox.onblur = leftBox.onchange = null;
+ }
+ if (rightBox) {
+ rightBox.onfocus = rightBox.onblur = rightBox.onchange = null;
+ }
+
+ // Discard divs and spans
+ each([leftBox, rightBox, boxSpanElements.min, boxSpanElements.max, divAbsolute, divRelative], function (item) {
+ discardElement(item);
+ });
+ // Null the references
+ leftBox = rightBox = boxSpanElements = div = divAbsolute = divRelative = null;
+
+ }
+
+ // Run RangeSelector
+ init();
+
+ // Expose
+ return {
+ render: render,
+ destroy: destroy
+ };
+};
+
+/* ****************************************************************************
+ * End Range Selector code *
+ *****************************************************************************/
+
+
+
+Chart.prototype.callbacks.push(function (chart) {
+ var extremes,
+ scroller = chart.scroller,
+ rangeSelector = chart.rangeSelector;
+
+ function renderScroller() {
+ extremes = chart.xAxis[0].getExtremes();
+ scroller.render(
+ mathMax(extremes.min, extremes.dataMin),
+ mathMin(extremes.max, extremes.dataMax)
+ );
+ }
+
+ function renderRangeSelector() {
+ extremes = chart.xAxis[0].getExtremes();
+ rangeSelector.render(extremes.min, extremes.max);
+ }
+
+ function afterSetExtremesHandlerScroller(e) {
+ scroller.render(e.min, e.max);
+ }
+
+ function afterSetExtremesHandlerRangeSelector(e) {
+ rangeSelector.render(e.min, e.max);
+ }
+
+ function destroyEvents() {
+ if (scroller) {
+ removeEvent(chart, 'resize', renderScroller);
+ removeEvent(chart.xAxis[0], 'afterSetExtremes', afterSetExtremesHandlerScroller);
+ }
+ if (rangeSelector) {
+ removeEvent(chart, 'resize', renderRangeSelector);
+ removeEvent(chart.xAxis[0], 'afterSetExtremes', afterSetExtremesHandlerRangeSelector);
+ }
+ }
+
+ // initiate the scroller
+ if (scroller) {
+ // redraw the scroller on setExtremes
+ addEvent(chart.xAxis[0], 'afterSetExtremes', afterSetExtremesHandlerScroller);
+
+ // redraw the scroller chart resize
+ addEvent(chart, 'resize', renderScroller);
+
+ // do it now
+ renderScroller();
+ }
+ if (rangeSelector) {
+ // redraw the scroller on setExtremes
+ addEvent(chart.xAxis[0], 'afterSetExtremes', afterSetExtremesHandlerRangeSelector);
+
+ // redraw the scroller chart resize
+ addEvent(chart, 'resize', renderRangeSelector);
+
+ // do it now
+ renderRangeSelector();
+ }
+
+ // Remove resize/afterSetExtremes at chart destroy
+ addEvent(chart, 'destroy', destroyEvents);
+});
+/**
+ * A wrapper for Chart with all the default values for a Stock chart
+ */
+Highcharts.StockChart = function (options, callback) {
+ var seriesOptions = options.series, // to increase performance, don't merge the data
+ opposite,
+ lineOptions = {
+
+ marker: {
+ enabled: false,
+ states: {
+ hover: {
+ enabled: true,
+ radius: 5
+ }
+ }
+ },
+ // gapSize: 0, // docs
+ shadow: false,
+ states: {
+ hover: {
+ lineWidth: 2
+ }
+ },
+ dataGrouping: {
+ enabled: true
+ }
+ };
+
+ // apply X axis options to both single and multi y axes
+ options.xAxis = map(splat(options.xAxis || {}), function (xAxisOptions) {
+ return merge({ // defaults
+ minPadding: 0,
+ maxPadding: 0,
+ ordinal: true,
+ title: {
+ text: null
+ },
+ showLastLabel: true
+ }, xAxisOptions, // user options
+ { // forced options
+ type: 'datetime',
+ categories: null
+ });
+ });
+
+ // apply Y axis options to both single and multi y axes
+ options.yAxis = map(splat(options.yAxis || {}), function (yAxisOptions) {
+ opposite = yAxisOptions.opposite;
+ return merge({ // defaults
+ labels: {
+ align: opposite ? 'right' : 'left',
+ x: opposite ? -2 : 2,
+ y: -2
+ },
+ showLastLabel: false,
+ title: {
+ text: null
+ }
+ }, yAxisOptions // user options
+ );
+ });
+
+ options.series = null;
+
+ options = merge({
+ chart: {
+ panning: true
+ },
+ navigator: {
+ enabled: true
+ },
+ scrollbar: {
+ enabled: true
+ },
+ rangeSelector: {
+ enabled: true
+ },
+ title: {
+ text: null
+ },
+ tooltip: {
+ shared: true,
+ crosshairs: true
+ },
+ legend: {
+ enabled: false
+ },
+
+ plotOptions: {
+ line: lineOptions,
+ spline: lineOptions,
+ area: lineOptions,
+ areaspline: lineOptions,
+ column: {
+ shadow: false,
+ borderWidth: 0,
+ dataGrouping: {
+ enabled: true
+ }
+ }
+ }
+
+ },
+ options, // user's options
+
+ { // forced options
+ chart: {
+ inverted: false
+ }
+ });
+
+ options.series = seriesOptions;
+
+
+ return new Chart(options, callback);
+};
+
+
+/* ****************************************************************************
+ * Start value compare logic *
+ *****************************************************************************/
+
+var seriesInit = seriesProto.init,
+ seriesProcessData = seriesProto.processData,
+ pointTooltipFormatter = Point.prototype.tooltipFormatter;
+
+/**
+ * Extend series.init by adding a method to modify the y value used for plotting
+ * on the y axis. This method is called both from the axis when finding dataMin
+ * and dataMax, and from the series.translate method.
+ */
+seriesProto.init = function () {
+
+ // call base method
+ seriesInit.apply(this, arguments);
+
+ // local variables
+ var series = this,
+ compare = series.options.compare;
+
+ if (compare) {
+ series.modifyValue = function (value, point) {
+ var compareValue = this.compareValue;
+
+ // get the modified value
+ value = compare === 'value' ?
+ value - compareValue : // compare value
+ value = 100 * (value / compareValue) - 100; // compare percent
+
+ // record for tooltip etc.
+ if (point) {
+ point.change = value;
+ }
+
+ return value;
+ };
+ }
+};
+
+/**
+ * Extend series.processData by finding the first y value in the plot area,
+ * used for comparing the following values
+ */
+seriesProto.processData = function () {
+ var series = this;
+
+ // call base method
+ seriesProcessData.apply(this, arguments);
+
+ if (series.options.compare) {
+
+ // local variables
+ var i = 0,
+ processedXData = series.processedXData,
+ processedYData = series.processedYData,
+ length = processedYData.length,
+ min = series.xAxis.getExtremes().min;
+
+ // find the first value for comparison
+ for (; i < length; i++) {
+ if (typeof processedYData[i] === NUMBER && processedXData[i] >= min) {
+ series.compareValue = processedYData[i];
+ break;
+ }
+ }
+ }
+};
+
+/**
+ * Extend the tooltip formatter by adding support for the point.change variable
+ * as well as the changeDecimals option
+ */
+Point.prototype.tooltipFormatter = function (pointFormat) {
+ var point = this;
+
+ pointFormat = pointFormat.replace(
+ '{point.change}',
+ (point.change > 0 ? '+' : '') + numberFormat(point.change, point.series.tooltipOptions.changeDecimals || 2)
+ );
+
+ return pointTooltipFormatter.apply(this, [pointFormat]);
+};
+
+/* ****************************************************************************
+ * End value compare logic *
+ *****************************************************************************/
+
+/* ****************************************************************************
+ * Start ordinal axis logic *
+ *****************************************************************************/
+
+(function () {
+ var baseInit = seriesProto.init,
+ baseGetSegments = seriesProto.getSegments;
+
+ seriesProto.init = function () {
+ var series = this,
+ chart,
+ xAxis;
+
+ // call base method
+ baseInit.apply(series, arguments);
+
+ // chart and xAxis are set in base init
+ chart = series.chart;
+ xAxis = series.xAxis;
+
+ // Destroy the extended ordinal index on updated data
+ if (xAxis && xAxis.options.ordinal) {
+ addEvent(series, 'updatedData', function () {
+ delete xAxis.ordinalIndex;
+ });
+ }
+
+ /**
+ * Extend the ordinal axis object. If we rewrite the axis object to a prototype model,
+ * we should add these properties to the prototype instead.
+ */
+ if (xAxis && xAxis.options.ordinal && !xAxis.hasOrdinalExtension) {
+
+ xAxis.hasOrdinalExtension = true;
+
+ /**
+ * Calculate the ordinal positions before tick positions are calculated.
+ * TODO: When we rewrite Axis to use a prototype model, this should be implemented
+ * as a method extension to avoid overhead in the core.
+ */
+ xAxis.beforeSetTickPositions = function () {
+ var axis = this,
+ len,
+ ordinalPositions = [],
+ useOrdinal = false,
+ dist,
+ extremes = axis.getExtremes(),
+ min = extremes.min,
+ max = extremes.max,
+ minIndex,
+ maxIndex,
+ slope,
+ i;
+
+ // apply the ordinal logic
+ if (axis.options.ordinal) {
+
+ each(axis.series, function (series, i) {
+
+ if (series.visible !== false) {
+
+ // concatenate the processed X data into the existing positions, or the empty array
+ ordinalPositions = ordinalPositions.concat(series.processedXData);
+ len = ordinalPositions.length;
+
+ // if we're dealing with more than one series, remove duplicates
+ if (i && len) {
+
+ ordinalPositions.sort(function (a, b) {
+ return a - b; // without a custom function it is sorted as strings
+ });
+
+ i = len - 1;
+ while (i--) {
+ if (ordinalPositions[i] === ordinalPositions[i + 1]) {
+ ordinalPositions.splice(i, 1);
+ }
+ }
+ }
+ }
+
+ });
+
+ // cache the length
+ len = ordinalPositions.length;
+
+ // Check if we really need the overhead of mapping axis data against the ordinal positions.
+ // If the series consist of evenly spaced data any way, we don't need any ordinal logic.
+ if (len > 2) { // two points have equal distance by default
+ dist = ordinalPositions[1] - ordinalPositions[0];
+ i = len - 1;
+ while (i-- && !useOrdinal) {
+ if (ordinalPositions[i + 1] - ordinalPositions[i] !== dist) {
+ useOrdinal = true;
+ }
+ }
+ }
+
+ // Record the slope and offset to compute the linear values from the array index.
+ // Since the ordinal positions may exceed the current range, get the start and
+ // end positions within it (#719, #665b)
+ if (useOrdinal) {
+
+ // Register
+ axis.ordinalPositions = ordinalPositions;
+
+ // This relies on the ordinalPositions being set
+ minIndex = xAxis.val2lin(min, true);
+ maxIndex = xAxis.val2lin(max, true);
+
+ // Set the slope and offset of the values compared to the indices in the ordinal positions
+ axis.ordinalSlope = slope = (max - min) / (maxIndex - minIndex);
+ axis.ordinalOffset = min - (minIndex * slope);
+
+ } else {
+ axis.ordinalPositions = axis.ordinalSlope = axis.ordinalOffset = UNDEFINED;
+ }
+ }
+ };
+
+ /**
+ * Translate from a linear axis value to the corresponding ordinal axis position. If there
+ * are no gaps in the ordinal axis this will be the same. The translated value is the value
+ * that the point would have if the axis were linear, using the same min and max.
+ *
+ * @param Number val The axis value
+ * @param Boolean toIndex Whether to return the index in the ordinalPositions or the new value
+ */
+ xAxis.val2lin = function (val, toIndex) {
+
+ var axis = this,
+ ordinalPositions = axis.ordinalPositions;
+
+ if (!ordinalPositions) {
+ return val;
+
+ } else {
+
+ var ordinalLength = ordinalPositions.length,
+ i,
+ distance,
+ ordinalIndex;
+
+ // first look for an exact match in the ordinalpositions array
+ i = ordinalLength;
+ while (i--) {
+ if (ordinalPositions[i] === val) {
+ ordinalIndex = i;
+ break;
+ }
+ }
+
+ // if that failed, find the intermediate position between the two nearest values
+ i = ordinalLength - 1;
+ while (i--) {
+ if (val > ordinalPositions[i] || i === 0) { // interpolate
+ distance = (val - ordinalPositions[i]) / (ordinalPositions[i + 1] - ordinalPositions[i]); // something between 0 and 1
+ ordinalIndex = i + distance;
+ break;
+ }
+ }
+ return toIndex ?
+ ordinalIndex :
+ axis.ordinalSlope * (ordinalIndex || 0) + axis.ordinalOffset;
+ }
+ };
+
+ /**
+ * Translate from linear (internal) to axis value
+ *
+ * @param Number val The linear abstracted value
+ * @param Boolean fromIndex Translate from an index in the ordinal positions rather than a value
+ */
+ xAxis.lin2val = function (val, fromIndex) {
+ var axis = this,
+ ordinalPositions = axis.ordinalPositions;
+
+ if (!ordinalPositions) { // the visible range contains only equally spaced values
+ return val;
+
+ } else {
+
+ var ordinalSlope = axis.ordinalSlope,
+ ordinalOffset = axis.ordinalOffset,
+ i = ordinalPositions.length - 1,
+ linearEquivalentLeft,
+ linearEquivalentRight,
+ distance;
+
+
+ // Handle the case where we translate from the index directly, used only
+ // when panning an ordinal axis
+ if (fromIndex) {
+
+ if (val < 0) { // out of range, in effect panning to the left
+ val = ordinalPositions[0];
+ } else if (val > i) { // out of range, panning to the right
+ val = ordinalPositions[i];
+ } else { // split it up
+ i = mathFloor(val);
+ distance = val - i; // the decimal
+ }
+
+ // Loop down along the ordinal positions. When the linear equivalent of i matches
+ // an ordinal position, interpolate between the left and right values.
+ } else {
+ while (i--) {
+ linearEquivalentLeft = (ordinalSlope * i) + ordinalOffset;
+ if (val >= linearEquivalentLeft) {
+ linearEquivalentRight = (ordinalSlope * (i + 1)) + ordinalOffset;
+ distance = (val - linearEquivalentLeft) / (linearEquivalentRight - linearEquivalentLeft); // something between 0 and 1
+ break;
+ }
+ }
+ }
+
+ // If the index is within the range of the ordinal positions, return the associated
+ // or interpolated value. If not, just return the value
+ return distance !== UNDEFINED && ordinalPositions[i] !== UNDEFINED ?
+ ordinalPositions[i] + (distance ? distance * (ordinalPositions[i + 1] - ordinalPositions[i]) : 0) :
+ val;
+ }
+ };
+
+ /**
+ * Get the ordinal positions for the entire data set. This is necessary in chart panning
+ * because we need to find out what points or data groups are available outside the
+ * visible range. When a panning operation starts, if an index for the given grouping
+ * does not exists, it is created and cached. This index is deleted on updated data, so
+ * it will be regenerated the next time a panning operation starts.
+ */
+ xAxis.getExtendedPositions = function () {
+ var grouping = xAxis.series[0].currentDataGrouping,
+ ordinalIndex = xAxis.ordinalIndex,
+ key = grouping ? grouping.count + grouping.unitName : 'raw',
+ extremes = xAxis.getExtremes(),
+ fakeAxis,
+ fakeSeries;
+
+ // If this is the first time, or the ordinal index is deleted by updatedData,
+ // create it.
+ if (!ordinalIndex) {
+ ordinalIndex = xAxis.ordinalIndex = {};
+ }
+
+
+ if (!ordinalIndex[key]) {
+
+ // Create a fake axis object where the extended ordinal positions are emulated
+ fakeAxis = {
+ series: [],
+ getExtremes: function () {
+ return {
+ min: extremes.dataMin,
+ max: extremes.dataMax
+ };
+ },
+ options: {
+ ordinal: true
+ }
+ };
+
+ // Add the fake series to hold the full data, then apply processData to it
+ each(xAxis.series, function (series) {
+ fakeSeries = {
+ xAxis: fakeAxis,
+ xData: series.xData,
+ chart: chart
+ };
+ fakeSeries.options = {
+ dataGrouping : grouping ? {
+ enabled: true,
+ forced: true,
+ approximation: 'open', // doesn't matter which, use the fastest
+ units: [[grouping.unitName, [grouping.count]]]
+ } : {
+ enabled: false
+ }
+ };
+ series.processData.apply(fakeSeries);
+
+ fakeAxis.series.push(fakeSeries);
+ });
+
+ // Run beforeSetTickPositions to compute the ordinalPositions
+ xAxis.beforeSetTickPositions.apply(fakeAxis);
+
+ // Cache it
+ ordinalIndex[key] = fakeAxis.ordinalPositions;
+ }
+ return ordinalIndex[key];
+ };
+
+ /**
+ * Find the factor to estimate how wide the plot area would have been if ordinal
+ * gaps were included. This value is used to compute an imagined plot width in order
+ * to establish the data grouping interval.
+ *
+ * A real world case is the intraday-candlestick
+ * example. Without this logic, it would show the correct data grouping when viewing
+ * a range within each day, but once moving the range to include the gap between two
+ * days, the interval would include the cut-away night hours and the data grouping
+ * would be wrong. So the below method tries to compensate by identifying the most
+ * common point interval, in this case days.
+ *
+ * An opposite case is presented in issue #718. We have a long array of daily data,
+ * then one point is appended one hour after the last point. We expect the data grouping
+ * not to change.
+ *
+ * In the future, if we find cases where this estimation doesn't work optimally, we
+ * might need to add a second pass to the data grouping logic, where we do another run
+ * with a greater interval if the number of data groups is more than a certain fraction
+ * of the desired group count.
+ */
+ xAxis.getGroupIntervalFactor = function (xMin, xMax, processedXData) {
+ var i = 0,
+ len = processedXData.length,
+ distances = [],
+ median;
+
+ // Register all the distances in an array
+ for (; i < len - 1; i++) {
+ distances[i] = processedXData[i + 1] - processedXData[i];
+ }
+
+ // Sort them and find the median
+ distances.sort(function (a, b) {
+ return a - b;
+ });
+ median = distances[mathFloor(len / 2)];
+
+ // Return the factor needed for data grouping
+ return (len * median) / (xMax - xMin);
+ };
+
+ /**
+ * Make the tick intervals closer because the ordinal gaps make the ticks spread out or cluster
+ */
+ xAxis.postProcessTickInterval = function (tickInterval) {
+ var ordinalSlope = this.ordinalSlope;
+
+ return ordinalSlope ?
+ tickInterval / (ordinalSlope / xAxis.closestPointRange) :
+ tickInterval;
+ };
+
+ /**
+ * In an ordinal axis, there might be areas with dense consentrations of points, then large
+ * gaps between some. Creating equally distributed ticks over this entire range
+ * may lead to a huge number of ticks that will later be removed. So instead, break the
+ * positions up in segments, find the tick positions for each segment then concatenize them.
+ * This method is used from both data grouping logic and X axis tick position logic.
+ */
+ xAxis.getNonLinearTimeTicks = function (normalizedInterval, min, max, startOfWeek, positions, closestDistance, findHigherRanks) {
+
+ var start = 0,
+ end = 0,
+ segmentPositions,
+ higherRanks = {},
+ hasCrossedHigherRank,
+ info,
+ posLength,
+ outsideMax,
+ groupPositions = [];
+
+ // The positions are not always defined, for example for ordinal positions when data
+ // has regular interval
+ if (!positions || min === UNDEFINED) {
+ return getTimeTicks(normalizedInterval, min, max, startOfWeek);
+ }
+
+ // Analyze the positions array to split it into segments on gaps larger than 5 times
+ // the closest distance. The closest distance is already found at this point, so
+ // we reuse that instead of computing it again.
+ posLength = positions.length;
+ for (; end < posLength; end++) {
+
+ outsideMax = end && positions[end - 1] > max;
+
+ if (positions[end] < min) { // Set the last position before min
+ start = end;
+
+ } else if (end === posLength - 1 || positions[end + 1] - positions[end] > closestDistance * 5 || outsideMax) {
+
+ // For each segment, calculate the tick positions from the getTimeTicks utility
+ // function. The interval will be the same regardless of how long the segment is.
+ segmentPositions = getTimeTicks(normalizedInterval, positions[start], positions[end], startOfWeek);
+
+ groupPositions = groupPositions.concat(segmentPositions);
+
+ // Set start of next segment
+ start = end + 1;
+ }
+
+ if (outsideMax) {
+ break;
+ }
+ }
+
+ // Get the grouping info from the last of the segments. The info is the same for
+ // all segments.
+ info = segmentPositions.info;
+
+ // Optionally identify ticks with higher rank, for example when the ticks
+ // have crossed midnight.
+ if (findHigherRanks && info.unitRange <= timeUnits[HOUR]) {
+ end = groupPositions.length - 1;
+
+ // Compare points two by two
+ for (start = 1; start < end; start++) {
+ if (new Date(groupPositions[start])[getDate]() !== new Date(groupPositions[start - 1])[getDate]()) {
+ higherRanks[groupPositions[start]] = DAY;
+ hasCrossedHigherRank = true;
+ }
+ }
+
+ // If the complete array has crossed midnight, we want to mark the first
+ // positions also as higher rank
+ if (hasCrossedHigherRank) {
+ higherRanks[groupPositions[0]] = DAY;
+ }
+ info.higherRanks = higherRanks;
+ }
+
+ // Save the info
+ groupPositions.info = info;
+
+
+ // Return it
+ return groupPositions;
+
+ };
+
+ /**
+ * Post process tick positions. The tickPositions array is altered. Don't show ticks
+ * within a gap in the ordinal axis, where the space between
+ * two points is greater than a portion of the tick pixel interval
+ */
+ addEvent(xAxis, 'afterSetTickPositions', function (e) {
+
+ var options = xAxis.options,
+ tickPixelIntervalOption = options.tickPixelInterval,
+ tickPositions = e.tickPositions;
+
+ if (xAxis.ordinalPositions && defined(tickPixelIntervalOption)) { // check for squashed ticks
+ var i = tickPositions.length,
+ itemToRemove,
+ translated,
+ lastTranslated,
+ tickInfo = tickPositions.info,
+ higherRanks = tickInfo ? tickInfo.higherRanks : [];
+
+ while (i--) {
+ translated = xAxis.translate(tickPositions[i]);
+
+ // Remove ticks that are closer than 0.6 times the pixel interval from the one to the right
+ if (lastTranslated && lastTranslated - translated < tickPixelIntervalOption * 0.6) {
+
+ // Is this a higher ranked position with a normal position to the right?
+ if (higherRanks[tickPositions[i]] && !higherRanks[tickPositions[i + 1]]) {
+
+ // Yes: remove the lower ranked neighbour to the right
+ itemToRemove = i + 1;
+ lastTranslated = translated; // #709
+
+ } else {
+
+ // No: remove this one
+ itemToRemove = i;
+ }
+
+ tickPositions.splice(itemToRemove, 1);
+
+ } else {
+ lastTranslated = translated;
+ }
+ }
+ }
+ });
+
+
+ /**
+ * Overrride the chart.pan method for ordinal axes.
+ */
+
+ var baseChartPan = chart.pan;
+ chart.pan = function (chartX) {
+ var xAxis = chart.xAxis[0],
+ runBase = false;
+ if (xAxis.options.ordinal) {
+
+ var mouseDownX = chart.mouseDownX,
+ extremes = xAxis.getExtremes(),
+ dataMax = extremes.dataMax,
+ min = extremes.min,
+ max = extremes.max,
+ newMin,
+ newMax,
+ hoverPoints = chart.hoverPoints,
+ closestPointRange = xAxis.closestPointRange,
+ pointPixelWidth = xAxis.translationSlope * (xAxis.ordinalSlope || closestPointRange),
+ movedUnits = (mouseDownX - chartX) / pointPixelWidth, // how many ordinal units did we move?
+ extendedAxis = { ordinalPositions: xAxis.getExtendedPositions() }, // get index of all the chart's points
+ ordinalPositions,
+ searchAxisLeft,
+ lin2val = xAxis.lin2val,
+ val2lin = xAxis.val2lin,
+ searchAxisRight;
+
+ if (!extendedAxis.ordinalPositions) { // we have an ordinal axis, but the data is equally spaced
+ runBase = true;
+
+ } else if (mathAbs(movedUnits) > 1) {
+
+ // Remove active points for shared tooltip
+ if (hoverPoints) {
+ each(hoverPoints, function (point) {
+ point.setState();
+ });
+ }
+
+ if (movedUnits < 0) {
+ searchAxisLeft = extendedAxis;
+ searchAxisRight = xAxis.ordinalPositions ? xAxis : extendedAxis;
+ } else {
+ searchAxisLeft = xAxis.ordinalPositions ? xAxis : extendedAxis;
+ searchAxisRight = extendedAxis;
+ }
+
+ // In grouped data series, the last ordinal position represents the grouped data, which is
+ // to the left of the real data max. If we don't compensate for this, we will be allowed
+ // to pan grouped data series passed the right of the plot area.
+ ordinalPositions = searchAxisRight.ordinalPositions;
+ if (dataMax > ordinalPositions[ordinalPositions.length - 1]) {
+ ordinalPositions.push(dataMax);
+ }
+
+ // Get the new min and max values by getting the ordinal index for the current extreme,
+ // then add the moved units and translate back to values. This happens on the
+ // extended ordinal positions if the new position is out of range, else it happens
+ // on the current x axis which is smaller and faster.
+ newMin = lin2val.apply(searchAxisLeft, [
+ val2lin.apply(searchAxisLeft, [min, true]) + movedUnits, // the new index
+ true // translate from index
+ ]);
+ newMax = lin2val.apply(searchAxisRight, [
+ val2lin.apply(searchAxisRight, [max, true]) + movedUnits, // the new index
+ true // translate from index
+ ]);
+
+ // Apply it if it is within the available data range
+ if (newMin > mathMin(extremes.dataMin, min) && newMax < mathMax(dataMax, max)) {
+ xAxis.setExtremes(newMin, newMax, true, false);
+ }
+
+ chart.mouseDownX = chartX; // set new reference for next run
+ css(chart.container, { cursor: 'move' });
+ }
+
+ } else {
+ runBase = true;
+ }
+
+ // revert to the linear chart.pan version
+ if (runBase) {
+ baseChartPan.apply(chart, arguments);
+ }
+ };
+ }
+ };
+
+ /**
+ * Extend getSegments by identifying gaps in the ordinal data so that we can draw a gap in the
+ * line or area
+ */
+ seriesProto.getSegments = function () {
+
+ var series = this,
+ segments,
+ gapSize = series.options.gapSize;
+
+ // call base method
+ baseGetSegments.apply(series);
+
+ if (series.xAxis.options.ordinal && gapSize) {
+
+ // properties
+ segments = series.segments;
+
+ // extension for ordinal breaks
+ each(segments, function (segment, no) {
+ var i = segment.length - 1;
+ while (i--) {
+ if (segment[i + 1].x - segment[i].x > series.xAxis.closestPointRange * gapSize) {
+ segments.splice( // insert after this one
+ no + 1,
+ 0,
+ segment.splice(i + 1, segment.length - i)
+ );
+ }
+ }
+ });
+ }
+ };
+}());
+
+/* ****************************************************************************
+ * End ordinal axis logic *
+ *****************************************************************************/
+// global variables
+extend(Highcharts, {
+ Chart: Chart,
+ dateFormat: dateFormat,
+ pathAnim: pathAnim,
+ getOptions: getOptions,
+ hasRtlBug: hasRtlBug,
+ numberFormat: numberFormat,
+ Point: Point,
+ Color: Color,
+ Renderer: Renderer,
+ seriesTypes: seriesTypes,
+ setOptions: setOptions,
+ Series: Series,
+
+ // Expose utility funcitons for modules
+ addEvent: addEvent,
+ removeEvent: removeEvent,
+ createElement: createElement,
+ discardElement: discardElement,
+ css: css,
+ each: each,
+ extend: extend,
+ map: map,
+ merge: merge,
+ pick: pick,
+ splat: splat,
+ extendClass: extendClass,
+ product: 'Highstock',
+ version: '1.1.4'
+});
+}());