(function(){var d;window.AmCharts?d=window.AmCharts:(d={},window.AmCharts=d,d.themes={},d.maps={},d.inheriting={},d.charts=[],d.onReadyArray=[],d.useUTC=!1,d.updateRate=60,d.uid=0,d.lang={},d.translations={},d.mapTranslations={},d.windows={},d.initHandlers=[]);d.Class=function(a){var b=function(){arguments[0]!==d.inheriting&&(this.events={},this.construct.apply(this,arguments))};a.inherits?(b.prototype=new a.inherits(d.inheriting),b.base=a.inherits.prototype,delete a.inherits):(b.prototype.createEvents= function(){for(var a=0,b=arguments.length;ad.IEversion&&0b)return a;h=-1;for(a=(k=a.split(/\r\n|\n|\r/)).length;++hb;k[h]+=d.trim(g.slice(0,f))+((g=g.slice(f)).length?c:""))f=2==e||(f=g.slice(0,b+1).match(/\S*(\s)?$/))[1]?b:f.input.length-f[0].length||1==e&&b||f.input.length+(f=g.slice(b).match(/^\S*/))[0].length;g=d.trim(g)}return k.join(c)};d.trim=function(a){return a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};d.wrappedText=function(a,b,c,e,h,f,g,k){var l=d.text(a,b,c,e,h,f,g);if(l){var m=l.getBBox();if(m.width>k){var n="\n";d.isModern||(n="
");k=Math.floor(k/(m.width/b.length)); 2c&&(a=c);return a};d.isDefined=function(a){return void 0===a?!1:!0};d.stripNumbers=function(a){return a.replace(/[0-9]+/g,"")};d.roundTo=function(a,b){if(0>b)return a;var c=Math.pow(10,b);return Math.round(a*c)/c};d.toFixed=function(a,b){var c=String(Math.round(a*Math.pow(10,b)));if(0=g[b].contains){var l=a-Math.floor(a/g[b].contains)*g[b].contains;"ss"==b?(l=d.formatNumber(l,f),1==l.split(k)[0].length&&(l="0"+l)):l=d.roundTo(l,f.precision);("mm"==b||"hh"==b)&&10>l&&(l="0"+l);c=l+""+e[b]+""+c;a=Math.floor(a/g[b].contains);b=g[b].nextInterval;return d.formatDuration(a,b,c,e,h,f)}"ss"==b&&(a=d.formatNumber(a,f),1==a.split(k)[0].length&&(a="0"+a));("mm"==b||"hh"==b)&& 10>a&&(a="0"+a);c=a+""+e[b]+""+c;if(g[h].count>g[b].count)for(a=g[b].count;aa?"-":"";a=Math.abs(a);var k=String(a),l=!1;-1!=k.indexOf("e")&&(l=!0);0<=c&&!l&&(k=d.toFixed(a,c));var m= "";if(l)m=k;else{var k=k.split("."),l=String(k[0]),n;for(n=l.length;0<=n;n-=3)m=n!=l.length?0!==n?l.substring(n-3,n)+b+m:l.substring(n-3,n)+m:l.substring(n-3,n);void 0!==k[1]&&(m=m+f+k[1]);void 0!==c&&0=c.x-5&&a<=c.x+c.width+5&&b>=c.y-5&&b<=c.y+c.height+5?!0:!1};d.isPercents=function(a){if(-1!=String(a).indexOf("%"))return!0};d.formatValue=function(a,b,c,e,h,f,g,k){if(b){void 0===h&&(h="");var l;for(l=0;la&&(g="-");a=Math.abs(a);if(1=b[k].number&&(l=a/b[k].number,m=+e.precision,1>m&&(m=1),c=d.roundTo(l,m),m=d.formatNumber(c,{precision:-1,decimalSeparator:e.decimalSeparator,thousandsSeparator:e.thousandsSeparator}),!h||l==c)){f=g+""+m+""+b[k].prefix;break}}else for(k=0;k"==a&&(a="easeOutSine");"<"==a&&(a="easeInSine");"elastic"==a&&(a="easeOutElastic");return a};d.getObjById=function(a,b){var c,e;for(e=0;e"));return a};d.fixBrakes=function(a){if(d.isModern){var b= RegExp("
","g");a&&(a=a.replace(b,"\n"))}else a=d.fixNewLines(a);return a};d.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;cb)return e/2*b*b+c;b--;return-e/2*(b*(b-2)-1)+c};d.easeInSine=function(a,b,c,e,d){return-e*Math.cos(b/d*(Math.PI/2))+e+c};d.easeOutSine=function(a,b,c,e,d){return e*Math.sin(b/d*(Math.PI/2))+c};d.easeOutElastic=function(a,b,c,e,d){a=1.70158;var f=0,g=e;if(0===b)return c;if(1==(b/=d))return c+e;f||(f=.3*d);gb?Math.abs(b)-1:Math.abs(b);var d;for(d=0;db?+("0."+c+String(a)):+(String(a)+c)};d.setCN=function(a,b,c,e){if(a.addClassNames&&b&&(b=b.node)&&c){var d=b.getAttribute("class");a=a.classNamePrefix+"-";e&&(a="");d?b.setAttribute("class",d+" "+a+c):b.setAttribute("class", a+c)}};d.parseDefs=function(a,b){for(var c in a){var e=typeof a[c];if(0a&&(a=3)):a=this.width/this.minHorizontalGap,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;this.titleLabel=null;if(a){var b=this.chart,c=this.titleColor;void 0===c&&(c=b.color);var e=this.titleFontSize;isNaN(e)&&(e= b.fontSize+1);a=d.text(b.container,a,c,b.fontFamily,e,this.titleAlign,this.titleBold);d.setCN(b,a,this.bcn+"title");this.titleLabel=a}},positionTitle:function(){var a=this.titleLabel;if(a){var b,c,e=this.labelsSet,h={};0 this.autoRotateCount&&!isNaN(this.autoRotateAngle)&&(this.labelRotationR=this.autoRotateAngle),a=k;a<=B;a++){p=q+z*(a+Math.floor((C-q)/z))-D;"DD"==A&&(p+=36E5);p=d.resetDateToMin(new Date(p),A,x,t).getTime();"MM"==A&&(h=(p-l)/z,1.5<=(p-l)/z&&(p=p-(h-1)*z+d.getPeriodDuration("DD",3),p=d.resetDateToMin(new Date(p),A,1).getTime(),D+=z));h=(p-this.startTime)*this.stepWidth;if("radar"==b.type){if(h=this.axisWidth-h,0>h||h>this.axisWidth)continue}else this.rotate?"date"==this.type&&"middle"==this.gridPosition&& (L=-z*this.stepWidth/2):"date"==this.type&&(h=this.axisWidth-h);f=!1;this.nextPeriod[g]&&(f=this.checkPeriodChange(this.nextPeriod[g],1,p,l,g));l=!1;f&&this.markPeriodChange?(f=this.dateFormatsObject[this.nextPeriod[g]],this.twoLineMode&&(f=this.dateFormatsObject[g]+"\n"+f,f=d.fixBrakes(f)),l=!0):f=this.dateFormatsObject[g];r||(l=!1);this.currentDateFormat=f;f=d.formatDate(new Date(p),f,b);if(a==k&&!c||a==B&&!e)f=" ";this.labelFunction&&(f=this.labelFunction(f,new Date(p),this,A,x,m).toString()); this.boldLabels&&(l=!0);m=new this.axisItemRenderer(this,h,f,!1,n,L,!1,l);this.pushAxisItem(m);m=l=p;if(!isNaN(u))for(h=1;hb||b>this.height)return;if(isNaN(b)){this.hideBalloon();return}b=this.adjustBalloonCoordinate(b,e);e=this.coordinateToValue(b)}else{if(0>a||a>this.width)return;if(isNaN(a)){this.hideBalloon();return}a=this.adjustBalloonCoordinate(a,e);e=this.coordinateToValue(a)}var f;if(d=this.chart.chartCursor)f= d.index;if(this.balloon&&void 0!==e&&this.balloon.enabled){if(this.balloonTextFunction){if("date"==this.type||!0===this.parseDates)e=new Date(e);e=this.balloonTextFunction(e)}else this.balloonText?e=this.formatBalloonText(this.balloonText,f,c):isNaN(e)||(e=this.formatValue(e,c));if(a!=this.prevBX||b!=this.prevBY)this.balloon.setPosition(a,b),this.prevBX=a,this.prevBY=b,e&&this.balloon.showBalloon(e)}},adjustBalloonCoordinate:function(a){return a},createBalloon:function(){var a=this.chart,b=a.chartCursor; b&&(b=b.cursorPosition,"mouse"!=b&&(this.stickBalloonToCategory=!0),"start"==b&&(this.stickBalloonToStart=!0),"ValueAxis"==this.cname&&(this.stickBalloonToCategory=!1));this.balloon&&(this.balloon.destroy&&this.balloon.destroy(),d.extend(this.balloon,a.balloon,!0))},setBalloonBounds:function(){var a=this.balloon;if(a){var b=this.chart;a.cornerRadius=0;a.shadowAlpha=0;a.borderThickness=1;a.borderAlpha=1;a.adjustBorderColor=!1;a.showBullet=!1;this.balloon=a;a.chart=b;a.mainSet=b.plotBalloonsSet;a.pointerWidth= this.tickLength;if(this.parseDates||"date"==this.type)a.pointerWidth=0;b="V";"V"==this.orientation&&(b="H");this.stickBalloonToCategory||(a.animationDuration=0);var c,e,d,f,g=this.inside,k=this.width,l=this.height;switch(this.position){case "bottom":c=0;e=k;g?(d=0,f=l):(d=l,f=l+1E3);break;case "top":c=0;e=k;g?(d=0,f=l):(d=-1E3,f=0);break;case "left":d=0;f=l;g?(c=0,e=k):(c=-1E3,e=0);break;case "right":d=0,f=l,g?(c=0,e=k):(c=k,e=k+1E3)}a.drop||(a.pointerOrientation=b);a.setBounds(c,d,e,f)}}})})();(function(){var d=window.AmCharts;d.ValueAxis=d.Class({inherits:d.AxisBase,construct:function(a){this.cname="ValueAxis";this.createEvents("axisChanged","logarithmicAxisFailed","axisZoomed","axisIntZoomed");d.ValueAxis.base.construct.call(this,a);this.dataChanged=!0;this.stackType="none";this.position="left";this.unitPosition="right";this.includeAllValues=this.recalculateToPercents=this.includeHidden=this.includeGuidesInMinMax=this.integersOnly=!1;this.durationUnits={DD:"d. ",hh:":",mm:":",ss:""}; this.scrollbar=!1;this.baseValue=0;this.radarCategoriesEnabled=!0;this.gridType="polygons";this.useScientificNotation=!1;this.axisTitleOffset=10;this.pointPosition="axis";this.minMaxMultiplier=1;this.logGridLimit=2;this.totalTextOffset=this.treatZeroAs=0;this.minPeriod="ss";this.relativeStart=0;this.relativeEnd=1;d.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&&this.synchronizeWith?(d.isString(this.synchronizeWith)&&(this.synchronizeWith=a.getValueAxisById(this.synchronizeWith)),this.synchronizeWith&&(this.synchronizeWithAxis(this.synchronizeWith),this.foundGraphs=!0)):(this.foundGraphs=!1,this.getMinMax(),0===this.start&&this.end==this.data.length-1&&isNaN(this.minZoom)&&isNaN(this.maxZoom)&&(this.fullMin= this.min,this.fullMax=this.max,"date"!=this.type&&(isNaN(this.minimum)||(this.fullMin=this.minimum),isNaN(this.maximum)||(this.fullMax=this.maximum)),this.logarithmic&&(this.fullMin=this.logMin,0===this.fullMin&&(this.fullMin=this.treatZeroAs)),"date"==this.type&&(this.minimumDate||(this.fullMin=this.minRR),this.maximumDate||(this.fullMax=this.maxRR))))},draw:function(){d.ValueAxis.base.draw.call(this);var a=this.chart,b=this.set;this.labelRotationR=this.labelRotation;d.setCN(a,this.set,"value-axis value-axis-"+ this.id);d.setCN(a,this.labelsSet,"value-axis value-axis-"+this.id);d.setCN(a,this.axisLine.axisSet,"value-axis value-axis-"+this.id);var c=this.type;"duration"==c&&(this.duration="ss");!0===this.dataChanged&&(this.updateData(),this.dataChanged=!1);"date"==c&&(this.logarithmic=!1,this.min=this.minRR,this.max=this.maxRR,this.reversed=!1,this.getDateMinMax());if(this.logarithmic){var e=this.treatZeroAs,h=this.getExtremes(0,this.data.length-1).min;this.logMin=h;this.minReal=h||0>=this.minimum){this.fire({type:"logarithmicAxisFailed",chart:a});return}}this.grid0=null;var f,g,k=a.dx,l=a.dy,e=!1,h=this.logarithmic;if(isNaN(this.min)||isNaN(this.max)||!this.foundGraphs||Infinity==this.min||-Infinity==this.max)e=!0;else{"date"==this.type&&this.min==this.max&&(this.max+=this.minDuration(),this.min-=this.minDuration());var m=this.labelFrequency,n=this.showFirstLabel,q=this.showLastLabel,p=1,t=0;this.minCalc=this.min;this.maxCalc= this.max;this.strictMinMax&&(isNaN(this.minimum)||(this.min=this.minimum),isNaN(this.maximum)||(this.max=this.maximum));isNaN(this.minZoom)||(this.minReal=this.min=this.minZoom);isNaN(this.maxZoom)||(this.max=this.maxZoom);if(this.logarithmic){g=Math.log(this.fullMax)*Math.LOG10E-Math.log(this.fullMin)*Math.LOG10E;var r=Math.log(this.max)/Math.LN10-Math.log(this.fullMin)*Math.LOG10E;this.relativeStart=(Math.log(this.minReal)/Math.LN10-Math.log(this.fullMin)*Math.LOG10E)/g;this.relativeEnd=r/g}else this.relativeStart= d.fitToBounds((this.min-this.fullMin)/(this.fullMax-this.fullMin),0,1),this.relativeEnd=d.fitToBounds((this.max-this.fullMin)/(this.fullMax-this.fullMin),0,1);var r=Math.round((this.maxCalc-this.minCalc)/this.step)+1,u;!0===h?(u=Math.log(this.max)*Math.LOG10E-Math.log(this.minReal)*Math.LOG10E,this.stepWidth=this.axisWidth/u,u>this.logGridLimit&&(r=Math.ceil(Math.log(this.max)*Math.LOG10E)+1,t=Math.round(Math.log(this.minReal)*Math.LOG10E),r>this.gridCountR&&(p=Math.ceil(r/this.gridCountR)))):this.stepWidth= this.axisWidth/(this.max-this.min);var w=0;1>this.step&&-1this.maxDecCount&&(w=this.maxDecCount);var y=this.precision;isNaN(y)||(w=y);isNaN(this.maxZoom)&&(this.max=d.roundTo(this.max,this.maxDecCount),this.min=d.roundTo(this.min,this.maxDecCount));g={};g.precision=w;g.decimalSeparator=a.nf.decimalSeparator;g.thousandsSeparator=a.nf.thousandsSeparator;this.numberFormatter=g;this.exponential=!1;for(g=t;g=this.autoRotateCount&&!isNaN(this.autoRotateAngle)&& (this.labelRotationR=this.autoRotateAngle),h&&r++,g=t;gthis.logGridLimit&&(c=Math.pow(10,g)));t=this.formatValue(c,!1,g);Math.round(g/m)!=g/m&&(t=void 0);if(0===g&&!n||g==r-1&&!q)t=" ";f=this.getCoordinate(c);var z;this.rotate&&this.autoWrap&&(z=this.stepWidth*w-10);t=new this.axisItemRenderer(this,f,t,void 0,z,void 0,void 0,this.boldLabels); this.pushAxisItem(t);if(c==this.baseValue&&"radar"!=a.type){var B,C,t=this.width,D=this.height;"H"==this.orientation?0<=f&&f<=t+1&&(B=[f,f,f+k],C=[D,0,l]):0<=f&&f<=D+1&&(B=[0,t,t+k],C=[f,f,f+l]);B&&(t=d.fitToBounds(2*this.gridAlpha,0,1),isNaN(this.zeroGridAlpha)||(t=this.zeroGridAlpha),t=d.line(a.container,B,C,this.gridColor,t,1,this.dashLength),t.translate(this.x,this.y),this.grid0=t,a.axesSet.push(t),t.toBack(),d.setCN(a,t,this.bcn+"zero-grid-"+this.id),d.setCN(a,t,this.bcn+"zero-grid"))}if(!isNaN(A)&& 0this.logGridLimit&&(A=Math.pow(10,g+p)),t=10,A=(A-c)/t);f=this.gridAlpha;this.gridAlpha=this.minorGridAlpha;for(D=1;Dthis.baseValue&&this.max>this.baseValue&&(g=this.min);this.minc&&(f.precision=Math.abs(c)),b&&1b&&c.shift();for(var e=Math.floor(Math.log(Math.abs(a))*Math.LOG10E),d=0;da){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=[],e=[],h=[],f=[],g,k=this.chart.graphs,l,m,n,q,p,t=this.baseValue,r=!1;if("line"==a||"step"==a||"smoothedLine"==a)r=!0;if(r&&("regular"==b||"100%"==b))for(q=0;qg?(m.values.close=g,isNaN(e[p])?m.values.open=t:(m.values.close+=e[p],m.values.open= e[p]),e[p]=m.values.close):(m.values.close=g,isNaN(h[p])?m.values.open=t:(m.values.close+=h[p],m.values.open=h[p]),h[p]=m.values.close)))}}for(p=this.start;p<=this.end;p++)for(q=0;qc?(m.values.close=d.fitToBounds(c+e[p],-100,100),m.values.open=e[p],e[p]=m.values.close):(m.values.close=d.fitToBounds(c+h[p],-100,100),m.values.open=h[p],h[p]=m.values.close)))))},recalculate:function(){var a=this.chart,b=a.graphs,c;for(c=0;cq&&g++}if(m=a.recalculateFromDate)m=d.getDate(m,a.dataDateFormat,"fff"),g=a.getClosestIndex(a.chartData,"time",m.getTime(),!0,0,a.chartData.length),k=a.chartData.length-1;for(m=g;m<=k&&(g=this.data[m].axes[this.id].graphs[e.id],f=g.values[h],e.recalculateValue&&(f=g.dataContext[e.valueField+ e.recalculateValue]),isNaN(f));m++);this.recBaseValue=f;for(h=l;h<=k;h++){g=this.data[h].axes[this.id].graphs[e.id];g.percents={};var l=g.values,p;for(p in l)g.percents[p]="percents"!=p?l[p]/f*100-100:l[p]}}}},getMinMax:function(){var a=!1,b=this.chart,c=b.graphs,e;for(e=0;ethis.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);"date"==this.type&&this.getDateMinMax();this.min>this.max&&(a=this.max,this.max=this.min,this.min=a);isNaN(this.minZoom)||(this.min=this.minZoom);isNaN(this.maxZoom)||(this.max=this.maxZoom);this.minCalc=this.min;this.maxCalc=this.max;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;e=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)&&(this.max=Math.ceil(this.max/e)*e+e);isNaN(this.minimum)&&(this.min=Math.floor(this.min/e)*e-e);0>this.min&&0<=a&&(this.min=0);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;e=Math.pow(10,Math.floor(Math.log(Math.abs(c))*Math.LOG10E))/ 10;this.step=Math.ceil(c/this.gridCountR/e)*e;c=Math.pow(10,Math.floor(Math.log(Math.abs(this.step))*Math.LOG10E));c=d.fixStepE(c);e=Math.ceil(this.step/c);5=e&&2c?(this.maxDecCount=Math.abs(Math.log(Math.abs(c))*Math.LOG10E),this.maxDecCount=Math.round(this.maxDecCount),this.step=d.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=b&&(this.max=0);1e&&(e=l);else for(var m in k)k.hasOwnProperty(m)&&"percents"!=m&&"total"!=m&&(l=k[m],le&&(e=l))}}}return{min:c,max:e}},zoomOut:function(){this.maxZoom=this.minZoom=NaN;this.zoomToRelativeValues(0,1)},zoomToRelativeValues:function(a,b,c){if(this.reversed){var e=a;a=1-b;b=1-e}var d=this.fullMax,e=this.fullMin,f= e+(d-e)*a,g=e+(d-e)*b;this.logarithmic&&(d=Math.log(d)*Math.LOG10E-Math.log(e)*Math.LOG10E,f=Math.pow(10,d*a+Math.log(e)*Math.LOG10E),g=Math.pow(10,d*b+Math.log(e)*Math.LOG10E));return this.zoomToValues(f,g,c)},zoomToValues:function(a,b,c){if(bn?(v=X+ha*Math.sin(T)-B-3+2,G+=-ha*Math.cos(T)-Pa*Math.sin(T)-4):v-=B+r+3+3,v-=Z):(0n?(v=X+B+3-ha/2*Math.sin(T)+2,G+=ha/2*Math.cos(T)):v+=B+x+3+3,v+=Z)):(v+=ma+r/2-da,G+=va,H?(0ya+2||0>f))ba.remove(),ba=null}else{0<=b&&b<=X+1&&(0X+1||vc&&"object"==typeof n&&(n=n.join(",").split(",").reverse());"V"==g?(g=d.rect(l,a.width,c,n,m),g.translate(h,b-k+f)):(g=d.rect(l, c,a.height,n,m),g.translate(b-k+h,f));d.setCN(a.chart,g,"guide-fill");e.id&&d.setCN(a.chart,g,"guide-fill-"+e.id);this.set=l.set([g])},graphics:function(){return this.set},getLabel:function(){}})})();(function(){var d=window.AmCharts;d.AmChart=d.Class({construct:function(a){this.svgIcons=this.tapToActivate=!0;this.theme=a;this.classNamePrefix="amcharts";this.addClassNames=!1;this.version="3.19.0";d.addChart(this);this.createEvents("buildStarted","dataUpdated","init","rendered","drawn","failed","resized","animationFinished");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.autoResize=!0;this.autoDisplay=!1;this.addCodeCredits=!0;this.precision=-1;this.percentPrecision=2;this.decimalSeparator=".";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=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;this.product="amcharts";this.animations=[];this.balloon=new d.AmBalloon(this.theme);this.balloon.chart=this;this.processTimeout=0;this.processCount=1E3;this.animatable=[];d.applyTheme(this,a,"AmChart")},drawChart:function(){0a||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 e=this.legendDiv,d=e.offsetWidth;isNaN(c.width)||(d=c.width);c.ieW&&(d=c.ieW);var f=e.offsetHeight,e=e.style,g=this.chartDiv.style,c=c.position;if("right"==c||"left"==c){a-=d;if(0>a||isNaN(a))a=0;g.width=a+"px";this.balloon.setBounds(2,2,a-2,this.realHeight);"left"==c?(g.left=d+"px",e.left="0px"):(g.left="0px", e.left=a+"px");b>f&&(e.top=(b-f)/2+"px")}}return a},getTitleHeight:function(){this.drawTitles(!0);return this.titleHeight},addTitle:function(a,b,c,e,d){isNaN(b)&&(b=this.fontSize+2);a={text:a,size:b,color:c,alpha:e,bold:d,enabled:!0};this.titles.push(a);return a},handleWheel:function(a){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(){},handleDocTouchStart:function(){this.hideBalloonReal(); this.handleMouseMove();this.tmx=this.mouseX;this.tmy=this.mouseY},handleDocTouchEnd:function(){-.5Math.abs(this.mouseX-this.tmx)&&4>Math.abs(this.mouseY-this.tmy)&&(this.tapped=!0)):this.tapped=!1},addListeners:function(){var a=this,b=a.chartDiv;document.addEventListener?(a.panEventsEnabled&&(b.style.msTouchAction="none",b.style.touchAction="none"),"ontouchstart"in document.documentElement&& (b.addEventListener("touchstart",function(b){a.handleTouchStart.call(a,b)},!0),b.addEventListener("touchmove",function(b){a.handleMouseMove.call(a,b)},!0),b.addEventListener("touchend",function(b){a.handleTouchEnd.call(a,b)},!0),document.addEventListener("touchstart",function(b){a.handleDocTouchStart.call(a,b)}),document.addEventListener("touchend",function(b){a.handleDocTouchEnd.call(a,b)})),b.addEventListener("mousedown",function(b){a.mouseIsOver=!0;a.handleMouseMove.call(a,b);a.handleMouseDown.call(a, b)},!0),b.addEventListener("mouseover",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(){this.skipEvents||(this.dispatchDataUpdated&&(this.dispatchDataUpdated=!1,this.fire({type:"dataUpdated",chart:this})), this.chartCreated||(this.chartCreated=!0,this.fire({type:"init",chart:this})),this.chartRendered||(this.fire({type:"rendered",chart:this}),this.chartRendered=!0),this.fire({type:"drawn",chart:this}));this.skipEvents=!1},validateSize:function(){var a=this;a.premeasure();a.checkDisplay();if(a.divRealWidth!=a.previousWidth||a.divRealHeight!=a.previousHeight){var b=a.legend;if(0a.valueAxis.minMaxMultiplier&&a.positiveClip(a.set));break;case "radar":a.createRadarGraph();break;case "xy":a.createXYGraph()}a.playedTO=setTimeout(function(){a.setAnimationPlayed.call(a)},500*a.chart.startDuration)}},setAnimationPlayed:function(){this.animationPlayed=!0},createXYGraph:function(){var a=[],b=[],c=this.xAxis,e=this.yAxis;this.pmh=e.height;this.pmw=c.width;this.pmy=this.pmx= 0;var d;for(d=this.start;d<=this.end;d++){var f=this.data[d].axes[c.id].graphs[this.id],g=f.values,k=g.x,l=g.y,g=c.getCoordinate(k,this.noRounding),m=e.getCoordinate(l,this.noRounding);if(!isNaN(k)&&!isNaN(l)&&(a.push(g),b.push(m),f.x=g,f.y=m,k=this.createBullet(f,g,m,d),l=this.labelText)){var l=this.createLabel(f,l),n=0;k&&(n=k.size);this.positionLabel(f,g,m,l,n)}}this.drawLineGraph(a,b);this.launchAnimation()},createRadarGraph:function(){var a=this.valueAxis.stackType,b=[],c=[],e=[],d=[],f,g,k, l,m;for(m=this.start;m<=this.end;m++){var n=this.data[m].axes[this.valueAxis.id].graphs[this.id],q,p;"none"==a||"3d"==a?q=n.values.value:(q=n.values.close,p=n.values.open);if(isNaN(q))this.connect||(this.drawLineGraph(b,c,e,d),b=[],c=[],e=[],d=[]);else{var t=this.valueAxis.getCoordinate(q,this.noRounding)-this.height,t=t*this.valueAxis.rMultiplier,r=-360/(this.end-this.start+1)*m;"middle"==this.valueAxis.pointPosition&&(r-=180/(this.end-this.start+1));q=t*Math.sin(r/180*Math.PI);t*=Math.cos(r/180* Math.PI);b.push(q);c.push(t);if(!isNaN(p)){var u=this.valueAxis.getCoordinate(p,this.noRounding)-this.height,u=u*this.valueAxis.rMultiplier,w=u*Math.sin(r/180*Math.PI),r=u*Math.cos(r/180*Math.PI);e.push(w);d.push(r);isNaN(k)&&(k=w);isNaN(l)&&(l=r)}r=this.createBullet(n,q,t,m);n.x=q;n.y=t;if(w=this.labelText)w=this.createLabel(n,w),u=0,r&&(u=r.size),this.positionLabel(n,q,t,w,u);isNaN(f)&&(f=q);isNaN(g)&&(g=t)}}b.push(f);c.push(g);isNaN(k)||(e.push(k),d.push(l));this.drawLineGraph(b,c,e,d);this.launchAnimation()}, positionLabel:function(a,b,c,e,d){if(e){var f=this.chart,g=this.valueAxis,k="middle",l=!1,m=this.labelPosition,n=e.getBBox(),q=this.chart.rotate,p=a.isNegative;c-=n.height/4/2;void 0!==a.labelIsNegative&&(p=a.labelIsNegative);switch(m){case "right":m=q?p?"left":"right":"right";break;case "top":m=q?"top":p?"bottom":"top";break;case "bottom":m=q?"bottom":p?"top":"bottom";break;case "left":m=q?p?"right":"left":"left"}var t=a.columnGraphics,r=0,u=0;t&&(r=t.x,u=t.y);var w=this.labelOffset;switch(m){case "right":k= "start";b+=d/2+w;break;case "top":c=g.reversed?c+(d/2+n.height/2+w):c-(d/2+n.height/2+w);break;case "bottom":c=g.reversed?c-(d/2+n.height/2+w):c+(d/2+n.height/2+w);break;case "left":k="end";b-=d/2+w;break;case "inside":"column"==this.type&&(l=!0,q?p?(k="end",b=r-3-w):(k="start",b=r+3+w):c=p?u+7+w:u-10-w);break;case "middle":"column"==this.type&&(l=!0,q?b-=(b-r)/2+w-3:c-=(c-u)/2+w-3)}"auto"!=this.labelAnchor&&(k=this.labelAnchor);e.attr({"text-anchor":k});this.labelRotation&&e.rotate(this.labelRotation); e.translate(b,c);!this.showAllValueLabels&&t&&l&&(n=e.getBBox(),n.height>a.columnHeight||n.width>a.columnWidth)&&(e.remove(),e=null);e&&(0>b||b>this.width||0>c||c>this.height)&&(e.remove(),e=null);if(e&&("serial"==f.type||"gantt"==f.type))if(q){if(0>c||c>this.height)e.remove(),e=null}else if(0>b||b>this.width)e.remove(),e=null;e&&this.allBullets.push(e);return e}},getGradRotation:function(){var a=270;"horizontal"==this.gradientOrientation&&(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,e=this.data,h=this.chart.container,f=this.valueAxis,g=this.type,k=this.columnWidthReal,l=this.showBulletsAt;isNaN(this.columnWidth)||(k=this.columnWidth);isNaN(k)&&(k=.8);var m=this.useNegativeColorIfDown,n=this.width,q=this.height,p=this.y,t=this.rotate,r=this.columnCount,u=d.toCoordinate(this.cornerRadiusTop,k/2),w=this.connect,y=[],x=[],A,z,B,C,D=this.chart.graphs.length,L,I=this.dx/this.tcc,S=this.dy/ this.tcc,O=f.stackType,Q=this.start,ia=this.end,H=this.scrollbar,Z="graph-column-";H&&(Z="scrollbar-graph-column-");var va=this.categoryAxis,ma=this.baseCoord,Oa=this.negativeBase,ea=this.columnIndex,ca=this.lineThickness,X=this.lineAlpha,ya=this.lineColorR,da=this.dashLength,fa=this.set,za,ga=this.getGradRotation(),T=this.chart.columnSpacing,Y=va.cellWidth,Ca=(Y*k-r)/r;T>Ca&&(T=Ca);var G,v,na,ha=q,Pa=n,ba=0,tb=0,ub,vb,gb,hb,wb=this.fillColorsR,Qa=this.negativeFillColors,Ja=this.negativeLineColor, Ya=this.fillAlphas,Za=this.negativeFillAlphas;"object"==typeof Ya&&(Ya=Ya[0]);"object"==typeof Za&&(Za=Za[0]);var xb=this.noRounding;"step"==g&&(xb=!1);var ib=f.getCoordinate(f.min);f.logarithmic&&(ib=f.getCoordinate(f.minReal));this.minCoord=ib;this.resetBullet&&(this.bullet="none");if(!(H||"line"!=g&&"smoothedLine"!=g&&"step"!=g||(1==e.length&&"step"!=g&&"none"==this.bullet&&(this.bullet="round",this.resetBullet=!0),!Qa&&void 0==Ja||m))){var Ua=Oa;Ua>f.max&&(Ua=f.max);Uak&&(k=1);var Mb=this.fixedColumnWidth;isNaN(Mb)||(k=Mb);var K;if("line"==g||"step"==g||"smoothedLine"==g){if(0W?!0:!1);if(!H)switch(this.showBalloonAt){case "close":v.y= F;break;case "open":v.y=M;break;case "high":v.y=sa;break;case "low":v.y=qa}var ja=G.x[va.id],Wa=this.periodSpan-1;"step"!=g||isNaN(G.cellWidth)||(Y=G.cellWidth);var xa=Math.floor(Y/2)+Math.floor(Wa*Y/2),Ga=xa,nb=0;"left"==this.stepDirection&&(nb=(2*Y+Wa*Y)/2,ja-=nb);"center"==this.stepDirection&&(nb=Y/2,ja-=nb);"start"==this.pointPosition&&(ja-=Y/2+Math.floor(Wa*Y/2),xa=0,Ga=Math.floor(Y)+Math.floor(Wa*Y));"end"==this.pointPosition&&(ja+=Y/2+Math.floor(Wa*Y/2),xa=Math.floor(Y)+Math.floor(Wa*Y),Ga= 0);if(Nb){var Cb=this.columnWidth;isNaN(Cb)||(xa*=Cb,Ga*=Cb)}H||(v.x=ja);-1E5>ja&&(ja=-1E5);ja>n+1E5&&(ja=n+1E5);t?(E=F,N=M,M=F=ja,isNaN(ta)&&!this.fillToGraph&&(N=ma),pa=qa,ra=sa):(N=E=ja,isNaN(ta)&&!this.fillToGraph&&(M=ma));if(!Bb&&WTa?(Sa&&($a=!0),Sa=!1):(Sa||($a=!0),Sa=!0):v.isNegative=W=lb||Math.abs(F-kb)>=lb)y.push(E),x.push(F),jb=E,kb=F;wa=E;Da=F;ka=E;la=F;!Ra||isNaN(M)||isNaN(N)||(U.push(N),V.push(M));if($a||void 0!=v.lineColor&&v.lineColor!=this.lineColorSwitched||void 0!=v.fillColors&&v.fillColors!=this.fillColorsSwitched||!isNaN(v.dashLength))this.drawLineGraph(y,x,U,V),y=[E],x=[F],U=[],V=[],!Ra||isNaN(M)||isNaN(N)||(U.push(N),V.push(M)),m?Sa?(this.lineColorSwitched= ya,this.fillColorsSwitched=wb):(this.lineColorSwitched=Ja,this.fillColorsSwitched=Qa):(this.lineColorSwitched=v.lineColor,this.fillColorsSwitched=v.fillColors),this.dashLengthSwitched=v.dashLength;v.gap&&(this.drawLineGraph(y,x,U,V),y=[],x=[],U=[],V=[])}break;case "smoothedLine":if(isNaN(W))w||(this.drawSmoothedGraph(y,x,U,V),y=[],x=[],U=[],V=[]);else{if(Math.abs(E-jb)>=lb||Math.abs(F-kb)>=lb)y.push(E),x.push(F),jb=E,kb=F;wa=E;Da=F;ka=E;la=F;!Ra||isNaN(M)||isNaN(N)||(U.push(N),V.push(M));void 0== v.lineColor&&void 0==v.fillColors&&isNaN(v.dashLength)||(this.drawSmoothedGraph(y,x,U,V),y=[E],x=[F],U=[],V=[],!Ra||isNaN(M)||isNaN(N)||(U.push(N),V.push(M)),this.lineColorSwitched=v.lineColor,this.fillColorsSwitched=v.fillColors,this.dashLengthSwitched=v.dashLength);v.gap&&(this.drawSmoothedGraph(y,x,U,V),y=[],x=[],U=[],V=[])}break;case "step":if(!isNaN(W)){t?(isNaN(A)||(y.push(A),x.push(F-xa)),x.push(F-xa),y.push(E),x.push(F+Ga),y.push(E),!Ra||isNaN(M)||isNaN(N)||(isNaN(B)||(U.push(B),V.push(M- xa)),U.push(N),V.push(M-xa),U.push(N),V.push(M+Ga))):(isNaN(z)||(x.push(z),y.push(E-xa)),y.push(E-xa),x.push(F),y.push(E+Ga),x.push(F),!Ra||isNaN(M)||isNaN(N)||(isNaN(C)||(U.push(N-xa),V.push(C)),U.push(N-xa),V.push(M),U.push(N+Ga),V.push(M)));A=E;z=F;B=N;C=M;wa=E;Da=F;ka=E;la=F;if($a||void 0!=v.lineColor||void 0!=v.fillColors||!isNaN(v.dashLength)){var cc=y[y.length-2],dc=x[x.length-2];y.pop();x.pop();this.drawLineGraph(y,x,U,V);y=[cc];x=[dc];t?(x.push(F+Ga),y.push(E)):(y.push(E+Ga),x.push(F));U= [];V=[];this.lineColorSwitched=v.lineColor;this.fillColorsSwitched=v.fillColors;this.dashLengthSwitched=v.dashLength;m&&(Sa?(this.lineColorSwitched=ya,this.fillColorsSwitched=wb):(this.lineColorSwitched=Ja,this.fillColorsSwitched=Qa))}if(Nb||v.gap)A=z=NaN,this.drawLineGraph(y,x,U,V),y=[],x=[],U=[],V=[]}else if(!w){if(1>=this.periodSpan||1xa+Ga)A=z=NaN;this.drawLineGraph(y,x,U,V);y=[];x=[];U=[];V=[]}break;case "column":Aa=Ha;void 0!=v.lineColor&&(Aa=v.lineColor);if(!isNaN(W)){m|| (v.isNegative=WQb&&ob>Qb)){var Ba;if(t){"3d"==O?(P=F-(r/2-this.depthCount+1)*(k+T)+T/2+S*ea,R=N+I*ea,Ba=ea):(P=Math.floor(F-(r/2-ea)*(k+T)+T/2),R=N,Ba=0);J=k;wa=E;Da=P+k/2;ka=E;la=P+k/2;P+J>q+Ba*S&&(J=q-P+Ba*S);Paa?!0:!1;0===aa&&1/W===1/-0&&(v.labelIsNegative= !0);isNaN(G.percentWidthValue)||(J=this.height*G.percentWidthValue/100,P=ja-J/2,Da=P+J/2);J=d.roundTo(J,2);aa=d.roundTo(aa,2);Pn+Ba*I&&(J=n-R+Ba*I);Rq&&(J=q-P);0>P&&(J+=P,P=0);if(Pta?(Db=[E,ra],Eb=[N,pa]):(Db=[N,ra],Eb=[E,pa]);!isNaN(ra)&&!isNaN(pa)&&Fn&&(J=n-R);0>R&&(J+=R,R=0);aa=F-M;if(R=ta&&(Va=0);var ua=new d.Cuboid(h,J,aa,I,S,Ma,Va,ca,Aa,X,ga,u,t,da,bb,mb,Z),Fb,Gb;W>ta?(Fb=[F,sa],Gb=[M,qa]):(Fb=[M,sa],Gb=[F,qa]);!isNaN(sa)&&!isNaN(qa)&&EW?E-$b/2-2-fb-sb:E+$b/2+3+fb+sb):(db=wa,eb=0>W?F+ac/2+fb+sb:F-ac/2-3-fb-sb);Na.translate(db,eb);f.totals[K]=Na;t?(0>eb||eb>q)&&Na.remove():(0>db||db>n)&&Na.remove()}}}}}}}if("line"==g||"step"==g||"smoothedLine"==g)"smoothedLine"==g?this.drawSmoothedGraph(y,x,U,V):this.drawLineGraph(y,x,U,V),H||this.launchAnimation();this.bulletsHidden&&this.hideBullets();this.customBulletsHidden&&this.hideCustomBullets()},animateColumns:function(a,b){var c=this,e=c.chart.startDuration; 0h.height&&(z=h.height),0>z&&(z=0));q=d.line(l,a,b,t,q,p,y,!1,!0,f);d.setCN(k,q,h.bcn+"stroke");m.push(q);m.click(function(a){h.handleGraphEvent(a,"clickGraph")}).mouseover(function(a){h.handleGraphEvent(a, "rollOverGraph")}).mouseout(function(a){h.handleGraphEvent(a,"rollOutGraph")}).touchmove(function(a){h.chart.handleMouseMove(a)}).touchend(function(a){h.chart.handleTouchEnd(a)});void 0===w||h.useNegativeColorIfDown||(p=d.line(l,a,b,w,r,p,y,!1,!0,f),d.setCN(k,p,h.bcn+"stroke"),d.setCN(k,p,h.bcn+"stroke-negative"),n.push(p));if(0a&&(a=this.fillAlphas),0===a&&(a=this.bulletAlpha),0===a&&(a=1));return a},createBullet:function(a,b,c){if(!isNaN(b)&&!isNaN(c)&&("none"!=this.bullet||this.customBullet||a.bullet||a.customBullet)){var e=this.chart,h=this.container,f=this.bulletOffset,g=this.bulletSize;isNaN(a.bulletSize)||(g=a.bulletSize);var k=a.values.value,l=this.maxValue,m=this.minValue,n=this.maxBulletSize,q=this.minBulletSize;isNaN(l)||(isNaN(k)||(g=(k-m)/(l-m)*(n-q)+q),m==l&&(g= n));l=g;this.bulletAxis&&(g=a.values.error,isNaN(g)||(k=g),g=this.bulletAxis.stepWidth*k);gb||b>this.width||c<-g/2||c>this.height)p.remove(),p=null;p&&(this.bulletSet.push(p),p.translate(b,c),this.addListeners(p,a),this.allBullets.push(p)); a.bx=b;a.by=c;d.setCN(e,p,this.bcn+"bullet");a.className&&d.setCN(e,p,a.className,!0)}p?(p.size=g||0,a.bulletGraphics=p):p={size:0};p.graphDataItem=a;return p}},showBullets:function(){var a=this.allBullets,b;this.bulletsHidden=!1;for(b=0;ba+k||hq+l)?(g.showBalloon(m),g.hide(0)):(g.followCursor(c),g.showBalloon(m)))):(this.hideBalloonReal(),this.resizeBullet(a,e,h))}else this.hideBalloonReal()}, resizeBullet:function(a,b,c){this.fixBulletSize();if(a&&d.isModern&&(1!=b||!isNaN(c))){var e=a.bulletGraphics;e&&!e.doNotScale&&(e.translate(a.bx,a.by,b),isNaN(c)||(e.setAttr("fill-opacity",c),e.setAttr("stroke-opacity",c)),this.resizedDItem=a)}}})})();(function(){var d=window.AmCharts;d.ChartCursor=d.Class({construct:function(a){this.cname="ChartCursor";this.createEvents("changed","zoomed","onHideCursor","onShowCursor","draw","selected","moved","panning","zoomStarted");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.categoryBalloonText="[[category]]"; this.categoryBalloonEnabled=this.valueBalloonsEnabled=!0;this.rolledOver=!1;this.cursorPosition="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;this.leaveCursor=!1;this.leaveAfterTouch=!0;this.valueZoomable=!1;this.balloonPointerOrientation="horizontal";this.hLineEnabled=this.vLineEnabled=!0;this.vZoomEnabled= this.hZoomEnabled=!1;d.applyTheme(this,a,this.cname)},draw:function(){this.destroy();var a=this.chart;a.panRequired=!0;var b=a.container;this.rotate=a.rotate;this.container=b;this.prevLineHeight=this.prevLineWidth=NaN;b=b.set();b.translate(this.x,this.y);this.set=b;a.cursorSet.push(b);this.createElements();d.isString(this.limitToGraph)&&(this.limitToGraph=d.getObjById(a.graphs,this.limitToGraph),this.fullWidth=!1,this.cursorPosition="middle");this.pointer=this.balloonPointerOrientation.substr(0,1).toUpperCase(); this.isHidden=!1;this.hideLines();this.valueLineAxis||(this.valueLineAxis=a.valueAxes[0])},createElements:function(){var a=this.chart,b=a.dx,c=a.dy,e=this.width,h=this.height,f,g,k=this.cursorAlpha;f=this.valueLineAlpha;this.rotate?g=k:(g=f,f=k);"xy"==a.type&&(f=g=k);this.vvLine=d.line(this.container,[b,0,0],[c,0,h],this.cursorColor,f,1);d.setCN(a,this.vvLine,"cursor-line");d.setCN(a,this.vvLine,"cursor-line-vertical");this.hhLine=d.line(this.container,[0,e,e+b],[0,0,c],this.cursorColor,g,1);d.setCN(a, this.hhLine,"cursor-line");d.setCN(a,this.hhLine,"cursor-line-horizontal");this.vLine=this.rotate?this.vvLine:this.hhLine;this.set.push(this.vvLine);this.set.push(this.hhLine);this.set.node.style.pointerEvents="none";this.fullLines=this.container.set();a=a.cursorLineSet;a.push(this.fullLines);a.translate(this.x,this.y);a.clipRect(0,0,e,h);this.set.clipRect(0,0,e,h)},update:function(){var a=this.chart,b=a.mouseX-this.x,c=a.mouseY-this.y;this.mouseX=b;this.mouseY=c;this.mouse2X=a.mouse2X-this.x;this.mouse2Y= a.mouse2Y-this.y;var e;if(a.chartData&&0document.documentMode&&(this.updateOnReleaseOnly=!0);this.dragIconHeight=this.dragIconWidth=35;this.dragIcon="dragIconRoundBig"; this.dragCursorHover="cursor: cursor: grab; cursor:-moz-grab; cursor:-webkit-grab;";this.dragCursorDown="cursor: cursor: grab; cursor:-moz-grabbing; cursor:-webkit-grabbing;";this.enabled=!0;this.percentStart=this.offset=0;this.percentEnd=1;d.applyTheme(this,a,"SimpleChartScrollbar")},draw:function(){var a=this;a.destroy();if(a.enabled){var b=a.chart.container,c=a.rotate,e=a.chart;e.panRequired=!0;var h=b.set();a.set=h;e.scrollbarsSet.push(h);var f,g;c?(f=a.scrollbarHeight,g=e.plotAreaHeight):(g= a.scrollbarHeight,f=e.plotAreaWidth);a.width=f;if((a.height=g)&&f){var k=d.rect(b,f,g,a.backgroundColor,a.backgroundAlpha,1,a.backgroundColor,a.backgroundAlpha);d.setCN(e,k,"scrollbar-bg");a.bg=k;h.push(k);k=d.rect(b,f,g,"#000",.005);h.push(k);a.invisibleBg=k;k.click(function(){a.handleBgClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()}).touchend(function(){a.handleBgClick()});k=d.rect(b,f,g,a.selectedBackgroundColor,a.selectedBackgroundAlpha);d.setCN(e, k,"scrollbar-bg-selected");a.selectedBG=k;h.push(k);f=d.rect(b,f,g,"#000",.005);a.dragger=f;h.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=e.pathToImages;g=a.dragIcon.replace(/\.[a-z]*$/i,"");c?(k=f+g+"H"+e.extension,f=a.dragIconWidth,c=a.dragIconHeight):(k=f+g+e.extension,c= a.dragIconWidth,f=a.dragIconHeight);g=b.image(k,0,0,c,f);d.setCN(e,g,"scrollbar-grip-left");k=b.image(k,0,0,c,f);d.setCN(e,k,"scrollbar-grip-right");var l=10,m=20;e.panEventsEnabled&&(l=25,m=a.scrollbarHeight);var n=d.rect(b,l,m,"#000",.005),q=d.rect(b,l,m,"#000",.005);q.translate(-(l-c)/2,-(m-f)/2);n.translate(-(l-c)/2,-(m-f)/2);c=b.set([g,q]);b=b.set([k,n]);a.iconLeft=c;h.push(a.iconLeft);a.iconRight=b;h.push(b);c.mousedown(function(){a.leftDragStart()}).mouseup(function(){a.leftDragStop()}).mouseover(function(){a.iconRollOver()}).mouseout(function(){a.iconRollOut()}).touchstart(function(){a.leftDragStart()}).touchend(function(){a.leftDragStop()}); b.mousedown(function(){a.rightDragStart()}).mouseup(function(){a.rightDragStop()}).mouseover(function(){a.iconRollOver()}).mouseout(function(){a.iconRollOut()}).touchstart(function(){a.rightDragStart()}).touchend(function(){a.rightDragStop()});d.ifArray(e.chartData)?h.show():h.hide();a.hideDragIcons();a.clipDragger(!1)}h.translate(a.x,a.y);h.node.style.msTouchAction="none";h.node.style.touchAction="none"}},updateScrollbarSize:function(a,b){if(!isNaN(a)&&!isNaN(b)){a=Math.round(a);b=Math.round(b); var c=this.dragger,e,d,f,g,k;this.rotate?(e=0,d=a,f=this.width+1,g=b-a,c.setAttr("height",b-a),c.setAttr("y",d)):(e=a,d=0,f=b-a,g=this.height+1,k=b-a,c.setAttr("x",e),c.setAttr("width",k));this.clipAndUpdate(e,d,f,g)}},update:function(){var a,b=!1,c,e,d=this.x,f=this.y,g=this.dragger,k=this.getDBox();if(k){c=k.x+d;e=k.y+f;var l=k.width,k=k.height,m=this.rotate,n=this.chart,q=this.width,p=this.height,t=n.mouseX,r=n.mouseY;a=this.initialMouse;this.forceClip&&this.clipDragger(!0);n.mouseIsOver&&(this.dragging&& (n=this.initialCoord,m?(a=n+(r-a),0>a&&(a=0),n=p-k,a>n&&(a=n),g.setAttr("y",a)):(a=n+(t-a),0>a&&(a=0),n=q-l,a>n&&(a=n),g.setAttr("x",a)),this.clipDragger(!0)),this.resizingRight&&(m?(a=r-e,a+e>p+f&&(a=p-e+f),0>a?(this.resizingRight=!1,b=this.resizingLeft=!0):(0===a&&(a=.1),g.setAttr("height",a))):(a=t-c,a+c>q+d&&(a=q-c+d),0>a?(this.resizingRight=!1,b=this.resizingLeft=!0):(0===a&&(a=.1),g.setAttr("width",a))),this.clipDragger(!0)),this.resizingLeft&&(m?(c=e,e=r,ep+f&&(e=p+f),a=!0===b? c-e:k+c-e,0>a?(this.resizingRight=!0,this.resizingLeft=!1,g.setAttr("y",c+k-f)):(0===a&&(a=.1),g.setAttr("y",e-f),g.setAttr("height",a))):(e=t,eq+d&&(e=q+d),a=!0===b?c-e:l+c-e,0>a?(this.resizingRight=!0,this.resizingLeft=!1,g.setAttr("x",c+l-d)):(0===a&&(a=.1),g.setAttr("x",e-d),g.setAttr("width",a))),this.clipDragger(!0)))}},stopForceClip:function(){this.animating=this.forceClip=!1},clipDragger:function(a){var b=this.getDBox();if(b){var c=b.x,e=b.y,d=b.width,b=b.height,f=!1;if(this.rotate){if(c= 0,d=this.width+1,this.clipY!=e||this.clipH!=b)f=!0}else if(e=0,b=this.height+1,this.clipX!=c||this.clipW!=d)f=!0;f&&(this.clipAndUpdate(c,e,d,b),a&&(this.updateOnReleaseOnly||this.dispatchScrollbarEvent()))}},maskGraphs:function(){},clipAndUpdate:function(a,b,c,e){this.clipX=a;this.clipY=b;this.clipW=c;this.clipH=e;this.selectedBG.setAttr("width",c);this.selectedBG.setAttr("height",e);this.selectedBG.translate(a,b);this.updateDragIconPositions();this.maskGraphs(a,b,c,e)},dispatchScrollbarEvent:function(){if(this.skipEvent)this.skipEvent= !1;else{var a=this.chart;a.hideBalloon();var b=this.getDBox(),c=b.x,e=b.y,d=b.width,f=b.height,g,k;this.rotate?(b=e,g=this.height/f,k=1-e/this.height,c=1-(e+f)/this.height):(b=c,g=this.width/d,k=c/this.width,c=(c+d)/this.width);this.fire({type:"zoomed",position:b,chart:a,target:this,multiplier:g,relativeStart:c,relativeEnd:k})}},updateDragIconPositions:function(){var a=this.getDBox(),b=a.x,c=a.y,e=this.iconLeft,d=this.iconRight,f,g,k=this.scrollbarHeight;this.rotate?(f=this.dragIconWidth,g=this.dragIconHeight, e.translate((k-g)/2,c-f/2),d.translate((k-g)/2,c+a.height-f/2)):(f=this.dragIconHeight,g=this.dragIconWidth,e.translate(b-g/2,(k-f)/2),d.translate(b-g/2+a.width,(k-f)/2))},showDragIcons:function(){this.resizeEnabled&&(this.iconLeft.show(),this.iconRight.show())},hideDragIcons:function(){if(!this.resizingLeft&&!this.resizingRight&&!this.dragging){if(this.hideResizeGrips||!this.resizeEnabled)this.iconLeft.hide(),this.iconRight.hide();this.removeCursors()}},removeCursors:function(){this.chart.setMouseCursor("auto")}, fireZoomEvent:function(a){this.fire({type:a,chart:this.chart,target:this})},percentZoom:function(a,b){if(this.dragger&&this.enabled){this.dragger.stop();isNaN(a)&&(a=0);isNaN(b)&&(b=1);var c,e,d;this.rotate?(c=this.height,e=c-c*b,d=c-c*a):(c=this.width,d=c*b,e=c*a);this.updateScrollbarSize(e,d);this.clipDragger(!1);this.percentStart=a;this.percentEnd=b}},destroy:function(){this.clear();d.remove(this.set);d.remove(this.iconRight);d.remove(this.iconLeft)},clear:function(){},handleDragStart:function(){if(this.enabled){this.fireZoomEvent("zoomStarted"); var a=this.chart;this.dragger.stop();this.removeCursors();d.isModern&&this.dragger.node.setAttribute("style",this.dragCursorDown);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.update(),this.skipEvent=!1,this.dispatchScrollbarEvent());this.dragging=!1;this.mouseIsOver&&this.removeCursors();d.isModern&&this.dragger.node.setAttribute("style", this.dragCursorHover);this.update();this.fireZoomEvent("zoomEnded")},handleDraggerOver:function(){this.handleMouseOver();d.isModern&&this.dragger.node.setAttribute("style",this.dragCursorHover)},leftDragStart:function(){this.fireZoomEvent("zoomStarted");this.dragger.stop();this.resizingLeft=!0},leftDragStop:function(){this.resizingLeft=!1;this.mouseIsOver||this.removeCursors();this.updateOnRelease();this.fireZoomEvent("zoomEnded")},rightDragStart:function(){this.fireZoomEvent("zoomStarted");this.dragger.stop(); this.resizingRight=!0},rightDragStop:function(){this.resizingRight=!1;this.mouseIsOver||this.removeCursors();this.updateOnRelease();this.fireZoomEvent("zoomEnded")},iconRollOut:function(){this.removeCursors()},iconRollOver:function(){this.rotate?this.chart.setMouseCursor("ns-resize"):this.chart.setMouseCursor("ew-resize");this.handleMouseOver()},getDBox:function(){if(this.dragger)return this.dragger.getBBox()},handleBgClick:function(){var a=this;if(!a.resizingRight&&!a.resizingLeft){a.zooming=!0; var b,c,e=a.scrollDuration,h=a.dragger;b=a.getDBox();var f=b.height,g=b.width;c=a.chart;var k=a.y,l=a.x,m=a.rotate;m?(b="y",c=c.mouseY-f/2-k,c=d.fitToBounds(c,0,a.height-f)):(b="x",c=c.mouseX-g/2-l,c=d.fitToBounds(c,0,a.width-g));a.updateOnReleaseOnly?(a.skipEvent=!1,h.setAttr(b,c),a.dispatchScrollbarEvent(),a.clipDragger()):(a.animating=!0,c=Math.round(c),m?h.animate({y:c},e,">"):h.animate({x:c},e,">"),a.forceClip=!0,clearTimeout(a.forceTO),a.forceTO=setTimeout(function(){a.stopForceClip.call(a)}, 5E3*e))}},updateOnRelease:function(){this.updateOnReleaseOnly&&(this.update(),this.skipEvent=!1,this.dispatchScrollbarEvent())},handleReleaseOutside:function(){if(this.set){if(this.resizingLeft||this.resizingRight||this.dragging)this.updateOnRelease(),this.removeCursors();this.animating=this.mouseIsOver=this.dragging=this.resizingRight=this.resizingLeft=!1;this.hideDragIcons();this.update()}},handleMouseOver:function(){this.mouseIsOver=!0;this.showDragIcons()},handleMouseOut:function(){this.mouseIsOver= !1;this.hideDragIcons();this.removeCursors()}})})();(function(){var d=window.AmCharts;d.ChartScrollbar=d.Class({inherits:d.SimpleChartScrollbar,construct:function(a){this.cname="ChartScrollbar";d.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=!1;this.color="#FFFFFF";this.scrollbarCreated=!1;this.oppositeAxis=!0;d.applyTheme(this,a,this.cname)},init:function(){var a=this.categoryAxis,b=this.chart,c=this.gridAxis;a||("CategoryAxis"==this.gridAxis.cname?(this.catScrollbar=!0,a=new d.CategoryAxis,a.id="scrollbar"):(a=new d.ValueAxis,a.data=b.chartData,a.id=c.id,a.type=c.type,a.maximumDate=c.maximumDate,a.minimumDate=c.minimumDate,a.minPeriod=c.minPeriod),this.categoryAxis=a);a.chart=b;a.dateFormats=c.dateFormats;a.markPeriodChange= c.markPeriodChange;a.boldPeriodBeginning=c.boldPeriodBeginning;a.labelFunction=c.labelFunction;a.axisItemRenderer=d.RecItem;a.axisRenderer=d.RecAxis;a.guideFillRenderer=d.RecFill;a.inside=!0;a.fontSize=this.fontSize;a.tickLength=0;a.axisAlpha=0;d.isString(this.graph)&&(this.graph=d.getObjById(b.graphs,this.graph));(a=this.graph)&&this.catScrollbar&&(c=this.valueAxis,c||(this.valueAxis=c=new d.ValueAxis,c.visible=!1,c.scrollbar=!0,c.axisItemRenderer=d.RecItem,c.axisRenderer=d.RecAxis,c.guideFillRenderer= d.RecFill,c.labelsEnabled=!1,c.chart=b),b=this.unselectedGraph,b||(b=new d.AmGraph,b.scrollbar=!0,this.unselectedGraph=b,b.negativeBase=a.negativeBase,b.noStepRisers=a.noStepRisers),b=this.selectedGraph,b||(b=new d.AmGraph,b.scrollbar=!0,this.selectedGraph=b,b.negativeBase=a.negativeBase,b.noStepRisers=a.noStepRisers));this.scrollbarCreated=!0},draw:function(){var a=this;d.ChartScrollbar.base.draw.call(a);if(a.enabled){a.scrollbarCreated||a.init();var b=a.chart,c=b.chartData,e=a.categoryAxis,h=a.rotate, f=a.x,g=a.y,k=a.width,l=a.height,m=a.gridAxis,n=a.set;e.setOrientation(!h);e.parseDates=m.parseDates;"ValueAxis"==a.categoryAxis.cname&&(e.rotate=!h);e.equalSpacing=m.equalSpacing;e.minPeriod=m.minPeriod;e.startOnAxis=m.startOnAxis;e.width=k-1;e.height=l;e.gridCount=a.gridCount;e.gridColor=a.gridColor;e.gridAlpha=a.gridAlpha;e.color=a.color;e.tickLength=0;e.axisAlpha=0;e.autoGridCount=a.autoGridCount;e.parseDates&&!e.equalSpacing&&e.timeZoom(b.firstTime,b.lastTime);e.minimum=a.gridAxis.fullMin;e.maximum= a.gridAxis.fullMax;e.strictMinMax=!0;e.zoom(0,c.length-1);if((m=a.graph)&&a.catScrollbar){var q=a.valueAxis,p=m.valueAxis;q.id=p.id;q.rotate=h;q.setOrientation(h);q.width=k;q.height=l;q.dataProvider=c;q.reversed=p.reversed;q.logarithmic=p.logarithmic;q.gridAlpha=0;q.axisAlpha=0;n.push(q.set);h?(q.y=g,q.x=0):(q.x=f,q.y=0);var f=Infinity,g=-Infinity,t;for(t=0;tg&&(g=w)}}Infinity!=f&&(q.minimum=f);-Infinity!=g&&(q.maximum=g+.1*(g-f));f==g&&(--q.minimum,q.maximum+=1);void 0!==a.minimum&&(q.minimum=a.minimum);void 0!==a.maximum&&(q.maximum=a.maximum);q.zoom(0,c.length-1);u=a.unselectedGraph;u.id=m.id;u.bcn="scrollbar-graph-";u.rotate=h;u.chart=b;u.data=c;u.valueAxis=q;u.chart=m.chart;u.categoryAxis=a.categoryAxis;u.periodSpan=m.periodSpan;u.valueField=m.valueField;u.openField=m.openField;u.closeField=m.closeField;u.highField=m.highField;u.lowField=m.lowField; u.lineAlpha=a.graphLineAlpha;u.lineColorR=a.graphLineColor;u.fillAlphas=a.graphFillAlpha;u.fillColorsR=a.graphFillColor;u.connect=m.connect;u.hidden=m.hidden;u.width=k;u.height=l;u.pointPosition=m.pointPosition;u.stepDirection=m.stepDirection;u.periodSpan=m.periodSpan;p=a.selectedGraph;p.id=m.id;p.bcn=u.bcn+"selected-";p.rotate=h;p.chart=b;p.data=c;p.valueAxis=q;p.chart=m.chart;p.categoryAxis=e;p.periodSpan=m.periodSpan;p.valueField=m.valueField;p.openField=m.openField;p.closeField=m.closeField;p.highField= m.highField;p.lowField=m.lowField;p.lineAlpha=a.selectedGraphLineAlpha;p.lineColorR=a.selectedGraphLineColor;p.fillAlphas=a.selectedGraphFillAlpha;p.fillColorsR=a.selectedGraphFillColor;p.connect=m.connect;p.hidden=m.hidden;p.width=k;p.height=l;p.pointPosition=m.pointPosition;p.stepDirection=m.stepDirection;p.periodSpan=m.periodSpan;b=a.graphType;b||(b=m.type);u.type=b;p.type=b;c=c.length-1;u.zoom(0,c);p.zoom(0,c);p.set.click(function(){a.handleBackgroundClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()}); u.set.click(function(){a.handleBackgroundClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()});n.push(u.set);n.push(p.set)}n.push(e.set);n.push(e.labelsSet);a.bg.toBack();a.invisibleBg.toFront();a.dragger.toFront();a.iconLeft.toFront();a.iconRight.toFront()}},timeZoom:function(a,b,c){this.startTime=a;this.endTime=b;this.timeDifference=b-a;this.skipEvent=!d.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("ValueAxis"==this.categoryAxis.cname)d.ChartScrollbar.base.dispatchScrollbarEvent.call(this);else if(this.skipEvent)this.skipEvent=!1;else{var a=this.chart.chartData,b,c,e=this.dragger.getBBox();b=e.x;var h=e.y,f=e.width,e=e.height,g=this.chart;this.rotate?(b=h,c=e):c=f;f={type:"zoomed",target:this};f.chart=g;var k=this.categoryAxis,l=this.stepWidth,h=g.minSelectedTime,e=g.maxSelectedTime,m=!1;if(k.parseDates&& !k.equalSpacing){if(a=g.lastTime,g=g.firstTime,k=Math.round(b/l)+g,b=this.dragging?k+this.timeDifference:Math.round((b+c)/l)+g,k>b&&(k=b),0e&&(b=Math.round(k+(b-k)/2),m=Math.round(e/2),k=b-m,b+=m,m=!0),b>a&&(b=a),b-hb&&(b=k+h),k!=this.startTime||b!=this.endTime)this.startTime=k,this.endTime=b,f.start=k,f.end=b,f.startDate=new Date(k),f.endDate=new Date(b),this.fire(f)}else if(k.startOnAxis|| (b+=l/2),c-=this.stepWidth/2,h=k.xToIndex(b),b=k.xToIndex(b+c),h!=this.start||this.end!=b)k.startOnAxis&&(this.resizingRight&&h==b&&b++,this.resizingLeft&&h==b&&(0this.timeDifference&&(this.timeDifference=0)},handleBackgroundClick:function(){d.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))}})})();(function(){var d=window.AmCharts;d.AmBalloon=d.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.maxWidth=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=this.animationDuration=.3;this.fixedPosition=!0;this.offsetY=6;this.offsetX=1;this.textAlign="center";this.disableMouseEvents=!0;this.deltaSignX=this.deltaSignY=1;d.isModern||(this.offsetY*=1.5);this.sdy=this.sdx=0;d.applyTheme(this,a,this.cname)},draw:function(){var a=this.pointToX,b=this.pointToY;d.isModern||(this.drop=!1);var c=this.chart;d.VML&&(this.fadeOutDuration=0);this.xAnim&&c.stopAnim(this.xAnim);this.yAnim&&c.stopAnim(this.yAnim);this.sdy=this.sdx=0;if(!isNaN(a)){var e= this.follow,h=c.container,f=this.set;d.remove(f);this.removeDiv();f=h.set();f.node.style.pointerEvents="none";this.set=f;this.mainSet?(this.mainSet.push(this.set),this.sdx=this.mainSet.x,this.sdy=this.mainSet.y):c.balloonsSet.push(f);if(this.show){var g=this.l,k=this.t,l=this.r,m=this.b,n=this.balloonColor,q=this.fillColor,p=this.borderColor,t=q;void 0!=n&&(this.adjustBorderColor?t=p=n:q=n);var r=this.horizontalPadding,u=this.verticalPadding,w=this.pointerWidth,y=this.pointerOrientation,x=this.cornerRadius, A=c.fontFamily,z=this.fontSize;void 0==z&&(z=c.fontSize);var n=document.createElement("div"),B=c.classNamePrefix;n.className=B+"-balloon-div";this.className&&(n.className=n.className+" "+B+"-balloon-div-"+this.className);B=n.style;this.disableMouseEvents&&(B.pointerEvents="none");B.position="absolute";var C=this.minWidth,D="";isNaN(C)||(D="min-width:"+(C-2*r)+"px; ");n.innerHTML='
'+this.text+"
";c.chartDiv.appendChild(n);this.textDiv=n;var L=n.offsetWidth,I=n.offsetHeight;n.clientHeight&&(L=n.clientWidth,I=n.clientHeight);A=I+2*u;D=L+2*r;!isNaN(C)&&DA&&(w=A/2),z=b-A/2,a=m&&(z=m-A); zl&&(C=l-D);var k=z+u,m=C+r,O=this.shadowAlpha,Q=this.shadowColor,r=this.borderThickness,ia=this.bulletSize,H,u=this.fillAlpha,Z=this.borderAlpha;this.showBullet&&(H=d.circle(h,ia,t,u),f.push(H));this.drop?(g=D/1.6,l=0,"V"==y&&(y="down"),"H"==y&&(y="left"),"down"==y&&(C=a+1,z=b-g-g/3),"up"==y&&(l=180,C=a+1,z=b+g+g/3),"left"==y&&(l=270,C=a+g+g/3+2,z=b),"right"==y&&(l=90,C=a-g-g/3+2,z=b),k=z-I/2+1,m=C-L/2-1,q=d.drop(h,g,l,q,u,r,p,Z)):0D-w&&(g=D-w),gA-w&&(y=A-w),ya?D:a-C,D,D,0,0,D]),0this.r-d.width&&(a=this.r-d.width);hthis.processCount&&(this.processCount=1);var b=a.length/this.processCount;this.parseCount=Math.ceil(b)-1;for(var c=0;ca.length&&(c=a.length);var h=this.graphs,f={},g=this.seriesIdField;g||(g=this.categoryField);var k=!1,l,m=this.categoryAxis,n,q,p;m&&(k=m.parseDates,n=m.forceShowField,p=m.classNameField,q=m.labelColorField,l=m.categoryFunction);var t,r,u={},w;k&&(t=d.extractPeriod(m.minPeriod), r=t.period,t=t.count,w=d.getPeriodDuration(r,t));var y={};this.lookupTable=y;var x,A=this.dataDateFormat,z={};for(x=b;x=w*Q&&(z[O].gap=!0);this.processFields(b,H,Z);H.category=B.category;H.serialDataItem=B;H.graph=b;B.axes[I].graphs[O]= H;u[O]=B.time;z[O]=H}}}this.chartData[x]=B}if(this.parseCount==e){for(a=0;ab?this.colors[b]:a.lineColorR?a.lineColorR:d.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=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)}}},highlightGraph:function(a){var b=this.graphs,c,d=.2;this.legend&&(d=this.legend.rollOverGraphAlpha);if(1!=d)for(c=0;c=b&&(b=.001);if(void 0==h||0===h)h=.01;void 0===f&&(f="#000000");void 0===g&&(g=0);e={fill:c,stroke:f,"fill-opacity":e,"stroke-width":h,"stroke-opacity":g};a=isNaN(l)?a.circle(0,0,b).attr(e):a.ellipse(0,0,b,l).attr(e);k&&a.gradient("radialGradient",[c,d.adjustLuminosity(c,-.6)]);return a};d.text=function(a,b,c,e,h,f,g,k){f||(f="middle");"right"==f&&(f="end");"left"==f&&(f="start");isNaN(k)&&(k=1);void 0!==b&&(b=String(b),d.isIE&& !d.isModern&&(b=b.replace("&","&"),b=b.replace("&","&")));c={fill:c,"font-family":e,"font-size":h+"px",opacity:k};!0===g&&(c["font-weight"]="bold");c["text-anchor"]=f;return a.text(b,c)};d.polygon=function(a,b,c,e,h,f,g,k,l,m,n){isNaN(f)&&(f=.01);isNaN(k)&&(k=h);var q=e,p=!1;"object"==typeof q&&1b&&(b=Math.abs(b),t=-b);0>c&&(c=Math.abs(c),r=-c);t+=d.dx;r+=d.dy;h={fill:q,stroke:g,"fill-opacity":h,"stroke-opacity":k};void 0!==n&&0=y&&(h=y);var x=1/180*Math.PI,y=b+Math.sin(e*x)*k,A=c-Math.cos(e*x)*u,z=b+Math.sin(e*x)*f,B=c-Math.cos(e*x)*g,C=b+Math.sin((e+h)*x)*f,D=c-Math.cos((e+h)*x)*g,L=b+Math.sin((e+h)*x)*k,x=c-Math.cos((e+h)*x)*u,I={fill:d.adjustLuminosity(m.fill,-.2),"stroke-opacity":0,"fill-opacity":m["fill-opacity"]},S=0;180Math.abs(h)&&1>=Math.abs(C-z)&&1>=Math.abs(D-B)&&(O=!0));h="";var Q;q&&(I["fill-opacity"]=0,I["stroke-opacity"]=m["stroke-opacity"]/2,I.stroke=m.stroke);if(0a.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="#",e,h;for(h=0;3>h;h++)e=parseInt(a.substr(2*h,2),16),e=Math.round(Math.min(Math.max(0,e+e*b),255)).toString(16),c+=("00"+ e).substr(e.length);return c}})();(function(){var d=window.AmCharts;d.Bezier=d.Class({construct:function(a,b,c,e,h,f,g,k,l,m){"object"==typeof g&&(g=g[0]);"object"==typeof k&&(k=k[0]);0===k&&(g="none");f={fill:g,"fill-opacity":k,"stroke-width":f};void 0!==l&&0c&&(k=c);b.push({x:l.x-k/h,y:l.y-e/f});b.push({x:l.x,y:l.y});b.push({x:l.x+k/h,y:l.y+e/f})}e=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-c/h,y:a[a.length-1].y-e/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 h=Math.round,f=this.getPointOnSegment(a,b,.75),g=this.getPointOnSegment(d,c,.75),k=(d.x-a.x)/16,l=(d.y-a.y)/16,m=this.getPointOnSegment(a,b,.375);a=this.getPointOnSegment(f,g,.375);a.x-=k;a.y-=l;b=this.getPointOnSegment(g, f,.375);b.x+=k;b.y+=l;c=this.getPointOnSegment(d,c,.375);k=this.getMiddle(m,a);f=this.getMiddle(f,g);g=this.getMiddle(b,c);m=" Q"+h(m.x)+","+h(m.y)+","+h(k.x)+","+h(k.y);m+=" Q"+h(a.x)+","+h(a.y)+","+h(f.x)+","+h(f.y);m+=" Q"+h(b.x)+","+h(b.y)+","+h(g.x)+","+h(g.y);return m+=" Q"+h(c.x)+","+h(c.y)+","+h(d.x)+","+h(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}}})})();(function(){var d=window.AmCharts;d.AmDraw=d.Class({construct:function(a,b,c,e){d.SVG_NS="http://www.w3.org/2000/svg";d.SVG_XLINK="http://www.w3.org/1999/xlink";d.hasSVG=!!document.createElementNS&&!!document.createElementNS(d.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");d.hasSVG?(d.SVG=!0,b=this.createSvgElement("svg"),a.appendChild(b),this.container=b,this.addDefs(e),this.R=new d.SVGRenderer(this)):d.isIE&&d.VMLRenderer&& (d.VML=!0,d.vmlStyleSheet||(document.namespaces.add("amvml","urn:schemas-microsoft-com:vml"),31>document.styleSheets.length?(b=document.createStyleSheet(),b.addRule(".amvml","behavior:url(#default#VML); display:inline-block; antialias:true"),d.vmlStyleSheet=b):document.styleSheets[0].addRule(".amvml","behavior:url(#default#VML); display:inline-block; antialias:true")),this.container=a,this.R=new d.VMLRenderer(this,e),this.R.disableSelection(a))},createSvgElement:function(a){return document.createElementNS(d.SVG_NS, a)},circle:function(a,b,c,e){var h=new d.AmDObject("circle",this);h.attr({r:c,cx:a,cy:b});this.addToContainer(h.node,e);return h},ellipse:function(a,b,c,e,h){var f=new d.AmDObject("ellipse",this);f.attr({rx:c,ry:e,cx:a,cy:b});this.addToContainer(f.node,h);return f},setSize:function(a,b){0c&&(c=1);1>e&&(e=1);k.attr({x:a,y:b,width:c,height:e,rx:h,ry:h,"stroke-width":f});this.addToContainer(k.node,g);return k},image:function(a,b,c,e,h,f){var g=new d.AmDObject("image",this);g.attr({x:b,y:c,width:e,height:h});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,e){var h=new d.AmDObject("path",this);e||(e="100,100"); h.attr({cs:e});c?h.attr({dd:a}):h.attr({d:a});this.addToContainer(h.node,b);return h},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=this.container,b=a.style;b.top="0px";b.left="0px";try{var c=a.getBoundingClientRect(),d=c.left-Math.round(c.left),h=c.top-Math.round(c.top);d&&(b.left=d+"px");h&&(b.top=h+"px")}catch(f){}},update:function(){this.R.update()},addDefs:function(a){if(d.hasSVG){var b=this.createSvgElement("desc"), c=this.container;c.setAttribute("version","1.1");c.style.position="absolute";this.setSize(this.width,this.height);d.rtl&&(c.setAttribute("direction","rtl"),c.style.left="auto",c.style.right="0px");a&&(a.addCodeCredits&&b.appendChild(document.createTextNode("JavaScript chart by amCharts "+a.version)),c.appendChild(b),a.defs&&(b=this.createSvgElement("defs"),c.appendChild(b),d.parseDefs(a.defs,b),this.defs=b))}}})})();(function(){var d=window.AmCharts;d.AmDObject=d.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)},rotate:function(a,b){this.R.rotate(this,a,b);this.angle=a},animate:function(a,b,c){for(var e in a)if(a.hasOwnProperty(e)){var h=e,f=a[e];c=d.getEffect(c);this.R.animate(this,h,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.stop();this.R.remove(this)},clear:function(){var a=this.node;if(a.hasChildNodes())for(;1<= a.childNodes.length;)a.removeChild(a.firstChild)},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;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},touchmove:function(a){this.R.addListener(this, "touchmove",a);return this},touchstart:function(a){this.R.addListener(this,"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(){d.removeFromArray(this.R.animations,this.an_translate);d.removeFromArray(this.R.animations,this.an_y);d.removeFromArray(this.R.animations,this.an_x)},length:function(){return this.node.childNodes.length}, gradient:function(a,b,c){this.R.gradient(this,a,b,c)},pattern:function(a,b,c){a&&this.R.pattern(this,a,b,c)}})})();(function(){var d=window.AmCharts;d.VMLRenderer=d.Class({construct:function(a,b){this.chart=b;this.D=a;this.cNames={circle:"oval",ellipse:"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="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 h=document.createElement("amvml:fill");c.appendChild(h);a.fill=h;h.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 e;8===document.documentMode&& (e=!0);var h=a.node,f=a.type,g=h.style;"r"==b&&(g.width=2*c,g.height=2*c);"oval"==a.shapeType&&("rx"==b&&(g.width=2*c),"ry"==b&&(g.height=2*c));"roundrect"==a.shapeType&&("width"!=b&&"height"!=b||--c);"cursor"==b&&(g.cursor=c);"cx"==b&&(g.left=c-d.removePx(g.width)/2);"cy"==b&&(g.top=c-d.removePx(g.height)/2);var k=this.styleMap[b];"width"==k&&0>c&&(c=0);void 0!==k&&(g[k]=c);"text"==f&&("text-anchor"==b&&(a.anchor=c,k=h.clientWidth,"end"==c&&(g.marginLeft=-k+"px"),"middle"==c&&(g.marginLeft=-(k/2)+ "px",g.textAlign="center"),"start"==c&&(g.marginLeft="0px")),"fill"==b&&(g.color=c),"font-weight"==b&&(g.fontWeight=c));if(g=a.children)for(k=0;kc&&(g="dot"),3<=c&&6>=c&&(g="dash"),6g&&(b+=g);0>k&&(c+=k)}return{x:b,y:c,width:d,height:h}},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 e=a.node,h=e.style;"text"==a.type&&(c-=d.removePx(h.fontSize)/2-1);"oval"==a.shapeType&&(b-=d.removePx(h.width)/2,c-=d.removePx(h.height)/2);a=a.bw;isNaN(a)||(b-=a,c-=a);isNaN(b)||isNaN(c)||(e.style.left=b+"px",e.style.top= c+"px")},svgPathToVml:function(a){var b=a.split(" ");a="";var c,d=Math.round,h;for(h=0;hthis.fontSize&&(this.ly=h/2-1);0p&&(p=z);x=x.height;x>t&&(t=x)}var z=t=0,B=f,C=0,D=0;for(A=0;AD&&(D=x.height);I+x.width>q&&0=l&&(z=0,t++,C=C+D+m,B=f,D=0);w.push(L)}x=w.getBBox();l=x.height+2*m-1;"left"==a||"right"==a?(n=x.width+2*f,k=n+b+c,g.style.width=k+"px",this.ieW=k):n=k-b-c-1;c=d.polygon(this.container,[0,n,n,0],[0,0,l,l],this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);d.setCN(this.chart,c,"legend-bg");u.push(c);u.translate(b,e);c.toBack(); b=f;if("top"==a||"bottom"==a||"absolute"==a||"outside"==a)"center"==this.align?b=f+(n-x.width)/2:"right"==this.align&&(b=f+n-x.width);w.translate(b,m+1);this.titleHeight>l&&(l=this.titleHeight);a=l+e+h+1;0>a&&(a=0);a>this.chart.divRealHeight&&(g.style.top="0px");g.style.height=Math.round(a)+"px";r.setSize(this.divWidth,a)},createEntry:function(a){if(!1!==a.visibleInLegend&&!a.hideFromLegend){var b=this.chart,c=a.markerType;a.legendEntryWidth=this.markerSize;c||(c=this.markerType);var e=a.color,h= a.alpha;a.legendKeyColor&&(e=a.legendKeyColor());a.legendKeyAlpha&&(h=a.legendKeyAlpha());var f;!0===a.hidden&&(f=e=this.markerDisabledColor);var g=a.pattern,k=a.customMarker;k||(k=this.customMarker);var l=this.container,m=this.markerSize,n=0,q=0,p=m/2;if(this.useGraphSettings){c=a.type;this.switchType=void 0;if("line"==c||"step"==c||"smoothedLine"==c||"ohlc"==c)g=l.set(),a.hidden||(e=a.lineColorR,f=a.bulletBorderColorR),n=d.line(l,[0,2*m],[m/2,m/2],e,a.lineAlpha,a.lineThickness,a.dashLength),d.setCN(b, n,"graph-stroke"),g.push(n),a.bullet&&(a.hidden||(e=a.bulletColorR),n=d.bullet(l,a.bullet,a.bulletSize,e,a.bulletAlpha,a.bulletBorderThickness,f,a.bulletBorderAlpha))&&(d.setCN(b,n,"graph-bullet"),n.translate(m+1,m/2),g.push(n)),p=0,n=m,q=m/3;else{var t;a.getGradRotation&&(t=a.getGradRotation(),0===t&&(t=180));n=a.fillColorsR;!0===a.hidden&&(n=e);if(g=this.createMarker("rectangle",n,a.fillAlphas,a.lineThickness,e,a.lineAlpha,t,g,a.dashLength))p=m,g.translate(p,m/2);n=m}d.setCN(b,g,"graph-"+c);d.setCN(b, g,"graph-"+a.id)}else if(k)g=l.image(k,0,0,m,m);else{var r;isNaN(this.gradientRotation)||(r=180+this.gradientRotation);(g=this.createMarker(c,e,h,void 0,void 0,void 0,r,g))&&g.translate(m/2,m/2)}d.setCN(b,g,"legend-marker");this.addListeners(g,a);l=l.set([g]);this.switchable&&a.switchable&&l.setAttr("cursor","pointer");void 0!==a.id&&d.setCN(b,l,"legend-item-"+a.id);d.setCN(b,l,a.className,!0);f=this.switchType;var u;f&&"none"!=f&&0c&&(d="00"+c);10<=c&&100>c&&(d="0"+c);a=a.replace(/fff/g,d)}return a};d.extractPeriod=function(a){var b=d.stripNumbers(a),c=1;b!=a&&(c=+a.slice(0,a.indexOf(b)));return{period:b,count:c}};d.getDate=function(a,b,c){return a instanceof Date?d.newDate(a,c):b&&isNaN(a)?d.stringToDate(a,b):new Date(a)};d.daysInMonth=function(a){return(new Date(a.getYear(),a.getMonth()+1, 0)).getDate()};d.newDate=function(a,b){return b&&-1==b.indexOf("fff")?new Date(a):new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds())};d.resetDateToMin=function(a,b,c,e){void 0===e&&(e=1);var h,f,g,k,l,m,n;d.useUTC?(h=a.getUTCFullYear(),f=a.getUTCMonth(),g=a.getUTCDate(),k=a.getUTCHours(),l=a.getUTCMinutes(),m=a.getUTCSeconds(),n=a.getUTCMilliseconds(),a=a.getUTCDay()):(h=a.getFullYear(),f=a.getMonth(),g=a.getDate(),k=a.getHours(),l=a.getMinutes(), m=a.getSeconds(),n=a.getMilliseconds(),a=a.getDay());switch(b){case "YYYY":h=Math.floor(h/c)*c;f=0;g=1;n=m=l=k=0;break;case "MM":f=Math.floor(f/c)*c;g=1;n=m=l=k=0;break;case "WW":g=a>=e?g-a+e:g-(7+a)+e;n=m=l=k=0;break;case "DD":n=m=l=k=0;break;case "hh":k=Math.floor(k/c)*c;n=m=l=0;break;case "mm":l=Math.floor(l/c)*c;n=m=0;break;case "ss":m=Math.floor(m/c)*c;n=0;break;case "fff":n=Math.floor(n/c)*c}d.useUTC?(a=new Date,a.setUTCFullYear(h,f,g),a.setUTCHours(k,l,m,n)):a=new Date(h,f,g,k,l,m,n);return a}; d.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};d.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}};d.getMaxInterval= function(a,b){var c=d.intervals;return a>=c[b].contains?(a=Math.round(a/c[b].contains),b=c[b].nextInterval,d.getMaxInterval(a,b)):"ss"==b?c[b].nextInterval:b};d.dayNames="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ");d.shortDayNames="Sun Mon Tue Wed Thu Fri Sat".split(" ");d.monthNames="January February March April May June July August September October November December".split(" ");d.shortMonthNames="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");d.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)};d.stringToDate=function(a,b){var c={},e=[{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",period:"minutes"},{pattern:"SS",period:"seconds"},{pattern:"S",period:"seconds"},{pattern:"QQQ",period:"milliseconds"},{pattern:"QQ",period:"milliseconds"},{pattern:"Q",period:"milliseconds"}],h=!0,f=b.indexOf("AA");-1!=f&&(a.substr(f,2),"pm"==a.toLowerCase&&(h=!1));var f=b,g,k,l;for(l=0;lr&&(r="0"+r);b=b.replace(/JJ/g,r);b=b.replace(/J/g,q);r=k;0===r&&(r=24,-1!=b.indexOf("H")&&(f--,0===f&&(e=new Date(a),e.setDate(e.getDate()-1),h=e.getMonth(),f=e.getDate(),e=e.getFullYear())));a=h+1;9>h&&(a="0"+a);q=f;10>f&&(q="0"+f);var u=r;10>u&&(u="0"+u);b=b.replace(/HH/g,u);b=b.replace(/H/g,r);r=k;11u&&(u="0"+u);b=b.replace(/KK/g,u);b=b.replace(/K/g,r);r=k;0===r&&(r=12);12u&&(u="0"+u);b=b.replace(/LL/g,u);b=b.replace(/L/g,r); r=l;10>r&&(r="0"+r);b=b.replace(/NN/g,r);b=b.replace(/N/g,l);l=m;10>l&&(l="0"+l);b=b.replace(/SS/g,l);b=b.replace(/S/g,m);m=n;10>m&&(m="00"+m);100>m&&(m="0"+m);l=n;10>l&&(l="00"+l);b=b.replace(/QQQ/g,m);b=b.replace(/QQ/g,l);b=b.replace(/Q/g,n);b=12>k?b.replace(/A/g,c.amString):b.replace(/A/g,c.pmString);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,e);b=b.replace(/@II@/g,p);b=b.replace(/@XXXX@/g,c.monthNames[h]);b=b.replace(/@XXX@/g,c.shortMonthNames[h]);b=b.replace(/@XX@/g,a);b=b.replace(/@X@/g,h+1);b=b.replace(/@RR@/g,q);b=b.replace(/@R@/g,f);b=b.replace(/@PPPP@/g,c.dayNames[g]);b=b.replace(/@PPP@/g,c.shortDayNames[g]);b=b.replace(/@PP@/g,t);return b=b.replace(/@P@/g,g)};d.changeDate=function(a,b,c,e,h){if(d.useUTC)return d.changeUTCDate(a, b,c,e,h);var f=-1;void 0===e&&(e=!0);void 0===h&&(h=!1);!0===e&&(f=1);switch(b){case "YYYY":a.setFullYear(a.getFullYear()+c*f);e||h||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);e||h||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()+c*f);break;case "ss":a.setSeconds(a.getSeconds()+ c*f);break;case "fff":a.setMilliseconds(a.getMilliseconds()+c*f)}return a};d.changeUTCDate=function(a,b,c,d,h){var f=-1;void 0===d&&(d=!0);void 0===h&&(h=!1);!0===d&&(f=1);switch(b){case "YYYY":a.setUTCFullYear(a.getUTCFullYear()+c*f);d||h||a.setUTCDate(a.getUTCDate()+1);break;case "MM":b=a.getUTCMonth();a.setUTCMonth(a.getUTCMonth()+c*f);a.getUTCMonth()>b+c*f&&a.setUTCDate(a.getUTCDate()-1);d||h||a.setUTCDate(a.getUTCDate()+1);break;case "DD":a.setUTCDate(a.getUTCDate()+c*f);break;case "WW":a.setUTCDate(a.getUTCDate()+ c*f*7);break;case "hh":a.setUTCHours(a.getUTCHours()+c*f);break;case "mm":a.setUTCMinutes(a.getUTCMinutes()+c*f);break;case "ss":a.setUTCSeconds(a.getUTCSeconds()+c*f);break;case "fff":a.setUTCMilliseconds(a.getUTCMilliseconds()+c*f)}return a}})(); (function(){var k=window.AmCharts;k.AmSlicedChart=k.Class({inherits:k.AmChart,construct:function(a){this.createEvents("rollOverSlice","rollOutSlice","clickSlice","pullOutSlice","pullInSlice","rightClickSlice");k.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=!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=10;this.gradientRatio=[];this.maxLabelWidth=200;k.applyTheme(this,a,"AmSlicedChart")},initChart:function(){k.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,c=a.dataItem,d=this.legend;if(!d.data&&c){var g=c.hidden;a=a.event;switch(b){case "clickMarker":g||d.switchable||this.clickSlice(c,a);break;case "clickLabel":g|| this.clickSlice(c,a,!1);break;case "rollOverItem":g||this.rollOverSlice(c,!1,a);break;case "rollOutItem":g||this.rollOutSlice(c,a);break;case "hideItem":this.hideSlice(c,a);break;case "showItem":this.showSlice(c,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)}).touchstart(function(a){}).mouseup(function(a){c.clickSlice(b,a)}).contextmenu(function(a){c.handleRightClick(b,a)})},formatString:function(a,b,c){a=k.formatValue(a,b,["value"],this.nf,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);var d=this.pf.precision;isNaN(this.tempPrec)||(this.pf.precision=this.tempPrec);a=k.formatValue(a,b,["percents"],this.pf);a=k.massReplace(a,{"[[title]]":b.title,"[[description]]":b.description});this.pf.precision=d;-1!=a.indexOf("[[")&&(a= k.formatDataContextValue(a,b.dataContext));a=c?k.fixNewLines(a):k.fixBrakes(a);return a=k.cleanFromEmpty(a)},startSlices:function(){var a;for(a=0;athis.hoverAlpha&&a.wedge&&a.wedge.attr({opacity:this.hoverAlpha});var d=a.balloonX,g=a.balloonY;a.pulled&&(d+=a.pullX,g+=a.pullY);var f=this.formatString(this.balloonText,a,!0),h=this.balloonFunction;h&&(f=h(a,f));h=k.adjustLuminosity(a.color,-.15);f?this.showBalloon(f,h,b,d,g):this.hideBalloon();0===a.value&&this.hideBalloon();this.fire({type:"rollOverSlice",dataItem:a,chart:this,event:c})}},rollOutSlice:function(a,b){isNaN(a)||(a=this.chartData[a]);a.wedge&&a.wedge.attr({opacity:1});this.hideBalloon(); this.fire({type:"rollOutSlice",dataItem:a,chart:this,event:b})},clickSlice:function(a,b,c){isNaN(a)||(a=this.chartData[a]);a.pulled?this.pullSlice(a,0):this.pullSlice(a,1);k.getURL(a.url,this.urlTarget);c||this.fire({type:"clickSlice",dataItem:a,chart:this,event:b})},handleRightClick:function(a,b){isNaN(a)||(a=this.chartData[a]);this.fire({type:"rightClickSlice",dataItem:a,chart:this,event:b})},drawTicks:function(){var a=this.chartData,b;for(b=0;bb&&(b=g);d.remove()}return b}})})();(function(){var k=window.AmCharts;k.AmPieChart=k.Class({inherits:k.AmSlicedChart,construct:function(a){this.type="pie";k.AmPieChart.base.construct.call(this,a);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;this.adjustPrecision= !1;this.gradientType="radial";k.applyTheme(this,a,this.cname)},drawChart:function(){k.AmPieChart.base.drawChart.call(this);var a=this.chartData;if(k.ifArray(a)){if(0this.maxLabelWidth&&(p=this.maxLabelWidth);this.labelText&&this.labelsEnabled||(x=p=0);A=void 0===this.pieX?(d-h-e)/2+h:f(this.pieX,this.realWidth);B=void 0===this.pieY?(g-z-n)/2+z:f(this.pieY,g);l=f(this.radius,d,g);l||(d=0<=x?d-h-e-2*p:d-h-e,g=g-z-n,l=Math.min(d,g),gd&&(l=d)),g=k.toCoordinate(this.pullOutRadius,l),l=(0<=x?l-1.8*(x+g):l-1.8*g)/2);l=l&&(f=l-1);n=k.fitToBounds(this.startAngle,0,360);0=this.hideLabelsPercent){var m=n+r/2;0>m&&(m+=360);360t&&(e.skipTick=!0));var r=A+p*(l+t),E=B+C*(l+t),w,u=0;isNaN(D)&&350=m&&0<=m?(y=0,w="start",u=8):90<=m&&180>m?(y=1,w="start",u=8): 180<=m&&270>m?(y=2,w="end",u=-8):270<=m&&354>=m?(y=3,w="end",u=-8):354<=m&&(h>D?(y=0,w="start",u=8):(y=3,w="end",u=-8));e.labelQuarter=y}else w="middle";m=this.formatString(this.labelText,e);(t=this.labelFunction)&&(m=t(e,m));t=e.labelColor;t||(t=this.color);""!==m&&(m=k.wrappedText(c,m,t,this.fontFamily,this.fontSize,w,!1,this.maxLabelWidth),k.setCN(this,m,"pie-label"),k.setCN(this,m,e.className,!0),m.translate(r+1.5*u,E),m.node.style.pointerEvents="none",e.ty=E,e.textX=r+1.5*u,v.push(m),this.axesSet.push(v), e.labelSet=v,e.label=m);e.tx=r;e.tx2=r+u;e.tx0=A+p*l;e.ty0=B+C*l}r=f+(l-f)/2;e.pulled&&(r+=this.pullOutRadiusReal);e.balloonX=p*r+A;e.balloonY=C*r+B;e.startX=Math.round(p*z);e.startY=Math.round(C*z);e.pullX=Math.round(p*g);e.pullY=Math.round(C*g);this.graphsSet.push(q);if(0===e.alpha||0c?d.toFront():180<=c&&d.toBack()}},arrangeLabels:function(){var a=this.chartData,b=a.length,c,d;for(d=b-1;0<=d;d--)c=a[d],0!==c.labelQuarter||c.hidden||this.checkOverlapping(d,c,0,!0,0);for(d=0;dg&&isNaN(b.labelRadius)&&(f=b.ty+3*b.iy,b.ty=f,n.translate(b.textX, f),this.checkOverlapping(a,b,c,d,g+1))}},checkOverlappingReal:function(a,b,c){var d=!1,g=a.label,f=b.label;a.labelQuarter!=c||a.hidden||b.hidden||!f||(g=g.getBBox(),c={},c.width=g.width,c.height=g.height,c.y=a.ty,c.x=a.tx,a=f.getBBox(),f={},f.width=a.width,f.height=a.height,f.y=b.ty,f.x=b.tx,k.hitTest(c,f)&&(d=!0));return d}})})(); (function(){var e=window.AmCharts;e.AmRectangularChart=e.Class({inherits:e.AmCoordinateChart,construct:function(a){e.AmRectangularChart.base.construct.call(this,a);this.theme=a;this.createEvents("zoomed","changed");this.marginRight=this.marginBottom=this.marginTop=this.marginLeft=20;this.depth3D=this.angle=0;this.plotAreaFillColors="#FFFFFF";this.plotAreaFillAlphas=0;this.plotAreaBorderColor="#000000";this.plotAreaBorderAlpha=0;this.maxZoomFactor=20;this.zoomOutButtonImageSize=19;this.zoomOutButtonImage= "lens";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;e.applyTheme(this,a,"AmRectangularChart")},initChart:function(){e.AmRectangularChart.base.initChart.call(this);this.updateDxy();!this.marginsUpdated&&this.autoMargins&&(this.resetMargins(),this.drawGraphs=!1);this.processScrollbars();this.updateMargins();this.updatePlotArea(); this.updateScrollbars();this.updateTrendLines();this.updateChartCursor();this.updateValueAxes();this.scrollbarOnly||this.updateGraphs()},drawChart:function(){e.AmRectangularChart.base.drawChart.call(this);this.drawPlotArea();if(e.ifArray(this.chartData)){var a=this.chartCursor;a&&a.draw()}},resetMargins:function(){var a={},b;if("xy"==this.type){var c=this.xAxes,d=this.yAxes;for(b=0;b=g-c&& (this.marginRight=Math.round(l-g+c));d.top&&eh-c&&(this.marginBottom=Math.round(this.marginBottom+b-h+c));this.initChart()},getAxisBounds:function(a,b,c,d,g){if(!a.ignoreAxisWidth){var e=a.labelsSet,f=a.tickLength;a.inside&&(f=0);if(e)switch(e=a.getBBox(),a.position){case "top":a=e.y;d>a&&(d=a);break;case "bottom":a=e.y+e.height;ga&&(b=a)}}return{l:b,t:d,r:c,b:g}},drawZoomOutButton:function(){var a=this;if(!a.zbSet){var b=a.container.set();a.zoomButtonSet.push(b);var c=a.color,d=a.fontSize,g=a.zoomOutButtonImageSize,h=a.zoomOutButtonImage.replace(/\.[a-z]*$/i,""),f=e.lang.zoomOutText||a.zoomOutText,k=a.zoomOutButtonColor,l=a.zoomOutButtonAlpha,m=a.zoomOutButtonFontSize,q=a.zoomOutButtonPadding;isNaN(m)||(d=m);(m=a.zoomOutButtonFontColor)&&(c=m);var m=a.zoomOutButton,n;m&&(m.fontSize&&(d=m.fontSize),m.color&&(c=m.color), m.backgroundColor&&(k=m.backgroundColor),isNaN(m.backgroundAlpha)||(a.zoomOutButtonRollOverAlpha=m.backgroundAlpha));var p=m=0;void 0!==a.pathToImages&&h&&(n=a.container.image(a.pathToImages+h+a.extension,0,0,g,g),e.setCN(a,n,"zoom-out-image"),b.push(n),n=n.getBBox(),m=n.width+5);void 0!==f&&(c=e.text(a.container,f,c,a.fontFamily,d,"start"),e.setCN(a,c,"zoom-out-label"),d=c.getBBox(),p=n?n.height/2-3:d.height/2,c.translate(m,p),b.push(c));n=b.getBBox();c=1;e.isModern||(c=0);k=e.rect(a.container,n.width+ 2*q+5,n.height+2*q-2,k,1,1,k,c);k.setAttr("opacity",l);k.translate(-q,-q);e.setCN(a,k,"zoom-out-bg");b.push(k);k.toBack();a.zbBG=k;n=k.getBBox();b.translate(a.marginLeftReal+a.plotAreaWidth-n.width+q,a.marginTopReal+q);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(l=0;la&&(a=1);1>b&&(b=1);this.plotAreaWidth=Math.round(a);this.plotAreaHeight=Math.round(b);this.plotBalloonsSet.translate(c,d)},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=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;this.fixMargins&&!this.fixMargins.top&&(this.marginTopReal+=a);this.marginBottomReal=this.marginBottom;this.marginLeftReal= this.marginLeft;this.marginRightReal=this.marginRight},updateValueAxes:function(){var a=this.valueAxes,b;for(b=0;bd)var g=c,c=d,d=g;this.relativeZoomValueAxes(b,c,d);this.updateAfterValueZoom()},updateAfterValueZoom:function(){this.zoomAxesAndGraphs(); this.zoomScrollbar()},relativeZoomValueAxes:function(a,b,c){b=e.fitToBounds(b,0,1);c=e.fitToBounds(c,0,1);if(b>c){var d=b;b=c;c=d}var d=1/this.maxZoomFactor,g=e.getDecimals(d)+4;c-ba?d?(f=this.endTime-this.startTime,d=this.startTime+c*g,g=this.endTime+e*g,0=k&&(g=k,d=k-f),this.zoomToDates(new Date(d),new Date(g))):(0=f-1&&(c=e=0),d=this.start+ c,g=this.end+e,this.zoomToIndexes(d,g)):d?(f=this.endTime-this.startTime,d=this.startTime-c*g,g=this.endTime-e*g,0this.start&&(c=e=0),d=this.start-c,g=this.end-e,this.zoomToIndexes(d,g))}},validateData:function(a){this.marginsUpdated=!1;this.zoomOutOnDataUpdate&&!a&&(this.endTime=this.end=this.startTime=this.start=NaN);e.AmSerialChart.base.validateData.call(this)},drawChart:function(){if(0c&&(a=b-c),a!=this.startTime&&b-a>c&&(b=a+c));var d=this.minSelectedTime;if(0k&&(a=k);bk&&(b=k);bthis.firstTime&&(a=!0),this.endTimec&&(a=b-c),a!=this.start&&b-a>c&&(b=a+c));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);bd&&(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();this.fixCursor();0!==a||b!=this.chartData.length-1?this.showZB(!0):this.showZB(!1);this.updateColumnsDepth();this.dispatchIndexZoomEvent()}},updateGraphs:function(){e.AmSerialChart.base.updateGraphs.call(this);var a=this.graphs,b;for(b=0;bb.depth?1:-1},zoomScrollbar:function(){var a=this.chartScrollbar,b=this.categoryAxis;if(a){if(!this.zoomedByScrollbar){var c=a.dragger;c&&c.stop()}this.zoomedByScrollbar=!1;b.parseDates&&!b.equalSpacing?a.timeZoom(this.startTime,this.endTime):a.zoom(this.start,this.end)}this.zoomValueScrollbar(this.valueScrollbar)},updateTrendLines:function(){var a=this.trendLines,b;for(b=0;be&&(e=0);h>a.length-1&&(h=a.length-1);var f=e+Math.round((h-e)/2),k=a[f][b];return c==k?f:1>=h-e?d?e:Math.abs(a[e][b]-c)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){var c=this.chartData;if(c)if(this.categoryAxis.equalSpacing){var d=this.getClosestIndex(c,"time",a.getTime(),!0,0,c.length);b=e.resetDateToMin(b,this.categoryAxis.minPeriod,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.chartData&&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(" "),g=b.valueAxis,h=this.chartData,f=b.numberFormatter;f||(f=this.nf);for(var k=0;ky.x||y.x>y.graph.height)D=NaN}else if(0>y.x||y.x>y.graph.width)D=NaN;if(!isNaN(D)){isNaN(n)&&(n=D);p=D;if(isNaN(x)||x>D)x=D;if(isNaN(u)||u< D)u=D;B=e.getDecimals(m);var F=e.getDecimals(D),m=m+D,m=e.roundTo(m,Math.max(B,F));q++;B=m/q}}if(y.percents&&(y=y.percents[l],!isNaN(y))){isNaN(C)&&(C=y);v=y;if(isNaN(w)||w>y)w=y;if(isNaN(A)||Ab&&0===q&&(q=180):0>c&&270==q&&(q=90);this.gradientRotation=q;0===d&&0===e&&(this.cornerRadius=n);this.draw()},draw:function(){var a=this.set;a.clear(); var b=this.container,c=b.chart,d=this.w,g=this.h,h=this.dx,f=this.dy,k=this.colors,l=this.alpha,m=this.bwidth,q=this.bcolor,n=this.balpha,p=this.gradientRotation,x=this.cornerRadius,u=this.dashLength,B=this.pattern,r=this.topRadius,t=this.bcn,C=k,v=k;"object"==typeof k&&(C=k[0],v=k[k.length-1]);var w,A,z,G,y,D,F,L,M,Q=l;B&&(l=0);var E,H,I,J,K=this.rotate;if(0Math.abs(g)&&(g=0);1>Math.abs(d)&&(d=0);!isNaN(r)&&(0g&&(m=" A"),l+=m+Math.round(d/2-I)+","+Math.round(g-J)+","+Math.round(d/2+I)+","+Math.round(g+J)+",0,"+g+","+d+","+g,l+=" L"+d+",0",l+=m+Math.round(d/ 2+E)+","+Math.round(H)+","+Math.round(d/2-E)+","+Math.round(-H)+","+d+",0,0,0"):(l+="A"+I+","+J+",0,0,0,"+(d-d/2*(1-r))+","+g+"L"+d+",0",l+="A"+E+","+H+",0,0,1,0,0"),E=180),b=b.path(l).attr(k),b.gradient("linearGradient",[C,e.adjustLuminosity(C,-.3),e.adjustLuminosity(C,-.3),C],E),K?b.translate(h/2,0):b.translate(0,f/2)):b=0===g?e.line(b,[0,d],[0,0],q,n,m,u):0===d?e.line(b,[0,0],[0,g],q,n,m,u):0g?[w, M,A,z,G,y,D,F,L,b]:[F,L,A,z,G,y,w,M,D,b]:K?0g?[w,b,F]:[F,b,w];e.setCN(c,b,t+"front");e.setCN(c,A,t+"back");e.setCN(c,F,t+"top");e.setCN(c,w,t+"bottom");e.setCN(c,G,t+"left");e.setCN(c,y,t+"right");for(w=0;wb&&(this.endTime=b);t=this.minorGridEnabled;B=this.gridAlpha;var v,w=0,A=0;if(this.widthField)for(b=this.start;b<=this.end;b++)if(v=this.data[b]){var z=+this.data[b].dataContext[this.widthField];isNaN(z)||(w+=z,v.widthValue=z)}if(this.parseDates&&!this.equalSpacing)this.lastTime=a[a.length-1].time,this.maxTime=e.resetDateToMin(new Date(this.lastTime+1.05*x),this.minPeriod,1, q).getTime(),this.timeDifference=this.endTime-this.startTime,this.parseDatesDraw();else if(!this.parseDates){if(this.cellWidth=this.getStepWidth(f),fp&&(p=0),v=0,this.widthField&&(p=this.start),this.end-p+1>=this.autoRotateCount&&(this.labelRotationR=this.autoRotateAngle),b=p;b<=this.end+2;b++){n=!1;0<=b&&bthis.end&&"start"==this.tickPosition&&(p=" ");this.rotate&&this.inside&&(r-=2);isNaN(u.widthValue)||(u.percentWidthValue=u.widthValue/w*100,z=this.rotate?this.height*u.widthValue/w:this.width*u.widthValue/w,q=A,A+=z,r=z/2);r=new this.axisItemRenderer(this,q,p,n,z,r,void 0,x,a,!1,u.labelColor,u.className);r.serialDataItem=u;this.pushAxisItem(r);this.gridAlpha= B}}else if(this.parseDates&&this.equalSpacing){h=this.start;this.startTime=this.data[this.start].time;this.endTime=this.data[this.end].time;this.timeDifference=this.endTime-this.startTime;b=this.choosePeriod(0);g=b.period;u=b.count;b=e.getPeriodDuration(g,u);bp&&(p=0);A=this.end+2;A>=this.data.length&&(A=this.data.length);v=!1;v=!l;this.previousPos=-1E3;20=a){q=this.getCoordinate(b-this.start);t=!1;this.nextPeriod[B]&&(t=this.checkPeriodChange(this.nextPeriod[B],1,f,x,B));x=!1;t&&this.markPeriodChange?(t=this.dateFormatsObject[this.nextPeriod[B]],x=!0):t=this.dateFormatsObject[B];p=e.formatDate(new Date(f),t,c);if(b==d&&!l||b==k&&!m)p=" ";v?v=!1:(n||(x=!1),q-this.previousPos>this.safeDistance*Math.cos(this.labelRotationR*Math.PI/180)&&(this.labelFunction&& (p=this.labelFunction(p,new Date(f),this,g,u,r)),this.boldLabels&&(x=!0),r=new this.axisItemRenderer(this,q,p,void 0,void 0,void 0,void 0,x),t=r.graphics(),this.pushAxisItem(r),t=t.getBBox().width,e.isModern||(t-=q),this.previousPos=q+t));r=x=f}}for(b=l=0;bthis.height+1&&h--:k>this.width+1&&h--;0>k&&h++;return h=e.fitToBounds(h,0,b.length-1)},dateToCoordinate:function(a){return this.parseDates&&!this.equalSpacing?(a.getTime()-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){if(this.chart){var b=this.chart.getCategoryIndexByValue(a);if(!isNaN(b))return this.getCoordinate(b-this.start);if(this.parseDates)return this.dateToCoordinate(new Date(a))}else return NaN},coordinateToDate:function(a){return this.equalSpacing?(a=this.xToIndex(a),new Date(this.data[a].time)):new Date(this.startTime+a/this.stepWidth)},coordinateToValue:function(a){a=this.xToIndex(a); if(a=this.data[a])return this.parseDates?a.time:a.category},getCoordinate:function(a){a*=this.stepWidth;this.startOnAxis||(a+=this.stepWidth/2);return Math.round(a)},formatValue:function(a,b){b||(b=this.currentDateFormat);this.parseDates&&(a=e.formatDate(new Date(a),b,this.chart));return a},showBalloonAt:function(a){a=this.parseDates?this.dateToCoordinate(new Date(a)):this.categoryToCoordinate(a);return this.adjustBalloonCoordinate(a)},formatBalloonText:function(a,b,c){var d="",g="",h=this.chart, f=this.data[b];if(f)if(this.parseDates)d=e.formatDate(f.category,c,h),b=e.changeDate(new Date(f.category),this.minPeriod,1),g=e.formatDate(b,c,h),-1!=d.indexOf("fff")&&(d=e.formatMilliseconds(d,f.category),g=e.formatMilliseconds(g,b));else{var k;this.data[b+1]&&(k=this.data[b+1]);d=e.fixNewLines(f.category);k&&(g=e.fixNewLines(k.category))}a=a.replace(/\[\[category\]\]/g,String(d));return a=a.replace(/\[\[toCategory\]\]/g,String(g))},adjustBalloonCoordinate:function(a,b){var c=this.xToIndex(a),d= this.chart.chartCursor;if(this.stickBalloonToCategory){var e=this.data[c];e&&(a=e.x[this.id]);this.stickBalloonToStart&&(a-=this.cellWidth/2);var h=0;if(d){var f=d.limitToGraph;f&&(h=e.axes[f.valueAxis.id].graphs[f.id].y);this.rotate?("left"==this.position?(f&&(h-=d.width),0h&&(h=0),d.fixHLine(a,h)):("top"==this.position?(f&&(h-=d.height),0h&&(h=0),d.fixVLine(a,h))}}d&&!b&&(d.setIndex(c),this.parseDates&&d.setTimestamp(this.coordinateToDate(a).getTime()));return a}})})(); if (typeof WS === 'undefined') { var WS = {}; } /** * WS.Choice * * @param {Array} params { * 'id': {Integer} choice id * 'text': {String} choice text * 'votes': {Integer} choice votes * } */ WS.Choice = function(params) { params = (params == null ? {} : params); var __objName = 'Choice'; var _id = (params.id == null ? null : params.id); var _text = (params.text == null ? '' : params.text); var _votes = (params.votes == null ? 0 : params.votes); return { getObjectName: function() { return __objName; }, setId: function(id) { if (id == null) { WS.error('Choice: Invalid arguments. id is null'); return; } _id = id; }, getId: function() { return _id; }, setText: function(text) { if (text == null) { WS.error('Choice: Invalid arguments. text is null'); return; } _text = text; }, getText: function() { return _text; }, setVotes: function(votes) { if (votes == null) { WS.error('Choice: Invalid arguments. votes is null'); return; } _votes = votes; }, getVotes: function() { return _votes; }, incrementVotes: function() { ++_votes; }, toJSON: function() { return { id: _id, text: _text, votes: _votes, }; }, }; }; /** * WS.Question * * @param {Array} params { * 'id': {Integer} question id * 'text': {String} question text * 'votes': {Integer} question votes * 'choices': {Array} choices * } */ WS.Question = function(params) { params = (params == null ? {} : params); var __objName = 'Question'; var _id = (params.id == null ? null : params.id); var _text = (params.text == null ? '' : params.text); var _choices = (params.choices == null ? [] : params.choices); return { getObjectName: function() { return __objName; }, setId: function(id) { if (id == null) { WS.error('Question: Invalid arguments. id is null'); return; } _id = id; }, getId: function() { return _id; }, setText: function(text) { if (text == null) { WS.error('Question: Invalid arguments. text is null'); return; } _text = text; }, getText: function() { return _text; }, setChoices: function(choices) { _choices = choices; }, addChoice: function(choice) { if (choice.getObjectName == null || choice.getObjectName() !== 'Choice') { WS.error('Question: Invalid argument. choice is not Choice object'); return; } _choices.push(choice); }, getChoices: function() { return _choices; }, choicesToJSON: function() { var cs = []; for (var i = 0, len = _choices.length; i < len; ++i) { cs.push(_choices[i].toJSON()); } return cs; }, getVotesSum: function() { var sum = 0; for (var i = 0, len = _choices.length; i < len; ++i) { sum += parseInt(_choices[i].getVotes(), 10); } return sum; }, }; }; /* Namespace of WS */ if (typeof WS === 'undefined') { var WS = {}; } /* Constant valiables */ WS._NAME = 'WebSurvey'; /* Color table for AmCharts 10色以上指定の必要がある */ WS._chartColorTable = [ '#796BAF', '#EE87B4', '#4784BF', '#54C3F1', '#EF845C', '#FFF67F', '#69BD83', '#dddddd', '#EF845C', '#FFF67F', '#69BD83', '#54C3F1' ]; /** * console.error()のラッパー * * @param[in] {String} msg */ WS.error = function(msg) { console.error(WS._NAME + ': ' + msg); }; /** * console.log()のラッパー * * @param[in] {String} msg */ WS.log = function(msg) { //console.log(WS._NAME + ': ' + msg); }; /** * WS.AmChart * * AmChartsのチャート群のI/Fを統一するためのオブジェクト。 * AmChartsのチャートは構築方法が統一されておらず、簡便さが必要になった。 * そのためこのオブジェクトを作成してある程度の統一を図った。 * * グラフィカルな描画もこのオブジェクトで行う。 * 描画のためのパラメーターはquestion.js: WS.Questionから取得する。 * WS.ChartがDOMの構築時にWS.Questionに描画用のパラメーターを保存する。 * WS.AmChartはそのWS.Questionを元に描画を行う。 * * @param[in] {Array} params { * 'type': {Integer} チャートのタイプ * } */ WS.AmChart = function(params) { params = (params == null ? {} : params); // Number of types var _Type = { PIE: 0, PIE_3D: 1, PIE_DONUT: 10, PIE_DONUT_3D: 11, COLUMN: 20, COLUMN_3D: 21, }; var _chart = null; // AmCharts object var _type = (params.type == null ? 0 : parseInt(params.type, 10)); // チャートのタイプ // バッファー var _titleFieldName; var _valueFieldName; var _colors; var _question; // タイプからチャートを構築 switch (_type) { case _Type.PIE: _chart = new AmCharts.AmPieChart(); break; case _Type.PIE_3D: _chart = new AmCharts.AmPieChart(); _chart.depth3D = 15; _chart.angle = 30; break; case _Type.PIE_DONUT: _chart = new AmCharts.AmPieChart(); _chart.sequencedAnimation = true; _chart.startEffect = "elastic"; _chart.innerRadius = "30%"; _chart.startDuration = 2; break; case _Type.PIE_DONUT_3D: _chart = new AmCharts.AmPieChart(); _chart.sequencedAnimation = true; _chart.startEffect = "elastic"; _chart.innerRadius = "30%"; _chart.startDuration = 2; _chart.depth3D = 15; _chart.angle = 15; break; case _Type.COLUMN: // Break through case _Type.COLUMN_3D: _chart = new AmCharts.AmSerialChart(); _chart.categoryField = "text"; // lazy _chart.startDuration = 1; if (_type === _Type.COLUMN_3D) { _chart.depth3D = 20; _chart.angle = 30; } // AXES // category var categoryAxis = _chart.categoryAxis; categoryAxis.labelRotation = 45; // this line makes category values to be rotated categoryAxis.gridAlpha = 0; categoryAxis.fillAlpha = 1; categoryAxis.fillColor = "#FAFAFA"; categoryAxis.gridPosition = "start"; // value var valueAxis = new AmCharts.ValueAxis(); valueAxis.id = 'axis'; valueAxis.dashLength = 5; valueAxis.title = ''; // lazy valueAxis.axisAlpha = 0; _chart.addValueAxis(valueAxis); // GRAPH var graph = new AmCharts.AmGraph(); graph.valueField = "votes"; // lazy graph.colorField = "color"; // lazy graph.balloonText = "[[category]]: [[value]]"; graph.type = "column"; graph.lineAlpha = 0; graph.fillAlphas = 1; graph.fixedColumnWidth = 36; _chart.addGraph(graph); // CURSOR var chartCursor = new AmCharts.ChartCursor(); chartCursor.cursorAlpha = 0; chartCursor.zoomable = false; chartCursor.categoryBalloonEnabled = false; _chart.addChartCursor(chartCursor); _chart.creditsPosition = "top-right"; break; default: /* Error */ WS.error('Not supported chart type of "' + type + '"'); _type = _Type.PIE; _chart = new AmCharts.AmPieChart(); break; } /* 共通設定 */ switch (_type) { case _Type.PIE: case _Type.PIE_3D: case _Type.PIE_DONUT: case _Type.PIE_DONUT_3D: _chart.autoMargins = false; _chart.marginTop = 8; _chart.marginBottom = 8; _chart.marginLeft = 8; _chart.marginRight = 8; _chart.pullOutRadius = 12; _chart.outlineColor = '#FFFFFF'; _chart.fontSize = 13; _chart.outlineAlpha = 0.8; _chart.outlineThickness = 2; break; case _Type.COLUMN: case _Type.COLUMN_3D: default: break; } var _hideLabels = function() { _chart.labelsEnabled = false; if (_chart.categoryAxis != null) { _chart.categoryAxis.labelsEnabled = false; } }; var _showLabels = function() { _chart.labelsEnabled = true; if (_chart.categoryAxis != null) { _chart.categoryAxis.labelsEnabled = true; } }; /** * レスポンシブ対応 * * チャートのラベル表示をデバイスに応じて切り替え。 * */ var _onWindowResize = function() { // モバイルであれば非表示 if (/Android|iPhone|iPod/i.test(navigator.userAgent)) { _hideLabels(); return; } if (window.matchMedia('(max-width: 768px)').matches) { // max-width 以下になったらラベルを切り替え _hideLabels(); } else if (window.matchMedia('(min-width:769px)').matches) { // min-width 以上になったらラベルを切り替え _showLabels(); }; }; _onWindowResize(); // 構築時の最初の調整 // レスポンシブ処理をイベントに登録 window.addEventListener('resize', function() { _onWindowResize(); }); /* Public interface */ return { Type: _Type, setColors: function(colors) { _colors = colors; }, setQuestion: function(question) { _question = question; }, setTitleField: function(name) { _titleFieldName = name; }, setValueField: function(name) { _valueFieldName = name; }, /** * オブジェクトの状態をチェックする * * @return {Boolean} 正常ならtrue * @return {Boolean} 異常ならfalse */ check: function() { var chk = function(name, el, rhval) { if (el == rhval) { WS.error('WS.AmChart: check: ' + name + ' is ' + rhval); return 1; } return 0; }; var ret = 0; ret += chk('chart', _chart, null); ret += chk('type', _type, null); ret += chk('titleFieldName', _titleFieldName, null); ret += chk('valueFieldName', _valueFieldName, null); ret += chk('colors', _colors, null); ret += chk('question', _question, null); return ret === 0; // Success to zero as true }, /** * 状態を更新する。 * * @return {Boolean} 成功したらtrue * @return {Boolean} 失敗したらfalse */ update: function() { if (!this.check()) { WS.error('WS.AmChart: update: Invalid status'); return false; } switch (_type) { default: _chart.titleField = _titleFieldName; _chart.valueField = _valueFieldName; _chart.colors = _colors; var cs = _question.choicesToJSON(); _chart.dataProvider = cs; break; case _Type.COLUMN: case _Type.COLUMN_3D: _chart.titleField = _titleFieldName; _chart.valueField = _valueFieldName; var vAxis = _chart.getValueAxisById('axis'); vAxis.title = _question.getText(); // タイトルを更新。 // Column chart のために色を格納する(chart.colorsは機能しない)。 var cs = _question.choicesToJSON(); for (var i = 0, len = Math.min(cs.length, _colors.length); i < len; ++i) { cs[i]['color'] = _colors[i]; } _chart.dataProvider = cs; break; } _chart.validateData(); return true; }, /** * チャートをノードに構築する。 * * @param[out] {Object} dstnode 構築先ノード * * @return {Boolean} 成功したらtrue * @return {Boolean} 失敗したらfalse */ buildTo: function(dstnode) { if (!this.update()) { WS.error('WS.AmChart: buildTo: Failed to update'); return false; } while (dstnode.hasChildNodes()) { dstnode.removeChild(dstnode.firstChild); } _chart.write(dstnode); return true; }, }; }; /** * WS.AmChartをtypeから作成する * 未対応のtypeであればエラー出力後、デフォルトのchartを作成する * * @param[in] {Integer} type チャートのタイプ * * @return {Object} WS.AmChart */ WS.makeAmChartFromType = function(type) { if (AmCharts == null) { WS.error('AmCharts is null'); return null; } var amChart = new WS.AmChart({ 'type': type, }); amChart.setTitleField('text'); amChart.setValueField('votes'); amChart.setColors(WS.getRandomChartColors()); return amChart; }; /** * isInteger for IE * * @param {Integer} value * * @return {Boolean} Integerならtrue * @return {Boolean} でなければfalse */ WS.isInteger = function(value) { return value ^ 0 === value; }; /** * AmChartsで使用する色の配列をランダムに作成して返す * カラーテーブルが 10 色以下であれば #eee で埋める * * @return {Array} */ WS.getRandomChartColors = function() { var colors = []; var max = 10; var min = (Math.min(WS._chartColorTable.length, max)); var ofs = Math.floor(Math.random() * (WS._chartColorTable.length - min)); for (var i = ofs, lim = ofs+min; i < lim; ++i) { colors.push(WS._chartColorTable[i]); } if (colors.length < max) { for (var i = 0, len = max-colors.length; i < len; ++i) { colors.push("#eee"); } } return colors; }; /** * ASCII文字列を16進数文字列に変換する * * @param[in] {String} src 変換元文字列 * * @return {String} 16進数文字列 */ WS.stringToHexString = function(src) { var dst = ''; for (var i = 0, len = src.length; i < len; ++i) { var b = src.charCodeAt(i); if (b < 16) { dst += '0' + b; } else { dst += b.toString(16); } } return dst; }; /** * 16進数文字列を文字列に変換する * * @param[in] {String} src 変換元文字列 * * @return {String} 文字列 */ WS.hexStringToString = function(src) { var dst = ''; for (var i = 0, len = src.length; i < len; i += 2) { var b = parseInt(src.substr(i,2), 16); dst += String.fromCharCode(b); } return dst; }; if (typeof WS === 'undefined') { var WS = {}; } /** * WS.Chart * * 主にチャートのDOMを構築するためのオブジェクト。 * 構築時にパラメーターを指定することで内容を設定できる。 * 広告も構築時に設定する。 * * templates/api/chart-factory.js の WSAPI.Chart.buildDom に使用例がある。 * グラフィカルなチャートの描画で使うパラメーターもこれで構築される。 * このオブジェクト自体はグラフィカルな描画を行わない。templates/api/ws.js: WS.AmChartも参照のこと。 * DOMのテンプレはtemplates/api/chart.htmlを参照のこと。 */ WS.Chart = function() { var _rootNode = null; /* 構築先ノード */ var _uniqueNumber = null; /* このチャートの唯一のID */ var _votesSumNode = null; /* 投票合計数を表示するノード */ var _question = new WS.Question(); return { getRoot: function() { return _rootNode; }, getNumber: function() { return _uniqueNumber; }, getVotesSumNode: function() { return _votesSumNode; }, getQuestion: function() { return _question; }, hideChoicesWithoutSelected: function() { var carea = _rootNode.querySelector('.choices-area'); var cs = (carea == null ? [] : carea.childNodes); for (var i = 0, len = cs.length; i < len; ++i) { var c = cs[i]; if (c.nodeType !== 1) { continue; // not a element node } var cls = c.getAttribute('class'); if (cls == null || cls.match(/choiced/) == null) { var st = c.getAttribute('style'); st = (st == null ? '' : st); c.setAttribute('style', st + ' display: none;'); } } }, buildDomTo: function(dstnode) { dstnode.innerHTML = (function() {/*
*/}).toString().match(/\/\*([^]*)\*\//)[1]; return dstnode; }, buildAdTo: function(dstnode, params) { if (!params.enableAd) { return dstnode; } /* PR */ var pr = document.createElement('span'); pr.textContent = params.adPrPrefix; pr.setAttribute('class', 'pr'); dstnode.appendChild(pr); /* 広告の構築先ノード */ var root = document.createElement(params.adRootType); var id = params.adRootIdPrefix + (_uniqueNumber+1); root.setAttribute('id', id); dstnode.appendChild(root); /* 広告のスクリプトは構築先ノードの後に追加する */ var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.textContent = params.adSpotCode; dstnode.appendChild(script); script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.src = params.adSrc; dstnode.appendChild(script); return dstnode; }, buildThanksVoteArea: function(rn, params) { var linknd = rn.querySelector('.thanks-vote .link'); linknd.href = params.linkThanksVoteUrl; linknd.textContent = params.linkThanksVoteName; }, /** * @param[in] params { * root: Building root node * uniqueNumber: Number of this chart (require unique) * questionText: Question text * choices: Choice list * selectedChoice: Selected choice * messageVotesSum: Text of votes-sum node * messageVotesSumAfter: Text of votes-sum node at after position * voteButtonValue: Value of vote-button node * messageChart: Message of chart (before flip) * linkHomeUrl: URL of link home * linkHomeName: Name of link home * linkThanksVoteUrl: URL of thanks vote * linkThanksVoteName: Name of thanks vote * adRootType: type of node of AD * adRootIdPrefix: id prefix of root node of AD * adSpotCode: text content of AD's script * adSrc: src of attribute in AD's script * adPrPrefix: Name of prefix of AD (like a "[PR]") * enableAd: Enable AD to true. Disable AD to false or undefined * } * */ build: function(params) { var self = this; /* Utils */ var extract = function(params, key) { var param = params[key]; if (param == null) { WS.error('Not found param by "' + key + '"'); } return param; }; var set = function(par, query, params, key, callback) { var node = par.querySelector(query); if (node == null) { WS.error('Not found node by "' + query + '"'); } var param = params[key]; if (param == null) { WS.error('Not found param by "' + key + '"'); } if (node && param) { callback(node, param); return true; } else { return false; } }; /* Init variables */ _rootNode = extract(params,'root'); if (_rootNode == null) { return false; } _uniqueNumber = extract(params, 'uniqueNumber'); if (_uniqueNumber == null) { return false; } /* Build DOM */ self.buildDomTo(_rootNode); /* Ad */ self.buildAdTo(_rootNode.querySelector('.ad-area'), params); self.buildThanksVoteArea(_rootNode, params); /* Settting DOM */ set(_rootNode, '.title', params, 'questionText', function(node, param) { _question.setText(param); node.textContent = param; }); set(_rootNode, '.link-home-area a', params, 'linkHomeUrl', function(node, param) { node.setAttribute('href', param); }); set(_rootNode, '.link-home-area a', params, 'linkHomeName', function(node, param) { node.textContent = param; }); set(_rootNode, '.votes-sum', params, 'messageVotesSum', function(node, param) { node.textContent = param; }); set(_rootNode, '.vote-button', params, 'voteButtonValue', function(node, param) { node.disabled = true; node.value = param; }); set(_rootNode, '.chart', params, 'messageChart', function(node, param) { node.className += ' message'; node.textContent = param; }); /* Choices */ var votesSum = 0; var choicesArea = _rootNode.querySelector('.choices-area'); if (choicesArea == null) { WS.error('Not found choices-area element in root node'); return false; } var choices = extract(params, 'choices'); if (choices == null) { return false; } var selc = params.selectedChoice; for (var i = 0, len = choices.length; i < len; ++i) { var choice = choices[i]; var ctext = extract(choice, 'text'); if (ctext == null) { continue; } var cvotes = extract(choice, 'votes'); if (cvotes == null) { continue; } var cid = extract(choice, 'id'); if (cid == null) { continue; } /* AmCharts */ _question.addChoice(new WS.Choice({ text: ctext, votes: cvotes, })); votesSum += parseInt(cvotes); /* Choice list */ var li = document.createElement('li'); var input = document.createElement('input'); var label = document.createElement('label'); li.appendChild(input); li.appendChild(label); input.setAttribute('type', 'radio'); input.setAttribute('name', 'choice' + _uniqueNumber); input.setAttribute('value', cid); if (selc && selc.id == cid) { li.className += ' choiced'; input.checked = true; } label.textContent = ctext; var ev = (function() { var _rn = _rootNode; var _ul = choicesArea; var _li = li; var _input = input; return function(e) { var lis = _ul.querySelectorAll('li'); /* choiced を外す */ for (var i = 0, len = lis.length; i < len; ++i) { var li = lis[i]; var cls = li.getAttribute('class'); cls = (cls == null ? '' : cls.replace(/( )+choiced/, '')); li.setAttribute('class', cls); } /* クラス属性の更新 */ var cls = _li.getAttribute('class'); cls = (cls == null ? '' : cls); _li.setAttribute('class', cls + ' choiced'); /* radio */ _input.checked = true; /* ボタンの有効化 */ var vbtn = _rn.querySelector('.vote-button'); if (vbtn) { vbtn.disabled = false; } }; }()); li.addEventListener('click', ev); input.addEventListener('click', ev); label.addEventListener('click', ev); choicesArea.appendChild(li); } /* VotesSum */ set(_rootNode, '.votes-sum', params, 'messageVotesSumAfter', function(node, param) { _votesSumNode = document.createElement('span'); _votesSumNode.className = 'sum'; _votesSumNode.textContent = votesSum; node.appendChild(_votesSumNode); node.appendChild(document.createTextNode(param)); }); }, hide: function(name) { var nd = _rootNode.querySelector(name); if (nd == null) { WS.error('WS.Chart: Not found name "' + name + '"'); return; } var st = nd.getAttribute('style'); st = (st == null ? '' : st); nd.setAttribute('style', st + ' display: none;'); }, show: function(name) { var nd = _rootNode.querySelector(name); if (nd == null) { WS.error('WS.Chart: Not found name "' + name + '"'); return; } var st = nd.getAttribute('style'); nd.setAttribute('style', st.replace('display: none;', '')); }, }; }; /* Namespace of WebSurveyAPI */ if (typeof WSAPI === 'undefined') { var WSAPI = {}; } /* Constant variables */ WSAPI._NAME = 'WebSurveyAPI'; /* Name of API */ WSAPI._BASEURI = 'http://websurvey-charts.com/api/questions'; /* Question Base URI */ WSAPI._CLASSNAME = 'websurvey-chart'; /* Class name of root nodes for build */ WSAPI._CSRFTOKEN = 'NOTPROVIDED'; /* For CSRF in Django */ WSAPI._INIT_DELAY_MS = 1000; /* Resources */ WSAPI._messageVoteButton = '投票する'; WSAPI._messageVoteDisplay = '投票して結果を表示する'; WSAPI._messagePleaseChoice = '投票には選択肢の選択が必要です'; WSAPI._messageVotesSum = '合計'; WSAPI._messageVotesSumAfter = '票'; /* Variables */ WSAPI._rootNodes = null; /* 構築先ノード群 */ WSAPI._offsetArataAdId = 0; /* ARATAスクリプトで使うノードIDのオフセット */ WSAPI._enableArataAd = true; /* ARATAの広告を有効にするなら true */ /** * console.error()のラッパー * * @param[in] msg */ WSAPI.error = function(msg) { console.error(WSAPI._NAME + ': ' + msg); }; /** * console.log()のラッパー * * @param[in] {String} msg */ WSAPI.log = function(msg) { //console.log(WSAPI._NAME + ': ' + msg); }; /** * XMLHttpRequestを取得する * * @return {XMLHttpRequest} object */ WSAPI.getXHR = function() { if (window.XMLHttpRequest) { /* Firefox, Chrome, IE10... */ return new XMLHttpRequest(); } /* ブラウザが非対応 */ WSAPI.error('This browser does not support XMLHttpRequest.'); }; /** * AmChartsのラッパーWS.AmChartをtypeから作成する * 未対応のtypeであればエラー出力後、デフォルトのchartを作成する * * @param {String} type チャートのタイプ * * @return {Object} */ WSAPI.makeAmChartFromType = function(type) { var amChart = WS.makeAmChartFromType(type); return amChart; }; /** * Chartオブジェクト * * @param params { * 'root': {Object} 構築先ノード * 'uniqueNumber': {Integer} このChartの唯一のID * 'config': {Array} Chartの設定を格納した連想配列 * } */ WSAPI.Chart = function(params) { var _rootNode = params.root; /* 構築先ノード */ var _uniqueNumber = params.uniqueNumber; /* このオブジェクトに割り振られる唯一の番号(0オリジン) */ var _conf = params.config; /* 設定 */ var _json = null; /* 構築で使用されるJSON */ var _wsChart = null; /* WS.Chart */ var _votesSumNode = null; /* votesの合計を表示するノード */ return { /** * rootNode以下のDOMをすべてクリアする * */ clear: function() { while (_rootNode.hasChildNodes()) { _rootNode.removeChild(_rootNode.firstChild); } }, /** * DOMを構築する * このDOMに対して全ての構築が行われる * */ buildDom: function() { _wsChart = new WS.Chart(); /* @see chart.js */ _wsChart.build({ 'root': _rootNode, 'uniqueNumber': _uniqueNumber, 'questionText': _json['text'], 'choices': _json['choices'], 'selectedChoice': _json['selectedChoice'], 'messageVotesSum': WSAPI._messageVotesSum, 'messageVotesSumAfter': WSAPI._messageVotesSumAfter, 'voteButtonValue': WSAPI._messageVoteButton, 'messageChart': WSAPI._messageVoteDisplay, 'linkHomeUrl': 'http://websurvey-charts.com/', 'linkHomeName': 'WEBアンケート.COM', 'linkThanksVoteUrl': 'http://websurvey-charts.com/', 'linkThanksVoteName': 'Websurvey - ブログに貼れる、アンケート。-', 'adRootType': 'span', 'adRootIdPrefix': 'ARATA_AD_', 'adSpotCode': 'ARATA_adspotId = 767;', 'adSrc': 'https://ad.ad-arata.com/static/embed.js', 'adPrPrefix': '[PR]', 'enableAd': WSAPI._enableArataAd, }); _wsChart.hide('.chart-area'); _wsChart.hide('.votes-sum-area'); _wsChart.hide('.link-home-area'); _wsChart.hide('.thanks-vote-area'); _votesSumNode = _wsChart.getVotesSumNode(); }, /** * 構築したChartにイベントをアタッチする * */ attachEvents: function() { /* Alias */ var that = this; var rn = _rootNode; var qid = _json['id']; var ul = rn.querySelector('.choices-area'); var lis = ul.getElementsByTagName('li'); var radios = ul.querySelectorAll('li input'); /* vote-buttonにイベントを設定する */ var vtbttn = rn.querySelector('.vote-button'); if (vtbttn == null) { WSAPI.error('vote-button'); return; } vtbttn.onclick = (function() { var _rn = rn; var _qid = qid; var _cid = null; var _radios = radios; return function() { /* Find checked radio for Choice ID */ var checkedRadio = null; var index = 0; for (var i = 0, len = _radios.length; i < len; ++i) { var r = _radios[i]; if (r.checked) { checkedRadio = r; index = i; break; } } if (checkedRadio == null) { alert(WSAPI._messagePleaseChoice); return; // Not found } _cid = checkedRadio.value; /* Vote */ WSAPI.voteToChoice(_qid, _cid); _votesSumNode.textContent = parseInt(_votesSumNode.textContent) + 1; var wsQuestion = _wsChart.getQuestion(); var wsChoices = wsQuestion.getChoices(); wsChoices[index].incrementVotes(); /* Done */ that.flip(); }; }()); }, /** * 通信で得られたJSONからChartを構築する * * @param[in] {Array} json JSON */ buildFromJson: function(json) { /* jsonを更新 */ if (json == null) { WSAPI.error('JSON is null'); return; } _json = json; /* Build */ this.clear(); this.buildDom(); this.attachEvents(); /* 既投票、または投票可能期間を過ぎた質問であればflip */ if (this.isAlreadyVote() || this.isDead()) { this.flip(); } }, /** * ユーザーがアンケートに投票済みかどうかチェックする * * @return {Boolean} 投票済みであればtrue * @return {Boolean} でなければfalse */ isAlreadyVote: function() { var key = 'isAlreadyVote'; if (parseInt(_votesSumNode.textContent, 10) === 0) { return false; } if (!(key in _json)) { WSAPI.error('Not found key "' + key + '" in json'); return false; } return _json[key]; /* 値を返す */ }, /** * チャートが投票可能期間を過ぎていないかチェックする * * @return {Boolean} 投票可能期間を過ぎていればtrue * @return {Boolean} でなければfalse */ isDead: function() { var key = 'isDead'; if (!(key in _json)) { WSAPI.error('Not found key "' + key + '" in json'); return false; } return _json[key]; /* 値を返す */ }, /** * Chartをひっくり返す * */ flip: function() { /* チャートの構築 */ /* チャートエリアの不要なDOMを削除 */ var chartArea = _rootNode.querySelector('.chart-area'); if (chartArea == null) { WSAPI.error('Not found chart-area'); return; } while (chartArea.hasChildNodes()) { chartArea.removeChild(chartArea.firstChild); } /* 選択中の選択肢以外を削除 */ _wsChart.hideChoicesWithoutSelected(); /* 隠し要素の表示 */ _wsChart.show('.chart-area'); _wsChart.show('.votes-sum-area'); _wsChart.show('.link-home-area'); /* チャートエリアに AmChart を構築 */ var amChartParent = document.createElement('div'); amChartParent.setAttribute('class', 'chart'); chartArea.appendChild(amChartParent); var amChart = WSAPI.makeAmChartFromType(_conf.chart.type); amChart.setQuestion(_wsChart.getQuestion()); amChart.buildTo(amChartParent); /* Swap display vote and thanks area */ _wsChart.hide('.vote-area'); _wsChart.show('.thanks-vote-area'); }, }; }; /** * Choiceにvoteする * * @param[in] {Integer} qid Question ID * @param[in] {Integer} cid Choice ID */ WSAPI.voteToChoice = function(qid, cid) { var xhr = WSAPI.getXHR(); if (xhr == null) { WSAPI.error('XHR is null'); return; } var callReadyStateChange = function() { if (xhr.status === 404) { WSAPI.error('Not found choice id ' + cid); return; } if (xhr.readyState === 4 && xhr.status === 200) { return; } }; var callTimeout = function() { WSAPI.error('Timeout in vote'); }; var url = WSAPI._BASEURI + '/' + qid + '/choices/' + cid + '/'; xhr.onreadystatechange = callReadyStateChange; xhr.open('PUT', url, true); /* DjangoのCSRF対策に対応する。この設定はopenの後に行うこと(Firefoxへの対応) */ xhr.setRequestHeader('X-CSRFToken', WSAPI._CSRFTOKEN); xhr.send(null); }; /** * RootNodeからConfigを取り出す * * @param[in] {Object} rn root node * * @return {Array} JSON */ WSAPI.getConfigFromRootNode = function(rn) { if (rn.dataset.source == null) { WSAPI.error('Not found source in dataset'); return null; } var js = null; if (rn.dataset.decode == 'true') { js = WS.hexStringToString(rn.dataset.source); } else { js = rn.dataset.source; } return JSON.parse(js); }; /** * HTMLのConfigからRoot NodeにQuestionを読み込む * * @param [in/out] {Object} rn root node * @param [in] {Integer} index number of index of root node */ WSAPI.loadRootNodeFromHtml = function(rn, index) { /* RootNodeから設定を取り出す */ var conf = WSAPI.getConfigFromRootNode(rn); if (conf == null) { WSAPI.error('Failed to get config from root node'); return; } /* 設定からQuestionのIDを取得 */ var qid = conf.question.id; if (qid == null) { WSAPI.error('Not found question id in root node'); return; } var xhr = WSAPI.getXHR(); if (xhr == null) { WSAPI.error('XHR is null'); return; } /* 非同期通信用のコールバック */ var callReadyStateChange = function() { if (xhr.status === 404) { WSAPI.error('Not found question by id ' + qid); return; } if (xhr.readyState === 4 && xhr.status === 200) { var text = xhr.responseText; if (text == null || text.length === 0) { WSAPI.error('Invalid response by question id ' + qid); return; } /* 読み込んだJSONをもとに構築開始 */ var chart = new WSAPI.Chart({ 'root': rn, 'uniqueNumber': WSAPI._offsetArataAdId + index, 'config': conf, }); chart.buildFromJson(JSON.parse(text)); return; } }; var callTimeout = function() { WSAPI.error('Timeout in load'); }; /* 通信を開始 */ var url = WSAPI._BASEURI + '/' + qid + '/'; xhr.onreadystatechange = callReadyStateChange; xhr.open('GET', url, true); xhr.send(null); }; /** * ドキュメントからARATAスクリプトで使用されるノードを全て走査し、 * 最後に見つけたノードのID番号を返す。 * * @param[in] {Integer} defofsid デフォルトのID番号 * * @return {Integer} 成功したら最終ノードのID番号 * @reutrn {Integer} 失敗したら defofsid (0 オリジン) */ WSAPI.getOffsetArataAdId = function(defofsid) { defofsid = (defofsid == null ? 0 : defofsid); var arataNodes = document.body.querySelectorAll('span'); var ofsid = defofsid; for (var i = 0, len = arataNodes.length; i < len; ++i) { var nd = arataNodes[i]; var id = nd.getAttribute('id'); if (id == null) { continue; } if (id.match(/ARATA_AD_/)) { var nid = parseInt(id.replace('ARATA_AD_', ''), 10); if (isNaN(nid)) { continue; } ofsid = nid; } } return ofsid; }; /** * API entry point * */ WSAPI.init = function() { try { WSAPI.log('Init...'); /* ARATA用のノードIDのオフセットを更新 */ var defofsid = 0; WSAPI._offsetArataAdId = WSAPI.getOffsetArataAdId(defofsid); /* オフセットが更新されていたら ARATA の広告を無効化 */ if (WSAPI._offsetArataAdId !== defofsid) { WSAPI._enableArataAd = false; } /* 表示先のルートノードを取得 */ WSAPI._rootNodes = document.getElementsByClassName(WSAPI._CLASSNAME); if (WSAPI._rootNodes == null) { WSAPI.error('Invalid class name "' + WSAPI._CLASSNAME + '"'); return; } /* すべてのルートノードに読み込み */ for (var i = 0, len = WSAPI._rootNodes.length; i < len; ++i) { var rn = WSAPI._rootNodes[i]; WSAPI.loadRootNodeFromHtml(rn, i); } /* CSSの登録 */ style = document.createElement('style'); style.setAttribute('type', 'text/css'); document.getElementsByTagName('head').item(0).appendChild(style); style.innerHTML += (function() {/* .websurvey-chart * { font-family: Verdana; } .websurvey-chart a { text-decoration: none; } .websurvey-chart > .title-area { text-align: center; border-bottom: 1px solid lightgray; padding: 0.5em 0 0.5em; } .websurvey-chart > .title-area > .title { font-weight: bold; font-size: 140%; color: gray; } .websurvey-chart > .chart-area { background-color: white; height: 400px; } .websurvey-chart > .chart-area > .message { line-height: 400px; text-align: center; font-size: medium; color: gray; } .websurvey-chart > .chart-area > .chart { width: auto; height: 400px; } .websurvey-chart .amcharts-chart-div a { left: 5px!important; top: 0px!important; font-size: 12px!important; } .websurvey-chart > .link-home-area { font-size: 11px; text-align: left; margin: 0; padding: 0; margin-left: 5px; margin-bottom: -4px; text-decoration: none!important; } .websurvey-chart .link { opacity: 0.7; color: black; } .websurvey-chart a { border-bottom: 0px; } .websurvey-chart > .votes-sum-area { border-bottom: 1px solid lightgray; margin-top: -20px; } .websurvey-chart > .votes-sum-area > .votes-sum { padding: 0.5em; font-size: 0.8em; } .websurvey-chart > .votes-sum-area > .votes-sum > .sum { margin-left: 0.1em; margin-right: 0.2em; font-weight: bold; font-size: 1.4em; } .websurvey-chart > .choices-area { padding: 0!important; margin: 0!important; list-style: none; } .websurvey-chart > .choices-area > li { padding: 0.6em!important; margin: 0!important; border-bottom: 1px solid lightgray; cursor: pointer; list-style: none!important; } .websurvey-chart > .choices-area > li > label { margin-left: 0.5em; font-weight: bold; color: #777; cursor: pointer; } .websurvey-chart > .choices-area > li > input { cursor: pointer; } .websurvey-chart > .choices-area > .choiced { background-color: #e4f0fc; } .websurvey-chart > .vote-area { margin-top: 0.5em; text-align: right; } .websurvey-chart > .thanks-vote-area { height: 45px; line-height: 45px; text-align: center; font-size: medium; } .websurvey-chart .thanks-vote .link { color: #085591; letter-spacing: 0.04em; } .websurvey-chart .thanks-vote .link:hover { color: #187595; letter-spacing: 0.04em; text-decoration: underline; } .websurvey-chart > .vote-area > .vote-button { padding: 0.4em 0.8em 0.4em 0.8em!important; font-size: large; background-color: #eee; border: 1px solid #888; border-radius: 4px; color: #222; } .websurvey-chart > .vote-area > .vote-button:disabled { color: #999; background-color: #eee; border: 1px solid #bbb; } .websurvey-chart > .ad-area .pr { opacity: 0.7; } .websurvey-chart > .ad-area { width: 100%; text-align: right; } .websurvey-chart > .ad-area span { margin-left: 5px; font-size: 13px; } .websurvey-chart > .ad-area * { color: #608DB1!important; } */}).toString().match(/\/\*([^]*)\*\//)[1]; WSAPI.log('Done to init'); } catch (e) { WSAPI.error(e); } }; /** * イベントに登録 * */ (function() { if (window.addEventListener) { window.addEventListener('load', WSAPI.init, false); } else if (window.attachEvent) { window.attachEvent('onload', WSAPI.init); } else { setTimeout(WSAPI.init, WSAPI._INIT_DELAY_MS); } }());