Commit aaa287d9450f4babcd974c3a7ad5173eed1b54ed

Authored by Jeff Chen
1 parent 7aaf34d782
Exists in master

NN

Showing 204 changed files with 20206 additions and 0 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 204 files displayed.

amcharts/amcharts.js
File was created 1 if(!AmCharts)var AmCharts={themes:{},maps:{},inheriting:{},charts:[],onReadyArray:[],useUTC:!1,updateRate:40,uid:0,lang:{},translations:{},mapTranslations:{}};
2 AmCharts.Class=function(a){var b=function(){arguments[0]!==AmCharts.inheriting&&(this.events={},this.construct.apply(this,arguments))};a.inherits?(b.prototype=new a.inherits(AmCharts.inheriting),b.base=a.inherits.prototype,delete a.inherits):(b.prototype.createEvents=function(){for(var a=0,b=arguments.length;a<b;a++)this.events[arguments[a]]=[]},b.prototype.listenTo=function(a,b,c){this.removeListener(a,b,c);a.events[b].push({handler:c,scope:this})},b.prototype.addListener=function(a,b,c){this.removeListener(this,
3 a,b);this.events[a].push({handler:b,scope:c})},b.prototype.removeListener=function(a,b,c){if(a&&a.events)for(a=a.events[b],b=a.length-1;0<=b;b--)a[b].handler===c&&a.splice(b,1)},b.prototype.fire=function(a,b){for(var c=this.events[a],g=0,h=c.length;g<h;g++){var k=c[g];k.handler.call(k.scope,b)}});for(var c in a)b.prototype[c]=a[c];return b};AmCharts.addChart=function(a){AmCharts.charts.push(a)};AmCharts.removeChart=function(a){for(var b=AmCharts.charts,c=b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1)};
4 AmCharts.isModern=!0;AmCharts.getIEVersion=function(){var a=0;if("Microsoft Internet Explorer"==navigator.appName){var b=navigator.userAgent,c=/MSIE ([0-9]{1,}[.0-9]{0,})/;null!=c.exec(b)&&(a=parseFloat(RegExp.$1))}else"Netscape"==navigator.appName&&(b=navigator.userAgent,c=/Trident\/.*rv:([0-9]{1,}[.0-9]{0,})/,null!=c.exec(b)&&(a=parseFloat(RegExp.$1)));return a};
5 AmCharts.applyLang=function(a){var b=AmCharts.translations;b&&(a=b[a])&&(AmCharts.lang=a,a.monthNames&&(AmCharts.dayNames=a.dayNames,AmCharts.shortDayNames=a.shortDayNames,AmCharts.monthNames=a.monthNames,AmCharts.shortMonthNames=a.shortMonthNames))};AmCharts.IEversion=AmCharts.getIEVersion();9>AmCharts.IEversion&&0<AmCharts.IEversion&&(AmCharts.isModern=!1,AmCharts.isIE=!0);AmCharts.dx=0;AmCharts.dy=0;
6 if(document.addEventListener||window.opera)AmCharts.isNN=!0,AmCharts.isIE=!1,AmCharts.dx=.5,AmCharts.dy=.5;document.attachEvent&&(AmCharts.isNN=!1,AmCharts.isIE=!0,AmCharts.isModern||(AmCharts.dx=0,AmCharts.dy=0));window.chrome&&(AmCharts.chrome=!0);AmCharts.handleResize=function(){for(var a=AmCharts.charts,b=0;b<a.length;b++){var c=a[b];c&&c.div&&c.handleResize()}};AmCharts.handleMouseUp=function(a){for(var b=AmCharts.charts,c=0;c<b.length;c++){var d=b[c];d&&d.handleReleaseOutside(a)}};
7 AmCharts.handleMouseMove=function(a){for(var b=AmCharts.charts,c=0;c<b.length;c++){var d=b[c];d&&d.handleMouseMove(a)}};AmCharts.resetMouseOver=function(){for(var a=AmCharts.charts,b=0;b<a.length;b++){var c=a[b];c&&(c.mouseIsOver=!1)}};AmCharts.ready=function(a){AmCharts.onReadyArray.push(a)};AmCharts.handleLoad=function(){AmCharts.isReady=!0;for(var a=AmCharts.onReadyArray,b=0;b<a.length;b++){var c=a[b];isNaN(AmCharts.processDelay)?c():setTimeout(c,AmCharts.processDelay*b)}};
8 AmCharts.getUniqueId=function(){AmCharts.uid++;return"AmChartsEl-"+AmCharts.uid};AmCharts.isNN&&(document.addEventListener("mousemove",AmCharts.handleMouseMove,!0),window.addEventListener("resize",AmCharts.handleResize,!0),document.addEventListener("mouseup",AmCharts.handleMouseUp,!0),window.addEventListener("load",AmCharts.handleLoad,!0));
9 AmCharts.isIE&&(document.attachEvent("onmousemove",AmCharts.handleMouseMove),window.attachEvent("onresize",AmCharts.handleResize),document.attachEvent("onmouseup",AmCharts.handleMouseUp),window.attachEvent("onload",AmCharts.handleLoad));
10 AmCharts.clear=function(){var a=AmCharts.charts;if(a)for(var b=0;b<a.length;b++)a[b].clear();AmCharts.charts=null;AmCharts.isNN&&(document.removeEventListener("mousemove",AmCharts.handleMouseMove,!0),window.removeEventListener("resize",AmCharts.handleResize,!0),document.removeEventListener("mouseup",AmCharts.handleMouseUp,!0),window.removeEventListener("load",AmCharts.handleLoad,!0));AmCharts.isIE&&(document.detachEvent("onmousemove",AmCharts.handleMouseMove),window.detachEvent("onresize",AmCharts.handleResize),
11 document.detachEvent("onmouseup",AmCharts.handleMouseUp),window.detachEvent("onload",AmCharts.handleLoad))};
12 AmCharts.makeChart=function(a,b,c){var d=b.type,e=b.theme;AmCharts.isString(e)&&(e=AmCharts.themes[e],b.theme=e);var f;switch(d){case "serial":f=new AmCharts.AmSerialChart(e);break;case "xy":f=new AmCharts.AmXYChart(e);break;case "pie":f=new AmCharts.AmPieChart(e);break;case "radar":f=new AmCharts.AmRadarChart(e);break;case "gauge":f=new AmCharts.AmAngularGauge(e);break;case "funnel":f=new AmCharts.AmFunnelChart(e);break;case "map":f=new AmCharts.AmMap(e);break;case "stock":f=new AmCharts.AmStockChart(e)}AmCharts.extend(f,
13 b);AmCharts.isReady?isNaN(c)?f.write(a):setTimeout(function(){AmCharts.realWrite(f,a)},c):AmCharts.ready(function(){isNaN(c)?f.write(a):setTimeout(function(){AmCharts.realWrite(f,a)},c)});return f};AmCharts.realWrite=function(a,b){a.write(b)};AmCharts.toBoolean=function(a,b){if(void 0===a)return b;switch(String(a).toLowerCase()){case "true":case "yes":case "1":return!0;case "false":case "no":case "0":case null:return!1;default:return Boolean(a)}};AmCharts.removeFromArray=function(a,b){var c;for(c=a.length-1;0<=c;c--)a[c]==b&&a.splice(c,1)};AmCharts.getDecimals=function(a){var b=0;isNaN(a)||(a=String(a),-1!=a.indexOf("e-")?b=Number(a.split("-")[1]):-1!=a.indexOf(".")&&(b=a.split(".")[1].length));return b};
14 AmCharts.wrappedText=function(a,b,c,d,e,f,g,h,k){var l=AmCharts.text(a,b,c,d,e,f,g),m="\n";AmCharts.isModern||(m="<br>");if(10<k)return l;if(l){var n=l.getBBox();if(n.width>h){l.remove();for(var l=[],p=0;-1<(index=b.indexOf(" ",p));)l.push(index),p=index+1;for(var q=Math.round(b.length/2),r=1E3,s,p=0;p<l.length;p++){var v=Math.abs(l[p]-q);v<r&&(s=l[p],r=v)}if(isNaN(s)){h=Math.ceil(n.width/h);for(p=1;p<h;p++)s=Math.round(b.length/h*p),b=b.substr(0,s)+m+b.substr(s);return AmCharts.text(a,b,c,d,e,f,
15 g)}b=b.substr(0,s)+m+b.substr(s+1);return AmCharts.wrappedText(a,b,c,d,e,f,g,h,k+1)}return l}};AmCharts.getStyle=function(a,b){var c="";document.defaultView&&document.defaultView.getComputedStyle?c=document.defaultView.getComputedStyle(a,"").getPropertyValue(b):a.currentStyle&&(b=b.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),c=a.currentStyle[b]);return c};AmCharts.removePx=function(a){if(void 0!=a)return Number(a.substring(0,a.length-2))};
16 AmCharts.getURL=function(a,b){if(a)if("_self"!=b&&b)if("_top"==b&&window.top)window.top.location.href=a;else if("_parent"==b&&window.parent)window.parent.location.href=a;else{var c=document.getElementsByName(b)[0];c?c.src=a:window.open(a)}else window.location.href=a};AmCharts.ifArray=function(a){return a&&0<a.length?!0:!1};AmCharts.callMethod=function(a,b){var c;for(c=0;c<b.length;c++){var d=b[c];if(d){if(d[a])d[a]();var e=d.length;if(0<e){var f;for(f=0;f<e;f++){var g=d[f];if(g&&g[a])g[a]()}}}}};
17 AmCharts.toNumber=function(a){return"number"==typeof a?a:Number(String(a).replace(/[^0-9\-.]+/g,""))};AmCharts.toColor=function(a){if(""!==a&&void 0!==a)if(-1!=a.indexOf(",")){a=a.split(",");var b;for(b=0;b<a.length;b++){var c=a[b].substring(a[b].length-6,a[b].length);a[b]="#"+c}}else a=a.substring(a.length-6,a.length),a="#"+a;return a};
18 AmCharts.toCoordinate=function(a,b,c){var d;void 0!==a&&(a=String(a),c&&c<b&&(b=c),d=Number(a),-1!=a.indexOf("!")&&(d=b-Number(a.substr(1))),-1!=a.indexOf("%")&&(d=b*Number(a.substr(0,a.length-1))/100));return d};AmCharts.fitToBounds=function(a,b,c){a<b&&(a=b);a>c&&(a=c);return a};AmCharts.isDefined=function(a){return void 0===a?!1:!0};AmCharts.stripNumbers=function(a){return a.replace(/[0-9]+/g,"")};AmCharts.roundTo=function(a,b){if(0>b)return a;var c=Math.pow(10,b);return Math.round(a*c)/c};
19 AmCharts.toFixed=function(a,b){var c=String(Math.round(a*Math.pow(10,b)));if(0<b){var d=c.length;if(d<b){var e;for(e=0;e<b-d;e++)c="0"+c}d=c.substring(0,c.length-b);""===d&&(d=0);return d+"."+c.substring(c.length-b,c.length)}return String(c)};
20 AmCharts.formatDuration=function(a,b,c,d,e,f){var g=AmCharts.intervals,h=f.decimalSeparator;if(a>=g[b].contains){var k=a-Math.floor(a/g[b].contains)*g[b].contains;"ss"==b&&(k=AmCharts.formatNumber(k,f),1==k.split(h)[0].length&&(k="0"+k));("mm"==b||"hh"==b)&&10>k&&(k="0"+k);c=k+""+d[b]+""+c;a=Math.floor(a/g[b].contains);b=g[b].nextInterval;return AmCharts.formatDuration(a,b,c,d,e,f)}"ss"==b&&(a=AmCharts.formatNumber(a,f),1==a.split(h)[0].length&&(a="0"+a));("mm"==b||"hh"==b)&&10>a&&(a="0"+a);c=a+""+
21 d[b]+""+c;if(g[e].count>g[b].count)for(a=g[b].count;a<g[e].count;a++)b=g[b].nextInterval,"ss"==b||"mm"==b||"hh"==b?c="00"+d[b]+""+c:"DD"==b&&(c="0"+d[b]+""+c);":"==c.charAt(c.length-1)&&(c=c.substring(0,c.length-1));return c};
22 AmCharts.formatNumber=function(a,b,c,d,e){a=AmCharts.roundTo(a,b.precision);isNaN(c)&&(c=b.precision);var f=b.decimalSeparator;b=b.thousandsSeparator;var g;g=0>a?"-":"";a=Math.abs(a);var h=String(a),k=!1;-1!=h.indexOf("e")&&(k=!0);0<=c&&!k&&(h=AmCharts.toFixed(a,c));var l="";if(k)l=h;else{var h=h.split("."),k=String(h[0]),m;for(m=k.length;0<=m;m-=3)l=m!=k.length?0!==m?k.substring(m-3,m)+b+l:k.substring(m-3,m)+l:k.substring(m-3,m);void 0!==h[1]&&(l=l+f+h[1]);void 0!==c&&0<c&&"0"!=l&&(l=AmCharts.addZeroes(l,
23 f,c))}l=g+l;""===g&&!0===d&&0!==a&&(l="+"+l);!0===e&&(l+="%");return l};AmCharts.addZeroes=function(a,b,c){a=a.split(b);void 0===a[1]&&0<c&&(a[1]="0");return a[1].length<c?(a[1]+="0",AmCharts.addZeroes(a[0]+b+a[1],b,c)):void 0!==a[1]?a[0]+b+a[1]:a[0]};
24 AmCharts.scientificToNormal=function(a){var b;a=String(a).split("e");var c;if("-"==a[1].substr(0,1)){b="0.";for(c=0;c<Math.abs(Number(a[1]))-1;c++)b+="0";b+=a[0].split(".").join("")}else{var d=0;b=a[0].split(".");b[1]&&(d=b[1].length);b=a[0].split(".").join("");for(c=0;c<Math.abs(Number(a[1]))-d;c++)b+="0"}return b};
25 AmCharts.toScientific=function(a,b){if(0===a)return"0";var c=Math.floor(Math.log(Math.abs(a))*Math.LOG10E);Math.pow(10,c);mantissa=String(mantissa).split(".").join(b);return String(mantissa)+"e"+c};AmCharts.randomColor=function(){return"#"+("00000"+(16777216*Math.random()<<0).toString(16)).substr(-6)};
26 AmCharts.hitTest=function(a,b,c){var d=!1,e=a.x,f=a.x+a.width,g=a.y,h=a.y+a.height,k=AmCharts.isInRectangle;d||(d=k(e,g,b));d||(d=k(e,h,b));d||(d=k(f,g,b));d||(d=k(f,h,b));d||!0===c||(d=AmCharts.hitTest(b,a,!0));return d};AmCharts.isInRectangle=function(a,b,c){return a>=c.x-5&&a<=c.x+c.width+5&&b>=c.y-5&&b<=c.y+c.height+5?!0:!1};AmCharts.isPercents=function(a){if(-1!=String(a).indexOf("%"))return!0};
27 AmCharts.findPosX=function(a){var b=a,c=a.offsetLeft;if(a.offsetParent){for(;a=a.offsetParent;)c+=a.offsetLeft;for(;(b=b.parentNode)&&b!=document.body;)c-=b.scrollLeft||0}return c};AmCharts.findPosY=function(a){var b=a,c=a.offsetTop;if(a.offsetParent){for(;a=a.offsetParent;)c+=a.offsetTop;for(;(b=b.parentNode)&&b!=document.body;)c-=b.scrollTop||0}return c};AmCharts.findIfFixed=function(a){if(a.offsetParent)for(;a=a.offsetParent;)if("fixed"==AmCharts.getStyle(a,"position"))return!0;return!1};
28 AmCharts.findIfAuto=function(a){return a.style&&"auto"==AmCharts.getStyle(a,"overflow")?!0:a.parentNode?AmCharts.findIfAuto(a.parentNode):!1};AmCharts.findScrollLeft=function(a,b){a.scrollLeft&&(b+=a.scrollLeft);return a.parentNode?AmCharts.findScrollLeft(a.parentNode,b):b};AmCharts.findScrollTop=function(a,b){a.scrollTop&&(b+=a.scrollTop);return a.parentNode?AmCharts.findScrollTop(a.parentNode,b):b};
29 AmCharts.formatValue=function(a,b,c,d,e,f,g,h){if(b){void 0===e&&(e="");var k;for(k=0;k<c.length;k++){var l=c[k],m=b[l];void 0!==m&&(m=f?AmCharts.addPrefix(m,h,g,d):AmCharts.formatNumber(m,d),a=a.replace(new RegExp("\\[\\["+e+""+l+"\\]\\]","g"),m))}}return a};AmCharts.formatDataContextValue=function(a,b){if(a){var c=a.match(/\[\[.*?\]\]/g),d;for(d=0;d<c.length;d++){var e=c[d],e=e.substr(2,e.length-4);void 0!==b[e]&&(a=a.replace(new RegExp("\\[\\["+e+"\\]\\]","g"),b[e]))}}return a};
30 AmCharts.massReplace=function(a,b){for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];void 0===d&&(d="");a=a.replace(c,d)}return a};AmCharts.cleanFromEmpty=function(a){return a.replace(/\[\[[^\]]*\]\]/g,"")};
31 AmCharts.addPrefix=function(a,b,c,d,e){var f=AmCharts.formatNumber(a,d),g="",h,k,l;if(0===a)return"0";0>a&&(g="-");a=Math.abs(a);if(1<a)for(h=b.length-1;-1<h;h--){if(a>=b[h].number&&(k=a/b[h].number,l=Number(d.precision),1>l&&(l=1),c=AmCharts.roundTo(k,l),l=AmCharts.formatNumber(c,{precision:-1,decimalSeparator:d.decimalSeparator,thousandsSeparator:d.thousandsSeparator}),!e||k==c)){f=g+""+l+""+b[h].prefix;break}}else for(h=0;h<c.length;h++)if(a<=c[h].number){k=a/c[h].number;l=Math.abs(Math.round(Math.log(k)*
32 Math.LOG10E));k=AmCharts.roundTo(k,l);f=g+""+k+""+c[h].prefix;break}return f};AmCharts.remove=function(a){a&&a.remove()};AmCharts.recommended=function(){var a="js";document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")||swfobject&&swfobject.hasFlashPlayerVersion("8")&&(a="flash");return a};AmCharts.getEffect=function(a){">"==a&&(a="easeOutSine");"<"==a&&(a="easeInSine");"elastic"==a&&(a="easeOutElastic");return a};
33 AmCharts.getObjById=function(a,b){var c,d;for(d=0;d<a.length;d++){var e=a[d];e.id==b&&(c=e)}return c};AmCharts.applyTheme=function(a,b,c){b||(b=AmCharts.theme);b&&b[c]&&AmCharts.extend(a,b[c])};AmCharts.isString=function(a){return"string"==typeof a?!0:!1};AmCharts.extend=function(a,b,c){for(var d in b)c?a.hasOwnProperty(d)||(a[d]=b[d]):a[d]=b[d];return a};
34 AmCharts.copyProperties=function(a,b){for(var c in a)a.hasOwnProperty(c)&&"events"!=c&&void 0!==a[c]&&"function"!=typeof a[c]&&"cname"!=c&&(b[c]=a[c])};AmCharts.processObject=function(a,b,c){!1===a instanceof b&&(a=AmCharts.extend(new b(c),a));return a};AmCharts.fixNewLines=function(a){var b=RegExp("\\n","g");a&&(a=a.replace(b,"<br />"));return a};AmCharts.fixBrakes=function(a){if(AmCharts.isModern){var b=RegExp("<br>","g");a&&(a=a.replace(b,"\n"))}else a=AmCharts.fixNewLines(a);return a};
35 AmCharts.deleteObject=function(a,b){if(a){if(void 0===b||null===b)b=20;if(0!==b)if("[object Array]"===Object.prototype.toString.call(a))for(var c=0;c<a.length;c++)AmCharts.deleteObject(a[c],b-1),a[c]=null;else if(a&&!a.tagName)try{for(c in a)a[c]&&("object"==typeof a[c]&&AmCharts.deleteObject(a[c],b-1),"function"!=typeof a[c]&&(a[c]=null))}catch(d){}}};
36 AmCharts.bounce=function(a,b,c,d,e){return(b/=e)<1/2.75?7.5625*d*b*b+c:b<2/2.75?d*(7.5625*(b-=1.5/2.75)*b+.75)+c:b<2.5/2.75?d*(7.5625*(b-=2.25/2.75)*b+.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+.984375)+c};AmCharts.easeInSine=function(a,b,c,d,e){return-d*Math.cos(b/e*(Math.PI/2))+d+c};AmCharts.easeOutSine=function(a,b,c,d,e){return d*Math.sin(b/e*(Math.PI/2))+c};
37 AmCharts.easeOutElastic=function(a,b,c,d,e){a=1.70158;var f=0,g=d;if(0===b)return c;if(1==(b/=e))return c+d;f||(f=.3*e);g<Math.abs(d)?(g=d,a=f/4):a=f/(2*Math.PI)*Math.asin(d/g);return g*Math.pow(2,-10*b)*Math.sin(2*(b*e-a)*Math.PI/f)+d+c};AmCharts.AxisBase=AmCharts.Class({construct:function(a){this.createEvents("clickItem","rollOverItem","rollOutItem");this.viY=this.viX=this.y=this.x=this.dy=this.dx=0;this.axisThickness=1;this.axisColor="#000000";this.axisAlpha=1;this.gridCount=this.tickLength=5;this.gridAlpha=.15;this.gridThickness=1;this.gridColor="#000000";this.dashLength=0;this.labelFrequency=1;this.showLastLabel=this.showFirstLabel=!0;this.fillColor="#FFFFFF";this.fillAlpha=0;this.labelsEnabled=!0;this.labelRotation=0;this.autoGridCount=
38 !0;this.valueRollOverColor="#CC0000";this.offset=0;this.guides=[];this.visible=!0;this.counter=0;this.guides=[];this.ignoreAxisWidth=this.inside=!1;this.minHorizontalGap=75;this.minVerticalGap=35;this.titleBold=!0;this.minorGridEnabled=!1;this.minorGridAlpha=.07;this.autoWrap=!1;this.titleAlign="middle";this.labelOffset=0;AmCharts.applyTheme(this,a,"AxisBase")},zoom:function(a,b){this.start=a;this.end=b;this.dataChanged=!0;this.draw()},fixAxisPosition:function(){var a=this.position;"H"==this.orientation?
39 ("left"==a&&(a="bottom"),"right"==a&&(a="top")):("bottom"==a&&(a="left"),"top"==a&&(a="right"));this.position=a},draw:function(){var a=this.chart;this.allLabels=[];this.counter=0;this.destroy();this.fixAxisPosition();this.labels=[];var b=a.container,c=b.set();a.gridSet.push(c);this.set=c;b=b.set();a.axesLabelsSet.push(b);this.labelsSet=b;this.axisLine=new this.axisRenderer(this);this.autoGridCount?("V"==this.orientation?(a=this.height/this.minVerticalGap,3>a&&(a=3)):a=this.width/this.minHorizontalGap,
40 this.gridCountR=Math.max(a,1)):this.gridCountR=this.gridCount;this.axisWidth=this.axisLine.axisWidth;this.addTitle()},setOrientation:function(a){this.orientation=a?"H":"V"},addTitle:function(){var a=this.title;if(a){var b=this.chart,c=this.titleColor;void 0===c&&(c=b.color);var d=this.titleFontSize;isNaN(d)&&(d=b.fontSize+1);this.titleLabel=AmCharts.text(b.container,a,c,b.fontFamily,d,this.titleAlign,this.titleBold)}},positionTitle:function(){var a=this.titleLabel;if(a){var b,c,d=this.labelsSet,e=
41 {};0<d.length()?e=d.getBBox():(e.x=0,e.y=0,e.width=this.viW,e.height=this.viH);d.push(a);var d=e.x,f=e.y;AmCharts.VML&&(this.rotate?d-=this.x:f-=this.y);var g=e.width,e=e.height,h=this.viW,k=this.viH,l=0,m=a.getBBox().height/2,n=this.inside,p=this.titleAlign;switch(this.position){case "top":b="left"==p?-1:"right"==p?h:h/2;c=f-10-m;break;case "bottom":b="left"==p?-1:"right"==p?h:h/2;c=f+e+10+m;break;case "left":b=d-10-m;n&&(b-=5);c="left"==p?k+1:"right"==p?-1:k/2;l=-90;break;case "right":b=d+g+10+
42 m-3,n&&(b+=7),c="left"==p?k+2:"right"==p?-2:k/2,l=-90}this.marginsChanged?(a.translate(b,c),this.tx=b,this.ty=c):a.translate(this.tx,this.ty);this.marginsChanged=!1;0!==l&&a.rotate(l)}},pushAxisItem:function(a,b){var c=this,d=a.graphics();0<d.length()&&(b?c.labelsSet.push(d):c.set.push(d));if(d=a.getLabel())this.labelsSet.push(d),d.click(function(b){c.handleMouse(b,a,"clickItem")}).mouseover(function(b){c.handleMouse(b,a,"rollOverItem")}).mouseout(function(b){c.handleMouse(b,a,"rollOutItem")})},handleMouse:function(a,
43 b,c){this.fire(c,{type:c,value:b.value,serialDataItem:b.serialDataItem,axis:this,target:b.label,chart:this.chart,event:a})},addGuide:function(a){for(var b=this.guides,c=!1,d=0;d<b.length;d++)b[d]==a&&(c=!0);c||b.push(a)},removeGuide:function(a){var b=this.guides,c;for(c=0;c<b.length;c++)b[c]==a&&b.splice(c,1)},handleGuideOver:function(a){clearTimeout(this.chart.hoverInt);var b=a.graphics.getBBox(),c=b.x+b.width/2,b=b.y+b.height/2,d=a.fillColor;void 0===d&&(d=a.lineColor);this.chart.showBalloon(a.balloonText,
44 d,!0,c,b)},handleGuideOut:function(a){this.chart.hideBalloon()},addEventListeners:function(a,b){var c=this;a.mouseover(function(){c.handleGuideOver(b)});a.mouseout(function(){c.handleGuideOut(b)})},getBBox:function(){var a=this.labelsSet.getBBox();AmCharts.VML||(a={x:a.x+this.x,y:a.y+this.y,width:a.width,height:a.height});return a},destroy:function(){AmCharts.remove(this.set);AmCharts.remove(this.labelsSet);var a=this.axisLine;a&&AmCharts.remove(a.set);AmCharts.remove(this.grid0)}});AmCharts.ValueAxis=AmCharts.Class({inherits:AmCharts.AxisBase,construct:function(a){this.cname="ValueAxis";this.createEvents("axisChanged","logarithmicAxisFailed","axisSelfZoomed","axisZoomed");AmCharts.ValueAxis.base.construct.call(this,a);this.dataChanged=!0;this.stackType="none";this.position="left";this.unitPosition="right";this.recalculateToPercents=this.includeHidden=this.includeGuidesInMinMax=this.integersOnly=!1;this.durationUnits={DD:"d. ",hh:":",mm:":",ss:""};this.scrollbar=!1;this.baseValue=
45 0;this.radarCategoriesEnabled=!0;this.gridType="polygons";this.useScientificNotation=!1;this.axisTitleOffset=10;this.minMaxMultiplier=1;this.logGridLimit=2;AmCharts.applyTheme(this,a,this.cname)},updateData:function(){0>=this.gridCountR&&(this.gridCountR=1);this.totals=[];this.data=this.chart.chartData;var a=this.chart;"xy"!=a.type&&(this.stackGraphs("smoothedLine"),this.stackGraphs("line"),this.stackGraphs("column"),this.stackGraphs("step"));this.recalculateToPercents&&this.recalculate();this.synchronizationMultiplier&&
46 this.synchronizeWith?(AmCharts.isString(this.synchronizeWith)&&(this.synchronizeWith=a.getValueAxisById(this.synchronizeWith)),this.synchronizeWith&&(this.synchronizeWithAxis(this.synchronizeWith),this.foundGraphs=!0)):(this.foundGraphs=!1,this.getMinMax())},draw:function(){AmCharts.ValueAxis.base.draw.call(this);var a=this.chart,b=this.set;"duration"==this.type&&(this.duration="ss");!0===this.dataChanged&&(this.updateData(),this.dataChanged=!1);if(this.logarithmic&&(0>=this.getMin(0,this.data.length-
47 1)||0>=this.minimum))this.fire("logarithmicAxisFailed",{type:"logarithmicAxisFailed",chart:a});else{this.grid0=null;var c,d,e=a.dx,f=a.dy,g=!1,h=this.logarithmic;if(isNaN(this.min)||isNaN(this.max)||!this.foundGraphs||Infinity==this.min||-Infinity==this.max)g=!0;else{var k=this.labelFrequency,l=this.showFirstLabel,m=this.showLastLabel,n=1,p=0,q=Math.round((this.max-this.min)/this.step)+1,r;!0===h?(r=Math.log(this.max)*Math.LOG10E-Math.log(this.minReal)*Math.LOG10E,this.stepWidth=this.axisWidth/r,
48 r>this.logGridLimit&&(q=Math.ceil(Math.log(this.max)*Math.LOG10E)+1,p=Math.round(Math.log(this.minReal)*Math.LOG10E),q>this.gridCountR&&(n=Math.ceil(q/this.gridCountR)))):this.stepWidth=this.axisWidth/(this.max-this.min);var s=0;1>this.step&&-1<this.step&&(s=AmCharts.getDecimals(this.step));this.integersOnly&&(s=0);s>this.maxDecCount&&(s=this.maxDecCount);var v=this.precision;isNaN(v)||(s=v);this.max=AmCharts.roundTo(this.max,this.maxDecCount);this.min=AmCharts.roundTo(this.min,this.maxDecCount);
49 var w={};w.precision=s;w.decimalSeparator=a.nf.decimalSeparator;w.thousandsSeparator=a.nf.thousandsSeparator;this.numberFormatter=w;var t,u=this.guides,y=u.length;if(0<y){c=this.fillAlpha;for(d=this.fillAlpha=0;d<y;d++){var E=u[d],A=NaN,z=E.above;isNaN(E.toValue)||(A=this.getCoordinate(E.toValue),t=new this.axisItemRenderer(this,A,"",!0,NaN,NaN,E),this.pushAxisItem(t,z));var K=NaN;isNaN(E.value)||(K=this.getCoordinate(E.value),t=new this.axisItemRenderer(this,K,E.label,!0,NaN,(A-K)/2,E),this.pushAxisItem(t,
50 z));isNaN(A-K)||(t=new this.guideFillRenderer(this,K,A,E),this.pushAxisItem(t,z),t=t.graphics(),E.graphics=t,E.balloonText&&this.addEventListeners(t,E))}this.fillAlpha=c}u=!1;for(d=p;d<q;d+=n)y=AmCharts.roundTo(this.step*d+this.min,s),-1!=String(y).indexOf("e")&&(u=!0,String(y).split("e"));this.duration&&(this.maxInterval=AmCharts.getMaxInterval(this.max,this.duration));var s=this.step,I,y=this.minorGridAlpha;this.minorGridEnabled&&(I=this.getMinorGridStep(s,this.stepWidth*s));for(d=p;d<q;d+=n)if(p=
51 s*d+this.min,h&&this.max-this.min>5*this.min&&(p-=this.min),p=AmCharts.roundTo(p,this.maxDecCount+1),!this.integersOnly||Math.round(p)==p)if(isNaN(v)||Number(AmCharts.toFixed(p,v))==p){!0===h&&(0===p&&(p=this.minReal),r>this.logGridLimit&&(p=Math.pow(10,d)),u=-1!=String(p).indexOf("e")?!0:!1);this.useScientificNotation&&(u=!0);this.usePrefixes&&(u=!1);u?(t=-1==String(p).indexOf("e")?p.toExponential(15):String(p),c=t.split("e"),t=Number(c[0]),c=Number(c[1]),t=AmCharts.roundTo(t,14),10==t&&(t=1,c+=
52 1),t=t+"e"+c,0===p&&(t="0"),1==p&&(t="1")):(h&&(t=String(p).split("."),t[1]?(w.precision=t[1].length,0>d&&(w.precision=Math.abs(d))):w.precision=-1),t=this.usePrefixes?AmCharts.addPrefix(p,a.prefixesOfBigNumbers,a.prefixesOfSmallNumbers,w,!0):AmCharts.formatNumber(p,w,w.precision));this.duration&&(t=AmCharts.formatDuration(p,this.duration,"",this.durationUnits,this.maxInterval,w));this.recalculateToPercents?t+="%":(c=this.unit)&&(t="left"==this.unitPosition?c+t:t+c);Math.round(d/k)!=d/k&&(t=void 0);
53 if(0===d&&!l||d==q-1&&!m)t=" ";c=this.getCoordinate(p);this.labelFunction&&(t=this.labelFunction(p,t,this).toString());t=new this.axisItemRenderer(this,c,t,void 0,void 0,void 0,void 0,this.boldLabels);this.pushAxisItem(t);if(p==this.baseValue&&"radar"!=a.type){var F,H,z=this.viW,A=this.viH;t=this.viX;E=this.viY;"H"==this.orientation?0<=c&&c<=z+1&&(F=[c,c,c+e],H=[A,0,f]):0<=c&&c<=A+1&&(F=[0,z,z+e],H=[c,c,c+f]);F&&(c=AmCharts.fitToBounds(2*this.gridAlpha,0,1),c=AmCharts.line(a.container,F,H,this.gridColor,
54 c,1,this.dashLength),c.translate(t,E),this.grid0=c,a.axesSet.push(c),c.toBack())}if(!isNaN(I)&&0<y&&d<q-1){t=this.gridAlpha;this.gridAlpha=this.minorGridAlpha;for(c=1;c<s/I;c++)E=this.getCoordinate(p+I*c),E=new this.axisItemRenderer(this,E,"",!1,0,0,!1,!1,0,!0),this.pushAxisItem(E);this.gridAlpha=t}}d=this.baseValue;this.min>this.baseValue&&this.max>this.baseValue&&(d=this.min);this.min<this.baseValue&&this.max<this.baseValue&&(d=this.max);h&&d<this.minReal&&(d=this.minReal);this.baseCoord=this.getCoordinate(d);
55 d={type:"axisChanged",target:this,chart:a};d.min=h?this.minReal:this.min;d.max=this.max;this.fire("axisChanged",d);this.axisCreated=!0}h=this.axisLine.set;d=this.labelsSet;this.positionTitle();"radar"!=a.type?(a=this.viX,e=this.viY,b.translate(a,e),d.translate(a,e)):h.toFront();!this.visible||g?(b.hide(),h.hide(),d.hide()):(b.show(),h.show(),d.show());this.axisY=this.y-this.viY;this.axisX=this.x-this.viX}},getMinorGridStep:function(a,b){var c=[5,4,2];60>b&&c.shift();for(var d=Math.floor(Math.log(Math.abs(a))*
56 Math.LOG10E),e=0;e<c.length;e++){var f=a/c[e],g=Math.floor(Math.log(Math.abs(f))*Math.LOG10E);if(!(0<Math.abs(d-g)))if(1>a){if(g=Math.pow(10,-g)*f,g==Math.round(g))return f}else if(f==Math.round(f))return f}},stackGraphs:function(a){var b=this.stackType;"stacked"==b&&(b="regular");"line"==b&&(b="none");"100% stacked"==b&&(b="100%");this.stackType=b;var c=[],d=[],e=[],f=[],g,h=this.chart.graphs,k,l,m,n,p=this.baseValue,q=!1;if("line"==a||"step"==a||"smoothedLine"==a)q=!0;if(q&&("regular"==b||"100%"==
57 b))for(n=0;n<h.length;n++)m=h[n],m.hidden||(l=m.type,m.chart==this.chart&&m.valueAxis==this&&a==l&&m.stackable&&(k&&(m.stackGraph=k),k=m));for(k=this.start;k<=this.end;k++){var r=0;for(n=0;n<h.length;n++)if(m=h[n],m.hidden)m.newStack&&(e[k]=NaN,d[k]=NaN);else if(l=m.type,m.chart==this.chart&&m.valueAxis==this&&a==l&&m.stackable&&(l=this.data[k].axes[this.id].graphs[m.id],g=l.values.value,!isNaN(g))){var s=AmCharts.getDecimals(g);r<s&&(r=s);isNaN(f[k])?f[k]=Math.abs(g):f[k]+=Math.abs(g);f[k]=AmCharts.roundTo(f[k],
58 r);s=m.fillToGraph;q&&s&&(s=this.data[k].axes[this.id].graphs[s.id])&&(l.values.open=s.values.value);"regular"==b&&(q&&(isNaN(c[k])?(c[k]=g,l.values.close=g,l.values.open=this.baseValue):(isNaN(g)?l.values.close=c[k]:l.values.close=g+c[k],l.values.open=c[k],c[k]=l.values.close)),"column"!=a||isNaN(g)||(m.newStack&&(e[k]=NaN,d[k]=NaN),l.values.close=g,0>g?(l.values.close=g,isNaN(d[k])?l.values.open=p:(l.values.close+=d[k],l.values.open=d[k]),d[k]=l.values.close):(l.values.close=g,isNaN(e[k])?l.values.open=
59 p:(l.values.close+=e[k],l.values.open=e[k]),e[k]=l.values.close)))}}for(k=this.start;k<=this.end;k++)for(n=0;n<h.length;n++)(m=h[n],m.hidden)?m.newStack&&(e[k]=NaN,d[k]=NaN):(l=m.type,m.chart==this.chart&&m.valueAxis==this&&a==l&&m.stackable&&(l=this.data[k].axes[this.id].graphs[m.id],g=l.values.value,isNaN(g)||(c=g/f[k]*100,l.values.percents=c,l.values.total=f[k],m.newStack&&(e[k]=NaN,d[k]=NaN),"100%"==b&&(isNaN(d[k])&&(d[k]=0),isNaN(e[k])&&(e[k]=0),0>c?(l.values.close=AmCharts.fitToBounds(c+d[k],
60 -100,100),l.values.open=d[k],d[k]=l.values.close):(l.values.close=AmCharts.fitToBounds(c+e[k],-100,100),l.values.open=e[k],e[k]=l.values.close)))))},recalculate:function(){var a=this.chart,b=a.graphs,c;for(c=0;c<b.length;c++){var d=b[c];if(d.valueAxis==this){var e="value";if("candlestick"==d.type||"ohlc"==d.type)e="open";var f,g,h=this.end+2,h=AmCharts.fitToBounds(this.end+1,0,this.data.length-1),k=this.start;0<k&&k--;var l;g=this.start;d.compareFromStart&&(g=0);if(!isNaN(a.startTime)&&(l=a.categoryAxis)){minDuration=
61 l.minDuration();var m=new Date(a.startTime+minDuration/2),n=AmCharts.resetDateToMin(new Date(a.startTime),l.minPeriod).getTime();AmCharts.resetDateToMin(new Date(m),l.minPeriod).getTime()>n&&g++}if(l=a.recalculateFromDate)a.dataDateFormat&&(l=AmCharts.stringToDate(l,a.dataDateFormat)),g=a.getClosestIndex(a.chartData,"time",l.getTime(),!0,0,a.chartData.length),h=a.chartData.length-1;for(l=g;l<=h&&(g=this.data[l].axes[this.id].graphs[d.id],f=g.values[e],isNaN(f));l++);this.recBaseValue=f;for(e=k;e<=
62 h;e++){g=this.data[e].axes[this.id].graphs[d.id];g.percents={};var k=g.values,p;for(p in k)g.percents[p]="percents"!=p?k[p]/f*100-100:k[p]}}}},getMinMax:function(){var a=!1,b=this.chart,c=b.graphs,d;for(d=0;d<c.length;d++){var e=c[d].type;("line"==e||"step"==e||"smoothedLine"==e)&&this.expandMinMax&&(a=!0)}a&&(0<this.start&&this.start--,this.end<this.data.length-1&&this.end++);"serial"==b.type&&(!0!==b.categoryAxis.parseDates||a||this.end<this.data.length-1&&this.end++);a=this.minMaxMultiplier;this.min=
63 this.getMin(this.start,this.end);this.max=this.getMax();a=(this.max-this.min)*(a-1);this.min-=a;this.max+=a;a=this.guides.length;if(this.includeGuidesInMinMax&&0<a)for(b=0;b<a;b++)c=this.guides[b],c.toValue<this.min&&(this.min=c.toValue),c.value<this.min&&(this.min=c.value),c.toValue>this.max&&(this.max=c.toValue),c.value>this.max&&(this.max=c.value);isNaN(this.minimum)||(this.min=this.minimum);isNaN(this.maximum)||(this.max=this.maximum);this.min>this.max&&(a=this.max,this.max=this.min,this.min=
64 a);isNaN(this.minTemp)||(this.min=this.minTemp);isNaN(this.maxTemp)||(this.max=this.maxTemp);this.minReal=this.min;this.maxReal=this.max;0===this.min&&0===this.max&&(this.max=9);this.min>this.max&&(this.min=this.max-1);a=this.min;b=this.max;c=this.max-this.min;d=0===c?Math.pow(10,Math.floor(Math.log(Math.abs(this.max))*Math.LOG10E))/10:Math.pow(10,Math.floor(Math.log(Math.abs(c))*Math.LOG10E))/10;isNaN(this.maximum)&&isNaN(this.maxTemp)&&(this.max=Math.ceil(this.max/d)*d+d);isNaN(this.minimum)&&isNaN(this.minTemp)&&
65 (this.min=Math.floor(this.min/d)*d-d);0>this.min&&0<=a&&(this.min=0);0<this.max&&0>=b&&(this.max=0);"100%"==this.stackType&&(this.min=0>this.min?-100:0,this.max=0>this.max?0:100);c=this.max-this.min;d=Math.pow(10,Math.floor(Math.log(Math.abs(c))*Math.LOG10E))/10;this.step=Math.ceil(c/this.gridCountR/d)*d;c=Math.pow(10,Math.floor(Math.log(Math.abs(this.step))*Math.LOG10E));c=this.fixStepE(c);d=Math.ceil(this.step/c);5<d&&(d=10);5>=d&&2<d&&(d=5);this.step=Math.ceil(this.step/(c*d))*c*d;1>c?(this.maxDecCount=
66 Math.abs(Math.log(Math.abs(c))*Math.LOG10E),this.maxDecCount=Math.round(this.maxDecCount),this.step=AmCharts.roundTo(this.step,this.maxDecCount+1)):this.maxDecCount=0;this.min=this.step*Math.floor(this.min/this.step);this.max=this.step*Math.ceil(this.max/this.step);0>this.min&&0<=a&&(this.min=0);0<this.max&&0>=b&&(this.max=0);1<this.minReal&&1<this.max-this.minReal&&(this.minReal=Math.floor(this.minReal));c=Math.pow(10,Math.floor(Math.log(Math.abs(this.minReal))*Math.LOG10E));0===this.min&&(this.minReal=
67 c);0===this.min&&1<this.minReal&&(this.minReal=1);0<this.min&&0<this.minReal-this.step&&(this.minReal=this.min+this.step<this.minReal?this.min+this.step:this.min);c=Math.log(b)*Math.LOG10E-Math.log(a)*Math.LOG10E;this.logarithmic&&(2<c?(this.minReal=this.min=Math.pow(10,Math.floor(Math.log(Math.abs(a))*Math.LOG10E)),this.max=Math.pow(10,Math.ceil(Math.log(Math.abs(b))*Math.LOG10E))):(b=Math.pow(10,Math.floor(Math.log(Math.abs(this.min))*Math.LOG10E))/10,a=Math.pow(10,Math.floor(Math.log(Math.abs(a))*
68 Math.LOG10E))/10,b<a&&(this.minReal=this.min=10*a)))},fixStepE:function(a){a=a.toExponential(0).split("e");var b=Number(a[1]);9==Number(a[0])&&b++;return this.generateNumber(1,b)},generateNumber:function(a,b){var c="",d;d=0>b?Math.abs(b)-1:Math.abs(b);var e;for(e=0;e<d;e++)c+="0";return 0>b?Number("0."+c+String(a)):Number(String(a)+c)},getMin:function(a,b){var c,d;for(d=a;d<=b;d++){var e=this.data[d].axes[this.id].graphs,f;for(f in e)if(e.hasOwnProperty(f)){var g=this.chart.getGraphById(f);if(g.includeInMinMax&&
69 (!g.hidden||this.includeHidden)){isNaN(c)&&(c=Infinity);this.foundGraphs=!0;g=e[f].values;this.recalculateToPercents&&(g=e[f].percents);var h;if(this.minMaxField)h=g[this.minMaxField],h<c&&(c=h);else for(var k in g)g.hasOwnProperty(k)&&"percents"!=k&&"total"!=k&&(h=g[k],h<c&&(c=h))}}}return c},getMax:function(){var a,b;for(b=this.start;b<=this.end;b++){var c=this.data[b].axes[this.id].graphs,d;for(d in c)if(c.hasOwnProperty(d)){var e=this.chart.getGraphById(d);if(e.includeInMinMax&&(!e.hidden||this.includeHidden)){isNaN(a)&&
70 (a=-Infinity);this.foundGraphs=!0;e=c[d].values;this.recalculateToPercents&&(e=c[d].percents);var f;if(this.minMaxField)f=e[this.minMaxField],f>a&&(a=f);else for(var g in e)e.hasOwnProperty(g)&&"percents"!=g&&"total"!=g&&(f=e[g],f>a&&(a=f))}}}return a},dispatchZoomEvent:function(a,b){var c={type:"axisZoomed",startValue:a,endValue:b,target:this,chart:this.chart};this.fire(c.type,c)},zoomToValues:function(a,b){if(b<a){var c=b;b=a;a=c}a<this.min&&(a=this.min);b>this.max&&(b=this.max);c={type:"axisSelfZoomed"};
71 c.chart=this.chart;c.valueAxis=this;c.multiplier=this.axisWidth/Math.abs(this.getCoordinate(b)-this.getCoordinate(a));c.position="V"==this.orientation?this.reversed?this.getCoordinate(a):this.getCoordinate(b):this.reversed?this.getCoordinate(b):this.getCoordinate(a);this.fire(c.type,c)},coordinateToValue:function(a){if(isNaN(a))return NaN;var b=this.axisWidth,c=this.stepWidth,d=this.reversed,e=this.rotate,f=this.min,g=this.minReal;return!0===this.logarithmic?Math.pow(10,(e?!0===d?(b-a)/c:a/c:!0===
72 d?a/c:(b-a)/c)+Math.log(g)*Math.LOG10E):!0===d?e?f-(a-b)/c:a/c+f:e?a/c+f:f-(a-b)/c},getCoordinate:function(a){if(isNaN(a))return NaN;var b=this.rotate,c=this.reversed,d=this.axisWidth,e=this.stepWidth,f=this.min,g=this.minReal;!0===this.logarithmic?(a=Math.log(a)*Math.LOG10E-Math.log(g)*Math.LOG10E,b=b?!0===c?d-e*a:e*a:!0===c?e*a:d-e*a):b=!0===c?b?d-e*(a-f):e*(a-f):b?e*(a-f):d-e*(a-f);b=this.rotate?b+(this.x-this.viX):b+(this.y-this.viY);1E7<Math.abs(b)&&(b=1E7*(b/Math.abs(b)));return Math.round(b)},
73 synchronizeWithAxis:function(a){this.synchronizeWith=a;this.listenTo(this.synchronizeWith,"axisChanged",this.handleSynchronization)},handleSynchronization:function(a){var b=this.synchronizeWith;a=b.min;var c=b.max,b=b.step,d=this.synchronizationMultiplier;d&&(this.min=a*d,this.max=c*d,this.step=b*d,a=Math.pow(10,Math.floor(Math.log(Math.abs(this.step))*Math.LOG10E)),a=Math.abs(Math.log(Math.abs(a))*Math.LOG10E),this.maxDecCount=a=Math.round(a),this.draw())}});AmCharts.RecAxis=AmCharts.Class({construct:function(a){var b=a.chart,c=a.axisThickness,d=a.axisColor,e=a.axisAlpha,f=a.offset,g=a.dx,h=a.dy,k=a.viX,l=a.viY,m=a.viH,n=a.viW,p=b.container;"H"==a.orientation?(d=AmCharts.line(p,[0,n],[0,0],d,e,c),this.axisWidth=a.width,"bottom"==a.position?(a=c/2+f+m+l-1,c=k):(a=-c/2-f+l+h,c=g+k)):(this.axisWidth=a.height,"right"==a.position?(d=AmCharts.line(p,[0,0,-g],[0,m,m-h],d,e,c),a=l+h,c=c/2+f+g+n+k-1):(d=AmCharts.line(p,[0,0],[0,m],d,e,c),a=l,c=-c/2-f+k));d.translate(c,
74 a);b.axesSet.push(d);this.set=d}});AmCharts.RecItem=AmCharts.Class({construct:function(a,b,c,d,e,f,g,h,k,l,m){b=Math.round(b);this.value=c;void 0==c&&(c="");k||(k=0);void 0==d&&(d=!0);var n=a.chart.fontFamily,p=a.fontSize;void 0==p&&(p=a.chart.fontSize);var q=a.color;void 0==q&&(q=a.chart.color);void 0!==m&&(q=m);var r=a.chart.container,s=r.set();this.set=s;var v=a.axisThickness,w=a.axisColor,t=a.axisAlpha,u=a.tickLength,y=a.gridAlpha,E=a.gridThickness,A=a.gridColor,z=a.dashLength,K=a.fillColor,I=a.fillAlpha,F=a.labelsEnabled;m=a.labelRotation;
75 var H=a.counter,L=a.inside,ha=a.labelOffset,ba=a.dx,$=a.dy,Ra=a.orientation,na=a.position,ta=a.previousCoord,V=a.viH,X=a.viW,Z=a.offset,oa,R;g?(F=!0,isNaN(g.tickLength)||(u=g.tickLength),void 0!=g.lineColor&&(A=g.lineColor),void 0!=g.color&&(q=g.color),isNaN(g.lineAlpha)||(y=g.lineAlpha),isNaN(g.dashLength)||(z=g.dashLength),isNaN(g.lineThickness)||(E=g.lineThickness),!0===g.inside&&(L=!0),isNaN(g.labelRotation)||(m=g.labelRotation),isNaN(g.fontSize)||(p=g.fontSize),g.position&&(na=g.position),void 0!==
76 g.boldLabel&&(h=g.boldLabel),isNaN(g.labelOffset)||(ha=g.labelOffset)):""===c&&(u=0);R="start";e&&(R="middle");var Y=m*Math.PI/180,qa,G=0,B=0,W=0,ca=qa=0,ja=0;"V"==Ra&&(m=0);var x;F&&(x=a.autoWrap&&0===m?AmCharts.wrappedText(r,c,q,n,p,R,h,e,0):AmCharts.text(r,c,q,n,p,R,h),R=x.getBBox(),ca=R.width,ja=R.height);if("H"==Ra){if(0<=b&&b<=X+1&&(0<u&&0<t&&b+k<=X+1&&(oa=AmCharts.line(r,[b+k,b+k],[0,u],w,t,E),s.push(oa)),0<y&&(R=AmCharts.line(r,[b,b+ba,b+ba],[V,V+$,$],A,y,E,z),s.push(R))),B=0,G=b,g&&90==m&&
77 L&&(G-=p),!1===d?(R="start",B="bottom"==na?L?B+u:B-u:L?B-u:B+u,G+=3,e&&(G+=e/2-3,R="middle"),0<m&&(R="middle")):R="middle",1==H&&0<I&&!g&&!l&&ta<X&&(d=AmCharts.fitToBounds(b,0,X),ta=AmCharts.fitToBounds(ta,0,X),qa=d-ta,0<qa&&(fill=AmCharts.rect(r,qa,a.height,K,I),fill.translate(d-qa+ba,$),s.push(fill))),"bottom"==na?(B+=V+p/2+Z,L?(0<m?(B=V-ca/2*Math.sin(Y)-u-3,G+=ca/2*Math.cos(Y)-4+2):0>m?(B=V+ca*Math.sin(Y)-u-3+2,G+=-ca*Math.cos(Y)-ja*Math.sin(Y)-4):B-=u+p+3+3,B-=ha):(0<m?(B=V+ca/2*Math.sin(Y)+u+
78 3,G-=ca/2*Math.cos(Y)):0>m?(B=V+u+3-ca/2*Math.sin(Y)+2,G+=ca/2*Math.cos(Y)):B+=u+v+3+3,B+=ha)):(B+=$+p/2-Z,G+=ba,L?(0<m?(B=ca/2*Math.sin(Y)+u+3,G-=ca/2*Math.cos(Y)):B+=u+3,B+=ha):(0<m?(B=-(ca/2)*Math.sin(Y)-u-6,G+=ca/2*Math.cos(Y)):B-=u+p+3+v+3,B-=ha)),"bottom"==na?qa=(L?V-u-1:V+v-1)+Z:(W=ba,qa=(L?$:$-u-v+1)-Z),f&&(G+=f),f=G,0<m&&(f+=ca/2*Math.cos(Y)),x&&(p=0,L&&(p=ca/2*Math.cos(Y)),f+p>X+2||0>f))x.remove(),x=null}else{0<=b&&b<=V+1&&(0<u&&0<t&&b+k<=V+1&&(oa=AmCharts.line(r,[0,u],[b+k,b+k],w,t,E),
79 s.push(oa)),0<y&&(R=AmCharts.line(r,[0,ba,X+ba],[b,b+$,b+$],A,y,E,z),s.push(R)));R="end";if(!0===L&&"left"==na||!1===L&&"right"==na)R="start";B=b-p/2;1==H&&0<I&&!g&&!l&&(d=AmCharts.fitToBounds(b,0,V),ta=AmCharts.fitToBounds(ta,0,V),Y=d-ta,fill=AmCharts.polygon(r,[0,a.width,a.width,0],[0,0,Y,Y],K,I),fill.translate(ba,d-Y+$),s.push(fill));B+=p/2;"right"==na?(G+=ba+X+Z,B+=$,L?(f||(B-=p/2+3),G=G-(u+4)-ha):(G+=u+4+v,B-=2,G+=ha)):L?(G+=u+4-Z,f||(B-=p/2+3),g&&(G+=ba,B+=$),G+=ha):(G+=-u-v-4-2-Z,B-=2,G-=ha);
80 oa&&("right"==na?(W+=ba+Z+X,qa+=$,W=L?W-v:W+v):(W-=Z,L||(W-=u+v)));f&&(B+=f);L=-3;"right"==na&&(L+=$);x&&(B>V+1||B<L)&&(x.remove(),x=null)}oa&&oa.translate(W,qa);!1===a.visible&&(oa&&oa.remove(),x&&(x.remove(),x=null));x&&(x.attr({"text-anchor":R}),x.translate(G,B),0!==m&&x.rotate(-m,a.chart.backgroundColor),a.allLabels.push(x)," "!=c&&(this.label=x));l||(a.counter=0===H?1:0,a.previousCoord=b);0===this.set.node.childNodes.length&&this.set.remove()},graphics:function(){return this.set},getLabel:function(){return this.label}});AmCharts.RecFill=AmCharts.Class({construct:function(a,b,c,d){var e=a.dx,f=a.dy,g=a.orientation,h=0;if(c<b){var k=b;b=c;c=k}var l=d.fillAlpha;isNaN(l)&&(l=0);k=a.chart.container;d=d.fillColor;"V"==g?(b=AmCharts.fitToBounds(b,0,a.viH),c=AmCharts.fitToBounds(c,0,a.viH)):(b=AmCharts.fitToBounds(b,0,a.viW),c=AmCharts.fitToBounds(c,0,a.viW));c-=b;isNaN(c)&&(c=4,h=2,l=0);0>c&&"object"==typeof d&&(d=d.join(",").split(",").reverse());"V"==g?(a=AmCharts.rect(k,a.width,c,d,l),a.translate(e,b-h+f)):(a=AmCharts.rect(k,
81 c,a.height,d,l),a.translate(b-h+e,f));this.set=k.set([a])},graphics:function(){return this.set},getLabel:function(){}});AmCharts.AmChart=AmCharts.Class({construct:function(a){this.theme=a;this.version="3.10.0C";AmCharts.addChart(this);this.createEvents("dataUpdated","init","rendered","drawn");this.height=this.width="100%";this.dataChanged=!0;this.chartCreated=!1;this.previousWidth=this.previousHeight=0;this.backgroundColor="#FFFFFF";this.borderAlpha=this.backgroundAlpha=0;this.color=this.borderColor="#000000";this.fontFamily="Verdana";this.fontSize=11;this.usePrefixes=!1;this.precision=-1;this.percentPrecision=2;this.decimalSeparator=
82 ".";this.thousandsSeparator=",";this.labels=[];this.allLabels=[];this.titles=[];this.marginRight=this.marginLeft=this.autoMarginOffset=0;this.timeOuts=[];this.creditsPosition="top-left";var b=document.createElement("div"),c=b.style;c.overflow="hidden";c.position="relative";c.textAlign="left";this.chartDiv=b;b=document.createElement("div");c=b.style;c.overflow="hidden";c.position="relative";c.textAlign="left";this.legendDiv=b;this.titleHeight=0;this.hideBalloonTime=150;this.handDrawScatter=2;this.handDrawThickness=
83 1;this.prefixesOfBigNumbers=[{number:1E3,prefix:"k"},{number:1E6,prefix:"M"},{number:1E9,prefix:"G"},{number:1E12,prefix:"T"},{number:1E15,prefix:"P"},{number:1E18,prefix:"E"},{number:1E21,prefix:"Z"},{number:1E24,prefix:"Y"}];this.prefixesOfSmallNumbers=[{number:1E-24,prefix:"y"},{number:1E-21,prefix:"z"},{number:1E-18,prefix:"a"},{number:1E-15,prefix:"f"},{number:1E-12,prefix:"p"},{number:1E-9,prefix:"n"},{number:1E-6,prefix:"\u03bc"},{number:.001,prefix:"m"}];this.panEventsEnabled=!0;AmCharts.bezierX=
84 3;AmCharts.bezierY=6;this.product="amcharts";this.animations=[];this.balloon=new AmCharts.AmBalloon(this.theme);this.balloon.chart=this;AmCharts.applyTheme(this,a,"AmChart")},drawChart:function(){this.drawBackground();this.redrawLabels();this.drawTitles();this.brr()},drawBackground:function(){AmCharts.remove(this.background);var a=this.container,b=this.backgroundColor,c=this.backgroundAlpha,d=this.set;AmCharts.isModern||0!==c||(c=.001);var e=this.updateWidth();this.realWidth=e;var f=this.updateHeight();
85 this.realHeight=f;this.background=b=AmCharts.polygon(a,[0,e-1,e-1,0],[0,0,f-1,f-1],b,c,1,this.borderColor,this.borderAlpha);d.push(b);if(b=this.backgroundImage)this.path&&(b=this.path+b),this.bgImg=a=a.image(b,0,0,e,f),d.push(a)},drawTitles:function(){var a=this.titles;if(AmCharts.ifArray(a)){var b=20,c;for(c=0;c<a.length;c++){var d=a[c],e=d.color;void 0===e&&(e=this.color);var f=d.size;isNaN(f)&&(f=this.fontSize+2);isNaN(d.alpha);var g=this.marginLeft,e=AmCharts.text(this.container,d.text,e,this.fontFamily,
86 f);e.translate(g+(this.realWidth-this.marginRight-g)/2,b);g=!0;void 0!==d.bold&&(g=d.bold);g&&e.attr({"font-weight":"bold"});e.attr({opacity:d.alpha});b+=f+6;this.freeLabelsSet.push(e)}}},write:function(a){if(a="object"!=typeof a?document.getElementById(a):a){a.innerHTML="";this.div=a;a.style.overflow="hidden";a.style.textAlign="left";var b=this.chartDiv,c=this.legendDiv,d=this.legend,e=c.style,f=b.style;this.measure();var g,h=document.createElement("div");g=h.style;g.position="relative";this.containerDiv=
87 h;a.appendChild(h);var k=this.exportConfig;k&&AmCharts.AmExport&&!this.AmExport&&(this.AmExport=new AmCharts.AmExport(this,k));this.amExport&&AmCharts.AmExport&&(this.AmExport=AmCharts.extend(this.amExport,new AmCharts.AmExport(this),!0));this.AmExport&&this.AmExport.init&&this.AmExport.init();if(d)switch(d=this.addLegend(d,d.divId),d.position){case "bottom":h.appendChild(b);h.appendChild(c);break;case "top":h.appendChild(c);h.appendChild(b);break;case "absolute":g.width=a.style.width;g.height=a.style.height;
88 e.position="absolute";f.position="absolute";void 0!==d.left&&(e.left=d.left+"px");void 0!==d.right&&(e.right=d.right+"px");void 0!==d.top&&(e.top=d.top+"px");void 0!==d.bottom&&(e.bottom=d.bottom+"px");d.marginLeft=0;d.marginRight=0;h.appendChild(b);h.appendChild(c);break;case "right":g.width=a.style.width;g.height=a.style.height;e.position="relative";f.position="absolute";h.appendChild(b);h.appendChild(c);break;case "left":g.width=a.style.width;g.height=a.style.height;e.position="absolute";f.position=
89 "relative";h.appendChild(b);h.appendChild(c);break;case "outside":h.appendChild(b)}else h.appendChild(b);this.listenersAdded||(this.addListeners(),this.listenersAdded=!0);this.initChart()}},createLabelsSet:function(){AmCharts.remove(this.labelsSet);this.labelsSet=this.container.set();this.freeLabelsSet.push(this.labelsSet)},initChart:function(){AmCharts.applyLang(this.language);var a=this.numberFormatter;a&&(isNaN(a.precision)||(this.precision=a.precision),void 0!==a.thousandsSeparator&&(this.thousandsSeparator=
90 a.thousandsSeparator),void 0!==a.decimalSeparator&&(this.decimalSeparator=a.decimalSeparator));(a=this.percentFormatter)&&!isNaN(a.precision)&&(this.percentPrecision=a.precision);this.nf={precision:this.precision,thousandsSeparator:this.thousandsSeparator,decimalSeparator:this.decimalSeparator};this.pf={precision:this.percentPrecision,thousandsSeparator:this.thousandsSeparator,decimalSeparator:this.decimalSeparator};this.divIsFixed=AmCharts.findIfFixed(this.chartDiv);this.previousHeight=this.divRealHeight;
91 this.previousWidth=this.divRealWidth;this.destroy();this.startInterval();a=0;document.attachEvent&&!window.opera&&(a=1);this.dmouseX=this.dmouseY=0;var b=document.getElementsByTagName("html")[0];b&&window.getComputedStyle&&(b=window.getComputedStyle(b,null))&&(this.dmouseY=AmCharts.removePx(b.getPropertyValue("margin-top")),this.dmouseX=AmCharts.removePx(b.getPropertyValue("margin-left")));this.mouseMode=a;(a=this.container)?(a.container.innerHTML="",this.chartDiv.appendChild(a.container),a.setSize(this.realWidth,
92 this.realHeight)):a=new AmCharts.AmDraw(this.chartDiv,this.realWidth,this.realHeight,this);if(AmCharts.VML||AmCharts.SVG)a.handDrawn=this.handDrawn,a.handDrawScatter=this.handDrawScatter,a.handDrawThickness=this.handDrawThickness,this.container=a,this.set&&this.set.remove(),this.set=a.set(),this.gridSet&&this.gridSet.remove(),this.gridSet=a.set(),this.cursorLineSet&&this.cursorLineSet.remove(),this.cursorLineSet=a.set(),this.graphsBehindSet&&this.graphsBehindSet.remove(),this.graphsBehindSet=a.set(),
93 this.bulletBehindSet&&this.bulletBehindSet.remove(),this.bulletBehindSet=a.set(),this.columnSet&&this.columnSet.remove(),this.columnSet=a.set(),this.graphsSet&&this.graphsSet.remove(),this.graphsSet=a.set(),this.trendLinesSet&&this.trendLinesSet.remove(),this.trendLinesSet=a.set(),this.axesLabelsSet&&this.axesLabelsSet.remove(),this.axesLabelsSet=a.set(),this.axesSet&&this.axesSet.remove(),this.axesSet=a.set(),this.cursorSet&&this.cursorSet.remove(),this.cursorSet=a.set(),this.scrollbarsSet&&this.scrollbarsSet.remove(),
94 this.scrollbarsSet=a.set(),this.bulletSet&&this.bulletSet.remove(),this.bulletSet=a.set(),this.freeLabelsSet&&this.freeLabelsSet.remove(),this.freeLabelsSet=a.set(),this.balloonsSet&&this.balloonsSet.remove(),this.balloonsSet=a.set(),this.zoomButtonSet&&this.zoomButtonSet.remove(),this.zoomButtonSet=a.set(),this.linkSet&&this.linkSet.remove(),this.linkSet=a.set(),this.renderFix()},measure:function(){var a=this.div;if(a){var b=this.chartDiv,c=a.offsetWidth,d=a.offsetHeight,e=this.container;a.clientHeight&&
95 (c=a.clientWidth,d=a.clientHeight);var f=AmCharts.removePx(AmCharts.getStyle(a,"padding-left")),g=AmCharts.removePx(AmCharts.getStyle(a,"padding-right")),h=AmCharts.removePx(AmCharts.getStyle(a,"padding-top")),k=AmCharts.removePx(AmCharts.getStyle(a,"padding-bottom"));isNaN(f)||(c-=f);isNaN(g)||(c-=g);isNaN(h)||(d-=h);isNaN(k)||(d-=k);f=a.style;a=f.width;f=f.height;-1!=a.indexOf("px")&&(c=AmCharts.removePx(a));-1!=f.indexOf("px")&&(d=AmCharts.removePx(f));a=AmCharts.toCoordinate(this.width,c);f=AmCharts.toCoordinate(this.height,
96 d);this.balloon=AmCharts.processObject(this.balloon,AmCharts.AmBalloon,this.theme);this.balloon.chart=this;(a!=this.previousWidth||f!=this.previousHeight)&&0<a&&0<f&&(b.style.width=a+"px",b.style.height=f+"px",e&&e.setSize(a,f));this.balloon.setBounds(2,2,a-2,f);this.realWidth=a;this.realHeight=f;this.divRealWidth=c;this.divRealHeight=d}},destroy:function(){this.chartDiv.innerHTML="";this.clearTimeOuts();this.interval&&clearInterval(this.interval);this.interval=NaN},clearTimeOuts:function(){var a=
97 this.timeOuts;if(a){var b;for(b=0;b<a.length;b++)clearTimeout(a[b])}this.timeOuts=[]},clear:function(a){AmCharts.callMethod("clear",[this.chartScrollbar,this.scrollbarV,this.scrollbarH,this.chartCursor]);this.chartCursor=this.scrollbarH=this.scrollbarV=this.chartScrollbar=null;this.clearTimeOuts();this.interval&&clearInterval(this.interval);this.container&&(this.container.remove(this.chartDiv),this.container.remove(this.legendDiv));a||AmCharts.removeChart(this)},setMouseCursor:function(a){"auto"==
98 a&&AmCharts.isNN&&(a="default");this.chartDiv.style.cursor=a;this.legendDiv.style.cursor=a},redrawLabels:function(){this.labels=[];var a=this.allLabels;this.createLabelsSet();var b;for(b=0;b<a.length;b++)this.drawLabel(a[b])},drawLabel:function(a){if(this.container){var b=a.y,c=a.text,d=a.align,e=a.size,f=a.color,g=a.rotation,h=a.alpha,k=a.bold,l=AmCharts.toCoordinate(a.x,this.realWidth),b=AmCharts.toCoordinate(b,this.realHeight);l||(l=0);b||(b=0);void 0===f&&(f=this.color);isNaN(e)&&(e=this.fontSize);
99 d||(d="start");"left"==d&&(d="start");"right"==d&&(d="end");"center"==d&&(d="middle",g?b=this.realHeight-b+b/2:l=this.realWidth/2-l);void 0===h&&(h=1);void 0===g&&(g=0);b+=e/2;c=AmCharts.text(this.container,c,f,this.fontFamily,e,d,k,h);c.translate(l,b);0!==g&&c.rotate(g);a.url&&(c.setAttr("cursor","pointer"),c.click(function(){AmCharts.getURL(a.url)}));this.labelsSet.push(c);this.labels.push(c)}},addLabel:function(a,b,c,d,e,f,g,h,k,l){a={x:a,y:b,text:c,align:d,size:e,color:f,alpha:h,rotation:g,bold:k,
100 url:l};this.container&&this.drawLabel(a);this.allLabels.push(a)},clearLabels:function(){var a=this.labels,b;for(b=a.length-1;0<=b;b--)a[b].remove();this.labels=[];this.allLabels=[]},updateHeight:function(){var a=this.divRealHeight,b=this.legend;if(b){var c=this.legendDiv.offsetHeight,b=b.position;if("top"==b||"bottom"==b){a-=c;if(0>a||isNaN(a))a=0;this.chartDiv.style.height=a+"px"}}return a},updateWidth:function(){var a=this.divRealWidth,b=this.divRealHeight,c=this.legend;if(c){var d=this.legendDiv,
101 e=d.offsetWidth;isNaN(c.width)||(e=c.width);var f=d.offsetHeight,d=d.style,g=this.chartDiv.style,c=c.position;if("right"==c||"left"==c){a-=e;if(0>a||isNaN(a))a=0;g.width=a+"px";"left"==c?g.left=e+"px":d.left=a+"px";d.top=(b-f)/2+"px"}}return a},getTitleHeight:function(){var a=0,b=this.titles;if(0<b.length){var a=15,c;for(c=0;c<b.length;c++){var d=b[c].size;isNaN(d)&&(d=this.fontSize+2);a+=d+6}}return a},addTitle:function(a,b,c,d,e){isNaN(b)&&(b=this.fontSize+2);a={text:a,size:b,color:c,alpha:d,bold:e};
102 this.titles.push(a);return a},addMouseWheel:function(){var a=this;window.addEventListener&&!a.wheelAdded&&(window.addEventListener("DOMMouseScroll",function(b){a.handleWheel.call(a,b)},!1),document.addEventListener("mousewheel",function(b){a.handleWheel.call(a,b)},!1),a.wheelAdded=!0)},handleWheel:function(a){if(this.mouseIsOver){var b=0;a||(a=window.event);a.wheelDelta?b=a.wheelDelta/120:a.detail&&(b=-a.detail/3);b&&this.handleWheelReal(b,a.shiftKey);a.preventDefault&&a.preventDefault()}},handleWheelReal:function(a){},
103 addListeners:function(){var a=this,b=a.chartDiv;document.addEventListener?(a.panEventsEnabled&&"ontouchstart"in document.documentElement&&(b.addEventListener("touchstart",function(b){a.handleTouchMove.call(a,b);a.handleTouchStart.call(a,b)},!0),b.addEventListener("touchmove",function(b){a.handleTouchMove.call(a,b)},!0),b.addEventListener("touchend",function(b){a.handleTouchEnd.call(a,b)},!0)),b.addEventListener("mousedown",function(b){a.handleMouseDown.call(a,b)},!0),b.addEventListener("mouseover",
104 function(b){a.handleMouseOver.call(a,b)},!0),b.addEventListener("mouseout",function(b){a.handleMouseOut.call(a,b)},!0)):(b.attachEvent("onmousedown",function(b){a.handleMouseDown.call(a,b)}),b.attachEvent("onmouseover",function(b){a.handleMouseOver.call(a,b)}),b.attachEvent("onmouseout",function(b){a.handleMouseOut.call(a,b)}))},dispDUpd:function(){var a;this.dispatchDataUpdated&&(this.dispatchDataUpdated=!1,a="dataUpdated",this.fire(a,{type:a,chart:this}));this.chartCreated||(a="init",this.fire(a,
105 {type:a,chart:this}));this.chartRendered||(a="rendered",this.fire(a,{type:a,chart:this}),this.chartRendered=!0);a="drawn";this.fire(a,{type:a,chart:this})},validateSize:function(){var a=this;a.measure();var b=a.legend;if((a.realWidth!=a.previousWidth||a.realHeight!=a.previousHeight)&&0<a.realWidth&&0<a.realHeight){a.sizeChanged=!0;if(b){clearTimeout(a.legendInitTO);var c=setTimeout(function(){b.invalidateSize()},100);a.timeOuts.push(c);a.legendInitTO=c}a.marginsUpdated="xy"!=a.type?!1:!0;clearTimeout(a.initTO);
106 c=setTimeout(function(){a.initChart()},150);a.timeOuts.push(c);a.initTO=c}a.renderFix();b&&b.renderFix()},invalidateSize:function(){this.previousHeight=this.previousWidth=NaN;this.invalidateSizeReal()},invalidateSizeReal:function(){var a=this;a.marginsUpdated=!1;clearTimeout(a.validateTO);var b=setTimeout(function(){a.validateSize()},5);a.timeOuts.push(b);a.validateTO=b},validateData:function(a){this.chartCreated&&(this.dataChanged=!0,this.marginsUpdated="xy"!=this.type?!1:!0,this.initChart(a))},
107 validateNow:function(){this.chartRendered=this.listenersAdded=!1;this.write(this.div)},showItem:function(a){a.hidden=!1;this.initChart()},hideItem:function(a){a.hidden=!0;this.initChart()},hideBalloon:function(){var a=this;clearInterval(a.hoverInt);clearTimeout(a.balloonTO);a.hoverInt=setTimeout(function(){a.hideBalloonReal.call(a)},a.hideBalloonTime)},cleanChart:function(){},hideBalloonReal:function(){var a=this.balloon;a&&a.hide()},showBalloon:function(a,b,c,d,e){var f=this;clearTimeout(f.balloonTO);
108 clearInterval(f.hoverInt);f.balloonTO=setTimeout(function(){f.showBalloonReal.call(f,a,b,c,d,e)},1)},showBalloonReal:function(a,b,c,d,e){this.handleMouseMove();var f=this.balloon;f.enabled&&(f.followCursor(!1),f.changeColor(b),!c||f.fixedPosition?(f.setPosition(d,e),f.followCursor(!1)):f.followCursor(!0),a&&f.showBalloon(a))},handleTouchMove:function(a){this.hideBalloon();var b=this.chartDiv;a.touches&&(a=a.touches.item(0),this.mouseX=a.pageX-AmCharts.findPosX(b),this.mouseY=a.pageY-AmCharts.findPosY(b))},
109 handleMouseOver:function(a){AmCharts.resetMouseOver();this.mouseIsOver=!0},handleMouseOut:function(a){AmCharts.resetMouseOver();this.mouseIsOver=!1},handleMouseMove:function(a){if(this.mouseIsOver){var b=this.chartDiv;a||(a=window.event);var c,d;if(a){this.posX=AmCharts.findPosX(b);this.posY=AmCharts.findPosY(b);switch(this.mouseMode){case 1:c=a.clientX-this.posX;d=a.clientY-this.posY;if(!this.divIsFixed){var b=document.body,e,f;b&&(e=b.scrollLeft,y1=b.scrollTop);if(b=document.documentElement)f=b.scrollLeft,
110 y2=b.scrollTop;e=Math.max(e,f);f=Math.max(y1,y2);c+=e;d+=f}break;case 0:this.divIsFixed?(c=a.clientX-this.posX,d=a.clientY-this.posY):(c=a.pageX-this.posX,d=a.pageY-this.posY)}a.touches&&(a=a.touches.item(0),c=a.pageX-this.posX,d=a.pageY-this.posY);this.mouseX=c-this.dmouseX;this.mouseY=d-this.dmouseY}}},handleTouchStart:function(a){this.handleMouseDown(a)},handleTouchEnd:function(a){AmCharts.resetMouseOver();this.handleReleaseOutside(a)},handleReleaseOutside:function(a){},handleMouseDown:function(a){AmCharts.resetMouseOver();
111 this.mouseIsOver=!0;a&&a.preventDefault&&a.preventDefault()},addLegend:function(a,b){a=AmCharts.processObject(a,AmCharts.AmLegend,this.theme);a.divId=b;var c;c="object"!=typeof b&&b?document.getElementById(b):b;this.legend=a;a.chart=this;c?(a.div=c,a.position="outside",a.autoMargins=!1):a.div=this.legendDiv;c=this.handleLegendEvent;this.listenTo(a,"showItem",c);this.listenTo(a,"hideItem",c);this.listenTo(a,"clickMarker",c);this.listenTo(a,"rollOverItem",c);this.listenTo(a,"rollOutItem",c);this.listenTo(a,
112 "rollOverMarker",c);this.listenTo(a,"rollOutMarker",c);this.listenTo(a,"clickLabel",c);return a},removeLegend:function(){this.legend=void 0;this.legendDiv.innerHTML=""},handleResize:function(){(AmCharts.isPercents(this.width)||AmCharts.isPercents(this.height))&&this.invalidateSizeReal();this.renderFix()},renderFix:function(){if(!AmCharts.VML){var a=this.container;a&&a.renderFix()}},getSVG:function(){if(AmCharts.hasSVG)return this.container},animate:function(a,b,c,d,e,f,g){a["an_"+b]&&AmCharts.removeFromArray(this.animations,
113 a["an_"+b]);c={obj:a,frame:0,attribute:b,from:c,to:d,time:e,effect:f,suffix:g};a["an_"+b]=c;this.animations.push(c);return c},setLegendData:function(a){var b=this.legend;b&&b.setData(a)},startInterval:function(){var a=this;clearInterval(a.interval);a.interval=setInterval(function(){a.updateAnimations.call(a)},AmCharts.updateRate)},stopAnim:function(a){AmCharts.removeFromArray(this.animations,a)},updateAnimations:function(){var a;this.container&&this.container.update();for(a=this.animations.length-
114 1;0<=a;a--){var b=this.animations[a],c=1E3*b.time/AmCharts.updateRate,d=b.frame+1,e=b.obj,f=b.attribute;if(d<=c){b.frame++;var g=Number(b.from),h=Number(b.to)-g,c=AmCharts[b.effect](0,d,g,h,c);0===h?(this.animations.splice(a,1),e.node.style[f]=Number(b.to)+b.suffix):e.node.style[f]=c+b.suffix}else e.node.style[f]=Number(b.to)+b.suffix,this.animations.splice(a,1)}},inIframe:function(){try{return window.self!==window.top}catch(a){return!0}},brr:function(){var a=window.location.hostname.split("."),b;
115 2<=a.length&&(b=a[a.length-2]+"."+a[a.length-1]);this.amLink&&(a=this.amLink.parentNode)&&a.removeChild(this.amLink);a=this.creditsPosition;if("amcharts.com"!=b||!0===this.inIframe()){var c=b=0,d=this.realWidth,e=this.realHeight;if("serial"==this.type||"xy"==this.type)b=this.marginLeftReal,c=this.marginTopReal,d=b+this.plotAreaWidth,e=c+this.plotAreaHeight;var f="http://www.amcharts.com/javascript-charts/",g="JavaScript charts",h="JS chart by amCharts";"ammap"==this.product&&(f="http://www.ammap.com/javascript-maps/",
116 g="Interactive JavaScript maps",h="JS map by amCharts");var k=document.createElement("a"),h=document.createTextNode(h);k.setAttribute("href",f);k.setAttribute("title",g);k.appendChild(h);this.chartDiv.appendChild(k);this.amLink=k;f=k.style;f.position="absolute";f.textDecoration="none";f.color=this.color;f.fontFamily=this.fontFamily;f.fontSize=this.fontSize+"px";f.opacity=.7;f.display="block";var g=k.offsetWidth,k=k.offsetHeight,h=5+b,l=c+5;"bottom-left"==a&&(h=5+b,l=e-k-3);"bottom-right"==a&&(h=d-
117 g-5,l=e-k-3);"top-right"==a&&(h=d-g-5,l=c+5);f.left=h+"px";f.top=l+"px"}}});AmCharts.Slice=AmCharts.Class({construct:function(){}});AmCharts.SerialDataItem=AmCharts.Class({construct:function(){}});AmCharts.GraphDataItem=AmCharts.Class({construct:function(){}});AmCharts.Guide=AmCharts.Class({construct:function(a){this.cname="Guide";AmCharts.applyTheme(this,a,this.cname)}});AmCharts.AmGraph=AmCharts.Class({construct:function(a){this.cname="AmGraph";this.createEvents("rollOverGraphItem","rollOutGraphItem","clickGraphItem","doubleClickGraphItem","rightClickGraphItem","clickGraph","rollOverGraph","rollOutGraph");this.type="line";this.stackable=!0;this.columnCount=1;this.columnIndex=0;this.centerCustomBullets=this.showBalloon=!0;this.maxBulletSize=50;this.minBulletSize=4;this.balloonText="[[value]]";this.hidden=this.scrollbar=this.animationPlayed=!1;this.pointPosition="middle";
118 this.depthCount=1;this.includeInMinMax=!0;this.negativeBase=0;this.visibleInLegend=!0;this.showAllValueLabels=!1;this.showBulletsAt=this.showBalloonAt="close";this.lineThickness=1;this.dashLength=0;this.connect=!0;this.lineAlpha=1;this.bullet="none";this.bulletBorderThickness=2;this.bulletBorderAlpha=0;this.bulletAlpha=1;this.bulletSize=8;this.hideBulletsCount=this.bulletOffset=0;this.labelPosition="top";this.cornerRadiusTop=0;this.cursorBulletAlpha=1;this.gradientOrientation="vertical";this.dy=this.dx=
119 0;this.periodValue="";this.clustered=!0;this.periodSpan=1;this.y=this.x=0;this.switchable=!0;this.tcc=this.minDistance=1;AmCharts.applyTheme(this,a,this.cname)},draw:function(){var a=this.chart;isNaN(this.precision)||(this.numberFormatter?this.numberFormatter.precision=this.precision:this.numberFormatter={precision:this.precision,decimalSeparator:a.decimalSeparator,thousandsSeparator:a.thousandsSeparator});var b=a.container;this.container=b;this.destroy();var c=b.set(),d=b.set();this.behindColumns?
120 (a.graphsBehindSet.push(c),a.bulletBehindSet.push(d)):(a.graphsSet.push(c),a.bulletSet.push(d));var e=this.bulletAxis;AmCharts.isString(e)&&(this.bulletAxis=a.getValueAxisById(e));this.bulletSet=d;this.scrollbar||(e=a.marginLeftReal,a=a.marginTopReal,c.translate(e,a),d.translate(e,a));b=b.set();AmCharts.remove(this.columnsSet);c.push(b);this.set=c;this.columnsSet=b;this.columnsArray=[];this.ownColumns=[];this.allBullets=[];this.animationArray=[];AmCharts.ifArray(this.data)&&(c=!1,"xy"==this.chart.type?
121 this.xAxis.axisCreated&&this.yAxis.axisCreated&&(c=!0):this.valueAxis.axisCreated&&(c=!0),!this.hidden&&c&&this.createGraph())},createGraph:function(){var a=this,b=a.chart;"inside"==a.labelPosition&&"column"!=a.type&&(a.labelPosition="bottom");a.startAlpha=b.startAlpha;a.seqAn=b.sequencedAnimation;a.baseCoord=a.valueAxis.baseCoord;void 0===a.fillAlphas&&(a.fillAlphas=0);a.bulletColorR=a.bulletColor;void 0===a.bulletColorR&&(a.bulletColorR=a.lineColorR,a.bulletColorNegative=a.negativeLineColor);void 0===
122 a.bulletAlpha&&(a.bulletAlpha=a.lineAlpha);clearTimeout(a.playedTO);if(!isNaN(a.valueAxis.min)&&!isNaN(a.valueAxis.max)){switch(b.type){case "serial":a.categoryAxis&&(a.createSerialGraph(),"candlestick"==a.type&&1>a.valueAxis.minMaxMultiplier&&a.positiveClip(a.set));break;case "radar":a.createRadarGraph();break;case "xy":a.createXYGraph(),a.positiveClip(a.set)}a.playedTO=setTimeout(function(){a.setAnimationPlayed.call(a)},500*a.chart.startDuration)}},setAnimationPlayed:function(){this.animationPlayed=
123 !0},createXYGraph:function(){var a=[],b=[],c=this.xAxis,d=this.yAxis;this.pmh=d.viH+1;this.pmw=c.viW+1;this.pmy=this.pmx=0;var e;for(e=this.start;e<=this.end;e++){var f=this.data[e].axes[c.id].graphs[this.id],g=f.values,h=g.x,k=g.y,g=c.getCoordinate(h),l=d.getCoordinate(k);!isNaN(h)&&!isNaN(k)&&(a.push(g),b.push(l),(h=this.createBullet(f,g,l,e))||(h=0),k=this.labelText)&&(f=this.createLabel(f,g,l,k),this.allBullets.push(f),this.positionLabel(g,l,f,this.labelPosition,h))}this.drawLineGraph(a,b);this.launchAnimation()},
124 createRadarGraph:function(){var a=this.valueAxis.stackType,b=[],c=[],d,e,f;for(f=this.start;f<=this.end;f++){var g=this.data[f].axes[this.valueAxis.id].graphs[this.id],h;h="none"==a||"3d"==a?g.values.value:g.values.close;if(isNaN(h))this.drawLineGraph(b,c),b=[],c=[];else{var k=this.y-(this.valueAxis.getCoordinate(h)-this.height),l=180-360/(this.end-this.start+1)*f;h=k*Math.sin(l/180*Math.PI);k*=Math.cos(l/180*Math.PI);b.push(h);c.push(k);(l=this.createBullet(g,h,k,f))||(l=0);var m=this.labelText;
125 m&&(g=this.createLabel(g,h,k,m),this.allBullets.push(g),this.positionLabel(h,k,g,this.labelPosition,l));isNaN(d)&&(d=h);isNaN(e)&&(e=k)}}b.push(d);c.push(e);this.drawLineGraph(b,c);this.launchAnimation()},positionLabel:function(a,b,c,d,e){var f=c.getBBox();switch(d){case "left":a-=(f.width+e)/2+2;break;case "top":b-=(e+f.height)/2+1;break;case "right":a+=(f.width+e)/2+2;break;case "bottom":b+=(e+f.height)/2+1}c.translate(a,b)},getGradRotation:function(){var a=270;"horizontal"==this.gradientOrientation&&
126 (a=0);return this.gradientRotation=a},createSerialGraph:function(){this.dashLengthSwitched=this.fillColorsSwitched=this.lineColorSwitched=void 0;var a=this.chart,b=this.id,c=this.index,d=this.data,e=this.chart.container,f=this.valueAxis,g=this.type,h=this.columnWidthReal,k=this.showBulletsAt;isNaN(this.columnWidth)||(h=this.columnWidth);isNaN(h)&&(h=.8);var l=this.useNegativeColorIfDown,m=this.width,n=this.height,p=this.y,q=this.rotate,r=this.columnCount,s=AmCharts.toCoordinate(this.cornerRadiusTop,
127 h/2),v=this.connect,w=[],t=[],u,y,E,A,z=this.chart.graphs.length,K,I=this.dx/this.tcc,F=this.dy/this.tcc;var H=f.stackType,L=this.labelPosition,ha=this.start,ba=this.end,$=this.scrollbar,Ra=this.categoryAxis,na=this.baseCoord,ta=this.negativeBase,V=this.columnIndex,X=this.lineThickness,Z=this.lineAlpha,oa=this.lineColorR,R=this.dashLength,Y=this.set,qa=L,G=this.getGradRotation(),B=this.chart.columnSpacing,W=Ra.cellWidth,ca=(W*h-r)/r;B>ca&&(B=ca);var ja,x,ab,jb=n+1,kb=m+1,bb=
128 0,lb=0,mb,nb,cb,db,ob=this.fillColorsR,Da=this.negativeFillColors,wa=this.negativeLineColor,Sa=this.fillAlphas,Ta=this.negativeFillAlphas;"object"==typeof Sa&&(Sa=Sa[0]);"object"==typeof Ta&&(Ta=Ta[0]);var eb=f.getCoordinate(f.min);f.logarithmic&&(eb=f.getCoordinate(f.minReal));this.minCoord=eb;this.resetBullet&&(this.bullet="none");if(!($||"line"!=g&&"smoothedLine"!=g&&"step"!=g||(1==d.length&&"step"!=g&&"none"==this.bullet&&(this.bullet="round",this.resetBullet=!0),!Da&&void 0==wa||l))){var La=
129 ta;La>f.max&&(La=f.max);La<f.min&&(La=f.min);f.logarithmic&&(La=f.minReal);var Aa=f.getCoordinate(La),Fb=f.getCoordinate(f.max);q?(jb=n,kb=Math.abs(Fb-Aa),mb=n,nb=Math.abs(eb-Aa),db=lb=0,f.reversed?(bb=0,cb=Aa):(bb=Aa,cb=0)):(kb=m,jb=Math.abs(Fb-Aa),nb=m,mb=Math.abs(eb-Aa),cb=bb=0,f.reversed?(db=p,lb=Aa):db=Aa+1)}var Ba=Math.round;this.pmx=Ba(bb);this.pmy=Ba(lb);this.pmh=Ba(jb);this.pmw=Ba(kb);this.nmx=Ba(cb);this.nmy=Ba(db);this.nmh=Ba(mb);this.nmw=Ba(nb);AmCharts.isModern||(this.nmy=this.nmx=0,
130 this.nmh=this.height);h="column"==g?(W*h-B*(r-1))/r:W*h;1>h&&(h=1);var J;if("line"==g||"step"==g||"smoothedLine"==g){if(0<ha){for(J=ha-1;-1<J;J--)if(ja=d[J],x=ja.axes[f.id].graphs[b],ab=x.values.value,!isNaN(ab)){ha=J;break}if(this.lineColorField)for(J=ha;-1<J;J--)if(ja=d[J],x=ja.axes[f.id].graphs[b],x.lineColor){this.bulletColorSwitched=this.lineColorSwitched=x.lineColor;break}if(this.fillColorsField)for(J=ha;-1<J;J--)if(ja=d[J],x=ja.axes[f.id].graphs[b],x.fillColors){this.fillColorsSwitched=x.fillColors;
131 break}if(this.dashLengthField)for(J=ha;-1<J;J--)if(ja=d[J],x=ja.axes[f.id].graphs[b],!isNaN(x.dashLength)){this.dashLengthSwitched=x.dashLength;break}}if(ba<d.length-1)for(J=ba+1;J<d.length;J++)if(ja=d[J],x=ja.axes[f.id].graphs[b],ab=x.values.value,!isNaN(ab)){ba=J;break}}ba<d.length-1&&ba++;var O=[],P=[],Ea=!1;if("line"==g||"step"==g||"smoothedLine"==g)if(this.stackable&&"regular"==H||"100%"==H||this.fillToGraph)Ea=!0;var Gb=this.noStepRisers,fb=-1E3,gb=-1E3,hb=this.minDistance,Ma=!0,Ua=!1;for(J=
132 ha;J<=ba;J++){ja=d[J];x=ja.axes[f.id].graphs[b];x.index=J;var Va,Na=NaN;if(l&&void 0==this.openField)for(var pb=J+1;pb<d.length&&(!d[pb]||!(Va=d[J+1].axes[f.id].graphs[b])||!Va.values||(Na=Va.values.value,isNaN(Na)));pb++);var S,T,Q,da,la=NaN,D=NaN,C=NaN,N=NaN,M=NaN,Fa=NaN,xa=NaN,Ga=NaN,ya=NaN,aa=NaN,ia=NaN,ea=NaN,fa=NaN,U=NaN,qb=NaN,rb=NaN,ka=NaN,ra=void 0,Ca=ob,Wa=Sa,ua=oa,pa,sa,Xa=this.pattern;void 0!=x.pattern&&(Xa=x.pattern);void 0!=x.color&&(Ca=x.color);x.fillColors&&(Ca=x.fillColors);isNaN(x.alpha)||
133 (Wa=x.alpha);isNaN(x.dashLength)||(R=x.dashLength);var va=x.values;f.recalculateToPercents&&(va=x.percents);if(va){U=this.stackable&&"none"!=H&&"3d"!=H?va.close:va.value;if("candlestick"==g||"ohlc"==g)U=va.close,rb=va.low,xa=f.getCoordinate(rb),qb=va.high,ya=f.getCoordinate(qb);ka=va.open;C=f.getCoordinate(U);isNaN(ka)||(M=f.getCoordinate(ka),l&&(Na=ka,ka=M=NaN));l&&(void 0==this.openField?Va&&(Va.isNegative=Na<U?!0:!1):x.isNegative=Na>U?!0:!1);if(!$)switch(this.showBalloonAt){case "close":x.y=C;
134 break;case "open":x.y=M;break;case "high":x.y=ya;break;case "low":x.y=xa}var la=ja.x[Ra.id],Oa=this.periodSpan-1,ma=Math.floor(W/2)+Math.floor(Oa*W/2),za=ma,Hb=0;"left"==this.stepDirection&&(Hb=(2*W+Oa*W)/2,la-=Hb);"start"==this.pointPosition&&(la-=W/2+Math.floor(Oa*W/2),ma=0,za=Math.floor(W)+Math.floor(Oa*W));"end"==this.pointPosition&&(la+=W/2+Math.floor(Oa*W/2),ma=Math.floor(W)+Math.floor(Oa*W),za=0);if(Gb){var sb=this.columnWidth;isNaN(sb)||(ma*=sb,za*=sb)}$||(x.x=la);-1E5>la&&(la=-1E5);la>m+
135 1E5&&(la=m+1E5);q?(D=C,N=M,M=C=la,isNaN(ka)&&!this.fillToGraph&&(N=na),Fa=xa,Ga=ya):(N=D=la,isNaN(ka)&&!this.fillToGraph&&(M=na));U<ka&&(x.isNegative=!0,Da&&(Ca=Da),Ta&&(Wa=Ta),void 0!=wa&&(ua=wa));Ua=!1;isNaN(U)||(l?U>Na?(Ma&&(Ua=!0),Ma=!1):(Ma||(Ua=!0),Ma=!0):x.isNegative=U<ta?!0:!1);switch(g){case "line":if(isNaN(U))v||(this.drawLineGraph(w,t,O,P),w=[],t=[],O=[],P=[]);else{if(Math.abs(D-fb)>=hb||Math.abs(C-gb)>=hb)w.push(D),t.push(C),fb=D,gb=C;aa=D;ia=C;ea=D;fa=C;!Ea||isNaN(M)||isNaN(N)||(O.push(N),
136 P.push(M));if(Ua||void 0!=x.lineColor||void 0!=x.fillColors||!isNaN(x.dashLength))this.drawLineGraph(w,t,O,P),w=[D],t=[C],O=[],P=[],!Ea||isNaN(M)||isNaN(N)||(O.push(N),P.push(M)),l?Ma?(this.lineColorSwitched=oa,this.fillColorsSwitched=ob):(this.lineColorSwitched=wa,this.fillColorsSwitched=Da):(this.lineColorSwitched=x.lineColor,this.fillColorsSwitched=x.fillColors),this.dashLengthSwitched=x.dashLength;x.gap&&(this.drawLineGraph(w,t,O,P),w=[],t=[],O=[],P=[])}break;case "smoothedLine":if(isNaN(U))v||
137 (this.drawSmoothedGraph(w,t,O,P),w=[],t=[],O=[],P=[]);else{if(Math.abs(D-fb)>=hb||Math.abs(C-gb)>=hb)w.push(D),t.push(C),fb=D,gb=C;aa=D;ia=C;ea=D;fa=C;!Ea||isNaN(M)||isNaN(N)||(O.push(N),P.push(M));void 0==x.lineColor&&void 0==x.fillColors&&isNaN(x.dashLength)||(this.drawSmoothedGraph(w,t,O,P),w=[D],t=[C],O=[],P=[],!Ea||isNaN(M)||isNaN(N)||(O.push(N),P.push(M)),this.lineColorSwitched=x.lineColor,this.fillColorsSwitched=x.fillColors,this.dashLengthSwitched=x.dashLength);x.gap&&(this.drawSmoothedGraph(w,
138 t,O,P),w=[],t=[],O=[],P=[])}break;case "step":if(!isNaN(U)){if(void 0==x.lineColor&&void 0==x.fillColors&&isNaN(x.dashLength)||(this.drawLineGraph(w,t,O,P),w=[],t=[],O=[],P=[],this.lineColorSwitched=x.lineColor,this.fillColorsSwitched=x.fillColors,this.dashLengthSwitched=x.dashLength),q?(isNaN(u)||(w.push(u),t.push(C-ma)),t.push(C-ma),w.push(D),t.push(C+za),w.push(D),!Ea||isNaN(M)||isNaN(N)||(O.push(E),P.push(M-ma),O.push(N),P.push(M-ma),O.push(N),P.push(M+za))):(isNaN(y)||(t.push(y),w.push(u),t.push(y),
139 w.push(D-ma)),w.push(D-ma),t.push(C),w.push(D+za),t.push(C),!Ea||isNaN(M)||isNaN(N)||(O.push(N-ma),P.push(A),O.push(N-ma),P.push(M),O.push(N+za),P.push(M))),u=D,y=C,E=N,A=M,aa=D,ia=C,ea=D,fa=C,Ua&&(this.drawLineGraph(w,t,O,P),w=[],t=[],O=[],P=[],l&&(Ma?(this.lineColorSwitched=oa,this.fillColorsSwitched=ob):(this.lineColorSwitched=wa,this.fillColorsSwitched=Da))),Gb||x.gap)u=y=NaN,this.drawLineGraph(w,t,O,P),w=[],t=[],O=[],P=[]}else if(!v){if(1>=this.periodSpan||1<this.periodSpan&&D-u>ma+za)u=y=NaN;
140 this.drawLineGraph(w,t,O,P);w=[];t=[];O=[];P=[]}break;case "column":pa=ua;void 0!=x.lineColor&&(pa=x.lineColor);if(!isNaN(U)){l||(x.isNegative=U<ta?!0:!1);x.isNegative&&(Da&&(Ca=Da),void 0!=wa&&(pa=wa));var Ib=f.min,Jb=f.max;if(!(U<Ib&&ka<Ib||U>Jb&&ka>Jb))if(q){"3d"==H?(T=C-(r/2-this.depthCount+1)*(h+B)+B/2+F*V,S=N+I*V):(T=Math.floor(C-(r/2-V)*(h+B)+B/2),S=N);Q=h;aa=D;ia=T+h/2;ea=D;fa=T+h/2;T+Q>n&&(Q=n-T);0>T&&(Q+=T,T=0);da=D-N;var Vb=S;S=AmCharts.fitToBounds(S,0,m);da+=Vb-S;da=AmCharts.fitToBounds(da,
141 -S,m-S+I*V);T<n&&0<Q&&(ra=new AmCharts.Cuboid(e,da,Q,I-a.d3x,F-a.d3y,Ca,Wa,X,pa,Z,G,s,q,R,Xa),"bottom"!=L&&"inside"!=L&&"middle"!=L&&(L=f.reversed?"left":"right",0>U&&(L=f.reversed?"right":"left")),"regular"==H||"100%"==H)&&(aa+=this.dx)}else{"3d"==H?(S=D-(r/2-this.depthCount+1)*(h+B)+B/2+I*V,T=M+F*V):(S=D-(r/2-V)*(h+B)+B/2,T=M);Q=h;aa=S+h/2;ia=C;ea=S+h/2;fa=C;S+Q>m+V*I&&(Q=m-S+V*I);0>S&&(Q+=S,S=0);da=C-M;var Wb=T;T=AmCharts.fitToBounds(T,this.dy,n);da+=Wb-T;da=AmCharts.fitToBounds(da,-T+F*V,n-T);
142 if(S<m+V*I&&0<Q)if(ra=new AmCharts.Cuboid(e,Q,da,I-a.d3x,F-a.d3y,Ca,Wa,X,pa,this.lineAlpha,G,s,q,R,Xa),0>U&&"middle"!=L&&"inside"!=L)L="bottom";else if(L=qa,"regular"==H||"100%"==H)ia+=this.dy}if(ra&&(sa=ra.set,x.columnGraphics=sa,sa.translate(S,T),this.columnsSet.push(sa),(x.url||this.showHandOnHover)&&sa.setAttr("cursor","pointer"),!$)){"none"==H&&(K=q?(this.end+1-J)*z-c:z*J+c);"3d"==H&&(q?(K=(this.end+1-J)*z-c-1E3*this.depthCount,aa+=I*this.columnIndex,ea+=I*this.columnIndex,x.y+=I*this.columnIndex):
143 (K=(z-c)*(J+1)+1E3*this.depthCount,aa+=3,ia+=F*this.columnIndex+7,fa+=F*this.columnIndex,x.y+=F*this.columnIndex));if("regular"==H||"100%"==H)"inside"!=L&&(L="middle"),K=q?0<va.value?(this.end+1-J)*z+c:(this.end+1-J)*z-c:0<va.value?z*J+c:z*J-c;this.columnsArray.push({column:ra,depth:K});x.x=q?T+Q/2:S+Q/2;this.ownColumns.push(ra);this.animateColumns(ra,J,D,N,C,M);this.addListeners(sa,x)}}break;case "candlestick":if(!isNaN(ka)&&!isNaN(U)){var ib,tb;pa=ua;void 0!=x.lineColor&&(pa=x.lineColor);if(q){if(T=
144 C-h/2,S=N,Q=h,T+Q>n&&(Q=n-T),0>T&&(Q+=T,T=0),T<n&&0<Q){var ub,vb;U>ka?(ub=[D,Ga],vb=[N,Fa]):(ub=[N,Ga],vb=[D,Fa]);!isNaN(Ga)&&!isNaN(Fa)&&C<n&&0<C&&(ib=AmCharts.line(e,ub,[C,C],pa,Z,X),tb=AmCharts.line(e,vb,[C,C],pa,Z,X));da=D-N;ra=new AmCharts.Cuboid(e,da,Q,I,F,Ca,Sa,X,pa,Z,G,s,q,R,Xa)}}else if(S=D-h/2,T=M+X/2,Q=h,S+Q>m&&(Q=m-S),0>S&&(Q+=S,S=0),da=C-M,S<m&&0<Q){var ra=new AmCharts.Cuboid(e,Q,da,I,F,Ca,Wa,X,pa,Z,G,s,q,R,Xa),wb,xb;U>ka?(wb=[C,ya],xb=[M,xa]):(wb=[M,ya],xb=[C,xa]);!isNaN(ya)&&!isNaN(xa)&&
145 D<m&&0<D&&(ib=AmCharts.line(e,[D,D],wb,pa,Z,X),tb=AmCharts.line(e,[D,D],xb,pa,Z,X))}ra&&(sa=ra.set,x.columnGraphics=sa,Y.push(sa),sa.translate(S,T-X/2),(x.url||this.showHandOnHover)&&sa.setAttr("cursor","pointer"),ib&&(Y.push(ib),Y.push(tb)),aa=D,ia=C,q?(fa=C,ea=D,"open"==k&&(ea=N),"high"==k&&(ea=Ga),"low"==k&&(ea=Fa)):(fa=C,"open"==k&&(fa=M),"high"==k&&(fa=ya),"low"==k&&(fa=xa),ea=D),$||(x.x=q?T+Q/2:S+Q/2,this.animateColumns(ra,J,D,N,C,M),this.addListeners(sa,x)))}break;case "ohlc":if(!(isNaN(ka)||
146 isNaN(qb)||isNaN(rb)||isNaN(U))){U<ka&&(x.isNegative=!0,void 0!=wa&&(ua=wa));var yb,zb,Ab;if(q){var Bb=C-h/2,Bb=AmCharts.fitToBounds(Bb,0,n),Kb=AmCharts.fitToBounds(C,0,n),Cb=C+h/2,Cb=AmCharts.fitToBounds(Cb,0,n);zb=AmCharts.line(e,[N,N],[Bb,Kb],ua,Z,X,R);0<C&&C<n&&(yb=AmCharts.line(e,[Fa,Ga],[C,C],ua,Z,X,R));Ab=AmCharts.line(e,[D,D],[Kb,Cb],ua,Z,X,R);fa=C;ea=D;"open"==k&&(ea=N);"high"==k&&(ea=Ga);"low"==k&&(ea=Fa)}else{var Db=D-h/2,Db=AmCharts.fitToBounds(Db,0,m),Lb=AmCharts.fitToBounds(D,0,m),Eb=
147 D+h/2,Eb=AmCharts.fitToBounds(Eb,0,m);zb=AmCharts.line(e,[Db,Lb],[M,M],ua,Z,X,R);0<D&&D<m&&(yb=AmCharts.line(e,[D,D],[xa,ya],ua,Z,X,R));Ab=AmCharts.line(e,[Lb,Eb],[C,C],ua,Z,X,R);fa=C;"open"==k&&(fa=M);"high"==k&&(fa=ya);"low"==k&&(fa=xa);ea=D}Y.push(zb);Y.push(yb);Y.push(Ab);aa=D;ia=C}}if(!$&&!isNaN(U)){var Mb=this.hideBulletsCount;if(this.end-this.start<=Mb||0===Mb){var Ha=this.createBullet(x,ea,fa,J);Ha||(Ha=0);var Nb=this.labelText;if(Nb){var ga=this.createLabel(x,0,0,Nb),Ia=0,Ja=0,Ob=ga.getBBox(),
148 Pa=Ob.width,Ka=Ob.height;switch(L){case "left":Ia=-(Pa/2+Ha/2+3);break;case "top":Ja=-(Ka/2+Ha/2+3);break;case "right":Ia=Ha/2+2+Pa/2;break;case "bottom":q&&"column"==g?(aa=na,0>U||0<U&&f.reversed?(Ia=-6,ga.attr({"text-anchor":"end"})):(Ia=6,ga.attr({"text-anchor":"start"}))):(Ja=Ha/2+Ka/2,ga.x=-(Pa/2+2));break;case "middle":"column"==g&&(q?(Ja=-(Ka/2)+this.fontSize/2,Ia=-(D-N)/2-I,Math.abs(D-N)<Pa&&!this.showAllValueLabels&&(ga.remove(),ga=null)):(Ja=-(C-M)/2-F,Math.abs(C-M)<Ka&&!this.showAllValueLabels&&
149 (ga.remove(),ga=null)));break;case "inside":q?(Ja=-(Ka/2)+this.fontSize/2,Ia=0>da?Pa/2+6:-Pa/2-6):Ja=0>da?Ka:-Ka}if(ga){if(isNaN(ia)||isNaN(aa))ga.remove(),ga=null;else if(aa+=Ia,ia+=Ja,ga.translate(aa,ia),q){if(0>ia||ia>n)ga.remove(),ga=null}else{var Pb=0;"3d"==H&&(Pb=I*V);if(0>aa||aa>m+Pb)ga.remove(),ga=null}ga&&this.allBullets.push(ga)}}if("regular"==H||"100%"==H){var Qb=f.totalText;if(Qb){var Qa=this.createLabel(x,0,0,Qb,f.totalTextColor);this.allBullets.push(Qa);var Rb=Qa.getBBox(),Sb=Rb.width,
150 Tb=Rb.height,Ya,Za,Ub=f.totals[J];Ub&&Ub.remove();var $a=0;"column"!=g&&($a=Ha);q?(Za=C,Ya=0>U?D-Sb/2-2-$a:D+Sb/2+3+$a):(Ya=D,Za=0>U?C+Tb/2+$a:C-Tb/2-3-$a);Qa.translate(Ya,Za);f.totals[J]=Qa;q?(0>Za||Za>n)&&Qa.remove():(0>Ya||Ya>m)&&Qa.remove()}}}}}}if("line"==g||"step"==g||"smoothedLine"==g)"smoothedLine"==g?this.drawSmoothedGraph(w,t,O,P):this.drawLineGraph(w,t,O,P),$||this.launchAnimation();this.bulletsHidden&&this.hideBullets()},animateColumns:function(a,b,c,d,e,f){var g=this;c=g.chart.startDuration;
151 0<c&&!g.animationPlayed&&(g.seqAn?(a.set.hide(),g.animationArray.push(a),a=setTimeout(function(){g.animate.call(g)},c/(g.end-g.start+1)*(b-g.start)*1E3),g.timeOuts.push(a)):g.animate(a))},createLabel:function(a,b,c,d,e){var f=this.chart,g=a.labelColor;g||(g=this.color);g||(g=f.color);e&&(g=e);e=this.fontSize;void 0===e&&(this.fontSize=e=f.fontSize);var h=this.labelFunction;d=f.formatString(d,a);d=AmCharts.cleanFromEmpty(d);h&&(d=h(a,d));a=AmCharts.text(this.container,d,g,f.fontFamily,e);a.node.style.pointerEvents=
152 "none";a.translate(b,c);this.bulletSet.push(a);return a},positiveClip:function(a){a.clipRect(this.pmx,this.pmy,this.pmw,this.pmh)},negativeClip:function(a){a.clipRect(this.nmx,this.nmy,this.nmw,this.nmh)},drawLineGraph:function(a,b,c,d){var e=this;if(1<a.length){var f=e.set,g=e.chart,h=e.container,k=h.set(),l=h.set();f.push(l);f.push(k);var m=e.lineAlpha,n=e.lineThickness,f=e.fillAlphas,p=e.lineColorR,q=e.negativeLineAlpha;isNaN(q)&&(q=m);var r=e.lineColorSwitched;r&&(p=r);var r=e.fillColorsR,s=e.fillColorsSwitched;
153 s&&(r=s);var v=e.dashLength;(s=e.dashLengthSwitched)&&(v=s);var s=e.negativeLineColor,w=e.negativeFillColors,t=e.negativeFillAlphas,u=e.baseCoord;0!==e.negativeBase&&(u=e.valueAxis.getCoordinate(e.negativeBase));m=AmCharts.line(h,a,b,p,m,n,v,!1,!0);k.push(m);k.click(function(a){e.handleGraphEvent(a,"clickGraph")}).mouseover(function(a){e.handleGraphEvent(a,"rollOverGraph")}).mouseout(function(a){e.handleGraphEvent(a,"rollOutGraph")});void 0===s||e.useNegativeColorIfDown||(n=AmCharts.line(h,a,b,s,
154 q,n,v,!1,!0),l.push(n));if(0<f||0<t)if(n=a.join(";").split(";"),q=b.join(";").split(";"),m=g.type,"serial"==m?0<c.length?(c.reverse(),d.reverse(),n=a.concat(c),q=b.concat(d)):e.rotate?(q.push(q[q.length-1]),n.push(u),q.push(q[0]),n.push(u),q.push(q[0]),n.push(n[0])):(n.push(n[n.length-1]),q.push(u),n.push(n[0]),q.push(u),n.push(a[0]),q.push(q[0])):"xy"==m&&(b=e.fillToAxis)&&(AmCharts.isString(b)&&(b=g.getValueAxisById(b)),"H"==b.orientation?(u="top"==b.position?0:b.viH,n.push(n[n.length-1]),q.push(u),
155 n.push(n[0]),q.push(u),n.push(a[0]),q.push(q[0])):(u="left"==b.position?0:b.viW,q.push(q[q.length-1]),n.push(u),q.push(q[0]),n.push(u),q.push(q[0]),n.push(n[0]))),a=e.gradientRotation,0<f&&(g=AmCharts.polygon(h,n,q,r,f,1,"#000",0,a),g.pattern(e.pattern),k.push(g)),w||void 0!==s)isNaN(t)&&(t=f),w||(w=s),h=AmCharts.polygon(h,n,q,w,t,1,"#000",0,a),h.pattern(e.pattern),l.push(h),l.click(function(a){e.handleGraphEvent(a,"clickGraph")}).mouseover(function(a){e.handleGraphEvent(a,"rollOverGraph")}).mouseout(function(a){e.handleGraphEvent(a,
156 "rollOutGraph")});e.applyMask(l,k)}},applyMask:function(a,b){var c=a.length();"serial"!=this.chart.type||this.scrollbar||(this.positiveClip(b),0<c&&this.negativeClip(a))},drawSmoothedGraph:function(a,b,c,d){if(1<a.length){var e=this.set,f=this.container,g=f.set(),h=f.set();e.push(h);e.push(g);var k=this.lineAlpha,l=this.lineThickness,e=this.dashLength,m=this.fillAlphas,n=this.lineColorR,p=this.fillColorsR,q=this.negativeLineColor,r=this.negativeFillColors,s=this.negativeFillAlphas,v=this.baseCoord,
157 w=this.lineColorSwitched;w&&(n=w);(w=this.fillColorsSwitched)&&(p=w);w=this.negativeLineAlpha;isNaN(w)&&(w=k);k=new AmCharts.Bezier(f,a,b,n,k,l,p,0,e);g.push(k.path);void 0!==q&&(l=new AmCharts.Bezier(f,a,b,q,w,l,p,0,e),h.push(l.path));0<m&&(k=a.join(";").split(";"),n=b.join(";").split(";"),l="",0<c.length?(c.push("M"),d.push("M"),c.reverse(),d.reverse(),k=a.concat(c),n=b.concat(d)):(this.rotate?(l+=" L"+v+","+b[b.length-1],l+=" L"+v+","+b[0]):(l+=" L"+a[a.length-1]+","+v,l+=" L"+a[0]+","+v),l+=" L"+
158 a[0]+","+b[0]),c=new AmCharts.Bezier(f,k,n,NaN,0,0,p,m,e,l),c.path.pattern(this.pattern),g.push(c.path),r||void 0!==q)&&(s||(s=m),r||(r=q),a=new AmCharts.Bezier(f,a,b,NaN,0,0,r,s,e,l),a.path.pattern(this.pattern),h.push(a.path));this.applyMask(h,g)}},launchAnimation:function(){var a=this,b=a.chart.startDuration;if(0<b&&!a.animationPlayed){var c=a.set,d=a.bulletSet;AmCharts.VML||(c.attr({opacity:a.startAlpha}),d.attr({opacity:a.startAlpha}));c.hide();d.hide();a.seqAn?(b=setTimeout(function(){a.animateGraphs.call(a)},
159 a.index*b*1E3),a.timeOuts.push(b)):a.animateGraphs()}},animateGraphs:function(){var a=this.chart,b=this.set,c=this.bulletSet,d=this.x,e=this.y;b.show();c.show();var f=a.startDuration,a=a.startEffect;b&&(this.rotate?(b.translate(-1E3,e),c.translate(-1E3,e)):(b.translate(d,-1E3),c.translate(d,-1E3)),b.animate({opacity:1,translate:d+","+e},f,a),c.animate({opacity:1,translate:d+","+e},f,a))},animate:function(a){var b=this.chart,c=this.animationArray;!a&&0<c.length&&(a=c[0],c.shift());c=AmCharts[AmCharts.getEffect(b.startEffect)];
160 b=b.startDuration;a&&(this.rotate?a.animateWidth(b,c):a.animateHeight(b,c),a.set.show())},legendKeyColor:function(){var a=this.legendColor,b=this.lineAlpha;void 0===a&&(a=this.lineColorR,0===b&&(b=this.fillColorsR)&&(a="object"==typeof b?b[0]:b));return a},legendKeyAlpha:function(){var a=this.legendAlpha;void 0===a&&(a=this.lineAlpha,this.fillAlphas>a&&(a=this.fillAlphas),0===a&&(a=this.bulletAlpha),0===a&&(a=1));return a},createBullet:function(a,b,c,d){d=this.container;var e=this.bulletOffset,f=
161 this.bulletSize;isNaN(a.bulletSize)||(f=a.bulletSize);var g=a.values.value,h=this.maxValue,k=this.minValue,l=this.maxBulletSize,m=this.minBulletSize;isNaN(h)||(isNaN(g)||(f=(g-k)/(h-k)*(l-m)+m),k==h&&(f=l));h=f;this.bulletAxis&&(f=a.values.error,isNaN(f)||(g=f),f=this.bulletAxis.stepWidth*g);f<this.minBulletSize&&(f=this.minBulletSize);this.rotate?b=a.isNegative?b-e:b+e:c=a.isNegative?c+e:c-e;var n,m=this.bulletColorR;a.lineColor&&(this.bulletColorSwitched=a.lineColor);this.bulletColorSwitched&&(m=
162 this.bulletColorSwitched);a.isNegative&&void 0!==this.bulletColorNegative&&(m=this.bulletColorNegative);void 0!==a.color&&(m=a.color);var p;"xy"==this.chart.type&&this.valueField&&(p=this.pattern,a.pattern&&(p=a.pattern));e=this.bullet;a.bullet&&(e=a.bullet);var g=this.bulletBorderThickness,k=this.bulletBorderColorR,l=this.bulletBorderAlpha,q=this.bulletAlpha;k||(k=m);this.useLineColorForBulletBorder&&(k=this.lineColorR);var r=a.alpha;isNaN(r)||(q=r);if("none"!=this.bullet||a.bullet)n=AmCharts.bullet(d,
163 e,f,m,q,g,k,l,h,0,p);if(this.customBullet||a.customBullet)p=this.customBullet,a.customBullet&&(p=a.customBullet),p&&(n&&n.remove(),"function"==typeof p?(n=new p,n.chart=this.chart,a.bulletConfig&&(n.availableSpace=c,n.graph=this,n.graphDataItem=a,n.bulletY=c,a.bulletConfig.minCoord=this.minCoord-c,n.bulletConfig=a.bulletConfig),n.write(d),n=n.set):(this.chart.path&&(p=this.chart.path+p),n=d.set(),d=d.image(p,0,0,f,f),n.push(d),this.centerCustomBullets&&d.translate(-f/2,-f/2)));n&&((a.url||this.showHandOnHover)&&
164 n.setAttr("cursor","pointer"),"serial"==this.chart.type&&(0>b-0||b-0>this.width||c<-f/2||c-0>this.height)&&(n.remove(),n=null),n&&(this.bulletSet.push(n),n.translate(b,c),this.addListeners(n,a),this.allBullets.push(n)),a.bx=b,a.by=c);a.bulletGraphics=n;return f},showBullets:function(){var a=this.allBullets,b;this.bulletsHidden=!1;for(b=0;b<a.length;b++)a[b].show()},hideBullets:function(){var a=this.allBullets,b;this.bulletsHidden=!0;for(b=0;b<a.length;b++)a[b].hide()},addListeners:function(a,b){var c=
165 this;a.mouseover(function(a){c.handleRollOver(b,a)}).mouseout(function(a){c.handleRollOut(b,a)}).touchend(function(a){c.handleRollOver(b,a);c.chart.panEventsEnabled&&c.handleClick(b,a)}).touchstart(function(a){c.handleRollOver(b,a)}).click(function(a){c.handleClick(b,a)}).dblclick(function(a){c.handleDoubleClick(b,a)}).contextmenu(function(a){c.handleRightClick(b,a)})},handleRollOver:function(a,b){if(a){var c=this.chart,d={type:"rollOverGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,
166 event:b};this.fire("rollOverGraphItem",d);c.fire("rollOverGraphItem",d);clearTimeout(c.hoverInt);d=this.showBalloon;c.chartCursor&&"serial"==c.type&&(d=!1,!c.chartCursor.valueBalloonsEnabled&&this.showBalloon&&(d=!0));if(d){var d=c.formatString(this.balloonText,a,!0),e=this.balloonFunction;e&&(d=e(a,a.graph));d=AmCharts.cleanFromEmpty(d);e=c.getBalloonColor(this,a);c.balloon.showBullet=!1;c.balloon.pointerOrientation="V";var f=a.x,g=a.y;c.rotate&&(f=a.y,g=a.x);c.showBalloon(d,e,!0,f+c.marginLeftReal,
167 g+c.marginTopReal)}}this.handleGraphEvent(b,"rollOverGraph")},handleRollOut:function(a,b){this.chart.hideBalloon();if(a){var c={type:"rollOutGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire("rollOutGraphItem",c);this.chart.fire("rollOutGraphItem",c)}this.handleGraphEvent(b,"rollOutGraph")},handleClick:function(a,b){if(a){var c={type:"clickGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire("clickGraphItem",c);this.chart.fire("clickGraphItem",
168 c);AmCharts.getURL(a.url,this.urlTarget)}this.handleGraphEvent(b,"clickGraph")},handleGraphEvent:function(a,b){var c={type:b,graph:this,target:this,chart:this.chart,event:a};this.fire(b,c);this.chart.fire(b,c)},handleRightClick:function(a,b){if(a){var c={type:"rightClickGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire("rightClickGraphItem",c);this.chart.fire("rightClickGraphItem",c)}},handleDoubleClick:function(a,b){if(a){var c={type:"doubleClickGraphItem",
169 item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire("doubleClickGraphItem",c);this.chart.fire("doubleClickGraphItem",c)}},zoom:function(a,b){this.start=a;this.end=b;this.draw()},changeOpacity:function(a){var b=this.set;b&&b.setAttr("opacity",a);if(b=this.ownColumns){var c;for(c=0;c<b.length;c++){var d=b[c].set;d&&d.setAttr("opacity",a)}}(b=this.bulletSet)&&b.setAttr("opacity",a)},destroy:function(){AmCharts.remove(this.set);AmCharts.remove(this.bulletSet);var a=this.timeOuts;
170 if(a){var b;for(b=0;b<a.length;b++)clearTimeout(a[b])}this.timeOuts=[]}});AmCharts.ChartCursor=AmCharts.Class({construct:function(a){this.cname="ChartCursor";this.createEvents("changed","zoomed","onHideCursor","draw","selected","moved");this.enabled=!0;this.cursorAlpha=1;this.selectionAlpha=.2;this.cursorColor="#CC0000";this.categoryBalloonAlpha=1;this.color="#FFFFFF";this.type="cursor";this.zoomed=!1;this.zoomable=!0;this.pan=!1;this.categoryBalloonDateFormat="MMM DD, YYYY";this.categoryBalloonEnabled=this.valueBalloonsEnabled=!0;this.rolledOver=!1;this.cursorPosition=
171 "middle";this.bulletsEnabled=this.skipZoomDispatch=!1;this.bulletSize=8;this.selectWithoutZooming=this.oneBalloonOnly=!1;this.graphBulletSize=1.7;this.animationDuration=.3;this.zooming=!1;this.adjustment=0;this.avoidBalloonOverlapping=!0;AmCharts.applyTheme(this,a,this.cname)},draw:function(){var a=this;a.destroy();var b=a.chart,c=b.container;a.rotate=b.rotate;a.container=c;c=c.set();c.translate(a.x,a.y);a.set=c;b.cursorSet.push(c);c=new AmCharts.AmBalloon;c.chart=b;a.categoryBalloon=c;AmCharts.copyProperties(b.balloon,
172 c);c.cornerRadius=0;c.shadowAlpha=0;c.borderThickness=1;c.borderAlpha=1;c.showBullet=!1;var d=a.categoryBalloonColor;void 0===d&&(d=a.cursorColor);c.fillColor=d;c.fillAlpha=a.categoryBalloonAlpha;c.borderColor=d;c.color=a.color;a.rotate&&(c.pointerOrientation="H");a.extraWidth=0;a.prevX=[];a.prevY=[];a.prevTX=[];a.prevTY=[];if(a.valueBalloonsEnabled)for(c=0;c<b.graphs.length;c++)d=new AmCharts.AmBalloon,d.chart=b,AmCharts.copyProperties(b.balloon,d),b.graphs[c].valueBalloon=d;"cursor"==a.type?a.createCursor():
173 a.createCrosshair();a.interval=setInterval(function(){a.detectMovement.call(a)},40)},updateData:function(){var a=this.chart;this.data=a.chartData;this.firstTime=a.firstTime;this.lastTime=a.lastTime},createCursor:function(){var a=this.chart,b=this.cursorAlpha,c=a.categoryAxis,d=c.position,e=c.inside,f=c.axisThickness,g=this.categoryBalloon,h,k,l=a.dx,m=a.dy,n=this.x,p=this.y,q=this.width,r=this.height,a=a.rotate,s=c.tickLength;g.pointerWidth=s;a?(h=[0,q,q+l],k=[0,0,m]):(h=[l,0,0],k=[m,0,r]);this.line=
174 b=AmCharts.line(this.container,h,k,this.cursorColor,b,1);(h=this.fullRectSet)?(h.push(b),h.translate(this.x,this.y)):this.set.push(b);a?(e&&(g.pointerWidth=0),"right"==d?e?g.setBounds(n,p+m,n+q+l,p+r+m):g.setBounds(n+q+l+f,p+m,n+q+1E3,p+r+m):e?g.setBounds(n,p,q+n,r+p):g.setBounds(-1E3,-1E3,n-s-f,p+r+15)):(g.maxWidth=q,c.parseDates&&(s=0,g.pointerWidth=0),"top"==d?e?g.setBounds(n+l,p+m,q+l+n,r+p):g.setBounds(n+l,-1E3,q+l+n,p+m-s-f):e?g.setBounds(n,p,q+n,r+p-s):g.setBounds(n,p+r+s+f-1,n+q,p+r+s+f));
175 this.hideCursor()},createCrosshair:function(){var a=this.cursorAlpha,b=this.container,c=AmCharts.line(b,[0,0],[0,this.height],this.cursorColor,a,1),a=AmCharts.line(b,[0,this.width],[0,0],this.cursorColor,a,1);this.set.push(c);this.set.push(a);this.vLine=c;this.hLine=a;this.hideCursor()},detectMovement:function(){var a=this.chart;if(a.mouseIsOver){var b=a.mouseX-this.x,c=a.mouseY-this.y;-.5<b&&b<this.width+1&&0<c&&c<this.height?(this.drawing?this.rolledOver||a.setMouseCursor("crosshair"):this.pan&&
176 (this.rolledOver||a.setMouseCursor("move")),this.rolledOver=!0,this.setPosition()):this.rolledOver&&(this.handleMouseOut(),this.rolledOver=!1)}else this.rolledOver&&(this.handleMouseOut(),this.rolledOver=!1)},getMousePosition:function(){var a,b=this.width,c=this.height;a=this.chart;this.rotate?(a=a.mouseY-this.y,0>a&&(a=0),a>c&&(a=c)):(a=a.mouseX-this.x-1,0>a&&(a=0),a>b&&(a=b));return a},updateCrosshair:function(){var a=this.chart,b=a.mouseX-this.x,c=a.mouseY-this.y,d=this.vLine,e=this.hLine,b=AmCharts.fitToBounds(b,
177 0,this.width),c=AmCharts.fitToBounds(c,0,this.height);0<this.cursorAlpha&&(d.show(),e.show(),d.translate(b,0),e.translate(0,c));this.zooming&&(a.hideXScrollbar&&(b=NaN),a.hideYScrollbar&&(c=NaN),this.updateSelectionSize(b,c));this.fireMoved();a.mouseIsOver||this.zooming||this.hideCursor()},fireMoved:function(){var a=this.chart,b={type:"moved",target:this};b.chart=a;b.zooming=this.zooming;b.x=a.mouseX-this.x;b.y=a.mouseY-this.y;this.fire("moved",b)},updateSelectionSize:function(a,b){AmCharts.remove(this.selection);
178 var c=this.selectionPosX,d=this.selectionPosY,e=0,f=0,g=this.width,h=this.height;isNaN(a)||(c>a&&(e=a,g=c-a),c<a&&(e=c,g=a-c),c==a&&(e=a,g=0),g+=this.extraWidth,e-=this.extraWidth/2);isNaN(b)||(d>b&&(f=b,h=d-b),d<b&&(f=d,h=b-d),d==b&&(f=b,h=0),h+=this.extraWidth,f-=this.extraWidth/2);0<g&&0<h&&(c=AmCharts.rect(this.container,g,h,this.cursorColor,this.selectionAlpha),c.translate(e+this.x,f+this.y),this.selection=c)},arrangeBalloons:function(){var a=this.valueBalloons,b=this.x,c=this.y,d=this.height+
179 c;a.sort(this.compareY);var e;for(e=0;e<a.length;e++){var f=a[e].balloon;f.setBounds(b,c,b+this.width,d);f.prevX=this.prevX[e];f.prevY=this.prevY[e];f.prevTX=this.prevTX[e];f.prevTY=this.prevTY[e];f.draw();d=f.yPos-3}this.arrangeBalloons2()},compareY:function(a,b){return a.yy<b.yy?1:-1},arrangeBalloons2:function(){var a=this.valueBalloons;a.reverse();var b,c=this.x,d,e,f=a.length;for(e=0;e<f;e++){var g=a[e].balloon;b=g.bottom;var h=g.bottom-g.yPos,k=f-e-1;0<e&&b-h<d+3&&(g.setBounds(c,d+3,c+this.width,
180 d+h+3),g.prevX=this.prevX[k],g.prevY=this.prevY[k],g.prevTX=this.prevTX[k],g.prevTY=this.prevTY[k],g.draw());g.set&&g.set.show();this.prevX[k]=g.prevX;this.prevY[k]=g.prevY;this.prevTX[k]=g.prevTX;this.prevTY[k]=g.prevTY;d=g.bottom}},showBullets:function(){AmCharts.remove(this.allBullets);var a=this.container,b=a.set();this.set.push(b);this.set.show();this.allBullets=b;var b=this.chart.graphs,c;for(c=0;c<b.length;c++){var d=b[c];if(!d.hidden&&d.balloonText){var e=this.data[this.index].axes[d.valueAxis.id].graphs[d.id],
181 f=e.y;if(!isNaN(f)){var g,h;g=e.x;this.rotate?(h=f,f=g):h=g;d=AmCharts.circle(a,this.bulletSize/2,this.chart.getBalloonColor(d,e,!0),d.cursorBulletAlpha);d.translate(h,f);this.allBullets.push(d)}}}},destroy:function(){this.clear();AmCharts.remove(this.selection);this.selection=null;var a=this.categoryBalloon;a&&a.destroy();this.destroyValueBalloons();AmCharts.remove(this.set)},clear:function(){clearInterval(this.interval)},destroyValueBalloons:function(){var a=this.valueBalloons;if(a){var b;for(b=
182 0;b<a.length;b++)a[b].balloon.hide()}},zoom:function(a,b,c,d){var e=this.chart;this.destroyValueBalloons();this.zooming=!1;var f;this.rotate?this.selectionPosY=f=e.mouseY:this.selectionPosX=f=e.mouseX;this.start=a;this.end=b;this.startTime=c;this.endTime=d;this.zoomed=!0;d=e.categoryAxis;e=this.rotate;b=this.width;c=this.height;a=d.stepWidth;this.fullWidth&&(f=1,d.parseDates&&!d.equalSpacing&&(f=d.minDuration()),e?this.extraWidth=c=a*f:(this.extraWidth=b=a*f,this.categoryBalloon.minWidth=b),this.line&&
183 this.line.remove(),this.line=AmCharts.rect(this.container,b,c,this.cursorColor,this.cursorAlpha,0),this.fullRectSet&&this.fullRectSet.push(this.line));this.stepWidth=a;this.tempVal=this.valueBalloonsEnabled;this.valueBalloonsEnabled=!1;this.setPosition();this.valueBalloonsEnabled=this.tempVal;this.hideCursor()},hideObj:function(a){a&&a.hide()},hideCursor:function(a){void 0===a&&(a=!0);this.hideObj(this.set);this.hideObj(this.categoryBalloon);this.hideObj(this.line);this.hideObj(this.vLine);this.hideObj(this.hLine);
184 this.hideObj(this.allBullets);this.destroyValueBalloons();this.selectWithoutZooming||AmCharts.remove(this.selection);this.previousIndex=NaN;a&&this.fire("onHideCursor",{type:"onHideCursor",chart:this.chart,target:this});this.drawing||this.chart.setMouseCursor("auto");this.normalizeBulletSize()},setPosition:function(a,b,c){void 0===b&&(b=!0);if("cursor"==this.type){if(this.tempPosition=NaN,AmCharts.ifArray(this.data))isNaN(a)&&(a=this.getMousePosition()),(a!=this.previousMousePosition||!0===this.zoomed||
185 this.oneBalloonOnly)&&!isNaN(a)&&("mouse"==this.cursorPosition&&(this.tempPosition=a),isNaN(c)&&(c=this.chart.categoryAxis.xToIndex(a)),c!=this.previousIndex||this.zoomed||"mouse"==this.cursorPosition||this.oneBalloonOnly)&&(this.updateCursor(c,b),this.zoomed=!1),this.previousMousePosition=a}else this.updateCrosshair()},normalizeBulletSize:function(){var a=this.resizedBullets;if(a)for(var b=0;b<a.length;b++){var c=a[b],d=c.bulletGraphics;d&&(d.translate(c.bx,c.by,1),c=c.graph,isNaN(this.graphBulletAlpha)||
186 (d.setAttr("fill-opacity",c.bulletAlpha),d.setAttr("stroke-opacity",c.bulletBorderAlpha)))}},updateCursor:function(a,b){var c=this.chart,d=this.fullWidth,e=c.mouseX-this.x,f=c.mouseY-this.y;this.drawingNow&&(AmCharts.remove(this.drawingLine),this.drawingLine=AmCharts.line(this.container,[this.x+this.drawStartX,this.x+e],[this.y+this.drawStartY,this.y+f],this.cursorColor,1,1));if(this.enabled){void 0===b&&(b=!0);this.index=a+=this.adjustment;var g=c.categoryAxis,h=c.dx,k=c.dy,l=this.x+1,m=this.y+1,
187 n=this.width,p=this.height,q=this.data[a];this.fireMoved();if(q){var r=q.x[g.id],s=c.rotate,v=g.inside,w=this.stepWidth,t=this.categoryBalloon,u=this.firstTime,y=this.lastTime,E=this.cursorPosition,A=g.position,z=this.zooming,K=this.panning,I=c.graphs,F=g.axisThickness;if(c.mouseIsOver||z||K||this.forceShow)if(this.forceShow=!1,K){var h=this.panClickPos,c=this.panClickEndTime,z=this.panClickStartTime,H=this.panClickEnd,l=this.panClickStart,e=(s?h-f:h-e)/w;if(!g.parseDates||g.equalSpacing)e=Math.round(e);
188 0!==e&&(h={type:"zoomed",target:this},h.chart=this.chart,g.parseDates&&!g.equalSpacing?(c+e>y&&(e=y-c),z+e<u&&(e=u-z),h.start=Math.round(z+e),h.end=Math.round(c+e),this.fire(h.type,h)):H+e>=this.data.length||0>l+e||(h.start=l+e,h.end=H+e,this.fire(h.type,h)))}else{"start"==E?r-=g.cellWidth/2:"mouse"==E&&(c.mouseIsOver?r=s?f-2:e-2:isNaN(this.tempPosition)||(r=this.tempPosition-2));if(s){if(0>r)if(z)r=0;else{this.hideCursor();return}if(r>p+1)if(z)r=p+1;else{this.hideCursor();return}}else{if(0>r)if(z)r=
189 0;else{this.hideCursor();return}if(r>n)if(z)r=n;else{this.hideCursor();return}}if(0<this.cursorAlpha){var L=this.line;s?(u=0,y=r+k,d&&(y-=g.cellWidth/2)):(u=r,y=0,d&&(u-=g.cellWidth/2));w=this.animationDuration;0<w&&!this.zooming?isNaN(this.previousX)?L.translate(u,y):(L.translate(this.previousX,this.previousY),L.animate({translate:u+","+y},w,"easeOutSine")):L.translate(u,y);this.previousX=u;this.previousY=y;L.show()}this.linePos=s?r+k:r;z&&(d&&L.hide(),s?this.updateSelectionSize(NaN,r):this.updateSelectionSize(r,
190 NaN));w=!0;z&&(w=!1);this.categoryBalloonEnabled&&w?(s?(v&&("right"==A?t.setBounds(l,m+k,l+n+h,m+r+k):t.setBounds(l,m+k,l+n+h,m+r)),"right"==A?v?t.setPosition(l+n+h,m+r+k):t.setPosition(l+n+h+F,m+r+k):v?t.setPosition(l,m+r):t.setPosition(l-F,m+r)):"top"==A?v?t.setPosition(l+r+h,m+k):t.setPosition(l+r+h,m+k-F+1):v?t.setPosition(l+r,m+p):t.setPosition(l+r,m+p+F-1),(u=this.categoryBalloonFunction)?t.showBalloon(u(q.category)):g.parseDates?(g=AmCharts.formatDate(q.category,this.categoryBalloonDateFormat),
191 -1!=g.indexOf("fff")&&(g=AmCharts.formatMilliseconds(g,q.category)),t.showBalloon(g)):t.showBalloon(AmCharts.fixNewLines(q.category))):t.hide();I&&this.bulletsEnabled&&this.showBullets();if(this.oneBalloonOnly){k=Infinity;for(g=0;g<I.length;g++)u=I[g],u.showBalloon&&!u.hidden&&u.balloonText&&(y=q.axes[u.valueAxis.id].graphs[u.id],t=y.y,isNaN(t)||(s?Math.abs(e-t)<k&&(k=Math.abs(e-t),H=u):Math.abs(f-t)<k&&(k=Math.abs(f-t),H=u)));this.mostCloseGraph&&(H=this.mostCloseGraph)}if(a!=this.previousIndex||
192 H!=this.previousMostCloseGraph)if(this.normalizeBulletSize(),this.destroyValueBalloons(),this.resizedBullets=[],I&&this.valueBalloonsEnabled&&w&&c.balloon.enabled){this.valueBalloons=w=[];for(g=0;g<I.length;g++)if(u=I[g],t=NaN,(!this.oneBalloonOnly||u==H)&&u.showBalloon&&!u.hidden&&u.balloonText&&("step"==u.type&&"left"==u.stepDirection&&(q=this.data[a+1]),q)){if(y=q.axes[u.valueAxis.id].graphs[u.id])t=y.y;if(this.showNextAvailable&&isNaN(t)&&a+1<this.data.length)for(k=a+1;k<this.data.length;k++)if(r=
193 this.data[k])if(y=r.axes[u.valueAxis.id].graphs[u.id],t=y.y,!isNaN(t))break;if(!isNaN(t)){r=y.x;v=!0;if(s){if(k=t,0>r||r>p)v=!1}else if(k=r,r=t,0>k||k>n+h+1)v=!1;v&&(1!=this.graphBulletSize&&AmCharts.isModern&&(v=y.bulletGraphics)&&(v.getBBox(),v.translate(y.bx,y.by,this.graphBulletSize),this.resizedBullets.push(y),A=this.graphBulletAlpha,isNaN(A)||(v.setAttr("fill-opacity",A),v.setAttr("stroke-opacity",A))),v=u.valueBalloon,A=c.getBalloonColor(u,y),v.setBounds(l,m,l+n,m+p),v.pointerOrientation="H",
194 F=this.balloonPointerOrientation,"vertical"==F&&(v.pointerOrientation="V"),"horizontal"==F&&(v.pointerOrientation="H"),v.changeColor(A),void 0!==u.balloonAlpha&&(v.fillAlpha=u.balloonAlpha),void 0!==u.balloonTextColor&&(v.color=u.balloonTextColor),v.setPosition(k+l,r+m),k=c.formatString(u.balloonText,y,!0),(r=u.balloonFunction)&&(k=r(y,u).toString()),""!==k&&(s?v.showBalloon(k):(v.text=k,v.show=!0),w.push({yy:t,balloon:v})),!s&&v.set&&(v.set.hide(),u=v.textDiv)&&(u.style.visibility="hidden"))}}this.avoidBalloonOverlapping&&
195 this.arrangeBalloons()}b?(h={type:"changed"},h.index=a,h.chart=this.chart,h.zooming=z,h.mostCloseGraph=H,h.position=s?f:e,h.target=this,c.fire("changed",h),this.fire("changed",h),this.skipZoomDispatch=!1):(this.skipZoomDispatch=!0,c.updateLegendValues(a));this.previousIndex=a;this.previousMostCloseGraph=H}}}else this.hideCursor()},enableDrawing:function(a){this.enabled=!a;this.hideCursor();this.rolledOver=!1;this.drawing=a},isZooming:function(a){a&&a!=this.zooming&&this.handleMouseDown("fake");a||
196 a==this.zooming||this.handleMouseUp()},handleMouseOut:function(){if(this.enabled)if(this.zooming)this.setPosition();else{this.index=void 0;var a={type:"changed",index:void 0,target:this};a.chart=this.chart;this.fire("changed",a);this.hideCursor()}},handleReleaseOutside:function(){this.handleMouseUp()},handleMouseUp:function(){var a=this.chart,b=this.data,c;if(a){var d=a.mouseX-this.x,e=a.mouseY-this.y;if(this.drawingNow){this.drawingNow=!1;AmCharts.remove(this.drawingLine);c=this.drawStartX;var f=
197 this.drawStartY;if(2<Math.abs(c-d)||2<Math.abs(f-e))c={type:"draw",target:this,chart:a,initialX:c,initialY:f,finalX:d,finalY:e},this.fire(c.type,c)}if(this.enabled&&0<b.length){if(this.pan)this.rolledOver=!1;else if(this.zoomable&&this.zooming){c=this.selectWithoutZooming?{type:"selected"}:{type:"zoomed"};c.target=this;c.chart=a;if("cursor"==this.type)this.rotate?this.selectionPosY=e:this.selectionPosX=e=d,2>Math.abs(e-this.initialMouse)&&this.fromIndex==this.index||(this.index<this.fromIndex?(c.end=
198 this.fromIndex,c.start=this.index):(c.end=this.index,c.start=this.fromIndex),e=a.categoryAxis,e.parseDates&&!e.equalSpacing&&(c.start=b[c.start].time,c.end=a.getEndTime(b[c.end].time)),this.skipZoomDispatch||this.fire(c.type,c));else{var g=this.initialMouseX,h=this.initialMouseY;3>Math.abs(d-g)&&3>Math.abs(e-h)||(b=Math.min(g,d),f=Math.min(h,e),d=Math.abs(g-d),e=Math.abs(h-e),a.hideXScrollbar&&(b=0,d=this.width),a.hideYScrollbar&&(f=0,e=this.height),c.selectionHeight=e,c.selectionWidth=d,c.selectionY=
199 f,c.selectionX=b,this.skipZoomDispatch||this.fire(c.type,c))}this.selectWithoutZooming||AmCharts.remove(this.selection)}this.panning=this.zooming=this.skipZoomDispatch=!1}}},showCursorAt:function(a){var b=this.chart.categoryAxis;a=b.parseDates?b.dateToCoordinate(a):b.categoryToCoordinate(a);this.previousMousePosition=NaN;this.forceShow=!0;this.setPosition(a,!1)},clearSelection:function(){AmCharts.remove(this.selection)},handleMouseDown:function(a){if(this.zoomable||this.pan||this.drawing){var b=this.rotate,
200 c=this.chart,d=c.mouseX-this.x,e=c.mouseY-this.y;if(0<d&&d<this.width&&0<e&&e<this.height||"fake"==a)this.setPosition(),this.selectWithoutZooming&&AmCharts.remove(this.selection),this.drawing?(this.drawStartY=e,this.drawStartX=d,this.drawingNow=!0):this.pan?(this.zoomable=!1,c.setMouseCursor("move"),this.panning=!0,this.panClickPos=b?e:d,this.panClickStart=this.start,this.panClickEnd=this.end,this.panClickStartTime=this.startTime,this.panClickEndTime=this.endTime):this.zoomable&&("cursor"==this.type?
201 (this.fromIndex=this.index,b?(this.initialMouse=e,this.selectionPosY=this.linePos):(this.initialMouse=d,this.selectionPosX=this.linePos)):(this.initialMouseX=d,this.initialMouseY=e,this.selectionPosX=d,this.selectionPosY=e),this.zooming=!0)}}});AmCharts.SimpleChartScrollbar=AmCharts.Class({construct:function(a){this.createEvents("zoomed");this.backgroundColor="#D4D4D4";this.backgroundAlpha=1;this.selectedBackgroundColor="#EFEFEF";this.scrollDuration=this.selectedBackgroundAlpha=1;this.resizeEnabled=!0;this.hideResizeGrips=!1;this.scrollbarHeight=20;this.updateOnReleaseOnly=!1;9>document.documentMode&&(this.updateOnReleaseOnly=!0);this.dragIconWidth=18;this.dragIconHeight=25;AmCharts.applyTheme(this,a,"SimpleChartScrollbar")},draw:function(){var a=
202 this;a.destroy();a.interval=setInterval(function(){a.updateScrollbar.call(a)},40);var b=a.chart.container,c=a.rotate,d=a.chart,e=b.set();a.set=e;d.scrollbarsSet.push(e);var f,g;c?(f=a.scrollbarHeight,g=d.plotAreaHeight):(g=a.scrollbarHeight,f=d.plotAreaWidth);a.width=f;if((a.height=g)&&f){var h=AmCharts.rect(b,f,g,a.backgroundColor,a.backgroundAlpha,1,a.backgroundColor,a.backgroundAlpha);a.bg=h;e.push(h);h=AmCharts.rect(b,f,g,"#000",.005);e.push(h);a.invisibleBg=h;h.click(function(){a.handleBgClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()}).touchend(function(){a.handleBgClick()});
203 h=AmCharts.rect(b,f,g,a.selectedBackgroundColor,a.selectedBackgroundAlpha);a.selectedBG=h;e.push(h);f=AmCharts.rect(b,f,g,"#000",.005);a.dragger=f;e.push(f);f.mousedown(function(b){a.handleDragStart(b)}).mouseup(function(){a.handleDragStop()}).mouseover(function(){a.handleDraggerOver()}).mouseout(function(){a.handleMouseOut()}).touchstart(function(b){a.handleDragStart(b)}).touchend(function(){a.handleDragStop()});f=d.pathToImages;c?(h=f+"dragIconH.gif",f=a.dragIconWidth,c=a.dragIconHeight):(h=f+"dragIcon.gif",
204 c=a.dragIconWidth,f=a.dragIconHeight);g=b.image(h,0,0,c,f);var h=b.image(h,0,0,c,f),k=10,l=20;d.panEventsEnabled&&(k=25,l=a.scrollbarHeight);var m=AmCharts.rect(b,k,l,"#000",.005),n=AmCharts.rect(b,k,l,"#000",.005);n.translate(-(k-c)/2,-(l-f)/2);m.translate(-(k-c)/2,-(l-f)/2);c=b.set([g,n]);b=b.set([h,m]);a.iconLeft=c;a.iconRight=b;c.mousedown(function(){a.leftDragStart()}).mouseup(function(){a.leftDragStop()}).mouseover(function(){a.iconRollOver()}).mouseout(function(){a.iconRollOut()}).touchstart(function(b){a.leftDragStart()}).touchend(function(){a.leftDragStop()});
205 b.mousedown(function(){a.rightDragStart()}).mouseup(function(){a.rightDragStop()}).mouseover(function(){a.iconRollOver()}).mouseout(function(){a.iconRollOut()}).touchstart(function(b){a.rightDragStart()}).touchend(function(){a.rightDragStop()});AmCharts.ifArray(d.chartData)?e.show():e.hide();a.hideDragIcons();a.clipDragger(!1)}e.translate(a.x,a.y)},updateScrollbarSize:function(a,b){var c=this.dragger,d,e,f,g;this.rotate?(d=0,e=a,f=this.width+1,g=b-a,c.setAttr("height",b-a),c.setAttr("y",e)):(d=a,
206 e=0,f=b-a,g=this.height+1,c.setAttr("width",b-a),c.setAttr("x",d));this.clipAndUpdate(d,e,f,g)},updateScrollbar:function(){var a,b=!1,c,d,e=this.x,f=this.y,g=this.dragger,h=this.getDBox();c=h.x+e;d=h.y+f;var k=h.width,h=h.height,l=this.rotate,m=this.chart,n=this.width,p=this.height,q=m.mouseX,r=m.mouseY;a=this.initialMouse;m.mouseIsOver&&(this.dragging&&(m=this.initialCoord,l?(a=m+(r-a),0>a&&(a=0),m=p-h,a>m&&(a=m),g.setAttr("y",a)):(a=m+(q-a),0>a&&(a=0),m=n-k,a>m&&(a=m),g.setAttr("x",a))),this.resizingRight&&
207 (l?(a=r-d,a+d>p+f&&(a=p-d+f),0>a?(this.resizingRight=!1,b=this.resizingLeft=!0):(0===a&&(a=.1),g.setAttr("height",a))):(a=q-c,a+c>n+e&&(a=n-c+e),0>a?(this.resizingRight=!1,b=this.resizingLeft=!0):(0===a&&(a=.1),g.setAttr("width",a)))),this.resizingLeft&&(l?(c=d,d=r,d<f&&(d=f),d>p+f&&(d=p+f),a=!0===b?c-d:h+c-d,0>a?(this.resizingRight=!0,this.resizingLeft=!1,g.setAttr("y",c+h-f)):(0===a&&(a=.1),g.setAttr("y",d-f),g.setAttr("height",a))):(d=q,d<e&&(d=e),d>n+e&&(d=n+e),a=!0===b?c-d:k+c-d,0>a?(this.resizingRight=
208 !0,this.resizingLeft=!1,g.setAttr("x",c+k-e)):(0===a&&(a=.1),g.setAttr("x",d-e),g.setAttr("width",a)))),this.clipDragger(!0))},clipDragger:function(a){var b=this.getDBox();if(b){var c=b.x,d=b.y,e=b.width,b=b.height,f=!1;if(this.rotate){if(c=0,e=this.width+1,this.clipY!=d||this.clipH!=b)f=!0}else if(d=0,b=this.height+1,this.clipX!=c||this.clipW!=e)f=!0;f&&(this.clipAndUpdate(c,d,e,b),a&&(this.updateOnReleaseOnly||this.dispatchScrollbarEvent()))}},maskGraphs:function(){},clipAndUpdate:function(a,b,
209 c,d){this.clipX=a;this.clipY=b;this.clipW=c;this.clipH=d;this.selectedBG.clipRect(a,b,c,d);this.updateDragIconPositions();this.maskGraphs(a,b,c,d)},dispatchScrollbarEvent:function(){if(this.skipEvent)this.skipEvent=!1;else{var a=this.chart;a.hideBalloon();var b=this.getDBox(),c=b.x,d=b.y,e=b.width,b=b.height;this.rotate?(c=d,e=this.height/b):e=this.width/e;a={type:"zoomed",position:c,chart:a,target:this,multiplier:e};this.fire(a.type,a)}},updateDragIconPositions:function(){var a=this.getDBox(),b=
210 a.x,c=a.y,d=this.iconLeft,e=this.iconRight,f,g,h=this.scrollbarHeight;this.rotate?(f=this.dragIconWidth,g=this.dragIconHeight,d.translate(this.x+(h-g)/2,this.y+c-f/2),e.translate(this.x+(h-g)/2,this.y+c+a.height-f/2)):(f=this.dragIconHeight,g=this.dragIconWidth,d.translate(this.x+b-g/2,this.y+(h-f)/2),e.translate(this.x+b-g/2+a.width,this.y+(h-f)/2))},showDragIcons:function(){this.resizeEnabled&&(this.iconLeft.show(),this.iconRight.show())},hideDragIcons:function(){if(!this.resizingLeft&&!this.resizingRight&&
211 !this.dragging){if(this.hideResizeGrips||!this.resizeEnabled)this.iconLeft.hide(),this.iconRight.hide();this.removeCursors()}},removeCursors:function(){this.chart.setMouseCursor("auto")},relativeZoom:function(a,b){this.dragger.stop();this.multiplier=a;this.position=b;this.updateScrollbarSize(b,this.rotate?b+this.height/a:b+this.width/a)},destroy:function(){this.clear();AmCharts.remove(this.set);AmCharts.remove(this.iconRight);AmCharts.remove(this.iconLeft)},clear:function(){clearInterval(this.interval)},
212 handleDragStart:function(){var a=this.chart;this.dragger.stop();this.removeCursors();this.dragging=!0;var b=this.getDBox();this.rotate?(this.initialCoord=b.y,this.initialMouse=a.mouseY):(this.initialCoord=b.x,this.initialMouse=a.mouseX)},handleDragStop:function(){this.updateOnReleaseOnly&&(this.updateScrollbar(),this.skipEvent=!1,this.dispatchScrollbarEvent());this.dragging=!1;this.mouseIsOver&&this.removeCursors();this.updateScrollbar()},handleDraggerOver:function(){this.handleMouseOver()},leftDragStart:function(){this.dragger.stop();
213 this.resizingLeft=!0},leftDragStop:function(){this.resizingLeft=!1;this.mouseIsOver||this.removeCursors();this.updateOnRelease()},rightDragStart:function(){this.dragger.stop();this.resizingRight=!0},rightDragStop:function(){this.resizingRight=!1;this.mouseIsOver||this.removeCursors();this.updateOnRelease()},iconRollOut:function(){this.removeCursors()},iconRollOver:function(){this.rotate?this.chart.setMouseCursor("n-resize"):this.chart.setMouseCursor("e-resize");this.handleMouseOver()},getDBox:function(){if(this.dragger)return this.dragger.getBBox()},
214 handleBgClick:function(){if(!this.resizingRight&&!this.resizingLeft){this.zooming=!0;var a,b,c=this.scrollDuration,d=this.dragger;a=this.getDBox();var e=a.height,f=a.width;b=this.chart;var g=this.y,h=this.x,k=this.rotate;k?(a="y",b=b.mouseY-e/2-g,b=AmCharts.fitToBounds(b,0,this.height-e)):(a="x",b=b.mouseX-f/2-h,b=AmCharts.fitToBounds(b,0,this.width-f));this.updateOnReleaseOnly?(this.skipEvent=!1,d.setAttr(a,b),this.dispatchScrollbarEvent(),this.clipDragger()):(b=Math.round(b),k?d.animate({y:b},c,
215 ">"):d.animate({x:b},c,">"))}},updateOnRelease:function(){this.updateOnReleaseOnly&&(this.updateScrollbar(),this.skipEvent=!1,this.dispatchScrollbarEvent())},handleReleaseOutside:function(){if(this.set){if(this.resizingLeft||this.resizingRight||this.dragging)this.updateOnRelease(),this.removeCursors();this.mouseIsOver=this.dragging=this.resizingRight=this.resizingLeft=!1;this.hideDragIcons();this.updateScrollbar()}},handleMouseOver:function(){this.mouseIsOver=!0;this.showDragIcons()},handleMouseOut:function(){this.mouseIsOver=
216 !1;this.hideDragIcons()}});AmCharts.ChartScrollbar=AmCharts.Class({inherits:AmCharts.SimpleChartScrollbar,construct:function(a){this.cname="ChartScrollbar";AmCharts.ChartScrollbar.base.construct.call(this,a);this.graphLineColor="#BBBBBB";this.graphLineAlpha=0;this.graphFillColor="#BBBBBB";this.graphFillAlpha=1;this.selectedGraphLineColor="#888888";this.selectedGraphLineAlpha=0;this.selectedGraphFillColor="#888888";this.selectedGraphFillAlpha=1;this.gridCount=0;this.gridColor="#FFFFFF";this.gridAlpha=.7;this.skipEvent=this.autoGridCount=
217 !1;this.color="#FFFFFF";this.scrollbarCreated=!1;this.offset=0;AmCharts.applyTheme(this,a,this.cname)},init:function(){var a=this.categoryAxis,b=this.chart;a||(this.categoryAxis=a=new AmCharts.CategoryAxis);a.chart=b;a.id="scrollbar";a.dateFormats=b.categoryAxis.dateFormats;a.markPeriodChange=b.categoryAxis.markPeriodChange;a.boldPeriodBeginning=b.categoryAxis.boldPeriodBeginning;a.axisItemRenderer=AmCharts.RecItem;a.axisRenderer=AmCharts.RecAxis;a.guideFillRenderer=AmCharts.RecFill;a.inside=!0;a.fontSize=
218 this.fontSize;a.tickLength=0;a.axisAlpha=0;AmCharts.isString(this.graph)&&(this.graph=AmCharts.getObjById(b.graphs,this.graph));if(a=this.graph){var c=this.valueAxis;c||(this.valueAxis=c=new AmCharts.ValueAxis,c.visible=!1,c.scrollbar=!0,c.axisItemRenderer=AmCharts.RecItem,c.axisRenderer=AmCharts.RecAxis,c.guideFillRenderer=AmCharts.RecFill,c.labelsEnabled=!1,c.chart=b);b=this.unselectedGraph;b||(b=new AmCharts.AmGraph,b.scrollbar=!0,this.unselectedGraph=b,b.negativeBase=a.negativeBase,b.noStepRisers=
219 a.noStepRisers);b=this.selectedGraph;b||(b=new AmCharts.AmGraph,b.scrollbar=!0,this.selectedGraph=b,b.negativeBase=a.negativeBase,b.noStepRisers=a.noStepRisers)}this.scrollbarCreated=!0},draw:function(){var a=this;AmCharts.ChartScrollbar.base.draw.call(a);a.scrollbarCreated||a.init();var b=a.chart,c=b.chartData,d=a.categoryAxis,e=a.rotate,f=a.x,g=a.y,h=a.width,k=a.height,l=b.categoryAxis,m=a.set;d.setOrientation(!e);d.parseDates=l.parseDates;d.rotate=e;d.equalSpacing=l.equalSpacing;d.minPeriod=l.minPeriod;
220 d.startOnAxis=l.startOnAxis;d.viW=h;d.viH=k;d.width=h;d.height=k;d.gridCount=a.gridCount;d.gridColor=a.gridColor;d.gridAlpha=a.gridAlpha;d.color=a.color;d.tickLength=0;d.axisAlpha=0;d.autoGridCount=a.autoGridCount;d.parseDates&&!d.equalSpacing&&d.timeZoom(b.firstTime,b.lastTime);d.zoom(0,c.length-1);if(l=a.graph){var n=a.valueAxis,p=l.valueAxis;n.id=p.id;n.rotate=e;n.setOrientation(e);n.width=h;n.height=k;n.viW=h;n.viH=k;n.dataProvider=c;n.reversed=p.reversed;n.logarithmic=p.logarithmic;n.gridAlpha=
221 0;n.axisAlpha=0;m.push(n.set);e?(n.y=g,n.x=0):(n.x=f,n.y=0);var f=Infinity,g=-Infinity,q;for(q=0;q<c.length;q++){var r=c[q].axes[p.id].graphs[l.id].values,s;for(s in r)if(r.hasOwnProperty(s)&&"percents"!=s&&"total"!=s){var v=r[s];v<f&&(f=v);v>g&&(g=v)}}Infinity!=f&&(n.minimum=f);-Infinity!=g&&(n.maximum=g+.1*(g-f));f==g&&(n.minimum-=1,n.maximum+=1);void 0!==a.minimum&&(n.minimum=a.minimum);void 0!==a.maximum&&(n.maximum=a.maximum);n.zoom(0,c.length-1);s=a.unselectedGraph;s.id=l.id;s.rotate=e;s.chart=
222 b;s.data=c;s.valueAxis=n;s.chart=l.chart;s.categoryAxis=a.categoryAxis;s.periodSpan=l.periodSpan;s.valueField=l.valueField;s.openField=l.openField;s.closeField=l.closeField;s.highField=l.highField;s.lowField=l.lowField;s.lineAlpha=a.graphLineAlpha;s.lineColorR=a.graphLineColor;s.fillAlphas=a.graphFillAlpha;s.fillColorsR=a.graphFillColor;s.connect=l.connect;s.hidden=l.hidden;s.width=h;s.height=k;s.pointPosition=l.pointPosition;s.stepDirection=l.stepDirection;s.periodSpan=l.periodSpan;p=a.selectedGraph;
223 p.id=l.id;p.rotate=e;p.chart=b;p.data=c;p.valueAxis=n;p.chart=l.chart;p.categoryAxis=d;p.periodSpan=l.periodSpan;p.valueField=l.valueField;p.openField=l.openField;p.closeField=l.closeField;p.highField=l.highField;p.lowField=l.lowField;p.lineAlpha=a.selectedGraphLineAlpha;p.lineColorR=a.selectedGraphLineColor;p.fillAlphas=a.selectedGraphFillAlpha;p.fillColorsR=a.selectedGraphFillColor;p.connect=l.connect;p.hidden=l.hidden;p.width=h;p.height=k;p.pointPosition=l.pointPosition;p.stepDirection=l.stepDirection;
224 p.periodSpan=l.periodSpan;b=a.graphType;b||(b=l.type);s.type=b;p.type=b;c=c.length-1;s.zoom(0,c);p.zoom(0,c);p.set.click(function(){a.handleBackgroundClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()});s.set.click(function(){a.handleBackgroundClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()});m.push(s.set);m.push(p.set)}m.push(d.set);m.push(d.labelsSet);a.bg.toBack();a.invisibleBg.toFront();a.dragger.toFront();a.iconLeft.toFront();
225 a.iconRight.toFront()},timeZoom:function(a,b,c){this.startTime=a;this.endTime=b;this.timeDifference=b-a;this.skipEvent=!AmCharts.toBoolean(c);this.zoomScrollbar();this.skipEvent||this.dispatchScrollbarEvent()},zoom:function(a,b){this.start=a;this.end=b;this.skipEvent=!0;this.zoomScrollbar()},dispatchScrollbarEvent:function(){if(this.skipEvent)this.skipEvent=!1;else{var a=this.chart.chartData,b,c,d=this.dragger.getBBox();b=d.x;var e=d.y,f=d.width;c=d.height;d=this.chart;this.rotate?b=e:c=f;f={type:"zoomed",
226 target:this};f.chart=d;var g=this.categoryAxis,h=this.stepWidth,e=d.minSelectedTime;if(g.parseDates&&!g.equalSpacing){if(a=d.lastTime,d=d.firstTime,g.minDuration(),g=Math.round(b/h)+d,b=this.dragging?g+this.timeDifference:Math.round((b+c)/h)+d,g>b&&(g=b),0<e&&b-g<e&&(b=Math.round(g+(b-g)/2),c=Math.round(e/2),g=b-c,b+=c),b>a&&(b=a),b-e<g&&(g=b-e),g<d&&(g=d),g+e>b&&(b=g+e),g!=this.startTime||b!=this.endTime)this.startTime=g,this.endTime=b,f.start=g,f.end=b,f.startDate=new Date(g),f.endDate=new Date(b),
227 this.fire(f.type,f)}else if(g.startOnAxis||(b+=h/2),c-=this.stepWidth/2,e=g.xToIndex(b),b=g.xToIndex(b+c),e!=this.start||this.end!=b)g.startOnAxis&&(this.resizingRight&&e==b&&b++,this.resizingLeft&&e==b&&(0<e?e--:b=1)),this.start=e,this.end=this.dragging?this.start+this.difference:b,f.start=this.start,f.end=this.end,g.parseDates&&(a[this.start]&&(f.startDate=new Date(a[this.start].time)),a[this.end]&&(f.endDate=new Date(a[this.end].time))),this.fire(f.type,f)}this.zoomScrollbar()},zoomScrollbar:function(){var a,
228 b;a=this.chart;var c=a.chartData,d=this.categoryAxis;d.parseDates&&!d.equalSpacing?(c=d.stepWidth,d=a.firstTime,a=c*(this.startTime-d),b=c*(this.endTime-d)):(a=c[this.start].x[d.id],b=c[this.end].x[d.id],c=d.stepWidth,d.startOnAxis||(d=c/2,a-=d,b+=d));this.stepWidth=c;this.updateScrollbarSize(a,b)},maskGraphs:function(a,b,c,d){var e=this.selectedGraph;e&&e.set.clipRect(a,b,c,d)},handleDragStart:function(){AmCharts.ChartScrollbar.base.handleDragStart.call(this);this.difference=this.end-this.start;
229 this.timeDifference=this.endTime-this.startTime;0>this.timeDifference&&(this.timeDifference=0)},handleBackgroundClick:function(){AmCharts.ChartScrollbar.base.handleBackgroundClick.call(this);this.dragging||(this.difference=this.end-this.start,this.timeDifference=this.endTime-this.startTime,0>this.timeDifference&&(this.timeDifference=0))}});AmCharts.AmBalloon=AmCharts.Class({construct:function(a){this.cname="AmBalloon";this.enabled=!0;this.fillColor="#FFFFFF";this.fillAlpha=.8;this.borderThickness=2;this.borderColor="#FFFFFF";this.borderAlpha=1;this.cornerRadius=0;this.maximumWidth=220;this.horizontalPadding=8;this.verticalPadding=4;this.pointerWidth=6;this.pointerOrientation="V";this.color="#000000";this.adjustBorderColor=!0;this.show=this.follow=this.showBullet=!1;this.bulletSize=3;this.shadowAlpha=.4;this.shadowColor="#000000";this.fadeOutDuration=
230 this.animationDuration=.3;this.fixedPosition=!1;this.offsetY=6;this.offsetX=1;this.textAlign="center";AmCharts.isModern||(this.offsetY*=1.5);AmCharts.applyTheme(this,a,this.cname)},draw:function(){var a=this.pointToX,b=this.pointToY;this.deltaSignX=this.deltaSignY=1;var c=this.chart;AmCharts.VML&&(this.fadeOutDuration=0);this.xAnim&&c.stopAnim(this.xAnim);this.yAnim&&c.stopAnim(this.yAnim);if(!isNaN(a)){var d=this.follow,e=c.container,f=this.set;AmCharts.remove(f);this.removeDiv();f=e.set();f.node.style.pointerEvents=
231 "none";this.set=f;c.balloonsSet.push(f);if(this.show){var g=this.l,h=this.t,k=this.r,l=this.b,m=this.balloonColor,n=this.fillColor,p=this.borderColor,q=n;void 0!=m&&(this.adjustBorderColor?q=p=m:n=m);var r=this.horizontalPadding,s=this.verticalPadding,v=this.pointerWidth,w=this.pointerOrientation,t=this.cornerRadius,u=c.fontFamily,y=this.fontSize;void 0==y&&(y=c.fontSize);var m=document.createElement("div"),E=m.style;E.pointerEvents="none";E.position="absolute";var A=this.minWidth,z="";isNaN(A)||
232 (z="min-width:"+(A-2*r)+"px; ");m.innerHTML='<div style="text-align:'+this.textAlign+"; "+z+"max-width:"+this.maxWidth+"px; font-size:"+y+"px; color:"+this.color+"; font-family:"+u+'">'+this.text+"</div>";c.chartDiv.appendChild(m);this.textDiv=m;y=m.offsetWidth;u=m.offsetHeight;m.clientHeight&&(y=m.clientWidth,u=m.clientHeight);u+=2*s;z=y+2*r;!isNaN(A)&&z<A&&(z=A);window.opera&&(u+=2);var K=!1,y=this.offsetY;c.handDrawn&&(y+=c.handDrawScatter+2);"H"!=w?(A=a-z/2,b<h+u+10&&"down"!=w?(K=!0,d&&(b+=y),
233 y=b+v,this.deltaSignY=-1):(d&&(b-=y),y=b-u-v,this.deltaSignY=1)):(2*v>u&&(v=u/2),y=b-u/2,a<g+(k-g)/2?(A=a+v,this.deltaSignX=-1):(A=a-z-v,this.deltaSignX=1));y+u>=l&&(y=l-u);y<h&&(y=h);A<g&&(A=g);A+z>k&&(A=k-z);var h=y+s,l=A+r,s=this.shadowAlpha,I=this.shadowColor,r=this.borderThickness,F=this.bulletSize,H;0<t||0===v?(0<s&&(a=AmCharts.rect(e,z,u,n,0,r+1,I,s,this.cornerRadius),AmCharts.isModern?a.translate(1,1):a.translate(4,4),f.push(a)),n=AmCharts.rect(e,z,u,n,this.fillAlpha,r,p,this.borderAlpha,
234 this.cornerRadius),this.showBullet&&(H=AmCharts.circle(e,F,q,this.fillAlpha),f.push(H))):(q=[],t=[],"H"!=w?(g=a-A,g>z-v&&(g=z-v),g<v&&(g=v),q=[0,g-v,a-A,g+v,z,z,0,0],t=K?[0,0,b-y,0,0,u,u,0]:[u,u,b-y,u,u,0,0,u]):(q=b-y,q>u-v&&(q=u-v),q<v&&(q=v),t=[0,q-v,b-y,q+v,u,u,0,0],q=a<g+(k-g)/2?[0,0,A<a?0:a-A,0,0,z,z,0]:[z,z,A+z>a?z:a-A,z,z,0,0,z]),0<s&&(a=AmCharts.polygon(e,q,t,n,0,r,I,s),a.translate(1,1),f.push(a)),n=AmCharts.polygon(e,q,t,n,this.fillAlpha,r,p,this.borderAlpha));this.bg=n;f.push(n);n.toFront();
235 e=1*this.deltaSignX;E.left=l+"px";E.top=h+"px";f.translate(A-e,y);n=n.getBBox();this.bottom=y+u+1;this.yPos=n.y+y;H&&H.translate(this.pointToX-A+e,b-y);b=this.animationDuration;0<this.animationDuration&&!d&&!isNaN(this.prevX)&&(f.translate(this.prevX,this.prevY),f.animate({translate:A-e+","+y},b,"easeOutSine"),m&&(E.left=this.prevTX+"px",E.top=this.prevTY+"px",this.xAnim=c.animate({node:m},"left",this.prevTX,l,b,"easeOutSine","px"),this.yAnim=c.animate({node:m},"top",this.prevTY,h,b,"easeOutSine",
236 "px")));this.prevX=A-e;this.prevY=y;this.prevTX=l;this.prevTY=h}}},followMouse:function(){if(this.follow&&this.show){var a=this.chart.mouseX-this.offsetX*this.deltaSignX,b=this.chart.mouseY;this.pointToX=a;this.pointToY=b;if(a!=this.previousX||b!=this.previousY)if(this.previousX=a,this.previousY=b,0===this.cornerRadius)this.draw();else{var c=this.set;if(c){var d=c.getBBox(),a=a-d.width/2,e=b-d.height-10;a<this.l&&(a=this.l);a>this.r-d.width&&(a=this.r-d.width);e<this.t&&(e=b+10);c.translate(a,e);
237 b=this.textDiv.style;b.left=a+this.horizontalPadding+"px";b.top=e+this.verticalPadding+"px"}}}},changeColor:function(a){this.balloonColor=a},setBounds:function(a,b,c,d){this.l=a;this.t=b;this.r=c;this.b=d;this.destroyTO&&clearTimeout(this.destroyTO)},showBalloon:function(a){this.text=a;this.show=!0;this.destroyTO&&clearTimeout(this.destroyTO);a=this.chart;this.fadeAnim1&&a.stopAnim(this.fadeAnim1);this.fadeAnim2&&a.stopAnim(this.fadeAnim2);this.draw()},hide:function(){var a=this,b=a.fadeOutDuration,
238 c=a.chart;if(0<b){a.destroyTO=setTimeout(function(){a.destroy.call(a)},1E3*b);a.follow=!1;a.show=!1;var d=a.set;d&&(d.setAttr("opacity",a.fillAlpha),a.fadeAnim1=d.animate({opacity:0},b,"easeInSine"));a.textDiv&&(a.fadeAnim2=c.animate({node:a.textDiv},"opacity",1,0,b,"easeInSine",""))}else a.show=!1,a.follow=!1,a.destroy()},setPosition:function(a,b,c){this.pointToX=a;this.pointToY=b;c&&(a==this.previousX&&b==this.previousY||this.draw());this.previousX=a;this.previousY=b},followCursor:function(a){var b=
239 this;(b.follow=a)?(b.pShowBullet=b.showBullet,b.showBullet=!1):void 0!==b.pShowBullet&&(b.showBullet=b.pShowBullet);clearInterval(b.interval);var c=b.chart.mouseX,d=b.chart.mouseY;!isNaN(c)&&a&&(b.pointToX=c-b.offsetX*b.deltaSignX,b.pointToY=d,b.followMouse(),b.interval=setInterval(function(){b.followMouse.call(b)},40))},removeDiv:function(){if(this.textDiv){var a=this.textDiv.parentNode;a&&a.removeChild(this.textDiv)}},destroy:function(){clearInterval(this.interval);AmCharts.remove(this.set);this.removeDiv();
240 this.set=null}});AmCharts.AmCoordinateChart=AmCharts.Class({inherits:AmCharts.AmChart,construct:function(a){AmCharts.AmCoordinateChart.base.construct.call(this,a);this.theme=a;this.createEvents("rollOverGraphItem","rollOutGraphItem","clickGraphItem","doubleClickGraphItem","rightClickGraphItem","clickGraph","rollOverGraph","rollOutGraph");this.startAlpha=1;this.startDuration=0;this.startEffect="elastic";this.sequencedAnimation=!0;this.colors="#FF6600 #FCD202 #B0DE09 #0D8ECF #2A0CD0 #CD0D74 #CC0000 #00CC00 #0000CC #DDDDDD #999999 #333333 #990000".split(" ");
241 this.balloonDateFormat="MMM DD, YYYY";this.valueAxes=[];this.graphs=[];this.guides=[];this.gridAboveGraphs=!1;AmCharts.applyTheme(this,a,"AmCoordinateChart")},initChart:function(){AmCharts.AmCoordinateChart.base.initChart.call(this);var a=this.categoryAxis;a&&(this.categoryAxis=AmCharts.processObject(a,AmCharts.CategoryAxis,this.theme));this.processValueAxes();this.createValueAxes();this.processGraphs();this.processGuides();AmCharts.VML&&(this.startAlpha=1);this.setLegendData(this.graphs);this.gridAboveGraphs&&
242 this.gridSet.toFront()},createValueAxes:function(){if(0===this.valueAxes.length){var a=new AmCharts.ValueAxis;this.addValueAxis(a)}},parseData:function(){this.processValueAxes();this.processGraphs()},parseSerialData:function(){var a=this.graphs,b,c={},d=this.seriesIdField;d||(d=this.categoryField);this.chartData=[];var e=this.dataProvider;if(e){var f=!1,g,h=this.categoryAxis,k,l;h&&(f=h.parseDates,k=h.forceShowField,l=h.labelColorField,g=h.categoryFunction);var m,n,p={},q;f&&(b=AmCharts.extractPeriod(h.minPeriod),
243 m=b.period,n=b.count,q=AmCharts.getPeriodDuration(m,n));var r={};this.lookupTable=r;var s,v=this.dataDateFormat,w={};for(s=0;s<e.length;s++){var t={},u=e[s];b=u[this.categoryField];t.dataContext=u;t.category=g?g(b,u,h):String(b);k&&(t.forceShow=u[k]);l&&(t.labelColor=u[l]);r[u[d]]=t;if(f&&(b=h.categoryFunction?h.categoryFunction(b,u,h):b instanceof Date?AmCharts.newDate(b,h.minPeriod):v?AmCharts.stringToDate(b,v):new Date(b),b=AmCharts.resetDateToMin(b,m,n,h.firstDayOfWeek),t.category=b,t.time=b.getTime(),
244 isNaN(t.time)))continue;var y=this.valueAxes;t.axes={};t.x={};var E;for(E=0;E<y.length;E++){var A=y[E].id;t.axes[A]={};t.axes[A].graphs={};var z;for(z=0;z<a.length;z++){b=a[z];var K=b.id,I=b.periodValue;if(b.valueAxis.id==A){t.axes[A].graphs[K]={};var F={};F.index=s;var H=u;b.dataProvider&&(H=c);F.values=this.processValues(H,b,I);!b.connect&&w&&w[K]&&t.time-p[K]>1.1*q&&(w[K].gap=!0);this.processFields(b,F,H);F.category=t.category;F.serialDataItem=t;F.graph=b;t.axes[A].graphs[K]=F}p[K]=t.time;w[K]=
245 F}}this.chartData[s]=t}}for(c=0;c<a.length;c++)b=a[c],b.dataProvider&&this.parseGraphData(b)},processValues:function(a,b,c){var d={},e,f=!1;"candlestick"!=b.type&&"ohlc"!=b.type||""===c||(f=!0);e=Number(a[b.valueField+c]);isNaN(e)||(d.value=e);e=Number(a[b.errorField+c]);isNaN(e)||(d.error=e);f&&(c="Open");e=Number(a[b.openField+c]);isNaN(e)||(d.open=e);f&&(c="Close");e=Number(a[b.closeField+c]);isNaN(e)||(d.close=e);f&&(c="Low");e=Number(a[b.lowField+c]);isNaN(e)||(d.low=e);f&&(c="High");e=Number(a[b.highField+
246 c]);isNaN(e)||(d.high=e);return d},parseGraphData:function(a){var b=a.dataProvider,c=a.seriesIdField;c||(c=this.seriesIdField);c||(c=this.categoryField);var d;for(d=0;d<b.length;d++){var e=b[d],f=this.lookupTable[String(e[c])],g=a.valueAxis.id;f&&(g=f.axes[g].graphs[a.id],g.serialDataItem=f,g.values=this.processValues(e,a,a.periodValue),this.processFields(a,g,e))}},addValueAxis:function(a){a.chart=this;this.valueAxes.push(a);this.validateData()},removeValueAxesAndGraphs:function(){var a=this.valueAxes,
247 b;for(b=a.length-1;-1<b;b--)this.removeValueAxis(a[b])},removeValueAxis:function(a){var b=this.graphs,c;for(c=b.length-1;0<=c;c--){var d=b[c];d&&d.valueAxis==a&&this.removeGraph(d)}b=this.valueAxes;for(c=b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1);this.validateData()},addGraph:function(a){this.graphs.push(a);this.chooseGraphColor(a,this.graphs.length-1);this.validateData()},removeGraph:function(a){var b=this.graphs,c;for(c=b.length-1;0<=c;c--)b[c]==a&&(b.splice(c,1),a.destroy());this.validateData()},
248 processValueAxes:function(){var a=this.valueAxes,b;for(b=0;b<a.length;b++){var c=a[b],c=AmCharts.processObject(c,AmCharts.ValueAxis,this.theme);a[b]=c;c.chart=this;c.id||(c.id="valueAxisAuto"+b+"_"+(new Date).getTime());void 0===c.usePrefixes&&(c.usePrefixes=this.usePrefixes)}},processGuides:function(){var a=this.guides,b=this.categoryAxis;if(a)for(var c=0;c<a.length;c++){var d=a[c];(void 0!==d.category||void 0!==d.date)&&b&&b.addGuide(d);var e=d.valueAxis;e?(AmCharts.isString(e)&&(e=this.getValueAxisById(e)),
249 e?e.addGuide(d):this.valueAxes[0].addGuide(d)):isNaN(d.value)||this.valueAxes[0].addGuide(d)}},processGraphs:function(){var a=this.graphs,b;for(b=0;b<a.length;b++){var c=a[b],c=AmCharts.processObject(c,AmCharts.AmGraph,this.theme);a[b]=c;this.chooseGraphColor(c,b);c.chart=this;AmCharts.isString(c.valueAxis)&&(c.valueAxis=this.getValueAxisById(c.valueAxis));c.valueAxis||(c.valueAxis=this.valueAxes[0]);c.id||(c.id="graphAuto"+b+"_"+(new Date).getTime())}},formatString:function(a,b,c){var d=b.graph,
250 e=d.valueAxis;e.duration&&b.values.value&&(e=AmCharts.formatDuration(b.values.value,e.duration,"",e.durationUnits,e.maxInterval,e.numberFormatter),a=a.split("[[value]]").join(e));a=AmCharts.massReplace(a,{"[[title]]":d.title,"[[description]]":b.description});a=c?AmCharts.fixNewLines(a):AmCharts.fixBrakes(a);return a=AmCharts.cleanFromEmpty(a)},getBalloonColor:function(a,b,c){var d=a.lineColor,e=a.balloonColor;c&&(e=d);c=a.fillColorsR;"object"==typeof c?d=c[0]:void 0!==c&&(d=c);b.isNegative&&(c=a.negativeLineColor,
251 a=a.negativeFillColors,"object"==typeof a?c=a[0]:void 0!==a&&(c=a),void 0!==c&&(d=c));void 0!==b.color&&(d=b.color);void 0===e&&(e=d);return e},getGraphById:function(a){return AmCharts.getObjById(this.graphs,a)},getValueAxisById:function(a){return AmCharts.getObjById(this.valueAxes,a)},processFields:function(a,b,c){if(a.itemColors){var d=a.itemColors,e=b.index;b.color=e<d.length?d[e]:AmCharts.randomColor()}d="lineColor color alpha fillColors description bullet customBullet bulletSize bulletConfig url labelColor dashLength pattern".split(" ");
252 for(e=0;e<d.length;e++){var f=d[e],g=a[f+"Field"];g&&(g=c[g],AmCharts.isDefined(g)&&(b[f]=g))}b.dataContext=c},chooseGraphColor:function(a,b){if(a.lineColor)a.lineColorR=a.lineColor;else{var c;c=this.colors.length>b?this.colors[b]:AmCharts.randomColor();a.lineColorR=c}a.fillColorsR=a.fillColors?a.fillColors:a.lineColorR;a.bulletBorderColorR=a.bulletBorderColor?a.bulletBorderColor:a.useLineColorForBulletBorder?a.lineColorR:a.bulletColor;a.bulletColorR=a.bulletColor?a.bulletColor:a.lineColorR;if(c=
253 this.patterns)a.pattern=c[b]},handleLegendEvent:function(a){var b=a.type;a=a.dataItem;if(!this.legend.data&&a){var c=a.hidden,d=a.showBalloon;switch(b){case "clickMarker":this.textClickEnabled&&(d?this.hideGraphsBalloon(a):this.showGraphsBalloon(a));break;case "clickLabel":d?this.hideGraphsBalloon(a):this.showGraphsBalloon(a);break;case "rollOverItem":c||this.highlightGraph(a);break;case "rollOutItem":c||this.unhighlightGraph();break;case "hideItem":this.hideGraph(a);break;case "showItem":this.showGraph(a)}}},
254 highlightGraph:function(a){var b=this.graphs,c,d=.2;this.legend&&(d=this.legend.rollOverGraphAlpha);if(1!=d)for(c=0;c<b.length;c++){var e=b[c];e!=a&&e.changeOpacity(d)}},unhighlightGraph:function(){var a;this.legend&&(a=this.legend.rollOverGraphAlpha);if(1!=a){a=this.graphs;var b;for(b=0;b<a.length;b++)a[b].changeOpacity(1)}},showGraph:function(a){a.switchable&&(a.hidden=!1,this.dataChanged=!0,"xy"!=this.type&&(this.marginsUpdated=!1),this.chartCreated&&this.initChart())},hideGraph:function(a){a.switchable&&
255 (this.dataChanged=!0,"xy"!=this.type&&(this.marginsUpdated=!1),a.hidden=!0,this.chartCreated&&this.initChart())},hideGraphsBalloon:function(a){a.showBalloon=!1;this.updateLegend()},showGraphsBalloon:function(a){a.showBalloon=!0;this.updateLegend()},updateLegend:function(){this.legend&&this.legend.invalidateSize()},resetAnimation:function(){var a=this.graphs;if(a){var b;for(b=0;b<a.length;b++)a[b].animationPlayed=!1}},animateAgain:function(){this.resetAnimation();this.validateNow()}});AmCharts.AmSlicedChart=AmCharts.Class({inherits:AmCharts.AmChart,construct:function(a){this.createEvents("rollOverSlice","rollOutSlice","clickSlice","pullOutSlice","pullInSlice","rightClickSlice");AmCharts.AmSlicedChart.base.construct.call(this,a);this.colors="#FF0F00 #FF6600 #FF9E01 #FCD202 #F8FF01 #B0DE09 #04D215 #0D8ECF #0D52D1 #2A0CD0 #8A0CCF #CD0D74 #754DEB #DDDDDD #999999 #333333 #000000 #57032A #CA9726 #990000 #4B0C25".split(" ");this.alpha=1;this.groupPercent=0;this.groupedTitle="Other";this.groupedPulled=
256 !1;this.groupedAlpha=1;this.marginLeft=0;this.marginBottom=this.marginTop=10;this.marginRight=0;this.hoverAlpha=1;this.outlineColor="#FFFFFF";this.outlineAlpha=0;this.outlineThickness=1;this.startAlpha=0;this.startDuration=1;this.startEffect="bounce";this.sequencedAnimation=!0;this.pullOutDuration=1;this.pullOutEffect="bounce";this.pullOnHover=this.pullOutOnlyOne=!1;this.labelsEnabled=!0;this.labelTickColor="#000000";this.labelTickAlpha=.2;this.hideLabelsPercent=0;this.urlTarget="_self";this.autoMarginOffset=
257 10;this.gradientRatio=[];this.maxLabelWidth=200;AmCharts.applyTheme(this,a,"AmSlicedChart")},initChart:function(){AmCharts.AmSlicedChart.base.initChart.call(this);this.dataChanged&&(this.parseData(),this.dispatchDataUpdated=!0,this.dataChanged=!1,this.setLegendData(this.chartData));this.drawChart()},handleLegendEvent:function(a){var b=a.type;a=a.dataItem;if(!this.legend.data&&a){var c=a.hidden;switch(b){case "clickMarker":c||this.clickSlice(a);break;case "clickLabel":c||this.clickSlice(a);break;case "rollOverItem":c||
258 this.rollOverSlice(a,!1);break;case "rollOutItem":c||this.rollOutSlice(a);break;case "hideItem":this.hideSlice(a);break;case "showItem":this.showSlice(a)}}},invalidateVisibility:function(){this.recalculatePercents();this.initChart();var a=this.legend;a&&a.invalidateSize()},addEventListeners:function(a,b){var c=this;a.mouseover(function(a){c.rollOverSlice(b,!0,a)}).mouseout(function(a){c.rollOutSlice(b,a)}).touchend(function(a){c.rollOverSlice(b,a);c.panEventsEnabled&&c.clickSlice(b,a)}).touchstart(function(a){c.rollOverSlice(b,
259 a)}).click(function(a){c.clickSlice(b,a)}).contextmenu(function(a){c.handleRightClick(b,a)})},formatString:function(a,b,c){a=AmCharts.formatValue(a,b,["value"],this.nf,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);a=AmCharts.formatValue(a,b,["percents"],this.pf);a=AmCharts.massReplace(a,{"[[title]]":b.title,"[[description]]":b.description});-1!=a.indexOf("[[")&&(a=AmCharts.formatDataContextValue(a,b.dataContext));a=c?AmCharts.fixNewLines(a):AmCharts.fixBrakes(a);return a=
260 AmCharts.cleanFromEmpty(a)},startSlices:function(){var a;for(a=0;a<this.chartData.length;a++)0<this.startDuration&&this.sequencedAnimation?this.setStartTO(a):this.startSlice(this.chartData[a])},setStartTO:function(a){var b=this;a=setTimeout(function(){b.startSequenced.call(b)},b.startDuration/b.chartData.length*500*a);b.timeOuts.push(a)},pullSlices:function(a){var b=this.chartData,c;for(c=0;c<b.length;c++){var d=b[c];d.pulled&&this.pullSlice(d,1,a)}},startSequenced:function(){var a=this.chartData,
261 b;for(b=0;b<a.length;b++)if(!a[b].started){this.startSlice(this.chartData[b]);break}},startSlice:function(a){a.started=!0;var b=a.wedge,c=this.startDuration;b&&0<c&&(0<a.alpha&&b.show(),b.translate(a.startX,a.startY),b.animate({opacity:1,translate:"0,0"},c,this.startEffect))},showLabels:function(){var a=this.chartData,b;for(b=0;b<a.length;b++){var c=a[b];if(0<c.alpha){var d=c.label;d&&d.show();(c=c.tick)&&c.show()}}},showSlice:function(a){isNaN(a)?a.hidden=!1:this.chartData[a].hidden=!1;this.invalidateVisibility()},
262 hideSlice:function(a){isNaN(a)?a.hidden=!0:this.chartData[a].hidden=!0;this.hideBalloon();this.invalidateVisibility()},rollOverSlice:function(a,b,c){isNaN(a)||(a=this.chartData[a]);clearTimeout(this.hoverInt);if(!a.hidden){this.pullOnHover&&this.pullSlice(a,1);1>this.hoverAlpha&&a.wedge&&a.wedge.attr({opacity:this.hoverAlpha});var d=a.balloonX,e=a.balloonY;a.pulled&&(d+=a.pullX,e+=a.pullY);var f=this.formatString(this.balloonText,a,!0),g=this.balloonFunction;g&&(f=g(a,f));g=AmCharts.adjustLuminosity(a.color,
263 -.15);this.showBalloon(f,g,b,d,e);a={type:"rollOverSlice",dataItem:a,chart:this,event:c};this.fire(a.type,a)}},rollOutSlice:function(a,b){isNaN(a)||(a=this.chartData[a]);a.wedge&&a.wedge.attr({opacity:1});this.hideBalloon();var c={type:"rollOutSlice",dataItem:a,chart:this,event:b};this.fire(c.type,c)},clickSlice:function(a,b){isNaN(a)||(a=this.chartData[a]);a.pulled?this.pullSlice(a,0):this.pullSlice(a,1);AmCharts.getURL(a.url,this.urlTarget);var c={type:"clickSlice",dataItem:a,chart:this,event:b};
264 this.fire(c.type,c)},handleRightClick:function(a,b){isNaN(a)||(a=this.chartData[a]);var c={type:"rightClickSlice",dataItem:a,chart:this,event:b};this.fire(c.type,c)},drawTicks:function(){var a=this.chartData,b;for(b=0;b<a.length;b++){var c=a[b];if(c.label){var d=c.ty,d=AmCharts.line(this.container,[c.tx0,c.tx,c.tx2],[c.ty0,d,d],this.labelTickColor,this.labelTickAlpha);c.tick=d;c.wedge.push(d)}}},initialStart:function(){var a=this,b=a.startDuration,c=setTimeout(function(){a.showLabels.call(a)},1E3*
265 b);a.timeOuts.push(c);a.chartCreated?a.pullSlices(!0):(a.startSlices(),0<b?(b=setTimeout(function(){a.pullSlices.call(a)},1200*b),a.timeOuts.push(b)):a.pullSlices(!0))},pullSlice:function(a,b,c){var d=this.pullOutDuration;!0===c&&(d=0);(c=a.wedge)&&(0<d?c.animate({translate:b*a.pullX+","+b*a.pullY},d,this.pullOutEffect):c.translate(b*a.pullX,b*a.pullY));1==b?(a.pulled=!0,this.pullOutOnlyOne&&this.pullInAll(a.index),a={type:"pullOutSlice",dataItem:a,chart:this}):(a.pulled=!1,a={type:"pullInSlice",
266 dataItem:a,chart:this});this.fire(a.type,a)},pullInAll:function(a){var b=this.chartData,c;for(c=0;c<this.chartData.length;c++)c!=a&&b[c].pulled&&this.pullSlice(b[c],0)},pullOutAll:function(a){a=this.chartData;var b;for(b=0;b<a.length;b++)a[b].pulled||this.pullSlice(a[b],1)},parseData:function(){var a=[];this.chartData=a;var b=this.dataProvider;isNaN(this.pieAlpha)||(this.alpha=this.pieAlpha);if(void 0!==b){var c=b.length,d=0,e,f,g;for(e=0;e<c;e++){f={};var h=b[e];f.dataContext=h;f.value=Number(h[this.valueField]);
267 (g=h[this.titleField])||(g="");f.title=g;f.pulled=AmCharts.toBoolean(h[this.pulledField],!1);(g=h[this.descriptionField])||(g="");f.description=g;f.labelRadius=Number(h[this.labelRadiusField]);f.switchable=!0;f.url=h[this.urlField];g=h[this.patternField];!g&&this.patterns&&(g=this.patterns[e]);f.pattern=g;f.visibleInLegend=AmCharts.toBoolean(h[this.visibleInLegendField],!0);g=h[this.alphaField];f.alpha=void 0!==g?Number(g):this.alpha;g=h[this.colorField];void 0!==g&&(f.color=AmCharts.toColor(g));
268 f.labelColor=AmCharts.toColor(h[this.labelColorField]);d+=f.value;f.hidden=!1;a[e]=f}for(e=b=0;e<c;e++)f=a[e],f.percents=f.value/d*100,f.percents<this.groupPercent&&b++;1<b&&(this.groupValue=0,this.removeSmallSlices(),a.push({title:this.groupedTitle,value:this.groupValue,percents:this.groupValue/d*100,pulled:this.groupedPulled,color:this.groupedColor,url:this.groupedUrl,description:this.groupedDescription,alpha:this.groupedAlpha,pattern:this.groupedPattern,dataContext:{}}));c=this.baseColor;c||(c=
269 this.pieBaseColor);d=this.brightnessStep;d||(d=this.pieBrightnessStep);for(e=0;e<a.length;e++)c?g=AmCharts.adjustLuminosity(c,e*d/100):(g=this.colors[e],void 0===g&&(g=AmCharts.randomColor())),void 0===a[e].color&&(a[e].color=g);this.recalculatePercents()}},recalculatePercents:function(){var a=this.chartData,b=0,c,d;for(c=0;c<a.length;c++)d=a[c],!d.hidden&&0<d.value&&(b+=d.value);for(c=0;c<a.length;c++)d=this.chartData[c],d.percents=!d.hidden&&0<d.value?100*d.value/b:0},removeSmallSlices:function(){var a=
270 this.chartData,b;for(b=a.length-1;0<=b;b--)a[b].percents<this.groupPercent&&(this.groupValue+=a[b].value,a.splice(b,1))},animateAgain:function(){var a=this;a.startSlices();for(var b=0;b<a.chartData.length;b++){var c=a.chartData[b];c.started=!1;var d=c.wedge;d&&d.translate(c.startX,c.startY)}b=a.startDuration;0<b?(b=setTimeout(function(){a.pullSlices.call(a)},1200*b),a.timeOuts.push(b)):a.pullSlices()},measureMaxLabel:function(){var a=this.chartData,b=0,c;for(c=0;c<a.length;c++){var d=a[c],e=this.formatString(this.labelText,
271 d),f=this.labelFunction;f&&(e=f(d,e));d=AmCharts.text(this.container,e,this.color,this.fontFamily,this.fontSize);e=d.getBBox().width;e>b&&(b=e);d.remove()}return b}});AmCharts.AmRectangularChart=AmCharts.Class({inherits:AmCharts.AmCoordinateChart,construct:function(a){AmCharts.AmRectangularChart.base.construct.call(this,a);this.theme=a;this.createEvents("zoomed");this.marginRight=this.marginBottom=this.marginTop=this.marginLeft=20;this.verticalPosition=this.horizontalPosition=this.depth3D=this.angle=0;this.heightMultiplier=this.widthMultiplier=1;this.plotAreaFillColors="#FFFFFF";this.plotAreaFillAlphas=0;this.plotAreaBorderColor="#000000";this.plotAreaBorderAlpha=
272 0;this.zoomOutButtonImageSize=17;this.zoomOutButtonImage="lens.png";this.zoomOutText="Show all";this.zoomOutButtonColor="#e5e5e5";this.zoomOutButtonAlpha=0;this.zoomOutButtonRollOverAlpha=1;this.zoomOutButtonPadding=8;this.trendLines=[];this.autoMargins=!0;this.marginsUpdated=!1;this.autoMarginOffset=10;AmCharts.applyTheme(this,a,"AmRectangularChart")},initChart:function(){AmCharts.AmRectangularChart.base.initChart.call(this);this.updateDxy();var a=!0;!this.marginsUpdated&&this.autoMargins&&(this.resetMargins(),
273 a=!1);this.processScrollbars();this.updateMargins();this.updatePlotArea();this.updateScrollbars();this.updateTrendLines();this.updateChartCursor();this.updateValueAxes();a&&(this.scrollbarOnly||this.updateGraphs())},drawChart:function(){AmCharts.AmRectangularChart.base.drawChart.call(this);this.drawPlotArea();if(AmCharts.ifArray(this.chartData)){var a=this.chartCursor;a&&a.draw();a=this.zoomOutText;""!==a&&a&&this.drawZoomOutButton()}},resetMargins:function(){var a={},b;if("serial"==this.type){var c=
274 this.valueAxes;for(b=0;b<c.length;b++){var d=c[b];d.ignoreAxisWidth||(d.setOrientation(this.rotate),d.fixAxisPosition(),a[d.position]=!0)}(b=this.categoryAxis)&&!b.ignoreAxisWidth&&(b.setOrientation(!this.rotate),b.fixAxisPosition(),b.fixAxisPosition(),a[b.position]=!0)}else{d=this.xAxes;c=this.yAxes;for(b=0;b<d.length;b++){var e=d[b];e.ignoreAxisWidth||(e.setOrientation(!0),e.fixAxisPosition(),a[e.position]=!0)}for(b=0;b<c.length;b++)d=c[b],d.ignoreAxisWidth||(d.setOrientation(!1),d.fixAxisPosition(),
275 a[d.position]=!0)}a.left&&(this.marginLeft=0);a.right&&(this.marginRight=0);a.top&&(this.marginTop=0);a.bottom&&(this.marginBottom=0);this.fixMargins=a},measureMargins:function(){var a=this.valueAxes,b,c=this.autoMarginOffset,d=this.fixMargins,e=this.realWidth,f=this.realHeight,g=c,h=c,k=e;b=f;var l;for(l=0;l<a.length;l++)b=this.getAxisBounds(a[l],g,k,h,b),g=Math.round(b.l),k=Math.round(b.r),h=Math.round(b.t),b=Math.round(b.b);if(a=this.categoryAxis)b=this.getAxisBounds(a,g,k,h,b),g=Math.round(b.l),
276 k=Math.round(b.r),h=Math.round(b.t),b=Math.round(b.b);d.left&&g<c&&(this.marginLeft=Math.round(-g+c));d.right&&k>=e-c&&(this.marginRight=Math.round(k-e+c));d.top&&h<c+this.titleHeight&&(this.marginTop=Math.round(this.marginTop-h+c+this.titleHeight));d.bottom&&b>f-c&&(this.marginBottom=Math.round(this.marginBottom+b-f+c));this.initChart()},getAxisBounds:function(a,b,c,d,e){if(!a.ignoreAxisWidth){var f=a.labelsSet,g=a.tickLength;a.inside&&(g=0);if(f)switch(f=a.getBBox(),a.position){case "top":a=f.y;
277 d>a&&(d=a);break;case "bottom":a=f.y+f.height;e<a&&(e=a);break;case "right":a=f.x+f.width+g+3;c<a&&(c=a);break;case "left":a=f.x-g,b>a&&(b=a)}}return{l:b,t:d,r:c,b:e}},drawZoomOutButton:function(){var a=this,b=a.container.set();a.zoomButtonSet.push(b);var c=a.color,d=a.fontSize,e=a.zoomOutButtonImageSize,f=a.zoomOutButtonImage,g=AmCharts.lang.zoomOutText||a.zoomOutText,h=a.zoomOutButtonColor,k=a.zoomOutButtonAlpha,l=a.zoomOutButtonFontSize,m=a.zoomOutButtonPadding;isNaN(l)||(d=l);(l=a.zoomOutButtonFontColor)&&
278 (c=l);var l=a.zoomOutButton,n;l&&(l.fontSize&&(d=l.fontSize),l.color&&(c=l.color),l.backgroundColor&&(h=l.backgroundColor),isNaN(l.backgroundAlpha)||(a.zoomOutButtonRollOverAlpha=l.backgroundAlpha));var p=l=0;void 0!==a.pathToImages&&f&&(n=a.container.image(a.pathToImages+f,0,0,e,e),b.push(n),n=n.getBBox(),l=n.width+5);void 0!==g&&(c=AmCharts.text(a.container,g,c,a.fontFamily,d,"start"),d=c.getBBox(),p=n?n.height/2-3:d.height/2,c.translate(l,p),b.push(c));n=b.getBBox();c=1;AmCharts.isModern||(c=0);
279 h=AmCharts.rect(a.container,n.width+2*m+5,n.height+2*m-2,h,1,1,h,c);h.setAttr("opacity",k);h.translate(-m,-m);b.push(h);h.toBack();a.zbBG=h;n=h.getBBox();b.translate(a.marginLeftReal+a.plotAreaWidth-n.width+m,a.marginTopReal+m);b.hide();b.mouseover(function(){a.rollOverZB()}).mouseout(function(){a.rollOutZB()}).click(function(){a.clickZB()}).touchstart(function(){a.rollOverZB()}).touchend(function(){a.rollOutZB();a.clickZB()});for(k=0;k<b.length;k++)b[k].attr({cursor:"pointer"});a.zbSet=b},rollOverZB:function(){this.zbBG.setAttr("opacity",
280 this.zoomOutButtonRollOverAlpha)},rollOutZB:function(){this.zbBG.setAttr("opacity",this.zoomOutButtonAlpha)},clickZB:function(){this.zoomOut()},zoomOut:function(){this.updateScrollbar=!0;this.zoom()},drawPlotArea:function(){var a=this.dx,b=this.dy,c=this.marginLeftReal,d=this.marginTopReal,e=this.plotAreaWidth-1,f=this.plotAreaHeight-1,g=this.plotAreaFillColors,h=this.plotAreaFillAlphas,k=this.plotAreaBorderColor,l=this.plotAreaBorderAlpha;this.trendLinesSet.clipRect(c,d,e,f);"object"==typeof h&&
281 (h=h[0]);g=AmCharts.polygon(this.container,[0,e,e,0,0],[0,0,f,f,0],g,h,1,k,l,this.plotAreaGradientAngle);g.translate(c+a,d+b);this.set.push(g);0!==a&&0!==b&&(g=this.plotAreaFillColors,"object"==typeof g&&(g=g[0]),g=AmCharts.adjustLuminosity(g,-.15),e=AmCharts.polygon(this.container,[0,a,e+a,e,0],[0,b,b,0,0],g,h,1,k,l),e.translate(c,d+f),this.set.push(e),a=AmCharts.polygon(this.container,[0,0,a,a,0],[0,f,f+b,b,0],g,h,1,k,l),a.translate(c,d),this.set.push(a));(c=this.bbset)&&this.scrollbarOnly&&c.remove()},
282 updatePlotArea:function(){var a=this.updateWidth(),b=this.updateHeight(),c=this.container;this.realWidth=a;this.realWidth=b;c&&this.container.setSize(a,b);a=a-this.marginLeftReal-this.marginRightReal-this.dx;b=b-this.marginTopReal-this.marginBottomReal;1>a&&(a=1);1>b&&(b=1);this.plotAreaWidth=Math.round(a);this.plotAreaHeight=Math.round(b)},updateDxy:function(){this.dx=Math.round(this.depth3D*Math.cos(this.angle*Math.PI/180));this.dy=Math.round(-this.depth3D*Math.sin(this.angle*Math.PI/180));this.d3x=
283 Math.round(this.columnSpacing3D*Math.cos(this.angle*Math.PI/180));this.d3y=Math.round(-this.columnSpacing3D*Math.sin(this.angle*Math.PI/180))},updateMargins:function(){var a=this.getTitleHeight();this.titleHeight=a;this.marginTopReal=this.marginTop-this.dy+a;this.marginBottomReal=this.marginBottom;this.marginLeftReal=this.marginLeft;this.marginRightReal=this.marginRight},updateValueAxes:function(){var a=this.valueAxes,b=this.marginLeftReal,c=this.marginTopReal,d=this.plotAreaHeight,e=this.plotAreaWidth,
284 f;for(f=0;f<a.length;f++){var g=a[f];g.axisRenderer=AmCharts.RecAxis;g.guideFillRenderer=AmCharts.RecFill;g.axisItemRenderer=AmCharts.RecItem;g.dx=this.dx;g.dy=this.dy;g.viW=e-1;g.viH=d-1;g.marginsChanged=!0;g.viX=b;g.viY=c;this.updateObjectSize(g)}},updateObjectSize:function(a){a.width=(this.plotAreaWidth-1)*this.widthMultiplier;a.height=(this.plotAreaHeight-1)*this.heightMultiplier;a.x=this.marginLeftReal+this.horizontalPosition;a.y=this.marginTopReal+this.verticalPosition},updateGraphs:function(){var a=
285 this.graphs,b;for(b=0;b<a.length;b++){var c=a[b];c.x=this.marginLeftReal+this.horizontalPosition;c.y=this.marginTopReal+this.verticalPosition;c.width=this.plotAreaWidth*this.widthMultiplier;c.height=this.plotAreaHeight*this.heightMultiplier;c.index=b;c.dx=this.dx;c.dy=this.dy;c.rotate=this.rotate}},updateChartCursor:function(){var a=this.chartCursor;a&&(a=AmCharts.processObject(a,AmCharts.ChartCursor,this.theme),this.addChartCursor(a),a.x=this.marginLeftReal,a.y=this.marginTopReal,a.width=this.plotAreaWidth-
286 1,a.height=this.plotAreaHeight-1,a.chart=this)},processScrollbars:function(){var a=this.chartScrollbar;a&&(a=AmCharts.processObject(a,AmCharts.ChartScrollbar,this.theme),this.addChartScrollbar(a))},updateScrollbars:function(){},addChartCursor:function(a){AmCharts.callMethod("destroy",[this.chartCursor]);a&&(this.listenTo(a,"changed",this.handleCursorChange),this.listenTo(a,"zoomed",this.handleCursorZoom));this.chartCursor=a},removeChartCursor:function(){AmCharts.callMethod("destroy",[this.chartCursor]);
287 this.chartCursor=null},zoomTrendLines:function(){var a=this.trendLines,b;for(b=0;b<a.length;b++){var c=a[b];c.valueAxis.recalculateToPercents?c.set&&c.set.hide():(c.x=this.marginLeftReal+this.horizontalPosition,c.y=this.marginTopReal+this.verticalPosition,c.draw())}},addTrendLine:function(a){this.trendLines.push(a)},removeTrendLine:function(a){var b=this.trendLines,c;for(c=b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1)},adjustMargins:function(a,b){var c=a.scrollbarHeight+a.offset;"top"==a.position?b?
288 this.marginLeftReal+=c:this.marginTopReal+=c:b?this.marginRightReal+=c:this.marginBottomReal+=c},getScrollbarPosition:function(a,b,c){a.position=b?"bottom"==c||"left"==c?"bottom":"top":"top"==c||"right"==c?"bottom":"top"},updateChartScrollbar:function(a,b){if(a){a.rotate=b;var c=this.marginTopReal,d=this.marginLeftReal,e=a.scrollbarHeight,f=this.dx,g=this.dy,h=a.offset;"top"==a.position?b?(a.y=c,a.x=d-e-h):(a.y=c-e+g-1-h,a.x=d+f):b?(a.y=c+g,a.x=d+this.plotAreaWidth+f+h):(a.y=c+this.plotAreaHeight+
289 h,a.x=this.marginLeftReal)}},showZB:function(a){var b=this.zbSet;b&&(a?b.show():b.hide(),this.rollOutZB())},handleReleaseOutside:function(a){AmCharts.AmRectangularChart.base.handleReleaseOutside.call(this,a);(a=this.chartCursor)&&a.handleReleaseOutside()},handleMouseDown:function(a){AmCharts.AmRectangularChart.base.handleMouseDown.call(this,a);var b=this.chartCursor;b&&b.handleMouseDown(a)},handleCursorChange:function(a){}});AmCharts.TrendLine=AmCharts.Class({construct:function(a){this.cname="TrendLine";this.createEvents("click");this.isProtected=!1;this.dashLength=0;this.lineColor="#00CC00";this.lineThickness=this.lineAlpha=1;AmCharts.applyTheme(this,a,this.cname)},draw:function(){var a=this;a.destroy();var b=a.chart,c=b.container,d,e,f,g,h=a.categoryAxis,k=a.initialDate,l=a.initialCategory,m=a.finalDate,n=a.finalCategory,p=a.valueAxis,q=a.valueAxisX,r=a.initialXValue,s=a.finalXValue,v=a.initialValue,w=a.finalValue,
290 t=p.recalculateToPercents,u=b.dataDateFormat;h&&(k&&(k instanceof Date||(k=u?AmCharts.stringToDate(k,u):new Date(k)),a.initialDate=k,d=h.dateToCoordinate(k)),l&&(d=h.categoryToCoordinate(l)),m&&(m instanceof Date||(m=u?AmCharts.stringToDate(m,u):new Date(m)),a.finalDate=m,e=h.dateToCoordinate(m)),n&&(e=h.categoryToCoordinate(n)));q&&!t&&(isNaN(r)||(d=q.getCoordinate(r)),isNaN(s)||(e=q.getCoordinate(s)));p&&!t&&(isNaN(v)||(f=p.getCoordinate(v)),isNaN(w)||(g=p.getCoordinate(w)));isNaN(d)||isNaN(e)||
291 isNaN(f)||isNaN(f)||(b.rotate?(h=[f,g],e=[d,e]):(h=[d,e],e=[f,g]),f=a.lineColor,d=AmCharts.line(c,h,e,f,a.lineAlpha,a.lineThickness,a.dashLength),g=h,k=e,n=h[1]-h[0],p=e[1]-e[0],0===n&&(n=.01),0===p&&(p=.01),l=n/Math.abs(n),m=p/Math.abs(p),p=n*p/Math.abs(n*p)*Math.sqrt(Math.pow(n,2)+Math.pow(p,2)),n=Math.asin(n/p),p=90*Math.PI/180-n,n=Math.abs(5*Math.cos(p)),p=Math.abs(5*Math.sin(p)),g.push(h[1]-l*p,h[0]-l*p),k.push(e[1]+m*n,e[0]+m*n),h=AmCharts.polygon(c,g,k,f,.005,0),c=c.set([h,d]),c.translate(b.marginLeftReal,
292 b.marginTopReal),b.trendLinesSet.push(c),a.line=d,a.set=c,h.mouseup(function(){a.handleLineClick()}).mouseover(function(){a.handleLineOver()}).mouseout(function(){a.handleLineOut()}),h.touchend&&h.touchend(function(){a.handleLineClick()}))},handleLineClick:function(){var a={type:"click",trendLine:this,chart:this.chart};this.fire(a.type,a)},handleLineOver:function(){var a=this.rollOverColor;void 0!==a&&this.line.attr({stroke:a})},handleLineOut:function(){this.line.attr({stroke:this.lineColor})},destroy:function(){AmCharts.remove(this.set)}});AmCharts.circle=function(a,b,c,d,e,f,g,h){if(void 0==e||0===e)e=.01;void 0===f&&(f="#000000");void 0===g&&(g=0);d={fill:c,stroke:f,"fill-opacity":d,"stroke-width":e,"stroke-opacity":g};a=a.circle(0,0,b).attr(d);h&&a.gradient("radialGradient",[c,AmCharts.adjustLuminosity(c,-.6)]);return a};
293 AmCharts.text=function(a,b,c,d,e,f,g,h){f||(f="middle");"right"==f&&(f="end");isNaN(h)&&(h=1);void 0!==b&&(b=String(b),AmCharts.isIE&&!AmCharts.isModern&&(b=b.replace("&amp;","&"),b=b.replace("&","&amp;")));c={fill:c,"font-family":d,"font-size":e,opacity:h};!0===g&&(c["font-weight"]="bold");c["text-anchor"]=f;return a.text(b,c)};
294 AmCharts.polygon=function(a,b,c,d,e,f,g,h,k,l,m){isNaN(f)&&(f=.01);isNaN(h)&&(h=e);var n=d,p=!1;"object"==typeof n&&1<n.length&&(p=!0,n=n[0]);void 0===g&&(g=n);e={fill:n,stroke:g,"fill-opacity":e,"stroke-width":f,"stroke-opacity":h};void 0!==m&&0<m&&(e["stroke-dasharray"]=m);m=AmCharts.dx;f=AmCharts.dy;a.handDrawn&&(c=AmCharts.makeHD(b,c,a.handDrawScatter),b=c[0],c=c[1]);g=Math.round;l&&(g=AmCharts.doNothing);l="M"+(g(b[0])+m)+","+(g(c[0])+f);for(h=1;h<b.length;h++)l+=" L"+(g(b[h])+m)+","+(g(c[h])+
295 f);a=a.path(l+" Z").attr(e);p&&a.gradient("linearGradient",d,k);return a};
296 AmCharts.rect=function(a,b,c,d,e,f,g,h,k,l,m){isNaN(f)&&(f=0);void 0===k&&(k=0);void 0===l&&(l=270);isNaN(e)&&(e=0);var n=d,p=!1;"object"==typeof n&&(n=n[0],p=!0);void 0===g&&(g=n);void 0===h&&(h=e);b=Math.round(b);c=Math.round(c);var q=0,r=0;0>b&&(b=Math.abs(b),q=-b);0>c&&(c=Math.abs(c),r=-c);q+=AmCharts.dx;r+=AmCharts.dy;e={fill:n,stroke:g,"fill-opacity":e,"stroke-opacity":h};void 0!==m&&0<m&&(e["stroke-dasharray"]=m);a=a.rect(q,r,b,c,k,f).attr(e);p&&a.gradient("linearGradient",d,l);return a};
297 AmCharts.bullet=function(a,b,c,d,e,f,g,h,k,l,m){var n;"circle"==b&&(b="round");switch(b){case "round":n=AmCharts.circle(a,c/2,d,e,f,g,h);break;case "square":n=AmCharts.polygon(a,[-c/2,c/2,c/2,-c/2],[c/2,c/2,-c/2,-c/2],d,e,f,g,h,l-180);break;case "rectangle":n=AmCharts.polygon(a,[-c,c,c,-c],[c/2,c/2,-c/2,-c/2],d,e,f,g,h,l-180);break;case "diamond":n=AmCharts.polygon(a,[-c/2,0,c/2,0],[0,-c/2,0,c/2],d,e,f,g,h);break;case "triangleUp":n=AmCharts.triangle(a,c,0,d,e,f,g,h);break;case "triangleDown":n=AmCharts.triangle(a,
298 c,180,d,e,f,g,h);break;case "triangleLeft":n=AmCharts.triangle(a,c,270,d,e,f,g,h);break;case "triangleRight":n=AmCharts.triangle(a,c,90,d,e,f,g,h);break;case "bubble":n=AmCharts.circle(a,c/2,d,e,f,g,h,!0);break;case "line":n=AmCharts.line(a,[-c/2,c/2],[0,0],d,e,f,g,h);break;case "yError":n=a.set();n.push(AmCharts.line(a,[0,0],[-c/2,c/2],d,e,f));n.push(AmCharts.line(a,[-k,k],[-c/2,-c/2],d,e,f));n.push(AmCharts.line(a,[-k,k],[c/2,c/2],d,e,f));break;case "xError":n=a.set(),n.push(AmCharts.line(a,[-c/
299 2,c/2],[0,0],d,e,f)),n.push(AmCharts.line(a,[-c/2,-c/2],[-k,k],d,e,f)),n.push(AmCharts.line(a,[c/2,c/2],[-k,k],d,e,f))}n&&n.pattern(m);return n};
300 AmCharts.triangle=function(a,b,c,d,e,f,g,h){if(void 0===f||0===f)f=1;void 0===g&&(g="#000");void 0===h&&(h=0);d={fill:d,stroke:g,"fill-opacity":e,"stroke-width":f,"stroke-opacity":h};b/=2;var k;0===c&&(k=" M"+-b+","+b+" L0,"+-b+" L"+b+","+b+" Z");180==c&&(k=" M"+-b+","+-b+" L0,"+b+" L"+b+","+-b+" Z");90==c&&(k=" M"+-b+","+-b+" L"+b+",0 L"+-b+","+b+" Z");270==c&&(k=" M"+-b+",0 L"+b+","+b+" L"+b+","+-b+" Z");return a.path(k).attr(d)};
301 AmCharts.line=function(a,b,c,d,e,f,g,h,k,l,m){if(a.handDrawn&&!m)return AmCharts.handDrawnLine(a,b,c,d,e,f,g,h,k,l,m);f={fill:"none","stroke-width":f};void 0!==g&&0<g&&(f["stroke-dasharray"]=g);isNaN(e)||(f["stroke-opacity"]=e);d&&(f.stroke=d);d=Math.round;l&&(d=AmCharts.doNothing);l=AmCharts.dx;e=AmCharts.dy;g="M"+(d(b[0])+l)+","+(d(c[0])+e);for(h=1;h<b.length;h++)g+=" L"+(d(b[h])+l)+","+(d(c[h])+e);if(AmCharts.VML)return a.path(g,void 0,!0).attr(f);k&&(g+=" M0,0 L0,0");return a.path(g).attr(f)};
302 AmCharts.makeHD=function(a,b,c){for(var d=[],e=[],f=1;f<a.length;f++)for(var g=Number(a[f-1]),h=Number(b[f-1]),k=Number(a[f]),l=Number(b[f]),m=Math.sqrt(Math.pow(k-g,2)+Math.pow(l-h,2)),m=Math.round(m/50)+1,k=(k-g)/m,l=(l-h)/m,n=0;n<=m;n++){var p=g+n*k+Math.random()*c,q=h+n*l+Math.random()*c;d.push(p);e.push(q)}return[d,e]};
303 AmCharts.handDrawnLine=function(a,b,c,d,e,f,g,h,k,l,m){var n=a.set();for(m=1;m<b.length;m++)for(var p=[b[m-1],b[m]],q=[c[m-1],c[m]],q=AmCharts.makeHD(p,q,a.handDrawScatter),p=q[0],q=q[1],r=1;r<p.length;r++)n.push(AmCharts.line(a,[p[r-1],p[r]],[q[r-1],q[r]],d,e,f+Math.random()*a.handDrawThickness-a.handDrawThickness/2,g,h,k,l,!0));return n};AmCharts.doNothing=function(a){return a};
304 AmCharts.wedge=function(a,b,c,d,e,f,g,h,k,l,m,n){var p=Math.round;f=p(f);g=p(g);h=p(h);var q=p(g/f*h),r=AmCharts.VML,s=359.5+f/100;359.94<s&&(s=359.94);e>=s&&(e=s);var v=1/180*Math.PI,s=b+Math.sin(d*v)*h,w=c-Math.cos(d*v)*q,t=b+Math.sin(d*v)*f,u=c-Math.cos(d*v)*g,y=b+Math.sin((d+e)*v)*f,E=c-Math.cos((d+e)*v)*g,A=b+Math.sin((d+e)*v)*h,v=c-Math.cos((d+e)*v)*q,z={fill:AmCharts.adjustLuminosity(l.fill,-.2),"stroke-opacity":0,"fill-opacity":l["fill-opacity"]},K=0;180<Math.abs(e)&&(K=1);d=a.set();var I;
305 r&&(s=p(10*s),t=p(10*t),y=p(10*y),A=p(10*A),w=p(10*w),u=p(10*u),E=p(10*E),v=p(10*v),b=p(10*b),k=p(10*k),c=p(10*c),f*=10,g*=10,h*=10,q*=10,1>Math.abs(e)&&1>=Math.abs(y-t)&&1>=Math.abs(E-u)&&(I=!0));e="";var F;n&&(z["fill-opacity"]=0,z["stroke-opacity"]=l["stroke-opacity"]/2,z.stroke=l.stroke);0<k&&(r?(F=" M"+s+","+(w+k)+" L"+t+","+(u+k),I||(F+=" A"+(b-f)+","+(k+c-g)+","+(b+f)+","+(k+c+g)+","+t+","+(u+k)+","+y+","+(E+k)),F+=" L"+A+","+(v+k),0<h&&(I||(F+=" B"+(b-h)+","+(k+c-q)+","+(b+h)+","+(k+c+q)+
306 ","+A+","+(k+v)+","+s+","+(k+w)))):(F=" M"+s+","+(w+k)+" L"+t+","+(u+k)+(" A"+f+","+g+",0,"+K+",1,"+y+","+(E+k)+" L"+A+","+(v+k)),0<h&&(F+=" A"+h+","+q+",0,"+K+",0,"+s+","+(w+k))),F+=" Z",F=a.path(F,void 0,void 0,"1000,1000").attr(z),d.push(F),F=a.path(" M"+s+","+w+" L"+s+","+(w+k)+" L"+t+","+(u+k)+" L"+t+","+u+" L"+s+","+w+" Z",void 0,void 0,"1000,1000").attr(z),k=a.path(" M"+y+","+E+" L"+y+","+(E+k)+" L"+A+","+(v+k)+" L"+A+","+v+" L"+y+","+E+" Z",void 0,void 0,"1000,1000").attr(z),d.push(F),d.push(k));
307 r?(I||(e=" A"+p(b-f)+","+p(c-g)+","+p(b+f)+","+p(c+g)+","+p(t)+","+p(u)+","+p(y)+","+p(E)),f=" M"+p(s)+","+p(w)+" L"+p(t)+","+p(u)+e+" L"+p(A)+","+p(v)):f=" M"+s+","+w+" L"+t+","+u+(" A"+f+","+g+",0,"+K+",1,"+y+","+E)+" L"+A+","+v;0<h&&(r?I||(f+=" B"+(b-h)+","+(c-q)+","+(b+h)+","+(c+q)+","+A+","+v+","+s+","+w):f+=" A"+h+","+q+",0,"+K+",0,"+s+","+w);a.handDrawn&&(b=AmCharts.line(a,[s,t],[w,u],l.stroke,l.thickness*Math.random()*a.handDrawThickness,l["stroke-opacity"]),d.push(b));a=a.path(f+" Z",void 0,
308 void 0,"1000,1000").attr(l);if(m){b=[];for(c=0;c<m.length;c++)b.push(AmCharts.adjustLuminosity(l.fill,m[c]));0<b.length&&a.gradient("linearGradient",b)}a.pattern(n);d.push(a);return d};
309 AmCharts.adjustLuminosity=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,"");6>a.length&&(a=String(a[0])+String(a[0])+String(a[1])+String(a[1])+String(a[2])+String(a[2]));b=b||0;var c="#",d,e;for(e=0;3>e;e++)d=parseInt(a.substr(2*e,2),16),d=Math.round(Math.min(Math.max(0,d+d*b),255)).toString(16),c+=("00"+d).substr(d.length);return c};AmCharts.Bezier=AmCharts.Class({construct:function(a,b,c,d,e,f,g,h,k,l){"object"==typeof g&&(g=g[0]);"object"==typeof h&&(h=h[0]);f={fill:g,"fill-opacity":h,"stroke-width":f};void 0!==k&&0<k&&(f["stroke-dasharray"]=k);isNaN(e)||(f["stroke-opacity"]=e);d&&(f.stroke=d);d="M"+Math.round(b[0])+","+Math.round(c[0]);e=[];for(k=0;k<b.length;k++)e.push({x:Number(b[k]),y:Number(c[k])});1<e.length&&(b=this.interpolate(e),d+=this.drawBeziers(b));l?d+=l:AmCharts.VML||(d+="M0,0 L0,0");this.path=a.path(d).attr(f)},
310 interpolate:function(a){var b=[];b.push({x:a[0].x,y:a[0].y});var c=a[1].x-a[0].x,d=a[1].y-a[0].y,e=AmCharts.bezierX,f=AmCharts.bezierY;b.push({x:a[0].x+c/e,y:a[0].y+d/f});var g;for(g=1;g<a.length-1;g++){var h=a[g-1],k=a[g],d=a[g+1];isNaN(d.x)&&(d=k);isNaN(k.x)&&(k=h);isNaN(h.x)&&(h=k);c=d.x-k.x;d=d.y-h.y;h=k.x-h.x;h>c&&(h=c);b.push({x:k.x-h/e,y:k.y-d/f});b.push({x:k.x,y:k.y});b.push({x:k.x+h/e,y:k.y+d/f})}d=a[a.length-1].y-a[a.length-2].y;c=a[a.length-1].x-a[a.length-2].x;b.push({x:a[a.length-1].x-
311 c/e,y:a[a.length-1].y-d/f});b.push({x:a[a.length-1].x,y:a[a.length-1].y});return b},drawBeziers:function(a){var b="",c;for(c=0;c<(a.length-1)/3;c++)b+=this.drawBezierMidpoint(a[3*c],a[3*c+1],a[3*c+2],a[3*c+3]);return b},drawBezierMidpoint:function(a,b,c,d){var e=Math.round,f=this.getPointOnSegment(a,b,.75),g=this.getPointOnSegment(d,c,.75),h=(d.x-a.x)/16,k=(d.y-a.y)/16,l=this.getPointOnSegment(a,b,.375);a=this.getPointOnSegment(f,g,.375);a.x-=h;a.y-=k;b=this.getPointOnSegment(g,f,.375);b.x+=h;b.y+=
312 k;c=this.getPointOnSegment(d,c,.375);h=this.getMiddle(l,a);f=this.getMiddle(f,g);g=this.getMiddle(b,c);l=" Q"+e(l.x)+","+e(l.y)+","+e(h.x)+","+e(h.y);l+=" Q"+e(a.x)+","+e(a.y)+","+e(f.x)+","+e(f.y);l+=" Q"+e(b.x)+","+e(b.y)+","+e(g.x)+","+e(g.y);return l+=" Q"+e(c.x)+","+e(c.y)+","+e(d.x)+","+e(d.y)},getMiddle:function(a,b){return{x:(a.x+b.x)/2,y:(a.y+b.y)/2}},getPointOnSegment:function(a,b,c){return{x:a.x+(b.x-a.x)*c,y:a.y+(b.y-a.y)*c}}});AmCharts.AmDraw=AmCharts.Class({construct:function(a,b,c,d){AmCharts.SVG_NS="http://www.w3.org/2000/svg";AmCharts.SVG_XLINK="http://www.w3.org/1999/xlink";AmCharts.hasSVG=!!document.createElementNS&&!!document.createElementNS(AmCharts.SVG_NS,"svg").createSVGRect;1>b&&(b=10);1>c&&(c=10);this.div=a;this.width=b;this.height=c;this.rBin=document.createElement("div");if(AmCharts.hasSVG){AmCharts.SVG=!0;var e=this.createSvgElement("svg");e.style.position="absolute";e.style.width=b+"px";e.style.height=c+
313 "px";b=this.createSvgElement("desc");b.appendChild(document.createTextNode("JavaScript chart by amCharts "+d.version));e.appendChild(b);AmCharts.rtl&&(e.setAttribute("direction","rtl"),e.style.left="auto",e.style.right="0px");e.setAttribute("version","1.1");a.appendChild(e);this.container=e;this.R=new AmCharts.SVGRenderer(this)}else AmCharts.isIE&&AmCharts.VMLRenderer&&(AmCharts.VML=!0,AmCharts.vmlStyleSheet||(document.namespaces.add("amvml","urn:schemas-microsoft-com:vml"),31>document.styleSheets.length?
314 (e=document.createStyleSheet(),e.addRule(".amvml","behavior:url(#default#VML); display:inline-block; antialias:true"),AmCharts.vmlStyleSheet=e):document.styleSheets[0].addRule(".amvml","behavior:url(#default#VML); display:inline-block; antialias:true")),this.container=a,this.R=new AmCharts.VMLRenderer(this,d),this.R.disableSelection(a))},createSvgElement:function(a){return document.createElementNS(AmCharts.SVG_NS,a)},circle:function(a,b,c,d){var e=new AmCharts.AmDObject("circle",this);e.attr({r:c,
315 cx:a,cy:b});this.addToContainer(e.node,d);return e},setSize:function(a,b){0<a&&0<b&&(this.container.style.width=a+"px",this.container.style.height=b+"px")},rect:function(a,b,c,d,e,f,g){var h=new AmCharts.AmDObject("rect",this);AmCharts.VML&&(e=100*e/Math.min(c,d),c+=2*f,d+=2*f,h.bw=f,h.node.style.marginLeft=-f,h.node.style.marginTop=-f);1>c&&(c=1);1>d&&(d=1);h.attr({x:a,y:b,width:c,height:d,rx:e,ry:e,"stroke-width":f});this.addToContainer(h.node,g);return h},image:function(a,b,c,d,e,f){var g=new AmCharts.AmDObject("image",
316 this);g.attr({x:b,y:c,width:d,height:e});this.R.path(g,a);this.addToContainer(g.node,f);return g},addToContainer:function(a,b){b||(b=this.container);b.appendChild(a)},text:function(a,b,c){return this.R.text(a,b,c)},path:function(a,b,c,d){var e=new AmCharts.AmDObject("path",this);d||(d="100,100");e.attr({cs:d});c?e.attr({dd:a}):e.attr({d:a});this.addToContainer(e.node,b);return e},set:function(a){return this.R.set(a)},remove:function(a){if(a){var b=this.rBin;b.appendChild(a);b.innerHTML=""}},renderFix:function(){var a=
317 this.container,b=a.style,c;try{c=a.getScreenCTM()||a.createSVGMatrix()}catch(d){c=a.createSVGMatrix()}a=1-c.e%1;c=1-c.f%1;.5<a&&(a-=1);.5<c&&(c-=1);a&&(b.left=a+"px");c&&(b.top=c+"px")},update:function(){this.R.update()}});AmCharts.AmDObject=AmCharts.Class({construct:function(a,b){this.D=b;this.R=b.R;this.node=this.R.create(this,a);this.y=this.x=0;this.scale=1},attr:function(a){this.R.attr(this,a);return this},getAttr:function(a){return this.node.getAttribute(a)},setAttr:function(a,b){this.R.setAttr(this,a,b);return this},clipRect:function(a,b,c,d){this.R.clipRect(this,a,b,c,d)},translate:function(a,b,c,d){d||(a=Math.round(a),b=Math.round(b));this.R.move(this,a,b,c);this.x=a;this.y=b;this.scale=c;this.angle&&this.rotate(this.angle)},
318 rotate:function(a,b){this.R.rotate(this,a,b);this.angle=a},animate:function(a,b,c){for(var d in a)if(a.hasOwnProperty(d)){var e=d,f=a[d];c=AmCharts.getEffect(c);this.R.animate(this,e,f,b,c)}},push:function(a){if(a){var b=this.node;b.appendChild(a.node);var c=a.clipPath;c&&b.appendChild(c);(a=a.grad)&&b.appendChild(a)}},text:function(a){this.R.setText(this,a)},remove:function(){this.R.remove(this)},clear:function(){var a=this.node;if(a.hasChildNodes())for(;1<=a.childNodes.length;)a.removeChild(a.firstChild)},
319 hide:function(){this.setAttr("visibility","hidden")},show:function(){this.setAttr("visibility","visible")},getBBox:function(){return this.R.getBBox(this)},toFront:function(){var a=this.node;if(a){this.prevNextNode=a.nextSibling;var b=a.parentNode;b&&b.appendChild(a)}},toPrevious:function(){var a=this.node;a&&this.prevNextNode&&(a=a.parentNode)&&a.insertBefore(this.prevNextNode,null)},toBack:function(){var a=this.node;if(a){this.prevNextNode=a.nextSibling;var b=a.parentNode;if(b){var c=b.firstChild;
320 c&&b.insertBefore(a,c)}}},mouseover:function(a){this.R.addListener(this,"mouseover",a);return this},mouseout:function(a){this.R.addListener(this,"mouseout",a);return this},click:function(a){this.R.addListener(this,"click",a);return this},dblclick:function(a){this.R.addListener(this,"dblclick",a);return this},mousedown:function(a){this.R.addListener(this,"mousedown",a);return this},mouseup:function(a){this.R.addListener(this,"mouseup",a);return this},touchstart:function(a){this.R.addListener(this,
321 "touchstart",a);return this},touchend:function(a){this.R.addListener(this,"touchend",a);return this},contextmenu:function(a){this.node.addEventListener?this.node.addEventListener("contextmenu",a,!0):this.R.addListener(this,"contextmenu",a);return this},stop:function(a){(a=this.animationX)&&AmCharts.removeFromArray(this.R.animations,a);(a=this.animationY)&&AmCharts.removeFromArray(this.R.animations,a)},length:function(){return this.node.childNodes.length},gradient:function(a,b,c){this.R.gradient(this,
322 a,b,c)},pattern:function(a,b){a&&this.R.pattern(this,a,b)}});AmCharts.VMLRenderer=AmCharts.Class({construct:function(a,b){this.chart=b;this.D=a;this.cNames={circle:"oval",rect:"roundrect",path:"shape"};this.styleMap={x:"left",y:"top",width:"width",height:"height","font-family":"fontFamily","font-size":"fontSize",visibility:"visibility"}},create:function(a,b){var c;if("group"==b)c=document.createElement("div"),a.type="div";else if("text"==b)c=document.createElement("div"),a.type="text";else if("image"==b)c=document.createElement("img"),a.type="image";else{a.type=
323 "shape";a.shapeType=this.cNames[b];c=document.createElement("amvml:"+this.cNames[b]);var d=document.createElement("amvml:stroke");c.appendChild(d);a.stroke=d;var e=document.createElement("amvml:fill");c.appendChild(e);a.fill=e;e.className="amvml";d.className="amvml";c.className="amvml"}c.style.position="absolute";c.style.top=0;c.style.left=0;return c},path:function(a,b){a.node.setAttribute("src",b)},setAttr:function(a,b,c){if(void 0!==c){var d;8===document.documentMode&&(d=!0);var e=a.node,f=a.type,
324 g=e.style;"r"==b&&(g.width=2*c,g.height=2*c);"roundrect"!=a.shapeType||"width"!=b&&"height"!=b||(c-=1);"cursor"==b&&(g.cursor=c);"cx"==b&&(g.left=c-AmCharts.removePx(g.width)/2);"cy"==b&&(g.top=c-AmCharts.removePx(g.height)/2);var h=this.styleMap[b];void 0!==h&&(g[h]=c);"text"==f&&("text-anchor"==b&&(a.anchor=c,h=e.clientWidth,"end"==c&&(g.marginLeft=-h+"px"),"middle"==c&&(g.marginLeft=-(h/2)+"px",g.textAlign="center"),"start"==c&&(g.marginLeft="0px")),"fill"==b&&(g.color=c),"font-weight"==b&&(g.fontWeight=
325 c));if(g=a.children)for(h=0;h<g.length;h++)g[h].setAttr(b,c);if("shape"==f){"cs"==b&&(e.style.width="100px",e.style.height="100px",e.setAttribute("coordsize",c));"d"==b&&e.setAttribute("path",this.svgPathToVml(c));"dd"==b&&e.setAttribute("path",c);f=a.stroke;a=a.fill;"stroke"==b&&(d?f.color=c:f.setAttribute("color",c));"stroke-width"==b&&(d?f.weight=c:f.setAttribute("weight",c));"stroke-opacity"==b&&(d?f.opacity=c:f.setAttribute("opacity",c));"stroke-dasharray"==b&&(g="solid",0<c&&3>c&&(g="dot"),
326 3<=c&&6>=c&&(g="dash"),6<c&&(g="longdash"),d?f.dashstyle=g:f.setAttribute("dashstyle",g));if("fill-opacity"==b||"opacity"==b)0===c?d?a.on=!1:a.setAttribute("on",!1):d?a.opacity=c:a.setAttribute("opacity",c);"fill"==b&&(d?a.color=c:a.setAttribute("color",c));"rx"==b&&(d?e.arcSize=c+"%":e.setAttribute("arcsize",c+"%"))}}},attr:function(a,b){for(var c in b)b.hasOwnProperty(c)&&this.setAttr(a,c,b[c])},text:function(a,b,c){var d=new AmCharts.AmDObject("text",this.D),e=d.node;e.style.whiteSpace="pre";e.innerHTML=
327 a;this.D.addToContainer(e,c);this.attr(d,b);return d},getBBox:function(a){return this.getBox(a.node)},getBox:function(a){var b=a.offsetLeft,c=a.offsetTop,d=a.offsetWidth,e=a.offsetHeight,f;if(a.hasChildNodes()){var g,h,k;for(k=0;k<a.childNodes.length;k++){f=this.getBox(a.childNodes[k]);var l=f.x;isNaN(l)||(isNaN(g)?g=l:l<g&&(g=l));var m=f.y;isNaN(m)||(isNaN(h)?h=m:m<h&&(h=m));l=f.width+l;isNaN(l)||(d=Math.max(d,l));f=f.height+m;isNaN(f)||(e=Math.max(e,f))}0>g&&(b+=g);0>h&&(c+=h)}return{x:b,y:c,width:d,
328 height:e}},setText:function(a,b){var c=a.node;c&&(c.innerHTML=b);this.setAttr(a,"text-anchor",a.anchor)},addListener:function(a,b,c){a.node["on"+b]=c},move:function(a,b,c){var d=a.node,e=d.style;"text"==a.type&&(c-=AmCharts.removePx(e.fontSize)/2-1);"oval"==a.shapeType&&(b-=AmCharts.removePx(e.width)/2,c-=AmCharts.removePx(e.height)/2);a=a.bw;isNaN(a)||(b-=a,c-=a);isNaN(b)||isNaN(c)||(d.style.left=b+"px",d.style.top=c+"px")},svgPathToVml:function(a){var b=a.split(" ");a="";var c,d=Math.round,e;for(e=
329 0;e<b.length;e++){var f=b[e],g=f.substring(0,1),f=f.substring(1),h=f.split(","),k=d(h[0])+","+d(h[1]);"M"==g&&(a+=" m "+k);"L"==g&&(a+=" l "+k);"Z"==g&&(a+=" x e");if("Q"==g){var l=c.length,m=c[l-1],n=h[0],p=h[1],k=h[2],q=h[3];c=d(c[l-2]/3+2/3*n);m=d(m/3+2/3*p);n=d(2/3*n+k/3);p=d(2/3*p+q/3);a+=" c "+c+","+m+","+n+","+p+","+k+","+q}"A"==g&&(a+=" wa "+f);"B"==g&&(a+=" at "+f);c=h}return a},animate:function(a,b,c,d,e){var f=a.node,g=this.chart;if("translate"==b){b=c.split(",");c=b[1];var h=f.offsetTop;
330 g.animate(a,"left",f.offsetLeft,b[0],d,e,"px");g.animate(a,"top",h,c,d,e,"px")}},clipRect:function(a,b,c,d,e){a=a.node;0===b&&0===c?(a.style.width=d+"px",a.style.height=e+"px",a.style.overflow="hidden"):a.style.clip="rect("+c+"px "+(b+d)+"px "+(c+e)+"px "+b+"px)"},rotate:function(a,b,c){if(0!==Number(b)){var d=a.node;a=d.style;c||(c=this.getBGColor(d.parentNode));a.backgroundColor=c;a.paddingLeft=1;c=b*Math.PI/180;var e=Math.cos(c),f=Math.sin(c),g=AmCharts.removePx(a.left),h=AmCharts.removePx(a.top),
331 k=d.offsetWidth,d=d.offsetHeight;b/=Math.abs(b);a.left=g+k/2-k/2*Math.cos(c)-b*d/2*Math.sin(c)+3;a.top=h-b*k/2*Math.sin(c)+b*d/2*Math.sin(c);a.cssText=a.cssText+"; filter:progid:DXImageTransform.Microsoft.Matrix(M11='"+e+"', M12='"+-f+"', M21='"+f+"', M22='"+e+"', sizingmethod='auto expand');"}},getBGColor:function(a){var b="#FFFFFF";if(a.style){var c=a.style.backgroundColor;""!==c?b=c:a.parentNode&&(b=this.getBGColor(a.parentNode))}return b},set:function(a){var b=new AmCharts.AmDObject("group",this.D);
332 this.D.container.appendChild(b.node);if(a){var c;for(c=0;c<a.length;c++)b.push(a[c])}return b},gradient:function(a,b,c,d){var e="";"radialGradient"==b&&(b="gradientradial",c.reverse());"linearGradient"==b&&(b="gradient");var f;for(f=0;f<c.length;f++){var g=Math.round(100*f/(c.length-1)),e=e+(g+"% "+c[f]);f<c.length-1&&(e+=",")}a=a.fill;90==d?d=0:270==d?d=180:180==d?d=90:0===d&&(d=270);8===document.documentMode?(a.type=b,a.angle=d):(a.setAttribute("type",b),a.setAttribute("angle",d));e&&(a.colors.value=
333 e)},remove:function(a){a.clipPath&&this.D.remove(a.clipPath);this.D.remove(a.node)},disableSelection:function(a){void 0!==typeof a.onselectstart&&(a.onselectstart=function(){return!1});a.style.cursor="default"},pattern:function(a,b){var c=a.node,d=a.fill,e="none";b.color&&(e=b.color);c.fillColor=e;8===document.documentMode?(d.type="tile",d.src=b.url):(d.setAttribute("type","tile"),d.setAttribute("src",b.url))},update:function(){}});AmCharts.SVGRenderer=AmCharts.Class({construct:function(a){this.D=a;this.animations=[]},create:function(a,b){return document.createElementNS(AmCharts.SVG_NS,b)},attr:function(a,b){for(var c in b)b.hasOwnProperty(c)&&this.setAttr(a,c,b[c])},setAttr:function(a,b,c){void 0!==c&&a.node.setAttribute(b,c)},animate:function(a,b,c,d,e){var f=a.node;a["an_"+b]&&AmCharts.removeFromArray(this.animations,a["an_"+b]);"translate"==b?(f=(f=f.getAttribute("transform"))?String(f).substring(10,f.length-1):"0,0",f=
334 f.split(", ").join(" "),f=f.split(" ").join(","),0===f&&(f="0,0")):f=Number(f.getAttribute(b));c={obj:a,frame:0,attribute:b,from:f,to:c,time:d,effect:e};this.animations.push(c);a["an_"+b]=c},update:function(){var a,b=this.animations;for(a=b.length-1;0<=a;a--){var c=b[a],d=1E3*c.time/AmCharts.updateRate,e=c.frame+1,f=c.obj,g=c.attribute,h,k,l;e<=d?(c.frame++,"translate"==g?(h=c.from.split(","),g=Number(h[0]),h=Number(h[1]),isNaN(h)&&(h=0),k=c.to.split(","),l=Number(k[0]),k=Number(k[1]),l=0===l-g?l:
335 Math.round(AmCharts[c.effect](0,e,g,l-g,d)),c=0===k-h?k:Math.round(AmCharts[c.effect](0,e,h,k-h,d)),g="transform",c="translate("+l+","+c+")"):(k=Number(c.from),h=Number(c.to),l=h-k,c=AmCharts[c.effect](0,e,k,l,d),isNaN(c)&&(c=h),0===l&&this.animations.splice(a,1)),this.setAttr(f,g,c)):("translate"==g?(k=c.to.split(","),l=Number(k[0]),k=Number(k[1]),f.translate(l,k)):(h=Number(c.to),this.setAttr(f,g,h)),this.animations.splice(a,1))}},getBBox:function(a){if(a=a.node)try{return a.getBBox()}catch(b){}return{width:0,
336 height:0,x:0,y:0}},path:function(a,b){a.node.setAttributeNS(AmCharts.SVG_XLINK,"xlink:href",b)},clipRect:function(a,b,c,d,e){var f=a.node,g=a.clipPath;g&&this.D.remove(g);var h=f.parentNode;h&&(f=document.createElementNS(AmCharts.SVG_NS,"clipPath"),g=AmCharts.getUniqueId(),f.setAttribute("id",g),this.D.rect(b,c,d,e,0,0,f),h.appendChild(f),b="#",AmCharts.baseHref&&!AmCharts.isIE&&(b=window.location.href+b),this.setAttr(a,"clip-path","url("+b+g+")"),this.clipPathC++,a.clipPath=f)},text:function(a,b,
337 c){var d=new AmCharts.AmDObject("text",this.D);a=String(a).split("\n");var e=b["font-size"],f;for(f=0;f<a.length;f++){var g=this.create(null,"tspan");g.appendChild(document.createTextNode(a[f]));g.setAttribute("y",(e+2)*f+Math.round(e/2));g.setAttribute("x",0);d.node.appendChild(g)}d.node.setAttribute("y",Math.round(e/2));this.attr(d,b);this.D.addToContainer(d.node,c);return d},setText:function(a,b){var c=a.node;c&&(c.removeChild(c.firstChild),c.appendChild(document.createTextNode(b)))},move:function(a,
338 b,c,d){b="translate("+b+","+c+")";d&&(b=b+" scale("+d+")");this.setAttr(a,"transform",b)},rotate:function(a,b){var c=a.node.getAttribute("transform"),d="rotate("+b+")";c&&(d=c+" "+d);this.setAttr(a,"transform",d)},set:function(a){var b=new AmCharts.AmDObject("g",this.D);this.D.container.appendChild(b.node);if(a){var c;for(c=0;c<a.length;c++)b.push(a[c])}return b},addListener:function(a,b,c){a.node["on"+b]=c},gradient:function(a,b,c,d){var e=a.node,f=a.grad;f&&this.D.remove(f);b=document.createElementNS(AmCharts.SVG_NS,
339 b);f=AmCharts.getUniqueId();b.setAttribute("id",f);if(!isNaN(d)){var g=0,h=0,k=0,l=0;90==d?k=100:270==d?l=100:180==d?g=100:0===d&&(h=100);b.setAttribute("x1",g+"%");b.setAttribute("x2",h+"%");b.setAttribute("y1",k+"%");b.setAttribute("y2",l+"%")}for(d=0;d<c.length;d++)g=document.createElementNS(AmCharts.SVG_NS,"stop"),h=100*d/(c.length-1),0===d&&(h=0),g.setAttribute("offset",h+"%"),g.setAttribute("stop-color",c[d]),b.appendChild(g);e.parentNode.appendChild(b);c="#";AmCharts.baseHref&&!AmCharts.isIE&&
340 (c=window.location.href+c);e.setAttribute("fill","url("+c+f+")");a.grad=b},pattern:function(a,b,c){var d=a.node;isNaN(c)&&(c=1);var e=a.patternNode;e&&this.D.remove(e);var e=document.createElementNS(AmCharts.SVG_NS,"pattern"),f=AmCharts.getUniqueId(),g=b;b.url&&(g=b.url);var h=Number(b.width);isNaN(h)&&(h=4);var k=Number(b.height);isNaN(k)&&(k=4);h/=c;k/=c;c=b.x;isNaN(c)&&(c=0);var l=-Math.random()*Number(b.randomX);isNaN(l)||(c=l);l=b.y;isNaN(l)&&(l=0);var m=-Math.random()*Number(b.randomY);isNaN(m)||
341 (l=m);e.setAttribute("id",f);e.setAttribute("width",h);e.setAttribute("height",k);e.setAttribute("patternUnits","userSpaceOnUse");e.setAttribute("xlink:href",g);b.color&&(m=document.createElementNS(AmCharts.SVG_NS,"rect"),m.setAttributeNS(null,"height",h),m.setAttributeNS(null,"width",k),m.setAttributeNS(null,"fill",b.color),e.appendChild(m));this.D.image(g,0,0,h,k,e).translate(c,l);g="#";AmCharts.baseHref&&!AmCharts.isIE&&(g=window.location.href+g);d.setAttribute("fill","url("+g+f+")");a.patternNode=
342 e;d.parentNode.appendChild(e)},remove:function(a){a.clipPath&&this.D.remove(a.clipPath);a.grad&&this.D.remove(a.grad);a.patternNode&&this.D.remove(a.patternNode);this.D.remove(a.node)}});AmCharts.AmDSet=AmCharts.Class({construct:function(a){this.create("g")},attr:function(a){this.R.attr(this.node,a)},move:function(a,b){this.R.move(this.node,a,b)}});AmCharts.AmLegend=AmCharts.Class({construct:function(a){this.cname="AmLegend";this.createEvents("rollOverMarker","rollOverItem","rollOutMarker","rollOutItem","showItem","hideItem","clickMarker","rollOverItem","rollOutItem","clickLabel");this.position="bottom";this.borderColor=this.color="#000000";this.borderAlpha=0;this.markerLabelGap=5;this.verticalGap=10;this.align="left";this.horizontalGap=0;this.spacing=10;this.markerDisabledColor="#AAB3B3";this.markerType="square";this.markerSize=16;this.markerBorderThickness=
343 this.markerBorderAlpha=1;this.marginBottom=this.marginTop=0;this.marginLeft=this.marginRight=20;this.autoMargins=!0;this.valueWidth=50;this.switchable=!0;this.switchType="x";this.switchColor="#FFFFFF";this.rollOverColor="#CC0000";this.reversedOrder=!1;this.labelText="[[title]]";this.valueText="[[value]]";this.useMarkerColorForLabels=!1;this.rollOverGraphAlpha=1;this.textClickEnabled=!1;this.equalWidths=!0;this.dateFormat="DD-MM-YYYY";this.backgroundColor="#FFFFFF";this.backgroundAlpha=0;this.useGraphSettings=
344 !1;this.showEntries=!0;AmCharts.applyTheme(this,a,this.cname)},setData:function(a){this.legendData=a;this.invalidateSize()},invalidateSize:function(){this.destroy();this.entries=[];this.valueLabels=[];(AmCharts.ifArray(this.legendData)||AmCharts.ifArray(this.data))&&this.drawLegend()},drawLegend:function(){var a=this.chart,b=this.position,c=this.width,d=a.divRealWidth,e=a.divRealHeight,f=this.div,g=this.legendData;this.data&&(g=this.data);isNaN(this.fontSize)&&(this.fontSize=a.fontSize);if("right"==
345 b||"left"==b)this.maxColumns=1,this.autoMargins&&(this.marginLeft=this.marginRight=10);else if(this.autoMargins){this.marginRight=a.marginRight;this.marginLeft=a.marginLeft;var h=a.autoMarginOffset;"bottom"==b?(this.marginBottom=h,this.marginTop=0):(this.marginTop=h,this.marginBottom=0)}var k;void 0!==c?k=AmCharts.toCoordinate(c,d):"right"!=b&&"left"!=b&&(k=a.realWidth);"outside"==b?(k=f.offsetWidth,e=f.offsetHeight,f.clientHeight&&(k=f.clientWidth,e=f.clientHeight)):(isNaN(k)||(f.style.width=k+"px"),
346 f.className="amChartsLegend");this.divWidth=k;(b=this.container)?(b.container.innerHTML="",f.appendChild(b.container),b.setSize(k,e)):b=new AmCharts.AmDraw(f,k,e,a);this.container=b;this.lx=0;this.ly=8;e=this.markerSize;e>this.fontSize&&(this.ly=e/2-1);0<e&&(this.lx+=e+this.markerLabelGap);this.titleWidth=0;if(e=this.title)a=AmCharts.text(this.container,e,this.color,a.fontFamily,this.fontSize,"start",!0),a.translate(this.marginLeft,this.marginTop+this.verticalGap+this.ly+1),a=a.getBBox(),this.titleWidth=
347 a.width+15,this.titleHeight=a.height+6;this.index=this.maxLabelWidth=0;if(this.showEntries){for(a=0;a<g.length;a++)this.createEntry(g[a]);for(a=this.index=0;a<g.length;a++)this.createValue(g[a])}this.arrangeEntries();this.updateValues()},arrangeEntries:function(){var a=this.position,b=this.marginLeft+this.titleWidth,c=this.marginRight,d=this.marginTop,e=this.marginBottom,f=this.horizontalGap,g=this.div,h=this.divWidth,k=this.maxColumns,l=this.verticalGap,m=this.spacing,n=h-c-b,p=0,q=0,r=this.container;
348 this.set&&this.set.remove();var s=r.set();this.set=s;r=r.set();s.push(r);var v=this.entries,w,t;for(t=0;t<v.length;t++){w=v[t].getBBox();var u=w.width;u>p&&(p=u);w=w.height;w>q&&(q=w)}var u=q=0,y=f,E=0,A=0;for(t=0;t<v.length;t++){var z=v[t];this.reversedOrder&&(z=v[v.length-t-1]);w=z.getBBox();var K;this.equalWidths?K=f+u*(p+m+this.markerLabelGap):(K=y,y=y+w.width+f+m);w.height>A&&(A=w.height);K+w.width>n&&0<t&&0!==u&&(q++,u=0,K=f,y=K+w.width+f+m,E=E+A+l,A=0);z.translate(K,E);u++;!isNaN(k)&&u>=k&&
349 (u=0,q++,E=E+A+l,A=0);r.push(z)}w=r.getBBox();k=w.height+2*l-1;"left"==a||"right"==a?(h=w.width+2*f,g.style.width=h+b+c+"px"):h=h-b-c-1;c=AmCharts.polygon(this.container,[0,h,h,0],[0,0,k,k],this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);s.push(c);s.translate(b,d);c.toBack();b=f;if("top"==a||"bottom"==a||"absolute"==a||"outside"==a)"center"==this.align?b=f+(h-w.width)/2:"right"==this.align&&(b=f+h-w.width);r.translate(b,l+1);this.titleHeight>k&&(k=this.titleHeight);
350 a=k+d+e+1;0>a&&(a=0);g.style.height=Math.round(a)+"px"},createEntry:function(a){if(!1!==a.visibleInLegend){var b=this.chart,c=a.markerType;c||(c=this.markerType);var d=a.color,e=a.alpha;a.legendKeyColor&&(d=a.legendKeyColor());a.legendKeyAlpha&&(e=a.legendKeyAlpha());var f;!0===a.hidden&&(f=d=this.markerDisabledColor);var g=a.pattern,h=a.customMarker;h||(h=this.customMarker);var k=this.container,l=this.markerSize,m=0,n=0,p=l/2;if(this.useGraphSettings)if(m=a.type,this.switchType=void 0,"line"==m||
351 "step"==m||"smoothedLine"==m||"ohlc"==m)g=k.set(),a.hidden||(d=a.lineColorR,f=a.bulletBorderColorR),n=AmCharts.line(k,[0,2*l],[l/2,l/2],d,a.lineAlpha,a.lineThickness,a.dashLength),g.push(n),a.bullet&&(a.hidden||(d=a.bulletColorR),n=AmCharts.bullet(k,a.bullet,a.bulletSize,d,a.bulletAlpha,a.bulletBorderThickness,f,a.bulletBorderAlpha))&&(n.translate(l+1,l/2),g.push(n)),p=0,m=l,n=l/3;else{var q;a.getGradRotation&&(q=a.getGradRotation());m=a.fillColorsR;!0===a.hidden&&(m=d);if(g=this.createMarker("rectangle",
352 m,a.fillAlphas,a.lineThickness,d,a.lineAlpha,q,g))p=l,g.translate(p,l/2);m=l}else h?(b.path&&(h=b.path+h),g=k.image(h,0,0,l,l)):(g=this.createMarker(c,d,e,void 0,void 0,void 0,void 0,g))&&g.translate(l/2,l/2);this.addListeners(g,a);k=k.set([g]);this.switchable&&a.switchable&&k.setAttr("cursor","pointer");(f=this.switchType)&&"none"!=f&&("x"==f?(q=this.createX(),q.translate(l/2,l/2)):q=this.createV(),q.dItem=a,!0!==a.hidden?"x"==f?q.hide():q.show():"x"!=f&&q.hide(),this.switchable||q.hide(),this.addListeners(q,
353 a),a.legendSwitch=q,k.push(q));f=this.color;a.showBalloon&&this.textClickEnabled&&void 0!==this.selectedColor&&(f=this.selectedColor);this.useMarkerColorForLabels&&(f=d);!0===a.hidden&&(f=this.markerDisabledColor);d=AmCharts.massReplace(this.labelText,{"[[title]]":a.title});q=this.fontSize;g&&l<=q&&g.translate(p,l/2+this.ly-q/2+(q+2-l)/2-n);var r;d&&(d=AmCharts.fixBrakes(d),a.legendTextReal=d,r=this.labelWidth,r=isNaN(r)?AmCharts.text(this.container,d,f,b.fontFamily,q,"start"):AmCharts.wrappedText(this.container,
354 d,f,b.fontFamily,q,"start",!1,r,0),r.translate(this.lx+m,this.ly),k.push(r),b=r.getBBox().width,this.maxLabelWidth<b&&(this.maxLabelWidth=b));this.entries[this.index]=k;a.legendEntry=this.entries[this.index];a.legendLabel=r;this.index++}},addListeners:function(a,b){var c=this;a&&a.mouseover(function(){c.rollOverMarker(b)}).mouseout(function(){c.rollOutMarker(b)}).click(function(){c.clickMarker(b)})},rollOverMarker:function(a){this.switchable&&this.dispatch("rollOverMarker",a);this.dispatch("rollOverItem",
355 a)},rollOutMarker:function(a){this.switchable&&this.dispatch("rollOutMarker",a);this.dispatch("rollOutItem",a)},clickMarker:function(a){this.switchable&&(!0===a.hidden?this.dispatch("showItem",a):this.dispatch("hideItem",a));this.dispatch("clickMarker",a)},rollOverLabel:function(a){a.hidden||(this.textClickEnabled&&a.legendLabel&&a.legendLabel.attr({fill:this.rollOverColor}),this.dispatch("rollOverItem",a))},rollOutLabel:function(a){if(!a.hidden){if(this.textClickEnabled&&a.legendLabel){var b=this.color;
356 void 0!==this.selectedColor&&a.showBalloon&&(b=this.selectedColor);this.useMarkerColorForLabels&&(b=a.lineColor,void 0===b&&(b=a.color));a.legendLabel.attr({fill:b})}this.dispatch("rollOutItem",a)}},clickLabel:function(a){this.textClickEnabled?a.hidden||this.dispatch("clickLabel",a):this.switchable&&(!0===a.hidden?this.dispatch("showItem",a):this.dispatch("hideItem",a))},dispatch:function(a,b){this.fire(a,{type:a,dataItem:b,target:this,chart:this.chart})},createValue:function(a){var b=this,c=b.fontSize;
357 if(!1!==a.visibleInLegend){var d=b.maxLabelWidth;b.equalWidths||(b.valueAlign="left");"left"==b.valueAlign&&(d=a.legendEntry.getBBox().width);var e=d;if(b.valueText&&0<b.valueWidth){var f=b.color;b.useMarkerColorForValues&&(f=a.color,a.legendKeyColor&&(f=a.legendKeyColor()));!0===a.hidden&&(f=b.markerDisabledColor);var g=b.valueText,d=d+b.lx+b.markerLabelGap+b.valueWidth,h="end";"left"==b.valueAlign&&(d-=b.valueWidth,h="start");f=AmCharts.text(b.container,g,f,b.chart.fontFamily,c,h);f.translate(d,
358 b.ly);b.entries[b.index].push(f);e+=b.valueWidth+2*b.markerLabelGap;f.dItem=a;b.valueLabels.push(f)}b.index++;f=b.markerSize;f<c+7&&(f=c+7,AmCharts.VML&&(f+=3));c=b.container.rect(b.markerSize,0,e,f,0,0).attr({stroke:"none",fill:"#ffffff","fill-opacity":.005});c.dItem=a;b.entries[b.index-1].push(c);c.mouseover(function(){b.rollOverLabel(a)}).mouseout(function(){b.rollOutLabel(a)}).click(function(){b.clickLabel(a)})}},createV:function(){var a=this.markerSize;return AmCharts.polygon(this.container,
359 [a/5,a/2,a-a/5,a/2],[a/3,a-a/5,a/5,a/1.7],this.switchColor)},createX:function(){var a=(this.markerSize-4)/2,b={stroke:this.switchColor,"stroke-width":3},c=this.container,d=AmCharts.line(c,[-a,a],[-a,a]).attr(b),a=AmCharts.line(c,[-a,a],[a,-a]).attr(b);return this.container.set([d,a])},createMarker:function(a,b,c,d,e,f,g,h){var k=this.markerSize,l=this.container;e||(e=this.markerBorderColor);e||(e=b);isNaN(d)&&(d=this.markerBorderThickness);isNaN(f)&&(f=this.markerBorderAlpha);return AmCharts.bullet(l,
360 a,k,b,c,d,e,f,k,g,h)},validateNow:function(){this.invalidateSize()},updateValues:function(){var a=this.valueLabels,b=this.chart,c,d=this.data;for(c=0;c<a.length;c++){var e=a[c],f=e.dItem,g=" ";if(d)f.value?e.text(f.value):e.text("");else{if(void 0!==f.type){var h=f.currentDataItem,k=this.periodValueText;f.legendPeriodValueText&&(k=f.legendPeriodValueText);h?(g=this.valueText,f.legendValueText&&(g=f.legendValueText),g=b.formatString(g,h)):k&&(g=b.formatPeriodString(k,f))}else g=b.formatString(this.valueText,
361 f);if(k=this.valueFunction)h&&(f=h),g=k(f,g);e.text(g)}}},renderFix:function(){if(!AmCharts.VML){var a=this.container;a&&a.renderFix()}},destroy:function(){this.div.innerHTML="";AmCharts.remove(this.set)}});AmCharts.formatMilliseconds=function(a,b){if(-1!=a.indexOf("fff")){var c=b.getMilliseconds(),d=String(c);10>c&&(d="00"+c);10<=c&&100>c&&(d="0"+c);a=a.replace(/fff/g,d)}return a};AmCharts.extractPeriod=function(a){var b=AmCharts.stripNumbers(a),c=1;b!=a&&(c=Number(a.slice(0,a.indexOf(b))));return{period:b,count:c}};
362 AmCharts.newDate=function(a,b){return date="fff"==b?AmCharts.useUTC?new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()):new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()):new Date(a)};
363 AmCharts.resetDateToMin=function(a,b,c,d){void 0===d&&(d=1);var e,f,g,h,k,l,m;AmCharts.useUTC?(e=a.getUTCFullYear(),f=a.getUTCMonth(),g=a.getUTCDate(),h=a.getUTCHours(),k=a.getUTCMinutes(),l=a.getUTCSeconds(),m=a.getUTCMilliseconds(),a=a.getUTCDay()):(e=a.getFullYear(),f=a.getMonth(),g=a.getDate(),h=a.getHours(),k=a.getMinutes(),l=a.getSeconds(),m=a.getMilliseconds(),a=a.getDay());switch(b){case "YYYY":e=Math.floor(e/c)*c;f=0;g=1;m=l=k=h=0;break;case "MM":f=Math.floor(f/c)*c;g=1;m=l=k=h=0;break;case "WW":0===
364 a&&0<d&&(a=7);g=g-a+d;m=l=k=h=0;break;case "DD":m=l=k=h=0;break;case "hh":h=Math.floor(h/c)*c;m=l=k=0;break;case "mm":k=Math.floor(k/c)*c;m=l=0;break;case "ss":l=Math.floor(l/c)*c;m=0;break;case "fff":m=Math.floor(m/c)*c}AmCharts.useUTC?(a=new Date,a.setUTCFullYear(e,f,g),a.setUTCHours(h,k,l,m)):a=new Date(e,f,g,h,k,l,m);return a};
365 AmCharts.getPeriodDuration=function(a,b){void 0===b&&(b=1);var c;switch(a){case "YYYY":c=316224E5;break;case "MM":c=26784E5;break;case "WW":c=6048E5;break;case "DD":c=864E5;break;case "hh":c=36E5;break;case "mm":c=6E4;break;case "ss":c=1E3;break;case "fff":c=1}return c*b};AmCharts.intervals={s:{nextInterval:"ss",contains:1E3},ss:{nextInterval:"mm",contains:60,count:0},mm:{nextInterval:"hh",contains:60,count:1},hh:{nextInterval:"DD",contains:24,count:2},DD:{nextInterval:"",contains:Infinity,count:3}};
366 AmCharts.getMaxInterval=function(a,b){var c=AmCharts.intervals;return a>=c[b].contains?(a=Math.round(a/c[b].contains),b=c[b].nextInterval,AmCharts.getMaxInterval(a,b)):"ss"==b?c[b].nextInterval:b};AmCharts.dayNames="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ");AmCharts.shortDayNames="Sun Mon Tue Wed Thu Fri Sat".split(" ");AmCharts.monthNames="January February March April May June July August September October November December".split(" ");AmCharts.shortMonthNames="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");
367 AmCharts.getWeekNumber=function(a){a=new Date(a);a.setHours(0,0,0);a.setDate(a.getDate()+4-(a.getDay()||7));var b=new Date(a.getFullYear(),0,1);return Math.ceil(((a-b)/864E5+1)/7)};
368 AmCharts.stringToDate=function(a,b){var c={},d=[{pattern:"YYYY",period:"year"},{pattern:"YY",period:"year"},{pattern:"MM",period:"month"},{pattern:"M",period:"month"},{pattern:"DD",period:"date"},{pattern:"D",period:"date"},{pattern:"JJ",period:"hours"},{pattern:"J",period:"hours"},{pattern:"HH",period:"hours"},{pattern:"H",period:"hours"},{pattern:"KK",period:"hours"},{pattern:"K",period:"hours"},{pattern:"LL",period:"hours"},{pattern:"L",period:"hours"},{pattern:"NN",period:"minutes"},{pattern:"N",
369 period:"minutes"},{pattern:"SS",period:"seconds"},{pattern:"S",period:"seconds"},{pattern:"QQQ",period:"milliseconds"},{pattern:"QQ",period:"milliseconds"},{pattern:"Q",period:"milliseconds"}],e=!0,f=b.indexOf("AA");-1!=f&&(a.substr(f,2),"pm"==a.toLowerCase&&(e=!1));var f=b,g,h,k;for(k=0;k<d.length;k++)h=d[k].period,c[h]=0,"date"==h&&(c[h]=1);for(k=0;k<d.length;k++)if(g=d[k].pattern,h=d[k].period,-1!=b.indexOf(g)){var l=AmCharts.getFromDateString(g,a,f);b=b.replace(g,"");if("KK"==g||"K"==g||"LL"==
370 g||"L"==g)e||(l+=12);c[h]=l}return new Date(c.year,c.month,c.date,c.hours,c.minutes,c.seconds,c.milliseconds)};AmCharts.getFromDateString=function(a,b,c){if(void 0!==b)return c=c.indexOf(a),b=b.substr(c,a.length),"0"==b.charAt(0)&&(b=b.substr(1,b.length-1)),b=Number(b),isNaN(b)&&(b=0),-1!=a.indexOf("M")&&b--,b};
371 AmCharts.formatDate=function(a,b){var c,d,e,f,g,h,k,l,m=AmCharts.getWeekNumber(a);AmCharts.useUTC?(c=a.getUTCFullYear(),d=a.getUTCMonth(),e=a.getUTCDate(),f=a.getUTCDay(),g=a.getUTCHours(),h=a.getUTCMinutes(),k=a.getUTCSeconds(),l=a.getUTCMilliseconds()):(c=a.getFullYear(),d=a.getMonth(),e=a.getDate(),f=a.getDay(),g=a.getHours(),h=a.getMinutes(),k=a.getSeconds(),l=a.getMilliseconds());var n=String(c).substr(2,2),p=d+1;9>d&&(p="0"+p);var q="0"+f;b=b.replace(/W/g,m);m=g;24==m&&(m=0);var r=m;10>r&&(r=
372 "0"+r);b=b.replace(/JJ/g,r);b=b.replace(/J/g,m);r=g;0===r&&(r=24,-1!=b.indexOf("H")&&e--);m=e;10>e&&(m="0"+e);var s=r;10>s&&(s="0"+s);b=b.replace(/HH/g,s);b=b.replace(/H/g,r);r=g;11<r&&(r-=12);s=r;10>s&&(s="0"+s);b=b.replace(/KK/g,s);b=b.replace(/K/g,r);r=g;0===r&&(r=12);12<r&&(r-=12);s=r;10>s&&(s="0"+s);b=b.replace(/LL/g,s);b=b.replace(/L/g,r);r=h;10>r&&(r="0"+r);b=b.replace(/NN/g,r);b=b.replace(/N/g,h);h=k;10>h&&(h="0"+h);b=b.replace(/SS/g,h);b=b.replace(/S/g,k);k=l;10>k&&(k="00"+k);100>k&&(k="0"+
373 k);h=l;10>h&&(h="00"+h);b=b.replace(/QQQ/g,k);b=b.replace(/QQ/g,h);b=b.replace(/Q/g,l);b=12>g?b.replace(/A/g,"am"):b.replace(/A/g,"pm");b=b.replace(/YYYY/g,"@IIII@");b=b.replace(/YY/g,"@II@");b=b.replace(/MMMM/g,"@XXXX@");b=b.replace(/MMM/g,"@XXX@");b=b.replace(/MM/g,"@XX@");b=b.replace(/M/g,"@X@");b=b.replace(/DD/g,"@RR@");b=b.replace(/D/g,"@R@");b=b.replace(/EEEE/g,"@PPPP@");b=b.replace(/EEE/g,"@PPP@");b=b.replace(/EE/g,"@PP@");b=b.replace(/E/g,"@P@");b=b.replace(/@IIII@/g,c);b=b.replace(/@II@/g,
374 n);b=b.replace(/@XXXX@/g,AmCharts.monthNames[d]);b=b.replace(/@XXX@/g,AmCharts.shortMonthNames[d]);b=b.replace(/@XX@/g,p);b=b.replace(/@X@/g,d+1);b=b.replace(/@RR@/g,m);b=b.replace(/@R@/g,e);b=b.replace(/@PPPP@/g,AmCharts.dayNames[f]);b=b.replace(/@PPP@/g,AmCharts.shortDayNames[f]);b=b.replace(/@PP@/g,q);return b=b.replace(/@P@/g,f)};
375 AmCharts.changeDate=function(a,b,c,d,e){var f=-1;void 0===d&&(d=!0);void 0===e&&(e=!1);!0===d&&(f=1);switch(b){case "YYYY":a.setFullYear(a.getFullYear()+c*f);d||e||a.setDate(a.getDate()+1);break;case "MM":b=a.getMonth();a.setMonth(a.getMonth()+c*f);a.getMonth()>b+c*f&&a.setDate(a.getDate()-1);d||e||a.setDate(a.getDate()+1);break;case "DD":a.setDate(a.getDate()+c*f);break;case "WW":a.setDate(a.getDate()+c*f*7);break;case "hh":a.setHours(a.getHours()+c*f);break;case "mm":a.setMinutes(a.getMinutes()+
376 c*f);break;case "ss":a.setSeconds(a.getSeconds()+c*f);break;case "fff":a.setMilliseconds(a.getMilliseconds()+c*f)}return a};
amcharts/exporting/amexport.js
File was created 1 AmCharts.AmExport = AmCharts.Class({
2 construct: function(chart, cfg, init ) {
3 var _this = this;
4 _this.DEBUG = false;
5 _this.chart = chart;
6 _this.canvas = null;
7 _this.svgs = [];
8 _this.userCFG = cfg;
9
10 _this.buttonIcon = 'export.png';
11 _this.exportPNG = true;
12 _this.exportPDF = false;
13 _this.exportJPG = false;
14 _this.exportSVG = false;
15 //_this.left;
16 _this.right = 0;
17 //_this.bottom;
18 _this.top = 0;
19 //_this.color;
20 _this.buttonRollOverColor = "#EFEFEF";
21 //_this.buttonColor = "#FFFFFF";
22 //_this.buttonRollOverAlpha = 0.5;
23 _this.textRollOverColor = "#CC0000";
24 _this.buttonTitle = "Save chart as an image";
25 _this.buttonAlpha = 0.75;
26 _this.imageFileName = "amChart";
27 _this.imageBackgroundColor = "#FFFFFF";
28
29 if (init) {
30 _this.init();
31 }
32 },
33
34 toCoordinate:function(value){
35 if(value === undefined){
36 return "auto";
37 }
38 if(String(value).indexOf("%") != -1){
39 return value;
40 }
41 else{
42 return value + "px";
43 }
44 },
45
46 init: function(){
47 var _this = this;
48
49 var formats = [];
50 if (_this.exportPNG) {
51 formats.push("png");
52 }
53 if (_this.exportPDF) {
54 formats.push("pdf");
55 }
56 if (_this.exportJPG) {
57 formats.push("jpg");
58 }
59 if (_this.exportSVG) {
60 formats.push("svg");
61 }
62
63 var menuItems = [];
64 if(formats.length == 1){
65 var format = formats[0];
66 menuItems.push({format:format, iconTitle:_this.buttonTitle, icon:_this.chart.pathToImages + _this.buttonIcon})
67 }
68 else if(formats.length > 1){
69 var subItems = [];
70 for(var i = 0; i < formats.length; i++){
71 subItems.push({format:formats[i], title:formats[i].toUpperCase()});
72 }
73 menuItems.push({onclick: function() {}, icon:_this.chart.pathToImages + _this.buttonIcon, items:subItems})
74 }
75
76
77 var color = _this.color;
78 if(color === undefined){
79 color = _this.chart.color;
80 }
81
82 var buttonColor = _this.buttonColor;
83 if(buttonColor === undefined){
84 buttonColor = "transparent";
85 }
86
87
88 _this.cfg = {
89 menuTop : _this.toCoordinate(_this.top),
90 menuLeft : _this.toCoordinate(_this.left),
91 menuRight : _this.toCoordinate(_this.right),
92 menuBottom : _this.toCoordinate(_this.bottom),
93 menuItems : menuItems,
94 menuItemStyle: {
95 backgroundColor : buttonColor,
96 opacity :_this.buttonAlpha,
97 rollOverBackgroundColor : _this.buttonRollOverColor,
98 color : color,
99 rollOverColor : _this.textRollOverColor,
100 paddingTop : '6px',
101 paddingRight : '6px',
102 paddingBottom : '6px',
103 paddingLeft : '6px',
104 marginTop : '0px',
105 marginRight : '0px',
106 marginBottom : '0px',
107 marginLeft : '0px',
108 textAlign : 'left',
109 textDecoration : 'none',
110 fontFamily : _this.chart.fontFamily,
111 fontSize : _this.chart.fontSize + 'px'
112 },
113 menuItemOutput: {
114 backgroundColor : _this.imageBackgroundColor,
115 fileName : _this.imageFileName,
116 format : 'png',
117 output : 'dataurlnewwindow',
118 render : 'browser',
119 dpi : 90,
120 onclick : function(instance, config, event) {
121 event.preventDefault();
122 if(_this.chart.prepareForExport){
123 _this.chart.prepareForExport();
124 }
125 instance.output(config);
126 }
127 },
128 removeImagery: true
129 };
130
131 _this.processing = {
132 buffer: [],
133 drawn: 0,
134 timer: 0
135 };
136
137 // Config dependency adaption
138 if (typeof(window.canvg) != 'undefined' && typeof(window.RGBColor) != 'undefined') {
139 _this.cfg.menuItemOutput.render = 'canvg';
140 }
141 if (typeof(window.saveAs) != 'undefined') {
142 _this.cfg.menuItemOutput.output = 'save';
143 }
144 if (AmCharts.isIE && AmCharts.IEversion < 10) {
145 _this.cfg.menuItemOutput.output = 'dataurlnewwindow';
146 }
147
148 // Merge given configs
149 var cfg = _this.userCFG;
150 if (cfg) {
151 cfg.menuItemOutput = AmCharts.extend(_this.cfg.menuItemOutput, cfg.menuItemOutput || {});
152 cfg.menuItemStyle = AmCharts.extend(_this.cfg.menuItemStyle, cfg.menuItemStyle || {});
153 _this.cfg = AmCharts.extend(_this.cfg, cfg);
154 }
155
156 // Add reference to chart
157 _this.chart.AmExport = _this;
158
159 // Listen to the drawer
160 _this.chart.addListener('rendered', function() {
161 _this.setup();
162 });
163
164 // DEBUG; Public reference
165 if (_this.DEBUG) {
166 window.AmExport = _this;
167 }
168 },
169
170
171 /*
172 Simple log function for internal purpose
173 @param **args
174 */
175 log: function() {
176 console.log('AmExport: ', arguments);
177 },
178
179 /* PUBLIC
180 Prepares everything to get exported
181 @param none
182 */
183 setup: function() {
184 var _this = this;
185
186 if (_this.DEBUG == 10) {
187 _this.log('SETUP START');
188 } // DEBUG
189
190
191 if (!AmCharts.isIE || (AmCharts.isIE && AmCharts.IEversion > 9)) {
192 // Build Buttons
193 _this.generateButtons();
194 if (_this.DEBUG == 10) {
195 _this.log('SETUP END');
196 } // DEBUG
197 } else {
198 if (_this.DEBUG == 10) {
199 _this.log('< IE10 NOT SUPPORTED');
200 } // DEBUG
201 }
202 },
203
204 /* PUBLIC
205 Decodes base64 string to binary array
206 @param base64_string
207 @copyright Eli Grey, http://eligrey.com and Devin Samarin, https://github.com/eboyjr
208 */
209 generateBinaryArray: function(base64_string) {
210 var
211 len = base64_string.length,
212 buffer = new Uint8Array(len / 4 * 3 | 0),
213 i = 0,
214 outptr = 0,
215 last = [0, 0],
216 state = 0,
217 save = 0,
218 rank, code, undef, base64_ranks = new Uint8Array([
219 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
220 ]);
221 while (len--) {
222 code = base64_string.charCodeAt(i++);
223 rank = base64_ranks[code - 43];
224 if (rank !== 255 && rank !== undef) {
225 last[1] = last[0];
226 last[0] = code;
227 save = (save << 6) | rank;
228 state++;
229 if (state === 4) {
230 buffer[outptr++] = save >>> 16;
231 if (last[1] !== 61 /* padding character */ ) {
232 buffer[outptr++] = save >>> 8;
233 }
234 if (last[0] !== 61 /* padding character */ ) {
235 buffer[outptr++] = save;
236 }
237 state = 0;
238 }
239 }
240 }
241 // 2/3 chance there's going to be some null bytes at the end, but that
242 // doesn't really matter with most image formats.
243 // If it somehow matters for you, truncate the buffer up outptr.
244 return buffer;
245 },
246
247 /*
248 Creates blob object
249 @param base64_datastring string
250 @param type string
251 */
252 generateBlob: function(datastring, type) {
253 var _this = this,
254 header_end = type!='image/svg+xml'?datastring.indexOf(',') + 1:0,
255 header = datastring.substring(0, header_end),
256 data = datastring,
257 blob = new Blob();
258
259 if (header.indexOf('base64') != -1) {
260 data = _this.generateBinaryArray(datastring.substring(header_end));
261 }
262
263 // Fake blob for IE
264 if (AmCharts.isIE && AmCharts.IEversion < 10) {
265 blob.data = data;
266 blob.size = data.length;
267 blob.type = type;
268 blob.encoding = 'base64';
269 } else {
270 blob = new Blob([data], {
271 type: type
272 });
273 }
274 return blob;
275 },
276
277 /*
278 Creates PDF object
279 @param config object
280 */
281 generatePDF: function(cfg) {
282 var _this = this,
283 pdf = {
284 output: function() {
285 return '';
286 }
287 },
288 data = _this.canvas.toDataURL('image/jpeg'), // JSPDF ONLY SUPPORTS JPG
289 width = (_this.canvas.width * 25.4) / cfg.dpi,
290 height = (_this.canvas.height * 25.4) / cfg.dpi;
291
292 // Check
293 if (window.jsPDF) {
294 pdf = new jsPDF();
295 if (pdf.addImage) {
296 pdf.addImage(data, 'JPEG', 0, 0, width, height);
297 } else {
298 alert("Missing jsPDF plugin; Please add the 'addImage' plugin.");
299 }
300 } else {
301 alert("Missing jsPDF lib; Don't forget to add the addImage plugin.");
302 }
303
304 return pdf;
305 },
306
307 /*
308 Creates the CANVAS to receive the image data
309 @param format void()
310 @param callback; given callback function which returns the blob or datastring of the configured ouput type
311 */
312 output: function(cfg, externalCallback) {
313 var _this = this;
314 cfg = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemOutput), cfg || {});
315
316 /* PRIVATE
317 Callback function which gets called after the drawing process is done
318 @param none
319 */
320 function internalCallback() {
321 var data = null;
322 var blob;
323 if (_this.DEBUG == 10) {
324 _this.log('OUTPUT', cfg.format);
325 } // DEBUG
326
327 // SVG
328 if (cfg.format == 'image/svg+xml' || cfg.format == 'svg') {
329 data = _this.generateSVG();
330 blob = _this.generateBlob(data, 'image/svg+xml');
331
332 if (cfg.output == 'save') {
333 saveAs(blob, cfg.fileName + '.svg');
334 } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
335 blob = 'data:image/svg+xml;base64,' + btoa(data);
336 } else if (cfg.output == 'dataurlnewwindow') {
337 window.open('data:image/svg+xml;base64,' + btoa(data));
338 } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
339 location.href = 'data:image/svg+xml;base64,' + btoa(data);
340 } else if (cfg.output == 'datastream') {
341 location.href = 'data:image/octet-stream;base64,' + data;
342 }
343
344 if (externalCallback)
345 externalCallback.apply(_this, [blob]);
346
347 // PDF
348 } else if (cfg.format == 'application/pdf' || cfg.format == 'pdf') {
349 data = _this.generatePDF(cfg).output('dataurlstring');
350 blob = _this.generateBlob(data, 'application/pdf');
351
352 if (cfg.output == 'save') {
353 saveAs(blob, cfg.fileName + '.pdf');
354 } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
355 blob = data;
356 } else if (cfg.output == 'dataurlnewwindow') {
357 window.open(data);
358 } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
359 location.href = data;
360 } else if (cfg.output == 'datastream') {
361 location.href = data.replace('application/pdf', 'application/octet-stream');
362 }
363
364 if (externalCallback)
365 externalCallback.apply(_this, [blob]);
366
367 // PNG
368 } else if (cfg.format == 'image/png' || cfg.format == 'png') {
369 data = _this.canvas.toDataURL('image/png');
370 blob = _this.generateBlob(data, 'image/png');
371
372 if (cfg.output == 'save') {
373 saveAs(blob, cfg.fileName + '.png');
374 } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
375 blob = data;
376 } else if (cfg.output == 'dataurlnewwindow') {
377 window.open(data);
378 } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
379 location.href = data;
380 } else if (cfg.output == 'datastream') {
381 location.href = data.replace('image/png', 'image/octet-stream');
382 }
383
384 if (externalCallback)
385 externalCallback.apply(_this, [blob]);
386
387 // JPG
388 } else if (cfg.format == 'image/jpeg' || cfg.format == 'jpeg' || cfg.format == 'jpg') {
389 data = _this.canvas.toDataURL('image/jpeg');
390 blob = _this.generateBlob(data, 'image/jpeg');
391
392 if (cfg.output == 'save') {
393 saveAs(blob, cfg.fileName + '.jpg');
394 } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
395 blob = data;
396 } else if (cfg.output == 'dataurlnewwindow') {
397 window.open(data);
398 } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
399 location.href = data;
400 } else if (cfg.output == 'datastream') {
401 location.href = data.replace('image/jpeg', 'image/octet-stream');
402 }
403
404 if (externalCallback)
405 externalCallback.apply(_this, [blob]);
406 }
407
408 }
409
410 return _this.generateOutput(cfg, internalCallback);
411 },
412
413 /* PUBLIC
414 Polifies missing attributes to the SVG and replaces images to embedded base64 images
415 @param none
416 */
417 polifySVG: function(svg) {
418 var _this = this;
419
420 // Recursive function to force the attributes
421 function recursiveChange(svg, tag) {
422 var items = svg.getElementsByTagName(tag);
423 var i = items.length;
424
425 while(i--) {
426 if (_this.cfg.removeImagery) {
427 items[i].parentNode.removeChild(items[i]);
428
429 } else {
430 var image = document.createElement('img');
431 var canvas = document.createElement('canvas');
432 var ctx = canvas.getContext('2d');
433
434 canvas.width = items[i].getAttribute('width');
435 canvas.height = items[i].getAttribute('height');
436 image.src = items[i].getAttribute('xlink:href');
437 image.width = items[i].getAttribute('width');
438 image.height = items[i].getAttribute('height');
439
440 try {
441 ctx.drawImage(image, 0, 0, image.width, image.height);
442 datastring = canvas.toDataURL(); // image.src; // canvas.toDataURL(); //
443 } catch (err) {
444 datastring = image.src; // image.src; // canvas.toDataURL(); //
445
446 _this.log('Tainted canvas, reached browser CORS security; origin from imagery must be equal to the server!');
447 throw new Error(err);
448 }
449
450 items[i].setAttribute('xlink:href', datastring);
451 }
452
453 if (_this.DEBUG == 10) {
454 _this.log('POLIFIED', items[i]);
455 } // DEBUG
456 }
457 }
458
459 // Put some attrs to it; fixed 20/03/14 xmlns is required to produce a valid svg file
460 if (AmCharts.IEversion == 0) {
461 svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
462 if ( !_this.cfg.removeImagery ) {
463 svg.setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
464 }
465 }
466
467 // DEBUG
468 if (_this.DEBUG == 10) {
469 _this.log('POLIFIED', svg);
470 }
471
472 // Force link adaption
473 recursiveChange(svg, 'pattern');
474 recursiveChange(svg, 'image');
475
476 _this.svgs.push(svg);
477
478 return svg;
479 },
480
481
482 /* PUBLIC
483 Stacks multiple SVGs into one
484 @param none
485 */
486 generateSVG: function() {
487 var _this = this;
488 var context = document.createElement('svg');
489 context.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
490 context.setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
491
492 for (var i = 0; i < _this.processing.buffer.length; i++) {
493 var group = document.createElement('g'),
494 data = _this.processing.buffer[i];
495
496 data[0].setAttribute('xmlns', 'http://www.w3.org/2000/svg');
497 data[0].setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
498
499 group.setAttribute('transform', 'translate('+data[1].x+','+data[1].y+')');
500 group.appendChild(data[0]);
501 context.appendChild(group);
502 }
503
504 return new XMLSerializer().serializeToString(context);
505 },
506
507 /* PUBLIC
508 Generates the canvas with the given SVGs and configured renderer
509 @param callback; function(); gets called after drawing process on the canvas has been finished
510 */
511 generateOutput: function(cfg, callback) {
512 var _this = this,
513 svgs = _this.chart.div.getElementsByTagName('svg'),
514 canvas = document.createElement('canvas'),
515 context = canvas.getContext('2d'),
516 offset = {
517 y: 0,
518 x: 0
519 },
520 tmp = {};
521
522 // Reset
523 _this.processing.buffer = [];
524 _this.processing.drawn = 0;
525 _this.canvas = canvas;
526 _this.svgs = [];
527
528 // Walkthroug SVGs
529 if (_this.DEBUG == 10) {
530 _this.log('START EXPORT');
531 } // DEBUG
532 if (_this.DEBUG == 10) {
533 _this.log('START BUFFERING');
534 } // DEBUG
535 for (var i = 0; i < svgs.length; i++) {
536 var parent = svgs[i].parentNode,
537 svgX = Number(parent.style.left.slice(0, -2)),
538 svgY = Number(parent.style.top.slice(0, -2)),
539 svgClone = _this.polifySVG(svgs[i].cloneNode(true)),
540 tmp = AmCharts.extend({}, offset);
541
542 // Overtake parent position if given; fixed 20/03/14 distinguish between relativ and others
543 if (parent.style.position == 'relative') {
544 offset.x = svgX ? svgX : offset.x;
545 offset.y = svgY ? svgY : offset.y;
546 } else {
547 offset.x = svgX;
548 offset.y = svgY;
549 }
550
551 _this.processing.buffer.push([svgClone, AmCharts.extend({}, offset)]);
552
553 // Put back from "cache"
554 if (svgY && svgX) {
555 offset = tmp;
556
557 // New offset for next one
558 } else {
559 offset.y += svgY ? 0 : parent.offsetHeight;
560 }
561
562 if (_this.DEBUG == 10) {
563 _this.log('BUFFERED', svgs[i], offset);
564 } // DEBUG
565 }
566 if (_this.DEBUG == 10) {
567 _this.log('END BUFFERING');
568 } // DEBUG
569
570 // Apply background
571 if (_this.DEBUG == 10) {
572 _this.log('START DRAWING', cfg.render);
573 } // DEBUG
574 if (_this.DEBUG == 10) {
575 _this.log('FILL BACKGROUND');
576 } // DEBUG
577 canvas.id = AmCharts.getUniqueId();
578 canvas.width = _this.chart.divRealWidth;
579 canvas.height = _this.chart.divRealHeight;
580
581
582 // Stockchart exception
583 var adapted = {
584 width: false,
585 height: false
586 };
587 if ( _this.chart.periodSelector ) {
588 if ( ['left','right'].indexOf(_this.chart.periodSelector.position) != -1 ) {
589 canvas.width -= _this.chart.periodSelector.div.offsetWidth + 16;
590 adapted.width = true;
591 } else {
592 canvas.height -= _this.chart.periodSelector.div.offsetHeight;
593 adapted.height = true;
594 }
595 }
596
597 if ( _this.chart.dataSetSelector ) {
598 if ( ['left','right'].indexOf(_this.chart.dataSetSelector.position) != -1 ) {
599 if ( !adapted.width ) {
600 canvas.width -= _this.chart.dataSetSelector.div.offsetWidth + 16;
601 }
602 } else {
603 canvas.height -= _this.chart.dataSetSelector.div.offsetHeight;
604 }
605 }
606
607 // Set given background; jpeg default
608 if (cfg.backgroundColor || cfg.format == 'image/jpeg') {
609 context.fillStyle = cfg.backgroundColor || '#FFFFFF';
610 context.fillRect(0, 0, canvas.width, canvas.height);
611 }
612
613 /* PRIVATE
614 Recursive function to draw the images to the canvas;
615 @param none;
616 */
617 function drawItWhenItsLoaded() {
618 var img, buffer, offset, source;
619
620 // DRAWING PROCESS DONE
621 if (_this.processing.buffer.length == _this.processing.drawn || cfg.format == 'svg' ) {
622 if (_this.DEBUG == 10) {
623 _this.log('END DRAWING');
624 } // DEBUG
625 return callback();
626
627 // LOOPING LUI
628 } else {
629 if (_this.DEBUG == 10) {
630 _this.log('DRAW', _this.processing.drawn + 1, 'OF', _this.processing.buffer.length);
631 } // DEBUG
632
633 buffer = _this.processing.buffer[_this.processing.drawn];
634 source = new XMLSerializer().serializeToString(buffer[0]); //source = 'data:image/svg+xml;base64,' + btoa();
635 offset = buffer[1];
636
637 if (_this.DEBUG == 10) {
638 _this.log('SOURCE', source);
639 } // DEBUG
640
641 // NATIVE
642 if (cfg.render == 'browser') {
643 img = new Image();
644 img.id = AmCharts.getUniqueId();
645 source = 'data:image/svg+xml;base64,' + btoa(source);
646
647 //img.crossOrigin = "Anonymous";
648 img.onload = function() {
649 context.drawImage(this, buffer[1].x, buffer[1].y);
650 _this.processing.drawn++;
651
652 if (_this.DEBUG == 10) {
653 _this.log('ONLOAD', this);
654 } // DEBUG
655 drawItWhenItsLoaded();
656 };
657 img.onerror = function() {
658 if (_this.DEBUG == 10) {
659 _this.log('ONERROR', this);
660 } // DEBUG
661 context.drawImage(this, buffer[1].x, buffer[1].y);
662 _this.processing.drawn++;
663 drawItWhenItsLoaded();
664 };
665 img.src = source;
666
667 if (_this.DEBUG == 10) {
668 _this.log('ADD', img);
669 } // DEBUG
670 if (img.complete || typeof(img.complete) == 'undefined' || img.complete === undefined) {
671 if (_this.DEBUG == 10) {
672 _this.log('FORCE ONLOAD', img);
673 } // DEBUG
674 img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
675 img.src = source;
676 }
677
678 // CANVG
679 } else if (cfg.render == 'canvg') {
680 canvg(canvas, source, {
681 offsetX: offset.x,
682 offsetY: offset.y,
683 ignoreMouse: true,
684 ignoreAnimation: true,
685 ignoreDimensions: true,
686 ignoreClear: true,
687 renderCallback: function() {
688 _this.processing.drawn++;
689 drawItWhenItsLoaded();
690 }
691 });
692 }
693 }
694 }
695 return drawItWhenItsLoaded();
696 },
697
698 /*
699 Generates the export menu to trigger the exportation
700 @param none;
701 */
702 generateButtons: function() {
703 var _this = this,
704 div = document.createElement('div'),
705 lvl = 0;
706
707 // Push sublings
708 function createList(items) {
709 var ul = document.createElement('ul');
710
711 ul.setAttribute('style', 'list-style: none; margin: 0; padding: 0;');
712
713 // Walkthrough items
714 for (var i = 0; i < items.length; i++) {
715 var li = document.createElement('li'),
716 img = document.createElement('img'),
717 a = document.createElement('a'),
718 item = items[i],
719 children = null,
720 itemStyle = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemStyle), items[i]);
721
722 // MERGE CFG
723 item = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemOutput), item);
724
725 // ICON
726 if (item['icon']) {
727 img.alt = '';
728 img.src = item['icon'];
729 img.setAttribute('style', 'margin: 0 auto;border: none;outline: none');
730 if (item['iconTitle']) {
731 img.title = item['iconTitle'];
732 }
733 a.appendChild(img);
734 }
735
736 // TITLE; STYLING
737 a.href = '#';
738 if (item['title']) {
739 img.setAttribute('style', 'margin-right: 5px;');
740 a.innerHTML += item.title;
741 }
742 a.setAttribute('style', 'display: block;');
743 AmCharts.extend(a.style, itemStyle);
744
745 // ONCLICK
746 a.onclick = item.onclick.bind(a, _this, item);
747 li.appendChild(a);
748
749 // APPEND SIBLINGS
750 if (item.items) {
751 children = createList(item.items);
752 li.appendChild(children);
753
754 li.onmouseover = function() {
755 children.style.display = 'block';
756 };
757 li.onmouseout = function() {
758 children.style.display = 'none';
759 };
760 children.style.display = 'none';
761 }
762
763 // Append to parent
764 ul.appendChild(li);
765
766 // Apply hover
767 a.onmouseover = function() {
768 this.style.backgroundColor = itemStyle.rollOverBackgroundColor;
769 this.style.color = itemStyle.rollOverColor;
770 this.style.borderColor = itemStyle.rollOverBorderColor;
771 };
772 a.onmouseout = function() {
773 this.style.backgroundColor = itemStyle.backgroundColor;
774 this.style.color = itemStyle.color;
775 this.style.borderColor = itemStyle.borderColor;
776 };
777 }
778 lvl++;
779
780 if (_this.DEBUG == 10) {
781 _this.log('MENU', ul);
782 } // DEBUG
783
784 return ul;
785 }
786
787 // Style wrapper; Push into chart div
788 div.setAttribute('style', 'width:39px; height:28px; position: absolute;top:' + _this.cfg.menuTop + ';right:' + _this.cfg.menuRight + ';bottom:' + _this.cfg.menuBottom + ';left:' + _this.cfg.menuLeft + ';box-shadow:0px 0px 1px 0px rgba(0,0,0,0);');
789 div.setAttribute('class', 'amExportButton');
790 div.appendChild(createList(_this.cfg.menuItems));
791 _this.chart.containerDiv.appendChild(div);
792 }
793 });
amcharts/exporting/canvg.js
File was created 1 /*
2 * canvg.js - Javascript SVG parser and renderer on Canvas
3 * MIT Licensed
4 * Gabe Lerner (gabelerner@gmail.com)
5 * http://code.google.com/p/canvg/
6 *
7 * Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/
8 */
9 (function(){
10 // canvg(target, s)
11 // empty parameters: replace all 'svg' elements on page with 'canvas' elements
12 // target: canvas element or the id of a canvas element
13 // s: svg string, url to svg file, or xml document
14 // opts: optional hash of options
15 // ignoreMouse: true => ignore mouse events
16 // ignoreAnimation: true => ignore animations
17 // ignoreDimensions: true => does not try to resize canvas
18 // ignoreClear: true => does not clear canvas
19 // offsetX: int => draws at a x offset
20 // offsetY: int => draws at a y offset
21 // scaleWidth: int => scales horizontally to width
22 // scaleHeight: int => scales vertically to height
23 // renderCallback: function => will call the function after the first render is completed
24 // forceRedraw: function => will call the function on every frame, if it returns true, will redraw
25 this.canvg = function (target, s, opts) {
26 // no parameters
27 if (target == null && s == null && opts == null) {
28 var svgTags = document.getElementsByTagName('svg');
29 for (var i=0; i<svgTags.length; i++) {
30 var svgTag = svgTags[i];
31 var c = document.createElement('canvas');
32 c.width = svgTag.clientWidth;
33 c.height = svgTag.clientHeight;
34 svgTag.parentNode.insertBefore(c, svgTag);
35 svgTag.parentNode.removeChild(svgTag);
36 var div = document.createElement('div');
37 div.appendChild(svgTag);
38 canvg(c, div.innerHTML);
39 }
40 return;
41 }
42 opts = opts || {};
43
44 if (typeof target == 'string') {
45 target = document.getElementById(target);
46 }
47
48 // store class on canvas
49 if (target.svg != null) target.svg.stop();
50 var svg = build();
51 // on i.e. 8 for flash canvas, we can't assign the property so check for it
52 if (!(target.childNodes.length == 1 && target.childNodes[0].nodeName == 'OBJECT')) target.svg = svg;
53 svg.opts = opts;
54
55 var ctx = target.getContext('2d');
56 if (typeof(s.documentElement) != 'undefined') {
57 // load from xml doc
58 svg.loadXmlDoc(ctx, s);
59 }
60 else if (s.substr(0,1) == '<') {
61 // load from xml string
62 svg.loadXml(ctx, s);
63 }
64 else {
65 // load from url
66 svg.load(ctx, s);
67 }
68 }
69
70 function build() {
71 var svg = { };
72
73 svg.FRAMERATE = 30;
74 svg.MAX_VIRTUAL_PIXELS = 30000;
75
76 // globals
77 svg.init = function(ctx) {
78 var uniqueId = 0;
79 svg.UniqueId = function () { uniqueId++; return 'canvg' + uniqueId; };
80 svg.Definitions = {};
81 svg.Styles = {};
82 svg.Animations = [];
83 svg.Images = [];
84 svg.ctx = ctx;
85 svg.ViewPort = new (function () {
86 this.viewPorts = [];
87 this.Clear = function() { this.viewPorts = []; }
88 this.SetCurrent = function(width, height) { this.viewPorts.push({ width: width, height: height }); }
89 this.RemoveCurrent = function() { this.viewPorts.pop(); }
90 this.Current = function() { return this.viewPorts[this.viewPorts.length - 1]; }
91 this.width = function() { return this.Current().width; }
92 this.height = function() { return this.Current().height; }
93 this.ComputeSize = function(d) {
94 if (d != null && typeof(d) == 'number') return d;
95 if (d == 'x') return this.width();
96 if (d == 'y') return this.height();
97 return Math.sqrt(Math.pow(this.width(), 2) + Math.pow(this.height(), 2)) / Math.sqrt(2);
98 }
99 });
100 }
101 svg.init();
102
103 // images loaded
104 svg.ImagesLoaded = function() {
105 for (var i=0; i<svg.Images.length; i++) {
106 if (!svg.Images[i].loaded) return false;
107 }
108 return true;
109 }
110
111 // trim
112 svg.trim = function(s) { return s.replace(/^\s+|\s+$/g, ''); }
113
114 // compress spaces
115 svg.compressSpaces = function(s) { return s.replace(/[\s\r\t\n]+/gm,' '); }
116
117 // ajax
118 svg.ajax = function(url) {
119 var AJAX;
120 if(window.XMLHttpRequest){AJAX=new XMLHttpRequest();}
121 else{AJAX=new ActiveXObject('Microsoft.XMLHTTP');}
122 if(AJAX){
123 AJAX.open('GET',url,false);
124 AJAX.send(null);
125 return AJAX.responseText;
126 }
127 return null;
128 }
129
130 // parse xml
131
132 svg.parseXml = function(xml) {
133 if (window.DOMParser)
134 {
135 var parser = new DOMParser();
136 return parser.parseFromString(xml, 'text/xml');
137 }
138 else
139 {
140 xml = xml.replace(/<!DOCTYPE svg[^>]*>/, '');
141 var xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
142 xmlDoc.async = 'false';
143 xmlDoc.loadXML(xml);
144 return xmlDoc;
145 }
146 }
147
148 svg.Property = function(name, value) {
149 this.name = name;
150 this.value = value;
151 }
152 svg.Property.prototype.getValue = function() {
153 return this.value;
154 }
155
156 svg.Property.prototype.hasValue = function() {
157 return (this.value != null && this.value !== '');
158 }
159
160 // return the numerical value of the property
161 svg.Property.prototype.numValue = function() {
162 if (!this.hasValue()) return 0;
163
164 var n = parseFloat(this.value);
165 if ((this.value + '').match(/%$/)) {
166 n = n / 100.0;
167 }
168 return n;
169 }
170
171 svg.Property.prototype.valueOrDefault = function(def) {
172 if (this.hasValue()) return this.value;
173 return def;
174 }
175
176 svg.Property.prototype.numValueOrDefault = function(def) {
177 if (this.hasValue()) return this.numValue();
178 return def;
179 }
180
181 // color extensions
182 // augment the current color value with the opacity
183 svg.Property.prototype.addOpacity = function(opacity) {
184 var newValue = this.value;
185 if (opacity != null && opacity != '' && typeof(this.value)=='string') { // can only add opacity to colors, not patterns
186 var color = new RGBColor(this.value);
187 if (color.ok) {
188 newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacity + ')';
189 }
190 }
191 return new svg.Property(this.name, newValue);
192 }
193
194 // definition extensions
195 // get the definition from the definitions table
196 svg.Property.prototype.getDefinition = function() {
197 var name = this.value.match(/#([^\)'"]+)/);
198 if (name) { name = name[1]; }
199 if (!name) { name = this.value; }
200 return svg.Definitions[name];
201 }
202
203 svg.Property.prototype.isUrlDefinition = function() {
204 return this.value.indexOf('url(') == 0
205 }
206
207 svg.Property.prototype.getFillStyleDefinition = function(e, opacityProp) {
208 var def = this.getDefinition();
209
210 // gradient
211 if (def != null && def.createGradient) {
212 return def.createGradient(svg.ctx, e, opacityProp);
213 }
214
215 // pattern
216 if (def != null && def.createPattern) {
217 if (def.getHrefAttribute().hasValue()) {
218 var pt = def.attribute('patternTransform');
219 def = def.getHrefAttribute().getDefinition();
220 if (pt.hasValue()) { def.attribute('patternTransform', true).value = pt.value; }
221 }
222 return def.createPattern(svg.ctx, e);
223 }
224
225 return null;
226 }
227
228 // length extensions
229 svg.Property.prototype.getDPI = function(viewPort) {
230 return 96.0; // TODO: compute?
231 }
232
233 svg.Property.prototype.getEM = function(viewPort) {
234 var em = 12;
235
236 var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);
237 if (fontSize.hasValue()) em = fontSize.toPixels(viewPort);
238
239 return em;
240 }
241
242 svg.Property.prototype.getUnits = function() {
243 var s = this.value+'';
244 return s.replace(/[0-9\.\-]/g,'');
245 }
246
247 // get the length as pixels
248 svg.Property.prototype.toPixels = function(viewPort, processPercent) {
249 if (!this.hasValue()) return 0;
250 var s = this.value+'';
251 if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
252 if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
253 if (s.match(/px$/)) return this.numValue();
254 if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
255 if (s.match(/pc$/)) return this.numValue() * 15;
256 if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
257 if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
258 if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
259 if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
260 var n = this.numValue();
261 if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
262 return n;
263 }
264
265 // time extensions
266 // get the time as milliseconds
267 svg.Property.prototype.toMilliseconds = function() {
268 if (!this.hasValue()) return 0;
269 var s = this.value+'';
270 if (s.match(/s$/)) return this.numValue() * 1000;
271 if (s.match(/ms$/)) return this.numValue();
272 return this.numValue();
273 }
274
275 // angle extensions
276 // get the angle as radians
277 svg.Property.prototype.toRadians = function() {
278 if (!this.hasValue()) return 0;
279 var s = this.value+'';
280 if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
281 if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
282 if (s.match(/rad$/)) return this.numValue();
283 return this.numValue() * (Math.PI / 180.0);
284 }
285
286 // fonts
287 svg.Font = new (function() {
288 this.Styles = 'normal|italic|oblique|inherit';
289 this.Variants = 'normal|small-caps|inherit';
290 this.Weights = 'normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit';
291
292 this.CreateFont = function(fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) {
293 var f = inherit != null ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font);
294 return {
295 fontFamily: fontFamily || f.fontFamily,
296 fontSize: fontSize || f.fontSize,
297 fontStyle: fontStyle || f.fontStyle,
298 fontWeight: fontWeight || f.fontWeight,
299 fontVariant: fontVariant || f.fontVariant,
300 toString: function () { return [this.fontStyle, this.fontVariant, this.fontWeight, this.fontSize, this.fontFamily].join(' ') }
301 }
302 }
303
304 var that = this;
305 this.Parse = function(s) {
306 var f = {};
307 var d = svg.trim(svg.compressSpaces(s || '')).split(' ');
308 var set = { fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false }
309 var ff = '';
310 for (var i=0; i<d.length; i++) {
311 if (!set.fontStyle && that.Styles.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontStyle = d[i]; set.fontStyle = true; }
312 else if (!set.fontVariant && that.Variants.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontVariant = d[i]; set.fontStyle = set.fontVariant = true; }
313 else if (!set.fontWeight && that.Weights.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontWeight = d[i]; set.fontStyle = set.fontVariant = set.fontWeight = true; }
314 else if (!set.fontSize) { if (d[i] != 'inherit') f.fontSize = d[i].split('/')[0]; set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true; }
315 else { if (d[i] != 'inherit') ff += d[i]; }
316 } if (ff != '') f.fontFamily = ff;
317 return f;
318 }
319 });
320
321 // points and paths
322 svg.ToNumberArray = function(s) {
323 var a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');
324 for (var i=0; i<a.length; i++) {
325 a[i] = parseFloat(a[i]);
326 }
327 return a;
328 }
329 svg.Point = function(x, y) {
330 this.x = x;
331 this.y = y;
332 }
333 svg.Point.prototype.angleTo = function(p) {
334 return Math.atan2(p.y - this.y, p.x - this.x);
335 }
336
337 svg.Point.prototype.applyTransform = function(v) {
338 var xp = this.x * v[0] + this.y * v[2] + v[4];
339 var yp = this.x * v[1] + this.y * v[3] + v[5];
340 this.x = xp;
341 this.y = yp;
342 }
343
344 svg.CreatePoint = function(s) {
345 var a = svg.ToNumberArray(s);
346 return new svg.Point(a[0], a[1]);
347 }
348 svg.CreatePath = function(s) {
349 var a = svg.ToNumberArray(s);
350 var path = [];
351 for (var i=0; i<a.length; i+=2) {
352 path.push(new svg.Point(a[i], a[i+1]));
353 }
354 return path;
355 }
356
357 // bounding box
358 svg.BoundingBox = function(x1, y1, x2, y2) { // pass in initial points if you want
359 this.x1 = Number.NaN;
360 this.y1 = Number.NaN;
361 this.x2 = Number.NaN;
362 this.y2 = Number.NaN;
363
364 this.x = function() { return this.x1; }
365 this.y = function() { return this.y1; }
366 this.width = function() { return this.x2 - this.x1; }
367 this.height = function() { return this.y2 - this.y1; }
368
369 this.addPoint = function(x, y) {
370 if (x != null) {
371 if (isNaN(this.x1) || isNaN(this.x2)) {
372 this.x1 = x;
373 this.x2 = x;
374 }
375 if (x < this.x1) this.x1 = x;
376 if (x > this.x2) this.x2 = x;
377 }
378
379 if (y != null) {
380 if (isNaN(this.y1) || isNaN(this.y2)) {
381 this.y1 = y;
382 this.y2 = y;
383 }
384 if (y < this.y1) this.y1 = y;
385 if (y > this.y2) this.y2 = y;
386 }
387 }
388 this.addX = function(x) { this.addPoint(x, null); }
389 this.addY = function(y) { this.addPoint(null, y); }
390
391 this.addBoundingBox = function(bb) {
392 this.addPoint(bb.x1, bb.y1);
393 this.addPoint(bb.x2, bb.y2);
394 }
395
396 this.addQuadraticCurve = function(p0x, p0y, p1x, p1y, p2x, p2y) {
397 var cp1x = p0x + 2/3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0)
398 var cp1y = p0y + 2/3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0)
399 var cp2x = cp1x + 1/3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0)
400 var cp2y = cp1y + 1/3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0)
401 this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y);
402 }
403
404 this.addBezierCurve = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {
405 // from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
406 var p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y];
407 this.addPoint(p0[0], p0[1]);
408 this.addPoint(p3[0], p3[1]);
409
410 for (i=0; i<=1; i++) {
411 var f = function(t) {
412 return Math.pow(1-t, 3) * p0[i]
413 + 3 * Math.pow(1-t, 2) * t * p1[i]
414 + 3 * (1-t) * Math.pow(t, 2) * p2[i]
415 + Math.pow(t, 3) * p3[i];
416 }
417
418 var b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i];
419 var a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i];
420 var c = 3 * p1[i] - 3 * p0[i];
421
422 if (a == 0) {
423 if (b == 0) continue;
424 var t = -c / b;
425 if (0 < t && t < 1) {
426 if (i == 0) this.addX(f(t));
427 if (i == 1) this.addY(f(t));
428 }
429 continue;
430 }
431
432 var b2ac = Math.pow(b, 2) - 4 * c * a;
433 if (b2ac < 0) continue;
434 var t1 = (-b + Math.sqrt(b2ac)) / (2 * a);
435 if (0 < t1 && t1 < 1) {
436 if (i == 0) this.addX(f(t1));
437 if (i == 1) this.addY(f(t1));
438 }
439 var t2 = (-b - Math.sqrt(b2ac)) / (2 * a);
440 if (0 < t2 && t2 < 1) {
441 if (i == 0) this.addX(f(t2));
442 if (i == 1) this.addY(f(t2));
443 }
444 }
445 }
446
447 this.isPointInBox = function(x, y) {
448 return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2);
449 }
450
451 this.addPoint(x1, y1);
452 this.addPoint(x2, y2);
453 }
454
455 // transforms
456 svg.Transform = function(v) {
457 var that = this;
458 this.Type = {}
459
460 // translate
461 this.Type.translate = function(s) {
462 this.p = svg.CreatePoint(s);
463 this.apply = function(ctx) {
464 ctx.translate(this.p.x || 0.0, this.p.y || 0.0);
465 }
466 this.unapply = function(ctx) {
467 ctx.translate(-1.0 * this.p.x || 0.0, -1.0 * this.p.y || 0.0);
468 }
469 this.applyToPoint = function(p) {
470 p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
471 }
472 }
473
474 // rotate
475 this.Type.rotate = function(s) {
476 var a = svg.ToNumberArray(s);
477 this.angle = new svg.Property('angle', a[0]);
478 this.cx = a[1] || 0;
479 this.cy = a[2] || 0;
480 this.apply = function(ctx) {
481 ctx.translate(this.cx, this.cy);
482 ctx.rotate(this.angle.toRadians());
483 ctx.translate(-this.cx, -this.cy);
484 }
485 this.unapply = function(ctx) {
486 ctx.translate(this.cx, this.cy);
487 ctx.rotate(-1.0 * this.angle.toRadians());
488 ctx.translate(-this.cx, -this.cy);
489 }
490 this.applyToPoint = function(p) {
491 var a = this.angle.toRadians();
492 p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
493 p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]);
494 p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]);
495 }
496 }
497
498 this.Type.scale = function(s) {
499 this.p = svg.CreatePoint(s);
500 this.apply = function(ctx) {
501 ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0);
502 }
503 this.unapply = function(ctx) {
504 ctx.scale(1.0 / this.p.x || 1.0, 1.0 / this.p.y || this.p.x || 1.0);
505 }
506 this.applyToPoint = function(p) {
507 p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]);
508 }
509 }
510
511 this.Type.matrix = function(s) {
512 this.m = svg.ToNumberArray(s);
513 this.apply = function(ctx) {
514 ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
515 }
516 this.applyToPoint = function(p) {
517 p.applyTransform(this.m);
518 }
519 }
520
521 this.Type.SkewBase = function(s) {
522 this.base = that.Type.matrix;
523 this.base(s);
524 this.angle = new svg.Property('angle', s);
525 }
526 this.Type.SkewBase.prototype = new this.Type.matrix;
527
528 this.Type.skewX = function(s) {
529 this.base = that.Type.SkewBase;
530 this.base(s);
531 this.m = [1, 0, Math.tan(this.angle.toRadians()), 1, 0, 0];
532 }
533 this.Type.skewX.prototype = new this.Type.SkewBase;
534
535 this.Type.skewY = function(s) {
536 this.base = that.Type.SkewBase;
537 this.base(s);
538 this.m = [1, Math.tan(this.angle.toRadians()), 0, 1, 0, 0];
539 }
540 this.Type.skewY.prototype = new this.Type.SkewBase;
541
542 this.transforms = [];
543
544 this.apply = function(ctx) {
545 for (var i=0; i<this.transforms.length; i++) {
546 this.transforms[i].apply(ctx);
547 }
548 }
549
550 this.unapply = function(ctx) {
551 for (var i=this.transforms.length-1; i>=0; i--) {
552 this.transforms[i].unapply(ctx);
553 }
554 }
555
556 this.applyToPoint = function(p) {
557 for (var i=0; i<this.transforms.length; i++) {
558 this.transforms[i].applyToPoint(p);
559 }
560 }
561
562 var data = svg.trim(svg.compressSpaces(v)).replace(/\)(\s?,\s?)/g,') ').split(/\s(?=[a-z])/);
563 for (var i=0; i<data.length; i++) {
564 var type = svg.trim(data[i].split('(')[0]);
565 var s = data[i].split('(')[1].replace(')','');
566 var transform = new this.Type[type](s);
567 transform.type = type;
568 this.transforms.push(transform);
569 }
570 }
571
572 // aspect ratio
573 svg.AspectRatio = function(ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) {
574 // aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
575 aspectRatio = svg.compressSpaces(aspectRatio);
576 aspectRatio = aspectRatio.replace(/^defer\s/,''); // ignore defer
577 var align = aspectRatio.split(' ')[0] || 'xMidYMid';
578 var meetOrSlice = aspectRatio.split(' ')[1] || 'meet';
579
580 // calculate scale
581 var scaleX = width / desiredWidth;
582 var scaleY = height / desiredHeight;
583 var scaleMin = Math.min(scaleX, scaleY);
584 var scaleMax = Math.max(scaleX, scaleY);
585 if (meetOrSlice == 'meet') { desiredWidth *= scaleMin; desiredHeight *= scaleMin; }
586 if (meetOrSlice == 'slice') { desiredWidth *= scaleMax; desiredHeight *= scaleMax; }
587
588 refX = new svg.Property('refX', refX);
589 refY = new svg.Property('refY', refY);
590 if (refX.hasValue() && refY.hasValue()) {
591 ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
592 }
593 else {
594 // align
595 if (align.match(/^xMid/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
596 if (align.match(/YMid$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
597 if (align.match(/^xMax/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width - desiredWidth, 0);
598 if (align.match(/YMax$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height - desiredHeight);
599 }
600
601 // scale
602 if (align == 'none') ctx.scale(scaleX, scaleY);
603 else if (meetOrSlice == 'meet') ctx.scale(scaleMin, scaleMin);
604 else if (meetOrSlice == 'slice') ctx.scale(scaleMax, scaleMax);
605
606 // translate
607 ctx.translate(minX == null ? 0 : -minX, minY == null ? 0 : -minY);
608 }
609
610 // elements
611 svg.Element = {}
612
613 svg.EmptyProperty = new svg.Property('EMPTY', '');
614
615 svg.Element.ElementBase = function(node) {
616 this.attributes = {};
617 this.styles = {};
618 this.children = [];
619
620 // get or create attribute
621 this.attribute = function(name, createIfNotExists) {
622 var a = this.attributes[name];
623 if (a != null) return a;
624
625 if (createIfNotExists == true) { a = new svg.Property(name, ''); this.attributes[name] = a; }
626 return a || svg.EmptyProperty;
627 }
628
629 this.getHrefAttribute = function() {
630 for (var a in this.attributes) {
631 if (a.match(/:href$/)) {
632 return this.attributes[a];
633 }
634 }
635 return svg.EmptyProperty;
636 }
637
638 // get or create style, crawls up node tree
639 this.style = function(name, createIfNotExists) {
640 var s = this.styles[name];
641 if (s != null) return s;
642
643 var a = this.attribute(name);
644 if (a != null && a.hasValue()) {
645 this.styles[name] = a; // move up to me to cache
646 return a;
647 }
648
649 var p = this.parent;
650 if (p != null) {
651 var ps = p.style(name);
652 if (ps != null && ps.hasValue()) {
653 return ps;
654 }
655 }
656
657 if (createIfNotExists == true) { s = new svg.Property(name, ''); this.styles[name] = s; }
658 return s || svg.EmptyProperty;
659 }
660
661 // base render
662 this.render = function(ctx) {
663 // don't render display=none
664 if (this.style('display').value == 'none') return;
665
666 // don't render visibility=hidden
667 if (this.attribute('visibility').value == 'hidden') return;
668
669 ctx.save();
670 if (this.attribute('mask').hasValue()) { // mask
671 var mask = this.attribute('mask').getDefinition();
672 if (mask != null) mask.apply(ctx, this);
673 }
674 else if (this.style('filter').hasValue()) { // filter
675 var filter = this.style('filter').getDefinition();
676 if (filter != null) filter.apply(ctx, this);
677 }
678 else {
679 this.setContext(ctx);
680 this.renderChildren(ctx);
681 this.clearContext(ctx);
682 }
683 ctx.restore();
684 }
685
686 // base set context
687 this.setContext = function(ctx) {
688 // OVERRIDE ME!
689 }
690
691 // base clear context
692 this.clearContext = function(ctx) {
693 // OVERRIDE ME!
694 }
695
696 // base render children
697 this.renderChildren = function(ctx) {
698 for (var i=0; i<this.children.length; i++) {
699 this.children[i].render(ctx);
700 }
701 }
702
703 this.addChild = function(childNode, create) {
704 var child = childNode;
705 if (create) child = svg.CreateElement(childNode);
706 child.parent = this;
707 this.children.push(child);
708 }
709
710 if (node != null && node.nodeType == 1) { //ELEMENT_NODE
711 // add children
712 for (var i=0; i<node.childNodes.length; i++) {
713 var childNode = node.childNodes[i];
714 if (childNode.nodeType == 1) this.addChild(childNode, true); //ELEMENT_NODE
715 if (this.captureTextNodes && childNode.nodeType == 3) {
716 var text = childNode.nodeValue || childNode.text || '';
717 if (svg.trim(svg.compressSpaces(text)) != '') {
718 this.addChild(new svg.Element.tspan(childNode), false); // TEXT_NODE
719 }
720 }
721 }
722
723 // add attributes
724 for (var i=0; i<node.attributes.length; i++) {
725 var attribute = node.attributes[i];
726 this.attributes[attribute.nodeName] = new svg.Property(attribute.nodeName, attribute.nodeValue);
727 }
728
729 // add tag styles
730 var styles = svg.Styles[node.nodeName];
731 if (styles != null) {
732 for (var name in styles) {
733 this.styles[name] = styles[name];
734 }
735 }
736
737 // add class styles
738 if (this.attribute('class').hasValue()) {
739 var classes = svg.compressSpaces(this.attribute('class').value).split(' ');
740 for (var j=0; j<classes.length; j++) {
741 styles = svg.Styles['.'+classes[j]];
742 if (styles != null) {
743 for (var name in styles) {
744 this.styles[name] = styles[name];
745 }
746 }
747 styles = svg.Styles[node.nodeName+'.'+classes[j]];
748 if (styles != null) {
749 for (var name in styles) {
750 this.styles[name] = styles[name];
751 }
752 }
753 }
754 }
755
756 // add id styles
757 if (this.attribute('id').hasValue()) {
758 var styles = svg.Styles['#' + this.attribute('id').value];
759 if (styles != null) {
760 for (var name in styles) {
761 this.styles[name] = styles[name];
762 }
763 }
764 }
765
766 // add inline styles
767 if (this.attribute('style').hasValue()) {
768 var styles = this.attribute('style').value.split(';');
769 for (var i=0; i<styles.length; i++) {
770 if (svg.trim(styles[i]) != '') {
771 var style = styles[i].split(':');
772 var name = svg.trim(style[0]);
773 var value = svg.trim(style[1]);
774 this.styles[name] = new svg.Property(name, value);
775 }
776 }
777 }
778
779 // add id
780 if (this.attribute('id').hasValue()) {
781 if (svg.Definitions[this.attribute('id').value] == null) {
782 svg.Definitions[this.attribute('id').value] = this;
783 }
784 }
785 }
786 }
787
788 svg.Element.RenderedElementBase = function(node) {
789 this.base = svg.Element.ElementBase;
790 this.base(node);
791
792 this.setContext = function(ctx) {
793 // fill
794 if (this.style('fill').isUrlDefinition()) {
795 var fs = this.style('fill').getFillStyleDefinition(this, this.style('fill-opacity'));
796 if (fs != null) ctx.fillStyle = fs;
797 }
798 else if (this.style('fill').hasValue()) {
799 var fillStyle = this.style('fill');
800 if (fillStyle.value == 'currentColor') fillStyle.value = this.style('color').value;
801 ctx.fillStyle = (fillStyle.value == 'none' ? 'rgba(0,0,0,0)' : fillStyle.value);
802 }
803 if (this.style('fill-opacity').hasValue()) {
804 var fillStyle = new svg.Property('fill', ctx.fillStyle);
805 fillStyle = fillStyle.addOpacity(this.style('fill-opacity').value);
806 ctx.fillStyle = fillStyle.value;
807 }
808
809 // stroke
810 if (this.style('stroke').isUrlDefinition()) {
811 var fs = this.style('stroke').getFillStyleDefinition(this, this.style('stroke-opacity'));
812 if (fs != null) ctx.strokeStyle = fs;
813 }
814 else if (this.style('stroke').hasValue()) {
815 var strokeStyle = this.style('stroke');
816 if (strokeStyle.value == 'currentColor') strokeStyle.value = this.style('color').value;
817 ctx.strokeStyle = (strokeStyle.value == 'none' ? 'rgba(0,0,0,0)' : strokeStyle.value);
818 }
819 if (this.style('stroke-opacity').hasValue()) {
820 var strokeStyle = new svg.Property('stroke', ctx.strokeStyle);
821 strokeStyle = strokeStyle.addOpacity(this.style('stroke-opacity').value);
822 ctx.strokeStyle = strokeStyle.value;
823 }
824 if (this.style('stroke-width').hasValue()) {
825 var newLineWidth = this.style('stroke-width').toPixels();
826 ctx.lineWidth = newLineWidth == 0 ? 0.001 : newLineWidth; // browsers don't respect 0
827 }
828 if (this.style('stroke-linecap').hasValue()) ctx.lineCap = this.style('stroke-linecap').value;
829 if (this.style('stroke-linejoin').hasValue()) ctx.lineJoin = this.style('stroke-linejoin').value;
830 if (this.style('stroke-miterlimit').hasValue()) ctx.miterLimit = this.style('stroke-miterlimit').value;
831 if (this.style('stroke-dasharray').hasValue()) {
832 var gaps = svg.ToNumberArray(this.style('stroke-dasharray').value);
833 if (typeof(ctx.setLineDash) != 'undefined') { ctx.setLineDash(gaps); }
834 else if (typeof(ctx.webkitLineDash) != 'undefined') { ctx.webkitLineDash = gaps; }
835 else if (typeof(ctx.mozDash ) != 'undefined') { ctx.mozDash = gaps; }
836
837 var offset = this.style('stroke-dashoffset').numValueOrDefault(1);
838 if (typeof(ctx.lineDashOffset) != 'undefined') { ctx.lineDashOffset = offset; }
839 else if (typeof(ctx.webkitLineDashOffset) != 'undefined') { ctx.webkitLineDashOffset = offset; }
840 else if (typeof(ctx.mozDashOffset) != 'undefined') { ctx.mozDashOffset = offset; }
841 }
842
843 // font
844 if (typeof(ctx.font) != 'undefined') {
845 ctx.font = svg.Font.CreateFont(
846 this.style('font-style').value,
847 this.style('font-variant').value,
848 this.style('font-weight').value,
849 this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
850 this.style('font-family').value).toString();
851 }
852
853 // transform
854 if (this.attribute('transform').hasValue()) {
855 var transform = new svg.Transform(this.attribute('transform').value);
856 transform.apply(ctx);
857 }
858
859 // clip
860 if (this.style('clip-path').hasValue()) {
861 var clip = this.style('clip-path').getDefinition();
862 if (clip != null) clip.apply(ctx);
863 }
864
865 // opacity
866 if (this.style('opacity').hasValue()) {
867 ctx.globalAlpha = this.style('opacity').numValue();
868 }
869 }
870 }
871 svg.Element.RenderedElementBase.prototype = new svg.Element.ElementBase;
872
873 svg.Element.PathElementBase = function(node) {
874 this.base = svg.Element.RenderedElementBase;
875 this.base(node);
876
877 this.path = function(ctx) {
878 if (ctx != null) ctx.beginPath();
879 return new svg.BoundingBox();
880 }
881
882 this.renderChildren = function(ctx) {
883 this.path(ctx);
884 svg.Mouse.checkPath(this, ctx);
885 if (ctx.fillStyle != '') {
886 if (this.attribute('fill-rule').hasValue()) { ctx.fill(this.attribute('fill-rule').value); }
887 else { ctx.fill(); }
888 }
889 if (ctx.strokeStyle != '') ctx.stroke();
890
891 var markers = this.getMarkers();
892 if (markers != null) {
893 if (this.style('marker-start').isUrlDefinition()) {
894 var marker = this.style('marker-start').getDefinition();
895 marker.render(ctx, markers[0][0], markers[0][1]);
896 }
897 if (this.style('marker-mid').isUrlDefinition()) {
898 var marker = this.style('marker-mid').getDefinition();
899 for (var i=1;i<markers.length-1;i++) {
900 marker.render(ctx, markers[i][0], markers[i][1]);
901 }
902 }
903 if (this.style('marker-end').isUrlDefinition()) {
904 var marker = this.style('marker-end').getDefinition();
905 marker.render(ctx, markers[markers.length-1][0], markers[markers.length-1][1]);
906 }
907 }
908 }
909
910 this.getBoundingBox = function() {
911 return this.path();
912 }
913
914 this.getMarkers = function() {
915 return null;
916 }
917 }
918 svg.Element.PathElementBase.prototype = new svg.Element.RenderedElementBase;
919
920 // svg element
921 svg.Element.svg = function(node) {
922 this.base = svg.Element.RenderedElementBase;
923 this.base(node);
924
925 this.baseClearContext = this.clearContext;
926 this.clearContext = function(ctx) {
927 this.baseClearContext(ctx);
928 svg.ViewPort.RemoveCurrent();
929 }
930
931 this.baseSetContext = this.setContext;
932 this.setContext = function(ctx) {
933 // initial values
934 ctx.strokeStyle = 'rgba(0,0,0,0)';
935 ctx.lineCap = 'butt';
936 ctx.lineJoin = 'miter';
937 ctx.miterLimit = 4;
938
939 this.baseSetContext(ctx);
940
941 // create new view port
942 if (!this.attribute('x').hasValue()) this.attribute('x', true).value = 0;
943 if (!this.attribute('y').hasValue()) this.attribute('y', true).value = 0;
944 ctx.translate(this.attribute('x').toPixels('x'), this.attribute('y').toPixels('y'));
945
946 var width = svg.ViewPort.width();
947 var height = svg.ViewPort.height();
948
949 if (!this.attribute('width').hasValue()) this.attribute('width', true).value = '100%';
950 if (!this.attribute('height').hasValue()) this.attribute('height', true).value = '100%';
951 if (typeof(this.root) == 'undefined') {
952 width = this.attribute('width').toPixels('x');
953 height = this.attribute('height').toPixels('y');
954
955 var x = 0;
956 var y = 0;
957 if (this.attribute('refX').hasValue() && this.attribute('refY').hasValue()) {
958 x = -this.attribute('refX').toPixels('x');
959 y = -this.attribute('refY').toPixels('y');
960 }
961
962 ctx.beginPath();
963 ctx.moveTo(x, y);
964 ctx.lineTo(width, y);
965 ctx.lineTo(width, height);
966 ctx.lineTo(x, height);
967 ctx.closePath();
968 ctx.clip();
969 }
970 svg.ViewPort.SetCurrent(width, height);
971
972 // viewbox
973 if (this.attribute('viewBox').hasValue()) {
974 var viewBox = svg.ToNumberArray(this.attribute('viewBox').value);
975 var minX = viewBox[0];
976 var minY = viewBox[1];
977 width = viewBox[2];
978 height = viewBox[3];
979
980 svg.AspectRatio(ctx,
981 this.attribute('preserveAspectRatio').value,
982 svg.ViewPort.width(),
983 width,
984 svg.ViewPort.height(),
985 height,
986 minX,
987 minY,
988 this.attribute('refX').value,
989 this.attribute('refY').value);
990
991 svg.ViewPort.RemoveCurrent();
992 svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]);
993 }
994 }
995 }
996 svg.Element.svg.prototype = new svg.Element.RenderedElementBase;
997
998 // rect element
999 svg.Element.rect = function(node) {
1000 this.base = svg.Element.PathElementBase;
1001 this.base(node);
1002
1003 this.path = function(ctx) {
1004 var x = this.attribute('x').toPixels('x');
1005 var y = this.attribute('y').toPixels('y');
1006 var width = this.attribute('width').toPixels('x');
1007 var height = this.attribute('height').toPixels('y');
1008 var rx = this.attribute('rx').toPixels('x');
1009 var ry = this.attribute('ry').toPixels('y');
1010 if (this.attribute('rx').hasValue() && !this.attribute('ry').hasValue()) ry = rx;
1011 if (this.attribute('ry').hasValue() && !this.attribute('rx').hasValue()) rx = ry;
1012 rx = Math.min(rx, width / 2.0);
1013 ry = Math.min(ry, height / 2.0);
1014 if (ctx != null) {
1015 ctx.beginPath();
1016 ctx.moveTo(x + rx, y);
1017 ctx.lineTo(x + width - rx, y);
1018 ctx.quadraticCurveTo(x + width, y, x + width, y + ry)
1019 ctx.lineTo(x + width, y + height - ry);
1020 ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height)
1021 ctx.lineTo(x + rx, y + height);
1022 ctx.quadraticCurveTo(x, y + height, x, y + height - ry)
1023 ctx.lineTo(x, y + ry);
1024 ctx.quadraticCurveTo(x, y, x + rx, y)
1025 ctx.closePath();
1026 }
1027
1028 return new svg.BoundingBox(x, y, x + width, y + height);
1029 }
1030 }
1031 svg.Element.rect.prototype = new svg.Element.PathElementBase;
1032
1033 // circle element
1034 svg.Element.circle = function(node) {
1035 this.base = svg.Element.PathElementBase;
1036 this.base(node);
1037
1038 this.path = function(ctx) {
1039 var cx = this.attribute('cx').toPixels('x');
1040 var cy = this.attribute('cy').toPixels('y');
1041 var r = this.attribute('r').toPixels();
1042
1043 if (ctx != null) {
1044 ctx.beginPath();
1045 ctx.arc(cx, cy, r, 0, Math.PI * 2, true);
1046 ctx.closePath();
1047 }
1048
1049 return new svg.BoundingBox(cx - r, cy - r, cx + r, cy + r);
1050 }
1051 }
1052 svg.Element.circle.prototype = new svg.Element.PathElementBase;
1053
1054 // ellipse element
1055 svg.Element.ellipse = function(node) {
1056 this.base = svg.Element.PathElementBase;
1057 this.base(node);
1058
1059 this.path = function(ctx) {
1060 var KAPPA = 4 * ((Math.sqrt(2) - 1) / 3);
1061 var rx = this.attribute('rx').toPixels('x');
1062 var ry = this.attribute('ry').toPixels('y');
1063 var cx = this.attribute('cx').toPixels('x');
1064 var cy = this.attribute('cy').toPixels('y');
1065
1066 if (ctx != null) {
1067 ctx.beginPath();
1068 ctx.moveTo(cx, cy - ry);
1069 ctx.bezierCurveTo(cx + (KAPPA * rx), cy - ry, cx + rx, cy - (KAPPA * ry), cx + rx, cy);
1070 ctx.bezierCurveTo(cx + rx, cy + (KAPPA * ry), cx + (KAPPA * rx), cy + ry, cx, cy + ry);
1071 ctx.bezierCurveTo(cx - (KAPPA * rx), cy + ry, cx - rx, cy + (KAPPA * ry), cx - rx, cy);
1072 ctx.bezierCurveTo(cx - rx, cy - (KAPPA * ry), cx - (KAPPA * rx), cy - ry, cx, cy - ry);
1073 ctx.closePath();
1074 }
1075
1076 return new svg.BoundingBox(cx - rx, cy - ry, cx + rx, cy + ry);
1077 }
1078 }
1079 svg.Element.ellipse.prototype = new svg.Element.PathElementBase;
1080
1081 // line element
1082 svg.Element.line = function(node) {
1083 this.base = svg.Element.PathElementBase;
1084 this.base(node);
1085
1086 this.getPoints = function() {
1087 return [
1088 new svg.Point(this.attribute('x1').toPixels('x'), this.attribute('y1').toPixels('y')),
1089 new svg.Point(this.attribute('x2').toPixels('x'), this.attribute('y2').toPixels('y'))];
1090 }
1091
1092 this.path = function(ctx) {
1093 var points = this.getPoints();
1094
1095 if (ctx != null) {
1096 ctx.beginPath();
1097 ctx.moveTo(points[0].x, points[0].y);
1098 ctx.lineTo(points[1].x, points[1].y);
1099 }
1100
1101 return new svg.BoundingBox(points[0].x, points[0].y, points[1].x, points[1].y);
1102 }
1103
1104 this.getMarkers = function() {
1105 var points = this.getPoints();
1106 var a = points[0].angleTo(points[1]);
1107 return [[points[0], a], [points[1], a]];
1108 }
1109 }
1110 svg.Element.line.prototype = new svg.Element.PathElementBase;
1111
1112 // polyline element
1113 svg.Element.polyline = function(node) {
1114 this.base = svg.Element.PathElementBase;
1115 this.base(node);
1116
1117 this.points = svg.CreatePath(this.attribute('points').value);
1118 this.path = function(ctx) {
1119 var bb = new svg.BoundingBox(this.points[0].x, this.points[0].y);
1120 if (ctx != null) {
1121 ctx.beginPath();
1122 ctx.moveTo(this.points[0].x, this.points[0].y);
1123 }
1124 for (var i=1; i<this.points.length; i++) {
1125 bb.addPoint(this.points[i].x, this.points[i].y);
1126 if (ctx != null) ctx.lineTo(this.points[i].x, this.points[i].y);
1127 }
1128 return bb;
1129 }
1130
1131 this.getMarkers = function() {
1132 var markers = [];
1133 for (var i=0; i<this.points.length - 1; i++) {
1134 markers.push([this.points[i], this.points[i].angleTo(this.points[i+1])]);
1135 }
1136 markers.push([this.points[this.points.length-1], markers[markers.length-1][1]]);
1137 return markers;
1138 }
1139 }
1140 svg.Element.polyline.prototype = new svg.Element.PathElementBase;
1141
1142 // polygon element
1143 svg.Element.polygon = function(node) {
1144 this.base = svg.Element.polyline;
1145 this.base(node);
1146
1147 this.basePath = this.path;
1148 this.path = function(ctx) {
1149 var bb = this.basePath(ctx);
1150 if (ctx != null) {
1151 ctx.lineTo(this.points[0].x, this.points[0].y);
1152 ctx.closePath();
1153 }
1154 return bb;
1155 }
1156 }
1157 svg.Element.polygon.prototype = new svg.Element.polyline;
1158
1159 // path element
1160 svg.Element.path = function(node) {
1161 this.base = svg.Element.PathElementBase;
1162 this.base(node);
1163
1164 var d = this.attribute('d').value;
1165 // TODO: convert to real lexer based on http://www.w3.org/TR/SVG11/paths.html#PathDataBNF
1166 d = d.replace(/,/gm,' '); // get rid of all commas
1167 d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from commands
1168 d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from commands
1169 d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,'$1 $2'); // separate commands from points
1170 d = d.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from points
1171 d = d.replace(/([0-9])([+\-])/gm,'$1 $2'); // separate digits when no comma
1172 d = d.replace(/(\.[0-9]*)(\.)/gm,'$1 $2'); // separate digits when no comma
1173 d = d.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,'$1 $3 $4 '); // shorthand elliptical arc path syntax
1174 d = svg.compressSpaces(d); // compress multiple spaces
1175 d = svg.trim(d);
1176 this.PathParser = new (function(d) {
1177 this.tokens = d.split(' ');
1178
1179 this.reset = function() {
1180 this.i = -1;
1181 this.command = '';
1182 this.previousCommand = '';
1183 this.start = new svg.Point(0, 0);
1184 this.control = new svg.Point(0, 0);
1185 this.current = new svg.Point(0, 0);
1186 this.points = [];
1187 this.angles = [];
1188 }
1189
1190 this.isEnd = function() {
1191 return this.i >= this.tokens.length - 1;
1192 }
1193
1194 this.isCommandOrEnd = function() {
1195 if (this.isEnd()) return true;
1196 return this.tokens[this.i + 1].match(/^[A-Za-z]$/) != null;
1197 }
1198
1199 this.isRelativeCommand = function() {
1200 switch(this.command)
1201 {
1202 case 'm':
1203 case 'l':
1204 case 'h':
1205 case 'v':
1206 case 'c':
1207 case 's':
1208 case 'q':
1209 case 't':
1210 case 'a':
1211 case 'z':
1212 return true;
1213 break;
1214 }
1215 return false;
1216 }
1217
1218 this.getToken = function() {
1219 this.i++;
1220 return this.tokens[this.i];
1221 }
1222
1223 this.getScalar = function() {
1224 return parseFloat(this.getToken());
1225 }
1226
1227 this.nextCommand = function() {
1228 this.previousCommand = this.command;
1229 this.command = this.getToken();
1230 }
1231
1232 this.getPoint = function() {
1233 var p = new svg.Point(this.getScalar(), this.getScalar());
1234 return this.makeAbsolute(p);
1235 }
1236
1237 this.getAsControlPoint = function() {
1238 var p = this.getPoint();
1239 this.control = p;
1240 return p;
1241 }
1242
1243 this.getAsCurrentPoint = function() {
1244 var p = this.getPoint();
1245 this.current = p;
1246 return p;
1247 }
1248
1249 this.getReflectedControlPoint = function() {
1250 if (this.previousCommand.toLowerCase() != 'c' &&
1251 this.previousCommand.toLowerCase() != 's' &&
1252 this.previousCommand.toLowerCase() != 'q' &&
1253 this.previousCommand.toLowerCase() != 't' ){
1254 return this.current;
1255 }
1256
1257 // reflect point
1258 var p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y);
1259 return p;
1260 }
1261
1262 this.makeAbsolute = function(p) {
1263 if (this.isRelativeCommand()) {
1264 p.x += this.current.x;
1265 p.y += this.current.y;
1266 }
1267 return p;
1268 }
1269
1270 this.addMarker = function(p, from, priorTo) {
1271 // if the last angle isn't filled in because we didn't have this point yet ...
1272 if (priorTo != null && this.angles.length > 0 && this.angles[this.angles.length-1] == null) {
1273 this.angles[this.angles.length-1] = this.points[this.points.length-1].angleTo(priorTo);
1274 }
1275 this.addMarkerAngle(p, from == null ? null : from.angleTo(p));
1276 }
1277
1278 this.addMarkerAngle = function(p, a) {
1279 this.points.push(p);
1280 this.angles.push(a);
1281 }
1282
1283 this.getMarkerPoints = function() { return this.points; }
1284 this.getMarkerAngles = function() {
1285 for (var i=0; i<this.angles.length; i++) {
1286 if (this.angles[i] == null) {
1287 for (var j=i+1; j<this.angles.length; j++) {
1288 if (this.angles[j] != null) {
1289 this.angles[i] = this.angles[j];
1290 break;
1291 }
1292 }
1293 }
1294 }
1295 return this.angles;
1296 }
1297 })(d);
1298
1299 this.path = function(ctx) {
1300 var pp = this.PathParser;
1301 pp.reset();
1302
1303 var bb = new svg.BoundingBox();
1304 if (ctx != null) ctx.beginPath();
1305 while (!pp.isEnd()) {
1306 pp.nextCommand();
1307 switch (pp.command) {
1308 case 'M':
1309 case 'm':
1310 var p = pp.getAsCurrentPoint();
1311 pp.addMarker(p);
1312 bb.addPoint(p.x, p.y);
1313 if (ctx != null) ctx.moveTo(p.x, p.y);
1314 pp.start = pp.current;
1315 while (!pp.isCommandOrEnd()) {
1316 var p = pp.getAsCurrentPoint();
1317 pp.addMarker(p, pp.start);
1318 bb.addPoint(p.x, p.y);
1319 if (ctx != null) ctx.lineTo(p.x, p.y);
1320 }
1321 break;
1322 case 'L':
1323 case 'l':
1324 while (!pp.isCommandOrEnd()) {
1325 var c = pp.current;
1326 var p = pp.getAsCurrentPoint();
1327 pp.addMarker(p, c);
1328 bb.addPoint(p.x, p.y);
1329 if (ctx != null) ctx.lineTo(p.x, p.y);
1330 }
1331 break;
1332 case 'H':
1333 case 'h':
1334 while (!pp.isCommandOrEnd()) {
1335 var newP = new svg.Point((pp.isRelativeCommand() ? pp.current.x : 0) + pp.getScalar(), pp.current.y);
1336 pp.addMarker(newP, pp.current);
1337 pp.current = newP;
1338 bb.addPoint(pp.current.x, pp.current.y);
1339 if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y);
1340 }
1341 break;
1342 case 'V':
1343 case 'v':
1344 while (!pp.isCommandOrEnd()) {
1345 var newP = new svg.Point(pp.current.x, (pp.isRelativeCommand() ? pp.current.y : 0) + pp.getScalar());
1346 pp.addMarker(newP, pp.current);
1347 pp.current = newP;
1348 bb.addPoint(pp.current.x, pp.current.y);
1349 if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y);
1350 }
1351 break;
1352 case 'C':
1353 case 'c':
1354 while (!pp.isCommandOrEnd()) {
1355 var curr = pp.current;
1356 var p1 = pp.getPoint();
1357 var cntrl = pp.getAsControlPoint();
1358 var cp = pp.getAsCurrentPoint();
1359 pp.addMarker(cp, cntrl, p1);
1360 bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
1361 if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
1362 }
1363 break;
1364 case 'S':
1365 case 's':
1366 while (!pp.isCommandOrEnd()) {
1367 var curr = pp.current;
1368 var p1 = pp.getReflectedControlPoint();
1369 var cntrl = pp.getAsControlPoint();
1370 var cp = pp.getAsCurrentPoint();
1371 pp.addMarker(cp, cntrl, p1);
1372 bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
1373 if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
1374 }
1375 break;
1376 case 'Q':
1377 case 'q':
1378 while (!pp.isCommandOrEnd()) {
1379 var curr = pp.current;
1380 var cntrl = pp.getAsControlPoint();
1381 var cp = pp.getAsCurrentPoint();
1382 pp.addMarker(cp, cntrl, cntrl);
1383 bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);
1384 if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);
1385 }
1386 break;
1387 case 'T':
1388 case 't':
1389 while (!pp.isCommandOrEnd()) {
1390 var curr = pp.current;
1391 var cntrl = pp.getReflectedControlPoint();
1392 pp.control = cntrl;
1393 var cp = pp.getAsCurrentPoint();
1394 pp.addMarker(cp, cntrl, cntrl);
1395 bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);
1396 if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);
1397 }
1398 break;
1399 case 'A':
1400 case 'a':
1401 while (!pp.isCommandOrEnd()) {
1402 var curr = pp.current;
1403 var rx = pp.getScalar();
1404 var ry = pp.getScalar();
1405 var xAxisRotation = pp.getScalar() * (Math.PI / 180.0);
1406 var largeArcFlag = pp.getScalar();
1407 var sweepFlag = pp.getScalar();
1408 var cp = pp.getAsCurrentPoint();
1409
1410 // Conversion from endpoint to center parameterization
1411 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
1412 // x1', y1'
1413 var currp = new svg.Point(
1414 Math.cos(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.sin(xAxisRotation) * (curr.y - cp.y) / 2.0,
1415 -Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0
1416 );
1417 // adjust radii
1418 var l = Math.pow(currp.x,2)/Math.pow(rx,2)+Math.pow(currp.y,2)/Math.pow(ry,2);
1419 if (l > 1) {
1420 rx *= Math.sqrt(l);
1421 ry *= Math.sqrt(l);
1422 }
1423 // cx', cy'
1424 var s = (largeArcFlag == sweepFlag ? -1 : 1) * Math.sqrt(
1425 ((Math.pow(rx,2)*Math.pow(ry,2))-(Math.pow(rx,2)*Math.pow(currp.y,2))-(Math.pow(ry,2)*Math.pow(currp.x,2))) /
1426 (Math.pow(rx,2)*Math.pow(currp.y,2)+Math.pow(ry,2)*Math.pow(currp.x,2))
1427 );
1428 if (isNaN(s)) s = 0;
1429 var cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx);
1430 // cx, cy
1431 var centp = new svg.Point(
1432 (curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y,
1433 (curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y
1434 );
1435 // vector magnitude
1436 var m = function(v) { return Math.sqrt(Math.pow(v[0],2) + Math.pow(v[1],2)); }
1437 // ratio between two vectors
1438 var r = function(u, v) { return (u[0]*v[0]+u[1]*v[1]) / (m(u)*m(v)) }
1439 // angle between two vectors
1440 var a = function(u, v) { return (u[0]*v[1] < u[1]*v[0] ? -1 : 1) * Math.acos(r(u,v)); }
1441 // initial angle
1442 var a1 = a([1,0], [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]);
1443 // angle delta
1444 var u = [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry];
1445 var v = [(-currp.x-cpp.x)/rx,(-currp.y-cpp.y)/ry];
1446 var ad = a(u, v);
1447 if (r(u,v) <= -1) ad = Math.PI;
1448 if (r(u,v) >= 1) ad = 0;
1449
1450 // for markers
1451 var dir = 1 - sweepFlag ? 1.0 : -1.0;
1452 var ah = a1 + dir * (ad / 2.0);
1453 var halfWay = new svg.Point(
1454 centp.x + rx * Math.cos(ah),
1455 centp.y + ry * Math.sin(ah)
1456 );
1457 pp.addMarkerAngle(halfWay, ah - dir * Math.PI / 2);
1458 pp.addMarkerAngle(cp, ah - dir * Math.PI);
1459
1460 bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better
1461 if (ctx != null) {
1462 var r = rx > ry ? rx : ry;
1463 var sx = rx > ry ? 1 : rx / ry;
1464 var sy = rx > ry ? ry / rx : 1;
1465
1466 ctx.translate(centp.x, centp.y);
1467 ctx.rotate(xAxisRotation);
1468 ctx.scale(sx, sy);
1469 ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag);
1470 ctx.scale(1/sx, 1/sy);
1471 ctx.rotate(-xAxisRotation);
1472 ctx.translate(-centp.x, -centp.y);
1473 }
1474 }
1475 break;
1476 case 'Z':
1477 case 'z':
1478 if (ctx != null) ctx.closePath();
1479 pp.current = pp.start;
1480 }
1481 }
1482
1483 return bb;
1484 }
1485
1486 this.getMarkers = function() {
1487 var points = this.PathParser.getMarkerPoints();
1488 var angles = this.PathParser.getMarkerAngles();
1489
1490 var markers = [];
1491 for (var i=0; i<points.length; i++) {
1492 markers.push([points[i], angles[i]]);
1493 }
1494 return markers;
1495 }
1496 }
1497 svg.Element.path.prototype = new svg.Element.PathElementBase;
1498
1499 // pattern element
1500 svg.Element.pattern = function(node) {
1501 this.base = svg.Element.ElementBase;
1502 this.base(node);
1503
1504 this.createPattern = function(ctx, element) {
1505 var width = this.attribute('width').toPixels('x', true);
1506 var height = this.attribute('height').toPixels('y', true);
1507
1508 // render me using a temporary svg element
1509 var tempSvg = new svg.Element.svg();
1510 tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value);
1511 tempSvg.attributes['width'] = new svg.Property('width', width + 'px');
1512 tempSvg.attributes['height'] = new svg.Property('height', height + 'px');
1513 tempSvg.attributes['transform'] = new svg.Property('transform', this.attribute('patternTransform').value);
1514 tempSvg.children = this.children;
1515
1516 var c = document.createElement('canvas');
1517 c.width = width;
1518 c.height = height;
1519 var cctx = c.getContext('2d');
1520 if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) {
1521 cctx.translate(this.attribute('x').toPixels('x', true), this.attribute('y').toPixels('y', true));
1522 }
1523 // render 3x3 grid so when we transform there's no white space on edges
1524 for (var x=-1; x<=1; x++) {
1525 for (var y=-1; y<=1; y++) {
1526 cctx.save();
1527 cctx.translate(x * c.width, y * c.height);
1528 tempSvg.render(cctx);
1529 cctx.restore();
1530 }
1531 }
1532 var pattern = ctx.createPattern(c, 'repeat');
1533 return pattern;
1534 }
1535 }
1536 svg.Element.pattern.prototype = new svg.Element.ElementBase;
1537
1538 // marker element
1539 svg.Element.marker = function(node) {
1540 this.base = svg.Element.ElementBase;
1541 this.base(node);
1542
1543 this.baseRender = this.render;
1544 this.render = function(ctx, point, angle) {
1545 ctx.translate(point.x, point.y);
1546 if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(angle);
1547 if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(ctx.lineWidth, ctx.lineWidth);
1548 ctx.save();
1549
1550 // render me using a temporary svg element
1551 var tempSvg = new svg.Element.svg();
1552 tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value);
1553 tempSvg.attributes['refX'] = new svg.Property('refX', this.attribute('refX').value);
1554 tempSvg.attributes['refY'] = new svg.Property('refY', this.attribute('refY').value);
1555 tempSvg.attributes['width'] = new svg.Property('width', this.attribute('markerWidth').value);
1556 tempSvg.attributes['height'] = new svg.Property('height', this.attribute('markerHeight').value);
1557 tempSvg.attributes['fill'] = new svg.Property('fill', this.attribute('fill').valueOrDefault('black'));
1558 tempSvg.attributes['stroke'] = new svg.Property('stroke', this.attribute('stroke').valueOrDefault('none'));
1559 tempSvg.children = this.children;
1560 tempSvg.render(ctx);
1561
1562 ctx.restore();
1563 if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(1/ctx.lineWidth, 1/ctx.lineWidth);
1564 if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(-angle);
1565 ctx.translate(-point.x, -point.y);
1566 }
1567 }
1568 svg.Element.marker.prototype = new svg.Element.ElementBase;
1569
1570 // definitions element
1571 svg.Element.defs = function(node) {
1572 this.base = svg.Element.ElementBase;
1573 this.base(node);
1574
1575 this.render = function(ctx) {
1576 // NOOP
1577 }
1578 }
1579 svg.Element.defs.prototype = new svg.Element.ElementBase;
1580
1581 // base for gradients
1582 svg.Element.GradientBase = function(node) {
1583 this.base = svg.Element.ElementBase;
1584 this.base(node);
1585
1586 this.gradientUnits = this.attribute('gradientUnits').valueOrDefault('objectBoundingBox');
1587
1588 this.stops = [];
1589 for (var i=0; i<this.children.length; i++) {
1590 var child = this.children[i];
1591 if (child.type == 'stop') this.stops.push(child);
1592 }
1593
1594 this.getGradient = function() {
1595 // OVERRIDE ME!
1596 }
1597
1598 this.createGradient = function(ctx, element, parentOpacityProp) {
1599 var stopsContainer = this;
1600 if (this.getHrefAttribute().hasValue()) {
1601 stopsContainer = this.getHrefAttribute().getDefinition();
1602 }
1603
1604 var addParentOpacity = function (color) {
1605 if (parentOpacityProp.hasValue()) {
1606 var p = new svg.Property('color', color);
1607 return p.addOpacity(parentOpacityProp.value).value;
1608 }
1609 return color;
1610 };
1611
1612 var g = this.getGradient(ctx, element);
1613 if (g == null) return addParentOpacity(stopsContainer.stops[stopsContainer.stops.length - 1].color);
1614 for (var i=0; i<stopsContainer.stops.length; i++) {
1615 g.addColorStop(stopsContainer.stops[i].offset, addParentOpacity(stopsContainer.stops[i].color));
1616 }
1617
1618 if (this.attribute('gradientTransform').hasValue()) {
1619 // render as transformed pattern on temporary canvas
1620 var rootView = svg.ViewPort.viewPorts[0];
1621
1622 var rect = new svg.Element.rect();
1623 rect.attributes['x'] = new svg.Property('x', -svg.MAX_VIRTUAL_PIXELS/3.0);
1624 rect.attributes['y'] = new svg.Property('y', -svg.MAX_VIRTUAL_PIXELS/3.0);
1625 rect.attributes['width'] = new svg.Property('width', svg.MAX_VIRTUAL_PIXELS);
1626 rect.attributes['height'] = new svg.Property('height', svg.MAX_VIRTUAL_PIXELS);
1627
1628 var group = new svg.Element.g();
1629 group.attributes['transform'] = new svg.Property('transform', this.attribute('gradientTransform').value);
1630 group.children = [ rect ];
1631
1632 var tempSvg = new svg.Element.svg();
1633 tempSvg.attributes['x'] = new svg.Property('x', 0);
1634 tempSvg.attributes['y'] = new svg.Property('y', 0);
1635 tempSvg.attributes['width'] = new svg.Property('width', rootView.width);
1636 tempSvg.attributes['height'] = new svg.Property('height', rootView.height);
1637 tempSvg.children = [ group ];
1638
1639 var c = document.createElement('canvas');
1640 c.width = rootView.width;
1641 c.height = rootView.height;
1642 var tempCtx = c.getContext('2d');
1643 tempCtx.fillStyle = g;
1644 tempSvg.render(tempCtx);
1645 return tempCtx.createPattern(c, 'no-repeat');
1646 }
1647
1648 return g;
1649 }
1650 }
1651 svg.Element.GradientBase.prototype = new svg.Element.ElementBase;
1652
1653 // linear gradient element
1654 svg.Element.linearGradient = function(node) {
1655 this.base = svg.Element.GradientBase;
1656 this.base(node);
1657
1658 this.getGradient = function(ctx, element) {
1659 var bb = element.getBoundingBox();
1660
1661 if (!this.attribute('x1').hasValue()
1662 && !this.attribute('y1').hasValue()
1663 && !this.attribute('x2').hasValue()
1664 && !this.attribute('y2').hasValue()) {
1665 this.attribute('x1', true).value = 0;
1666 this.attribute('y1', true).value = 0;
1667 this.attribute('x2', true).value = 1;
1668 this.attribute('y2', true).value = 0;
1669 }
1670
1671 var x1 = (this.gradientUnits == 'objectBoundingBox'
1672 ? bb.x() + bb.width() * this.attribute('x1').numValue()
1673 : this.attribute('x1').toPixels('x'));
1674 var y1 = (this.gradientUnits == 'objectBoundingBox'
1675 ? bb.y() + bb.height() * this.attribute('y1').numValue()
1676 : this.attribute('y1').toPixels('y'));
1677 var x2 = (this.gradientUnits == 'objectBoundingBox'
1678 ? bb.x() + bb.width() * this.attribute('x2').numValue()
1679 : this.attribute('x2').toPixels('x'));
1680 var y2 = (this.gradientUnits == 'objectBoundingBox'
1681 ? bb.y() + bb.height() * this.attribute('y2').numValue()
1682 : this.attribute('y2').toPixels('y'));
1683
1684 if (x1 == x2 && y1 == y2) return null;
1685 return ctx.createLinearGradient(x1, y1, x2, y2);
1686 }
1687 }
1688 svg.Element.linearGradient.prototype = new svg.Element.GradientBase;
1689
1690 // radial gradient element
1691 svg.Element.radialGradient = function(node) {
1692 this.base = svg.Element.GradientBase;
1693 this.base(node);
1694
1695 this.getGradient = function(ctx, element) {
1696 var bb = element.getBoundingBox();
1697
1698 if (!this.attribute('cx').hasValue()) this.attribute('cx', true).value = '50%';
1699 if (!this.attribute('cy').hasValue()) this.attribute('cy', true).value = '50%';
1700 if (!this.attribute('r').hasValue()) this.attribute('r', true).value = '50%';
1701
1702 var cx = (this.gradientUnits == 'objectBoundingBox'
1703 ? bb.x() + bb.width() * this.attribute('cx').numValue()
1704 : this.attribute('cx').toPixels('x'));
1705 var cy = (this.gradientUnits == 'objectBoundingBox'
1706 ? bb.y() + bb.height() * this.attribute('cy').numValue()
1707 : this.attribute('cy').toPixels('y'));
1708
1709 var fx = cx;
1710 var fy = cy;
1711 if (this.attribute('fx').hasValue()) {
1712 fx = (this.gradientUnits == 'objectBoundingBox'
1713 ? bb.x() + bb.width() * this.attribute('fx').numValue()
1714 : this.attribute('fx').toPixels('x'));
1715 }
1716 if (this.attribute('fy').hasValue()) {
1717 fy = (this.gradientUnits == 'objectBoundingBox'
1718 ? bb.y() + bb.height() * this.attribute('fy').numValue()
1719 : this.attribute('fy').toPixels('y'));
1720 }
1721
1722 var r = (this.gradientUnits == 'objectBoundingBox'
1723 ? (bb.width() + bb.height()) / 2.0 * this.attribute('r').numValue()
1724 : this.attribute('r').toPixels());
1725
1726 return ctx.createRadialGradient(fx, fy, 0, cx, cy, r);
1727 }
1728 }
1729 svg.Element.radialGradient.prototype = new svg.Element.GradientBase;
1730
1731 // gradient stop element
1732 svg.Element.stop = function(node) {
1733 this.base = svg.Element.ElementBase;
1734 this.base(node);
1735
1736 this.offset = this.attribute('offset').numValue();
1737 if (this.offset < 0) this.offset = 0;
1738 if (this.offset > 1) this.offset = 1;
1739
1740 var stopColor = this.style('stop-color');
1741 if (this.style('stop-opacity').hasValue()) stopColor = stopColor.addOpacity(this.style('stop-opacity').value);
1742 this.color = stopColor.value;
1743 }
1744 svg.Element.stop.prototype = new svg.Element.ElementBase;
1745
1746 // animation base element
1747 svg.Element.AnimateBase = function(node) {
1748 this.base = svg.Element.ElementBase;
1749 this.base(node);
1750
1751 svg.Animations.push(this);
1752
1753 this.duration = 0.0;
1754 this.begin = this.attribute('begin').toMilliseconds();
1755 this.maxDuration = this.begin + this.attribute('dur').toMilliseconds();
1756
1757 this.getProperty = function() {
1758 var attributeType = this.attribute('attributeType').value;
1759 var attributeName = this.attribute('attributeName').value;
1760
1761 if (attributeType == 'CSS') {
1762 return this.parent.style(attributeName, true);
1763 }
1764 return this.parent.attribute(attributeName, true);
1765 };
1766
1767 this.initialValue = null;
1768 this.initialUnits = '';
1769 this.removed = false;
1770
1771 this.calcValue = function() {
1772 // OVERRIDE ME!
1773 return '';
1774 }
1775
1776 this.update = function(delta) {
1777 // set initial value
1778 if (this.initialValue == null) {
1779 this.initialValue = this.getProperty().value;
1780 this.initialUnits = this.getProperty().getUnits();
1781 }
1782
1783 // if we're past the end time
1784 if (this.duration > this.maxDuration) {
1785 // loop for indefinitely repeating animations
1786 if (this.attribute('repeatCount').value == 'indefinite'
1787 || this.attribute('repeatDur').value == 'indefinite') {
1788 this.duration = 0.0
1789 }
1790 else if (this.attribute('fill').valueOrDefault('remove') == 'remove' && !this.removed) {
1791 this.removed = true;
1792 this.getProperty().value = this.initialValue;
1793 return true;
1794 }
1795 else {
1796 return false; // no updates made
1797 }
1798 }
1799 this.duration = this.duration + delta;
1800
1801 // if we're past the begin time
1802 var updated = false;
1803 if (this.begin < this.duration) {
1804 var newValue = this.calcValue(); // tween
1805
1806 if (this.attribute('type').hasValue()) {
1807 // for transform, etc.
1808 var type = this.attribute('type').value;
1809 newValue = type + '(' + newValue + ')';
1810 }
1811
1812 this.getProperty().value = newValue;
1813 updated = true;
1814 }
1815
1816 return updated;
1817 }
1818
1819 this.from = this.attribute('from');
1820 this.to = this.attribute('to');
1821 this.values = this.attribute('values');
1822 if (this.values.hasValue()) this.values.value = this.values.value.split(';');
1823
1824 // fraction of duration we've covered
1825 this.progress = function() {
1826 var ret = { progress: (this.duration - this.begin) / (this.maxDuration - this.begin) };
1827 if (this.values.hasValue()) {
1828 var p = ret.progress * (this.values.value.length - 1);
1829 var lb = Math.floor(p), ub = Math.ceil(p);
1830 ret.from = new svg.Property('from', parseFloat(this.values.value[lb]));
1831 ret.to = new svg.Property('to', parseFloat(this.values.value[ub]));
1832 ret.progress = (p - lb) / (ub - lb);
1833 }
1834 else {
1835 ret.from = this.from;
1836 ret.to = this.to;
1837 }
1838 return ret;
1839 }
1840 }
1841 svg.Element.AnimateBase.prototype = new svg.Element.ElementBase;
1842
1843 // animate element
1844 svg.Element.animate = function(node) {
1845 this.base = svg.Element.AnimateBase;
1846 this.base(node);
1847
1848 this.calcValue = function() {
1849 var p = this.progress();
1850
1851 // tween value linearly
1852 var newValue = p.from.numValue() + (p.to.numValue() - p.from.numValue()) * p.progress;
1853 return newValue + this.initialUnits;
1854 };
1855 }
1856 svg.Element.animate.prototype = new svg.Element.AnimateBase;
1857
1858 // animate color element
1859 svg.Element.animateColor = function(node) {
1860 this.base = svg.Element.AnimateBase;
1861 this.base(node);
1862
1863 this.calcValue = function() {
1864 var p = this.progress();
1865 var from = new RGBColor(p.from.value);
1866 var to = new RGBColor(p.to.value);
1867
1868 if (from.ok && to.ok) {
1869 // tween color linearly
1870 var r = from.r + (to.r - from.r) * p.progress;
1871 var g = from.g + (to.g - from.g) * p.progress;
1872 var b = from.b + (to.b - from.b) * p.progress;
1873 return 'rgb('+parseInt(r,10)+','+parseInt(g,10)+','+parseInt(b,10)+')';
1874 }
1875 return this.attribute('from').value;
1876 };
1877 }
1878 svg.Element.animateColor.prototype = new svg.Element.AnimateBase;
1879
1880 // animate transform element
1881 svg.Element.animateTransform = function(node) {
1882 this.base = svg.Element.AnimateBase;
1883 this.base(node);
1884
1885 this.calcValue = function() {
1886 var p = this.progress();
1887
1888 // tween value linearly
1889 var from = svg.ToNumberArray(p.from.value);
1890 var to = svg.ToNumberArray(p.to.value);
1891 var newValue = '';
1892 for (var i=0; i<from.length; i++) {
1893 newValue += from[i] + (to[i] - from[i]) * p.progress + ' ';
1894 }
1895 return newValue;
1896 };
1897 }
1898 svg.Element.animateTransform.prototype = new svg.Element.animate;
1899
1900 // font element
1901 svg.Element.font = function(node) {
1902 this.base = svg.Element.ElementBase;
1903 this.base(node);
1904
1905 this.horizAdvX = this.attribute('horiz-adv-x').numValue();
1906
1907 this.isRTL = false;
1908 this.isArabic = false;
1909 this.fontFace = null;
1910 this.missingGlyph = null;
1911 this.glyphs = [];
1912 for (var i=0; i<this.children.length; i++) {
1913 var child = this.children[i];
1914 if (child.type == 'font-face') {
1915 this.fontFace = child;
1916 if (child.style('font-family').hasValue()) {
1917 svg.Definitions[child.style('font-family').value] = this;
1918 }
1919 }
1920 else if (child.type == 'missing-glyph') this.missingGlyph = child;
1921 else if (child.type == 'glyph') {
1922 if (child.arabicForm != '') {
1923 this.isRTL = true;
1924 this.isArabic = true;
1925 if (typeof(this.glyphs[child.unicode]) == 'undefined') this.glyphs[child.unicode] = [];
1926 this.glyphs[child.unicode][child.arabicForm] = child;
1927 }
1928 else {
1929 this.glyphs[child.unicode] = child;
1930 }
1931 }
1932 }
1933 }
1934 svg.Element.font.prototype = new svg.Element.ElementBase;
1935
1936 // font-face element
1937 svg.Element.fontface = function(node) {
1938 this.base = svg.Element.ElementBase;
1939 this.base(node);
1940
1941 this.ascent = this.attribute('ascent').value;
1942 this.descent = this.attribute('descent').value;
1943 this.unitsPerEm = this.attribute('units-per-em').numValue();
1944 }
1945 svg.Element.fontface.prototype = new svg.Element.ElementBase;
1946
1947 // missing-glyph element
1948 svg.Element.missingglyph = function(node) {
1949 this.base = svg.Element.path;
1950 this.base(node);
1951
1952 this.horizAdvX = 0;
1953 }
1954 svg.Element.missingglyph.prototype = new svg.Element.path;
1955
1956 // glyph element
1957 svg.Element.glyph = function(node) {
1958 this.base = svg.Element.path;
1959 this.base(node);
1960
1961 this.horizAdvX = this.attribute('horiz-adv-x').numValue();
1962 this.unicode = this.attribute('unicode').value;
1963 this.arabicForm = this.attribute('arabic-form').value;
1964 }
1965 svg.Element.glyph.prototype = new svg.Element.path;
1966
1967 // text element
1968 svg.Element.text = function(node) {
1969 this.captureTextNodes = true;
1970 this.base = svg.Element.RenderedElementBase;
1971 this.base(node);
1972
1973 this.baseSetContext = this.setContext;
1974 this.setContext = function(ctx) {
1975 this.baseSetContext(ctx);
1976 if (this.style('dominant-baseline').hasValue()) ctx.textBaseline = this.style('dominant-baseline').value;
1977 if (this.style('alignment-baseline').hasValue()) ctx.textBaseline = this.style('alignment-baseline').value;
1978 }
1979
1980 this.getBoundingBox = function () {
1981 // TODO: implement
1982 return new svg.BoundingBox(this.attribute('x').toPixels('x'), this.attribute('y').toPixels('y'), 0, 0);
1983 }
1984
1985 this.renderChildren = function(ctx) {
1986 this.x = this.attribute('x').toPixels('x');
1987 this.y = this.attribute('y').toPixels('y');
1988 this.x += this.getAnchorDelta(ctx, this, 0);
1989 for (var i=0; i<this.children.length; i++) {
1990 this.renderChild(ctx, this, i);
1991 }
1992 }
1993
1994 this.getAnchorDelta = function (ctx, parent, startI) {
1995 var textAnchor = this.style('text-anchor').valueOrDefault('start');
1996 if (textAnchor != 'start') {
1997 var width = 0;
1998 for (var i=startI; i<parent.children.length; i++) {
1999 var child = parent.children[i];
2000 if (i > startI && child.attribute('x').hasValue()) break; // new group
2001 width += child.measureTextRecursive(ctx);
2002 }
2003 return -1 * (textAnchor == 'end' ? width : width / 2.0);
2004 }
2005 return 0;
2006 }
2007
2008 this.renderChild = function(ctx, parent, i) {
2009 var child = parent.children[i];
2010 if (child.attribute('x').hasValue()) {
2011 child.x = child.attribute('x').toPixels('x') + this.getAnchorDelta(ctx, parent, i);
2012 }
2013 else {
2014 if (this.attribute('dx').hasValue()) this.x += this.attribute('dx').toPixels('x');
2015 if (child.attribute('dx').hasValue()) this.x += child.attribute('dx').toPixels('x');
2016 child.x = this.x;
2017 }
2018 this.x = child.x + child.measureText(ctx);
2019
2020 if (child.attribute('y').hasValue()) {
2021 child.y = child.attribute('y').toPixels('y');
2022 }
2023 else {
2024 if (this.attribute('dy').hasValue()) this.y += this.attribute('dy').toPixels('y');
2025 if (child.attribute('dy').hasValue()) this.y += child.attribute('dy').toPixels('y');
2026 child.y = this.y;
2027 }
2028 this.y = child.y;
2029
2030 child.render(ctx);
2031
2032 for (var i=0; i<child.children.length; i++) {
2033 this.renderChild(ctx, child, i);
2034 }
2035 }
2036 }
2037 svg.Element.text.prototype = new svg.Element.RenderedElementBase;
2038
2039 // text base
2040 svg.Element.TextElementBase = function(node) {
2041 this.base = svg.Element.RenderedElementBase;
2042 this.base(node);
2043
2044 this.getGlyph = function(font, text, i) {
2045 var c = text[i];
2046 var glyph = null;
2047 if (font.isArabic) {
2048 var arabicForm = 'isolated';
2049 if ((i==0 || text[i-1]==' ') && i<text.length-2 && text[i+1]!=' ') arabicForm = 'terminal';
2050 if (i>0 && text[i-1]!=' ' && i<text.length-2 && text[i+1]!=' ') arabicForm = 'medial';
2051 if (i>0 && text[i-1]!=' ' && (i == text.length-1 || text[i+1]==' ')) arabicForm = 'initial';
2052 if (typeof(font.glyphs[c]) != 'undefined') {
2053 glyph = font.glyphs[c][arabicForm];
2054 if (glyph == null && font.glyphs[c].type == 'glyph') glyph = font.glyphs[c];
2055 }
2056 }
2057 else {
2058 glyph = font.glyphs[c];
2059 }
2060 if (glyph == null) glyph = font.missingGlyph;
2061 return glyph;
2062 }
2063
2064 this.renderChildren = function(ctx) {
2065 var customFont = this.parent.style('font-family').getDefinition();
2066 if (customFont != null) {
2067 var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
2068 var fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle);
2069 var text = this.getText();
2070 if (customFont.isRTL) text = text.split("").reverse().join("");
2071
2072 var dx = svg.ToNumberArray(this.parent.attribute('dx').value);
2073 for (var i=0; i<text.length; i++) {
2074 var glyph = this.getGlyph(customFont, text, i);
2075 var scale = fontSize / customFont.fontFace.unitsPerEm;
2076 ctx.translate(this.x, this.y);
2077 ctx.scale(scale, -scale);
2078 var lw = ctx.lineWidth;
2079 ctx.lineWidth = ctx.lineWidth * customFont.fontFace.unitsPerEm / fontSize;
2080 if (fontStyle == 'italic') ctx.transform(1, 0, .4, 1, 0, 0);
2081 glyph.render(ctx);
2082 if (fontStyle == 'italic') ctx.transform(1, 0, -.4, 1, 0, 0);
2083 ctx.lineWidth = lw;
2084 ctx.scale(1/scale, -1/scale);
2085 ctx.translate(-this.x, -this.y);
2086
2087 this.x += fontSize * (glyph.horizAdvX || customFont.horizAdvX) / customFont.fontFace.unitsPerEm;
2088 if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) {
2089 this.x += dx[i];
2090 }
2091 }
2092 return;
2093 }
2094
2095 if (ctx.fillStyle != '') ctx.fillText(svg.compressSpaces(this.getText()), this.x, this.y);
2096 if (ctx.strokeStyle != '') ctx.strokeText(svg.compressSpaces(this.getText()), this.x, this.y);
2097 }
2098
2099 this.getText = function() {
2100 // OVERRIDE ME
2101 }
2102
2103 this.measureTextRecursive = function(ctx) {
2104 var width = this.measureText(ctx);
2105 for (var i=0; i<this.children.length; i++) {
2106 width += this.children[i].measureTextRecursive(ctx);
2107 }
2108 return width;
2109 }
2110
2111 this.measureText = function(ctx) {
2112 var customFont = this.parent.style('font-family').getDefinition();
2113 if (customFont != null) {
2114 var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
2115 var measure = 0;
2116 var text = this.getText();
2117 if (customFont.isRTL) text = text.split("").reverse().join("");
2118 var dx = svg.ToNumberArray(this.parent.attribute('dx').value);
2119 for (var i=0; i<text.length; i++) {
2120 var glyph = this.getGlyph(customFont, text, i);
2121 measure += (glyph.horizAdvX || customFont.horizAdvX) * fontSize / customFont.fontFace.unitsPerEm;
2122 if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) {
2123 measure += dx[i];
2124 }
2125 }
2126 return measure;
2127 }
2128
2129 var textToMeasure = svg.compressSpaces(this.getText());
2130 if (!ctx.measureText) return textToMeasure.length * 10;
2131
2132 ctx.save();
2133 this.setContext(ctx);
2134 var width = ctx.measureText(textToMeasure).width;
2135 ctx.restore();
2136 return width;
2137 }
2138 }
2139 svg.Element.TextElementBase.prototype = new svg.Element.RenderedElementBase;
2140
2141 // tspan
2142 svg.Element.tspan = function(node) {
2143 this.captureTextNodes = true;
2144 this.base = svg.Element.TextElementBase;
2145 this.base(node);
2146
2147 this.text = node.nodeValue || node.text || '';
2148 this.getText = function() {
2149 return this.text;
2150 }
2151 }
2152 svg.Element.tspan.prototype = new svg.Element.TextElementBase;
2153
2154 // tref
2155 svg.Element.tref = function(node) {
2156 this.base = svg.Element.TextElementBase;
2157 this.base(node);
2158
2159 this.getText = function() {
2160 var element = this.getHrefAttribute().getDefinition();
2161 if (element != null) return element.children[0].getText();
2162 }
2163 }
2164 svg.Element.tref.prototype = new svg.Element.TextElementBase;
2165
2166 // a element
2167 svg.Element.a = function(node) {
2168 this.base = svg.Element.TextElementBase;
2169 this.base(node);
2170
2171 this.hasText = true;
2172 for (var i=0; i<node.childNodes.length; i++) {
2173 if (node.childNodes[i].nodeType != 3) this.hasText = false;
2174 }
2175
2176 // this might contain text
2177 this.text = this.hasText ? node.childNodes[0].nodeValue : '';
2178 this.getText = function() {
2179 return this.text;
2180 }
2181
2182 this.baseRenderChildren = this.renderChildren;
2183 this.renderChildren = function(ctx) {
2184 if (this.hasText) {
2185 // render as text element
2186 this.baseRenderChildren(ctx);
2187 var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);
2188 svg.Mouse.checkBoundingBox(this, new svg.BoundingBox(this.x, this.y - fontSize.toPixels('y'), this.x + this.measureText(ctx), this.y));
2189 }
2190 else {
2191 // render as temporary group
2192 var g = new svg.Element.g();
2193 g.children = this.children;
2194 g.parent = this;
2195 g.render(ctx);
2196 }
2197 }
2198
2199 this.onclick = function() {
2200 window.open(this.getHrefAttribute().value);
2201 }
2202
2203 this.onmousemove = function() {
2204 svg.ctx.canvas.style.cursor = 'pointer';
2205 }
2206 }
2207 svg.Element.a.prototype = new svg.Element.TextElementBase;
2208
2209 // image element
2210 svg.Element.image = function(node) {
2211 this.base = svg.Element.RenderedElementBase;
2212 this.base(node);
2213
2214 var href = this.getHrefAttribute().value;
2215 var isSvg = href.match(/\.svg$/)
2216
2217 svg.Images.push(this);
2218 this.loaded = false;
2219 if (!isSvg) {
2220 this.img = document.createElement('img');
2221 var self = this;
2222 this.img.onload = function() { self.loaded = true; }
2223 this.img.onerror = function() { if (typeof(console) != 'undefined') { console.log('ERROR: image "' + href + '" not found'); self.loaded = true; } }
2224 this.img.src = href;
2225 }
2226 else {
2227 this.img = svg.ajax(href);
2228 this.loaded = true;
2229 }
2230
2231 this.renderChildren = function(ctx) {
2232 var x = this.attribute('x').toPixels('x');
2233 var y = this.attribute('y').toPixels('y');
2234
2235 var width = this.attribute('width').toPixels('x');
2236 var height = this.attribute('height').toPixels('y');
2237 if (width == 0 || height == 0) return;
2238
2239 ctx.save();
2240 if (isSvg) {
2241 ctx.drawSvg(this.img, x, y, width, height);
2242 }
2243 else {
2244 ctx.translate(x, y);
2245 svg.AspectRatio(ctx,
2246 this.attribute('preserveAspectRatio').value,
2247 width,
2248 this.img.width,
2249 height,
2250 this.img.height,
2251 0,
2252 0);
2253 ctx.drawImage(this.img, 0, 0);
2254 }
2255 ctx.restore();
2256 }
2257
2258 this.getBoundingBox = function() {
2259 var x = this.attribute('x').toPixels('x');
2260 var y = this.attribute('y').toPixels('y');
2261 var width = this.attribute('width').toPixels('x');
2262 var height = this.attribute('height').toPixels('y');
2263 return new svg.BoundingBox(x, y, x + width, y + height);
2264 }
2265 }
2266 svg.Element.image.prototype = new svg.Element.RenderedElementBase;
2267
2268 // group element
2269 svg.Element.g = function(node) {
2270 this.base = svg.Element.RenderedElementBase;
2271 this.base(node);
2272
2273 this.getBoundingBox = function() {
2274 var bb = new svg.BoundingBox();
2275 for (var i=0; i<this.children.length; i++) {
2276 bb.addBoundingBox(this.children[i].getBoundingBox());
2277 }
2278 return bb;
2279 };
2280 }
2281 svg.Element.g.prototype = new svg.Element.RenderedElementBase;
2282
2283 // symbol element
2284 svg.Element.symbol = function(node) {
2285 this.base = svg.Element.RenderedElementBase;
2286 this.base(node);
2287
2288 this.baseSetContext = this.setContext;
2289 this.setContext = function(ctx) {
2290 this.baseSetContext(ctx);
2291
2292 // viewbox
2293 if (this.attribute('viewBox').hasValue()) {
2294 var viewBox = svg.ToNumberArray(this.attribute('viewBox').value);
2295 var minX = viewBox[0];
2296 var minY = viewBox[1];
2297 width = viewBox[2];
2298 height = viewBox[3];
2299
2300 svg.AspectRatio(ctx,
2301 this.attribute('preserveAspectRatio').value,
2302 this.attribute('width').toPixels('x'),
2303 width,
2304 this.attribute('height').toPixels('y'),
2305 height,
2306 minX,
2307 minY);
2308
2309 svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]);
2310 }
2311 }
2312 }
2313 svg.Element.symbol.prototype = new svg.Element.RenderedElementBase;
2314
2315 // style element
2316 svg.Element.style = function(node) {
2317 this.base = svg.Element.ElementBase;
2318 this.base(node);
2319
2320 // text, or spaces then CDATA
2321 var css = ''
2322 for (var i=0; i<node.childNodes.length; i++) {
2323 css += node.childNodes[i].nodeValue;
2324 }
2325 css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
2326 css = svg.compressSpaces(css); // replace whitespace
2327 var cssDefs = css.split('}');
2328 for (var i=0; i<cssDefs.length; i++) {
2329 if (svg.trim(cssDefs[i]) != '') {
2330 var cssDef = cssDefs[i].split('{');
2331 var cssClasses = cssDef[0].split(',');
2332 var cssProps = cssDef[1].split(';');
2333 for (var j=0; j<cssClasses.length; j++) {
2334 var cssClass = svg.trim(cssClasses[j]);
2335 if (cssClass != '') {
2336 var props = {};
2337 for (var k=0; k<cssProps.length; k++) {
2338 var prop = cssProps[k].indexOf(':');
2339 var name = cssProps[k].substr(0, prop);
2340 var value = cssProps[k].substr(prop + 1, cssProps[k].length - prop);
2341 if (name != null && value != null) {
2342 props[svg.trim(name)] = new svg.Property(svg.trim(name), svg.trim(value));
2343 }
2344 }
2345 svg.Styles[cssClass] = props;
2346 if (cssClass == '@font-face') {
2347 var fontFamily = props['font-family'].value.replace(/"/g,'');
2348 var srcs = props['src'].value.split(',');
2349 for (var s=0; s<srcs.length; s++) {
2350 if (srcs[s].indexOf('format("svg")') > 0) {
2351 var urlStart = srcs[s].indexOf('url');
2352 var urlEnd = srcs[s].indexOf(')', urlStart);
2353 var url = srcs[s].substr(urlStart + 5, urlEnd - urlStart - 6);
2354 var doc = svg.parseXml(svg.ajax(url));
2355 var fonts = doc.getElementsByTagName('font');
2356 for (var f=0; f<fonts.length; f++) {
2357 var font = svg.CreateElement(fonts[f]);
2358 svg.Definitions[fontFamily] = font;
2359 }
2360 }
2361 }
2362 }
2363 }
2364 }
2365 }
2366 }
2367 }
2368 svg.Element.style.prototype = new svg.Element.ElementBase;
2369
2370 // use element
2371 svg.Element.use = function(node) {
2372 this.base = svg.Element.RenderedElementBase;
2373 this.base(node);
2374
2375 this.baseSetContext = this.setContext;
2376 this.setContext = function(ctx) {
2377 this.baseSetContext(ctx);
2378 if (this.attribute('x').hasValue()) ctx.translate(this.attribute('x').toPixels('x'), 0);
2379 if (this.attribute('y').hasValue()) ctx.translate(0, this.attribute('y').toPixels('y'));
2380 }
2381
2382 this.getDefinition = function() {
2383 var element = this.getHrefAttribute().getDefinition();
2384 if (this.attribute('width').hasValue()) element.attribute('width', true).value = this.attribute('width').value;
2385 if (this.attribute('height').hasValue()) element.attribute('height', true).value = this.attribute('height').value;
2386 return element;
2387 }
2388
2389 this.path = function(ctx) {
2390 var element = this.getDefinition();
2391 if (element != null) element.path(ctx);
2392 }
2393
2394 this.getBoundingBox = function() {
2395 var element = this.getDefinition();
2396 if (element != null) return element.getBoundingBox();
2397 }
2398
2399 this.renderChildren = function(ctx) {
2400 var element = this.getDefinition();
2401 if (element != null) {
2402 // temporarily detach from parent and render
2403 var oldParent = element.parent;
2404 element.parent = null;
2405 element.render(ctx);
2406 element.parent = oldParent;
2407 }
2408 }
2409 }
2410 svg.Element.use.prototype = new svg.Element.RenderedElementBase;
2411
2412 // mask element
2413 svg.Element.mask = function(node) {
2414 this.base = svg.Element.ElementBase;
2415 this.base(node);
2416
2417 this.apply = function(ctx, element) {
2418 // render as temp svg
2419 var x = this.attribute('x').toPixels('x');
2420 var y = this.attribute('y').toPixels('y');
2421 var width = this.attribute('width').toPixels('x');
2422 var height = this.attribute('height').toPixels('y');
2423
2424 if (width == 0 && height == 0) {
2425 var bb = new svg.BoundingBox();
2426 for (var i=0; i<this.children.length; i++) {
2427 bb.addBoundingBox(this.children[i].getBoundingBox());
2428 }
2429 var x = Math.floor(bb.x1);
2430 var y = Math.floor(bb.y1);
2431 var width = Math.floor(bb.width());
2432 var height = Math.floor(bb.height());
2433 }
2434
2435 // temporarily remove mask to avoid recursion
2436 var mask = element.attribute('mask').value;
2437 element.attribute('mask').value = '';
2438
2439 var cMask = document.createElement('canvas');
2440 cMask.width = x + width;
2441 cMask.height = y + height;
2442 var maskCtx = cMask.getContext('2d');
2443 this.renderChildren(maskCtx);
2444
2445 var c = document.createElement('canvas');
2446 c.width = x + width;
2447 c.height = y + height;
2448 var tempCtx = c.getContext('2d');
2449 element.render(tempCtx);
2450 tempCtx.globalCompositeOperation = 'destination-in';
2451 tempCtx.fillStyle = maskCtx.createPattern(cMask, 'no-repeat');
2452 tempCtx.fillRect(0, 0, x + width, y + height);
2453
2454 ctx.fillStyle = tempCtx.createPattern(c, 'no-repeat');
2455 ctx.fillRect(0, 0, x + width, y + height);
2456
2457 // reassign mask
2458 element.attribute('mask').value = mask;
2459 }
2460
2461 this.render = function(ctx) {
2462 // NO RENDER
2463 }
2464 }
2465 svg.Element.mask.prototype = new svg.Element.ElementBase;
2466
2467 // clip element
2468 svg.Element.clipPath = function(node) {
2469 this.base = svg.Element.ElementBase;
2470 this.base(node);
2471
2472 this.apply = function(ctx) {
2473 for (var i=0; i<this.children.length; i++) {
2474 var child = this.children[i];
2475 if (typeof(child.path) != 'undefined') {
2476 var transform = null;
2477 if (child.attribute('transform').hasValue()) {
2478 transform = new svg.Transform(child.attribute('transform').value);
2479 transform.apply(ctx);
2480 }
2481 child.path(ctx);
2482 ctx.clip();
2483 if (transform) { transform.unapply(ctx); }
2484 }
2485 }
2486 }
2487
2488 this.render = function(ctx) {
2489 // NO RENDER
2490 }
2491 }
2492 svg.Element.clipPath.prototype = new svg.Element.ElementBase;
2493
2494 // filters
2495 svg.Element.filter = function(node) {
2496 this.base = svg.Element.ElementBase;
2497 this.base(node);
2498
2499 this.apply = function(ctx, element) {
2500 // render as temp svg
2501 var bb = element.getBoundingBox();
2502 var x = Math.floor(bb.x1);
2503 var y = Math.floor(bb.y1);
2504 var width = Math.floor(bb.width());
2505 var height = Math.floor(bb.height());
2506
2507 // temporarily remove filter to avoid recursion
2508 var filter = element.style('filter').value;
2509 element.style('filter').value = '';
2510
2511 var px = 0, py = 0;
2512 for (var i=0; i<this.children.length; i++) {
2513 var efd = this.children[i].extraFilterDistance || 0;
2514 px = Math.max(px, efd);
2515 py = Math.max(py, efd);
2516 }
2517
2518 var c = document.createElement('canvas');
2519 c.width = width + 2*px;
2520 c.height = height + 2*py;
2521 var tempCtx = c.getContext('2d');
2522 tempCtx.translate(-x + px, -y + py);
2523 element.render(tempCtx);
2524
2525 // apply filters
2526 for (var i=0; i<this.children.length; i++) {
2527 this.children[i].apply(tempCtx, 0, 0, width + 2*px, height + 2*py);
2528 }
2529
2530 // render on me
2531 ctx.drawImage(c, 0, 0, width + 2*px, height + 2*py, x - px, y - py, width + 2*px, height + 2*py);
2532
2533 // reassign filter
2534 element.style('filter', true).value = filter;
2535 }
2536
2537 this.render = function(ctx) {
2538 // NO RENDER
2539 }
2540 }
2541 svg.Element.filter.prototype = new svg.Element.ElementBase;
2542
2543 svg.Element.feMorphology = function(node) {
2544 this.base = svg.Element.ElementBase;
2545 this.base(node);
2546
2547 this.apply = function(ctx, x, y, width, height) {
2548 // TODO: implement
2549 }
2550 }
2551 svg.Element.feMorphology.prototype = new svg.Element.ElementBase;
2552
2553 svg.Element.feColorMatrix = function(node) {
2554 this.base = svg.Element.ElementBase;
2555 this.base(node);
2556
2557 function imGet(img, x, y, width, height, rgba) {
2558 return img[y*width*4 + x*4 + rgba];
2559 }
2560
2561 function imSet(img, x, y, width, height, rgba, val) {
2562 img[y*width*4 + x*4 + rgba] = val;
2563 }
2564
2565 this.apply = function(ctx, x, y, width, height) {
2566 // only supporting grayscale for now per Issue 195, need to extend to all matrix
2567 // assuming x==0 && y==0 for now
2568 var srcData = ctx.getImageData(0, 0, width, height);
2569 for (var y = 0; y < height; y++) {
2570 for (var x = 0; x < width; x++) {
2571 var r = imGet(srcData.data, x, y, width, height, 0);
2572 var g = imGet(srcData.data, x, y, width, height, 1);
2573 var b = imGet(srcData.data, x, y, width, height, 2);
2574 var gray = (r + g + b) / 3;
2575 imSet(srcData.data, x, y, width, height, 0, gray);
2576 imSet(srcData.data, x, y, width, height, 1, gray);
2577 imSet(srcData.data, x, y, width, height, 2, gray);
2578 }
2579 }
2580 ctx.clearRect(0, 0, width, height);
2581 ctx.putImageData(srcData, 0, 0);
2582 }
2583 }
2584 svg.Element.feColorMatrix.prototype = new svg.Element.ElementBase;
2585
2586 svg.Element.feGaussianBlur = function(node) {
2587 this.base = svg.Element.ElementBase;
2588 this.base(node);
2589
2590 this.blurRadius = Math.floor(this.attribute('stdDeviation').numValue());
2591 this.extraFilterDistance = this.blurRadius;
2592
2593 this.apply = function(ctx, x, y, width, height) {
2594 if (typeof(stackBlurCanvasRGBA) == 'undefined') {
2595 if (typeof(console) != 'undefined') { console.log('ERROR: StackBlur.js must be included for blur to work'); }
2596 return;
2597 }
2598
2599 // StackBlur requires canvas be on document
2600 ctx.canvas.id = svg.UniqueId();
2601 ctx.canvas.style.display = 'none';
2602 document.body.appendChild(ctx.canvas);
2603 stackBlurCanvasRGBA(ctx.canvas.id, x, y, width, height, this.blurRadius);
2604 document.body.removeChild(ctx.canvas);
2605 }
2606 }
2607 svg.Element.feGaussianBlur.prototype = new svg.Element.ElementBase;
2608
2609 // title element, do nothing
2610 svg.Element.title = function(node) {
2611 }
2612 svg.Element.title.prototype = new svg.Element.ElementBase;
2613
2614 // desc element, do nothing
2615 svg.Element.desc = function(node) {
2616 }
2617 svg.Element.desc.prototype = new svg.Element.ElementBase;
2618
2619 svg.Element.MISSING = function(node) {
2620 if (typeof(console) != 'undefined') { console.log('ERROR: Element \'' + node.nodeName + '\' not yet implemented.'); }
2621 }
2622 svg.Element.MISSING.prototype = new svg.Element.ElementBase;
2623
2624 // element factory
2625 svg.CreateElement = function(node) {
2626 var className = node.nodeName.replace(/^[^:]+:/,''); // remove namespace
2627 className = className.replace(/\-/g,''); // remove dashes
2628 var e = null;
2629 if (typeof(svg.Element[className]) != 'undefined') {
2630 e = new svg.Element[className](node);
2631 }
2632 else {
2633 e = new svg.Element.MISSING(node);
2634 }
2635
2636 e.type = node.nodeName;
2637 return e;
2638 }
2639
2640 // load from url
2641 svg.load = function(ctx, url) {
2642 svg.loadXml(ctx, svg.ajax(url));
2643 }
2644
2645 // load from xml
2646 svg.loadXml = function(ctx, xml) {
2647 svg.loadXmlDoc(ctx, svg.parseXml(xml));
2648 }
2649
2650 svg.loadXmlDoc = function(ctx, dom) {
2651 svg.init(ctx);
2652
2653 var mapXY = function(p) {
2654 var e = ctx.canvas;
2655 while (e) {
2656 p.x -= e.offsetLeft;
2657 p.y -= e.offsetTop;
2658 e = e.offsetParent;
2659 }
2660 if (window.scrollX) p.x += window.scrollX;
2661 if (window.scrollY) p.y += window.scrollY;
2662 return p;
2663 }
2664
2665 // bind mouse
2666 if (svg.opts['ignoreMouse'] != true) {
2667 ctx.canvas.onclick = function(e) {
2668 var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY));
2669 svg.Mouse.onclick(p.x, p.y);
2670 };
2671 ctx.canvas.onmousemove = function(e) {
2672 var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY));
2673 svg.Mouse.onmousemove(p.x, p.y);
2674 };
2675 }
2676
2677 var e = svg.CreateElement(dom.documentElement);
2678 e.root = true;
2679
2680 // render loop
2681 var isFirstRender = true;
2682 var draw = function() {
2683 svg.ViewPort.Clear();
2684 if (ctx.canvas.parentNode) svg.ViewPort.SetCurrent(ctx.canvas.parentNode.clientWidth, ctx.canvas.parentNode.clientHeight);
2685
2686 if (svg.opts['ignoreDimensions'] != true) {
2687 // set canvas size
2688 if (e.style('width').hasValue()) {
2689 ctx.canvas.width = e.style('width').toPixels('x');
2690 ctx.canvas.style.width = ctx.canvas.width + 'px';
2691 }
2692 if (e.style('height').hasValue()) {
2693 ctx.canvas.height = e.style('height').toPixels('y');
2694 ctx.canvas.style.height = ctx.canvas.height + 'px';
2695 }
2696 }
2697 var cWidth = ctx.canvas.clientWidth || ctx.canvas.width;
2698 var cHeight = ctx.canvas.clientHeight || ctx.canvas.height;
2699 if (svg.opts['ignoreDimensions'] == true && e.style('width').hasValue() && e.style('height').hasValue()) {
2700 cWidth = e.style('width').toPixels('x');
2701 cHeight = e.style('height').toPixels('y');
2702 }
2703 svg.ViewPort.SetCurrent(cWidth, cHeight);
2704
2705 if (svg.opts['offsetX'] != null) e.attribute('x', true).value = svg.opts['offsetX'];
2706 if (svg.opts['offsetY'] != null) e.attribute('y', true).value = svg.opts['offsetY'];
2707 if (svg.opts['scaleWidth'] != null && svg.opts['scaleHeight'] != null) {
2708 var xRatio = 1, yRatio = 1, viewBox = svg.ToNumberArray(e.attribute('viewBox').value);
2709 if (e.attribute('width').hasValue()) xRatio = e.attribute('width').toPixels('x') / svg.opts['scaleWidth'];
2710 else if (!isNaN(viewBox[2])) xRatio = viewBox[2] / svg.opts['scaleWidth'];
2711 if (e.attribute('height').hasValue()) yRatio = e.attribute('height').toPixels('y') / svg.opts['scaleHeight'];
2712 else if (!isNaN(viewBox[3])) yRatio = viewBox[3] / svg.opts['scaleHeight'];
2713
2714 e.attribute('width', true).value = svg.opts['scaleWidth'];
2715 e.attribute('height', true).value = svg.opts['scaleHeight'];
2716 e.attribute('viewBox', true).value = '0 0 ' + (cWidth * xRatio) + ' ' + (cHeight * yRatio);
2717 e.attribute('preserveAspectRatio', true).value = 'none';
2718 }
2719
2720 // clear and render
2721 if (svg.opts['ignoreClear'] != true) {
2722 ctx.clearRect(0, 0, cWidth, cHeight);
2723 }
2724 e.render(ctx);
2725 if (isFirstRender) {
2726 isFirstRender = false;
2727 if (typeof(svg.opts['renderCallback']) == 'function') svg.opts['renderCallback'](dom);
2728 }
2729 }
2730
2731 var waitingForImages = true;
2732 if (svg.ImagesLoaded()) {
2733 waitingForImages = false;
2734 draw();
2735 }
2736 svg.intervalID = setInterval(function() {
2737 var needUpdate = false;
2738
2739 if (waitingForImages && svg.ImagesLoaded()) {
2740 waitingForImages = false;
2741 needUpdate = true;
2742 }
2743
2744 // need update from mouse events?
2745 if (svg.opts['ignoreMouse'] != true) {
2746 needUpdate = needUpdate | svg.Mouse.hasEvents();
2747 }
2748
2749 // need update from animations?
2750 if (svg.opts['ignoreAnimation'] != true) {
2751 for (var i=0; i<svg.Animations.length; i++) {
2752 needUpdate = needUpdate | svg.Animations[i].update(1000 / svg.FRAMERATE);
2753 }
2754 }
2755
2756 // need update from redraw?
2757 if (typeof(svg.opts['forceRedraw']) == 'function') {
2758 if (svg.opts['forceRedraw']() == true) needUpdate = true;
2759 }
2760
2761 // render if needed
2762 if (needUpdate) {
2763 draw();
2764 svg.Mouse.runEvents(); // run and clear our events
2765 }
2766 }, 1000 / svg.FRAMERATE);
2767 }
2768
2769 svg.stop = function() {
2770 if (svg.intervalID) {
2771 clearInterval(svg.intervalID);
2772 }
2773 }
2774
2775 svg.Mouse = new (function() {
2776 this.events = [];
2777 this.hasEvents = function() { return this.events.length != 0; }
2778
2779 this.onclick = function(x, y) {
2780 this.events.push({ type: 'onclick', x: x, y: y,
2781 run: function(e) { if (e.onclick) e.onclick(); }
2782 });
2783 }
2784
2785 this.onmousemove = function(x, y) {
2786 this.events.push({ type: 'onmousemove', x: x, y: y,
2787 run: function(e) { if (e.onmousemove) e.onmousemove(); }
2788 });
2789 }
2790
2791 this.eventElements = [];
2792
2793 this.checkPath = function(element, ctx) {
2794 for (var i=0; i<this.events.length; i++) {
2795 var e = this.events[i];
2796 if (ctx.isPointInPath && ctx.isPointInPath(e.x, e.y)) this.eventElements[i] = element;
2797 }
2798 }
2799
2800 this.checkBoundingBox = function(element, bb) {
2801 for (var i=0; i<this.events.length; i++) {
2802 var e = this.events[i];
2803 if (bb.isPointInBox(e.x, e.y)) this.eventElements[i] = element;
2804 }
2805 }
2806
2807 this.runEvents = function() {
2808 svg.ctx.canvas.style.cursor = '';
2809
2810 for (var i=0; i<this.events.length; i++) {
2811 var e = this.events[i];
2812 var element = this.eventElements[i];
2813 while (element) {
2814 e.run(element);
2815 element = element.parent;
2816 }
2817 }
2818
2819 // done running, clear
2820 this.events = [];
2821 this.eventElements = [];
2822 }
2823 });
2824
2825 return svg;
2826 }
2827 })();
2828
2829 if (typeof(CanvasRenderingContext2D) != 'undefined') {
2830 CanvasRenderingContext2D.prototype.drawSvg = function(s, dx, dy, dw, dh) {
2831 canvg(this.canvas, s, {
2832 ignoreMouse: true,
2833 ignoreAnimation: true,
2834 ignoreDimensions: true,
2835 ignoreClear: true,
2836 offsetX: dx,
2837 offsetY: dy,
2838 scaleWidth: dw,
2839 scaleHeight: dh
2840 });
2841 }
2842 }
amcharts/exporting/filesaver.js
File was created 1 /* FileSaver.js
2 * A saveAs() FileSaver implementation.
3 * 2013-10-21
4 *
5 * By Eli Grey, http://eligrey.com
6 * License: X11/MIT
7 * See LICENSE.md
8 */
9
10 /*global self */
11 /*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
12 plusplus: true */
13
14 /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
15 if(AmCharts.isModern){ /// added by AmCharts to avoid old IE problems if this file is included
16 var saveAs = saveAs
17 || (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
18 || (function(view) {
19 "use strict";
20 var
21 doc = view.document
22 // only get URL when necessary in case BlobBuilder.js hasn't overridden it yet
23 , get_URL = function() {
24 return view.URL || view.webkitURL || view;
25 }
26 , URL = view.URL || view.webkitURL || view
27 , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
28 , can_use_save_link = !view.externalHost && "download" in save_link
29 , click = function(node) {
30 var event = doc.createEvent("MouseEvents");
31 event.initMouseEvent(
32 "click", true, false, view, 0, 0, 0, 0, 0
33 , false, false, false, false, 0, null
34 );
35 node.dispatchEvent(event);
36 }
37 , webkit_req_fs = view.webkitRequestFileSystem
38 , req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
39 , throw_outside = function (ex) {
40 (view.setImmediate || view.setTimeout)(function() {
41 throw ex;
42 }, 0);
43 }
44 , force_saveable_type = "application/octet-stream"
45 , fs_min_size = 0
46 , deletion_queue = []
47 , process_deletion_queue = function() {
48 var i = deletion_queue.length;
49 while (i--) {
50 var file = deletion_queue[i];
51 if (typeof file === "string") { // file is an object URL
52 URL.revokeObjectURL(file);
53 } else { // file is a File
54 file.remove();
55 }
56 }
57 deletion_queue.length = 0; // clear queue
58 }
59 , dispatch = function(filesaver, event_types, event) {
60 event_types = [].concat(event_types);
61 var i = event_types.length;
62 while (i--) {
63 var listener = filesaver["on" + event_types[i]];
64 if (typeof listener === "function") {
65 try {
66 listener.call(filesaver, event || filesaver);
67 } catch (ex) {
68 throw_outside(ex);
69 }
70 }
71 }
72 }
73 , FileSaver = function(blob, name) {
74 // First try a.download, then web filesystem, then object URLs
75 var
76 filesaver = this
77 , type = blob.type
78 , blob_changed = false
79 , object_url
80 , target_view
81 , get_object_url = function() {
82 var object_url = get_URL().createObjectURL(blob);
83 deletion_queue.push(object_url);
84 return object_url;
85 }
86 , dispatch_all = function() {
87 dispatch(filesaver, "writestart progress write writeend".split(" "));
88 }
89 // on any filesys errors revert to saving with object URLs
90 , fs_error = function() {
91 // don't create more object URLs than needed
92 if (blob_changed || !object_url) {
93 object_url = get_object_url(blob);
94 }
95 if (target_view) {
96 target_view.location.href = object_url;
97 } else {
98 window.open(object_url, "_blank");
99 }
100 filesaver.readyState = filesaver.DONE;
101 dispatch_all();
102 }
103 , abortable = function(func) {
104 return function() {
105 if (filesaver.readyState !== filesaver.DONE) {
106 return func.apply(this, arguments);
107 }
108 };
109 }
110 , create_if_not_found = {create: true, exclusive: false}
111 , slice
112 ;
113 filesaver.readyState = filesaver.INIT;
114 if (!name) {
115 name = "download";
116 }
117 if (can_use_save_link) {
118 object_url = get_object_url(blob);
119 // FF for Android has a nasty garbage collection mechanism
120 // that turns all objects that are not pure javascript into 'deadObject'
121 // this means `doc` and `save_link` are unusable and need to be recreated
122 // `view` is usable though:
123 doc = view.document;
124 save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
125 save_link.href = object_url;
126 save_link.download = name;
127 var event = doc.createEvent("MouseEvents");
128 event.initMouseEvent(
129 "click", true, false, view, 0, 0, 0, 0, 0
130 , false, false, false, false, 0, null
131 );
132 save_link.dispatchEvent(event);
133 filesaver.readyState = filesaver.DONE;
134 dispatch_all();
135 return;
136 }
137 // Object and web filesystem URLs have a problem saving in Google Chrome when
138 // viewed in a tab, so I force save with application/octet-stream
139 // http://code.google.com/p/chromium/issues/detail?id=91158
140 if (view.chrome && type && type !== force_saveable_type) {
141 slice = blob.slice || blob.webkitSlice;
142 blob = slice.call(blob, 0, blob.size, force_saveable_type);
143 blob_changed = true;
144 }
145 // Since I can't be sure that the guessed media type will trigger a download
146 // in WebKit, I append .download to the filename.
147 // https://bugs.webkit.org/show_bug.cgi?id=65440
148 if (webkit_req_fs && name !== "download") {
149 name += ".download";
150 }
151 if (type === force_saveable_type || webkit_req_fs) {
152 target_view = view;
153 }
154 if (!req_fs) {
155 fs_error();
156 return;
157 }
158 fs_min_size += blob.size;
159 req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
160 fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
161 var save = function() {
162 dir.getFile(name, create_if_not_found, abortable(function(file) {
163 file.createWriter(abortable(function(writer) {
164 writer.onwriteend = function(event) {
165 target_view.location.href = file.toURL();
166 deletion_queue.push(file);
167 filesaver.readyState = filesaver.DONE;
168 dispatch(filesaver, "writeend", event);
169 };
170 writer.onerror = function() {
171 var error = writer.error;
172 if (error.code !== error.ABORT_ERR) {
173 fs_error();
174 }
175 };
176 "writestart progress write abort".split(" ").forEach(function(event) {
177 writer["on" + event] = filesaver["on" + event];
178 });
179 writer.write(blob);
180 filesaver.abort = function() {
181 writer.abort();
182 filesaver.readyState = filesaver.DONE;
183 };
184 filesaver.readyState = filesaver.WRITING;
185 }), fs_error);
186 }), fs_error);
187 };
188 dir.getFile(name, {create: false}, abortable(function(file) {
189 // delete file if it already exists
190 file.remove();
191 save();
192 }), abortable(function(ex) {
193 if (ex.code === ex.NOT_FOUND_ERR) {
194 save();
195 } else {
196 fs_error();
197 }
198 }));
199 }), fs_error);
200 }), fs_error);
201 }
202 , FS_proto = FileSaver.prototype
203 , saveAs = function(blob, name) {
204 return new FileSaver(blob, name);
205 }
206 ;
207 FS_proto.abort = function() {
208 var filesaver = this;
209 filesaver.readyState = filesaver.DONE;
210 dispatch(filesaver, "abort");
211 };
212 FS_proto.readyState = FS_proto.INIT = 0;
213 FS_proto.WRITING = 1;
214 FS_proto.DONE = 2;
215
216 FS_proto.error =
217 FS_proto.onwritestart =
218 FS_proto.onprogress =
219 FS_proto.onwrite =
220 FS_proto.onabort =
221 FS_proto.onerror =
222 FS_proto.onwriteend =
223 null;
224
225 view.addEventListener("unload", process_deletion_queue, false);
226 return saveAs;
227 }(this.self || this.window || this.content));
228 // `self` is undefined in Firefox for Android content script context
229 // while `this` is nsIContentFrameMessageManager
230 // with an attribute `content` that corresponds to the window
231
232 if (typeof module !== 'undefined') module.exports = saveAs;
233 }/// added by AmCharts to avoid old IE problems if this file is included
amcharts/exporting/jspdf.js
File was created 1 /** @preserve jsPDF 0.9.0rc2 ( ${buildDate} ${commitID} )
2 Copyright (c) 2010-2012 James Hall, james@snapshotmedia.co.uk, https://github.com/MrRio/jsPDF
3 Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
4 MIT license.
5 */
6
7 /*
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * ====================================================================
27 */
28
29
30 /**
31 Creates new jsPDF document object instance
32 @class
33 @param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
34 @param unit Measurement unit to be used when coordinates are specified. One of "pt" (points), "mm" (Default), "cm", "in"
35 @param format One of 'a0', 'a1', 'a2', 'a3', 'a4' (Default) etc to 'a10', 'b0' to 'b10', 'c0' to 'c10', 'letter', 'government-letter', 'legal', 'junior-legal', 'ledger' or 'tabloid'
36 @returns {jsPDF}
37 @name jsPDF
38 */
39 var jsPDF = (function () {
40 'use strict';
41 /*jslint browser:true, plusplus: true, bitwise: true, nomen: true */
42 /*global document: false, btoa, atob, zpipe, Uint8Array, ArrayBuffer, Blob, saveAs, adler32cs, Deflater */
43
44 // this will run on <=IE9, possibly some niche browsers
45 // new webkit-based, FireFox, IE10 already have native version of this.
46 if (typeof btoa === 'undefined') {
47 window.btoa = function (data) {
48 // DO NOT ADD UTF8 ENCODING CODE HERE!!!!
49
50 // UTF8 encoding encodes bytes over char code 128
51 // and, essentially, turns an 8-bit binary streams
52 // (that base64 can deal with) into 7-bit binary streams.
53 // (by default server does not know that and does not recode the data back to 8bit)
54 // You destroy your data.
55
56 // binary streams like jpeg image data etc, while stored in JavaScript strings,
57 // (which are 16bit arrays) are in 8bit format already.
58 // You do NOT need to char-encode that before base64 encoding.
59
60 // if you, by act of fate
61 // have string which has individual characters with code
62 // above 255 (pure unicode chars), encode that BEFORE you base64 here.
63 // you can use absolutely any approch there, as long as in the end,
64 // base64 gets an 8bit (char codes 0 - 255) stream.
65 // when you get it on the server after un-base64, you must
66 // UNencode it too, to get back to 16, 32bit or whatever original bin stream.
67
68 // Note, Yes, JavaScript strings are, in most cases UCS-2 -
69 // 16-bit character arrays. This does not mean, however,
70 // that you always have to UTF8 it before base64.
71 // it means that if you have actual characters anywhere in
72 // that string that have char code above 255, you need to
73 // recode *entire* string from 16-bit (or 32bit) to 8-bit array.
74 // You can do binary split to UTF16 (BE or LE)
75 // you can do utf8, you can split the thing by hand and prepend BOM to it,
76 // but whatever you do, make sure you mirror the opposite on
77 // the server. If server does not expect to post-process un-base64
78 // 8-bit binary stream, think very very hard about messing around with encoding.
79
80 // so, long story short:
81 // DO NOT ADD UTF8 ENCODING CODE HERE!!!!
82
83 /* @preserve
84 ====================================================================
85 base64 encoder
86 MIT, GPL
87
88 version: 1109.2015
89 discuss at: http://phpjs.org/functions/base64_encode
90 + original by: Tyler Akins (http://rumkin.com)
91 + improved by: Bayron Guevara
92 + improved by: Thunder.m
93 + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
94 + bugfixed by: Pellentesque Malesuada
95 + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
96 + improved by: Rafal Kukawski (http://kukawski.pl)
97 + Daniel Dotsenko, Willow Systems Corp, willow-systems.com
98 ====================================================================
99 */
100
101 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
102 b64a = b64.split(''),
103 o1,
104 o2,
105 o3,
106 h1,
107 h2,
108 h3,
109 h4,
110 bits,
111 i = 0,
112 ac = 0,
113 enc = "",
114 tmp_arr = [],
115 r;
116
117 do { // pack three octets into four hexets
118 o1 = data.charCodeAt(i++);
119 o2 = data.charCodeAt(i++);
120 o3 = data.charCodeAt(i++);
121
122 bits = o1 << 16 | o2 << 8 | o3;
123
124 h1 = bits >> 18 & 0x3f;
125 h2 = bits >> 12 & 0x3f;
126 h3 = bits >> 6 & 0x3f;
127 h4 = bits & 0x3f;
128
129 // use hexets to index into b64, and append result to encoded string
130 tmp_arr[ac++] = b64a[h1] + b64a[h2] + b64a[h3] + b64a[h4];
131 } while (i < data.length);
132
133 enc = tmp_arr.join('');
134 r = data.length % 3;
135 return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
136 // end of base64 encoder MIT, GPL
137 };
138 }
139
140 if (typeof atob === 'undefined') {
141 window.atob = function (data) {
142 // http://kevin.vanzonneveld.net
143 // + original by: Tyler Akins (http://rumkin.com)
144 // + improved by: Thunder.m
145 // + input by: Aman Gupta
146 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
147 // + bugfixed by: Onno Marsman
148 // + bugfixed by: Pellentesque Malesuada
149 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
150 // + input by: Brett Zamir (http://brett-zamir.me)
151 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
152 // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
153 // * returns 1: 'Kevin van Zonneveld'
154 // mozilla has this native
155 // - but breaks in 2.0.0.12!
156 //if (typeof this.window['atob'] == 'function') {
157 // return atob(data);
158 //}
159 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
160 o1,
161 o2,
162 o3,
163 h1,
164 h2,
165 h3,
166 h4,
167 bits,
168 i = 0,
169 ac = 0,
170 dec = "",
171 tmp_arr = [];
172
173 if (!data) {
174 return data;
175 }
176
177 data += '';
178
179 do { // unpack four hexets into three octets using index points in b64
180 h1 = b64.indexOf(data.charAt(i++));
181 h2 = b64.indexOf(data.charAt(i++));
182 h3 = b64.indexOf(data.charAt(i++));
183 h4 = b64.indexOf(data.charAt(i++));
184
185 bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
186
187 o1 = bits >> 16 & 0xff;
188 o2 = bits >> 8 & 0xff;
189 o3 = bits & 0xff;
190
191 if (h3 === 64) {
192 tmp_arr[ac++] = String.fromCharCode(o1);
193 } else if (h4 === 64) {
194 tmp_arr[ac++] = String.fromCharCode(o1, o2);
195 } else {
196 tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
197 }
198 } while (i < data.length);
199 dec = tmp_arr.join('');
200 return dec;
201 };
202 }
203
204 var getObjectLength = typeof Object.keys === 'function' ?
205 function (object) {
206 return Object.keys(object).length;
207 } :
208 function (object) {
209 var i = 0, e;
210 for (e in object) {
211 if (object.hasOwnProperty(e)) {
212 i++;
213 }
214 }
215 return i;
216 },
217
218 /**
219 PubSub implementation
220
221 @class
222 @name PubSub
223 */
224 PubSub = function (context) {
225 /** @preserve
226 -----------------------------------------------------------------------------------------------
227 JavaScript PubSub library
228 2012 (c) ddotsenko@willowsystems.com
229 based on Peter Higgins (dante@dojotoolkit.org)
230 Loosely based on Dojo publish/subscribe API, limited in scope. Rewritten blindly.
231 Original is (c) Dojo Foundation 2004-2010. Released under either AFL or new BSD, see:
232 http://dojofoundation.org/license for more information.
233 -----------------------------------------------------------------------------------------------
234 */
235 /**
236 @private
237 @fieldOf PubSub
238 */
239 this.topics = {};
240 /**
241 Stores what will be `this` within the callback functions.
242
243 @private
244 @fieldOf PubSub#
245 */
246 this.context = context;
247 /**
248 Allows caller to emit an event and pass arguments to event listeners.
249 @public
250 @function
251 @param topic {String} Name of the channel on which to voice this event
252 @param args Any number of arguments you want to pass to the listeners of this event.
253 @methodOf PubSub#
254 @name publish
255 */
256 this.publish = function (topic, args) {
257 if (this.topics[topic]) {
258 var currentTopic = this.topics[topic],
259 toremove = [],
260 fn,
261 i,
262 l,
263 pair,
264 emptyFunc = function () {};
265 args = Array.prototype.slice.call(arguments, 1);
266 for (i = 0, l = currentTopic.length; i < l; i++) {
267 pair = currentTopic[i]; // this is a [function, once_flag] array
268 fn = pair[0];
269 if (pair[1]) { /* 'run once' flag set */
270 pair[0] = emptyFunc;
271 toremove.push(i);
272 }
273 fn.apply(this.context, args);
274 }
275 for (i = 0, l = toremove.length; i < l; i++) {
276 currentTopic.splice(toremove[i], 1);
277 }
278 }
279 };
280 /**
281 Allows listener code to subscribe to channel and be called when data is available
282 @public
283 @function
284 @param topic {String} Name of the channel on which to voice this event
285 @param callback {Function} Executable (function pointer) that will be ran when event is voiced on this channel.
286 @param once {Boolean} (optional. False by default) Flag indicating if the function is to be triggered only once.
287 @returns {Object} A token object that cen be used for unsubscribing.
288 @methodOf PubSub#
289 @name subscribe
290 */
291 this.subscribe = function (topic, callback, once) {
292 if (!this.topics[topic]) {
293 this.topics[topic] = [[callback, once]];
294 } else {
295 this.topics[topic].push([callback, once]);
296 }
297 return {
298 "topic": topic,
299 "callback": callback
300 };
301 };
302 /**
303 Allows listener code to unsubscribe from a channel
304 @public
305 @function
306 @param token {Object} A token object that was returned by `subscribe` method
307 @methodOf PubSub#
308 @name unsubscribe
309 */
310 this.unsubscribe = function (token) {
311 if (this.topics[token.topic]) {
312 var currentTopic = this.topics[token.topic], i, l;
313
314 for (i = 0, l = currentTopic.length; i < l; i++) {
315 if (currentTopic[i][0] === token.callback) {
316 currentTopic.splice(i, 1);
317 }
318 }
319 }
320 };
321 };
322
323
324 /**
325 @constructor
326 @private
327 */
328 function jsPDF(orientation, unit, format, compressPdf) { /** String orientation, String unit, String format, Boolean compressed */
329
330 // Default parameter values
331 if (typeof orientation === 'undefined') {
332 orientation = 'p';
333 } else {
334 orientation = orientation.toString().toLowerCase();
335 }
336 if (typeof unit === 'undefined') { unit = 'mm'; }
337 if (typeof format === 'undefined') { format = 'a4'; }
338 if (typeof compressPdf === 'undefined' && typeof zpipe === 'undefined') { compressPdf = false; }
339
340 var format_as_string = format.toString().toLowerCase(),
341 version = '0.9.0rc2',
342 content = [],
343 content_length = 0,
344 compress = compressPdf,
345 pdfVersion = '1.3', // PDF Version
346 pageFormats = { // Size in pt of various paper formats
347 'a0': [2383.94, 3370.39],
348 'a1': [1683.78, 2383.94],
349 'a2': [1190.55, 1683.78],
350 'a3': [841.89, 1190.55],
351 'a4': [595.28, 841.89],
352 'a5': [419.53, 595.28],
353 'a6': [297.64, 419.53],
354 'a7': [209.76, 297.64],
355 'a8': [147.4 , 209.76],
356 'a9': [104.88, 147.4],
357 'a10': [73.7, 104.88],
358 'b0': [2834.65, 4008.19],
359 'b1': [2004.09, 2834.65],
360 'b2': [1417.32, 2004.09],
361 'b3': [1000.63, 1417.32],
362 'b4': [708.66, 1000.63],
363 'b5': [498.9, 708.66],
364 'b6': [354.33, 498.9],
365 'b7': [249.45, 354.33],
366 'b8': [175.75, 249.45],
367 'b9': [124.72, 175.75],
368 'b10': [87.87, 124.72],
369 'c0': [2599.37, 3676.54],
370 'c1': [1836.85, 2599.37],
371 'c2': [1298.27, 1836.85],
372 'c3': [918.43, 1298.27],
373 'c4': [649.13, 918.43],
374 'c5': [459.21, 649.13],
375 'c6': [323.15, 459.21],
376 'c7': [229.61, 323.15],
377 'c8': [161.57, 229.61],
378 'c9': [113.39, 161.57],
379 'c10': [79.37, 113.39],
380 'letter': [612, 792],
381 'government-letter': [576, 756],
382 'legal': [612, 1008],
383 'junior-legal': [576, 360],
384 'ledger': [1224, 792],
385 'tabloid': [792, 1224]
386 },
387 textColor = '0 g',
388 drawColor = '0 G',
389 page = 0,
390 pages = [],
391 objectNumber = 2, // 'n' Current object number
392 outToPages = false, // switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content
393 offsets = [], // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.
394 fonts = {}, // collection of font objects, where key is fontKey - a dynamically created label for a given font.
395 fontmap = {}, // mapping structure fontName > fontStyle > font key - performance layer. See addFont()
396 activeFontSize = 16,
397 activeFontKey, // will be string representing the KEY of the font as combination of fontName + fontStyle
398 lineWidth = 0.200025, // 2mm
399 lineHeightProportion = 1.15,
400 pageHeight,
401 pageWidth,
402 k, // Scale factor
403 documentProperties = {'title': '', 'subject': '', 'author': '', 'keywords': '', 'creator': ''},
404 lineCapID = 0,
405 lineJoinID = 0,
406 API = {},
407 events = new PubSub(API),
408 tmp,
409 plugin,
410 /////////////////////
411 // Private functions
412 /////////////////////
413 // simplified (speedier) replacement for sprintf's %.2f conversion
414 f2 = function (number) {
415 return number.toFixed(2);
416 },
417 // simplified (speedier) replacement for sprintf's %.3f conversion
418 f3 = function (number) {
419 return number.toFixed(3);
420 },
421 // simplified (speedier) replacement for sprintf's %02d
422 padd2 = function (number) {
423 var n = (number).toFixed(0);
424 if (number < 10) {
425 return '0' + n;
426 } else {
427 return n;
428 }
429 },
430 // simplified (speedier) replacement for sprintf's %02d
431 padd10 = function (number) {
432 var n = (number).toFixed(0);
433 if (n.length < 10) {
434 return new Array( 11 - n.length ).join('0') + n;
435 } else {
436 return n;
437 }
438 },
439 out = function (string) {
440 if (outToPages) { /* set by beginPage */
441 pages[page].push(string);
442 } else {
443 content.push(string);
444 content_length += string.length + 1; // +1 is for '\n' that will be used to join contents of content
445 }
446 },
447 newObject = function () {
448 // Begin a new object
449 objectNumber++;
450 offsets[objectNumber] = content_length;
451 out(objectNumber + ' 0 obj');
452 return objectNumber;
453 },
454 putStream = function (str) {
455 out('stream');
456 out(str);
457 out('endstream');
458 },
459 wPt,
460 hPt,
461 kids,
462 i,
463 putPages = function () {
464 wPt = pageWidth * k;
465 hPt = pageHeight * k;
466
467 // outToPages = false as set in endDocument(). out() writes to content.
468
469 var n, p, arr, uint, i, deflater, adler32;
470 for (n = 1; n <= page; n++) {
471 newObject();
472 out('<</Type /Page');
473 out('/Parent 1 0 R');
474 out('/Resources 2 0 R');
475 out('/Contents ' + (objectNumber + 1) + ' 0 R>>');
476 out('endobj');
477
478 // Page content
479 p = pages[n].join('\n');
480 newObject();
481 if (compress) {
482 arr = [];
483 for (i = 0; i < p.length; ++i) {
484 arr[i] = p.charCodeAt(i);
485 }
486 adler32 = adler32cs.from(p);
487 deflater = new Deflater(6);
488 deflater.append(new Uint8Array(arr));
489 p = deflater.flush();
490 arr = [new Uint8Array([120, 156]), new Uint8Array(p),
491 new Uint8Array([adler32 & 0xFF, (adler32 >> 8) & 0xFF, (adler32 >> 16) & 0xFF, (adler32 >> 24) & 0xFF])];
492 p = '';
493 for (i in arr) {
494 if (arr.hasOwnProperty(i)) {
495 p += String.fromCharCode.apply(null, arr[i]);
496 }
497 }
498 out('<</Length ' + p.length + ' /Filter [/FlateDecode]>>');
499 } else {
500 out('<</Length ' + p.length + '>>');
501 }
502 putStream(p);
503 out('endobj');
504 }
505 offsets[1] = content_length;
506 out('1 0 obj');
507 out('<</Type /Pages');
508 kids = '/Kids [';
509 for (i = 0; i < page; i++) {
510 kids += (3 + 2 * i) + ' 0 R ';
511 }
512 out(kids + ']');
513 out('/Count ' + page);
514 out('/MediaBox [0 0 ' + f2(wPt) + ' ' + f2(hPt) + ']');
515 out('>>');
516 out('endobj');
517 },
518 putFont = function (font) {
519 font.objectNumber = newObject();
520 out('<</BaseFont/' + font.PostScriptName + '/Type/Font');
521 if (typeof font.encoding === 'string') {
522 out('/Encoding/' + font.encoding);
523 }
524 out('/Subtype/Type1>>');
525 out('endobj');
526 },
527 putFonts = function () {
528 var fontKey;
529 for (fontKey in fonts) {
530 if (fonts.hasOwnProperty(fontKey)) {
531 putFont(fonts[fontKey]);
532 }
533 }
534 },
535 putXobjectDict = function () {
536 // Loop through images, or other data objects
537 events.publish('putXobjectDict');
538 },
539 putResourceDictionary = function () {
540 out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
541 out('/Font <<');
542 // Do this for each font, the '1' bit is the index of the font
543 var fontKey;
544 for (fontKey in fonts) {
545 if (fonts.hasOwnProperty(fontKey)) {
546 out('/' + fontKey + ' ' + fonts[fontKey].objectNumber + ' 0 R');
547 }
548 }
549 out('>>');
550 out('/XObject <<');
551 putXobjectDict();
552 out('>>');
553 },
554 putResources = function () {
555 putFonts();
556 events.publish('putResources');
557 // Resource dictionary
558 offsets[2] = content_length;
559 out('2 0 obj');
560 out('<<');
561 putResourceDictionary();
562 out('>>');
563 out('endobj');
564 events.publish('postPutResources');
565 },
566 addToFontDictionary = function (fontKey, fontName, fontStyle) {
567 // this is mapping structure for quick font key lookup.
568 // returns the KEY of the font (ex: "F1") for a given pair of font name and type (ex: "Arial". "Italic")
569 var undef;
570 if (fontmap[fontName] === undef) {
571 fontmap[fontName] = {}; // fontStyle is a var interpreted and converted to appropriate string. don't wrap in quotes.
572 }
573 fontmap[fontName][fontStyle] = fontKey;
574 },
575 /**
576 FontObject describes a particular font as member of an instnace of jsPDF
577
578 It's a collection of properties like 'id' (to be used in PDF stream),
579 'fontName' (font's family name), 'fontStyle' (font's style variant label)
580
581 @class
582 @public
583 @property id {String} PDF-document-instance-specific label assinged to the font.
584 @property PostScriptName {String} PDF specification full name for the font
585 @property encoding {Object} Encoding_name-to-Font_metrics_object mapping.
586 @name FontObject
587 */
588 FontObject = {},
589 addFont = function (PostScriptName, fontName, fontStyle, encoding) {
590 var fontKey = 'F' + (getObjectLength(fonts) + 1).toString(10),
591 // This is FontObject
592 font = fonts[fontKey] = {
593 'id': fontKey,
594 // , 'objectNumber': will be set by putFont()
595 'PostScriptName': PostScriptName,
596 'fontName': fontName,
597 'fontStyle': fontStyle,
598 'encoding': encoding,
599 'metadata': {}
600 };
601
602 addToFontDictionary(fontKey, fontName, fontStyle);
603
604 events.publish('addFont', font);
605
606 return fontKey;
607 },
608 addFonts = function () {
609
610 var HELVETICA = "helvetica",
611 TIMES = "times",
612 COURIER = "courier",
613 NORMAL = "normal",
614 BOLD = "bold",
615 ITALIC = "italic",
616 BOLD_ITALIC = "bolditalic",
617 encoding = 'StandardEncoding',
618 standardFonts = [
619 ['Helvetica', HELVETICA, NORMAL],
620 ['Helvetica-Bold', HELVETICA, BOLD],
621 ['Helvetica-Oblique', HELVETICA, ITALIC],
622 ['Helvetica-BoldOblique', HELVETICA, BOLD_ITALIC],
623 ['Courier', COURIER, NORMAL],
624 ['Courier-Bold', COURIER, BOLD],
625 ['Courier-Oblique', COURIER, ITALIC],
626 ['Courier-BoldOblique', COURIER, BOLD_ITALIC],
627 ['Times-Roman', TIMES, NORMAL],
628 ['Times-Bold', TIMES, BOLD],
629 ['Times-Italic', TIMES, ITALIC],
630 ['Times-BoldItalic', TIMES, BOLD_ITALIC]
631 ],
632 i,
633 l,
634 fontKey,
635 parts;
636 for (i = 0, l = standardFonts.length; i < l; i++) {
637 fontKey = addFont(
638 standardFonts[i][0],
639 standardFonts[i][1],
640 standardFonts[i][2],
641 encoding
642 );
643
644 // adding aliases for standard fonts, this time matching the capitalization
645 parts = standardFonts[i][0].split('-');
646 addToFontDictionary(fontKey, parts[0], parts[1] || '');
647 }
648
649 events.publish('addFonts', {'fonts': fonts, 'dictionary': fontmap});
650 },
651 /**
652
653 @public
654 @function
655 @param text {String}
656 @param flags {Object} Encoding flags.
657 @returns {String} Encoded string
658 */
659 to8bitStream = function (text, flags) {
660 /* PDF 1.3 spec:
661 "For text strings encoded in Unicode, the first two bytes must be 254 followed by
662 255, representing the Unicode byte order marker, U+FEFF. (This sequence conflicts
663 with the PDFDocEncoding character sequence thorn ydieresis, which is unlikely
664 to be a meaningful beginning of a word or phrase.) The remainder of the
665 string consists of Unicode character codes, according to the UTF-16 encoding
666 specified in the Unicode standard, version 2.0. Commonly used Unicode values
667 are represented as 2 bytes per character, with the high-order byte appearing first
668 in the string."
669
670 In other words, if there are chars in a string with char code above 255, we
671 recode the string to UCS2 BE - string doubles in length and BOM is prepended.
672
673 HOWEVER!
674 Actual *content* (body) text (as opposed to strings used in document properties etc)
675 does NOT expect BOM. There, it is treated as a literal GID (Glyph ID)
676
677 Because of Adobe's focus on "you subset your fonts!" you are not supposed to have
678 a font that maps directly Unicode (UCS2 / UTF16BE) code to font GID, but you could
679 fudge it with "Identity-H" encoding and custom CIDtoGID map that mimics Unicode
680 code page. There, however, all characters in the stream are treated as GIDs,
681 including BOM, which is the reason we need to skip BOM in content text (i.e. that
682 that is tied to a font).
683
684 To signal this "special" PDFEscape / to8bitStream handling mode,
685 API.text() function sets (unless you overwrite it with manual values
686 given to API.text(.., flags) )
687 flags.autoencode = true
688 flags.noBOM = true
689
690 */
691
692 /*
693 `flags` properties relied upon:
694 .sourceEncoding = string with encoding label.
695 "Unicode" by default. = encoding of the incoming text.
696 pass some non-existing encoding name
697 (ex: 'Do not touch my strings! I know what I am doing.')
698 to make encoding code skip the encoding step.
699 .outputEncoding = Either valid PDF encoding name
700 (must be supported by jsPDF font metrics, otherwise no encoding)
701 or a JS object, where key = sourceCharCode, value = outputCharCode
702 missing keys will be treated as: sourceCharCode === outputCharCode
703 .noBOM
704 See comment higher above for explanation for why this is important
705 .autoencode
706 See comment higher above for explanation for why this is important
707 */
708
709 var i, l, undef, sourceEncoding, encodingBlock, outputEncoding, newtext, isUnicode, ch, bch;
710
711 if (flags === undef) {
712 flags = {};
713 }
714
715 sourceEncoding = flags.sourceEncoding ? sourceEncoding : 'Unicode';
716
717 outputEncoding = flags.outputEncoding;
718
719 // This 'encoding' section relies on font metrics format
720 // attached to font objects by, among others,
721 // "Willow Systems' standard_font_metrics plugin"
722 // see jspdf.plugin.standard_font_metrics.js for format
723 // of the font.metadata.encoding Object.
724 // It should be something like
725 // .encoding = {'codePages':['WinANSI....'], 'WinANSI...':{code:code, ...}}
726 // .widths = {0:width, code:width, ..., 'fof':divisor}
727 // .kerning = {code:{previous_char_code:shift, ..., 'fof':-divisor},...}
728 if ((flags.autoencode || outputEncoding) &&
729 fonts[activeFontKey].metadata &&
730 fonts[activeFontKey].metadata[sourceEncoding] &&
731 fonts[activeFontKey].metadata[sourceEncoding].encoding
732 ) {
733 encodingBlock = fonts[activeFontKey].metadata[sourceEncoding].encoding;
734
735 // each font has default encoding. Some have it clearly defined.
736 if (!outputEncoding && fonts[activeFontKey].encoding) {
737 outputEncoding = fonts[activeFontKey].encoding;
738 }
739
740 // Hmmm, the above did not work? Let's try again, in different place.
741 if (!outputEncoding && encodingBlock.codePages) {
742 outputEncoding = encodingBlock.codePages[0]; // let's say, first one is the default
743 }
744
745 if (typeof outputEncoding === 'string') {
746 outputEncoding = encodingBlock[outputEncoding];
747 }
748 // we want output encoding to be a JS Object, where
749 // key = sourceEncoding's character code and
750 // value = outputEncoding's character code.
751 if (outputEncoding) {
752 isUnicode = false;
753 newtext = [];
754 for (i = 0, l = text.length; i < l; i++) {
755 ch = outputEncoding[text.charCodeAt(i)];
756 if (ch) {
757 newtext.push(
758 String.fromCharCode(ch)
759 );
760 } else {
761 newtext.push(
762 text[i]
763 );
764 }
765
766 // since we are looping over chars anyway, might as well
767 // check for residual unicodeness
768 if (newtext[i].charCodeAt(0) >> 8) { /* more than 255 */
769 isUnicode = true;
770 }
771 }
772 text = newtext.join('');
773 }
774 }
775
776 i = text.length;
777 // isUnicode may be set to false above. Hence the triple-equal to undefined
778 while (isUnicode === undef && i !== 0) {
779 if (text.charCodeAt(i - 1) >> 8) { /* more than 255 */
780 isUnicode = true;
781 }
782 i--;
783 }
784 if (!isUnicode) {
785 return text;
786 } else {
787 newtext = flags.noBOM ? [] : [254, 255];
788 for (i = 0, l = text.length; i < l; i++) {
789 ch = text.charCodeAt(i);
790 bch = ch >> 8; // divide by 256
791 if (bch >> 8) { /* something left after dividing by 256 second time */
792 throw new Error("Character at position " + i.toString(10) + " of string '" + text + "' exceeds 16bits. Cannot be encoded into UCS-2 BE");
793 }
794 newtext.push(bch);
795 newtext.push(ch - (bch << 8));
796 }
797 return String.fromCharCode.apply(undef, newtext);
798 }
799 },
800 // Replace '/', '(', and ')' with pdf-safe versions
801 pdfEscape = function (text, flags) {
802 // doing to8bitStream does NOT make this PDF display unicode text. For that
803 // we also need to reference a unicode font and embed it - royal pain in the rear.
804
805 // There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars,
806 // which JavaScript Strings are happy to provide. So, while we still cannot display
807 // 2-byte characters property, at least CONDITIONALLY converting (entire string containing)
808 // 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF
809 // is still parseable.
810 // This will allow immediate support for unicode in document properties strings.
811 return to8bitStream(text, flags).replace(/\\/g, '\\\\').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
812 },
813 putInfo = function () {
814 out('/Producer (jsPDF ' + version + ')');
815 if (documentProperties.title) {
816 out('/Title (' + pdfEscape(documentProperties.title) + ')');
817 }
818 if (documentProperties.subject) {
819 out('/Subject (' + pdfEscape(documentProperties.subject) + ')');
820 }
821 if (documentProperties.author) {
822 out('/Author (' + pdfEscape(documentProperties.author) + ')');
823 }
824 if (documentProperties.keywords) {
825 out('/Keywords (' + pdfEscape(documentProperties.keywords) + ')');
826 }
827 if (documentProperties.creator) {
828 out('/Creator (' + pdfEscape(documentProperties.creator) + ')');
829 }
830 var created = new Date();
831 out('/CreationDate (D:' +
832 [
833 created.getFullYear(),
834 padd2(created.getMonth() + 1),
835 padd2(created.getDate()),
836 padd2(created.getHours()),
837 padd2(created.getMinutes()),
838 padd2(created.getSeconds())
839 ].join('') +
840 ')'
841 );
842 },
843 putCatalog = function () {
844 out('/Type /Catalog');
845 out('/Pages 1 0 R');
846 // @TODO: Add zoom and layout modes
847 out('/OpenAction [3 0 R /FitH null]');
848 out('/PageLayout /OneColumn');
849 events.publish('putCatalog');
850 },
851 putTrailer = function () {
852 out('/Size ' + (objectNumber + 1));
853 out('/Root ' + objectNumber + ' 0 R');
854 out('/Info ' + (objectNumber - 1) + ' 0 R');
855 },
856 beginPage = function () {
857 page++;
858 // Do dimension stuff
859 outToPages = true;
860 pages[page] = [];
861 },
862 _addPage = function () {
863 beginPage();
864 // Set line width
865 out(f2(lineWidth * k) + ' w');
866 // Set draw color
867 out(drawColor);
868 // resurrecting non-default line caps, joins
869 if (lineCapID !== 0) {
870 out(lineCapID.toString(10) + ' J');
871 }
872 if (lineJoinID !== 0) {
873 out(lineJoinID.toString(10) + ' j');
874 }
875 events.publish('addPage', {'pageNumber': page});
876 },
877 /**
878 Returns a document-specific font key - a label assigned to a
879 font name + font type combination at the time the font was added
880 to the font inventory.
881
882 Font key is used as label for the desired font for a block of text
883 to be added to the PDF document stream.
884 @private
885 @function
886 @param fontName {String} can be undefined on "falthy" to indicate "use current"
887 @param fontStyle {String} can be undefined on "falthy" to indicate "use current"
888 @returns {String} Font key.
889 */
890 getFont = function (fontName, fontStyle) {
891 var key, undef;
892
893 if (fontName === undef) {
894 fontName = fonts[activeFontKey].fontName;
895 }
896 if (fontStyle === undef) {
897 fontStyle = fonts[activeFontKey].fontStyle;
898 }
899
900 try {
901 key = fontmap[fontName][fontStyle]; // returns a string like 'F3' - the KEY corresponding tot he font + type combination.
902 } catch (e) {
903 key = undef;
904 }
905 if (!key) {
906 throw new Error("Unable to look up font label for font '" + fontName + "', '" + fontStyle + "'. Refer to getFontList() for available fonts.");
907 }
908
909 return key;
910 },
911 buildDocument = function () {
912
913 outToPages = false; // switches out() to content
914 content = [];
915 offsets = [];
916
917 // putHeader()
918 out('%PDF-' + pdfVersion);
919
920 putPages();
921
922 putResources();
923
924 // Info
925 newObject();
926 out('<<');
927 putInfo();
928 out('>>');
929 out('endobj');
930
931 // Catalog
932 newObject();
933 out('<<');
934 putCatalog();
935 out('>>');
936 out('endobj');
937
938 // Cross-ref
939 var o = content_length, i;
940 out('xref');
941 out('0 ' + (objectNumber + 1));
942 out('0000000000 65535 f ');
943 for (i = 1; i <= objectNumber; i++) {
944 out(padd10(offsets[i]) + ' 00000 n ');
945 }
946 // Trailer
947 out('trailer');
948 out('<<');
949 putTrailer();
950 out('>>');
951 out('startxref');
952 out(o);
953 out('%%EOF');
954
955 outToPages = true;
956
957 return content.join('\n');
958 },
959 getStyle = function (style) {
960 // see Path-Painting Operators of PDF spec
961 var op = 'S'; // stroke
962 if (style === 'F') {
963 op = 'f'; // fill
964 } else if (style === 'FD' || style === 'DF') {
965 op = 'B'; // both
966 }
967 return op;
968 },
969
970 /**
971 Generates the PDF document.
972 Possible values:
973 datauristring (alias dataurlstring) - Data-Url-formatted data returned as string.
974 datauri (alias datauri) - Data-Url-formatted data pushed into current window's location (effectively reloading the window with contents of the PDF).
975
976 If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
977
978 @param {String} type A string identifying one of the possible output types.
979 @param {Object} options An object providing some additional signalling to PDF generator.
980 @function
981 @returns {jsPDF}
982 @methodOf jsPDF#
983 @name output
984 */
985 output = function (type, options) {
986 var undef, data, length, array, i, blob;
987 switch (type) {
988 case undef:
989 return buildDocument();
990 case 'save':
991 if (navigator.getUserMedia) {
992 if (window.URL === undefined) {
993 return API.output('dataurlnewwindow');
994 } else if (window.URL.createObjectURL === undefined) {
995 return API.output('dataurlnewwindow');
996 }
997 }
998 data = buildDocument();
999
1000 // Need to add the file to BlobBuilder as a Uint8Array
1001 length = data.length;
1002 array = new Uint8Array(new ArrayBuffer(length));
1003
1004 for (i = 0; i < length; i++) {
1005 array[i] = data.charCodeAt(i);
1006 }
1007
1008 blob = new Blob([array], {type: "application/pdf"});
1009
1010 saveAs(blob, options);
1011 break;
1012 case 'datauristring':
1013 case 'dataurlstring':
1014 return 'data:application/pdf;base64,' + btoa(buildDocument());
1015 case 'datauri':
1016 case 'dataurl':
1017 document.location.href = 'data:application/pdf;base64,' + btoa(buildDocument());
1018 break;
1019 case 'dataurlnewwindow':
1020 window.open('data:application/pdf;base64,' + btoa(buildDocument()));
1021 break;
1022 default:
1023 throw new Error('Output type "' + type + '" is not supported.');
1024 }
1025 // @TODO: Add different output options
1026 };
1027
1028 if (unit === 'pt') {
1029 k = 1;
1030 } else if (unit === 'mm') {
1031 k = 72 / 25.4;
1032 } else if (unit === 'cm') {
1033 k = 72 / 2.54;
1034 } else if (unit === 'in') {
1035 k = 72;
1036 } else {
1037 throw ('Invalid unit: ' + unit);
1038 }
1039
1040 // Dimensions are stored as user units and converted to points on output
1041 if (pageFormats.hasOwnProperty(format_as_string)) {
1042 pageHeight = pageFormats[format_as_string][1] / k;
1043 pageWidth = pageFormats[format_as_string][0] / k;
1044 } else {
1045 try {
1046 pageHeight = format[1];
1047 pageWidth = format[0];
1048 } catch (err) {
1049 throw ('Invalid format: ' + format);
1050 }
1051 }
1052
1053 if (orientation === 'p' || orientation === 'portrait') {
1054 orientation = 'p';
1055 if (pageWidth > pageHeight) {
1056 tmp = pageWidth;
1057 pageWidth = pageHeight;
1058 pageHeight = tmp;
1059 }
1060 } else if (orientation === 'l' || orientation === 'landscape') {
1061 orientation = 'l';
1062 if (pageHeight > pageWidth) {
1063 tmp = pageWidth;
1064 pageWidth = pageHeight;
1065 pageHeight = tmp;
1066 }
1067 } else {
1068 throw ('Invalid orientation: ' + orientation);
1069 }
1070
1071
1072
1073 //---------------------------------------
1074 // Public API
1075
1076 /*
1077 Object exposing internal API to plugins
1078 @public
1079 */
1080 API.internal = {
1081 'pdfEscape': pdfEscape,
1082 'getStyle': getStyle,
1083 /**
1084 Returns {FontObject} describing a particular font.
1085 @public
1086 @function
1087 @param fontName {String} (Optional) Font's family name
1088 @param fontStyle {String} (Optional) Font's style variation name (Example:"Italic")
1089 @returns {FontObject}
1090 */
1091 'getFont': function () { return fonts[getFont.apply(API, arguments)]; },
1092 'getFontSize': function () { return activeFontSize; },
1093 'getLineHeight': function () { return activeFontSize * lineHeightProportion; },
1094 'btoa': btoa,
1095 'write': function (string1, string2, string3, etc) {
1096 out(
1097 arguments.length === 1 ? string1 : Array.prototype.join.call(arguments, ' ')
1098 );
1099 },
1100 'getCoordinateString': function (value) {
1101 return f2(value * k);
1102 },
1103 'getVerticalCoordinateString': function (value) {
1104 return f2((pageHeight - value) * k);
1105 },
1106 'collections': {},
1107 'newObject': newObject,
1108 'putStream': putStream,
1109 'events': events,
1110 // ratio that you use in multiplication of a given "size" number to arrive to 'point'
1111 // units of measurement.
1112 // scaleFactor is set at initialization of the document and calculated against the stated
1113 // default measurement units for the document.
1114 // If default is "mm", k is the number that will turn number in 'mm' into 'points' number.
1115 // through multiplication.
1116 'scaleFactor': k,
1117 'pageSize': {'width': pageWidth, 'height': pageHeight},
1118 'output': function (type, options) {
1119 return output(type, options);
1120 },
1121 'getNumberOfPages': function () {return pages.length - 1; },
1122 'pages': pages
1123 };
1124
1125 /**
1126 Adds (and transfers the focus to) new page to the PDF document.
1127 @function
1128 @returns {jsPDF}
1129
1130 @methodOf jsPDF#
1131 @name addPage
1132 */
1133 API.addPage = function () {
1134 _addPage();
1135 return this;
1136 };
1137
1138 /**
1139 Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
1140 @function
1141 @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call.
1142 @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
1143 @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
1144 @param {Object} flags Collection of settings signalling how the text must be encoded. Defaults are sane. If you think you want to pass some flags, you likely can read the source.
1145 @returns {jsPDF}
1146 @methodOf jsPDF#
1147 @name text
1148 */
1149 API.text = function (text, x, y, flags) {
1150 /**
1151 * Inserts something like this into PDF
1152 BT
1153 /F1 16 Tf % Font name + size
1154 16 TL % How many units down for next line in multiline text
1155 0 g % color
1156 28.35 813.54 Td % position
1157 (line one) Tj
1158 T* (line two) Tj
1159 T* (line three) Tj
1160 ET
1161 */
1162
1163 var undef, _first, _second, _third, newtext, str, i;
1164 // Pre-August-2012 the order of arguments was function(x, y, text, flags)
1165 // in effort to make all calls have similar signature like
1166 // function(data, coordinates... , miscellaneous)
1167 // this method had its args flipped.
1168 // code below allows backward compatibility with old arg order.
1169 if (typeof text === 'number') {
1170 _first = y;
1171 _second = text;
1172 _third = x;
1173
1174 text = _first;
1175 x = _second;
1176 y = _third;
1177 }
1178
1179 // If there are any newlines in text, we assume
1180 // the user wanted to print multiple lines, so break the
1181 // text up into an array. If the text is already an array,
1182 // we assume the user knows what they are doing.
1183 if (typeof text === 'string' && text.match(/[\n\r]/)) {
1184 text = text.split(/\r\n|\r|\n/g);
1185 }
1186
1187 if (typeof flags === 'undefined') {
1188 flags = {'noBOM': true, 'autoencode': true};
1189 } else {
1190
1191 if (flags.noBOM === undef) {
1192 flags.noBOM = true;
1193 }
1194
1195 if (flags.autoencode === undef) {
1196 flags.autoencode = true;
1197 }
1198
1199 }
1200
1201 if (typeof text === 'string') {
1202 str = pdfEscape(text, flags);
1203 } else if (text instanceof Array) { /* Array */
1204 // we don't want to destroy original text array, so cloning it
1205 newtext = text.concat();
1206 // we do array.join('text that must not be PDFescaped")
1207 // thus, pdfEscape each component separately
1208 for (i = newtext.length - 1; i !== -1; i--) {
1209 newtext[i] = pdfEscape(newtext[i], flags);
1210 }
1211 str = newtext.join(") Tj\nT* (");
1212 } else {
1213 throw new Error('Type of text must be string or Array. "' + text + '" is not recognized.');
1214 }
1215 // Using "'" ("go next line and render text" mark) would save space but would complicate our rendering code, templates
1216
1217 // BT .. ET does NOT have default settings for Tf. You must state that explicitely every time for BT .. ET
1218 // if you want text transformation matrix (+ multiline) to work reliably (which reads sizes of things from font declarations)
1219 // Thus, there is NO useful, *reliable* concept of "default" font for a page.
1220 // The fact that "default" (reuse font used before) font worked before in basic cases is an accident
1221 // - readers dealing smartly with brokenness of jsPDF's markup.
1222 out(
1223 'BT\n/' +
1224 activeFontKey + ' ' + activeFontSize + ' Tf\n' + // font face, style, size
1225 (activeFontSize * lineHeightProportion) + ' TL\n' + // line spacing
1226 textColor +
1227 '\n' + f2(x * k) + ' ' + f2((pageHeight - y) * k) + ' Td\n(' +
1228 str +
1229 ') Tj\nET'
1230 );
1231 return this;
1232 };
1233
1234 API.line = function (x1, y1, x2, y2) {
1235 out(
1236 f2(x1 * k) + ' ' + f2((pageHeight - y1) * k) + ' m ' +
1237 f2(x2 * k) + ' ' + f2((pageHeight - y2) * k) + ' l S'
1238 );
1239 return this;
1240 };
1241
1242 /**
1243 Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
1244 All data points in `lines` are relative to last line origin.
1245 `x`, `y` become x1,y1 for first line / curve in the set.
1246 For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point.
1247 For bezier curves you need to specify [x2,y2,x3,y3,x4,y4] - vectors to control points 1, 2, ending point. All vectors are against the start of the curve - x1,y1.
1248
1249 @example .lines([[2,2],[-2,2],[1,1,2,2,3,3],[2,1]], 212,110, 10) // line, line, bezier curve, line
1250 @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).
1251 @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
1252 @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
1253 @param {Number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction.
1254 @param {String} style One of 'S' (the default), 'F', 'FD' or 'DF'. 'S' draws just the curve. 'F' fills the region defined by the curves. 'DF' or 'FD' draws the curves and fills the region.
1255 @param {Boolean} closed If true, the path is closed with a straight line from the end of the last curve to the starting point.
1256 @function
1257 @returns {jsPDF}
1258 @methodOf jsPDF#
1259 @name lines
1260 */
1261 API.lines = function (lines, x, y, scale, style, closed) {
1262 var undef, _first, _second, _third, scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4;
1263
1264 // Pre-August-2012 the order of arguments was function(x, y, lines, scale, style)
1265 // in effort to make all calls have similar signature like
1266 // function(content, coordinateX, coordinateY , miscellaneous)
1267 // this method had its args flipped.
1268 // code below allows backward compatibility with old arg order.
1269 if (typeof lines === 'number') {
1270 _first = y;
1271 _second = lines;
1272 _third = x;
1273
1274 lines = _first;
1275 x = _second;
1276 y = _third;
1277 }
1278
1279 style = getStyle(style);
1280 scale = scale === undef ? [1, 1] : scale;
1281
1282 // starting point
1283 out(f3(x * k) + ' ' + f3((pageHeight - y) * k) + ' m ');
1284
1285 scalex = scale[0];
1286 scaley = scale[1];
1287 l = lines.length;
1288 //, x2, y2 // bezier only. In page default measurement "units", *after* scaling
1289 //, x3, y3 // bezier only. In page default measurement "units", *after* scaling
1290 // ending point for all, lines and bezier. . In page default measurement "units", *after* scaling
1291 x4 = x; // last / ending point = starting point for first item.
1292 y4 = y; // last / ending point = starting point for first item.
1293
1294 for (i = 0; i < l; i++) {
1295 leg = lines[i];
1296 if (leg.length === 2) {
1297 // simple line
1298 x4 = leg[0] * scalex + x4; // here last x4 was prior ending point
1299 y4 = leg[1] * scaley + y4; // here last y4 was prior ending point
1300 out(f3(x4 * k) + ' ' + f3((pageHeight - y4) * k) + ' l');
1301 } else {
1302 // bezier curve
1303 x2 = leg[0] * scalex + x4; // here last x4 is prior ending point
1304 y2 = leg[1] * scaley + y4; // here last y4 is prior ending point
1305 x3 = leg[2] * scalex + x4; // here last x4 is prior ending point
1306 y3 = leg[3] * scaley + y4; // here last y4 is prior ending point
1307 x4 = leg[4] * scalex + x4; // here last x4 was prior ending point
1308 y4 = leg[5] * scaley + y4; // here last y4 was prior ending point
1309 out(
1310 f3(x2 * k) + ' ' +
1311 f3((pageHeight - y2) * k) + ' ' +
1312 f3(x3 * k) + ' ' +
1313 f3((pageHeight - y3) * k) + ' ' +
1314 f3(x4 * k) + ' ' +
1315 f3((pageHeight - y4) * k) + ' c'
1316 );
1317 }
1318 }
1319
1320 if (closed == true) {
1321 out(' h');
1322 }
1323
1324 // stroking / filling / both the path
1325 out(style);
1326 return this;
1327 };
1328
1329 /**
1330 Adds a rectangle to PDF
1331
1332 @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
1333 @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
1334 @param {Number} w Width (in units declared at inception of PDF document)
1335 @param {Number} h Height (in units declared at inception of PDF document)
1336 @param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
1337 @function
1338 @returns {jsPDF}
1339 @methodOf jsPDF#
1340 @name rect
1341 */
1342 API.rect = function (x, y, w, h, style) {
1343 var op = getStyle(style);
1344 out([
1345 f2(x * k),
1346 f2((pageHeight - y) * k),
1347 f2(w * k),
1348 f2(-h * k),
1349 're',
1350 op
1351 ].join(' '));
1352 return this;
1353 };
1354
1355 /**
1356 Adds a triangle to PDF
1357
1358 @param {Number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page
1359 @param {Number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page
1360 @param {Number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page
1361 @param {Number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page
1362 @param {Number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page
1363 @param {Number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page
1364 @param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
1365 @function
1366 @returns {jsPDF}
1367 @methodOf jsPDF#
1368 @name triangle
1369 */
1370 API.triangle = function (x1, y1, x2, y2, x3, y3, style) {
1371 this.lines(
1372 [
1373 [ x2 - x1, y2 - y1 ], // vector to point 2
1374 [ x3 - x2, y3 - y2 ], // vector to point 3
1375 [ x1 - x3, y1 - y3 ] // closing vector back to point 1
1376 ],
1377 x1,
1378 y1, // start of path
1379 [1, 1],
1380 style,
1381 true
1382 );
1383 return this;
1384 };
1385
1386 /**
1387 Adds a rectangle with rounded corners to PDF
1388
1389 @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
1390 @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
1391 @param {Number} w Width (in units declared at inception of PDF document)
1392 @param {Number} h Height (in units declared at inception of PDF document)
1393 @param {Number} rx Radius along x axis (in units declared at inception of PDF document)
1394 @param {Number} rx Radius along y axis (in units declared at inception of PDF document)
1395 @param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
1396 @function
1397 @returns {jsPDF}
1398 @methodOf jsPDF#
1399 @name roundedRect
1400 */
1401 API.roundedRect = function (x, y, w, h, rx, ry, style) {
1402 var MyArc = 4 / 3 * (Math.SQRT2 - 1);
1403 this.lines(
1404 [
1405 [ (w - 2 * rx), 0 ],
1406 [ (rx * MyArc), 0, rx, ry - (ry * MyArc), rx, ry ],
1407 [ 0, (h - 2 * ry) ],
1408 [ 0, (ry * MyArc), -(rx * MyArc), ry, -rx, ry],
1409 [ (-w + 2 * rx), 0],
1410 [ -(rx * MyArc), 0, -rx, -(ry * MyArc), -rx, -ry],
1411 [ 0, (-h + 2 * ry)],
1412 [ 0, -(ry * MyArc), (rx * MyArc), -ry, rx, -ry]
1413 ],
1414 x + rx,
1415 y, // start of path
1416 [1, 1],
1417 style
1418 );
1419 return this;
1420 };
1421
1422 /**
1423 Adds an ellipse to PDF
1424
1425 @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
1426 @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
1427 @param {Number} rx Radius along x axis (in units declared at inception of PDF document)
1428 @param {Number} rx Radius along y axis (in units declared at inception of PDF document)
1429 @param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
1430 @function
1431 @returns {jsPDF}
1432 @methodOf jsPDF#
1433 @name ellipse
1434 */
1435 API.ellipse = function (x, y, rx, ry, style) {
1436 var op = getStyle(style),
1437 lx = 4 / 3 * (Math.SQRT2 - 1) * rx,
1438 ly = 4 / 3 * (Math.SQRT2 - 1) * ry;
1439
1440 out([
1441 f2((x + rx) * k),
1442 f2((pageHeight - y) * k),
1443 'm',
1444 f2((x + rx) * k),
1445 f2((pageHeight - (y - ly)) * k),
1446 f2((x + lx) * k),
1447 f2((pageHeight - (y - ry)) * k),
1448 f2(x * k),
1449 f2((pageHeight - (y - ry)) * k),
1450 'c'
1451 ].join(' '));
1452 out([
1453 f2((x - lx) * k),
1454 f2((pageHeight - (y - ry)) * k),
1455 f2((x - rx) * k),
1456 f2((pageHeight - (y - ly)) * k),
1457 f2((x - rx) * k),
1458 f2((pageHeight - y) * k),
1459 'c'
1460 ].join(' '));
1461 out([
1462 f2((x - rx) * k),
1463 f2((pageHeight - (y + ly)) * k),
1464 f2((x - lx) * k),
1465 f2((pageHeight - (y + ry)) * k),
1466 f2(x * k),
1467 f2((pageHeight - (y + ry)) * k),
1468 'c'
1469 ].join(' '));
1470 out([
1471 f2((x + lx) * k),
1472 f2((pageHeight - (y + ry)) * k),
1473 f2((x + rx) * k),
1474 f2((pageHeight - (y + ly)) * k),
1475 f2((x + rx) * k),
1476 f2((pageHeight - y) * k),
1477 'c',
1478 op
1479 ].join(' '));
1480 return this;
1481 };
1482
1483 /**
1484 Adds an circle to PDF
1485
1486 @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
1487 @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
1488 @param {Number} r Radius (in units declared at inception of PDF document)
1489 @param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
1490 @function
1491 @returns {jsPDF}
1492 @methodOf jsPDF#
1493 @name circle
1494 */
1495 API.circle = function (x, y, r, style) {
1496 return this.ellipse(x, y, r, r, style);
1497 };
1498
1499 /**
1500 Adds a properties to the PDF document
1501
1502 @param {Object} A property_name-to-property_value object structure.
1503 @function
1504 @returns {jsPDF}
1505 @methodOf jsPDF#
1506 @name setProperties
1507 */
1508 API.setProperties = function (properties) {
1509 // copying only those properties we can render.
1510 var property;
1511 for (property in documentProperties) {
1512 if (documentProperties.hasOwnProperty(property) && properties[property]) {
1513 documentProperties[property] = properties[property];
1514 }
1515 }
1516 return this;
1517 };
1518
1519 /**
1520 Sets font size for upcoming text elements.
1521
1522 @param {Number} size Font size in points.
1523 @function
1524 @returns {jsPDF}
1525 @methodOf jsPDF#
1526 @name setFontSize
1527 */
1528 API.setFontSize = function (size) {
1529 activeFontSize = size;
1530 return this;
1531 };
1532
1533 /**
1534 Sets text font face, variant for upcoming text elements.
1535 See output of jsPDF.getFontList() for possible font names, styles.
1536
1537 @param {String} fontName Font name or family. Example: "times"
1538 @param {String} fontStyle Font style or variant. Example: "italic"
1539 @function
1540 @returns {jsPDF}
1541 @methodOf jsPDF#
1542 @name setFont
1543 */
1544 API.setFont = function (fontName, fontStyle) {
1545 activeFontKey = getFont(fontName, fontStyle);
1546 // if font is not found, the above line blows up and we never go further
1547 return this;
1548 };
1549
1550 /**
1551 Switches font style or variant for upcoming text elements,
1552 while keeping the font face or family same.
1553 See output of jsPDF.getFontList() for possible font names, styles.
1554
1555 @param {String} style Font style or variant. Example: "italic"
1556 @function
1557 @returns {jsPDF}
1558 @methodOf jsPDF#
1559 @name setFontStyle
1560 */
1561 API.setFontStyle = API.setFontType = function (style) {
1562 var undef;
1563 activeFontKey = getFont(undef, style);
1564 // if font is not found, the above line blows up and we never go further
1565 return this;
1566 };
1567
1568 /**
1569 Returns an object - a tree of fontName to fontStyle relationships available to
1570 active PDF document.
1571
1572 @public
1573 @function
1574 @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }
1575 @methodOf jsPDF#
1576 @name getFontList
1577 */
1578 API.getFontList = function () {
1579 // TODO: iterate over fonts array or return copy of fontmap instead in case more are ever added.
1580 var list = {},
1581 fontName,
1582 fontStyle,
1583 tmp;
1584
1585 for (fontName in fontmap) {
1586 if (fontmap.hasOwnProperty(fontName)) {
1587 list[fontName] = tmp = [];
1588 for (fontStyle in fontmap[fontName]) {
1589 if (fontmap[fontName].hasOwnProperty(fontStyle)) {
1590 tmp.push(fontStyle);
1591 }
1592 }
1593 }
1594 }
1595
1596 return list;
1597 };
1598
1599 /**
1600 Sets line width for upcoming lines.
1601
1602 @param {Number} width Line width (in units declared at inception of PDF document)
1603 @function
1604 @returns {jsPDF}
1605 @methodOf jsPDF#
1606 @name setLineWidth
1607 */
1608 API.setLineWidth = function (width) {
1609 out((width * k).toFixed(2) + ' w');
1610 return this;
1611 };
1612
1613 /**
1614 Sets the stroke color for upcoming elements.
1615
1616 Depending on the number of arguments given, Gray, RGB, or CMYK
1617 color space is implied.
1618
1619 When only ch1 is given, "Gray" color space is implied and it
1620 must be a value in the range from 0.00 (solid black) to to 1.00 (white)
1621 if values are communicated as String types, or in range from 0 (black)
1622 to 255 (white) if communicated as Number type.
1623 The RGB-like 0-255 range is provided for backward compatibility.
1624
1625 When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
1626 value must be in the range from 0.00 (minimum intensity) to to 1.00
1627 (max intensity) if values are communicated as String types, or
1628 from 0 (min intensity) to to 255 (max intensity) if values are communicated
1629 as Number types.
1630 The RGB-like 0-255 range is provided for backward compatibility.
1631
1632 When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
1633 value must be a in the range from 0.00 (0% concentration) to to
1634 1.00 (100% concentration)
1635
1636 Because JavaScript treats fixed point numbers badly (rounds to
1637 floating point nearest to binary representation) it is highly advised to
1638 communicate the fractional numbers as String types, not JavaScript Number type.
1639
1640 @param {Number|String} ch1 Color channel value
1641 @param {Number|String} ch2 Color channel value
1642 @param {Number|String} ch3 Color channel value
1643 @param {Number|String} ch4 Color channel value
1644
1645 @function
1646 @returns {jsPDF}
1647 @methodOf jsPDF#
1648 @name setDrawColor
1649 */
1650 API.setDrawColor = function (ch1, ch2, ch3, ch4) {
1651 var color;
1652 if (ch2 === undefined || (ch4 === undefined && ch1 === ch2 === ch3)) {
1653 // Gray color space.
1654 if (typeof ch1 === 'string') {
1655 color = ch1 + ' G';
1656 } else {
1657 color = f2(ch1 / 255) + ' G';
1658 }
1659 } else if (ch4 === undefined) {
1660 // RGB
1661 if (typeof ch1 === 'string') {
1662 color = [ch1, ch2, ch3, 'RG'].join(' ');
1663 } else {
1664 color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), 'RG'].join(' ');
1665 }
1666 } else {
1667 // CMYK
1668 if (typeof ch1 === 'string') {
1669 color = [ch1, ch2, ch3, ch4, 'K'].join(' ');
1670 } else {
1671 color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), 'K'].join(' ');
1672 }
1673 }
1674
1675 out(color);
1676 return this;
1677 };
1678
1679 /**
1680 Sets the fill color for upcoming elements.
1681
1682 Depending on the number of arguments given, Gray, RGB, or CMYK
1683 color space is implied.
1684
1685 When only ch1 is given, "Gray" color space is implied and it
1686 must be a value in the range from 0.00 (solid black) to to 1.00 (white)
1687 if values are communicated as String types, or in range from 0 (black)
1688 to 255 (white) if communicated as Number type.
1689 The RGB-like 0-255 range is provided for backward compatibility.
1690
1691 When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
1692 value must be in the range from 0.00 (minimum intensity) to to 1.00
1693 (max intensity) if values are communicated as String types, or
1694 from 0 (min intensity) to to 255 (max intensity) if values are communicated
1695 as Number types.
1696 The RGB-like 0-255 range is provided for backward compatibility.
1697
1698 When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
1699 value must be a in the range from 0.00 (0% concentration) to to
1700 1.00 (100% concentration)
1701
1702 Because JavaScript treats fixed point numbers badly (rounds to
1703 floating point nearest to binary representation) it is highly advised to
1704 communicate the fractional numbers as String types, not JavaScript Number type.
1705
1706 @param {Number|String} ch1 Color channel value
1707 @param {Number|String} ch2 Color channel value
1708 @param {Number|String} ch3 Color channel value
1709 @param {Number|String} ch4 Color channel value
1710
1711 @function
1712 @returns {jsPDF}
1713 @methodOf jsPDF#
1714 @name setFillColor
1715 */
1716 API.setFillColor = function (ch1, ch2, ch3, ch4) {
1717 var color;
1718
1719 if (ch2 === undefined || (ch4 === undefined && ch1 === ch2 === ch3)) {
1720 // Gray color space.
1721 if (typeof ch1 === 'string') {
1722 color = ch1 + ' g';
1723 } else {
1724 color = f2(ch1 / 255) + ' g';
1725 }
1726 } else if (ch4 === undefined) {
1727 // RGB
1728 if (typeof ch1 === 'string') {
1729 color = [ch1, ch2, ch3, 'rg'].join(' ');
1730 } else {
1731 color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), 'rg'].join(' ');
1732 }
1733 } else {
1734 // CMYK
1735 if (typeof ch1 === 'string') {
1736 color = [ch1, ch2, ch3, ch4, 'k'].join(' ');
1737 } else {
1738 color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), 'k'].join(' ');
1739 }
1740 }
1741
1742 out(color);
1743 return this;
1744 };
1745
1746 /**
1747 Sets the text color for upcoming elements.
1748 If only one, first argument is given,
1749 treats the value as gray-scale color value.
1750
1751 @param {Number} r Red channel color value in range 0-255 or {String} r color value in hexadecimal, example: '#FFFFFF'
1752 @param {Number} g Green channel color value in range 0-255
1753 @param {Number} b Blue channel color value in range 0-255
1754 @function
1755 @returns {jsPDF}
1756 @methodOf jsPDF#
1757 @name setTextColor
1758 */
1759 API.setTextColor = function (r, g, b) {
1760 var patt = /#[0-9A-Fa-f]{6}/;
1761 if ((typeof r == 'string') && patt.test(r)) {
1762 var hex = r.replace('#','');
1763 var bigint = parseInt(hex, 16);
1764 r = (bigint >> 16) & 255;
1765 g = (bigint >> 8) & 255;
1766 b = bigint & 255;
1767 }
1768
1769 if ((r === 0 && g === 0 && b === 0) || (typeof g === 'undefined')) {
1770 textColor = f3(r / 255) + ' g';
1771 } else {
1772 textColor = [f3(r / 255), f3(g / 255), f3(b / 255), 'rg'].join(' ');
1773 }
1774 return this;
1775 };
1776
1777 /**
1778 Is an Object providing a mapping from human-readable to
1779 integer flag values designating the varieties of line cap
1780 and join styles.
1781
1782 @returns {Object}
1783 @fieldOf jsPDF#
1784 @name CapJoinStyles
1785 */
1786 API.CapJoinStyles = {
1787 0: 0,
1788 'butt': 0,
1789 'but': 0,
1790 'miter': 0,
1791 1: 1,
1792 'round': 1,
1793 'rounded': 1,
1794 'circle': 1,
1795 2: 2,
1796 'projecting': 2,
1797 'project': 2,
1798 'square': 2,
1799 'bevel': 2
1800 };
1801
1802 /**
1803 Sets the line cap styles
1804 See {jsPDF.CapJoinStyles} for variants
1805
1806 @param {String|Number} style A string or number identifying the type of line cap
1807 @function
1808 @returns {jsPDF}
1809 @methodOf jsPDF#
1810 @name setLineCap
1811 */
1812 API.setLineCap = function (style) {
1813 var id = this.CapJoinStyles[style];
1814 if (id === undefined) {
1815 throw new Error("Line cap style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
1816 }
1817 lineCapID = id;
1818 out(id.toString(10) + ' J');
1819
1820 return this;
1821 };
1822
1823 /**
1824 Sets the line join styles
1825 See {jsPDF.CapJoinStyles} for variants
1826
1827 @param {String|Number} style A string or number identifying the type of line join
1828 @function
1829 @returns {jsPDF}
1830 @methodOf jsPDF#
1831 @name setLineJoin
1832 */
1833 API.setLineJoin = function (style) {
1834 var id = this.CapJoinStyles[style];
1835 if (id === undefined) {
1836 throw new Error("Line join style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
1837 }
1838 lineJoinID = id;
1839 out(id.toString(10) + ' j');
1840
1841 return this;
1842 };
1843
1844 // Output is both an internal (for plugins) and external function
1845 API.output = output;
1846
1847 /**
1848 * Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf')
1849 * @param {String} filename The filename including extension.
1850 *
1851 * @function
1852 * @returns {jsPDF}
1853 * @methodOf jsPDF#
1854 * @name save
1855 */
1856 API.save = function (filename) {
1857 API.output('save', filename);
1858 };
1859
1860 // applying plugins (more methods) ON TOP of built-in API.
1861 // this is intentional as we allow plugins to override
1862 // built-ins
1863 for (plugin in jsPDF.API) {
1864 if (jsPDF.API.hasOwnProperty(plugin)) {
1865 if (plugin === 'events' && jsPDF.API.events.length) {
1866 (function (events, newEvents) {
1867
1868 // jsPDF.API.events is a JS Array of Arrays
1869 // where each Array is a pair of event name, handler
1870 // Events were added by plugins to the jsPDF instantiator.
1871 // These are always added to the new instance and some ran
1872 // during instantiation.
1873
1874 var eventname, handler_and_args, i;
1875
1876 for (i = newEvents.length - 1; i !== -1; i--) {
1877 // subscribe takes 3 args: 'topic', function, runonce_flag
1878 // if undefined, runonce is false.
1879 // users can attach callback directly,
1880 // or they can attach an array with [callback, runonce_flag]
1881 // that's what the "apply" magic is for below.
1882 eventname = newEvents[i][0];
1883 handler_and_args = newEvents[i][1];
1884 events.subscribe.apply(
1885 events,
1886 [eventname].concat(
1887 typeof handler_and_args === 'function' ?
1888 [ handler_and_args ] :
1889 handler_and_args
1890 )
1891 );
1892 }
1893 }(events, jsPDF.API.events));
1894 } else {
1895 API[plugin] = jsPDF.API[plugin];
1896 }
1897 }
1898 }
1899
1900 /////////////////////////////////////////
1901 // continuing initilisation of jsPDF Document object
1902 /////////////////////////////////////////
1903
1904
1905 // Add the first page automatically
1906 addFonts();
1907 activeFontKey = 'F1';
1908 _addPage();
1909
1910 events.publish('initialized');
1911
1912 return API;
1913 }
1914
1915 /**
1916 jsPDF.API is a STATIC property of jsPDF class.
1917 jsPDF.API is an object you can add methods and properties to.
1918 The methods / properties you add will show up in new jsPDF objects.
1919
1920 One property is prepopulated. It is the 'events' Object. Plugin authors can add topics, callbacks to this object. These will be reassigned to all new instances of jsPDF.
1921 Examples:
1922 jsPDF.API.events['initialized'] = function(){ 'this' is API object }
1923 jsPDF.API.events['addFont'] = function(added_font_object){ 'this' is API object }
1924
1925 @static
1926 @public
1927 @memberOf jsPDF
1928 @name API
1929
1930 @example
1931 jsPDF.API.mymethod = function(){
1932 // 'this' will be ref to internal API object. see jsPDF source
1933 // , so you can refer to built-in methods like so:
1934 // this.line(....)
1935 // this.text(....)
1936 }
1937 var pdfdoc = new jsPDF()
1938 pdfdoc.mymethod() // <- !!!!!!
1939 */
1940 jsPDF.API = {'events': []};
1941
1942 return jsPDF;
1943 }());
amcharts/exporting/jspdf.plugin.addimage.js
File was created 1 /** @preserve
2 jsPDF addImage plugin (JPEG only at this time)
3 Copyright (c) 2012 https://github.com/siefkenj/
4 */
5
6 /**
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * ====================================================================
26 */
27
28 ;(function(jsPDFAPI) {
29 'use strict'
30
31 var namespace = 'addImage_'
32
33 // takes a string imgData containing the raw bytes of
34 // a jpeg image and returns [width, height]
35 // Algorithm from: http://www.64lines.com/jpeg-width-height
36 var getJpegSize = function(imgData) {
37 'use strict'
38 var width, height;
39 // Verify we have a valid jpeg header 0xff,0xd8,0xff,0xe0,?,?,'J','F','I','F',0x00
40 if (!imgData.charCodeAt(0) === 0xff ||
41 !imgData.charCodeAt(1) === 0xd8 ||
42 !imgData.charCodeAt(2) === 0xff ||
43 !imgData.charCodeAt(3) === 0xe0 ||
44 !imgData.charCodeAt(6) === 'J'.charCodeAt(0) ||
45 !imgData.charCodeAt(7) === 'F'.charCodeAt(0) ||
46 !imgData.charCodeAt(8) === 'I'.charCodeAt(0) ||
47 !imgData.charCodeAt(9) === 'F'.charCodeAt(0) ||
48 !imgData.charCodeAt(10) === 0x00) {
49 throw new Error('getJpegSize requires a binary jpeg file')
50 }
51 var blockLength = imgData.charCodeAt(4)*256 + imgData.charCodeAt(5);
52 var i = 4, len = imgData.length;
53 while ( i < len ) {
54 i += blockLength;
55 if (imgData.charCodeAt(i) !== 0xff) {
56 throw new Error('getJpegSize could not find the size of the image');
57 }
58 if (imgData.charCodeAt(i+1) === 0xc0 || //(SOF) Huffman - Baseline DCT
59 imgData.charCodeAt(i+1) === 0xc1 || //(SOF) Huffman - Extended sequential DCT
60 imgData.charCodeAt(i+1) === 0xc2 || // Progressive DCT (SOF2)
61 imgData.charCodeAt(i+1) === 0xc3 || // Spatial (sequential) lossless (SOF3)
62 imgData.charCodeAt(i+1) === 0xc4 || // Differential sequential DCT (SOF5)
63 imgData.charCodeAt(i+1) === 0xc5 || // Differential progressive DCT (SOF6)
64 imgData.charCodeAt(i+1) === 0xc6 || // Differential spatial (SOF7)
65 imgData.charCodeAt(i+1) === 0xc7) {
66 height = imgData.charCodeAt(i+5)*256 + imgData.charCodeAt(i+6);
67 width = imgData.charCodeAt(i+7)*256 + imgData.charCodeAt(i+8);
68 return [width, height];
69 } else {
70 i += 2;
71 blockLength = imgData.charCodeAt(i)*256 + imgData.charCodeAt(i+1)
72 }
73 }
74 }
75 // Image functionality ported from pdf.js
76 , putImage = function(img) {
77 var objectNumber = this.internal.newObject()
78 , out = this.internal.write
79 , putStream = this.internal.putStream
80
81 img['n'] = objectNumber
82
83 out('<</Type /XObject')
84 out('/Subtype /Image')
85 out('/Width ' + img['w'])
86 out('/Height ' + img['h'])
87 if (img['cs'] === 'Indexed') {
88 out('/ColorSpace [/Indexed /DeviceRGB '
89 + (img['pal'].length / 3 - 1) + ' ' + (objectNumber + 1)
90 + ' 0 R]');
91 } else {
92 out('/ColorSpace /' + img['cs']);
93 if (img['cs'] === 'DeviceCMYK') {
94 out('/Decode [1 0 1 0 1 0 1 0]');
95 }
96 }
97 out('/BitsPerComponent ' + img['bpc']);
98 if ('f' in img) {
99 out('/Filter /' + img['f']);
100 }
101 if ('dp' in img) {
102 out('/DecodeParms <<' + img['dp'] + '>>');
103 }
104 if ('trns' in img && img['trns'].constructor == Array) {
105 var trns = '';
106 for ( var i = 0; i < img['trns'].length; i++) {
107 trns += (img[trns][i] + ' ' + img['trns'][i] + ' ');
108 out('/Mask [' + trns + ']');
109 }
110 }
111 if ('smask' in img) {
112 out('/SMask ' + (objectNumber + 1) + ' 0 R');
113 }
114 out('/Length ' + img['data'].length + '>>');
115
116 putStream(img['data']);
117
118 out('endobj');
119 }
120 , putResourcesCallback = function() {
121 var images = this.internal.collections[namespace + 'images']
122 for ( var i in images ) {
123 putImage.call(this, images[i])
124 }
125 }
126 , putXObjectsDictCallback = function(){
127 var images = this.internal.collections[namespace + 'images']
128 , out = this.internal.write
129 , image
130 for (var i in images) {
131 image = images[i]
132 out(
133 '/I' + image['i']
134 , image['n']
135 , '0'
136 , 'R'
137 )
138 }
139 }
140
141 jsPDFAPI.addImage = function(imageData, format, x, y, w, h) {
142 'use strict'
143 if (typeof imageData === 'object' && imageData.nodeType === 1) {
144 var canvas = document.createElement('canvas');
145 canvas.width = imageData.clientWidth;
146 canvas.height = imageData.clientHeight;
147
148 var ctx = canvas.getContext('2d');
149 if (!ctx) {
150 throw ('addImage requires canvas to be supported by browser.');
151 }
152 ctx.drawImage(imageData, 0, 0, canvas.width, canvas.height);
153 imageData = canvas.toDataURL('image/jpeg');
154 format = "JPEG";
155 }
156 if (format.toUpperCase() !== 'JPEG') {
157 throw new Error('addImage currently only supports format \'JPEG\', not \''+format+'\'');
158 }
159
160 var imageIndex
161 , images = this.internal.collections[namespace + 'images']
162 , coord = this.internal.getCoordinateString
163 , vcoord = this.internal.getVerticalCoordinateString;
164
165 // Detect if the imageData is raw binary or Data URL
166 if (imageData.substring(0, 23) === 'data:image/jpeg;base64,') {
167 imageData = atob(imageData.replace('data:image/jpeg;base64,', ''));
168 }
169
170 if (images){
171 // this is NOT the first time this method is ran on this instance of jsPDF object.
172 imageIndex = Object.keys ?
173 Object.keys(images).length :
174 (function(o){
175 var i = 0
176 for (var e in o){if(o.hasOwnProperty(e)){ i++ }}
177 return i
178 })(images)
179 } else {
180 // this is the first time this method is ran on this instance of jsPDF object.
181 imageIndex = 0
182 this.internal.collections[namespace + 'images'] = images = {}
183 this.internal.events.subscribe('putResources', putResourcesCallback)
184 this.internal.events.subscribe('putXobjectDict', putXObjectsDictCallback)
185 }
186
187 var dims = getJpegSize(imageData);
188 var info = {
189 w : dims[0],
190 h : dims[1],
191 cs : 'DeviceRGB',
192 bpc : 8,
193 f : 'DCTDecode',
194 i : imageIndex,
195 data : imageData
196 // n: objectNumber will be added by putImage code
197
198 };
199 images[imageIndex] = info
200 if (!w && !h) {
201 w = -96;
202 h = -96;
203 }
204 if (w < 0) {
205 w = (-1) * info['w'] * 72 / w / this.internal.scaleFactor;
206 }
207 if (h < 0) {
208 h = (-1) * info['h'] * 72 / h / this.internal.scaleFactor;
209 }
210 if (w === 0) {
211 w = h * info['w'] / info['h'];
212 }
213 if (h === 0) {
214 h = w * info['h'] / info['w'];
215 }
216
217 this.internal.write(
218 'q'
219 , coord(w)
220 , '0 0'
221 , coord(h) // TODO: check if this should be shifted by vcoord
222 , coord(x)
223 , vcoord(y + h)
224 , 'cm /I'+info['i']
225 , 'Do Q'
226 )
227
228 return this
229 }
230 })(jsPDF.API)
amcharts/exporting/rgbcolor.js
File was created 1 /**
2 * A class to parse color values
3 * @author Stoyan Stefanov <sstoo@gmail.com>
4 * @link http://www.phpied.com/rgb-color-parser-in-javascript/
5 * @license Use it if you like it
6 */
7 function RGBColor(color_string)
8 {
9 this.ok = false;
10
11 // strip any leading #
12 if (color_string.charAt(0) == '#') { // remove # if any
13 color_string = color_string.substr(1,6);
14 }
15
16 color_string = color_string.replace(/ /g,'');
17 color_string = color_string.toLowerCase();
18
19 // before getting into regexps, try simple matches
20 // and overwrite the input
21 var simple_colors = {
22 aliceblue: 'f0f8ff',
23 antiquewhite: 'faebd7',
24 aqua: '00ffff',
25 aquamarine: '7fffd4',
26 azure: 'f0ffff',
27 beige: 'f5f5dc',
28 bisque: 'ffe4c4',
29 black: '000000',
30 blanchedalmond: 'ffebcd',
31 blue: '0000ff',
32 blueviolet: '8a2be2',
33 brown: 'a52a2a',
34 burlywood: 'deb887',
35 cadetblue: '5f9ea0',
36 chartreuse: '7fff00',
37 chocolate: 'd2691e',
38 coral: 'ff7f50',
39 cornflowerblue: '6495ed',
40 cornsilk: 'fff8dc',
41 crimson: 'dc143c',
42 cyan: '00ffff',
43 darkblue: '00008b',
44 darkcyan: '008b8b',
45 darkgoldenrod: 'b8860b',
46 darkgray: 'a9a9a9',
47 darkgreen: '006400',
48 darkkhaki: 'bdb76b',
49 darkmagenta: '8b008b',
50 darkolivegreen: '556b2f',
51 darkorange: 'ff8c00',
52 darkorchid: '9932cc',
53 darkred: '8b0000',
54 darksalmon: 'e9967a',
55 darkseagreen: '8fbc8f',
56 darkslateblue: '483d8b',
57 darkslategray: '2f4f4f',
58 darkturquoise: '00ced1',
59 darkviolet: '9400d3',
60 deeppink: 'ff1493',
61 deepskyblue: '00bfff',
62 dimgray: '696969',
63 dodgerblue: '1e90ff',
64 feldspar: 'd19275',
65 firebrick: 'b22222',
66 floralwhite: 'fffaf0',
67 forestgreen: '228b22',
68 fuchsia: 'ff00ff',
69 gainsboro: 'dcdcdc',
70 ghostwhite: 'f8f8ff',
71 gold: 'ffd700',
72 goldenrod: 'daa520',
73 gray: '808080',
74 green: '008000',
75 greenyellow: 'adff2f',
76 honeydew: 'f0fff0',
77 hotpink: 'ff69b4',
78 indianred : 'cd5c5c',
79 indigo : '4b0082',
80 ivory: 'fffff0',
81 khaki: 'f0e68c',
82 lavender: 'e6e6fa',
83 lavenderblush: 'fff0f5',
84 lawngreen: '7cfc00',
85 lemonchiffon: 'fffacd',
86 lightblue: 'add8e6',
87 lightcoral: 'f08080',
88 lightcyan: 'e0ffff',
89 lightgoldenrodyellow: 'fafad2',
90 lightgrey: 'd3d3d3',
91 lightgreen: '90ee90',
92 lightpink: 'ffb6c1',
93 lightsalmon: 'ffa07a',
94 lightseagreen: '20b2aa',
95 lightskyblue: '87cefa',
96 lightslateblue: '8470ff',
97 lightslategray: '778899',
98 lightsteelblue: 'b0c4de',
99 lightyellow: 'ffffe0',
100 lime: '00ff00',
101 limegreen: '32cd32',
102 linen: 'faf0e6',
103 magenta: 'ff00ff',
104 maroon: '800000',
105 mediumaquamarine: '66cdaa',
106 mediumblue: '0000cd',
107 mediumorchid: 'ba55d3',
108 mediumpurple: '9370d8',
109 mediumseagreen: '3cb371',
110 mediumslateblue: '7b68ee',
111 mediumspringgreen: '00fa9a',
112 mediumturquoise: '48d1cc',
113 mediumvioletred: 'c71585',
114 midnightblue: '191970',
115 mintcream: 'f5fffa',
116 mistyrose: 'ffe4e1',
117 moccasin: 'ffe4b5',
118 navajowhite: 'ffdead',
119 navy: '000080',
120 oldlace: 'fdf5e6',
121 olive: '808000',
122 olivedrab: '6b8e23',
123 orange: 'ffa500',
124 orangered: 'ff4500',
125 orchid: 'da70d6',
126 palegoldenrod: 'eee8aa',
127 palegreen: '98fb98',
128 paleturquoise: 'afeeee',
129 palevioletred: 'd87093',
130 papayawhip: 'ffefd5',
131 peachpuff: 'ffdab9',
132 peru: 'cd853f',
133 pink: 'ffc0cb',
134 plum: 'dda0dd',
135 powderblue: 'b0e0e6',
136 purple: '800080',
137 red: 'ff0000',
138 rosybrown: 'bc8f8f',
139 royalblue: '4169e1',
140 saddlebrown: '8b4513',
141 salmon: 'fa8072',
142 sandybrown: 'f4a460',
143 seagreen: '2e8b57',
144 seashell: 'fff5ee',
145 sienna: 'a0522d',
146 silver: 'c0c0c0',
147 skyblue: '87ceeb',
148 slateblue: '6a5acd',
149 slategray: '708090',
150 snow: 'fffafa',
151 springgreen: '00ff7f',
152 steelblue: '4682b4',
153 tan: 'd2b48c',
154 teal: '008080',
155 thistle: 'd8bfd8',
156 tomato: 'ff6347',
157 turquoise: '40e0d0',
158 violet: 'ee82ee',
159 violetred: 'd02090',
160 wheat: 'f5deb3',
161 white: 'ffffff',
162 whitesmoke: 'f5f5f5',
163 yellow: 'ffff00',
164 yellowgreen: '9acd32'
165 };
166 for (var key in simple_colors) {
167 if (color_string == key) {
168 color_string = simple_colors[key];
169 }
170 }
171 // emd of simple type-in colors
172
173 // array of color definition objects
174 var color_defs = [
175 {
176 re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
177 example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
178 process: function (bits){
179 return [
180 parseInt(bits[1]),
181 parseInt(bits[2]),
182 parseInt(bits[3])
183 ];
184 }
185 },
186 {
187 re: /^(\w{2})(\w{2})(\w{2})$/,
188 example: ['#00ff00', '336699'],
189 process: function (bits){
190 return [
191 parseInt(bits[1], 16),
192 parseInt(bits[2], 16),
193 parseInt(bits[3], 16)
194 ];
195 }
196 },
197 {
198 re: /^(\w{1})(\w{1})(\w{1})$/,
199 example: ['#fb0', 'f0f'],
200 process: function (bits){
201 return [
202 parseInt(bits[1] + bits[1], 16),
203 parseInt(bits[2] + bits[2], 16),
204 parseInt(bits[3] + bits[3], 16)
205 ];
206 }
207 }
208 ];
209
210 // search through the definitions to find a match
211 for (var i = 0; i < color_defs.length; i++) {
212 var re = color_defs[i].re;
213 var processor = color_defs[i].process;
214 var bits = re.exec(color_string);
215 if (bits) {
216 channels = processor(bits);
217 this.r = channels[0];
218 this.g = channels[1];
219 this.b = channels[2];
220 this.ok = true;
221 }
222
223 }
224
225 // validate/cleanup values
226 this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
227 this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
228 this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
229
230 // some getters
231 this.toRGB = function () {
232 return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
233 }
234 this.toHex = function () {
235 var r = this.r.toString(16);
236 var g = this.g.toString(16);
237 var b = this.b.toString(16);
238 if (r.length == 1) r = '0' + r;
239 if (g.length == 1) g = '0' + g;
240 if (b.length == 1) b = '0' + b;
241 return '#' + r + g + b;
242 }
243
244 // help
245 this.getHelpXML = function () {
246
247 var examples = new Array();
248 // add regexps
249 for (var i = 0; i < color_defs.length; i++) {
250 var example = color_defs[i].example;
251 for (var j = 0; j < example.length; j++) {
252 examples[examples.length] = example[j];
253 }
254 }
255 // add type-in colors
256 for (var sc in simple_colors) {
257 examples[examples.length] = sc;
258 }
259
260 var xml = document.createElement('ul');
261 xml.setAttribute('id', 'rgbcolor-examples');
262 for (var i = 0; i < examples.length; i++) {
263 try {
264 var list_item = document.createElement('li');
265 var list_color = new RGBColor(examples[i]);
266 var example_div = document.createElement('div');
267 example_div.style.cssText =
268 'margin: 3px; '
269 + 'border: 1px solid black; '
270 + 'background:' + list_color.toHex() + '; '
271 + 'color:' + list_color.toHex()
272 ;
273 example_div.appendChild(document.createTextNode('test'));
274 var list_item_value = document.createTextNode(
275 ' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
276 );
277 list_item.appendChild(example_div);
278 list_item.appendChild(list_item_value);
279 xml.appendChild(list_item);
280
281 } catch(e){}
282 }
283 return xml;
284
285 }
286
287 }
288
289
amcharts/funnel.js
File was created 1 AmCharts.AmFunnelChart=AmCharts.Class({inherits:AmCharts.AmSlicedChart,construct:function(u){this.type="funnel";AmCharts.AmFunnelChart.base.construct.call(this,u);this.cname="AmFunnelChart";this.startX=this.startY=0;this.baseWidth="100%";this.neckHeight=this.neckWidth=0;this.rotate=!1;this.valueRepresents="height";this.pullDistance=30;this.labelPosition="center";this.labelText="[[title]]: [[value]]";this.balloonText="[[title]]: [[value]]\n[[description]]";AmCharts.applyTheme(this,u,this.cname)},drawChart:function(){AmCharts.AmFunnelChart.base.drawChart.call(this);
2 var u=this.chartData;if(AmCharts.ifArray(u))if(0<this.realWidth&&0<this.realHeight){var t=this.container,D=this.startDuration,k=this.rotate,x=this.updateWidth();this.realWidth=x;var g=this.updateHeight();this.realHeight=g;var q=AmCharts.toCoordinate,A=q(this.marginLeft,x),v=q(this.marginRight,x),a=q(this.marginTop,g)+this.getTitleHeight(),q=q(this.marginBottom,g),v=x-A-v,y=AmCharts.toCoordinate(this.baseWidth,v),l=AmCharts.toCoordinate(this.neckWidth,v),z=g-q-a,w=AmCharts.toCoordinate(this.neckHeight,
3 z),r=a+z-w;k&&(a=g-q,r=a-z+w);this.firstSliceY=a;AmCharts.VML&&(this.startAlpha=1);for(var h=v/2+A,E=(z-w)/((y-l)/2),m=y/2,y=(z-w)*(y+l)/2+l*w,B=a,F=0,w=0;w<u.length;w++){var c=u[w],d;if(!0!==c.hidden){var n=[],e=[],b;if("height"==this.valueRepresents)b=z*c.percents/100;else{var p=-y*c.percents/100/2,C=m;d=-1/(2*E);b=Math.pow(C,2)-4*d*p;0>b&&(b=0);b=(Math.sqrt(b)-C)/(2*d);if(!k&&a>=r||k&&a<=r)b=2*-p/l;else if(!k&&a+b>r||k&&a-b<r)d=k?Math.round(b+(a-b-r)):Math.round(b-(a+b-r)),b=d/E,b=d+2*(-p-(C-b/
4 2)*d)/l}p=m-b/E;C=!1;!k&&a+b>r||k&&a-b<r?(p=l/2,n.push(h-m,h+m,h+p,h+p,h-p,h-p),k?(d=b+(a-b-r),a<r&&(d=0),e.push(a,a,a-d,a-b,a-b,a-d,a)):(d=b-(a+b-r),a>r&&(d=0),e.push(a,a,a+d,a+b,a+b,a+d,a)),C=!0):(n.push(h-m,h+m,h+p,h-p),k?e.push(a,a,a-b,a-b):e.push(a,a,a+b,a+b));t.set();d=t.set();n=AmCharts.polygon(t,n,e,c.color,c.alpha,this.outlineThickness,this.outlineColor,this.outlineAlpha);d.push(n);this.graphsSet.push(d);c.wedge=d;c.index=w;if(e=this.gradientRatio){var s=[],f;for(f=0;f<e.length;f++)s.push(AmCharts.adjustLuminosity(c.color,
5 e[f]));0<s.length&&n.gradient("linearGradient",s);c.pattern&&n.pattern(c.pattern)}0<D&&(this.chartCreated||d.setAttr("opacity",this.startAlpha));this.addEventListeners(d,c);c.ty0=a-b/2;this.labelsEnabled&&this.labelText&&c.percents>=this.hideLabelsPercent&&(e=this.formatString(this.labelText,c),(n=this.labelFunction)&&(e=n(c,e)),s=c.labelColor,s||(s=this.color),n=this.labelPosition,f="left","center"==n&&(f="middle"),"left"==n&&(f="right"),e=AmCharts.wrappedText(t,e,s,this.fontFamily,this.fontSize,
6 f,!1,this.maxLabelWidth),e.node.style.pointerEvents="none",d.push(e),s=h,k?(f=a-b/2,c.ty0=f):(f=a+b/2,c.ty0=f,f<B+F+5&&(f=B+F+5),f>g-q&&(f=g-q)),"right"==n&&(s=v+10+A,c.tx0=h+(m-b/2/E),C&&(c.tx0=h+p)),"left"==n&&(c.tx0=h-(m-b/2/E),C&&(c.tx0=h-p),s=A),c.label=e,c.labelX=s,c.labelY=f,c.labelHeight=e.getBBox().height,e.translate(s,f),m=e.getBBox(),B=AmCharts.rect(t,m.width+5,m.height+5,"#ffffff",.005),B.translate(s+m.x,f+m.y),d.push(B),c.hitRect=B,F=e.getBBox().height,B=f);(0===c.alpha||0<D&&!this.chartCreated)&&
7 d.hide();a=k?a-b:a+b;m=p;c.startX=AmCharts.toCoordinate(this.startX,x);c.startY=AmCharts.toCoordinate(this.startY,g);c.pullX=AmCharts.toCoordinate(this.pullDistance,x);c.pullY=0;c.balloonX=h;c.balloonY=c.ty0}}this.arrangeLabels();this.initialStart();(u=this.legend)&&u.invalidateSize()}else this.cleanChart();this.dispDUpd();this.chartCreated=!0},arrangeLabels:function(){var u=this.rotate,t;t=u?0:this.realHeight;for(var D=0,k=this.chartData,x=k.length,g,q=0;q<x;q++){g=k[x-q-1];var A=g.label,v=g.labelY,
8 a=g.labelX,y=g.labelHeight,l=v;u?t+D+5>v&&(l=t+D+5):v+y+5>t&&(l=t-5-y);t=l;D=y;if(A){A.translate(a,l);var z=A.getBBox()}g.hitRect.translate(a+z.x,l+z.y);g.labelY=l;g.tx=a;g.ty=l;g.tx2=a}"center"!=this.labelPosition&&this.drawTicks()}});
amcharts/gauge.js
File was created 1 AmCharts.GaugeAxis=AmCharts.Class({construct:function(a){this.cname="GaugeAxis";this.radius="95%";this.startAngle=-120;this.endAngle=120;this.startValue=0;this.endValue=200;this.gridCount=5;this.tickLength=10;this.minorTickLength=5;this.tickColor="#555555";this.labelFrequency=this.tickThickness=this.tickAlpha=1;this.inside=!0;this.labelOffset=10;this.showLastLabel=this.showFirstLabel=!0;this.axisThickness=1;this.axisColor="#000000";this.axisAlpha=1;this.gridInside=!0;this.topTextYOffset=0;this.topTextBold=
2 !0;this.bottomTextYOffset=0;this.bottomTextBold=!0;this.centerY=this.centerX="0%";this.bandOutlineAlpha=this.bandOutlineThickness=0;this.bandOutlineColor="#000000";this.bandAlpha=1;AmCharts.applyTheme(this,a,"GaugeAxis")},value2angle:function(a){return(a-this.startValue)/(this.endValue-this.startValue)*(this.endAngle-this.startAngle)+this.startAngle},setTopText:function(a){if(void 0!==a){this.topText=a;var b=this.chart;if(this.axisCreated){this.topTF&&this.topTF.remove();var c=this.topTextFontSize;
3 c||(c=b.fontSize);var d=this.topTextColor;d||(d=b.color);a=AmCharts.text(b.container,a,d,b.fontFamily,c,void 0,this.topTextBold);a.translate(this.centerXReal,this.centerYReal-this.radiusReal/2+this.topTextYOffset);this.chart.graphsSet.push(a);this.topTF=a}}},setBottomText:function(a){if(void 0!==a){this.bottomText=a;var b=this.chart;if(this.axisCreated){this.bottomTF&&this.bottomTF.remove();var c=this.bottomTextFontSize;c||(c=b.fontSize);var d=this.bottomTextColor;d||(d=b.color);a=AmCharts.text(b.container,
4 a,d,b.fontFamily,c,void 0,this.bottomTextBold);a.translate(this.centerXReal,this.centerYReal+this.radiusReal/2+this.bottomTextYOffset);this.bottomTF=a;this.chart.graphsSet.push(a)}}},draw:function(){var a=this.chart,b=a.graphsSet,c=this.startValue,d=this.endValue,f=this.valueInterval;isNaN(f)&&(f=(d-c)/this.gridCount);var m=this.minorTickInterval;isNaN(m)&&(m=f/5);var p=this.startAngle,k=this.endAngle,e=this.tickLength,l=(d-c)/f+1,g=(k-p)/(l-1);this.singleValueAngle=d=g/f;var h=a.container,q=this.tickColor,
5 u=this.tickAlpha,C=this.tickThickness,D=f/m,F=g/D,m=this.minorTickLength,I=this.labelFrequency,s=this.radiusReal;this.inside||(s-=15);var y=a.centerX+AmCharts.toCoordinate(this.centerX,a.realWidth),z=a.centerY+AmCharts.toCoordinate(this.centerY,a.realHeight);this.centerXReal=y;this.centerYReal=z;var J={fill:this.axisColor,"fill-opacity":this.axisAlpha,"stroke-width":0,"stroke-opacity":0},n,A;this.gridInside?A=n=s:(n=s-e,A=n+m);var r=this.axisThickness/2,k=AmCharts.wedge(h,y,z,p,k-p,n+r,n+r,n-r,0,
6 J);b.push(k);k=AmCharts.doNothing;AmCharts.isModern||(k=Math.round);J=AmCharts.getDecimals(f);for(n=0;n<l;n++){var w=c+n*f,r=p+n*g,v=k(y+s*Math.sin(r/180*Math.PI)),B=k(z-s*Math.cos(r/180*Math.PI)),x=k(y+(s-e)*Math.sin(r/180*Math.PI)),t=k(z-(s-e)*Math.cos(r/180*Math.PI)),v=AmCharts.line(h,[v,x],[B,t],q,u,C,0,!1,!1,!0);b.push(v);v=-1;x=this.labelOffset;this.inside||(x=-x-e,v=1);var B=Math.sin(r/180*Math.PI),t=Math.cos(r/180*Math.PI),B=y+(s-e-x)*B,x=z-(s-e-x)*t,E=this.fontSize;isNaN(E)&&(E=a.fontSize);
7 var t=Math.sin((r-90)/180*Math.PI),K=Math.cos((r-90)/180*Math.PI);if(0<I&&n/I==Math.round(n/I)&&(this.showLastLabel||n!=l-1)&&(this.showFirstLabel||0!==n)){var G=AmCharts.formatNumber(w,a.nf,J),H=this.unit;H&&(G="left"==this.unitPosition?H+G:G+H);(H=this.labelFunction)&&(G=H(w));w=AmCharts.text(h,G,a.color,a.fontFamily,E);E=w.getBBox();w.translate(B+v*E.width/2*K,x+v*E.height/2*t);b.push(w)}if(n<l-1)for(w=1;w<D;w++)t=r+F*w,v=k(y+A*Math.sin(t/180*Math.PI)),B=k(z-A*Math.cos(t/180*Math.PI)),x=k(y+(A-
8 m)*Math.sin(t/180*Math.PI)),t=k(z-(A-m)*Math.cos(t/180*Math.PI)),v=AmCharts.line(h,[v,x],[B,t],q,u,C,0,!1,!1,!0),b.push(v)}if(b=this.bands)for(c=0;c<b.length;c++)if(f=b[c])q=f.startValue,u=f.endValue,e=AmCharts.toCoordinate(f.radius,s),isNaN(e)&&(e=A),l=AmCharts.toCoordinate(f.innerRadius,s),isNaN(l)&&(l=e-m),g=p+d*(q-this.startValue),u=d*(u-q),C=f.outlineColor,void 0==C&&(C=this.bandOutlineColor),D=f.outlineThickness,isNaN(D)&&(D=this.bandOutlineThickness),F=f.outlineAlpha,isNaN(F)&&(F=this.bandOutlineAlpha),
9 q=f.alpha,isNaN(q)&&(q=this.bandAlpha),e=AmCharts.wedge(h,y,z,g,u,e,e,l,0,{fill:f.color,stroke:C,"stroke-width":D,"stroke-opacity":F}),e.setAttr("opacity",q),a.gridSet.push(e),this.addEventListeners(e,f);this.axisCreated=!0;this.setTopText(this.topText);this.setBottomText(this.bottomText);a=a.graphsSet.getBBox();this.width=a.width;this.height=a.height},addEventListeners:function(a,b){var c=this.chart;a.mouseover(function(a){c.showBalloon(b.balloonText,b.color,!0)}).mouseout(function(a){c.hideBalloon()})}});AmCharts.GaugeArrow=AmCharts.Class({construct:function(a){this.cname="GaugeArrow";this.color="#000000";this.nailAlpha=this.alpha=1;this.startWidth=this.nailRadius=8;this.endWidth=0;this.borderAlpha=1;this.radius="90%";this.nailBorderAlpha=this.innerRadius=0;this.nailBorderThickness=1;this.frame=0;AmCharts.applyTheme(this,a,"GaugeArrow")},setValue:function(a){var b=this.chart;b?b.setValue?b.setValue(this,a):this.previousValue=this.value=a:this.previousValue=this.value=a}});
10 AmCharts.GaugeBand=AmCharts.Class({construct:function(){this.cname="GaugeBand"}});AmCharts.AmAngularGauge=AmCharts.Class({inherits:AmCharts.AmChart,construct:function(a){this.cname="AmAngularGauge";AmCharts.AmAngularGauge.base.construct.call(this,a);this.theme=a;this.type="gauge";this.minRadius=this.marginRight=this.marginBottom=this.marginTop=this.marginLeft=10;this.faceColor="#FAFAFA";this.faceAlpha=0;this.faceBorderWidth=1;this.faceBorderColor="#555555";this.faceBorderAlpha=0;this.arrows=[];this.axes=[];this.startDuration=1;this.startEffect="easeOutSine";this.adjustSize=!0;
11 this.extraHeight=this.extraWidth=0;AmCharts.applyTheme(this,a,this.cname)},addAxis:function(a){this.axes.push(a)},formatString:function(a,b){return a=AmCharts.formatValue(a,b,["value"],this.nf,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers)},initChart:function(){AmCharts.AmAngularGauge.base.initChart.call(this);var a;0===this.axes.length&&(a=new AmCharts.GaugeAxis(this.theme),this.addAxis(a));var b;for(b=0;b<this.axes.length;b++)a=this.axes[b],a=AmCharts.processObject(a,
12 AmCharts.GaugeAxis,this.theme),a.chart=this,this.axes[b]=a;var c=this.arrows;for(b=0;b<c.length;b++){a=c[b];a=AmCharts.processObject(a,AmCharts.GaugeArrow,this.theme);a.chart=this;c[b]=a;var d=a.axis;AmCharts.isString(d)&&(a.axis=AmCharts.getObjById(this.axes,d));a.axis||(a.axis=this.axes[0]);isNaN(a.value)&&a.setValue(a.axis.startValue);isNaN(a.previousValue)&&(a.previousValue=a.axis.startValue)}this.setLegendData(c);this.drawChart();this.totalFrames=1E3*this.startDuration/AmCharts.updateRate},drawChart:function(){AmCharts.AmAngularGauge.base.drawChart.call(this);
13 var a=this.container,b=this.updateWidth();this.realWidth=b;var c=this.updateHeight();this.realHeight=c;var d=AmCharts.toCoordinate,f=d(this.marginLeft,b),m=d(this.marginRight,b),p=d(this.marginTop,c)+this.getTitleHeight(),k=d(this.marginBottom,c),e=d(this.radius,b,c),d=b-f-m,l=c-p-k+this.extraHeight;e||(e=Math.min(d,l)/2);e<this.minRadius&&(e=this.minRadius);this.radiusReal=e;this.centerX=(b-f-m)/2+f;this.centerY=(c-p-k)/2+p+this.extraHeight/2;isNaN(this.gaugeX)||(this.centerX=this.gaugeX);isNaN(this.gaugeY)||
14 (this.centerY=this.gaugeY);var b=this.faceAlpha,c=this.faceBorderAlpha,g;if(0<b||0<c)g=AmCharts.circle(a,e,this.faceColor,b,this.faceBorderWidth,this.faceBorderColor,c,!1),g.translate(this.centerX,this.centerY),g.toBack(),(a=this.facePattern)&&g.pattern(a);for(b=e=a=0;b<this.axes.length;b++){c=this.axes[b];f=c.radius;c.radiusReal=AmCharts.toCoordinate(f,this.radiusReal);c.draw();if(-1!==f.indexOf("%"))var h=1+(100-Number(f.substr(0,f.length-1)))/100;c.width*h>a&&(a=c.width*h);c.height*h>e&&(e=c.height*
15 h)}(h=this.legend)&&h.invalidateSize();if(this.adjustSize&&!this.chartCreated){g&&(g=g.getBBox(),g.width>a&&(a=g.width),g.height>e&&(e=g.height));g=0;if(l>e||d>a)g=Math.min(l-e,d-a);0<g&&(this.extraHeight=l-e,this.chartCreated=!0,this.validateNow())}this.dispDUpd();this.chartCreated=!0},validateSize:function(){this.extraHeight=this.extraWidth=0;this.chartCreated=!1;AmCharts.AmAngularGauge.base.validateSize.call(this)},addArrow:function(a){this.arrows.push(a)},removeArrow:function(a){AmCharts.removeFromArray(this.arrows,
16 a);this.validateNow()},removeAxis:function(a){AmCharts.removeFromArray(this.axes,a);this.validateNow()},drawArrow:function(a,b){a.set&&a.set.remove();var c=this.container;a.set=c.set();if(!a.hidden){var d=a.axis,f=d.radiusReal,m=d.centerXReal,p=d.centerYReal,k=a.startWidth,e=a.endWidth,l=AmCharts.toCoordinate(a.innerRadius,d.radiusReal),g=AmCharts.toCoordinate(a.radius,d.radiusReal);d.inside||(g-=15);var h=a.nailColor;h||(h=a.color);var q=a.nailColor;q||(q=a.color);h=AmCharts.circle(c,a.nailRadius,
17 h,a.nailAlpha,a.nailBorderThickness,h,a.nailBorderAlpha);a.set.push(h);h.translate(m,p);isNaN(g)&&(g=f-d.tickLength);var d=Math.sin(b/180*Math.PI),f=Math.cos(b/180*Math.PI),h=Math.sin((b+90)/180*Math.PI),u=Math.cos((b+90)/180*Math.PI),c=AmCharts.polygon(c,[m-k/2*h+l*d,m+g*d-e/2*h,m+g*d+e/2*h,m+k/2*h+l*d],[p+k/2*u-l*f,p-g*f+e/2*u,p-g*f-e/2*u,p-k/2*u-l*f],a.color,a.alpha,1,q,a.borderAlpha,void 0,!0);a.set.push(c);this.graphsSet.push(a.set)}},setValue:function(a,b){a.axis&&a.axis.value2angle&&(a.axis.value2angle(b),
18 a.frame=0,a.previousValue=a.value);a.value=b;var c=this.legend;c&&c.updateValues()},handleLegendEvent:function(a){var b=a.type;a=a.dataItem;if(!this.legend.data&&a)switch(b){case "hideItem":this.hideArrow(a);break;case "showItem":this.showArrow(a)}},hideArrow:function(a){a.set.hide();a.hidden=!0},showArrow:function(a){a.set.show();a.hidden=!1},updateAnimations:function(){AmCharts.AmAngularGauge.base.updateAnimations.call(this);for(var a=this.arrows.length,b,c=0;c<a;c++){b=this.arrows[c];var d;b.frame>=
19 this.totalFrames?d=b.value:(b.frame++,b.clockWiseOnly&&b.value<b.previousValue&&(d=b.axis,b.previousValue-=d.endValue-d.startValue),d=AmCharts.getEffect(this.startEffect),d=AmCharts[d](0,b.frame,b.previousValue,b.value-b.previousValue,this.totalFrames),isNaN(d)&&(d=b.value));d=b.axis.value2angle(d);this.drawArrow(b,d)}}});
amcharts/images/dragIcon.gif

122 Bytes

amcharts/images/dragIconBlack.gif

122 Bytes

amcharts/images/dragIconH.gif

111 Bytes

amcharts/images/dragIconHBlack.gif

111 Bytes

amcharts/images/export.png

216 Bytes

amcharts/images/exportWhite.png

213 Bytes

amcharts/images/lens.png

257 Bytes

amcharts/images/lensWhite.png

262 Bytes

amcharts/lang/az.js
File was created 1 AmCharts.translations.az = {"monthNames":["Yanvar","Fevral","Mart","Aprel","May","Iyun","Iyul","Avqust","Sentyabr","Oktyabr","Noyabr","Dekabr"],"shortMonthNames":["Yan","Fev","Mar","Apr","May","Iyn","Iyl","Avq","Sen","Okt","Noy","Dek"],"dayNames":["Bazar ertษ™si","ร‡ษ™rลŸษ™nbษ™ axลŸamฤฑ","ร‡ษ™rลŸษ™nbษ™","Cรผmษ™ axลŸamฤฑ","Cรผmษ™","ลžษ™nbษ™","Bazar gรผnรผ"],"shortDayNames":["Ber","ร‡ax","ร‡ษ™r","Cax","Cรผm","ลžnb","Baz"],"zoomOutText":"Bรผtรผn gรถstษ™r"}
amcharts/lang/bg.js
File was created 1 AmCharts.translations.bg = {"monthNames":["ะฏะฝัƒะฐั€ะธ","ะคะตะฒั€ัƒะฐั€ะธ","ะœะฐั€ั‚","ะะฟั€ะธะป","ะœะฐะน","ะฎะฝะธ","ะฎะปะธ","ะะฒะณัƒัั‚","ะกะตะฟั‚ะตะผะฒั€ะธ","ะžะบั‚ะพะผะฒั€ะธ","ะะพะตะผะฒั€ะธ","ะ”ะตะบะตะผะฒั€ะธ"],"shortMonthNames":["ะฏะฝัƒ","ะคะตะฒ","ะœะฐั€","ะะฟั€","ะœะฐะน","ะฎะฝะธ","ะฎะปะธ","ะะฒะณ","ะกะตะฟ","ะžะบั‚","ะะพะต","ะ”ะตะบ"],"dayNames":["ะŸะพะฝะตะดะตะปะฝะธะบ","ะ’ั‚ะพั€ะฝะธะบ","ะกั€ัะดะฐ","ะงะตั‚ะฒัŠั€ั‚ัŠะบ","ะŸะตั‚ัŠะบ","ะกัŠะฑะพั‚ะฐ","ะะตะดะตะปั"],"shortDayNames":["ะŸะฝ","ะ’ั‚","ะกั€","ะงั‚","ะŸั‚","ะกะฑ","ะะด"],"zoomOutText":"ะŸะพะบะฐะถะธ ะฒัะธั‡ะบะธ"}
amcharts/lang/de.js
File was created 1 AmCharts.translations.de = {
2 "monthNames": ["Januar", "Februar", "Mรคrz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
3 "shortMonthNames": ["Jan", "Feb", "Mรคr", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
4 "dayNames": ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
5 "shortDayNames": ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
6 "zoomOutText": "Alle anzeigen",
7 "fromText": "Von:",
8 "toText":"Bis:",
9 "periodsText":"Ansicht:",
10 "selectText":"Auswahl:",
11 "comboBoxSelectText":"Auswahl...",
12 "compareText":"Vergleichen mit:"
13 }
amcharts/lang/es.js
File was created 1 AmCharts.translations.es = {"monthNames":["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],"shortMonthNames":["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],"dayNames":["Lunes","Martes","Miรฉrcoles","Jueves","Viernes","Sรกbado","Domingo"],"shortDayNames":["Lun","Mar","Miรฉ","Jue","Vie","Sรกb","Dom"],"zoomOutText":"Mostrar todos"}
amcharts/lang/fi.js
File was created 1 AmCharts.translations.fi = {"monthNames":["Tammikuu","Helmikuu","Maaliskuu","Huhtikuu","Toukokuu","Kesรคkuu","Heinรคkuu","Elokuu","Syyskuu","Lokakuu","Marraskuu","Joulukuu"],"shortMonthNames":["Tammiย ","Helmiย ","Maalis","Huhtiย ","Toukoย ","Kesรคย ย ","Heinรคย ","Eloย ย ย ","Syysย ย ","Lokaย ย ","Marras","Jouluย "],"dayNames":["Maanantai","Tiistai","Keskiviikko","Torstai","Perjantai","Lauantai","Sunnuntai"],"shortDayNames":["Ma","Ti","Ke","To","Pe","La","Su"],"zoomOutText":"Nรคytรค kaikki"}
amcharts/lang/fo.js
File was created 1 AmCharts.translations.fo = {"monthNames":["Januar","Februar","Mars","Aprรญl","Mai","Juni","Juli","August","September","Oktober","November","Desember"],"shortMonthNames":["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],"dayNames":["Mรกnadagur","Tรฝsdagur","Mikudagur","Hรณsdagur","Frรญggjadagur","Leygardagur","Sunnudagur"],"shortDayNames":["Mรกn","Tรฝs","Mik","Hรณs","Frรญ","Ley","Sun"],"zoomOutText":"Show all"}
amcharts/lang/fr.js
File was created 1 AmCharts.translations.fr = {"monthNames":["Janvier","Fรฉvrier","Mars","Avril","Mai","Juin","Juillet","Aoรปt","Septembre","Octobre","Novembre","Dรฉcembre"],"shortMonthNames":["Janv.","Fรฉvr.","Mars","Avril","Mai","Juin","Juil.","Aoรปt","Sept.","Oct.","Nov.","Dรฉc."],"dayNames":["Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"],"shortDayNames":["Lun.","Mar.","Mer.","Jeu.","Ven.","Sam.","Dim."],"zoomOutText":"Voir tous"}
amcharts/lang/hr.js
File was created 1 AmCharts.translations.hr = {"monthNames":["Sijeฤanj","Veljaฤa","Oลพujak","Travanj","Svibanj","Lipanj","Srpanj","Kolovoz","Rujan","Listopad","Studeni","Prosinac"],"shortMonthNames":["Sij","Vel","Oลพu","Tra","Svi","Lip","Srp","Kol","Ruj","Lis","Stu","Pro"],"dayNames":["Ponedjeljak","Utorak","Srijeda","ฤŒetvrtak","Petak","Subota","Nedjelja"],"shortDayNames":["Pon","Uto","Sri","ฤŒet","Pet","Sub","Ned"],"zoomOutText":"Prikaลพi sve"}
amcharts/lang/hu.js
File was created 1 AmCharts.translations.hu = {"monthNames":["Januรกr","Februรกr","Mรกrcius","รprilis","Mรกjus","Jรบnius","Jรบlius","Augusztus","Szeptember","Oktรณber","November","December"],"shortMonthNames":["Jan","Febr","Mรกrc","รpr","Mรกj","Jรบn","Jรบl","Aug","Szept","Okt","Nov","Dec"],"dayNames":["Hรฉtfล‘","Kedd","Szerda","Csรผtรถrtรถk","Pรฉntek","Szombat","Vasรกrnap"],"shortDayNames":["H","K","Sze","Cs","P","Szo","V"],"zoomOutText":"ร–sszes"}
amcharts/lang/id.js
File was created 1 AmCharts.translations.id = {"monthNames":["Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"],"shortMonthNames":["Jan","Peb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],"dayNames":["Senin","Selasa","Rabu","Kamis","Jumat","Sabtu","Minggu"],"shortDayNames":["Sen","Sel","Rab","Kam","Jum","Sab","Min"],"zoomOutText":"Tampilkan semua"}
amcharts/lang/is.js
File was created 1 AmCharts.translations.is = {"monthNames":["Janรบar","Febrรบar","Mars","Aprรญl","Maรญ","Jรบnรญ","Jรบlรญ","รgรบst","September","Oktรณber","Nรณvember","Desember"],"shortMonthNames":["Jan","Feb","Mar","Apr","Maรญ","Jรบn","Jรบl","รgรบ","Sep","Okt","Nรณv","Des"],"dayNames":["Mรกnudagur","รžriรฐjudagur","Miรฐvikudagur","Fimmtudagur","Fรถstudagur","Laugardagur","Sunnudagur"],"shortDayNames":["Mรกn","รžri","Miรฐ","Fim","Fรถs","Lau","Sun"],"zoomOutText":"Sรฝna allt"}
amcharts/lang/it.js
File was created 1 AmCharts.translations.it = {"monthNames":["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],"shortMonthNames":["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],"dayNames":["Lunedรฌ","Martedรฌ","Mercoledรฌ","Giovedรฌ","Venerdรฌ","Sabato","Domenica"],"shortDayNames":["Lun","Mar","Mer","Gio","Ven","Sab","Dom"],"zoomOutText":"Mostra tutti"}
amcharts/lang/lt.js
File was created 1 AmCharts.translations.lt = {"monthNames":["Sausio","Vasario","Kovo","Balandลพio","Geguลพฤ—s","Birลพelio","Liepos","Rugpjลซฤio","Rugsฤ—jo","Spalio","Lapkriฤio","Gruodลพio"],"shortMonthNames":["Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rgp","Rgs","Spa","Lap","Grd"],"dayNames":["Pirmadienis","Antradienis","Treฤiadienis","Ketvirtadienis","Penktadienis","ล eลกtadienis","Sekmadienis"],"shortDayNames":["Pr","An","Tr","Kt","Pn","ล t","Sk"],"zoomOutText":"Rodyti viskฤ…"}
amcharts/lang/lv.js
File was created 1 AmCharts.translations.lv = {"monthNames":["Janvฤris","Februฤris","Marts","Aprฤซlis","Maijs","Jลซnijs","Jลซlijs","Augusts","Septembris","Oktobris","Novembris","Decembris"],"shortMonthNames":["Jan","Feb","Mar","Apr","Mai","Jลซn","Jลซl","Aug","Sep","Okt","Nov","Dec"],"dayNames":["Pirmdiena","Otrdiena","Treลกdiena","Ceturtdiena","Piektdiena","Sestdiena","Svฤ“tdiena"],"shortDayNames":["Pย ","Oย ","Tย ","Cย ","Pk","Sย ","Sv"],"zoomOutText":"Parฤdฤซt visu"}
amcharts/lang/mk.js
File was created 1 AmCharts.translations.mk = {"monthNames":["ะˆะฐะฝัƒะฐั€ะธ","ะคะตะฒั€ัƒะฐั€ะธ","ะœะฐั€ั‚","ะะฟั€ะธะป","ะœะฐั˜","ะˆัƒะฝะธ","ะˆัƒะปะธ","ะะฒะณัƒัั‚","ะกะตะฟั‚ะตะผะฒั€ะธ","ะžะบั‚ะพะผะฒั€ะธ","ะะพะตะผะฒั€ะธ","ะ”ะตะบะตะผะฒั€ะธ"],"shortMonthNames":["ะˆะฐะฝ","ะคะตะฒ","ะœะฐั€","ะะฟั€","ะœะฐั˜","ะˆัƒะฝ","ะˆัƒะป","ะะฒะณ","ะกะตะฟ","ะžะบั‚","ะะพะต","ะ”ะตะบ"],"dayNames":["ะŸะพะฝะตะดะตะปะฝะธะบ","ะ’ั‚ะพั€ะฝะธะบ","ะกั€ะตะดะฐ","ะงะตั‚ะฒั€ั‚ะพะบ","ะŸะตั‚ะพะบ","ะกะฐะฑะพั‚ะฐ","ะะตะดะตะปะฐ"],"shortDayNames":["ะŸะพะฝ","ะ’ั‚ะพ","ะกั€ะต","ะงะตั‚","ะŸะตั‚","ะกะฐะฑ","ะะตะด"],"zoomOutText":"ะŸั€ะธะบะฐะถะธ ะณะธ ัะธั‚ะต"}
amcharts/lang/mn.js
File was created 1 AmCharts.translations.mn = {"monthNames":["ะฅัƒะปะณะฐะฝะฐ ัะฐั€ั‹ะฝ","าฎั…ัั€ ัะฐั€ั‹ะฝ","ะ‘ะฐั€ ัะฐั€ั‹ะฝ","ะขัƒัƒะปะฐะน ัะฐั€ั‹ะฝ","ะ›ัƒัƒ ัะฐั€ั‹ะฝ","ะœะพะณะพะน ัะฐั€ั‹ะฝ","ะœะพั€ัŒ ัะฐั€ั‹ะฝ","ะฅะพะฝัŒ ัะฐั€ั‹ะฝ","ะ‘ะธั‡ ัะฐั€ั‹ะฝ","ะขะฐั…ะธะฐ ัะฐั€ั‹ะฝ","ะะพั…ะพะน ัะฐั€ั‹ะฝ","ะ“ะฐั…ะฐะน ัะฐั€ั‹ะฝ"],"shortMonthNames":["ะฅัƒะป","าฎั…ั","ะ‘ะฐั€","ะขัƒัƒ","ะ›ัƒัƒ","ะœะพะณ","ะœะพั€","ะฅะพะฝ","ะ‘ะธั‡","ะขะฐั…","ะะพั…","ะ“ะฐั…"],"dayNames":["ะ”ะฐะฒะฐะฐ","ะœัะณะผะฐั€","ะ›ั…ะฐะณะฒะฐ","ะŸาฏั€ัะฒ","ะ‘ะฐะฐัะฐะฝ","ะ‘ัะผะฑะฐ","ะัะผ"],"shortDayNames":["ะ”ะฐ","ะœั","ะ›ั…","ะŸาฏ","ะ‘ะฐ","ะ‘ั","ะั"],"zoomOutText":"ะ‘าฏั… ั…ะฐั€ัƒัƒะปะฐั…"}
amcharts/lang/mt.js
File was created 1 AmCharts.translations.mt = {"monthNames":["Jannar","Frar","Marzu","April","Mejju","ฤ unju","Lulju","Awwissu","Settembru","Ottubru","Novembru","Diฤ‹embru "],"shortMonthNames":["Jan","Fra","Mar","Apr","Mej","ฤ un","Lul","Aww","Set","Ott","Nov","Diฤ‹"],"dayNames":["It-tnejn","It-tlieta","L-erbgฤงa","Il-ฤงamis","Il-ฤกimgฤงa","Is-sibt","Il-ฤงadd"],"shortDayNames":["Tne","Tli","Erb","ฤฆam","ฤ im","Sib","ฤฆad"],"zoomOutText":"Turi kollha"}
amcharts/lang/nl.js
File was created 1 AmCharts.translations.nl = {"monthNames":["Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December"],"shortMonthNames":["Jan","Feb","Mrt","Apr","Mei","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],"dayNames":["Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag","Zondag"],"shortDayNames":["Ma","Di","Wo","Do","Vr","Za","Zo"],"zoomOutText":"Alles weergeven"}
amcharts/lang/no.js
File was created 1 AmCharts.translations.no = {"monthNames":["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],"shortMonthNames":["Jan.","Feb.","Mars","April","Mai","Juni","Juli","Aug.","Sep.","Okt.","Nov.","Des."],"dayNames":["Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lรธrdag","Sรธndag"],"shortDayNames":["Ma.","Ti.","On.","To.","Fr.","Lรธ.","Sรธ."],"zoomOutText":"Vis alle"}
amcharts/lang/pl.js
File was created 1 AmCharts.translations.pl = {"monthNames":["Styczeล„","Luty","Marzec","Kwiecieล„","Maj","Czerwiec","Lipiec","Sierpieล„","Wrzesieล„","Paลบdziernik","Listopad","Grudzieล„"],"shortMonthNames":["Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paลบ","Lis","Gru"],"dayNames":["Poniedziaล‚ek","Wtorek","ลšroda","Czwartek","Piฤ…tek","Sobota","Niedziela"],"shortDayNames":["Pon","Wto","ลšro","Czw","Piฤ…","Sob","Nie"],"zoomOutText":"Pokaลผ wszystko"}
amcharts/lang/pt.js
File was created 1 AmCharts.translations.pt = {"monthNames":["Janeiro","Fevereiro","Marรงo","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],"shortMonthNames":["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],"dayNames":["Segunda","Terรงa","Quarta","Quinta","Sexta","Sรกbado","Domingo"],"shortDayNames":["Seg","Ter","Qua","Qui","Sex","Sรกb","Dom"],"zoomOutText":"Mostrar todos"}
amcharts/lang/ro.js
File was created 1 AmCharts.translations.ro = {"monthNames":["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"],"shortMonthNames":["Ian","Feb","Mar","Apr","Mai","Iun","Iul","Aug","Sep","Oct","Nov","Dec"],"dayNames":["Luni","Marลฃi","Miercuri","Joi","Vineri","Sรขmbฤƒtฤƒ","Duminicฤƒ"],"shortDayNames":["Lu","Ma","Mi","Jo","Vi","Sb","Du"],"zoomOutText":"Aratฤƒ tot"}
amcharts/lang/ru.js
File was created 1 AmCharts.translations.ru = {"monthNames":["ะฏะฝะฒะฐั€ัŒ","ะคะตะฒั€ะฐะปัŒ","ะœะฐั€ั‚","ะะฟั€ะตะปัŒ","ะœะฐะน","ะ˜ัŽะฝัŒ","ะ˜ัŽะปัŒ","ะะฒะณัƒัั‚","ะกะตะฝั‚ัะฑั€ัŒ","ะžะบั‚ัะฑั€ัŒ","ะะพัะฑั€ัŒ","ะ”ะตะบะฐะฑั€ัŒ"],"shortMonthNames":["ะฏะฝะฒ","ะคะตะฒ","ะœะฐั€","ะะฟั€","ะœะฐะน","ะ˜ัŽะฝ","ะ˜ัŽะป","ะะฒะณ","ะกะตะฝ","ะžะบั‚","ะะพั","ะ”ะตะบ"],"dayNames":["ะŸะพะฝะตะดะตะปัŒะฝะธะบ","ะ’ั‚ะพั€ะฝะธะบ","ะกั€ะตะดะฐ","ะงะตั‚ะฒะตั€ะณ","ะŸัั‚ะฝะธั†ะฐ","ะกัƒะฑะฑะพั‚ะฐ","ะ’ะพัะบั€ะตัะตะฝัŒะต"],"shortDayNames":["ะŸะฝะด","ะ’ั‚ั€","ะกั€ะด","ะงั‚ะฒ","ะŸั‚ะฝ","ะกะฑั‚","ะ’ัะบ"],"zoomOutText":"ะŸะพะบะฐะทะฐั‚ัŒ ะฒัะต"}
amcharts/lang/rw.js
File was created 1 AmCharts.translations.rw = {"monthNames":["Mutarama","Gashyantare","Werurwe","Mata","Gicuransi","Kamena","Nyakanga","Kanama","Nzeli","Ukwakira","Ugushyingo","Ukuboza"],"shortMonthNames":["Mut","Gas","Wer","Mat","Gic","Kam","Nya","Kan","Nze","Ukw","Ugu","Uku"],"dayNames":["Kuwa mbere","Kuwa kabiri","Kuwa gatatu","Kuwa kane","Kuwa gatanu","Kuwa gatandatu","Ku cyumweru"],"shortDayNames":["Mbe","Kab","Gtu","Kan","Gnu","Gnd","Mwe"],"zoomOutText":"Show all"}
amcharts/lang/sk.js
File was created 1 AmCharts.translations.sk = {"monthNames":["Januรกr","Februรกr","Marec","Aprรญl","Mรกj","Jรบn","Jรบl","August","September","Oktรณber","November","December"],"shortMonthNames":["Jan","Feb","Mar","Apr","Mรกj","Jรบn","Jรบl","Aug","Sep","Okt","Nov","Dec"],"dayNames":["Pondelok","Utorok","Streda","ล tvrtok","Piatok","Sobota","Nedeฤพa"],"shortDayNames":["Po","Ut","St","ล t","Pi","So","Ne"],"zoomOutText":"Zobraziลฅ vลกetky"}
amcharts/lang/so.js
File was created 1 AmCharts.translations.so = {"monthNames":["Bisha koobaad","Bisha labaad","Bisha saddexaad","Bisha afraad","Bisha shanaad","Bisha lixaad","Bisha todobaad","Bisha sideedaad","Bisha sagaalaad","Bisha tobnaad","Bisha kow iyo tobnaad","Bisha laba iyo tobnaad"],"shortMonthNames":["Kob","Lab","Sad","Afr","Sha","Lix","Tod","Sid","Sag","Tob","Kit","Lit"],"dayNames":["Isniin","Salaaso","Arbaco","Khamiis","Jimco","Sabti","Axad"],"shortDayNames":["Isn","Sal","Arb","Kha","Jim","Sab","Axa"],"zoomOutText":"Tus dhammaan"}
amcharts/lang/th.js
File was created 1 AmCharts.translations.th = {"monthNames":["เธกเธเธฃเธฒเธ„เธก","เธเธธเธกเธ เธฒเธžเธฑเธ™เธ˜เนŒ","เธกเธตเธ™เธฒเธ„เธก","เน€เธกเธฉเธฒเธขเธ™","เธžเธคเธฉเธ เธฒเธ„เธก","เธกเธดเธ–เธธเธ™เธฒเธขเธ™","เธเธฃเธเธŽเธฒเธ„เธก","เธชเธดเธ‡เธซเธฒเธ„เธก","เธเธฑเธ™เธขเธฒเธขเธ™","เธ•เธธเธฅเธฒเธ„เธก","เธžเธคเธจเธˆเธดเธเธฒเธขเธ™","เธ˜เธฑเธ™เธงเธฒเธ„เธก"],"shortMonthNames":["เธก.เธ„.","เธ.เธž.","เธกเธต.เธ„.","เน€เธก.เธข.","เธž.เธ„.","เธกเธด.เธข.","เธ.เธ„.","เธช.เธ„.","เธ.เธข.","เธ•.เธ„.","เธž.เธข.","เธ˜.เธ„."],"dayNames":["เธˆเธฑเธ™เธ—เธฃเนŒ","เธญเธฑเธ‡เธ„เธฒเธฃ","เธžเธธเธ˜","เธžเธคเธซเธฑเธชเธšเธ”เธต","เธจเธธเธเธฃเนŒ","เน€เธชเธฒเธฃเนŒ","เธญเธฒเธ—เธดเธ•เธขเนŒ"],"shortDayNames":["เธˆ.","เธญ.","เธž.","เธžเธค.","เธจ.","เธช.","เธญเธฒ."],"zoomOutText":"เนเธชเธ”เธ‡เธ—เธฑเน‰เธ‡เธซเธกเธ”"}
amcharts/lang/tr.js
File was created 1 AmCharts.translations.tr = {"monthNames":["Ocak","ลžubat","Mart","Nisan","Mayฤฑs","Haziran","Temmuz","AฤŸustos","Eylรผl","Ekim","Kasฤฑm","Aralฤฑk"],"shortMonthNames":["Oca","ลžub","Mar","Nis","May","Haz","Tem","AฤŸu","Eyl","Eki","Kas","Ara"],"dayNames":["Pazartesi","Salฤฑ","ร‡arลŸamba","PerลŸembe","Cuma","Cumartesi","Pazar"],"shortDayNames":["Pzt","Sal","ร‡rลŸ","PrลŸ","Cum","Cts","Paz"],"zoomOutText":"Tรผmรผnรผ gรถster"}
amcharts/patterns/black/pattern1.png

158 Bytes

amcharts/patterns/black/pattern10.png

155 Bytes

amcharts/patterns/black/pattern11.png

161 Bytes

amcharts/patterns/black/pattern12.png

161 Bytes

amcharts/patterns/black/pattern13.png

153 Bytes

amcharts/patterns/black/pattern14.png

160 Bytes

amcharts/patterns/black/pattern15.png

157 Bytes

amcharts/patterns/black/pattern16.png

160 Bytes

amcharts/patterns/black/pattern17.png

162 Bytes

amcharts/patterns/black/pattern18.png

155 Bytes

amcharts/patterns/black/pattern19.png

160 Bytes

amcharts/patterns/black/pattern2.png

161 Bytes

amcharts/patterns/black/pattern20.png

161 Bytes

amcharts/patterns/black/pattern21.png

158 Bytes

amcharts/patterns/black/pattern3.png

156 Bytes

amcharts/patterns/black/pattern4.png

154 Bytes

amcharts/patterns/black/pattern5.png

158 Bytes

amcharts/patterns/black/pattern6.png

155 Bytes

amcharts/patterns/black/pattern7.png

153 Bytes

amcharts/patterns/black/pattern8.png

160 Bytes

amcharts/patterns/black/pattern9.png

153 Bytes

amcharts/patterns/chalk/pattern1.jpg

113 KB

amcharts/patterns/chalk/pattern1r.jpg

111 KB

amcharts/patterns/chalk/pattern2.jpg

114 KB

amcharts/patterns/chalk/pattern3.jpg

160 KB

amcharts/patterns/chalk/pattern4.jpg

160 KB

amcharts/patterns/chalk/pattern5.jpg

173 KB

amcharts/patterns/chalk/pattern6.jpg

143 KB

amcharts/patterns/white/pattern1.png

156 Bytes

amcharts/patterns/white/pattern10.png

155 Bytes

amcharts/patterns/white/pattern11.png

159 Bytes

amcharts/patterns/white/pattern12.png

160 Bytes

amcharts/patterns/white/pattern13.png

154 Bytes

amcharts/patterns/white/pattern14.png

161 Bytes

amcharts/patterns/white/pattern15.png

155 Bytes

amcharts/patterns/white/pattern16.png

158 Bytes

amcharts/patterns/white/pattern17.png

158 Bytes

amcharts/patterns/white/pattern18.png

155 Bytes

amcharts/patterns/white/pattern19.png

159 Bytes

amcharts/patterns/white/pattern2.png

157 Bytes

amcharts/patterns/white/pattern20.png

158 Bytes

amcharts/patterns/white/pattern21.png

158 Bytes

amcharts/patterns/white/pattern3.png

146 Bytes

amcharts/patterns/white/pattern4.png

154 Bytes

amcharts/patterns/white/pattern5.png

159 Bytes

amcharts/patterns/white/pattern6.png

161 Bytes

amcharts/patterns/white/pattern7.png

154 Bytes

amcharts/patterns/white/pattern8.png

160 Bytes

amcharts/patterns/white/pattern9.png

155 Bytes

File was created 1 AmCharts.AmPieChart=AmCharts.Class({inherits:AmCharts.AmSlicedChart,construct:function(e){this.type="pie";AmCharts.AmPieChart.base.construct.call(this,e);this.cname="AmPieChart";this.pieBrightnessStep=30;this.minRadius=10;this.depth3D=0;this.startAngle=90;this.angle=this.innerRadius=0;this.startRadius="500%";this.pullOutRadius="20%";this.labelRadius=20;this.labelText="[[title]]: [[percents]]%";this.balloonText="[[title]]: [[percents]]% ([[value]])\n[[description]]";this.previousScale=1;AmCharts.applyTheme(this,
2 e,this.cname)},drawChart:function(){AmCharts.AmPieChart.base.drawChart.call(this);var e=this.chartData;if(AmCharts.ifArray(e)){if(0<this.realWidth&&0<this.realHeight){AmCharts.VML&&(this.startAlpha=1);var f=this.startDuration,c=this.container,b=this.updateWidth();this.realWidth=b;var h=this.updateHeight();this.realHeight=h;var d=AmCharts.toCoordinate,k=d(this.marginLeft,b),a=d(this.marginRight,b),t=d(this.marginTop,h)+this.getTitleHeight(),m=d(this.marginBottom,h),w,x,g,v=AmCharts.toNumber(this.labelRadius),
3 q=this.measureMaxLabel();q>this.maxLabelWidth&&(q=this.maxLabelWidth);this.labelText&&this.labelsEnabled||(v=q=0);w=void 0===this.pieX?(b-k-a)/2+k:d(this.pieX,this.realWidth);x=void 0===this.pieY?(h-t-m)/2+t:d(this.pieY,h);g=d(this.radius,b,h);g||(b=0<=v?b-k-a-2*q:b-k-a,h=h-t-m,g=Math.min(b,h),h<b&&(g/=1-this.angle/90,g>b&&(g=b)),h=AmCharts.toCoordinate(this.pullOutRadius,g),g=(0<=v?g-1.8*(v+h):g-1.8*h)/2);g<this.minRadius&&(g=this.minRadius);h=d(this.pullOutRadius,g);t=AmCharts.toCoordinate(this.startRadius,
4 g);d=d(this.innerRadius,g);d>=g&&(d=g-1);m=AmCharts.fitToBounds(this.startAngle,0,360);0<this.depth3D&&(m=270<=m?270:90);m-=90;b=g-g*this.angle/90;for(k=0;k<e.length;k++)if(a=e[k],!0!==a.hidden&&0<a.percents){var n=360*a.percents/100,q=Math.sin((m+n/2)/180*Math.PI),y=-Math.cos((m+n/2)/180*Math.PI)*(b/g),p=this.outlineColor;p||(p=a.color);var z=this.alpha;isNaN(a.alpha)||(z=a.alpha);p={fill:a.color,stroke:p,"stroke-width":this.outlineThickness,"stroke-opacity":this.outlineAlpha,"fill-opacity":z};a.url&&
5 (p.cursor="pointer");p=AmCharts.wedge(c,w,x,m,n,g,b,d,this.depth3D,p,this.gradientRatio,a.pattern);this.addEventListeners(p,a);a.startAngle=m;e[k].wedge=p;0<f&&(this.chartCreated||p.setAttr("opacity",this.startAlpha));a.ix=q;a.iy=y;a.wedge=p;a.index=k;if(this.labelsEnabled&&this.labelText&&a.percents>=this.hideLabelsPercent){var l=m+n/2;360<l&&(l-=360);var r=v;isNaN(a.labelRadius)||(r=a.labelRadius);var n=w+q*(g+r),z=x+y*(g+r),A,u=0;if(0<=r){var B;90>=l&&0<=l?(B=0,A="start",u=8):90<=l&&180>l?(B=1,
6 A="start",u=8):180<=l&&270>l?(B=2,A="end",u=-8):270<=l&&360>l&&(B=3,A="end",u=-8);a.labelQuarter=B}else A="middle";var l=this.formatString(this.labelText,a),s=this.labelFunction;s&&(l=s(a,l));s=a.labelColor;s||(s=this.color);l=AmCharts.wrappedText(c,l,s,this.fontFamily,this.fontSize,A,!1,this.maxLabelWidth);l.translate(n+1.5*u,z);l.node.style.pointerEvents="none";a.tx=n+1.5*u;a.ty=z;0<=r?(r=l.getBBox(),s=AmCharts.rect(c,r.width+5,r.height+5,"#FFFFFF",.005),s.translate(n+1.5*u+r.x,z+r.y),a.hitRect=
7 s,p.push(l),p.push(s)):this.freeLabelsSet.push(l);a.label=l;a.tx=n;a.tx2=n+u;a.tx0=w+q*g;a.ty0=x+y*g}n=d+(g-d)/2;a.pulled&&(n+=this.pullOutRadiusReal);a.balloonX=q*n+w;a.balloonY=y*n+x;a.startX=Math.round(q*t);a.startY=Math.round(y*t);a.pullX=Math.round(q*h);a.pullY=Math.round(y*h);this.graphsSet.push(p);(0===a.alpha||0<f&&!this.chartCreated)&&p.hide();m+=360*a.percents/100}0<v&&!this.labelRadiusField&&this.arrangeLabels();this.pieXReal=w;this.pieYReal=x;this.radiusReal=g;this.innerRadiusReal=d;0<
8 v&&this.drawTicks();this.initialStart();this.setDepths()}(e=this.legend)&&e.invalidateSize()}else this.cleanChart();this.dispDUpd();this.chartCreated=!0},setDepths:function(){var e=this.chartData,f;for(f=0;f<e.length;f++){var c=e[f],b=c.wedge,c=c.startAngle;0<=c&&180>c?b.toFront():180<=c&&b.toBack()}},arrangeLabels:function(){var e=this.chartData,f=e.length,c,b;for(b=f-1;0<=b;b--)c=e[b],0!==c.labelQuarter||c.hidden||this.checkOverlapping(b,c,0,!0,0);for(b=0;b<f;b++)c=e[b],1!=c.labelQuarter||c.hidden||
9 this.checkOverlapping(b,c,1,!1,0);for(b=f-1;0<=b;b--)c=e[b],2!=c.labelQuarter||c.hidden||this.checkOverlapping(b,c,2,!0,0);for(b=0;b<f;b++)c=e[b],3!=c.labelQuarter||c.hidden||this.checkOverlapping(b,c,3,!1,0)},checkOverlapping:function(e,f,c,b,h){var d,k,a=this.chartData,t=a.length,m=f.label;if(m){if(!0===b)for(k=e+1;k<t;k++)a[k].labelQuarter==c&&(d=this.checkOverlappingReal(f,a[k],c))&&(k=t);else for(k=e-1;0<=k;k--)a[k].labelQuarter==c&&(d=this.checkOverlappingReal(f,a[k],c))&&(k=0);!0===d&&100>
10 h&&(d=f.ty+3*f.iy,f.ty=d,m.translate(f.tx2,d),f.hitRect&&(m=m.getBBox(),f.hitRect.translate(f.tx2+m.x,d+m.y)),this.checkOverlapping(e,f,c,b,h+1))}},checkOverlappingReal:function(e,f,c){var b=!1,h=e.label,d=f.label;e.labelQuarter!=c||e.hidden||f.hidden||!d||(h=h.getBBox(),c={},c.width=h.width,c.height=h.height,c.y=e.ty,c.x=e.tx,e=d.getBBox(),d={},d.width=e.width,d.height=e.height,d.y=f.ty,d.x=f.tx,AmCharts.hitTest(c,d)&&(b=!0));return b}});
amcharts/radar.js
File was created 1 AmCharts.AmRadarChart=AmCharts.Class({inherits:AmCharts.AmCoordinateChart,construct:function(a){this.type="radar";AmCharts.AmRadarChart.base.construct.call(this,a);this.cname="AmRadarChart";this.marginRight=this.marginBottom=this.marginTop=this.marginLeft=0;this.radius="35%";AmCharts.applyTheme(this,a,this.cname)},initChart:function(){AmCharts.AmRadarChart.base.initChart.call(this);this.dataChanged&&(this.updateData(),this.dataChanged=!1,this.dispatchDataUpdated=!0);this.drawChart()},updateData:function(){this.parseData();
2 var a=this.graphs,b;for(b=0;b<a.length;b++)a[b].data=this.chartData},updateGraphs:function(){var a=this.graphs,b;for(b=0;b<a.length;b++){var c=a[b];c.index=b;c.width=this.realRadius;c.height=this.realRadius;c.x=this.marginLeftReal;c.y=this.marginTopReal}},parseData:function(){AmCharts.AmRadarChart.base.parseData.call(this);this.parseSerialData()},updateValueAxes:function(){var a=this.valueAxes,b;for(b=0;b<a.length;b++){var c=a[b];c.axisRenderer=AmCharts.RadAxis;c.guideFillRenderer=AmCharts.RadarFill;
3 c.axisItemRenderer=AmCharts.RadItem;c.autoGridCount=!1;c.x=this.marginLeftReal;c.y=this.marginTopReal;c.width=this.realRadius;c.height=this.realRadius}},drawChart:function(){AmCharts.AmRadarChart.base.drawChart.call(this);var a=this.updateWidth(),b=this.updateHeight(),c=this.marginTop+this.getTitleHeight(),d=this.marginLeft,b=b-c-this.marginBottom;this.marginLeftReal=d+(a-d-this.marginRight)/2;this.marginTopReal=c+b/2;this.realRadius=AmCharts.toCoordinate(this.radius,a,b);this.updateValueAxes();this.updateGraphs();
4 a=this.chartData;if(AmCharts.ifArray(a)){if(0<this.realWidth&&0<this.realHeight){a=a.length-1;d=this.valueAxes;for(c=0;c<d.length;c++)d[c].zoom(0,a);d=this.graphs;for(c=0;c<d.length;c++)d[c].zoom(0,a);(a=this.legend)&&a.invalidateSize()}}else this.cleanChart();this.dispDUpd();this.chartCreated=!0},formatString:function(a,b,c){var d=b.graph;-1!=a.indexOf("[[category]]")&&(a=a.replace(/\[\[category\]\]/g,String(b.serialDataItem.category)));d=d.numberFormatter;d||(d=this.nf);a=AmCharts.formatValue(a,
5 b.values,["value"],d,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);-1!=a.indexOf("[[")&&(a=AmCharts.formatDataContextValue(a,b.dataContext));return a=AmCharts.AmRadarChart.base.formatString.call(this,a,b,c)},cleanChart:function(){AmCharts.callMethod("destroy",[this.valueAxes,this.graphs])}});AmCharts.RadAxis=AmCharts.Class({construct:function(a){var b=a.chart,c=a.axisThickness,d=a.axisColor,m=a.axisAlpha,p=a.x,e=a.y;this.set=b.container.set();b.axesSet.push(this.set);var f=a.axisTitleOffset,n=a.radarCategoriesEnabled,l=a.chart.fontFamily,g=a.fontSize;void 0===g&&(g=a.chart.fontSize);var r=a.color;void 0===r&&(r=a.chart.color);if(b){this.axisWidth=a.height;a=b.chartData;var w=a.length,t;for(t=0;t<w;t++){var k=180-360/w*t,h=p+this.axisWidth*Math.sin(k/180*Math.PI),q=e+this.axisWidth*Math.cos(k/
6 180*Math.PI);0<m&&(h=AmCharts.line(b.container,[p,h],[e,q],d,m,c),this.set.push(h));if(n){var u="start",h=p+(this.axisWidth+f)*Math.sin(k/180*Math.PI),q=e+(this.axisWidth+f)*Math.cos(k/180*Math.PI);if(180==k||0===k)u="middle",h-=5;0>k&&(u="end",h-=10);180==k&&(q-=5);0===k&&(q+=5);k=AmCharts.text(b.container,a[t].category,r,l,g,u);k.translate(h+5,q);this.set.push(k);k.getBBox()}}}}});AmCharts.RadItem=AmCharts.Class({construct:function(a,b,c,d,m,p,e,f){void 0===c&&(c="");var n=a.chart.fontFamily,l=a.fontSize;void 0===l&&(l=a.chart.fontSize);var g=a.color;void 0===g&&(g=a.chart.color);var r=a.chart.container;this.set=d=r.set();var w=a.axisColor,t=a.axisAlpha,k=a.tickLength,h=a.gridAlpha,q=a.gridThickness,u=a.gridColor,A=a.dashLength,B=a.fillColor,y=a.fillAlpha,C=a.labelsEnabled;m=a.counter;var D=a.inside,E=a.gridType,s,H=a.labelOffset;b-=a.height;var x;p=a.x;var F=a.y;e?(C=!0,isNaN(e.tickLength)||
7 (k=e.tickLength),void 0!=e.lineColor&&(u=e.lineColor),isNaN(e.lineAlpha)||(h=e.lineAlpha),isNaN(e.dashLength)||(A=e.dashLength),isNaN(e.lineThickness)||(q=e.lineThickness),!0===e.inside&&(D=!0),void 0!==e.boldLabel&&(f=e.boldLabel)):c||(h/=3,k/=2);var G="end",z=-1;D&&(G="start",z=1);var v;C&&(v=AmCharts.text(r,c,g,n,l,G,f),v.translate(p+(k+3+H)*z,b),d.push(v),this.label=v,x=AmCharts.line(r,[p,p+k*z],[b,b],w,t,q),d.push(x));b=Math.round(a.y-b);f=[];n=[];if(0<h){if("polygons"==E){s=a.data.length;for(l=
8 0;l<s;l++)g=180-360/s*l,f.push(b*Math.sin(g/180*Math.PI)),n.push(b*Math.cos(g/180*Math.PI));f.push(f[0]);n.push(n[0]);h=AmCharts.line(r,f,n,u,h,q,A)}else h=AmCharts.circle(r,b,"#FFFFFF",0,q,u,h);h.translate(p,F);d.push(h)}if(1==m&&0<y&&!e&&""!==c){e=a.previousCoord;if("polygons"==E){for(l=s;0<=l;l--)g=180-360/s*l,f.push(e*Math.sin(g/180*Math.PI)),n.push(e*Math.cos(g/180*Math.PI));s=AmCharts.polygon(r,f,n,B,y)}else s=AmCharts.wedge(r,0,0,0,360,b,b,e,0,{fill:B,"fill-opacity":y,stroke:"#000","stroke-opacity":0,
9 "stroke-width":1});d.push(s);s.translate(p,F)}!1===a.visible&&(x&&x.hide(),v&&v.hide());""!==c&&(a.counter=0===m?1:0,a.previousCoord=b)},graphics:function(){return this.set},getLabel:function(){return this.label}});AmCharts.RadarFill=AmCharts.Class({construct:function(a,b,c,d){b-=a.axisWidth;c-=a.axisWidth;var m=Math.max(b,c);b=c=Math.min(b,c);c=a.chart.container;var p=d.fillAlpha,e=d.fillColor,m=Math.abs(m-a.y);b=Math.abs(b-a.y);var f=Math.max(m,b);b=Math.min(m,b);m=f;f=d.angle+90;d=d.toAngle+90;isNaN(f)&&(f=0);isNaN(d)&&(d=360);this.set=c.set();void 0===e&&(e="#000000");isNaN(p)&&(p=0);if("polygons"==a.gridType){d=[];var n=[],l=a.data.length,g;for(g=0;g<l;g++)f=180-360/l*g,d.push(m*Math.sin(f/180*Math.PI)),
10 n.push(m*Math.cos(f/180*Math.PI));d.push(d[0]);n.push(n[0]);for(g=l;0<=g;g--)f=180-360/l*g,d.push(b*Math.sin(f/180*Math.PI)),n.push(b*Math.cos(f/180*Math.PI));this.fill=AmCharts.polygon(c,d,n,e,p)}else this.fill=AmCharts.wedge(c,0,0,f,d-f,m,m,b,0,{fill:e,"fill-opacity":p,stroke:"#000","stroke-opacity":0,"stroke-width":1});this.set.push(this.fill);this.fill.translate(a.x,a.y)},graphics:function(){return this.set},getLabel:function(){}});
amcharts/serial.js
File was created 1 AmCharts.AmSerialChart=AmCharts.Class({inherits:AmCharts.AmRectangularChart,construct:function(a){this.type="serial";AmCharts.AmSerialChart.base.construct.call(this,a);this.cname="AmSerialChart";this.theme=a;this.createEvents("changed");this.columnSpacing=5;this.columnSpacing3D=0;this.columnWidth=.8;this.updateScrollbar=!0;var b=new AmCharts.CategoryAxis(a);b.chart=this;this.categoryAxis=b;this.zoomOutOnDataUpdate=!0;this.mouseWheelZoomEnabled=this.mouseWheelScrollEnabled=this.rotate=this.skipZoom=
2 !1;this.minSelectedTime=0;AmCharts.applyTheme(this,a,this.cname)},initChart:function(){AmCharts.AmSerialChart.base.initChart.call(this);this.updateCategoryAxis(this.categoryAxis,this.rotate,"categoryAxis");this.dataChanged&&(this.updateData(),this.dataChanged=!1,this.dispatchDataUpdated=!0);var a=this.chartCursor;a&&(a.updateData(),a.fullWidth&&(a.fullRectSet=this.cursorLineSet));var a=this.countColumns(),b=this.graphs,c;for(c=0;c<b.length;c++)b[c].columnCount=a;this.updateScrollbar=!0;this.drawChart();
3 this.autoMargins&&!this.marginsUpdated&&(this.marginsUpdated=!0,this.measureMargins());(this.mouseWheelScrollEnabled||this.mouseWheelZoomEnabled)&&this.addMouseWheel()},handleWheelReal:function(a,b){if(!this.wheelBusy){var c=this.categoryAxis,d=c.parseDates,c=c.minDuration(),e=1;this.mouseWheelZoomEnabled?b||(e=-1):b&&(e=-1);0>a?d?(d=this.startTime+e*c,c=this.endTime+1*c,this.zoomToDates(new Date(d),new Date(c))):(d=this.start+e,c=this.end+1,this.zoomToIndexes(d,c)):d?(d=this.startTime-e*c,c=this.endTime-
4 1*c,this.zoomToDates(new Date(d),new Date(c))):(d=this.start-e,c=this.end-1,this.zoomToIndexes(d,c))}},validateData:function(a){this.marginsUpdated=!1;this.zoomOutOnDataUpdate&&!a&&(this.endTime=this.end=this.startTime=this.start=NaN);AmCharts.AmSerialChart.base.validateData.call(this)},drawChart:function(){AmCharts.AmSerialChart.base.drawChart.call(this);var a=this.chartData;if(AmCharts.ifArray(a)){var b=this.chartScrollbar;b&&b.draw();if(0<this.realWidth&&0<this.realHeight){var a=a.length-1,c,b=
5 this.categoryAxis;if(b.parseDates&&!b.equalSpacing){if(b=this.startTime,c=this.endTime,isNaN(b)||isNaN(c))b=this.firstTime,c=this.lastTime}else if(b=this.start,c=this.end,isNaN(b)||isNaN(c))b=0,c=a;this.endTime=this.startTime=this.end=this.start=void 0;this.zoom(b,c)}}else this.cleanChart();this.dispDUpd();this.chartCreated=!0},cleanChart:function(){AmCharts.callMethod("destroy",[this.valueAxes,this.graphs,this.categoryAxis,this.chartScrollbar,this.chartCursor])},updateCategoryAxis:function(a,b,c){a.chart=
6 this;a.id=c;a.rotate=b;a.axisRenderer=AmCharts.RecAxis;a.guideFillRenderer=AmCharts.RecFill;a.axisItemRenderer=AmCharts.RecItem;a.setOrientation(!this.rotate);a.x=this.marginLeftReal;a.y=this.marginTopReal;a.dx=this.dx;a.dy=this.dy;a.width=this.plotAreaWidth-1;a.height=this.plotAreaHeight-1;a.viW=this.plotAreaWidth-1;a.viH=this.plotAreaHeight-1;a.viX=this.marginLeftReal;a.viY=this.marginTopReal;a.marginsChanged=!0},updateValueAxes:function(){AmCharts.AmSerialChart.base.updateValueAxes.call(this);
7 var a=this.valueAxes,b;for(b=0;b<a.length;b++){var c=a[b],d=this.rotate;c.rotate=d;c.setOrientation(d);d=this.categoryAxis;if(!d.startOnAxis||d.parseDates)c.expandMinMax=!0}},updateData:function(){this.parseData();var a=this.graphs,b,c=this.chartData;for(b=0;b<a.length;b++)a[b].data=c;0<c.length&&(this.firstTime=this.getStartTime(c[0].time),this.lastTime=this.getEndTime(c[c.length-1].time))},getStartTime:function(a){var b=this.categoryAxis;return AmCharts.resetDateToMin(new Date(a),b.minPeriod,1,
8 b.firstDayOfWeek).getTime()},getEndTime:function(a){var b=AmCharts.extractPeriod(this.categoryAxis.minPeriod);return AmCharts.changeDate(new Date(a),b.period,b.count,!0).getTime()-1},updateMargins:function(){AmCharts.AmSerialChart.base.updateMargins.call(this);var a=this.chartScrollbar;a&&(this.getScrollbarPosition(a,this.rotate,this.categoryAxis.position),this.adjustMargins(a,this.rotate))},updateScrollbars:function(){AmCharts.AmSerialChart.base.updateScrollbars.call(this);this.updateChartScrollbar(this.chartScrollbar,
9 this.rotate)},zoom:function(a,b){var c=this.categoryAxis;c.parseDates&&!c.equalSpacing?this.timeZoom(a,b):this.indexZoom(a,b);this.updateLegendValues()},timeZoom:function(a,b){var c=this.maxSelectedTime;isNaN(c)||(b!=this.endTime&&b-a>c&&(a=b-c,this.updateScrollbar=!0),a!=this.startTime&&b-a>c&&(b=a+c,this.updateScrollbar=!0));var d=this.minSelectedTime;if(0<d&&b-a<d){var e=Math.round(a+(b-a)/2),d=Math.round(d/2);a=e-d;b=e+d}var f=this.chartData,e=this.categoryAxis;if(AmCharts.ifArray(f)&&(a!=this.startTime||
10 b!=this.endTime)){var l=e.minDuration(),d=this.firstTime,n=this.lastTime;a||(a=d,isNaN(c)||(a=n-c));b||(b=n);a>n&&(a=n);b<d&&(b=d);a<d&&(a=d);b>n&&(b=n);b<a&&(b=a+l);b-a<l/5&&(b<n?b=a+l/5:a=b-l/5);this.startTime=a;this.endTime=b;c=f.length-1;l=this.getClosestIndex(f,"time",a,!0,0,c);f=this.getClosestIndex(f,"time",b,!1,l,c);e.timeZoom(a,b);e.zoom(l,f);this.start=AmCharts.fitToBounds(l,0,c);this.end=AmCharts.fitToBounds(f,0,c);this.zoomAxesAndGraphs();this.zoomScrollbar();a!=d||b!=n?this.showZB(!0):
11 this.showZB(!1);this.updateColumnsDepth();this.dispatchTimeZoomEvent()}},indexZoom:function(a,b){var c=this.maxSelectedSeries;isNaN(c)||(b!=this.end&&b-a>c&&(a=b-c,this.updateScrollbar=!0),a!=this.start&&b-a>c&&(b=a+c,this.updateScrollbar=!0));if(a!=this.start||b!=this.end){var d=this.chartData.length-1;isNaN(a)&&(a=0,isNaN(c)||(a=d-c));isNaN(b)&&(b=d);b<a&&(b=a);b>d&&(b=d);a>d&&(a=d-1);0>a&&(a=0);this.start=a;this.end=b;this.categoryAxis.zoom(a,b);this.zoomAxesAndGraphs();this.zoomScrollbar();0!==
12 a||b!=this.chartData.length-1?this.showZB(!0):this.showZB(!1);this.updateColumnsDepth();this.dispatchIndexZoomEvent()}},updateGraphs:function(){AmCharts.AmSerialChart.base.updateGraphs.call(this);var a=this.graphs,b;for(b=0;b<a.length;b++){var c=a[b];c.columnWidthReal=this.columnWidth;c.categoryAxis=this.categoryAxis;AmCharts.isString(c.fillToGraph)&&(c.fillToGraph=this.getGraphById(c.fillToGraph))}},updateColumnsDepth:function(){var a,b=this.graphs,c;AmCharts.remove(this.columnsSet);this.columnsArray=
13 [];for(a=0;a<b.length;a++){c=b[a];var d=c.columnsArray;if(d){var e;for(e=0;e<d.length;e++)this.columnsArray.push(d[e])}}this.columnsArray.sort(this.compareDepth);if(0<this.columnsArray.length){b=this.container.set();this.columnSet.push(b);for(a=0;a<this.columnsArray.length;a++)b.push(this.columnsArray[a].column.set);c&&b.translate(c.x,c.y);this.columnsSet=b}},compareDepth:function(a,b){return a.depth>b.depth?1:-1},zoomScrollbar:function(){var a=this.chartScrollbar,b=this.categoryAxis;a&&this.updateScrollbar&&
14 (b.parseDates&&!b.equalSpacing?a.timeZoom(this.startTime,this.endTime):a.zoom(this.start,this.end),this.updateScrollbar=!0)},updateTrendLines:function(){var a=this.trendLines,b;for(b=0;b<a.length;b++){var c=a[b],c=AmCharts.processObject(c,AmCharts.TrendLine,this.theme);a[b]=c;c.chart=this;AmCharts.isString(c.valueAxis)&&(c.valueAxis=this.getValueAxisById(c.valueAxis));c.valueAxis||(c.valueAxis=this.valueAxes[0]);c.categoryAxis=this.categoryAxis}},zoomAxesAndGraphs:function(){if(!this.scrollbarOnly){var a=
15 this.valueAxes,b;for(b=0;b<a.length;b++)a[b].zoom(this.start,this.end);a=this.graphs;for(b=0;b<a.length;b++)a[b].zoom(this.start,this.end);this.zoomTrendLines();(b=this.chartCursor)&&b.zoom(this.start,this.end,this.startTime,this.endTime)}},countColumns:function(){var a=0,b=this.valueAxes.length,c=this.graphs.length,d,e,f=!1,l,n;for(n=0;n<b;n++){e=this.valueAxes[n];var k=e.stackType;if("100%"==k||"regular"==k)for(f=!1,l=0;l<c;l++)d=this.graphs[l],d.tcc=1,d.valueAxis==e&&"column"==d.type&&(!f&&d.stackable&&
16 (a++,f=!0),(!d.stackable&&d.clustered||d.newStack)&&a++,d.columnIndex=a-1,d.clustered||(d.columnIndex=0));if("none"==k||"3d"==k)for(l=0;l<c;l++)d=this.graphs[l],d.valueAxis==e&&"column"==d.type&&d.clustered&&(d.tcc=1,d.newStack&&(a=0),d.hidden||(d.columnIndex=a,a++));if("3d"==k){e=1;for(n=0;n<c;n++)d=this.graphs[n],d.newStack&&e++,d.depthCount=e,d.tcc=a;a=e}}return a},parseData:function(){AmCharts.AmSerialChart.base.parseData.call(this);this.parseSerialData()},getCategoryIndexByValue:function(a){var b=
17 this.chartData,c,d;for(d=0;d<b.length;d++)b[d].category==a&&(c=d);return c},handleCursorChange:function(a){this.updateLegendValues(a.index)},handleCursorZoom:function(a){this.updateScrollbar=!0;this.zoom(a.start,a.end)},handleScrollbarZoom:function(a){this.updateScrollbar=!1;this.zoom(a.start,a.end)},dispatchTimeZoomEvent:function(){if(this.prevStartTime!=this.startTime||this.prevEndTime!=this.endTime){var a={type:"zoomed"};a.startDate=new Date(this.startTime);a.endDate=new Date(this.endTime);a.startIndex=
18 this.start;a.endIndex=this.end;this.startIndex=this.start;this.endIndex=this.end;this.startDate=a.startDate;this.endDate=a.endDate;this.prevStartTime=this.startTime;this.prevEndTime=this.endTime;var b=this.categoryAxis,c=AmCharts.extractPeriod(b.minPeriod).period,b=b.dateFormatsObject[c];a.startValue=AmCharts.formatDate(a.startDate,b);a.endValue=AmCharts.formatDate(a.endDate,b);a.chart=this;a.target=this;this.fire(a.type,a)}},dispatchIndexZoomEvent:function(){if(this.prevStartIndex!=this.start||this.prevEndIndex!=
19 this.end){this.startIndex=this.start;this.endIndex=this.end;var a=this.chartData;if(AmCharts.ifArray(a)&&!isNaN(this.start)&&!isNaN(this.end)){var b={chart:this,target:this,type:"zoomed"};b.startIndex=this.start;b.endIndex=this.end;b.startValue=a[this.start].category;b.endValue=a[this.end].category;this.categoryAxis.parseDates&&(this.startTime=a[this.start].time,this.endTime=a[this.end].time,b.startDate=new Date(this.startTime),b.endDate=new Date(this.endTime));this.prevStartIndex=this.start;this.prevEndIndex=
20 this.end;this.fire(b.type,b)}}},updateLegendValues:function(a){var b=this.graphs,c;for(c=0;c<b.length;c++){var d=b[c];isNaN(a)?d.currentDataItem=void 0:d.currentDataItem=this.chartData[a].axes[d.valueAxis.id].graphs[d.id]}this.legend&&this.legend.updateValues()},getClosestIndex:function(a,b,c,d,e,f){0>e&&(e=0);f>a.length-1&&(f=a.length-1);var l=e+Math.round((f-e)/2),n=a[l][b];if(1>=f-e){if(d)return e;d=a[f][b];return Math.abs(a[e][b]-c)<Math.abs(d-c)?e:f}return c==n?l:c<n?this.getClosestIndex(a,b,
21 c,d,e,l):this.getClosestIndex(a,b,c,d,l,f)},zoomToIndexes:function(a,b){this.updateScrollbar=!0;var c=this.chartData;if(c){var d=c.length;0<d&&(0>a&&(a=0),b>d-1&&(b=d-1),d=this.categoryAxis,d.parseDates&&!d.equalSpacing?this.zoom(c[a].time,this.getEndTime(c[b].time)):this.zoom(a,b))}},zoomToDates:function(a,b){this.updateScrollbar=!0;var c=this.chartData;if(this.categoryAxis.equalSpacing){var d=this.getClosestIndex(c,"time",a.getTime(),!0,0,c.length);b=AmCharts.resetDateToMin(b,this.categoryAxis.minPeriod,
22 1);c=this.getClosestIndex(c,"time",b.getTime(),!1,0,c.length);this.zoom(d,c)}else this.zoom(a.getTime(),b.getTime())},zoomToCategoryValues:function(a,b){this.updateScrollbar=!0;this.zoom(this.getCategoryIndexByValue(a),this.getCategoryIndexByValue(b))},formatPeriodString:function(a,b){if(b){var c=["value","open","low","high","close"],d="value open low high close average sum count".split(" "),e=b.valueAxis,f=this.chartData,l=b.numberFormatter;l||(l=this.nf);for(var n=0;n<c.length;n++){for(var k=c[n],
23 g=0,h=0,m,u,r,s,p,v=0,q=0,x,t,y,w,C,B=this.start;B<=this.end;B++){var z=f[B];if(z&&(z=z.axes[e.id].graphs[b.id])){if(z.values){var A=z.values[k];if(!isNaN(A)){isNaN(m)&&(m=A);u=A;if(isNaN(r)||r>A)r=A;if(isNaN(s)||s<A)s=A;p=AmCharts.getDecimals(g);var D=AmCharts.getDecimals(A),g=g+A,g=AmCharts.roundTo(g,Math.max(p,D));h++;p=g/h}}if(z.percents&&(z=z.percents[k],!isNaN(z))){isNaN(x)&&(x=z);t=z;if(isNaN(y)||y>z)y=z;if(isNaN(w)||w<z)w=z;C=AmCharts.getDecimals(v);A=AmCharts.getDecimals(z);v+=z;v=AmCharts.roundTo(v,
24 Math.max(C,A));q++;C=v/q}}}v={open:x,close:t,high:w,low:y,average:C,sum:v,count:q};a=AmCharts.formatValue(a,{open:m,close:u,high:s,low:r,average:p,sum:g,count:h},d,l,k+"\\.",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);a=AmCharts.formatValue(a,v,d,this.pf,"percents\\."+k+"\\.")}}return a},formatString:function(a,b,c){var d=b.graph;if(-1!=a.indexOf("[[category]]")){var e=b.serialDataItem.category;if(this.categoryAxis.parseDates){var f=this.balloonDateFormat,l=this.chartCursor;
25 l&&(f=l.categoryBalloonDateFormat);-1!=a.indexOf("[[category]]")&&(f=AmCharts.formatDate(e,f),-1!=f.indexOf("fff")&&(f=AmCharts.formatMilliseconds(f,e)),e=f)}a=a.replace(/\[\[category\]\]/g,String(e))}d=d.numberFormatter;d||(d=this.nf);e=b.graph.valueAxis;(f=e.duration)&&!isNaN(b.values.value)&&(e=AmCharts.formatDuration(b.values.value,f,"",e.durationUnits,e.maxInterval,d),a=a.replace(RegExp("\\[\\[value\\]\\]","g"),e));e="value open low high close total".split(" ");f=this.pf;a=AmCharts.formatValue(a,
26 b.percents,e,f,"percents\\.");a=AmCharts.formatValue(a,b.values,e,d,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);a=AmCharts.formatValue(a,b.values,["percents"],f);-1!=a.indexOf("[[")&&(a=AmCharts.formatDataContextValue(a,b.dataContext));return a=AmCharts.AmSerialChart.base.formatString.call(this,a,b,c)},addChartScrollbar:function(a){AmCharts.callMethod("destroy",[this.chartScrollbar]);a&&(a.chart=this,this.listenTo(a,"zoomed",this.handleScrollbarZoom));this.rotate?void 0===
27 a.width&&(a.width=a.scrollbarHeight):void 0===a.height&&(a.height=a.scrollbarHeight);this.chartScrollbar=a},removeChartScrollbar:function(){AmCharts.callMethod("destroy",[this.chartScrollbar]);this.chartScrollbar=null},handleReleaseOutside:function(a){AmCharts.AmSerialChart.base.handleReleaseOutside.call(this,a);AmCharts.callMethod("handleReleaseOutside",[this.chartScrollbar])}});AmCharts.Cuboid=AmCharts.Class({construct:function(a,b,c,d,e,f,l,n,k,g,h,m,u,r,s){this.set=a.set();this.container=a;this.h=Math.round(c);this.w=Math.round(b);this.dx=d;this.dy=e;this.colors=f;this.alpha=l;this.bwidth=n;this.bcolor=k;this.balpha=g;this.colors=f;this.dashLength=r;this.pattern=s;u?0>b&&0===h&&(h=180):0>c&&270==h&&(h=90);this.gradientRotation=h;0===d&&0===e&&(this.cornerRadius=m);this.draw()},draw:function(){var a=this.set;a.clear();var b=this.container,c=this.w,d=this.h,e=this.dx,f=
28 this.dy,l=this.colors,n=this.alpha,k=this.bwidth,g=this.bcolor,h=this.balpha,m=this.gradientRotation,u=this.cornerRadius,r=this.dashLength,s=this.pattern,p=l,v=l;"object"==typeof l&&(p=l[0],v=l[l.length-1]);var q,x,t,y,w,C,B,z,A,D=n;s&&(n=0);if(0<e||0<f)B=v,v=AmCharts.adjustLuminosity(p,-.2),v=AmCharts.adjustLuminosity(p,-.2),q=AmCharts.polygon(b,[0,e,c+e,c,0],[0,f,f,0,0],v,n,1,g,0,m),0<h&&(A=AmCharts.line(b,[0,e,c+e],[0,f,f],g,h,k,r)),x=AmCharts.polygon(b,[0,0,c,c,0],[0,d,d,0,0],v,n,1,g,0,m),x.translate(e,
29 f),0<h&&(t=AmCharts.line(b,[e,e],[f,f+d],g,h,k,r)),y=AmCharts.polygon(b,[0,0,e,e,0],[0,d,d+f,f,0],v,n,1,g,0,m),w=AmCharts.polygon(b,[c,c,c+e,c+e,c],[0,d,d+f,f,0],v,n,1,g,0,m),0<h&&(C=AmCharts.line(b,[c,c+e,c+e,c],[0,f,d+f,d],g,h,k,r)),v=AmCharts.adjustLuminosity(B,.2),B=AmCharts.polygon(b,[0,e,c+e,c,0],[d,d+f,d+f,d,d],v,n,1,g,0,m),0<h&&(z=AmCharts.line(b,[0,e,c+e],[d,d+f,d+f],g,h,k,r));n=D;1>Math.abs(d)&&(d=0);1>Math.abs(c)&&(c=0);b=0===d?AmCharts.line(b,[0,c],[0,0],g,h,k,r):0===c?AmCharts.line(b,
30 [0,0],[0,d],g,h,k,r):0<u?AmCharts.rect(b,c,d,l,n,k,g,h,u,m,r):AmCharts.polygon(b,[0,0,c,c,0],[0,d,d,0,0],l,n,k,g,h,m,!1,r);d=0>d?[q,A,x,t,y,w,C,B,z,b]:[B,z,x,t,y,w,q,A,C,b];for(q=0;q<d.length;q++)(x=d[q])&&a.push(x);s&&b.pattern(s)},width:function(a){this.w=a;this.draw()},height:function(a){this.h=a;this.draw()},animateHeight:function(a,b){var c=this;c.easing=b;c.totalFrames=Math.round(1E3*a/AmCharts.updateRate);c.rh=c.h;c.frame=0;c.height(1);setTimeout(function(){c.updateHeight.call(c)},AmCharts.updateRate)},
31 updateHeight:function(){var a=this;a.frame++;var b=a.totalFrames;a.frame<=b&&(b=a.easing(0,a.frame,1,a.rh-1,b),a.height(b),setTimeout(function(){a.updateHeight.call(a)},AmCharts.updateRate))},animateWidth:function(a,b){var c=this;c.easing=b;c.totalFrames=Math.round(1E3*a/AmCharts.updateRate);c.rw=c.w;c.frame=0;c.width(1);setTimeout(function(){c.updateWidth.call(c)},AmCharts.updateRate)},updateWidth:function(){var a=this;a.frame++;var b=a.totalFrames;a.frame<=b&&(b=a.easing(0,a.frame,1,a.rw-1,b),a.width(b),
32 setTimeout(function(){a.updateWidth.call(a)},AmCharts.updateRate))}});AmCharts.CategoryAxis=AmCharts.Class({inherits:AmCharts.AxisBase,construct:function(a){this.cname="CategoryAxis";AmCharts.CategoryAxis.base.construct.call(this,a);this.minPeriod="DD";this.equalSpacing=this.parseDates=!1;this.position="bottom";this.startOnAxis=!1;this.firstDayOfWeek=1;this.gridPosition="middle";this.markPeriodChange=this.boldPeriodBeginning=!0;this.safeDistance=30;this.centerLabelOnFullPeriod=!0;this.periods=[{period:"ss",count:1},{period:"ss",count:5},{period:"ss",count:10},{period:"ss",
33 count:30},{period:"mm",count:1},{period:"mm",count:5},{period:"mm",count:10},{period:"mm",count:30},{period:"hh",count:1},{period:"hh",count:3},{period:"hh",count:6},{period:"hh",count:12},{period:"DD",count:1},{period:"DD",count:2},{period:"DD",count:3},{period:"DD",count:4},{period:"DD",count:5},{period:"WW",count:1},{period:"MM",count:1},{period:"MM",count:2},{period:"MM",count:3},{period:"MM",count:6},{period:"YYYY",count:1},{period:"YYYY",count:2},{period:"YYYY",count:5},{period:"YYYY",count:10},
34 {period:"YYYY",count:50},{period:"YYYY",count:100}];this.dateFormats=[{period:"fff",format:"JJ:NN:SS"},{period:"ss",format:"JJ:NN:SS"},{period:"mm",format:"JJ:NN"},{period:"hh",format:"JJ:NN"},{period:"DD",format:"MMM DD"},{period:"WW",format:"MMM DD"},{period:"MM",format:"MMM"},{period:"YYYY",format:"YYYY"}];this.nextPeriod={};this.nextPeriod.fff="ss";this.nextPeriod.ss="mm";this.nextPeriod.mm="hh";this.nextPeriod.hh="DD";this.nextPeriod.DD="MM";this.nextPeriod.MM="YYYY";AmCharts.applyTheme(this,
35 a,this.cname)},draw:function(){AmCharts.CategoryAxis.base.draw.call(this);this.generateDFObject();var a=this.chart.chartData;this.data=a;if(AmCharts.ifArray(a)){var b,c=this.chart,d=this.start,e=this.labelFrequency,f=0;b=this.end-d+1;var l=this.gridCountR,n=this.showFirstLabel,k=this.showLastLabel,g,h="",m=AmCharts.extractPeriod(this.minPeriod);g=AmCharts.getPeriodDuration(m.period,m.count);var u,r,s,p,v,q;u=this.rotate;var x=this.firstDayOfWeek,t=this.boldPeriodBeginning,a=AmCharts.resetDateToMin(new Date(a[a.length-
36 1].time+1.05*g),this.minPeriod,1,x).getTime(),y;this.endTime>a&&(this.endTime=a);q=this.minorGridEnabled;var w,a=this.gridAlpha,C;if(this.parseDates&&!this.equalSpacing){this.timeDifference=this.endTime-this.startTime;d=this.choosePeriod(0);e=d.period;u=d.count;r=AmCharts.getPeriodDuration(e,u);r<g&&(e=m.period,u=m.count,r=g);s=e;"WW"==s&&(s="DD");this.stepWidth=this.getStepWidth(this.timeDifference);var l=Math.ceil(this.timeDifference/r)+5,B=h=AmCharts.resetDateToMin(new Date(this.startTime-r),e,
37 u,x).getTime();s==e&&1==u&&this.centerLabelOnFullPeriod&&(v=r*this.stepWidth);this.cellWidth=g*this.stepWidth;b=Math.round(h/r);d=-1;b/2==Math.round(b/2)&&(d=-2,h-=r);var z=c.firstTime,A=0;q&&1<u&&(w=this.chooseMinorFrequency(u),C=AmCharts.getPeriodDuration(e,w));if(0<this.gridCountR)for(b=d;b<=l;b++){m=z+r*(b+Math.floor((B-z)/r))-A;"DD"==e&&(m+=36E5);m=AmCharts.resetDateToMin(new Date(m),e,u,x).getTime();"MM"==e&&(q=(m-h)/r,1.5<=(m-h)/r&&(m=m-(q-1)*r+AmCharts.getPeriodDuration("DD",3),m=AmCharts.resetDateToMin(new Date(m),
38 e,1).getTime(),A+=r));g=(m-this.startTime)*this.stepWidth;q=!1;this.nextPeriod[s]&&(q=this.checkPeriodChange(this.nextPeriod[s],1,m,h,s));y=!1;q&&this.markPeriodChange?(q=this.dateFormatsObject[this.nextPeriod[s]],this.twoLineMode&&(q=this.dateFormatsObject[s]+"\n"+q,q=AmCharts.fixBrakes(q)),y=!0):q=this.dateFormatsObject[s];t||(y=!1);h=AmCharts.formatDate(new Date(m),q);if(b==d&&!n||b==l&&!k)h=" ";this.labelFunction&&(h=this.labelFunction(h,new Date(m),this,e,u,p).toString());this.boldLabels&&(y=
39 !0);p=new this.axisItemRenderer(this,g,h,!1,v,0,!1,y);this.pushAxisItem(p);p=h=m;if(!isNaN(w))for(g=1;g<u;g+=w)this.gridAlpha=this.minorGridAlpha,q=m+C*g,q=AmCharts.resetDateToMin(new Date(q),e,w,x).getTime(),q=new this.axisItemRenderer(this,(q-this.startTime)*this.stepWidth),this.pushAxisItem(q);this.gridAlpha=a}}else if(!this.parseDates){if(this.cellWidth=this.getStepWidth(b),b<l&&(l=b),f+=this.start,this.stepWidth=this.getStepWidth(b),0<l)for(t=Math.floor(b/l),w=this.chooseMinorFrequency(t),g=
40 f,g/2==Math.round(g/2)&&g--,0>g&&(g=0),l=0,this.end-g+1>=this.autoRotateCount&&(this.labelRotation=this.autoRotateAngle),b=g;b<=this.end+2;b++){p=!1;0<=b&&b<this.data.length?(s=this.data[b],h=s.category,p=s.forceShow):h="";if(q&&!isNaN(w))if(b/w==Math.round(b/w)||p)b/t==Math.round(b/t)||p||(this.gridAlpha=this.minorGridAlpha,h=void 0);else continue;else if(b/t!=Math.round(b/t)&&!p)continue;g=this.getCoordinate(b-f);p=0;"start"==this.gridPosition&&(g-=this.cellWidth/2,p=this.cellWidth/2);x=!0;tickShift=
41 p;"start"==this.tickPosition&&(tickShift=0,x=!1,p=0);if(b==d&&!n||b==this.end&&!k)h=void 0;Math.round(l/e)!=l/e&&(h=void 0);l++;B=this.cellWidth;u&&(B=NaN);this.labelFunction&&s&&(h=this.labelFunction(h,s,this));h=AmCharts.fixBrakes(h);y=!1;this.boldLabels&&(y=!0);b>this.end&&"start"==this.tickPosition&&(h=" ");p=new this.axisItemRenderer(this,g,h,x,B,p,void 0,y,tickShift,!1,s.labelColor);p.serialDataItem=s;this.pushAxisItem(p);this.gridAlpha=a}}else if(this.parseDates&&this.equalSpacing){f=this.start;
42 this.startTime=this.data[this.start].time;this.endTime=this.data[this.end].time;this.timeDifference=this.endTime-this.startTime;d=this.choosePeriod(0);e=d.period;u=d.count;r=AmCharts.getPeriodDuration(e,u);r<g&&(e=m.period,u=m.count,r=g);s=e;"WW"==s&&(s="DD");this.stepWidth=this.getStepWidth(b);l=Math.ceil(this.timeDifference/r)+1;h=AmCharts.resetDateToMin(new Date(this.startTime-r),e,u,x).getTime();this.cellWidth=this.getStepWidth(b);b=Math.round(h/r);d=-1;b/2==Math.round(b/2)&&(d=-2,h-=r);g=this.start;
43 g/2==Math.round(g/2)&&g--;0>g&&(g=0);v=this.end+2;v>=this.data.length&&(v=this.data.length);C=!1;C=!n;this.previousPos=-1E3;20<this.labelRotation&&(this.safeDistance=5);r=g;if(this.data[g].time!=AmCharts.resetDateToMin(new Date(this.data[g].time),e,u,x).getTime())for(x=0,y=h,b=g;b<v;b++)m=this.data[b].time,this.checkPeriodChange(e,u,m,y)&&(x++,2<=x&&(r=b,b=v),y=m);q&&1<u&&(w=this.chooseMinorFrequency(u),AmCharts.getPeriodDuration(e,w));if(0<this.gridCountR)for(b=g;b<v;b++)if(m=this.data[b].time,this.checkPeriodChange(e,
44 u,m,h)&&b>=r){g=this.getCoordinate(b-this.start);q=!1;this.nextPeriod[s]&&(q=this.checkPeriodChange(this.nextPeriod[s],1,m,h,s));y=!1;q&&this.markPeriodChange?(q=this.dateFormatsObject[this.nextPeriod[s]],y=!0):q=this.dateFormatsObject[s];h=AmCharts.formatDate(new Date(m),q);if(b==d&&!n||b==l&&!k)h=" ";C?C=!1:(t||(y=!1),g-this.previousPos>this.safeDistance*Math.cos(this.labelRotation*Math.PI/180)&&(this.labelFunction&&(h=this.labelFunction(h,new Date(m),this,e,u,p)),this.boldLabels&&(y=!0),p=new this.axisItemRenderer(this,
45 g,h,void 0,void 0,void 0,void 0,y),x=p.graphics(),this.pushAxisItem(p),p=x.getBBox().width,AmCharts.isModern||(p-=g),this.previousPos=g+p));p=h=m}else isNaN(w)||(this.checkPeriodChange(e,w,m,B)&&(this.gridAlpha=this.minorGridAlpha,g=this.getCoordinate(b-this.start),q=new this.axisItemRenderer(this,g),this.pushAxisItem(q),B=m),this.gridAlpha=a)}for(b=0;b<this.data.length;b++)if(n=this.data[b])k=this.parseDates&&!this.equalSpacing?Math.round((n.time-this.startTime)*this.stepWidth+this.cellWidth/2):
46 this.getCoordinate(b-f),n.x[this.id]=k;n=this.guides.length;for(b=0;b<n;b++)k=this.guides[b],t=t=t=a=d=NaN,w=k.above,k.toCategory&&(t=c.getCategoryIndexByValue(k.toCategory),isNaN(t)||(d=this.getCoordinate(t-f),k.expand&&(d+=this.cellWidth/2),p=new this.axisItemRenderer(this,d,"",!0,NaN,NaN,k),this.pushAxisItem(p,w))),k.category&&(t=c.getCategoryIndexByValue(k.category),isNaN(t)||(a=this.getCoordinate(t-f),k.expand&&(a-=this.cellWidth/2),t=(d-a)/2,p=new this.axisItemRenderer(this,a,k.label,!0,NaN,
47 t,k),this.pushAxisItem(p,w))),k.toDate&&(k.toDate instanceof Date||(k.toDate=AmCharts.stringToDate(k.toDate,c.dataDateFormat)),this.equalSpacing?(t=c.getClosestIndex(this.data,"time",k.toDate.getTime(),!1,0,this.data.length-1),isNaN(t)||(d=this.getCoordinate(t-f))):d=(k.toDate.getTime()-this.startTime)*this.stepWidth,p=new this.axisItemRenderer(this,d,"",!0,NaN,NaN,k),this.pushAxisItem(p,w)),k.date&&(k.date instanceof Date||(k.date=AmCharts.stringToDate(k.date,c.dataDateFormat)),this.equalSpacing?
48 (t=c.getClosestIndex(this.data,"time",k.date.getTime(),!1,0,this.data.length-1),isNaN(t)||(a=this.getCoordinate(t-f))):a=(k.date.getTime()-this.startTime)*this.stepWidth,t=(d-a)/2,p="H"==this.orientation?new this.axisItemRenderer(this,a,k.label,!1,2*t,NaN,k):new this.axisItemRenderer(this,a,k.label,!1,NaN,t,k),this.pushAxisItem(p,w)),(0<d||0<a)&&(d<this.width||a<this.width)&&(d=new this.guideFillRenderer(this,a,d,k),a=d.graphics(),this.pushAxisItem(d,w),k.graphics=a,a.index=b,k.balloonText&&this.addEventListeners(a,
49 k))}this.axisCreated=!0;c=this.x;f=this.y;this.set.translate(c,f);this.labelsSet.translate(c,f);this.positionTitle();(c=this.axisLine.set)&&c.toFront();c=this.getBBox().height;2<c-this.previousHeight&&this.autoWrap&&!this.parseDates&&(this.axisCreated=this.chart.marginsUpdated=!1);this.previousHeight=c},chooseMinorFrequency:function(a){for(var b=10;0<b;b--)if(a/b==Math.round(a/b))return a/b},choosePeriod:function(a){var b=AmCharts.getPeriodDuration(this.periods[a].period,this.periods[a].count),c=
50 Math.ceil(this.timeDifference/b),d=this.periods;return this.timeDifference<b&&0<a?d[a-1]:c<=this.gridCountR?d[a]:a+1<d.length?this.choosePeriod(a+1):d[a]},getStepWidth:function(a){var b;this.startOnAxis?(b=this.axisWidth/(a-1),1==a&&(b=this.axisWidth)):b=this.axisWidth/a;return b},getCoordinate:function(a){a*=this.stepWidth;this.startOnAxis||(a+=this.stepWidth/2);return Math.round(a)},timeZoom:function(a,b){this.startTime=a;this.endTime=b},minDuration:function(){var a=AmCharts.extractPeriod(this.minPeriod);
51 return AmCharts.getPeriodDuration(a.period,a.count)},checkPeriodChange:function(a,b,c,d,e){c=new Date(c);var f=new Date(d),l=this.firstDayOfWeek;d=b;"DD"==a&&(b=1);c=AmCharts.resetDateToMin(c,a,b,l).getTime();b=AmCharts.resetDateToMin(f,a,b,l).getTime();return"DD"==a&&"hh"!=e&&c-b<=AmCharts.getPeriodDuration(a,d)?!1:c!=b?!0:!1},generateDFObject:function(){this.dateFormatsObject={};var a;for(a=0;a<this.dateFormats.length;a++){var b=this.dateFormats[a];this.dateFormatsObject[b.period]=b.format}},xToIndex:function(a){var b=
52 this.data,c=this.chart,d=c.rotate,e=this.stepWidth;this.parseDates&&!this.equalSpacing?(a=this.startTime+Math.round(a/e)-this.minDuration()/2,c=c.getClosestIndex(b,"time",a,!1,this.start,this.end+1)):(this.startOnAxis||(a-=e/2),c=this.start+Math.round(a/e));var c=AmCharts.fitToBounds(c,0,b.length-1),f;b[c]&&(f=b[c].x[this.id]);d?f>this.height+1&&c--:f>this.width+1&&c--;0>f&&c++;return c=AmCharts.fitToBounds(c,0,b.length-1)},dateToCoordinate:function(a){return this.parseDates&&!this.equalSpacing?(a.getTime()-
53 this.startTime)*this.stepWidth:this.parseDates&&this.equalSpacing?(a=this.chart.getClosestIndex(this.data,"time",a.getTime(),!1,0,this.data.length-1),this.getCoordinate(a-this.start)):NaN},categoryToCoordinate:function(a){return this.chart?(a=this.chart.getCategoryIndexByValue(a),this.getCoordinate(a-this.start)):NaN},coordinateToDate:function(a){return this.equalSpacing?(a=this.xToIndex(a),new Date(this.data[a].time)):new Date(this.startTime+a/this.stepWidth)}});
amcharts/themes/black.js
File was created 1 AmCharts.themes.black = {
2
3 themeName: "black",
4
5 AmChart: {
6 color: "#e7e7e7", backgroundColor: "#222222"
7 },
8
9 AmCoordinateChart: {
10 colors: ["#de4c4f", "#d8854f", "#eea638", "#a7a737", "#86a965", "#8aabb0", "#69c8ff", "#cfd27e", "#9d9888", "#916b8a", "#724887", "#7256bc"]
11 },
12
13 AmStockChart: {
14 colors: ["#de4c4f", "#d8854f", "#eea638", "#a7a737", "#86a965", "#8aabb0", "#69c8ff", "#cfd27e", "#9d9888", "#916b8a", "#724887", "#7256bc"]
15 },
16
17 AmSlicedChart: {
18 outlineAlpha: 1,
19 outlineThickness: 2,
20 labelTickColor: "#FFFFFF",
21 labelTickAlpha: 0.3,
22 colors: ["#de4c4f", "#d8854f", "#eea638", "#a7a737", "#86a965", "#8aabb0", "#69c8ff", "#cfd27e", "#9d9888", "#916b8a", "#724887", "#7256bc"]
23 },
24
25 AmRectangularChart: {
26 zoomOutButtonColor: '#FFFFFF',
27 zoomOutButtonRollOverAlpha: 0.15,
28 zoomOutButtonImage: "lensWhite.png"
29 },
30
31 AxisBase: {
32 axisColor: "#FFFFFF",
33 axisAlpha: 0.3,
34 gridAlpha: 0.1,
35 gridColor: "#FFFFFF",
36 dashLength: 3
37 },
38
39 ChartScrollbar: {
40 backgroundColor: "#000000",
41 backgroundAlpha: 0.2,
42 graphFillAlpha: 0.2,
43 graphLineAlpha: 0,
44 graphFillColor: "#FFFFFF",
45 selectedGraphFillColor: "#FFFFFF",
46 selectedGraphFillAlpha: 0.4,
47 selectedGraphLineColor: "#FFFFFF",
48 selectedBackgroundColor: "#FFFFFF",
49 selectedBackgroundAlpha: 0.09,
50 gridAlpha: 0.15
51 },
52
53 ChartCursor: {
54 cursorColor: "#FFFFFF",
55 color: "#000000",
56 cursorAlpha: 0.5
57 },
58
59 AmLegend: {
60 color: "#e7e7e7"
61 },
62
63 AmGraph: {
64 lineAlpha: 0.9
65 },
66
67
68 GaugeArrow: {
69 color: "#FFFFFF",
70 alpha: 0.8,
71 nailAlpha: 0,
72 innerRadius: "40%",
73 nailRadius: 15,
74 startWidth: 15,
75 borderAlpha: 0.8,
76 nailBorderAlpha: 0
77 },
78
79 GaugeAxis: {
80 tickColor: "#FFFFFF",
81 tickAlpha: 1,
82 tickLength: 15,
83 minorTickLength: 8,
84 axisThickness: 3,
85 axisColor: '#FFFFFF',
86 axisAlpha: 1,
87 bandAlpha: 0.8
88 },
89
90 TrendLine: {
91 lineColor: "#c03246",
92 lineAlpha: 0.8
93 },
94
95 // ammap
96 AreasSettings: {
97 alpha: 0.8,
98 color: "#FFFFFF",
99 colorSolid: "#000000",
100 unlistedAreasAlpha: 0.4,
101 unlistedAreasColor: "#FFFFFF",
102 outlineColor: "#000000",
103 outlineAlpha: 0.5,
104 outlineThickness: 0.5,
105 rollOverColor: "#3c5bdc",
106 rollOverOutlineColor: "#000000",
107 selectedOutlineColor: "#000000",
108 selectedColor: "#f15135",
109 unlistedAreasOutlineColor: "#000000",
110 unlistedAreasOutlineAlpha: 0.5
111 },
112
113 LinesSettings: {
114 color: "#FFFFFF",
115 alpha: 0.8
116 },
117
118 ImagesSettings: {
119 alpha: 0.8,
120 labelColor: "#FFFFFF",
121 color: "#FFFFFF",
122 labelRollOverColor: "#3c5bdc"
123 },
124
125 ZoomControl: {
126 buttonRollOverColor: "#3c5bdc",
127 buttonFillColor: "#738f58",
128 buttonBorderColor: "#738f58",
129 buttonFillAlpha: 0.8,
130 gridBackgroundColor: "#FFFFFF",
131 buttonBorderAlpha:0,
132 buttonCornerRadius:2,
133 gridAlpha:0.5,
134 gridBackgroundColor:"#FFFFFF",
135 homeIconFile:"homeIconWhite.gif",
136 buttonIconAlpha:0.6,
137 gridAlpha: 0.2,
138 buttonSize:20
139 },
140
141 SmallMap: {
142 mapColor: "#FFFFFF",
143 rectangleColor: "#FFFFFF",
144 backgroundColor: "#000000",
145 backgroundAlpha: 0.7,
146 borderThickness: 1,
147 borderAlpha: 0.8
148 },
149
150 // the defaults below are set using CSS syntax, you can use any existing css property
151 // if you don't use Stock chart, you can delete lines below
152 PeriodSelector: {
153 color: "#e7e7e7"
154 },
155
156 PeriodButton: {
157 color: "#e7e7e7",
158 background: "transparent",
159 opacity: 0.7,
160 border: "1px solid rgba(255, 255, 255, .15)",
161 MozBorderRadius: "5px",
162 borderRadius: "5px",
163 margin: "1px",
164 outline: "none",
165 boxSizing: "border-box"
166 },
167
168 PeriodButtonSelected: {
169 color: "#e7e7e7",
170 backgroundColor: "rgba(255, 255, 255, 0.1)",
171 border: "1px solid rgba(255, 255, 255, .3)",
172 MozBorderRadius: "5px",
173 borderRadius: "5px",
174 margin: "1px",
175 outline: "none",
176 opacity: 1,
177 boxSizing: "border-box"
178 },
179
180 PeriodInputField: {
181 color: "#e7e7e7",
182 background: "transparent",
183 border: "1px solid rgba(255, 255, 255, .15)",
184 outline: "none"
185 },
186
187 DataSetSelector: {
188 color: "#e7e7e7",
189 selectedBackgroundColor: "rgba(255, 255, 255, .25)",
190 rollOverBackgroundColor: "rgba(255, 255, 255, .15)"
191 },
192
193 DataSetCompareList: {
194 color: "#e7e7e7",
195 lineHeight: "100%",
196 boxSizing: "initial",
197 webkitBoxSizing: "initial",
198 border: "1px solid rgba(255, 255, 255, .15)"
199 },
200
201 DataSetSelect: {
202 border: "1px solid rgba(255, 255, 255, .15)",
203 outline: "none"
204 }
205
206 };
amcharts/themes/chalk.js
File was created 1 AmCharts.themes.chalk = {
2
3 themeName: "chalk",
4
5 AmChart: {
6 color: "#e7e7e7",
7 fontFamily: "Covered By Your Grace",
8 fontSize: 18,
9 handDrawn: true,
10 backgroundColor: "#282828"
11 },
12
13 AmCoordinateChart: {
14 colors: ["#FFFFFF", "#e384a6", "#f4d499", "#4d90d6", "#c7e38c", "#9986c8", "#edf28c", "#ffd1d4", "#5ee1dc", "#b0eead", "#fef85a", "#8badd2"]
15 },
16
17 AmSlicedChart: {
18 outlineAlpha: 1,
19 labelTickColor: "#FFFFFF",
20 labelTickAlpha: 0.3,
21 colors: ["#FFFFFF", "#e384a6", "#f4d499", "#4d90d6", "#c7e38c", "#9986c8", "#edf28c", "#ffd1d4", "#5ee1dc", "#b0eead", "#fef85a", "#8badd2"]
22 },
23
24 AmStockChart: {
25 colors: ["#FFFFFF", "#e384a6", "#f4d499", "#4d90d6", "#c7e38c", "#9986c8", "#edf28c", "#ffd1d4", "#5ee1dc", "#b0eead", "#fef85a", "#8badd2"]
26 },
27
28 AmRectangularChart: {
29
30 zoomOutButtonColor: '#FFFFFF',
31 zoomOutButtonRollOverAlpha: 0.15,
32 zoomOutButtonImage: "lensWhite.png"
33 },
34
35 AxisBase: {
36 axisColor: "#FFFFFF",
37 gridColor: "#FFFFFF"
38 },
39
40 ChartScrollbar: {
41 backgroundColor: "#FFFFFF",
42 backgroundAlpha: 0.2,
43 graphFillAlpha: 0.5,
44 graphLineAlpha: 0,
45 selectedBackgroundColor: "#000000",
46 selectedBackgroundAlpha: 0.25,
47 fontSize: 15,
48 gridAlpha: 0.15
49 },
50
51 ChartCursor: {
52 cursorColor: "#FFFFFF",
53 color: "#000000"
54 },
55
56 AmLegend: {
57 color: "#e7e7e7",
58 markerSize: 20
59 },
60
61 AmGraph: {
62 lineAlpha: 0.8
63 },
64
65
66 GaugeArrow: {
67 color: "#FFFFFF",
68 alpha: 0.1,
69 nailAlpha: 0,
70 innerRadius: "40%",
71 nailRadius: 15,
72 startWidth: 15,
73 borderAlpha: 0.8,
74 nailBorderAlpha: 0
75 },
76
77 GaugeAxis: {
78 tickColor: "#FFFFFF",
79 tickAlpha: 0.8,
80 tickLength: 15,
81 minorTickLength: 8,
82 axisThickness: 3,
83 axisColor: '#FFFFFF',
84 axisAlpha: 0.8,
85 bandAlpha: 0.4
86 },
87
88 TrendLine: {
89 lineColor: "#c03246",
90 lineAlpha: 0.8
91 },
92
93 // ammap
94 AmMap: {
95 handDrawn: false
96 },
97
98 AreasSettings: {
99 alpha: 0.8,
100 color: "#FFFFFF",
101 colorSolid: "#000000",
102 unlistedAreasAlpha: 0.4,
103 unlistedAreasColor: "#FFFFFF",
104 outlineColor: "#000000",
105 outlineAlpha: 0.5,
106 outlineThickness: 0.5,
107 rollOverColor: "#4d90d6",
108 rollOverOutlineColor: "#000000",
109 selectedOutlineColor: "#000000",
110 selectedColor: "#e384a6",
111 unlistedAreasOutlineColor: "#000000",
112 unlistedAreasOutlineAlpha: 0.5
113 },
114
115 LinesSettings: {
116 color: "#FFFFFF",
117 alpha: 0.8
118 },
119
120 ImagesSettings: {
121 alpha: 0.8,
122 labelFontSize: 16,
123 labelColor: "#FFFFFF",
124 color: "#FFFFFF",
125 labelRollOverColor: "#4d90d6"
126 },
127
128 ZoomControl: {
129 buttonRollOverColor: "#4d90d6",
130 buttonFillColor: "#e384a6",
131 buttonFillAlpha: 0.8,
132 buttonBorderColor: "#FFFFFF",
133 gridBackgroundColor: "#FFFFFF",
134 gridAlpha: 0.8
135 },
136
137 SmallMap: {
138 mapColor: "#FFFFFF",
139 rectangleColor: "#FFFFFF",
140 backgroundColor: "#000000",
141 backgroundAlpha: 0.7,
142 borderThickness: 1,
143 borderAlpha: 0.8
144 },
145
146
147 // the defaults below are set using CSS syntax, you can use any existing css property
148 // if you don't use Stock chart, you can delete lines below
149 PeriodSelector: {
150 fontFamily: "Covered By Your Grace",
151 fontSize:"16px",
152 color: "#e7e7e7"
153 },
154
155 PeriodButton: {
156 fontFamily: "Covered By Your Grace",
157 fontSize:"16px",
158 color: "#e7e7e7",
159 background: "transparent",
160 opacity: 0.7,
161 border: "1px solid rgba(255, 255, 255, .15)",
162 MozBorderRadius: "5px",
163 borderRadius: "5px",
164 margin: "1px",
165 outline: "none",
166 boxSizing: "border-box"
167 },
168
169 PeriodButtonSelected: {
170 fontFamily: "Covered By Your Grace",
171 fontSize:"16px",
172 color: "#e7e7e7",
173 backgroundColor: "rgba(255, 255, 255, 0.1)",
174 border: "1px solid rgba(255, 255, 255, .3)",
175 MozBorderRadius: "5px",
176 borderRadius: "5px",
177 margin: "1px",
178 outline: "none",
179 opacity: 1,
180 boxSizing: "border-box"
181 },
182
183 PeriodInputField: {
184 fontFamily: "Covered By Your Grace",
185 fontSize:"16px",
186 color: "#e7e7e7",
187 background: "transparent",
188 border: "1px solid rgba(255, 255, 255, .15)",
189 outline: "none"
190 },
191
192 DataSetSelector: {
193 fontFamily: "Covered By Your Grace",
194 fontSize:"16px",
195 color: "#e7e7e7",
196 selectedBackgroundColor: "rgba(255, 255, 255, .25)",
197 rollOverBackgroundColor: "rgba(255, 255, 255, .15)"
198 },
199
200 DataSetCompareList: {
201 fontFamily: "Covered By Your Grace",
202 fontSize:"16px",
203 color: "#e7e7e7",
204 lineHeight: "100%",
205 boxSizing: "initial",
206 webkitBoxSizing: "initial",
207 border: "1px solid rgba(255, 255, 255, .15)"
208 },
209
210 DataSetSelect: {
211 fontFamily: "Covered By Your Grace",
212 fontSize:"16px",
213 border: "1px solid rgba(255, 255, 255, .15)",
214 outline: "none"
215 }
216
217 };
amcharts/themes/dark.js
File was created 1 AmCharts.themes.dark = {
2
3 themeName: "dark",
4
5 AmChart: {
6 color: "#e7e7e7", backgroundColor: "#282828"
7 },
8
9 AmCoordinateChart: {
10 colors: ["#ae85c9", "#aab9f7", "#b6d2ff", "#c9e6f2", "#c9f0e1", "#e8d685", "#e0ad63", "#d48652", "#d27362", "#495fba", "#7a629b", "#8881cc"]
11 },
12
13 AmStockChart: {
14 colors: ["#639dbd", "#e8d685", "#ae85c9", "#c9f0e1", "#d48652", "#629b6d", "#719dc3", "#719dc3"]
15 },
16
17 AmSlicedChart: {
18 outlineAlpha: 1,
19 outlineThickness: 2,
20 labelTickColor: "#FFFFFF",
21 labelTickAlpha: 0.3,
22 colors: ["#495fba", "#e8d685", "#ae85c9", "#c9f0e1", "#d48652", "#629b6d", "#719dc3", "#719dc3"]
23 },
24
25 AmRectangularChart: {
26 zoomOutButtonColor: '#FFFFFF',
27 zoomOutButtonRollOverAlpha: 0.15,
28 zoomOutButtonImage: "lensWhite.png"
29 },
30
31 AxisBase: {
32 axisColor: "#FFFFFF",
33 axisAlpha: 0.3,
34 gridAlpha: 0.1,
35 gridColor: "#FFFFFF",
36 dashLength: 3
37 },
38
39 ChartScrollbar: {
40 backgroundColor: "#000000",
41 backgroundAlpha: 0.2,
42 graphFillAlpha: 0.2,
43 graphLineAlpha: 0,
44 graphFillColor: "#FFFFFF",
45 selectedGraphFillColor: "#FFFFFF",
46 selectedGraphFillAlpha: 0.4,
47 selectedGraphLineColor: "#FFFFFF",
48 selectedBackgroundColor: "#FFFFFF",
49 selectedBackgroundAlpha: 0.09,
50 gridAlpha: 0.15
51 },
52
53 ChartCursor: {
54 cursorColor: "#FFFFFF",
55 color: "#000000",
56 cursorAlpha: 0.5
57 },
58
59 AmLegend: {
60 color: "#e7e7e7"
61 },
62
63 AmGraph: {
64 lineAlpha: 0.9
65 },
66
67
68 GaugeArrow: {
69 color: "#FFFFFF",
70 alpha: 0.8,
71 nailAlpha: 0,
72 innerRadius: "40%",
73 nailRadius: 15,
74 startWidth: 15,
75 borderAlpha: 0.8,
76 nailBorderAlpha: 0
77 },
78
79 GaugeAxis: {
80 tickColor: "#FFFFFF",
81 tickAlpha: 1,
82 tickLength: 15,
83 minorTickLength: 8,
84 axisThickness: 3,
85 axisColor: '#FFFFFF',
86 axisAlpha: 1,
87 bandAlpha: 0.8
88 },
89
90 TrendLine: {
91 lineColor: "#c03246",
92 lineAlpha: 0.8
93 },
94
95 // ammap
96 AreasSettings: {
97 alpha: 0.8,
98 color: "#FFFFFF",
99 colorSolid: "#000000",
100 unlistedAreasAlpha: 0.4,
101 unlistedAreasColor: "#FFFFFF",
102 outlineColor: "#000000",
103 outlineAlpha: 0.5,
104 outlineThickness: 0.5,
105 rollOverColor: "#3c5bdc",
106 rollOverOutlineColor: "#000000",
107 selectedOutlineColor: "#000000",
108 selectedColor: "#f15135",
109 unlistedAreasOutlineColor: "#000000",
110 unlistedAreasOutlineAlpha: 0.5
111 },
112
113 LinesSettings: {
114 color: "#FFFFFF",
115 alpha: 0.8
116 },
117
118 ImagesSettings: {
119 alpha: 0.8,
120 labelColor: "#FFFFFF",
121 color: "#FFFFFF",
122 labelRollOverColor: "#3c5bdc"
123 },
124
125 ZoomControl: {
126 buttonRollOverColor: "#3c5bdc",
127 buttonFillColor: "#f15135",
128 buttonFillAlpha: 0.8,
129 gridBackgroundColor: "#FFFFFF",
130 buttonBorderAlpha:0,
131 buttonCornerRadius:2,
132 gridAlpha:0.5,
133 gridBackgroundColor:"#FFFFFF",
134 homeIconFile:"homeIconWhite.gif",
135 buttonIconAlpha:0.6,
136 gridAlpha: 0.2,
137 buttonSize:20
138 },
139
140 SmallMap: {
141 mapColor: "#FFFFFF",
142 rectangleColor: "#FFFFFF",
143 backgroundColor: "#000000",
144 backgroundAlpha: 0.7,
145 borderThickness: 1,
146 borderAlpha: 0.8
147 },
148
149 // the defaults below are set using CSS syntax, you can use any existing css property
150 // if you don't use Stock chart, you can delete lines below
151 PeriodSelector: {
152 color: "#e7e7e7"
153 },
154
155 PeriodButton: {
156 color: "#e7e7e7",
157 background: "transparent",
158 opacity: 0.7,
159 border: "1px solid rgba(255, 255, 255, .15)",
160 MozBorderRadius: "5px",
161 borderRadius: "5px",
162 margin: "1px",
163 outline: "none",
164 boxSizing: "border-box"
165 },
166
167 PeriodButtonSelected: {
168 color: "#e7e7e7",
169 backgroundColor: "rgba(255, 255, 255, 0.1)",
170 border: "1px solid rgba(255, 255, 255, .3)",
171 MozBorderRadius: "5px",
172 borderRadius: "5px",
173 margin: "1px",
174 outline: "none",
175 opacity: 1,
176 boxSizing: "border-box"
177 },
178
179 PeriodInputField: {
180 color: "#e7e7e7",
181 background: "transparent",
182 border: "1px solid rgba(255, 255, 255, .15)",
183 outline: "none"
184 },
185
186 DataSetSelector: {
187 color: "#e7e7e7",
188 selectedBackgroundColor: "rgba(255, 255, 255, .25)",
189 rollOverBackgroundColor: "rgba(255, 255, 255, .15)"
190 },
191
192 DataSetCompareList: {
193 color: "#e7e7e7",
194 lineHeight: "100%",
195 boxSizing: "initial",
196 webkitBoxSizing: "initial",
197 border: "1px solid rgba(255, 255, 255, .15)"
198 },
199
200 DataSetSelect: {
201 border: "1px solid rgba(255, 255, 255, .15)",
202 outline: "none"
203 }
204
205 };