amcharts.rb 3.4.8.0 → 3.11.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/amcharts/helpers.js +12 -0
  3. data/app/assets/javascripts/amcharts/remote_json_provider.js +20 -3
  4. data/app/views/amcharts/_data_source.erb +7 -4
  5. data/app/views/amcharts/_immediate_data_load.erb +3 -0
  6. data/app/views/amcharts/chart_builder.erb +7 -2
  7. data/lib/amcharts/chart_builder.rb +8 -0
  8. data/lib/amcharts/version.rb +1 -1
  9. data/vendor/assets/javascripts/amcharts/amcharts.js +379 -362
  10. data/vendor/assets/javascripts/amcharts/amstock.js +97 -92
  11. data/vendor/assets/javascripts/amcharts/exporting/amexport.js +854 -666
  12. data/vendor/assets/javascripts/amcharts/funnel.js +17 -7
  13. data/vendor/assets/javascripts/amcharts/gauge.js +20 -19
  14. data/vendor/assets/javascripts/amcharts/lang/az.js +1 -0
  15. data/vendor/assets/javascripts/amcharts/lang/bg.js +1 -0
  16. data/vendor/assets/javascripts/amcharts/lang/de.js +13 -0
  17. data/vendor/assets/javascripts/amcharts/lang/es.js +1 -0
  18. data/vendor/assets/javascripts/amcharts/lang/fi.js +1 -0
  19. data/vendor/assets/javascripts/amcharts/lang/fo.js +1 -0
  20. data/vendor/assets/javascripts/amcharts/lang/fr.js +1 -0
  21. data/vendor/assets/javascripts/amcharts/lang/hr.js +1 -0
  22. data/vendor/assets/javascripts/amcharts/lang/hu.js +1 -0
  23. data/vendor/assets/javascripts/amcharts/lang/id.js +1 -0
  24. data/vendor/assets/javascripts/amcharts/lang/is.js +1 -0
  25. data/vendor/assets/javascripts/amcharts/lang/it.js +1 -0
  26. data/vendor/assets/javascripts/amcharts/lang/lt.js +1 -0
  27. data/vendor/assets/javascripts/amcharts/lang/lv.js +1 -0
  28. data/vendor/assets/javascripts/amcharts/lang/mk.js +1 -0
  29. data/vendor/assets/javascripts/amcharts/lang/mn.js +1 -0
  30. data/vendor/assets/javascripts/amcharts/lang/mt.js +1 -0
  31. data/vendor/assets/javascripts/amcharts/lang/nl.js +1 -0
  32. data/vendor/assets/javascripts/amcharts/lang/no.js +1 -0
  33. data/vendor/assets/javascripts/amcharts/lang/pl.js +1 -0
  34. data/vendor/assets/javascripts/amcharts/lang/pt.js +1 -0
  35. data/vendor/assets/javascripts/amcharts/lang/ro.js +1 -0
  36. data/vendor/assets/javascripts/amcharts/lang/ru.js +1 -0
  37. data/vendor/assets/javascripts/amcharts/lang/rw.js +1 -0
  38. data/vendor/assets/javascripts/amcharts/lang/sk.js +1 -0
  39. data/vendor/assets/javascripts/amcharts/lang/so.js +1 -0
  40. data/vendor/assets/javascripts/amcharts/lang/th.js +1 -0
  41. data/vendor/assets/javascripts/amcharts/lang/tr.js +1 -0
  42. data/vendor/assets/javascripts/amcharts/pie.js +10 -10
  43. data/vendor/assets/javascripts/amcharts/radar.js +6 -6
  44. data/vendor/assets/javascripts/amcharts/serial.js +57 -53
  45. data/vendor/assets/javascripts/amcharts/themes/black.js +205 -205
  46. data/vendor/assets/javascripts/amcharts/themes/chalk.js +216 -216
  47. data/vendor/assets/javascripts/amcharts/themes/dark.js +204 -204
  48. data/vendor/assets/javascripts/amcharts/themes/light.js +198 -198
  49. data/vendor/assets/javascripts/amcharts/themes/patterns.js +258 -258
  50. data/vendor/assets/javascripts/amcharts/xy.js +1 -1
  51. metadata +31 -2
@@ -1,93 +1,98 @@
1
- AmCharts.AmStockChart=AmCharts.Class({construct:function(a){this.type="stock";this.cname="AmStockChart";this.version="3.4.8";this.theme=a;this.createEvents("zoomed","rollOverStockEvent","rollOutStockEvent","clickStockEvent","panelRemoved","dataUpdated","init","rendered","drawn");this.colors="#FF6600 #FCD202 #B0DE09 #0D8ECF #2A0CD0 #CD0D74 #CC0000 #00CC00 #0000CC #DDDDDD #999999 #333333 #990000".split(" ");this.firstDayOfWeek=1;this.glueToTheEnd=!1;this.dataSetCounter=-1;this.zoomOutOnDataSetChange=
2
- !1;this.panels=[];this.dataSets=[];this.chartCursors=[];this.comparedDataSets=[];this.categoryAxesSettings=new AmCharts.CategoryAxesSettings(a);this.valueAxesSettings=new AmCharts.ValueAxesSettings(a);this.panelsSettings=new AmCharts.PanelsSettings(a);this.chartScrollbarSettings=new AmCharts.ChartScrollbarSettings(a);this.chartCursorSettings=new AmCharts.ChartCursorSettings(a);this.stockEventsSettings=new AmCharts.StockEventsSettings(a);this.legendSettings=new AmCharts.LegendSettings(a);this.balloon=
3
- new AmCharts.AmBalloon(a);this.previousEndDate=new Date(0);this.previousStartDate=new Date(0);this.dataSetCount=this.graphCount=0;this.chartCreated=!1;AmCharts.applyTheme(this,a,this.cname)},write:function(a){var b=this.theme,c=this.exportConfig;c&&AmCharts.AmExport&&!this.AmExport&&(this.AmExport=new AmCharts.AmExport(this,c));this.chartRendered=!1;a="object"!=typeof a?document.getElementById(a):a;this.zoomOutOnDataSetChange&&(this.endDate=this.startDate=void 0);this.categoryAxesSettings=AmCharts.processObject(this.categoryAxesSettings,
4
- AmCharts.CategoryAxesSettings,b);this.valueAxesSettings=AmCharts.processObject(this.valueAxesSettings,AmCharts.ValueAxesSettings,b);this.chartCursorSettings=AmCharts.processObject(this.chartCursorSettings,AmCharts.ChartCursorSettings,b);this.chartScrollbarSettings=AmCharts.processObject(this.chartScrollbarSettings,AmCharts.ChartScrollbarSettings,b);this.legendSettings=AmCharts.processObject(this.legendSettings,AmCharts.LegendSettings,b);this.panelsSettings=AmCharts.processObject(this.panelsSettings,
5
- AmCharts.PanelsSettings,b);this.stockEventsSettings=AmCharts.processObject(this.stockEventsSettings,AmCharts.StockEventsSettings,b);this.dataSetSelector&&(this.dataSetSelector=AmCharts.processObject(this.dataSetSelector,AmCharts.DataSetSelector,b));this.periodSelector&&(this.periodSelector=AmCharts.processObject(this.periodSelector,AmCharts.PeriodSelector,b));a.innerHTML="";this.div=a;this.measure();this.createLayout();this.updateDataSets();this.addDataSetSelector();this.addPeriodSelector();this.addPanels();
6
- this.updatePanels();this.addChartScrollbar();this.updateData();this.skipDefault||this.setDefaultPeriod()},setDefaultPeriod:function(a){var b=this.periodSelector;b&&(this.animationPlayed=!1,b.setDefaultPeriod(a))},validateSize:function(){var a,b=this.panels;this.measurePanels();for(a=0;a<b.length;a++)panel=b[a],panel.invalidateSize()},updateDataSets:function(){var a=this.mainDataSet,b=this.dataSets,c;for(c=0;c<b.length;c++){var d=b[c],d=AmCharts.processObject(d,AmCharts.DataSet);b[c]=d;d.id||(this.dataSetCount++,
7
- d.id="ds"+this.dataSetCount);void 0===d.color&&(d.color=this.colors.length-1>c?this.colors[c]:AmCharts.randomColor())}!a&&AmCharts.ifArray(b)&&(this.mainDataSet=this.dataSets[0])},updateEvents:function(a){AmCharts.ifArray(a.stockEvents)&&AmCharts.parseEvents(a,this.panels,this.stockEventsSettings,this.firstDayOfWeek,this,this.dataDateFormat)},getLastDate:function(a){var b=this.dataDateFormat;a=a instanceof Date?new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),
8
- a.getMilliseconds()):b?AmCharts.stringToDate(a,b):new Date(a);return new Date(AmCharts.changeDate(a,this.categoryAxesSettings.minPeriod,1,!0).getTime()-1)},getFirstDate:function(a){var b=this.dataDateFormat;a=a instanceof Date?new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()):b?AmCharts.stringToDate(a,b):new Date(a);return new Date(AmCharts.resetDateToMin(a,this.categoryAxesSettings.minPeriod,1,this.firstDayOfWeek))},updateData:function(){var a=
9
- this.mainDataSet;if(a){var b=this.categoryAxesSettings;-1==AmCharts.getItemIndex(b.minPeriod,b.groupToPeriods)&&b.groupToPeriods.unshift(b.minPeriod);var c=a.dataProvider;if(AmCharts.ifArray(c)){var d=a.categoryField;this.firstDate=this.getFirstDate(c[0][d]);this.lastDate=this.getLastDate(c[c.length-1][d]);this.periodSelector&&this.periodSelector.setRanges(this.firstDate,this.lastDate);a.dataParsed||(AmCharts.parseStockData(a,b.minPeriod,b.groupToPeriods,this.firstDayOfWeek,this.dataDateFormat),a.dataParsed=
10
- !0);this.updateComparingData();this.updateEvents(a)}else this.lastDate=this.firstDate=void 0;this.glueToTheEnd&&this.startDate&&this.endDate&&this.lastDate&&(AmCharts.getPeriodDuration(b.minPeriod),this.startDate=new Date(this.startDate.getTime()+(this.lastDate.getTime()-this.endDate.getTime())),this.endDate=this.lastDate,this.updateScrollbar=!0);this.updatePanelsWithNewData()}a={type:"dataUpdated",chart:this};this.fire(a.type,a)},updateComparingData:function(){var a=this.comparedDataSets,b=this.categoryAxesSettings,
11
- c;for(c=0;c<a.length;c++){var d=a[c];d.dataParsed||(AmCharts.parseStockData(d,b.minPeriod,b.groupToPeriods,this.firstDayOfWeek,this.dataDateFormat),d.dataParsed=!0);this.updateEvents(d)}},createLayout:function(){var a=this.div,b,c,d=document.createElement("div");d.style.position="relative";this.containerDiv=d;a.appendChild(d);if(a=this.periodSelector)b=a.position;if(a=this.dataSetSelector)c=a.position;if("left"==b||"left"==c)a=document.createElement("div"),a.style.cssFloat="left",a.style.styleFloat=
12
- "left",a.style.width="0px",a.style.position="absolute",d.appendChild(a),this.leftContainer=a;if("right"==b||"right"==c)b=document.createElement("div"),b.style.cssFloat="right",b.style.styleFloat="right",b.style.width="0px",d.appendChild(b),this.rightContainer=b;b=document.createElement("div");d.appendChild(b);this.centerContainer=b;d=document.createElement("div");b.appendChild(d);this.panelsContainer=d},addPanels:function(){this.measurePanels();for(var a=this.panels,b=0;b<a.length;b++){var c=a[b],
13
- c=AmCharts.processObject(c,AmCharts.StockPanel,this.theme);a[b]=c;this.addStockPanel(c,b)}this.panelsAdded=!0},measurePanels:function(){this.measure();var a=this.chartScrollbarSettings,b=this.divRealHeight,c=this.panelsSettings.panelSpacing;a.enabled&&(b-=a.height);(a=this.periodSelector)&&!a.vertical&&(a=a.offsetHeight,b-=a+c);(a=this.dataSetSelector)&&!a.vertical&&(a=a.offsetHeight,b-=a+c);a=this.panels;this.panelsContainer.style.height=b+"px";this.chartCursors=[];var d=0,e,h;for(e=0;e<a.length;e++){h=
14
- a[e];var f=h.percentHeight;isNaN(f)&&(f=100/a.length,h.percentHeight=f);d+=f}this.panelsHeight=Math.max(b-c*(a.length-1),0);for(e=0;e<a.length;e++)h=a[e],h.percentHeight=h.percentHeight/d*100,h.panelBox&&(h.panelBox.style.height=Math.round(h.percentHeight*this.panelsHeight/100)+"px")},addStockPanel:function(a,b){var c=this.panelsSettings,d=document.createElement("div");d.className="amChartsPanel";0<b&&!this.panels[b-1].showCategoryAxis&&(d.style.marginTop=c.panelSpacing+"px");a.panelBox=d;a.stockChart=
15
- this;a.id||(a.id="stockPanel"+b);a.pathToImages=this.pathToImages;d.style.height=Math.round(a.percentHeight*this.panelsHeight/100)+"px";d.style.width="100%";this.panelsContainer.appendChild(d);0<c.backgroundAlpha&&(d.style.backgroundColor=c.backgroundColor);if(d=a.stockLegend)d.container=void 0,d.title=a.title,d.marginLeft=c.marginLeft,d.marginRight=c.marginRight,d.verticalGap=3,d.position="top",AmCharts.copyProperties(this.legendSettings,d),a.addLegend(d,d.divId);a.zoomOutText="";a.removeChartCursor();
16
- this.addCursor(a)},enableCursors:function(a){var b=this.chartCursors,c;for(c=0;c<b.length;c++)b[c].enabled=a},updatePanels:function(){var a=this.panels,b;for(b=0;b<a.length;b++)this.updatePanel(a[b]);this.mainDataSet&&this.updateGraphs();this.currentPeriod=void 0},updatePanel:function(a){a.seriesIdField="amCategoryIdField";a.dataProvider=[];a.chartData=[];a.graphs=[];var b=a.categoryAxis,c=this.categoryAxesSettings;AmCharts.copyProperties(this.panelsSettings,a);AmCharts.copyProperties(c,b);b.parseDates=
17
- !0;a.zoomOutOnDataUpdate=!1;a.mouseWheelScrollEnabled=this.mouseWheelScrollEnabled;a.showCategoryAxis?"top"==b.position?a.marginTop=c.axisHeight:a.marginBottom=c.axisHeight:(a.categoryAxis.labelsEnabled=!1,a.chartCursor&&(a.chartCursor.categoryBalloonEnabled=!1));var c=a.valueAxes,d=c.length,e;0===d&&(e=new AmCharts.ValueAxis(this.theme),a.addValueAxis(e));b=new AmCharts.AmBalloon(this.theme);AmCharts.copyProperties(this.balloon,b);a.balloon=b;c=a.valueAxes;d=c.length;for(b=0;b<d;b++)e=c[b],AmCharts.copyProperties(this.valueAxesSettings,
18
- e);a.listenersAdded=!1;a.write(a.panelBox)},zoom:function(a,b){this.zoomChart(a,b)},zoomOut:function(){this.zoomChart(this.firstDate,this.lastDate)},updatePanelsWithNewData:function(){var a=this.mainDataSet,b=this.scrollbarChart;if(a){var c=this.panels;this.currentPeriod=void 0;var d;for(d=0;d<c.length;d++){var e=c[d];e.categoryField=a.categoryField;0===a.dataProvider.length&&(e.dataProvider=[]);e.scrollbarChart=b}b&&(c=this.categoryAxesSettings,d=c.minPeriod,b.categoryField=a.categoryField,0<a.dataProvider.length?
19
- (e=this.chartScrollbarSettings.usePeriod,b.dataProvider=e?a.agregatedDataProviders[e]:a.agregatedDataProviders[d]):b.dataProvider=[],e=b.categoryAxis,e.minPeriod=d,e.firstDayOfWeek=this.firstDayOfWeek,e.equalSpacing=c.equalSpacing,e.markPeriodChange=c.markPeriodChange,b.bbsetr=!0,b.validateData());0<a.dataProvider.length&&this.zoomChart(this.startDate,this.endDate)}this.panelDataInvalidated=!1},addChartScrollbar:function(){var a=this.chartScrollbarSettings,b=this.scrollbarChart;b&&(b.clear(),b.destroy());
20
- if(a.enabled){var c=this.panelsSettings,d=this.categoryAxesSettings,b=new AmCharts.AmSerialChart(this.theme);b.pathToImages=this.pathToImages;b.autoMargins=!1;this.scrollbarChart=b;b.id="scrollbarChart";b.scrollbarOnly=!0;b.zoomOutText="";b.panEventsEnabled=this.panelsSettings.panEventsEnabled;b.marginLeft=c.marginLeft;b.marginRight=c.marginRight;b.marginTop=0;b.marginBottom=0;var c=d.dateFormats,e=b.categoryAxis;e.boldPeriodBeginning=d.boldPeriodBeginning;c&&(e.dateFormats=d.dateFormats);e.labelsEnabled=
21
- !1;e.parseDates=!0;d=a.graph;if(AmCharts.isString(d)){c=this.panels;for(e=0;e<c.length;e++){var h=AmCharts.getObjById(c[e].stockGraphs,a.graph);h&&(d=h)}a.graph=d}var f;d&&(f=new AmCharts.AmGraph(this.theme),f.valueField=d.valueField,f.periodValue=d.periodValue,f.type=d.type,f.connect=d.connect,b.addGraph(f));d=new AmCharts.ChartScrollbar(this.theme);b.addChartScrollbar(d);AmCharts.copyProperties(a,d);d.scrollbarHeight=a.height;d.graph=f;this.listenTo(d,"zoomed",this.handleScrollbarZoom);f=document.createElement("div");
22
- f.style.height=a.height+"px";d=this.periodSelectorContainer;c=this.periodSelector;e=this.centerContainer;"bottom"==a.position?c?"bottom"==c.position?e.insertBefore(f,d):e.appendChild(f):e.appendChild(f):c?"top"==c.position?e.insertBefore(f,d.nextSibling):e.insertBefore(f,e.firstChild):e.insertBefore(f,e.firstChild);b.write(f)}},handleScrollbarZoom:function(a){if(this.skipScrollbarEvent)this.skipScrollbarEvent=!1;else{var b=a.endDate,c={};c.startDate=a.startDate;c.endDate=b;this.updateScrollbar=!1;
23
- this.handleZoom(c)}},addPeriodSelector:function(){var a=this.periodSelector;if(a){var b=this.categoryAxesSettings.minPeriod;a.minDuration=AmCharts.getPeriodDuration(b);a.minPeriod=b;a.chart=this;var c=this.dataSetSelector,d,b=this.dssContainer;c&&(d=c.position);var c=this.panelsSettings.panelSpacing,e=document.createElement("div");this.periodSelectorContainer=e;var h=this.leftContainer,f=this.rightContainer,g=this.centerContainer,k=this.panelsContainer,m=a.width+2*c+"px";switch(a.position){case "left":h.style.width=
24
- a.width+"px";h.appendChild(e);g.style.paddingLeft=m;break;case "right":g.style.marginRight=m;f.appendChild(e);f.style.width=a.width+"px";break;case "top":k.style.clear="both";g.insertBefore(e,k);e.style.paddingBottom=c+"px";e.style.overflow="hidden";break;case "bottom":e.style.marginTop=c+"px","bottom"==d?g.insertBefore(e,b):g.appendChild(e)}this.listenTo(a,"changed",this.handlePeriodSelectorZoom);a.write(e)}},addDataSetSelector:function(){var a=this.dataSetSelector;if(a){a.chart=this;a.dataProvider=
25
- this.dataSets;var b=a.position,c=this.panelsSettings.panelSpacing,d=document.createElement("div");this.dssContainer=d;var e=this.leftContainer,h=this.rightContainer,f=this.centerContainer,g=this.panelsContainer,c=a.width+2*c+"px";switch(b){case "left":e.style.width=a.width+"px";e.appendChild(d);f.style.paddingLeft=c;break;case "right":f.style.marginRight=c;h.appendChild(d);h.style.width=a.width+"px";break;case "top":g.style.clear="both";f.insertBefore(d,g);d.style.overflow="hidden";break;case "bottom":f.appendChild(d)}a.write(d)}},
26
- handlePeriodSelectorZoom:function(a){var b=this.scrollbarChart;b&&(b.updateScrollbar=!0);a.predefinedPeriod?(this.predefinedStart=a.startDate,this.predefinedEnd=a.endDate):this.predefinedEnd=this.predefinedStart=null;this.zoomChart(a.startDate,a.endDate)},addCursor:function(a){var b=this.chartCursorSettings;if(b.enabled){var c=new AmCharts.ChartCursor(this.theme);AmCharts.copyProperties(b,c);a.removeChartCursor();a.addChartCursor(c);this.listenTo(c,"changed",this.handleCursorChange);this.listenTo(c,
27
- "onHideCursor",this.hideChartCursor);this.listenTo(c,"zoomed",this.handleCursorZoom);this.chartCursors.push(c)}},hideChartCursor:function(){var a=this.chartCursors,b;for(b=0;b<a.length;b++){var c=a[b];c.hideCursor(!1);(c=c.chart)&&c.updateLegendValues()}},handleCursorZoom:function(a){var b=this.scrollbarChart;b&&(b.updateScrollbar=!0);var b={},c;if(this.categoryAxesSettings.equalSpacing){var d=this.mainDataSet.categoryField,e=this.mainDataSet.agregatedDataProviders[this.currentPeriod];c=new Date(e[a.start][d]);
28
- a=new Date(e[a.end][d])}else c=new Date(a.start),a=new Date(a.end);b.startDate=c;b.endDate=a;this.handleZoom(b)},handleZoom:function(a){this.zoomChart(a.startDate,a.endDate)},zoomChart:function(a,b){var c=new Date(a),d=this,e=d.firstDate,h=d.lastDate,f=d.currentPeriod,g=d.categoryAxesSettings,k=g.minPeriod,m=d.panelsSettings,p=d.periodSelector,x=d.panels,t=d.comparedGraphs,w=d.scrollbarChart,y=d.firstDayOfWeek;if(e&&h){a||(a=e);b||(b=h);if(f){var n=AmCharts.extractPeriod(f);a.getTime()==b.getTime()&&
29
- n!=k&&(b=AmCharts.changeDate(b,n.period,n.count),b.setTime(b.getTime()-1))}a.getTime()<e.getTime()&&(a=e);a.getTime()>h.getTime()&&(a=h);b.getTime()<e.getTime()&&(b=e);b.getTime()>h.getTime()&&(b=h);h=AmCharts.getItemIndex(k,g.groupToPeriods);e=f;f=d.choosePeriod(h,a,b);d.currentPeriod=f;h=AmCharts.extractPeriod(f);AmCharts.getPeriodDuration(h.period,h.count);AmCharts.getPeriodDuration(k);1>b.getTime()-a.getTime()&&(a=new Date(b.getTime()-1));k=new Date(a);for(g=0;g<x.length;g++){n=x[g];if(f!=e){var u;
30
- for(u=0;u<t.length;u++){var q=t[u].graph;q.dataProvider=q.dataSet.agregatedDataProviders[f]}u=n.categoryAxis;u.firstDayOfWeek=y;u.minPeriod=f;n.dataProvider=d.mainDataSet.agregatedDataProviders[f];if(u=n.chartCursor)u.categoryBalloonDateFormat=d.chartCursorSettings.categoryBalloonDateFormat(h.period),n.showCategoryAxis||(u.categoryBalloonEnabled=!1);n.startTime=k.getTime();n.endTime=b.getTime();n.validateData(!0)}u=!1;n.chartCursor&&n.chartCursor.panning&&(u=!0);u||(n.startTime=void 0,n.endTime=void 0,
31
- n.zoomToDates(c,b));0<m.startDuration&&d.animationPlayed?(n.startDuration=0,n.animateAgain()):0<m.startDuration&&n.animateAgain()}d.animationPlayed=!0;AmCharts.extractPeriod(f);c=new Date(b);w&&d.updateScrollbar&&(w.zoomToDates(a,c),d.skipScrollbarEvent=!0,setTimeout(function(){d.resetSkip.call(d)},100));d.updateScrollbar=!0;d.startDate=a;d.endDate=b;p&&p.zoom(a,b);if(a.getTime()!=d.previousStartDate.getTime()||b.getTime()!=d.previousEndDate.getTime())p={type:"zoomed"},p.startDate=a,p.endDate=b,p.chart=
32
- d,p.period=f,d.fire(p.type,p),d.previousStartDate=new Date(a),d.previousEndDate=new Date(b)}d.eventsHidden&&d.showHideEvents(!1);d.chartCreated||(f="init",d.fire(f,{type:f,chart:d}));d.chartRendered||(f="rendered",d.fire(f,{type:f,chart:d}),d.chartRendered=!0);f="drawn";d.fire(f,{type:f,chart:d});d.chartCreated=!0;d.animationPlayed=!0},resetSkip:function(){this.skipScrollbarEvent=!1},updateGraphs:function(){this.getSelections();if(0<this.dataSets.length){var a=this.panels;this.comparedGraphs=[];var b;
33
- for(b=0;b<a.length;b++){var c=a[b],d=c.valueAxes,e;for(e=0;e<d.length;e++){var h=d[e];h.prevLog&&(h.logarithmic=h.prevLog);h.recalculateToPercents="always"==c.recalculateToPercents?!0:!1}d=this.mainDataSet;e=this.comparedDataSets;h=c.stockGraphs;c.graphs=[];var f;for(f=0;f<h.length;f++){var g=h[f],g=AmCharts.processObject(g,AmCharts.StockGraph,this.theme);h[f]=g;if(!g.title||g.resetTitleOnDataSetChange)g.title=d.title,g.resetTitleOnDataSetChange=!0;g.useDataSetColors&&(g.lineColor=d.color,g.fillColors=
34
- void 0,g.bulletColor=void 0);c.addGraph(g);var k=!1;"always"==c.recalculateToPercents&&(k=!0);var m=c.stockLegend,p,x,t,w;m&&(m=AmCharts.processObject(m,AmCharts.StockLegend,this.theme),c.stockLegend=m,p=m.valueTextComparing,x=m.valueTextRegular,t=m.periodValueTextComparing,w=m.periodValueTextRegular);if(g.comparable){var y=e.length;0<y&&g.valueAxis.logarithmic&&"never"!=c.recalculateToPercents&&(g.valueAxis.logarithmic=!1,g.valueAxis.prevLog=!0);0<y&&"whenComparing"==c.recalculateToPercents&&(g.valueAxis.recalculateToPercents=
35
- !0);m&&g.valueAxis&&!0===g.valueAxis.recalculateToPercents&&(k=!0);var n;for(n=0;n<y;n++){var u=e[n],q=g.comparedGraphs[u.id];q||(q=new AmCharts.AmGraph(this.theme),q.id="comparedGraph"+n+"_"+u.id);q.periodValue=g.periodValue;q.dataSet=u;q.behindColumns=g.behindColumns;g.comparedGraphs[u.id]=q;q.seriesIdField="amCategoryIdField";q.connect=g.connect;var l=g.compareField;l||(l=g.valueField);var D=!1,A=u.fieldMappings,z;for(z=0;z<A.length;z++)A[z].toField==l&&(D=!0);if(D){q.valueField=l;q.title=u.title;
36
- q.lineColor=u.color;g.compareGraphType&&(q.type=g.compareGraphType);l=g.compareGraphLineThickness;isNaN(l)||(q.lineThickness=l);l=g.compareGraphDashLength;isNaN(l)||(q.dashLength=l);l=g.compareGraphLineAlpha;isNaN(l)||(q.lineAlpha=l);l=g.compareGraphCornerRadiusTop;isNaN(l)||(q.cornerRadiusTop=l);l=g.compareGraphCornerRadiusBottom;isNaN(l)||(q.cornerRadiusBottom=l);l=g.compareGraphBalloonColor;isNaN(l)||(q.balloonColor=l);if(l=g.compareGraphFillColors)q.fillColors=l;if(l=g.compareGraphNegativeFillColors)q.negativeFillColors=
37
- l;if(l=g.compareGraphFillAlphas)q.fillAlphas=l;if(l=g.compareGraphNegativeFillAlphas)q.negativeFillAlphas=l;if(l=g.compareGraphBullet)q.bullet=l;if(l=g.compareGraphNumberFormatter)q.numberFormatter=l;l=g.compareGraphPrecision;isNaN(l)||(q.precision=l);if(l=g.compareGraphBalloonText)q.balloonText=l;l=g.compareGraphBulletSize;isNaN(l)||(q.bulletSize=l);l=g.compareGraphBulletAlpha;isNaN(l)||(q.bulletAlpha=l);l=g.compareGraphBulletBorderAlpha;isNaN(l)||(q.bulletBorderAlpha=l);if(l=g.compareGraphBulletBorderColor)q.bulletBorderColor=
38
- l;l=g.compareGraphBulletBorderThickness;isNaN(l)||(q.bulletBorderThickness=l);q.visibleInLegend=g.compareGraphVisibleInLegend;q.balloonFunction=g.compareGraphBalloonFunction;q.hideBulletsCount=g.hideBulletsCount;q.valueAxis=g.valueAxis;m&&(k&&p?(q.legendValueText=p,q.legendPeriodValueText=t):(x&&(q.legendValueText=x),w&&(q.legendPeriodValueText=w)));c.showComparedOnTop?c.graphs.push(q):c.graphs.unshift(q);this.comparedGraphs.push({graph:q,dataSet:u})}}}m&&(k&&p?(g.legendValueText=p,g.legendPeriodValueText=
39
- t):(x&&(g.legendValueText=x),w&&(g.legendPeriodValueText=w)))}}}},choosePeriod:function(a,b,c){var d=this.categoryAxesSettings,e=d.groupToPeriods,h=e[a],e=e[a+1],f=AmCharts.extractPeriod(h),f=AmCharts.getPeriodDuration(f.period,f.count),g=b.getTime(),k=c.getTime(),d=d.maxSeries;return(k-g)/f>d&&0<d&&e?this.choosePeriod(a+1,b,c):h},handleCursorChange:function(a){var b=a.target,c=a.position;a=a.zooming;var d=this.chartCursors,e;for(e=0;e<d.length;e++){var h=d[e];h!=b&&c&&(h.isZooming(a),h.previousMousePosition=
40
- NaN,h.forceShow=!0,h.setPosition(c,!1))}},getSelections:function(){var a=[],b=this.dataSets,c;for(c=0;c<b.length;c++){var d=b[c];d.compared&&a.push(d)}this.comparedDataSets=a;b=this.panels;for(c=0;c<b.length;c++)d=b[c],"never"!=d.recalculateToPercents&&0<a.length?d.hideDrawingIcons(!0):d.drawingIconsEnabled&&d.hideDrawingIcons(!1)},addPanel:function(a){this.panels.push(a);AmCharts.removeChart(a);AmCharts.addChart(a)},addPanelAt:function(a,b){this.panels.splice(b,0,a);AmCharts.removeChart(a);AmCharts.addChart(a)},
41
- removePanel:function(a){var b=this.panels,c;for(c=b.length-1;0<=c;c--)if(b[c]==a){var d={type:"panelRemoved",panel:a,chart:this};this.fire(d.type,d);b.splice(c,1);a.destroy();a.clear()}},validateData:function(){this.resetDataParsed();this.updateDataSets();this.mainDataSet.compared=!1;this.updateGraphs();this.updateData();var a=this.dataSetSelector;a&&a.write(a.div)},resetDataParsed:function(){var a=this.dataSets,b;for(b=0;b<a.length;b++)a[b].dataParsed=!1},validateNow:function(){this.skipDefault=
42
- !0;this.chartRendered=!1;this.clear(!0);this.write(this.div)},hideStockEvents:function(){this.showHideEvents(!1);this.eventsHidden=!0},showStockEvents:function(){this.showHideEvents(!0);this.eventsHidden=!1},showHideEvents:function(a){var b=this.panels,c;for(c=0;c<b.length;c++){var d=b[c].graphs,e;for(e=0;e<d.length;e++){var h=d[e];!0===a?h.showBullets():h.hideBullets()}}},invalidateSize:function(){var a=this;clearTimeout(a.validateTO);var b=setTimeout(function(){a.validateNow()},5);a.validateTO=
43
- b},measure:function(){var a=this.div,b=a.offsetWidth,c=a.offsetHeight;a.clientHeight&&(b=a.clientWidth,c=a.clientHeight);this.divRealWidth=b;this.divRealHeight=c},clear:function(a){var b=this.panels,c;if(b)for(c=0;c<b.length;c++){var d=b[c];a||(d.cleanChart(),d.destroy());d.clear(a)}(b=this.scrollbarChart)&&b.clear();if(b=this.div)b.innerHTML="";a||(this.div=null,AmCharts.deleteObject(this))}});AmCharts.StockEvent=AmCharts.Class({construct:function(){}});AmCharts.DataSet=AmCharts.Class({construct:function(){this.cname="DataSet";this.fieldMappings=[];this.dataProvider=[];this.agregatedDataProviders=[];this.stockEvents=[];this.compared=!1;this.showInCompare=this.showInSelect=!0}});AmCharts.PeriodSelector=AmCharts.Class({construct:function(a){this.cname="PeriodSelector";this.theme=a;this.createEvents("changed");this.inputFieldsEnabled=!0;this.position="bottom";this.width=180;this.fromText="From: ";this.toText="to: ";this.periodsText="Zoom: ";this.periods=[];this.inputFieldWidth=100;this.dateFormat="DD-MM-YYYY";this.hideOutOfScopePeriods=!0;AmCharts.applyTheme(this,a,this.cname)},zoom:function(a,b){this.inputFieldsEnabled&&(this.startDateField.value=AmCharts.formatDate(a,this.dateFormat),
44
- this.endDateField.value=AmCharts.formatDate(b,this.dateFormat));this.markButtonAsSelected()},write:function(a){var b=this;a.className="amChartsPeriodSelector";var c=b.width,d=b.position;b.width=void 0;b.position=void 0;AmCharts.applyStyles(a.style,b);b.width=c;b.position=d;b.div=a;a.innerHTML="";c=b.theme;d=b.position;d="top"==d||"bottom"==d?!1:!0;b.vertical=d;var e=0,h=0;if(b.inputFieldsEnabled){var f=document.createElement("div");a.appendChild(f);var g=document.createTextNode(b.fromText);f.appendChild(g);
45
- d?AmCharts.addBr(f):(f.style.styleFloat="left",f.style.display="inline");var k=document.createElement("input");k.className="amChartsInputField";c&&AmCharts.applyStyles(k.style,c.PeriodInputField);k.style.textAlign="center";k.onblur=function(a){b.handleCalChange(a)};AmCharts.isNN&&k.addEventListener("keypress",function(a){b.handleCalendarChange.call(b,a)},!0);AmCharts.isIE&&k.attachEvent("onkeypress",function(a){b.handleCalendarChange.call(b,a)});f.appendChild(k);b.startDateField=k;if(d)g=b.width-
46
- 6+"px",AmCharts.addBr(f);else{var g=b.inputFieldWidth+"px",m=document.createTextNode(" ");f.appendChild(m)}k.style.width=g;k=document.createTextNode(b.toText);f.appendChild(k);d&&AmCharts.addBr(f);k=document.createElement("input");k.className="amChartsInputField";c&&AmCharts.applyStyles(k.style,c.PeriodInputField);k.style.textAlign="center";k.onblur=function(){b.handleCalChange()};AmCharts.isNN&&k.addEventListener("keypress",function(a){b.handleCalendarChange.call(b,a)},!0);AmCharts.isIE&&k.attachEvent("onkeypress",
47
- function(a){b.handleCalendarChange.call(b,a)});f.appendChild(k);b.endDateField=k;d?AmCharts.addBr(f):e=k.offsetHeight+2;g&&(k.style.width=g)}f=b.periods;if(AmCharts.ifArray(f)){g=document.createElement("div");d||(g.style.cssFloat="right",g.style.styleFloat="right",g.style.display="inline");a.appendChild(g);d&&AmCharts.addBr(g);a=document.createTextNode(b.periodsText);g.appendChild(a);b.periodContainer=g;var p;for(a=0;a<f.length;a++)k=f[a],p=document.createElement("input"),p.type="button",p.value=
48
- k.label,p.period=k.period,p.count=k.count,p.periodObj=k,p.className="amChartsButton",c&&AmCharts.applyStyles(p.style,c.PeriodButton),d&&(p.style.width=b.width-1+"px"),p.style.boxSizing="border-box",g.appendChild(p),b.addEventListeners(p),k.button=p;!d&&p&&(h=p.offsetHeight);b.offsetHeight=Math.max(e,h)}},addEventListeners:function(a){var b=this;AmCharts.isNN&&a.addEventListener("click",function(a){b.handlePeriodChange.call(b,a)},!0);AmCharts.isIE&&a.attachEvent("onclick",function(a){b.handlePeriodChange.call(b,
49
- a)})},getPeriodDates:function(){var a=this.periods,b;for(b=0;b<a.length;b++)this.selectPeriodButton(a[b],!0)},handleCalendarChange:function(a){13==a.keyCode&&this.handleCalChange(a)},handleCalChange:function(a){var b=this.dateFormat,c=AmCharts.stringToDate(this.startDateField.value,b),b=this.chart.getLastDate(AmCharts.stringToDate(this.endDateField.value,b));try{this.startDateField.blur(),this.endDateField.blur()}catch(d){}if(c&&b){var e={type:"changed"};e.startDate=c;e.endDate=b;e.chart=this.chart;
50
- e.event=a;this.fire(e.type,e)}},handlePeriodChange:function(a){this.selectPeriodButton((a.srcElement?a.srcElement:a.target).periodObj,!1,a)},setRanges:function(a,b){this.firstDate=a;this.lastDate=b;this.getPeriodDates()},selectPeriodButton:function(a,b,c){var d=a.button,e=d.count,h=d.period,f,g,k=this.firstDate,m=this.lastDate,p,x=this.theme;k&&m&&("MAX"==h?(f=k,g=m):"YTD"==h?(f=new Date,f.setMonth(0,1),f.setHours(0,0,0,0),0===e&&f.setDate(f.getDate()-1),g=this.lastDate):"YYYY"==h||"MM"==h?this.selectFromStart?
51
- (f=k,g=new Date(k),g.setMonth(g.getMonth()+e)):(f=new Date(m),AmCharts.changeDate(f,h,e,!1),f.setDate(f.getDate()-1),g=m):(p=AmCharts.getPeriodDuration(h,e),this.selectFromStart?(f=k,g=new Date(k.getTime()+p-1)):(f=new Date(m.getTime()-p+1),g=m)),a.startTime=f.getTime(),this.hideOutOfScopePeriods&&(b&&a.startTime<k.getTime()?d.style.display="none":d.style.display="inline"),f.getTime()>m.getTime()&&(p=AmCharts.getPeriodDuration("DD",1),f=new Date(m.getTime()-p)),f.getTime()<k.getTime()&&(f=k),"YTD"==
52
- h&&(a.startTime=f.getTime()),a.endTime=g.getTime(),b||(this.skipMark=!0,this.unselectButtons(),d.className="amChartsButtonSelected",x&&AmCharts.applyStyles(d.style,x.PeriodButtonSelected),a={type:"changed"},a.startDate=f,a.endDate=g,a.predefinedPeriod=h,a.chart=this.chart,a.count=e,a.event=c,this.fire(a.type,a)))},markButtonAsSelected:function(){if(!this.skipMark){var a=this.chart,b=this.periods,c=a.startDate.getTime(),a=a.endDate.getTime(),d=this.theme;this.unselectButtons();var e;for(e=b.length-
53
- 1;0<=e;e--){var h=b[e],f=h.button;h.startTime&&h.endTime&&c==h.startTime&&a==h.endTime&&(this.unselectButtons(),f.className="amChartsButtonSelected",d&&AmCharts.applyStyles(f.style,d.PeriodButtonSelected))}}this.skipMark=!1},unselectButtons:function(){var a=this.periods,b,c=this.theme;for(b=a.length-1;0<=b;b--){var d=a[b].button;d.className="amChartsButton";c&&AmCharts.applyStyles(d.style,c.PeriodButton)}},setDefaultPeriod:function(){var a=this.periods,b;for(b=0;b<a.length;b++){var c=a[b];c.selected&&
54
- this.selectPeriodButton(c)}}});AmCharts.StockGraph=AmCharts.Class({inherits:AmCharts.AmGraph,construct:function(a){AmCharts.StockGraph.base.construct.call(this,a);this.cname="StockGraph";this.useDataSetColors=!0;this.periodValue="Close";this.compareGraphType="line";this.compareGraphVisibleInLegend=!0;this.comparable=this.resetTitleOnDataSetChange=!1;this.comparedGraphs={};this.showEventsOnComparedGraphs=!1;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.StockPanel=AmCharts.Class({inherits:AmCharts.AmSerialChart,construct:function(a){AmCharts.StockPanel.base.construct.call(this,a);this.cname="StockPanel";this.theme=a;this.showCategoryAxis=this.showComparedOnTop=!0;this.recalculateToPercents="whenComparing";this.panelHeaderPaddingBottom=this.panelHeaderPaddingLeft=this.panelHeaderPaddingRight=this.panelHeaderPaddingTop=0;this.trendLineAlpha=1;this.trendLineColor="#00CC00";this.trendLineColorHover="#CC0000";this.trendLineThickness=2;this.trendLineDashLength=
55
- 0;this.stockGraphs=[];this.drawingIconsEnabled=!1;this.iconSize=18;this.autoMargins=this.allowTurningOff=this.eraseAll=this.erasingEnabled=this.drawingEnabled=!1;AmCharts.applyTheme(this,a,this.cname)},initChart:function(a){AmCharts.StockPanel.base.initChart.call(this,a);this.drawingIconsEnabled&&this.createDrawIcons();(a=this.chartCursor)&&this.listenTo(a,"draw",this.handleDraw)},addStockGraph:function(a){this.stockGraphs.push(a);return a},removeStockGraph:function(a){var b=this.stockGraphs,c;for(c=
56
- b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1)},createDrawIcons:function(){var a=this,b=a.iconSize,c=a.container,d=a.pathToImages,e=a.realWidth-2*b-1-a.marginRight,h=AmCharts.rect(c,b,b,"#000",0.005),f=AmCharts.rect(c,b,b,"#000",0.005);f.translate(b+1,0);var g=c.image(d+"pencilIcon.gif",0,0,b,b);a.pencilButton=g;f.setAttr("cursor","pointer");h.setAttr("cursor","pointer");h.mouseup(function(){a.handlePencilClick()});var k=c.image(d+"pencilIconH.gif",0,0,b,b);a.pencilButtonPushed=k;a.drawingEnabled||k.hide();
57
- var m=c.image(d+"eraserIcon.gif",b+1,0,b,b);a.eraserButton=m;f.mouseup(function(){a.handleEraserClick()});h.touchend&&(h.touchend(function(){a.handlePencilClick()}),f.touchend(function(){a.handleEraserClick()}));b=c.image(d+"eraserIconH.gif",b+1,0,b,b);a.eraserButtonPushed=b;a.erasingEnabled||b.hide();c=c.set([g,k,m,b,h,f]);c.translate(e,1);this.hideIcons&&c.hide()},handlePencilClick:function(){var a=!this.drawingEnabled;this.disableDrawing(!a);this.erasingEnabled=!1;this.eraserButtonPushed.hide();
58
- a?this.pencilButtonPushed.show():(this.pencilButtonPushed.hide(),this.setMouseCursor("auto"))},disableDrawing:function(a){this.drawingEnabled=!a;var b=this.chartCursor;this.stockChart.enableCursors(a);b&&b.enableDrawing(!a)},handleEraserClick:function(){this.disableDrawing(!0);this.pencilButtonPushed.hide();if(this.eraseAll){var a=this.trendLines,b;for(b=a.length-1;0<=b;b--){var c=a[b];c.isProtected||this.removeTrendLine(c)}this.validateNow()}else(this.erasingEnabled=a=!this.erasingEnabled)?(this.eraserButtonPushed.show(),
59
- this.setTrendColorHover(this.trendLineColorHover),this.setMouseCursor("auto")):(this.eraserButtonPushed.hide(),this.setTrendColorHover())},setTrendColorHover:function(a){var b=this.trendLines,c;for(c=b.length-1;0<=c;c--){var d=b[c];d.isProtected||(d.rollOverColor=a)}},handleDraw:function(a){var b=this.drawOnAxis;AmCharts.isString(b)&&(b=this.getValueAxisById(b));b||(b=this.valueAxes[0]);this.drawOnAxis=b;var c=this.categoryAxis,d=a.initialX,e=a.finalX,h=a.initialY;a=a.finalY;var f=new AmCharts.TrendLine(this.theme);
60
- f.initialDate=c.coordinateToDate(d);f.finalDate=c.coordinateToDate(e);f.initialValue=b.coordinateToValue(h);f.finalValue=b.coordinateToValue(a);f.lineAlpha=this.trendLineAlpha;f.lineColor=this.trendLineColor;f.lineThickness=this.trendLineThickness;f.dashLength=this.trendLineDashLength;f.valueAxis=b;f.categoryAxis=c;this.addTrendLine(f);this.listenTo(f,"click",this.handleTrendClick);this.validateNow()},hideDrawingIcons:function(a){(this.hideIcons=a)&&this.disableDrawing(a)},handleTrendClick:function(a){this.erasingEnabled&&
61
- (a=a.trendLine,this.eraseAll||a.isProtected||this.removeTrendLine(a),this.validateNow())},handleWheelReal:function(a,b){var c=this.scrollbarChart;if(!this.wheelBusy&&c){var d=1;b&&(d=-1);var c=c.chartScrollbar,e=this.categoryAxis.minDuration();0>a?(d=this.startTime+d*e,e=this.endTime+1*e):(d=this.startTime-d*e,e=this.endTime-1*e);d<this.firstTime&&(d=this.firstTime);e>this.lastTime&&(e=this.lastTime);d<e&&c.timeZoom(d,e,!0)}}});AmCharts.CategoryAxesSettings=AmCharts.Class({construct:function(a){this.cname="CategoryAxesSettings";this.minPeriod="DD";this.equalSpacing=!1;this.axisHeight=28;this.tickLength=this.axisAlpha=0;this.gridCount=10;this.maxSeries=150;this.groupToPeriods="ss 10ss 30ss mm 10mm 30mm hh DD WW MM YYYY".split(" ");this.markPeriodChange=this.autoGridCount=!0;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.ChartCursorSettings=AmCharts.Class({construct:function(a){this.cname="ChartCursorSettings";this.enabled=!0;this.bulletsEnabled=this.valueBalloonsEnabled=!1;this.categoryBalloonDateFormats=[{period:"YYYY",format:"YYYY"},{period:"MM",format:"MMM, YYYY"},{period:"WW",format:"MMM DD, YYYY"},{period:"DD",format:"MMM DD, YYYY"},{period:"hh",format:"JJ:NN"},{period:"mm",format:"JJ:NN"},{period:"ss",format:"JJ:NN:SS"},{period:"fff",format:"JJ:NN:SS"}];AmCharts.applyTheme(this,a,this.cname)},categoryBalloonDateFormat:function(a){var b=
62
- this.categoryBalloonDateFormats,c,d;for(d=0;d<b.length;d++)b[d].period==a&&(c=b[d].format);return c}});AmCharts.ChartScrollbarSettings=AmCharts.Class({construct:function(a){this.cname="ChartScrollbarSettings";this.height=40;this.enabled=!0;this.color="#FFFFFF";this.updateOnReleaseOnly=this.autoGridCount=!0;this.hideResizeGrips=!1;this.position="bottom";AmCharts.applyTheme(this,a,this.cname)}});AmCharts.LegendSettings=AmCharts.Class({construct:function(a){this.cname="LegendSettings";this.marginBottom=this.marginTop=0;this.usePositiveNegativeOnPercentsOnly=!0;this.positiveValueColor="#00CC00";this.negativeValueColor="#CC0000";this.autoMargins=this.equalWidths=this.textClickEnabled=!1;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.PanelsSettings=AmCharts.Class({construct:function(a){this.cname="PanelsSettings";this.marginBottom=this.marginTop=this.marginRight=this.marginLeft=0;this.backgroundColor="#FFFFFF";this.backgroundAlpha=0;this.panelSpacing=8;this.panEventsEnabled=!0;this.creditsPosition="top-right";AmCharts.applyTheme(this,a,this.cname)}});AmCharts.StockEventsSettings=AmCharts.Class({construct:function(a){this.cname="StockEventsSettings";this.type="sign";this.backgroundAlpha=1;this.backgroundColor="#DADADA";this.borderAlpha=1;this.borderColor="#888888";this.balloonColor=this.rollOverColor="#CC0000";AmCharts.applyTheme(this,a,this.cname)}});AmCharts.ValueAxesSettings=AmCharts.Class({construct:function(a){this.cname="ValueAxesSettings";this.tickLength=0;this.showFirstLabel=this.autoGridCount=this.inside=!0;this.showLastLabel=!1;this.axisAlpha=0;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.getItemIndex=function(a,b){var c=-1,d;for(d=0;d<b.length;d++)a==b[d]&&(c=d);return c};AmCharts.addBr=function(a){a.appendChild(document.createElement("br"))};AmCharts.applyStyles=function(a,b){if(b&&a)for(var c in a){var d=c,e=b[d];if(void 0!==e)try{a[d]=e}catch(h){}}};
63
- AmCharts.parseStockData=function(a,b,c,d,e){(new Date).getTime();var h={},f=a.dataProvider,g=a.categoryField;if(g){var k=AmCharts.getItemIndex(b,c),m=c.length,p,x=f.length,t,w={};for(p=k;p<m;p++)t=c[p],h[t]=[];var y={},n=a.fieldMappings,u=n.length;for(p=0;p<x;p++){var q=f[p],l=q[g],l=l instanceof Date?"fff"==b?AmCharts.useUTC?new Date(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()):new Date(l.getFullYear(),l.getMonth(),
64
- l.getDate(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()):new Date(l):e?AmCharts.stringToDate(l,e):new Date(l),D=l.getTime(),A={};for(t=0;t<u;t++)A[n[t].toField]=q[n[t].fromField];var z;for(z=k;z<m;z++){t=c[z];var s=AmCharts.extractPeriod(t),B=s.period,E=s.count,v,r;if(z==k||D>=w[t]||!w[t]){y[t]={};y[t].amCategoryIdField=String(AmCharts.resetDateToMin(l,B,E,d).getTime());var C;for(C=0;C<u;C++)s=n[C].toField,v=y[t],r=Number(A[s]),v[s+"Count"]=0,v[s+"Sum"]=0,isNaN(r)||(v[s+"Open"]=
65
- r,v[s+"Sum"]=r,v[s+"High"]=r,v[s+"Low"]=r,v[s+"Close"]=r,v[s+"Count"]=1,v[s+"Average"]=r);v.dataContext=q;h[t].push(y[t]);z>k&&(s=new Date(l),s=AmCharts.changeDate(s,B,E,!0),s=AmCharts.resetDateToMin(s,B,E,d),w[t]=s.getTime());if(z==k)for(var F in q)q.hasOwnProperty(F)&&(y[t][F]=q[F]);y[t][g]=new Date(l)}else for(B=0;B<u;B++)s=n[B].toField,v=y[t],p==x-1&&(v[g]=new Date(l)),r=Number(A[s]),isNaN(r)||(isNaN(v[s+"Low"])&&(v[s+"Low"]=r),r<v[s+"Low"]&&(v[s+"Low"]=r),isNaN(v[s+"High"])&&(v[s+"High"]=r),
66
- r>v[s+"High"]&&(v[s+"High"]=r),v[s+"Close"]=r,E=AmCharts.getDecimals(v[s+"Sum"]),C=AmCharts.getDecimals(r),v[s+"Sum"]+=r,v[s+"Sum"]=AmCharts.roundTo(v[s+"Sum"],Math.max(E,C)),v[s+"Count"]++,v[s+"Average"]=v[s+"Sum"]/v[s+"Count"])}}}a.agregatedDataProviders=h};
67
- AmCharts.parseEvents=function(a,b,c,d,e,h){var f=a.stockEvents,g=a.agregatedDataProviders,k=b.length,m,p,x,t,w,y,n,u;for(m=0;m<k;m++){y=b[m];w=y.graphs;x=w.length;var q;for(p=0;p<x;p++)t=w[p],t.customBulletField="amCustomBullet"+t.id+"_"+y.id,t.bulletConfigField="amCustomBulletConfig"+t.id+"_"+y.id;for(var l=0;l<f.length;l++)if(n=f[l],q=n.graph,AmCharts.isString(q)&&(q=AmCharts.getObjById(w,q)))n.graph=q}for(var D in g)if(g.hasOwnProperty(D)){q=g[D];var A=AmCharts.extractPeriod(D),z=q.length,s;for(s=
68
- 0;s<z;s++){var B=q[s];m=B[a.categoryField];u=m instanceof Date;h&&!u&&(m=AmCharts.stringToDate(m,h));var E=m.getTime();w=A.period;var l=A.count,v;v="fff"==w?m.getTime()+1:AmCharts.resetDateToMin(AmCharts.changeDate(new Date(m),A.period,A.count),w,l,d).getTime();for(m=0;m<k;m++)for(y=b[m],w=y.graphs,x=w.length,p=0;p<x;p++){t=w[p];var r={};r.eventDispatcher=e;r.eventObjects=[];r.letters=[];r.descriptions=[];r.shapes=[];r.backgroundColors=[];r.backgroundAlphas=[];r.borderColors=[];r.borderAlphas=[];
69
- r.colors=[];r.rollOverColors=[];r.showOnAxis=[];for(l=0;l<f.length;l++){n=f[l];u=n.date instanceof Date;h&&!u&&(n.date=AmCharts.stringToDate(n.date,h));u=n.date.getTime();var C=!1;n.graph&&(n.graph.showEventsOnComparedGraphs&&n.graph.comparedGraphs[a.id]&&(C=!0),(t==n.graph||C)&&u>=E&&u<v&&(r.eventObjects.push(n),r.letters.push(n.text),r.descriptions.push(n.description),n.type?r.shapes.push(n.type):r.shapes.push(c.type),void 0!==n.backgroundColor?r.backgroundColors.push(n.backgroundColor):r.backgroundColors.push(c.backgroundColor),
70
- isNaN(n.backgroundAlpha)?r.backgroundAlphas.push(c.backgroundAlpha):r.backgroundAlphas.push(n.backgroundAlpha),isNaN(n.borderAlpha)?r.borderAlphas.push(c.borderAlpha):r.borderAlphas.push(n.borderAlpha),void 0!==n.borderColor?r.borderColors.push(n.borderColor):r.borderColors.push(c.borderColor),void 0!==n.rollOverColor?r.rollOverColors.push(n.rollOverColor):r.rollOverColors.push(c.rollOverColor),r.colors.push(n.color),!n.panel&&n.graph&&(n.panel=n.graph.chart),r.showOnAxis.push(n.showOnAxis),r.date=
71
- new Date(n.date)));0<r.shapes.length&&(n="amCustomBullet"+t.id+"_"+y.id,u="amCustomBulletConfig"+t.id+"_"+y.id,B[n]=AmCharts.StackedBullet,B[u]=r)}}}}};AmCharts.StockLegend=AmCharts.Class({inherits:AmCharts.AmLegend,construct:function(a){AmCharts.StockLegend.base.construct.call(this,a);this.cname="StockLegend";this.valueTextComparing="[[percents.value]]%";this.valueTextRegular="[[value]]";AmCharts.applyTheme(this,a,this.cname)},drawLegend:function(){var a=this;AmCharts.StockLegend.base.drawLegend.call(a);var b=a.chart;if(b.allowTurningOff){var c=a.container,d=c.image(b.pathToImages+"xIcon.gif",b.realWidth-17,3,17,17),b=c.image(b.pathToImages+"xIconH.gif",
72
- b.realWidth-17,3,17,17);b.hide();a.xButtonHover=b;d.mouseup(function(){a.handleXClick()}).mouseover(function(){a.handleXOver()});b.mouseup(function(){a.handleXClick()}).mouseout(function(){a.handleXOut()})}},handleXOver:function(){this.xButtonHover.show()},handleXOut:function(){this.xButtonHover.hide()},handleXClick:function(){var a=this.chart,b=a.stockChart;b.removePanel(a);b.validateNow()}});AmCharts.DataSetSelector=AmCharts.Class({construct:function(a){this.cname="DataSetSelector";this.theme=a;this.createEvents("dataSetSelected","dataSetCompared","dataSetUncompared");this.position="left";this.selectText="Select:";this.comboBoxSelectText="Select...";this.compareText="Compare to:";this.width=180;this.dataProvider=[];this.listHeight=150;this.listCheckBoxSize=14;this.rollOverBackgroundColor="#b2e1ff";this.selectedBackgroundColor="#7fceff";AmCharts.applyTheme(this,a,this.cname)},write:function(a){var b=
73
- this,c,d=b.theme;a.className="amChartsDataSetSelector";var e=b.width;c=b.position;b.width=void 0;b.position=void 0;AmCharts.applyStyles(a.style,b);b.div=a;b.width=e;b.position=c;a.innerHTML="";var e=b.position,h;h="top"==e||"bottom"==e?!1:!0;b.vertical=h;var f;h&&(f=b.width+"px");var e=b.dataProvider,g,k;if(1<b.countDataSets("showInSelect")){c=document.createTextNode(b.selectText);a.appendChild(c);h&&AmCharts.addBr(a);var m=document.createElement("select");f&&(m.style.width=f);b.selectCB=m;d&&AmCharts.applyStyles(m.style,
74
- d.DataSetSelect);a.appendChild(m);AmCharts.isNN&&m.addEventListener("change",function(a){b.handleDataSetChange.call(b,a)},!0);AmCharts.isIE&&m.attachEvent("onchange",function(a){b.handleDataSetChange.call(b,a)});for(c=0;c<e.length;c++)if(g=e[c],!0===g.showInSelect){k=document.createElement("option");k.text=g.title;k.value=c;g==b.chart.mainDataSet&&(k.selected=!0);try{m.add(k,null)}catch(p){m.add(k)}}b.offsetHeight=m.offsetHeight}if(0<b.countDataSets("showInCompare")&&1<e.length)if(h?(AmCharts.addBr(a),
75
- AmCharts.addBr(a)):(c=document.createTextNode(" "),a.appendChild(c)),c=document.createTextNode(b.compareText),a.appendChild(c),k=b.listCheckBoxSize,h){AmCharts.addBr(a);f=document.createElement("div");a.appendChild(f);f.className="amChartsCompareList";d&&AmCharts.applyStyles(f.style,d.DataSetCompareList);f.style.overflow="auto";f.style.overflowX="hidden";f.style.width=b.width-2+"px";f.style.maxHeight=b.listHeight+"px";for(c=0;c<e.length;c++)g=e[c],!0===g.showInCompare&&g!=b.chart.mainDataSet&&(d=
76
- document.createElement("div"),d.style.padding="4px",d.style.position="relative",d.name="amCBContainer",d.dataSet=g,d.style.height=k+"px",g.compared&&(d.style.backgroundColor=b.selectedBackgroundColor),f.appendChild(d),h=document.createElement("div"),h.style.width=k+"px",h.style.height=k+"px",h.style.position="absolute",h.style.backgroundColor=g.color,d.appendChild(h),h=document.createElement("div"),h.style.width="100%",h.style.position="absolute",h.style.left=k+10+"px",d.appendChild(h),g=document.createTextNode(g.title),
77
- h.style.whiteSpace="nowrap",h.style.cursor="default",h.appendChild(g),b.addEventListeners(d));AmCharts.addBr(a);AmCharts.addBr(a)}else{d=document.createElement("select");b.compareCB=d;f&&(d.style.width=f);a.appendChild(d);AmCharts.isNN&&d.addEventListener("change",function(a){b.handleCBSelect.call(b,a)},!0);AmCharts.isIE&&d.attachEvent("onchange",function(a){b.handleCBSelect.call(b,a)});k=document.createElement("option");k.text=b.comboBoxSelectText;try{d.add(k,null)}catch(x){d.add(k)}for(c=0;c<e.length;c++)if(g=
78
- e[c],!0===g.showInCompare&&g!=b.chart.mainDataSet){k=document.createElement("option");k.text=g.title;k.value=c;g.compared&&(k.selected=!0);try{d.add(k,null)}catch(t){d.add(k)}}b.offsetHeight=d.offsetHeight}},addEventListeners:function(a){var b=this;AmCharts.isNN&&(a.addEventListener("mouseover",function(a){b.handleRollOver.call(b,a)},!0),a.addEventListener("mouseout",function(a){b.handleRollOut.call(b,a)},!0),a.addEventListener("click",function(a){b.handleClick.call(b,a)},!0));AmCharts.isIE&&(a.attachEvent("onmouseout",
79
- function(a){b.handleRollOut.call(b,a)}),a.attachEvent("onmouseover",function(a){b.handleRollOver.call(b,a)}),a.attachEvent("onclick",function(a){b.handleClick.call(b,a)}))},handleDataSetChange:function(){var a=this.selectCB,a=this.dataProvider[a.options[a.selectedIndex].value],b=this.chart;b.mainDataSet=a;b.zoomOutOnDataSetChange&&(b.startDate=void 0,b.endDate=void 0);b.validateData();a={type:"dataSetSelected",dataSet:a,chart:this.chart};this.fire(a.type,a)},handleRollOver:function(a){a=this.getRealDiv(a);
80
- a.dataSet.compared||(a.style.backgroundColor=this.rollOverBackgroundColor)},handleRollOut:function(a){a=this.getRealDiv(a);a.dataSet.compared||(a.style.removeProperty&&a.style.removeProperty("background-color"),a.style.removeAttribute&&a.style.removeAttribute("backgroundColor"))},handleCBSelect:function(a){var b=this.compareCB,c=this.dataProvider,d,e;for(d=0;d<c.length;d++)e=c[d],e.compared&&(a={type:"dataSetUncompared",dataSet:e}),e.compared=!1;c=b.selectedIndex;0<c&&(e=this.dataProvider[b.options[c].value],
81
- e.compared||(a={type:"dataSetCompared",dataSet:e}),e.compared=!0);b=this.chart;b.validateData();a.chart=b;this.fire(a.type,a)},handleClick:function(a){a=this.getRealDiv(a).dataSet;!0===a.compared?(a.compared=!1,a={type:"dataSetUncompared",dataSet:a}):(a.compared=!0,a={type:"dataSetCompared",dataSet:a});var b=this.chart;b.validateData();a.chart=b;this.fire(a.type,a)},getRealDiv:function(a){a||(a=window.event);a=a.currentTarget?a.currentTarget:a.srcElement;"amCBContainer"==a.parentNode.name&&(a=a.parentNode);
82
- return a},countDataSets:function(a){var b=this.dataProvider,c=0,d;for(d=0;d<b.length;d++)!0===b[d][a]&&c++;return c}});AmCharts.StackedBullet=AmCharts.Class({construct:function(){this.fontSize=11;this.stackDown=!1;this.mastHeight=8;this.shapes=[];this.backgroundColors=[];this.backgroundAlphas=[];this.borderAlphas=[];this.borderColors=[];this.colors=[];this.rollOverColors=[];this.showOnAxiss=[];this.textColor="#000000";this.nextY=0;this.size=16},parseConfig:function(){var a=this.bulletConfig;this.eventObjects=a.eventObjects;this.letters=a.letters;this.shapes=a.shapes;this.backgroundColors=a.backgroundColors;this.backgroundAlphas=
83
- a.backgroundAlphas;this.borderColors=a.borderColors;this.borderAlphas=a.borderAlphas;this.colors=a.colors;this.rollOverColors=a.rollOverColors;this.date=a.date;this.showOnAxiss=a.showOnAxis;this.axisCoordinate=a.minCoord},write:function(a){this.parseConfig();this.container=a;this.bullets=[];if(this.graph){var b=this.graph.fontSize;b&&(this.fontSize=b)}b=this.letters.length;(this.mastHeight+2*(this.fontSize/2+2))*b>this.availableSpace&&(this.stackDown=!0);this.set=a.set();a=0;var c;for(c=0;c<b;c++)this.shape=
84
- this.shapes[c],this.backgroundColor=this.backgroundColors[c],this.backgroundAlpha=this.backgroundAlphas[c],this.borderAlpha=this.borderAlphas[c],this.borderColor=this.borderColors[c],this.rollOverColor=this.rollOverColors[c],this.showOnAxis=this.showOnAxiss[c],this.color=this.colors[c],this.addLetter(this.letters[c],a,c),this.showOnAxis||a++},addLetter:function(a,b,c){var d=this.container;b=d.set();var e=-1,h=this.stackDown;this.showOnAxis&&(this.stackDown=this.graph.valueAxis.reversed?!0:!1);this.stackDown&&
85
- (e=1);var f=0,g=0,k=0,m,k=this.fontSize,p=this.mastHeight,x=this.shape,t=this.textColor;void 0!==this.color&&(t=this.color);void 0===a&&(a="");a=AmCharts.text(d,a,t,this.chart.fontFamily,this.fontSize);d=a.getBBox();this.labelWidth=t=d.width;this.labelHeight=d.height;d=0;switch(x){case "sign":m=this.drawSign(b);f=p+4+k/2;d=p+k+4;1==e&&(f-=4);break;case "flag":m=this.drawFlag(b);g=t/2+3;f=p+4+k/2;d=p+k+4;1==e&&(f-=4);break;case "pin":m=this.drawPin(b);f=6+k/2;d=k+8;break;case "triangleUp":m=this.drawTriangleUp(b);
86
- f=-k-1;d=k+4;e=-1;break;case "triangleDown":m=this.drawTriangleDown(b);f=k+1;d=k+4;e=-1;break;case "triangleLeft":m=this.drawTriangleLeft(b);g=k;d=k+4;e=-1;break;case "triangleRight":m=this.drawTriangleRight(b);g=-k;e=-1;d=k+4;break;case "arrowUp":m=this.drawArrowUp(b);a.hide();break;case "arrowDown":m=this.drawArrowDown(b);a.hide();d=k+4;break;case "text":e=-1;m=this.drawTextBackground(b,a);f=this.labelHeight+3;d=k+10;break;case "round":m=this.drawCircle(b)}this.bullets[c]=m;this.showOnAxis?(m=isNaN(this.nextAxisY)?
87
- this.axisCoordinate:this.nextY,k=f*e,this.nextAxisY=m+e*d):(m=this.nextY,k=f*e);a.translate(g,k);b.push(a);b.translate(0,m);this.addEventListeners(b,c);this.nextY=m+e*d;this.stackDown=h},addEventListeners:function(a,b){var c=this;a.click(function(){c.handleClick(b)}).mouseover(function(){c.handleMouseOver(b)}).touchend(function(){c.handleMouseOver(b,!0)}).mouseout(function(){c.handleMouseOut(b)})},drawPin:function(a){var b=-1;this.stackDown&&(b=1);var c=this.fontSize+4;return this.drawRealPolygon(a,
88
- [0,c/2,c/2,-c/2,-c/2,0],[0,b*c/4,b*(c+c/4),b*(c+c/4),b*c/4,0])},drawSign:function(a){var b=-1;this.stackDown&&(b=1);var c=this.mastHeight*b,d=this.fontSize/2+2,e=AmCharts.line(this.container,[0,0],[0,c],this.borderColor,this.borderAlpha,1),h=AmCharts.circle(this.container,d,this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);h.translate(0,c+d*b);a.push(e);a.push(h);this.set.push(a);return h},drawFlag:function(a){var b=-1;this.stackDown&&(b=1);var c=this.fontSize+4,d=this.labelWidth+
89
- 6,e=this.mastHeight,b=1==b?b*e:b*e-c,e=AmCharts.line(this.container,[0,0],[0,b],this.borderColor,this.borderAlpha,1),c=AmCharts.polygon(this.container,[0,d,d,0],[0,0,c,c],this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);c.translate(0,b);a.push(e);a.push(c);this.set.push(a);return c},drawTriangleUp:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,b/2,-b/2,0],[0,b,b,0])},drawArrowUp:function(a){var b=this.size,c=b/2,d=b/4;return this.drawRealPolygon(a,
90
- [0,c,d,d,-d,-d,-c,0],[0,c,c,b,b,c,c,0])},drawArrowDown:function(a){var b=this.size,c=b/2,d=b/4;return this.drawRealPolygon(a,[0,c,d,d,-d,-d,-c,0],[0,-c,-c,-b,-b,-c,-c,0])},drawTriangleDown:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,b/2,-b/2,0],[0,-b,-b,0])},drawTriangleLeft:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,b,b,0],[0,-b/2,b/2])},drawTriangleRight:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,-b,-b,0],[0,-b/2,b/2,0])},drawRealPolygon:function(a,
91
- b,c){b=AmCharts.polygon(this.container,b,c,this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);a.push(b);this.set.push(a);return b},drawCircle:function(a){shape=AmCharts.circle(this.container,this.fontSize/2,this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);a.push(shape);this.set.push(a);return shape},drawTextBackground:function(a,b){var c=b.getBBox(),d=-c.width/2-5,e=c.width/2+5,c=-c.height-12;return this.drawRealPolygon(a,[d,-5,0,5,e,e,d,d],
92
- [-5,-5,0,-5,-5,c,c,-5])},handleMouseOver:function(a,b){b||this.bullets[a].attr({fill:this.rollOverColors[a]});var c=this.eventObjects[a],d={type:"rollOverStockEvent",eventObject:c,graph:this.graph,date:this.date},e=this.bulletConfig.eventDispatcher;d.chart=e;e.fire(d.type,d);c.url&&this.bullets[a].setAttr("cursor","pointer");this.chart.showBalloon(AmCharts.fixNewLines(c.description),e.stockEventsSettings.balloonColor,!0)},handleClick:function(a){a=this.eventObjects[a];var b={type:"clickStockEvent",
1
+ AmCharts.AmStockChart=AmCharts.Class({construct:function(a){this.type="stock";this.cname="AmStockChart";this.version="3.11.1";this.theme=a;this.createEvents("zoomed","rollOverStockEvent","rollOutStockEvent","clickStockEvent","panelRemoved","dataUpdated","init","rendered","drawn");this.colors="#FF6600 #FCD202 #B0DE09 #0D8ECF #2A0CD0 #CD0D74 #CC0000 #00CC00 #0000CC #DDDDDD #999999 #333333 #990000".split(" ");this.firstDayOfWeek=1;this.glueToTheEnd=!1;this.dataSetCounter=-1;this.zoomOutOnDataSetChange=
2
+ !1;this.panels=[];this.dataSets=[];this.chartCursors=[];this.comparedDataSets=[];this.categoryAxesSettings=new AmCharts.CategoryAxesSettings(a);this.valueAxesSettings=new AmCharts.ValueAxesSettings(a);this.panelsSettings=new AmCharts.PanelsSettings(a);this.chartScrollbarSettings=new AmCharts.ChartScrollbarSettings(a);this.chartCursorSettings=new AmCharts.ChartCursorSettings(a);this.stockEventsSettings=new AmCharts.StockEventsSettings(a);this.legendSettings=new AmCharts.LegendSettings(a);this.balloon=
3
+ new AmCharts.AmBalloon(a);this.previousEndDate=new Date(0);this.previousStartDate=new Date(0);this.dataSetCount=this.graphCount=0;this.chartCreated=!1;this.extendToFullPeriod=!0;AmCharts.applyTheme(this,a,this.cname)},write:function(a){var b=this.theme;AmCharts.callInitHandler(this);AmCharts.applyLang(this.language,this);var c=this.exportConfig;c&&AmCharts.AmExport&&!this.AmExport&&(this.AmExport=new AmCharts.AmExport(this,c));this.amExport&&AmCharts.AmExport&&(this.AmExport=AmCharts.extend(this.amExport,
4
+ new AmCharts.AmExport(this),!0));this.AmExport&&this.AmExport.init();this.chartRendered=!1;a="object"!=typeof a?document.getElementById(a):a;this.zoomOutOnDataSetChange&&(this.endDate=this.startDate=void 0);this.categoryAxesSettings=AmCharts.processObject(this.categoryAxesSettings,AmCharts.CategoryAxesSettings,b);this.valueAxesSettings=AmCharts.processObject(this.valueAxesSettings,AmCharts.ValueAxesSettings,b);this.chartCursorSettings=AmCharts.processObject(this.chartCursorSettings,AmCharts.ChartCursorSettings,
5
+ b);this.chartScrollbarSettings=AmCharts.processObject(this.chartScrollbarSettings,AmCharts.ChartScrollbarSettings,b);this.legendSettings=AmCharts.processObject(this.legendSettings,AmCharts.LegendSettings,b);this.panelsSettings=AmCharts.processObject(this.panelsSettings,AmCharts.PanelsSettings,b);this.stockEventsSettings=AmCharts.processObject(this.stockEventsSettings,AmCharts.StockEventsSettings,b);this.dataSetSelector&&(this.dataSetSelector=AmCharts.processObject(this.dataSetSelector,AmCharts.DataSetSelector,
6
+ b));this.periodSelector&&(this.periodSelector=AmCharts.processObject(this.periodSelector,AmCharts.PeriodSelector,b));a.innerHTML="";this.div=a;this.measure();this.createLayout();this.updateDataSets();this.addDataSetSelector();this.addPeriodSelector();this.addPanels();this.updatePanels();this.addChartScrollbar();this.updateData();this.skipDefault||this.setDefaultPeriod()},setDefaultPeriod:function(a){var b=this.periodSelector;b&&(this.animationPlayed=!1,b.setDefaultPeriod(a))},validateSize:function(){var a,
7
+ b=this.panels;this.measurePanels();for(a=0;a<b.length;a++)panel=b[a],panel.invalidateSize()},updateDataSets:function(){var a=this.mainDataSet,b=this.dataSets,c;for(c=0;c<b.length;c++){var d=b[c],d=AmCharts.processObject(d,AmCharts.DataSet);b[c]=d;d.id||(this.dataSetCount++,d.id="ds"+this.dataSetCount);void 0===d.color&&(d.color=this.colors.length-1>c?this.colors[c]:AmCharts.randomColor())}!a&&AmCharts.ifArray(b)&&(this.mainDataSet=this.dataSets[0])},updateEvents:function(a){AmCharts.ifArray(a.stockEvents)&&
8
+ AmCharts.parseEvents(a,this.panels,this.stockEventsSettings,this.firstDayOfWeek,this,this.dataDateFormat)},getLastDate:function(a){var b=this.dataDateFormat;a=a instanceof Date?new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()):b?AmCharts.stringToDate(a,b):new Date(a);return new Date(AmCharts.changeDate(a,this.categoryAxesSettings.minPeriod,1,!0).getTime()-1)},getFirstDate:function(a){var b=this.dataDateFormat;a=a instanceof Date?new Date(a.getFullYear(),
9
+ a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()):b?AmCharts.stringToDate(a,b):new Date(a);return new Date(AmCharts.resetDateToMin(a,this.categoryAxesSettings.minPeriod,1,this.firstDayOfWeek))},updateData:function(){var a=this.mainDataSet;if(a){var b=this.categoryAxesSettings;-1==AmCharts.getItemIndex(b.minPeriod,b.groupToPeriods)&&b.groupToPeriods.unshift(b.minPeriod);var c=a.dataProvider;if(AmCharts.ifArray(c)){var d=a.categoryField;this.firstDate=this.getFirstDate(c[0][d]);
10
+ this.lastDate=this.getLastDate(c[c.length-1][d]);this.periodSelector&&this.periodSelector.setRanges(this.firstDate,this.lastDate);a.dataParsed||(AmCharts.parseStockData(a,b.minPeriod,b.groupToPeriods,this.firstDayOfWeek,this.dataDateFormat),a.dataParsed=!0);this.updateComparingData();this.updateEvents(a)}else this.lastDate=this.firstDate=void 0;this.glueToTheEnd&&this.startDate&&this.endDate&&this.lastDate&&(AmCharts.getPeriodDuration(b.minPeriod),this.startDate=new Date(this.startDate.getTime()+
11
+ (this.lastDate.getTime()-this.endDate.getTime())),this.endDate=this.lastDate,this.updateScrollbar=!0);this.updatePanelsWithNewData()}a={type:"dataUpdated",chart:this};this.fire(a.type,a)},updateComparingData:function(){var a=this.comparedDataSets,b=this.categoryAxesSettings,c;for(c=0;c<a.length;c++){var d=a[c];d.dataParsed||(AmCharts.parseStockData(d,b.minPeriod,b.groupToPeriods,this.firstDayOfWeek,this.dataDateFormat),d.dataParsed=!0);this.updateEvents(d)}},createLayout:function(){var a=this.div,
12
+ b,c,d=document.createElement("div");d.style.position="relative";this.containerDiv=d;a.appendChild(d);if(a=this.periodSelector)b=a.position;if(a=this.dataSetSelector)c=a.position;if("left"==b||"left"==c)a=document.createElement("div"),a.style.cssFloat="left",a.style.styleFloat="left",a.style.width="0px",a.style.position="absolute",d.appendChild(a),this.leftContainer=a;if("right"==b||"right"==c)b=document.createElement("div"),b.style.cssFloat="right",b.style.styleFloat="right",b.style.width="0px",d.appendChild(b),
13
+ this.rightContainer=b;b=document.createElement("div");d.appendChild(b);this.centerContainer=b;d=document.createElement("div");b.appendChild(d);this.panelsContainer=d},addPanels:function(){this.measurePanels();for(var a=this.panels,b=0;b<a.length;b++){var c=a[b],c=AmCharts.processObject(c,AmCharts.StockPanel,this.theme);a[b]=c;this.addStockPanel(c,b)}this.panelsAdded=!0},measurePanels:function(){this.measure();var a=this.chartScrollbarSettings,b=this.divRealHeight,c=this.panelsSettings.panelSpacing;
14
+ a.enabled&&(b-=a.height);(a=this.periodSelector)&&!a.vertical&&(a=a.offsetHeight,b-=a+c);(a=this.dataSetSelector)&&!a.vertical&&(a=a.offsetHeight,b-=a+c);a=this.panels;this.panelsContainer.style.height=b+"px";this.chartCursors=[];var d=0,e,k;for(e=0;e<a.length;e++){k=a[e];var f=k.percentHeight;isNaN(f)&&(f=100/a.length,k.percentHeight=f);d+=f}this.panelsHeight=Math.max(b-c*(a.length-1),0);for(e=0;e<a.length;e++)k=a[e],k.percentHeight=k.percentHeight/d*100,k.panelBox&&(k.panelBox.style.height=Math.round(k.percentHeight*
15
+ this.panelsHeight/100)+"px")},addStockPanel:function(a,b){var c=this.panelsSettings,d=document.createElement("div");d.className="amChartsPanel";0<b&&!this.panels[b-1].showCategoryAxis&&(d.style.marginTop=c.panelSpacing+"px");a.panelBox=d;a.stockChart=this;a.id||(a.id="stockPanel"+b);a.pathToImages=this.pathToImages;d.style.height=Math.round(a.percentHeight*this.panelsHeight/100)+"px";d.style.width="100%";this.panelsContainer.appendChild(d);0<c.backgroundAlpha&&(d.style.backgroundColor=c.backgroundColor);
16
+ if(d=a.stockLegend)d.container=void 0,d.title=a.title,d.marginLeft=c.marginLeft,d.marginRight=c.marginRight,d.verticalGap=3,d.position="top",AmCharts.copyProperties(this.legendSettings,d),a.addLegend(d,d.divId);a.zoomOutText="";this.addCursor(a)},enableCursors:function(a){var b=this.chartCursors,c;for(c=0;c<b.length;c++)b[c].enabled=a},updatePanels:function(){var a=this.panels,b;for(b=0;b<a.length;b++)this.updatePanel(a[b]);this.mainDataSet&&this.updateGraphs();this.currentPeriod=void 0},updatePanel:function(a){a.seriesIdField=
17
+ "amCategoryIdField";a.dataProvider=[];a.chartData=[];a.graphs=[];var b=a.categoryAxis,c=this.categoryAxesSettings;AmCharts.copyProperties(this.panelsSettings,a);AmCharts.copyProperties(c,b);b.parseDates=!0;a.zoomOutOnDataUpdate=!1;a.mouseWheelScrollEnabled=this.mouseWheelScrollEnabled;a.dataDateFormat=this.dataDateFormat;a.language=this.language;a.showCategoryAxis?"top"==b.position?a.marginTop=c.axisHeight:a.marginBottom=c.axisHeight:(a.categoryAxis.labelsEnabled=!1,a.chartCursor&&(a.chartCursor.categoryBalloonEnabled=
18
+ !1));var c=a.valueAxes,d=c.length,e;0===d&&(e=new AmCharts.ValueAxis(this.theme),a.addValueAxis(e));b=new AmCharts.AmBalloon(this.theme);AmCharts.copyProperties(this.balloon,b);a.balloon=b;c=a.valueAxes;d=c.length;for(b=0;b<d;b++)e=c[b],AmCharts.copyProperties(this.valueAxesSettings,e);a.listenersAdded=!1;a.write(a.panelBox)},zoom:function(a,b){this.zoomChart(a,b)},zoomOut:function(){this.zoomChart(this.firstDate,this.lastDate)},updatePanelsWithNewData:function(){var a=this.mainDataSet,b=this.scrollbarChart;
19
+ if(a){var c=this.panels;this.currentPeriod=void 0;var d;for(d=0;d<c.length;d++){var e=c[d];e.categoryField=a.categoryField;0===a.dataProvider.length&&(e.dataProvider=[]);e.scrollbarChart=b}b&&(c=this.categoryAxesSettings,d=c.minPeriod,b.categoryField=a.categoryField,0<a.dataProvider.length?(e=this.chartScrollbarSettings.usePeriod,b.dataProvider=e?a.agregatedDataProviders[e]:a.agregatedDataProviders[d]):b.dataProvider=[],e=b.categoryAxis,e.minPeriod=d,e.firstDayOfWeek=this.firstDayOfWeek,e.equalSpacing=
20
+ c.equalSpacing,e.axisAlpha=0,e.markPeriodChange=c.markPeriodChange,b.bbsetr=!0,b.validateData(),c=this.panelsSettings,b.maxSelectedTime=c.maxSelectedTime,b.minSelectedTime=c.minSelectedTime);0<a.dataProvider.length&&this.zoomChart(this.startDate,this.endDate)}this.panelDataInvalidated=!1},addChartScrollbar:function(){var a=this.chartScrollbarSettings,b=this.scrollbarChart;b&&(b.clear(),b.destroy());if(a.enabled){var c=this.panelsSettings,d=this.categoryAxesSettings,b=new AmCharts.AmSerialChart(this.theme);
21
+ b.language=this.language;b.pathToImages=this.pathToImages;b.autoMargins=!1;this.scrollbarChart=b;b.id="scrollbarChart";b.scrollbarOnly=!0;b.zoomOutText="";b.panEventsEnabled=this.panelsSettings.panEventsEnabled;b.marginLeft=c.marginLeft;b.marginRight=c.marginRight;b.marginTop=0;b.marginBottom=0;var c=d.dateFormats,e=b.categoryAxis;e.boldPeriodBeginning=d.boldPeriodBeginning;c&&(e.dateFormats=d.dateFormats);e.labelsEnabled=!1;e.parseDates=!0;d=a.graph;if(AmCharts.isString(d)){c=this.panels;for(e=0;e<
22
+ c.length;e++){var k=AmCharts.getObjById(c[e].stockGraphs,a.graph);k&&(d=k)}a.graph=d}var f;d&&(f=new AmCharts.AmGraph(this.theme),f.valueField=d.valueField,f.periodValue=d.periodValue,f.type=d.type,f.connect=d.connect,f.minDistance=a.minDistance,b.addGraph(f));d=new AmCharts.ChartScrollbar(this.theme);b.addChartScrollbar(d);AmCharts.copyProperties(a,d);d.scrollbarHeight=a.height;d.graph=f;this.listenTo(d,"zoomed",this.handleScrollbarZoom);f=document.createElement("div");f.style.height=a.height+"px";
23
+ d=this.periodSelectorContainer;c=this.periodSelector;e=this.centerContainer;"bottom"==a.position?c?"bottom"==c.position?e.insertBefore(f,d):e.appendChild(f):e.appendChild(f):c?"top"==c.position?e.insertBefore(f,d.nextSibling):e.insertBefore(f,e.firstChild):e.insertBefore(f,e.firstChild);b.write(f)}},handleScrollbarZoom:function(a){if(this.skipScrollbarEvent)this.skipScrollbarEvent=!1;else{var b=a.endDate,c={};c.startDate=a.startDate;c.endDate=b;this.updateScrollbar=!1;this.handleZoom(c)}},addPeriodSelector:function(){var a=
24
+ this.periodSelector;if(a){var b=this.categoryAxesSettings.minPeriod;a.minDuration=AmCharts.getPeriodDuration(b);a.minPeriod=b;a.chart=this;var c=this.dataSetSelector,d,b=this.dssContainer;c&&(d=c.position);var c=this.panelsSettings.panelSpacing,e=document.createElement("div");this.periodSelectorContainer=e;var k=this.leftContainer,f=this.rightContainer,h=this.centerContainer,g=this.panelsContainer,n=a.width+2*c+"px";switch(a.position){case "left":k.style.width=a.width+"px";k.appendChild(e);h.style.paddingLeft=
25
+ n;break;case "right":h.style.marginRight=n;f.appendChild(e);f.style.width=a.width+"px";break;case "top":g.style.clear="both";h.insertBefore(e,g);e.style.paddingBottom=c+"px";e.style.overflow="hidden";break;case "bottom":e.style.marginTop=c+"px","bottom"==d?h.insertBefore(e,b):h.appendChild(e)}this.listenTo(a,"changed",this.handlePeriodSelectorZoom);a.write(e)}},addDataSetSelector:function(){var a=this.dataSetSelector;if(a){a.chart=this;a.dataProvider=this.dataSets;var b=a.position,c=this.panelsSettings.panelSpacing,
26
+ d=document.createElement("div");this.dssContainer=d;var e=this.leftContainer,k=this.rightContainer,f=this.centerContainer,h=this.panelsContainer,c=a.width+2*c+"px";switch(b){case "left":e.style.width=a.width+"px";e.appendChild(d);f.style.paddingLeft=c;break;case "right":f.style.marginRight=c;k.appendChild(d);k.style.width=a.width+"px";break;case "top":h.style.clear="both";f.insertBefore(d,h);d.style.overflow="hidden";break;case "bottom":f.appendChild(d)}a.write(d)}},handlePeriodSelectorZoom:function(a){var b=
27
+ this.scrollbarChart;b&&(b.updateScrollbar=!0);a.predefinedPeriod?(this.predefinedStart=a.startDate,this.predefinedEnd=a.endDate):this.predefinedEnd=this.predefinedStart=null;this.zoomChart(a.startDate,a.endDate)},addCursor:function(a){var b=this.chartCursorSettings;if(b.enabled){var c=new AmCharts.ChartCursor(this.theme);AmCharts.copyProperties(b,c);a.chartCursor&&AmCharts.copyProperties(a.chartCursor,c);a.removeChartCursor();a.addChartCursor(c);this.listenTo(c,"changed",this.handleCursorChange);
28
+ this.listenTo(c,"onHideCursor",this.hideChartCursor);this.listenTo(c,"zoomed",this.handleCursorZoom);this.chartCursors.push(c)}},hideChartCursor:function(){var a=this.chartCursors,b;for(b=0;b<a.length;b++){var c=a[b];c.hideCursor(!1);(c=c.chart)&&c.updateLegendValues()}},handleCursorZoom:function(a){var b=this.scrollbarChart;b&&(b.updateScrollbar=!0);var b={},c;if(this.categoryAxesSettings.equalSpacing){var d=this.mainDataSet.categoryField,e=this.mainDataSet.agregatedDataProviders[this.currentPeriod];
29
+ c=new Date(e[a.start][d]);a=new Date(e[a.end][d])}else c=new Date(a.start),a=new Date(a.end);b.startDate=c;b.endDate=a;this.handleZoom(b)},handleZoom:function(a){this.zoomChart(a.startDate,a.endDate)},zoomChart:function(a,b){var c=new Date(a),d=this,e=d.firstDate,k=d.lastDate,f=d.currentPeriod,h=d.categoryAxesSettings,g=h.minPeriod,n=d.panelsSettings,m=d.periodSelector,t=d.panels,r=d.comparedGraphs,v=d.scrollbarChart,w=d.firstDayOfWeek;if(e&&k){a||(a=e);b||(b=k);if(f){var l=AmCharts.extractPeriod(f);
30
+ a.getTime()==b.getTime()&&l!=g&&(b=AmCharts.changeDate(b,l.period,l.count),b.setTime(b.getTime()-1))}a.getTime()<e.getTime()&&(a=e);a.getTime()>k.getTime()&&(a=k);b.getTime()<e.getTime()&&(b=e);b.getTime()>k.getTime()&&(b=k);l=AmCharts.getItemIndex(g,h.groupToPeriods);h=f;f=d.choosePeriod(l,a,b);d.currentPeriod=f;var l=AmCharts.extractPeriod(f),y=AmCharts.getPeriodDuration(l.period,l.count);AmCharts.getPeriodDuration(g);1>b.getTime()-a.getTime()&&(a=new Date(b.getTime()-1));g=AmCharts.newDate(a);
31
+ d.extendToFullPeriod&&(g.getTime()-e.getTime()<.1*y&&(g=AmCharts.resetDateToMin(a,l.period,l.count,w)),k.getTime()-b.getTime()<.1*y&&(b=AmCharts.resetDateToMin(k,l.period,l.count,w),b=AmCharts.changeDate(b,l.period,l.count,!0)));for(e=0;e<t.length;e++)k=t[e],k.chartCursor&&k.chartCursor.panning&&(g=c);for(e=0;e<t.length;e++){k=t[e];if(f!=h){for(c=0;c<r.length;c++)y=r[c].graph,y.dataProvider=y.dataSet.agregatedDataProviders[f];c=k.categoryAxis;c.firstDayOfWeek=w;c.minPeriod=f;k.dataProvider=d.mainDataSet.agregatedDataProviders[f];
32
+ if(c=k.chartCursor)c.categoryBalloonDateFormat=d.chartCursorSettings.categoryBalloonDateFormat(l.period),k.showCategoryAxis||(c.categoryBalloonEnabled=!1);k.startTime=g.getTime();k.endTime=b.getTime();k.validateData(!0)}c=!1;k.chartCursor&&k.chartCursor.panning&&(c=!0);c||(k.startTime=void 0,k.endTime=void 0,k.zoomToDates(g,b));0<n.startDuration&&d.animationPlayed&&!c?(k.startDuration=0,k.animateAgain()):0<n.startDuration&&!c&&k.animateAgain()}d.animationPlayed=!0;AmCharts.extractPeriod(f);n=new Date(b);
33
+ v&&d.updateScrollbar&&(v.zoomToDates(a,n),d.skipScrollbarEvent=!0,setTimeout(function(){d.resetSkip.call(d)},100));d.updateScrollbar=!0;d.startDate=a;d.endDate=b;m&&m.zoom(a,b);if(a.getTime()!=d.previousStartDate.getTime()||b.getTime()!=d.previousEndDate.getTime())m={type:"zoomed"},m.startDate=a,m.endDate=b,m.chart=d,m.period=f,d.fire(m.type,m),d.previousStartDate=new Date(a),d.previousEndDate=new Date(b)}d.eventsHidden&&d.showHideEvents(!1);d.chartCreated||(f="init",d.fire(f,{type:f,chart:d}));d.chartRendered||
34
+ (f="rendered",d.fire(f,{type:f,chart:d}),d.chartRendered=!0);f="drawn";d.fire(f,{type:f,chart:d});d.chartCreated=!0;d.animationPlayed=!0},resetSkip:function(){this.skipScrollbarEvent=!1},updateGraphs:function(){this.getSelections();if(0<this.dataSets.length){var a=this.panels;this.comparedGraphs=[];var b;for(b=0;b<a.length;b++){var c=a[b],d=c.valueAxes,e;for(e=0;e<d.length;e++){var k=d[e];k.prevLog&&(k.logarithmic=k.prevLog);k.recalculateToPercents="always"==c.recalculateToPercents?!0:!1}d=this.mainDataSet;
35
+ e=this.comparedDataSets;k=c.stockGraphs;c.graphs=[];var f;for(f=0;f<k.length;f++){var h=k[f],h=AmCharts.processObject(h,AmCharts.StockGraph,this.theme);k[f]=h;if(!h.title||h.resetTitleOnDataSetChange)h.title=d.title,h.resetTitleOnDataSetChange=!0;h.useDataSetColors&&(h.lineColor=d.color,h.fillColors=void 0,h.bulletColor=void 0);var g=!1,n=d.fieldMappings,m;for(m=0;m<n.length;m++){var t=n[m],r=h.valueField;r&&t.toField==r&&(g=!0);(r=h.openField)&&t.toField==r&&(g=!0);(r=h.closeField)&&t.toField==r&&
36
+ (g=!0);(r=h.lowField)&&t.toField==r&&(g=!0)}g&&c.addGraph(h);r=!1;"always"==c.recalculateToPercents&&(r=!0);var v=c.stockLegend,w,l,y,z;v&&(v=AmCharts.processObject(v,AmCharts.StockLegend,this.theme),c.stockLegend=v,w=v.valueTextComparing,l=v.valueTextRegular,y=v.periodValueTextComparing,z=v.periodValueTextRegular);if(h.comparable){var x=e.length;0<x&&h.valueAxis.logarithmic&&"never"!=c.recalculateToPercents&&(h.valueAxis.logarithmic=!1,h.valueAxis.prevLog=!0);0<x&&"whenComparing"==c.recalculateToPercents&&
37
+ (h.valueAxis.recalculateToPercents=!0);v&&h.valueAxis&&!0===h.valueAxis.recalculateToPercents&&(r=!0);var B;for(B=0;B<x;B++){var A=e[B],q=h.comparedGraphs[A.id];q||(q=new AmCharts.AmGraph(this.theme),q.id="comparedGraph"+B+"_"+f+A.id);q.periodValue=h.periodValue;q.dataSet=A;q.behindColumns=h.behindColumns;h.comparedGraphs[A.id]=q;q.seriesIdField="amCategoryIdField";q.connect=h.connect;var s=h.compareField;s||(s=h.valueField);g=!1;n=A.fieldMappings;m;for(m=0;m<n.length;m++)t=n[m],t.toField==s&&(g=
38
+ !0);if(g){q.valueField=s;q.title=A.title;q.lineColor=A.color;h.compareGraphType&&(q.type=h.compareGraphType);g=h.compareGraphLineThickness;isNaN(g)||(q.lineThickness=g);g=h.compareGraphDashLength;isNaN(g)||(q.dashLength=g);g=h.compareGraphLineAlpha;isNaN(g)||(q.lineAlpha=g);g=h.compareGraphCornerRadiusTop;isNaN(g)||(q.cornerRadiusTop=g);g=h.compareGraphCornerRadiusBottom;isNaN(g)||(q.cornerRadiusBottom=g);g=h.compareGraphBalloonColor;isNaN(g)||(q.balloonColor=g);g=h.compareGraphBulletColor;isNaN(g)||
39
+ (q.bulletColor=g);if(g=h.compareGraphFillColors)q.fillColors=g;if(g=h.compareGraphNegativeFillColors)q.negativeFillColors=g;if(g=h.compareGraphFillAlphas)q.fillAlphas=g;if(g=h.compareGraphNegativeFillAlphas)q.negativeFillAlphas=g;if(g=h.compareGraphBullet)q.bullet=g;if(g=h.compareGraphNumberFormatter)q.numberFormatter=g;g=h.compareGraphPrecision;isNaN(g)||(q.precision=g);if(g=h.compareGraphBalloonText)q.balloonText=g;g=h.compareGraphBulletSize;isNaN(g)||(q.bulletSize=g);g=h.compareGraphBulletAlpha;
40
+ isNaN(g)||(q.bulletAlpha=g);g=h.compareGraphBulletBorderAlpha;isNaN(g)||(q.bulletBorderAlpha=g);if(g=h.compareGraphBulletBorderColor)q.bulletBorderColor=g;g=h.compareGraphBulletBorderThickness;isNaN(g)||(q.bulletBorderThickness=g);q.visibleInLegend=h.compareGraphVisibleInLegend;q.balloonFunction=h.compareGraphBalloonFunction;q.hideBulletsCount=h.hideBulletsCount;q.valueAxis=h.valueAxis;v&&(r&&w?(q.legendValueText=w,q.legendPeriodValueText=y):(l&&(q.legendValueText=l),q.legendPeriodValueText=z));c.showComparedOnTop?
41
+ c.graphs.push(q):c.graphs.unshift(q);this.comparedGraphs.push({graph:q,dataSet:A})}}}v&&(r&&w?(h.legendValueText=w,h.legendPeriodValueText=y):(l&&(h.legendValueText=l),h.legendPeriodValueText=z))}}}},choosePeriod:function(a,b,c){var d=this.categoryAxesSettings,e=d.groupToPeriods,k=e[a],e=e[a+1],f=AmCharts.extractPeriod(k),f=AmCharts.getPeriodDuration(f.period,f.count),h=b.getTime(),g=c.getTime(),d=d.maxSeries;return(g-h)/f>d&&0<d&&e?this.choosePeriod(a+1,b,c):k},handleCursorChange:function(a){var b=
42
+ a.target,c=a.position,d=a.zooming;a=a.index;var e=this.chartCursors,k;for(k=0;k<e.length;k++){var f=e[k];f!=b&&c&&(f.isZooming(d),f.previousMousePosition=NaN,f.forceShow=!0,f.initialMouse=b.initialMouse,f.selectionPosX=b.selectionPosX,f.setPosition(c,!1,a))}},getSelections:function(){var a=[],b=this.dataSets,c;for(c=0;c<b.length;c++){var d=b[c];d.compared&&a.push(d)}this.comparedDataSets=a;b=this.panels;for(c=0;c<b.length;c++)d=b[c],"never"!=d.recalculateToPercents&&0<a.length?d.hideDrawingIcons(!0):
43
+ d.drawingIconsEnabled&&d.hideDrawingIcons(!1)},addPanel:function(a){this.panels.push(a);AmCharts.removeChart(a);AmCharts.addChart(a)},addPanelAt:function(a,b){this.panels.splice(b,0,a);AmCharts.removeChart(a);AmCharts.addChart(a)},removePanel:function(a){var b=this.panels,c;for(c=b.length-1;0<=c;c--)if(b[c]==a){var d={type:"panelRemoved",panel:a,chart:this};this.fire(d.type,d);b.splice(c,1);a.destroy();a.clear()}},validateData:function(){this.resetDataParsed();this.updateDataSets();this.mainDataSet.compared=
44
+ !1;this.updateGraphs();this.updateData();var a=this.dataSetSelector;a&&a.write(a.div)},resetDataParsed:function(){var a=this.dataSets,b;for(b=0;b<a.length;b++)a[b].dataParsed=!1},validateNow:function(){this.skipDefault=!0;this.chartRendered=!1;this.clear(!0);this.write(this.div)},hideStockEvents:function(){this.showHideEvents(!1);this.eventsHidden=!0},showStockEvents:function(){this.showHideEvents(!0);this.eventsHidden=!1},showHideEvents:function(a){var b=this.panels,c;for(c=0;c<b.length;c++){var d=
45
+ b[c].graphs,e;for(e=0;e<d.length;e++){var k=d[e];!0===a?k.showBullets():k.hideBullets()}}},invalidateSize:function(){var a=this;clearTimeout(a.validateTO);var b=setTimeout(function(){a.validateNow()},5);a.validateTO=b},measure:function(){var a=this.div,b=a.offsetWidth,c=a.offsetHeight;a.clientHeight&&(b=a.clientWidth,c=a.clientHeight);this.divRealWidth=b;this.divRealHeight=c},clear:function(a){var b=this.panels,c;if(b)for(c=0;c<b.length;c++){var d=b[c];a||(d.cleanChart(),d.destroy());d.clear(a)}(b=
46
+ this.scrollbarChart)&&b.clear();if(b=this.div)b.innerHTML="";a||(this.div=null,AmCharts.deleteObject(this))}});AmCharts.StockEvent=AmCharts.Class({construct:function(){}});AmCharts.DataSet=AmCharts.Class({construct:function(){this.cname="DataSet";this.fieldMappings=[];this.dataProvider=[];this.agregatedDataProviders=[];this.stockEvents=[];this.compared=!1;this.showInCompare=this.showInSelect=!0}});AmCharts.PeriodSelector=AmCharts.Class({construct:function(a){this.cname="PeriodSelector";this.theme=a;this.createEvents("changed");this.inputFieldsEnabled=!0;this.position="bottom";this.width=180;this.fromText="From: ";this.toText="to: ";this.periodsText="Zoom: ";this.periods=[];this.inputFieldWidth=100;this.dateFormat="DD-MM-YYYY";this.hideOutOfScopePeriods=!0;AmCharts.applyTheme(this,a,this.cname)},zoom:function(a,b){var c=this.chart;this.inputFieldsEnabled&&(this.startDateField.value=AmCharts.formatDate(a,
47
+ this.dateFormat,c),this.endDateField.value=AmCharts.formatDate(b,this.dateFormat,c));this.markButtonAsSelected()},write:function(a){var b=this;a.className="amChartsPeriodSelector";var c=b.width,d=b.position;b.width=void 0;b.position=void 0;AmCharts.applyStyles(a.style,b);b.width=c;b.position=d;b.div=a;a.innerHTML="";c=b.theme;d=b.position;d="top"==d||"bottom"==d?!1:!0;b.vertical=d;var e=0,k=0;if(b.inputFieldsEnabled){var f=document.createElement("div");a.appendChild(f);var h=document.createTextNode(AmCharts.lang.fromText||
48
+ b.fromText);f.appendChild(h);d?AmCharts.addBr(f):(f.style.styleFloat="left",f.style.display="inline");var g=document.createElement("input");g.className="amChartsInputField";c&&AmCharts.applyStyles(g.style,c.PeriodInputField);g.style.textAlign="center";g.onblur=function(a){b.handleCalChange(a)};AmCharts.isNN&&g.addEventListener("keypress",function(a){b.handleCalendarChange.call(b,a)},!0);AmCharts.isIE&&g.attachEvent("onkeypress",function(a){b.handleCalendarChange.call(b,a)});f.appendChild(g);b.startDateField=
49
+ g;if(d)h=b.width-6+"px",AmCharts.addBr(f);else{var h=b.inputFieldWidth+"px",n=document.createTextNode(" ");f.appendChild(n)}g.style.width=h;g=document.createTextNode(AmCharts.lang.toText||b.toText);f.appendChild(g);d&&AmCharts.addBr(f);g=document.createElement("input");g.className="amChartsInputField";c&&AmCharts.applyStyles(g.style,c.PeriodInputField);g.style.textAlign="center";g.onblur=function(){b.handleCalChange()};AmCharts.isNN&&g.addEventListener("keypress",function(a){b.handleCalendarChange.call(b,
50
+ a)},!0);AmCharts.isIE&&g.attachEvent("onkeypress",function(a){b.handleCalendarChange.call(b,a)});f.appendChild(g);b.endDateField=g;d?AmCharts.addBr(f):e=g.offsetHeight+2;h&&(g.style.width=h)}f=b.periods;if(AmCharts.ifArray(f)){h=document.createElement("div");d||(h.style.cssFloat="right",h.style.styleFloat="right",h.style.display="inline");a.appendChild(h);d&&AmCharts.addBr(h);a=document.createTextNode(AmCharts.lang.periodsText||b.periodsText);h.appendChild(a);b.periodContainer=h;var m;for(a=0;a<f.length;a++)g=
51
+ f[a],m=document.createElement("input"),m.type="button",m.value=g.label,m.period=g.period,m.count=g.count,m.periodObj=g,m.className="amChartsButton",c&&AmCharts.applyStyles(m.style,c.PeriodButton),d&&(m.style.width=b.width-1+"px"),m.style.boxSizing="border-box",h.appendChild(m),b.addEventListeners(m),g.button=m;!d&&m&&(k=m.offsetHeight);b.offsetHeight=Math.max(e,k)}},addEventListeners:function(a){var b=this;AmCharts.isNN&&a.addEventListener("click",function(a){b.handlePeriodChange.call(b,a)},!0);AmCharts.isIE&&
52
+ a.attachEvent("onclick",function(a){b.handlePeriodChange.call(b,a)})},getPeriodDates:function(){var a=this.periods,b;for(b=0;b<a.length;b++)this.selectPeriodButton(a[b],!0)},handleCalendarChange:function(a){13==a.keyCode&&this.handleCalChange(a)},handleCalChange:function(a){var b=this.dateFormat,c=AmCharts.stringToDate(this.startDateField.value,b),b=this.chart.getLastDate(AmCharts.stringToDate(this.endDateField.value,b));try{this.startDateField.blur(),this.endDateField.blur()}catch(d){}if(c&&b){var e=
53
+ {type:"changed"};e.startDate=c;e.endDate=b;e.chart=this.chart;e.event=a;this.fire(e.type,e)}},handlePeriodChange:function(a){this.selectPeriodButton((a.srcElement?a.srcElement:a.target).periodObj,!1,a)},setRanges:function(a,b){this.firstDate=a;this.lastDate=b;this.getPeriodDates()},selectPeriodButton:function(a,b,c){var d=a.button,e=d.count,k=d.period,f,h,g=this.firstDate,n=this.lastDate,m,t=this.theme;g&&n&&("MAX"==k?(f=g,h=n):"YTD"==k?(f=new Date,f.setMonth(0,1),f.setHours(0,0,0,0),0===e&&f.setDate(f.getDate()-
54
+ 1),h=this.lastDate):"YYYY"==k||"MM"==k?this.selectFromStart?(f=g,h=new Date(g),h.setMonth(h.getMonth()+e)):(f=new Date(n),AmCharts.changeDate(f,k,e,!1),f.setDate(f.getDate()-1),h=n):(m=AmCharts.getPeriodDuration(k,e),this.selectFromStart?(f=g,h=new Date(g.getTime()+m-1)):(f=new Date(n.getTime()-m+1),h=n)),a.startTime=f.getTime(),this.hideOutOfScopePeriods&&(b&&a.startTime<g.getTime()?d.style.display="none":d.style.display="inline"),f.getTime()>n.getTime()&&(m=AmCharts.getPeriodDuration("DD",1),f=
55
+ new Date(n.getTime()-m)),f.getTime()<g.getTime()&&(f=g),"YTD"==k&&(a.startTime=f.getTime()),a.endTime=h.getTime(),b||(this.skipMark=!0,this.unselectButtons(),d.className="amChartsButtonSelected",t&&AmCharts.applyStyles(d.style,t.PeriodButtonSelected),a={type:"changed"},a.startDate=f,a.endDate=h,a.predefinedPeriod=k,a.chart=this.chart,a.count=e,a.event=c,this.fire(a.type,a)))},markButtonAsSelected:function(){if(!this.skipMark){var a=this.chart,b=this.periods,c=a.startDate.getTime(),a=a.endDate.getTime(),
56
+ d=this.lastDate.getTime();a>d&&(a=d);d=this.theme;this.unselectButtons();var e;for(e=b.length-1;0<=e;e--){var k=b[e],f=k.button;k.startTime&&k.endTime&&c==k.startTime&&a==k.endTime&&(this.unselectButtons(),f.className="amChartsButtonSelected",d&&AmCharts.applyStyles(f.style,d.PeriodButtonSelected))}}this.skipMark=!1},unselectButtons:function(){var a=this.periods,b,c=this.theme;for(b=a.length-1;0<=b;b--){var d=a[b].button;d.className="amChartsButton";c&&AmCharts.applyStyles(d.style,c.PeriodButton)}},
57
+ setDefaultPeriod:function(){var a=this.periods,b;for(b=0;b<a.length;b++){var c=a[b];c.selected&&this.selectPeriodButton(c)}}});AmCharts.StockGraph=AmCharts.Class({inherits:AmCharts.AmGraph,construct:function(a){AmCharts.StockGraph.base.construct.call(this,a);this.cname="StockGraph";this.useDataSetColors=!0;this.periodValue="Close";this.compareGraphType="line";this.compareGraphVisibleInLegend=!0;this.comparable=this.resetTitleOnDataSetChange=!1;this.comparedGraphs={};this.showEventsOnComparedGraphs=!1;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.StockPanel=AmCharts.Class({inherits:AmCharts.AmSerialChart,construct:function(a){AmCharts.StockPanel.base.construct.call(this,a);this.cname="StockPanel";this.theme=a;this.showCategoryAxis=this.showComparedOnTop=!0;this.recalculateToPercents="whenComparing";this.panelHeaderPaddingBottom=this.panelHeaderPaddingLeft=this.panelHeaderPaddingRight=this.panelHeaderPaddingTop=0;this.trendLineAlpha=1;this.trendLineColor="#00CC00";this.trendLineColorHover="#CC0000";this.trendLineThickness=2;this.trendLineDashLength=
58
+ 0;this.stockGraphs=[];this.drawingIconsEnabled=!1;this.iconSize=18;this.autoMargins=this.allowTurningOff=this.eraseAll=this.erasingEnabled=this.drawingEnabled=!1;AmCharts.applyTheme(this,a,this.cname)},initChart:function(a){AmCharts.StockPanel.base.initChart.call(this,a);this.drawingIconsEnabled&&this.createDrawIcons();(a=this.chartCursor)&&this.listenTo(a,"draw",this.handleDraw)},addStockGraph:function(a){this.stockGraphs.push(a);return a},handleCursorZoom:function(a){this.chartCursor&&this.chartCursor.pan&&
59
+ AmCharts.StockPanel.base.handleCursorZoom.call(this,a)},removeStockGraph:function(a){var b=this.stockGraphs,c;for(c=b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1)},createDrawIcons:function(){var a=this,b=a.iconSize,c=a.container,d=a.pathToImages,e=a.realWidth-2*b-1-a.marginRight,k=AmCharts.rect(c,b,b,"#000",.005),f=AmCharts.rect(c,b,b,"#000",.005);f.translate(b+1,0);var h=c.image(d+"pencilIcon.gif",0,0,b,b);a.pencilButton=h;f.setAttr("cursor","pointer");k.setAttr("cursor","pointer");k.mouseup(function(){a.handlePencilClick()});
60
+ var g=c.image(d+"pencilIconH.gif",0,0,b,b);a.pencilButtonPushed=g;a.drawingEnabled||g.hide();var n=c.image(d+"eraserIcon.gif",b+1,0,b,b);a.eraserButton=n;f.mouseup(function(){a.handleEraserClick()});k.touchend&&(k.touchend(function(){a.handlePencilClick()}),f.touchend(function(){a.handleEraserClick()}));b=c.image(d+"eraserIconH.gif",b+1,0,b,b);a.eraserButtonPushed=b;a.erasingEnabled||b.hide();c=c.set([h,g,n,b,k,f]);c.translate(e,1);this.hideIcons&&c.hide()},handlePencilClick:function(){var a=!this.drawingEnabled;
61
+ this.disableDrawing(!a);this.erasingEnabled=!1;var b=this.eraserButtonPushed;b&&b.hide();b=this.pencilButtonPushed;a?b&&b.show():(b&&b.hide(),this.setMouseCursor("auto"))},disableDrawing:function(a){this.drawingEnabled=!a;var b=this.chartCursor;this.stockChart.enableCursors(a);b&&b.enableDrawing(!a)},handleEraserClick:function(){this.disableDrawing(!0);var a=this.pencilButtonPushed;a&&a.hide();a=this.eraserButtonPushed;if(this.eraseAll){var a=this.trendLines,b;for(b=a.length-1;0<=b;b--){var c=a[b];
62
+ c.isProtected||this.removeTrendLine(c)}this.validateNow()}else(this.erasingEnabled=b=!this.erasingEnabled)?(a&&a.show(),this.setTrendColorHover(this.trendLineColorHover),this.setMouseCursor("auto")):(a&&a.hide(),this.setTrendColorHover())},setTrendColorHover:function(a){var b=this.trendLines,c;for(c=b.length-1;0<=c;c--){var d=b[c];d.isProtected||(d.rollOverColor=a)}},handleDraw:function(a){var b=this.drawOnAxis;AmCharts.isString(b)&&(b=this.getValueAxisById(b));b||(b=this.valueAxes[0]);this.drawOnAxis=
63
+ b;var c=this.categoryAxis,d=a.initialX,e=a.finalX,k=a.initialY;a=a.finalY;var f=new AmCharts.TrendLine(this.theme);f.initialDate=c.coordinateToDate(d);f.finalDate=c.coordinateToDate(e);f.initialValue=b.coordinateToValue(k);f.finalValue=b.coordinateToValue(a);f.lineAlpha=this.trendLineAlpha;f.lineColor=this.trendLineColor;f.lineThickness=this.trendLineThickness;f.dashLength=this.trendLineDashLength;f.valueAxis=b;f.categoryAxis=c;this.addTrendLine(f);this.listenTo(f,"click",this.handleTrendClick);this.validateNow()},
64
+ hideDrawingIcons:function(a){(this.hideIcons=a)&&this.disableDrawing(a)},handleTrendClick:function(a){this.erasingEnabled&&(a=a.trendLine,this.eraseAll||a.isProtected||this.removeTrendLine(a),this.validateNow())},handleWheelReal:function(a,b){var c=this.scrollbarChart;if(!this.wheelBusy&&c){var d=1;b&&(d=-1);var c=c.chartScrollbar,e=this.categoryAxis.minDuration();0>a?(d=this.startTime+d*e,e=this.endTime+1*e):(d=this.startTime-d*e,e=this.endTime-1*e);d<this.firstTime&&(d=this.firstTime);e>this.lastTime&&
65
+ (e=this.lastTime);d<e&&c.timeZoom(d,e,!0)}}});AmCharts.CategoryAxesSettings=AmCharts.Class({construct:function(a){this.cname="CategoryAxesSettings";this.minPeriod="DD";this.equalSpacing=!1;this.axisHeight=28;this.tickLength=this.axisAlpha=0;this.gridCount=10;this.maxSeries=150;this.groupToPeriods="ss 10ss 30ss mm 10mm 30mm hh DD WW MM YYYY".split(" ");this.markPeriodChange=this.autoGridCount=!0;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.ChartCursorSettings=AmCharts.Class({construct:function(a){this.cname="ChartCursorSettings";this.enabled=!0;this.bulletsEnabled=this.valueBalloonsEnabled=!1;this.categoryBalloonDateFormats=[{period:"YYYY",format:"YYYY"},{period:"MM",format:"MMM, YYYY"},{period:"WW",format:"MMM DD, YYYY"},{period:"DD",format:"MMM DD, YYYY"},{period:"hh",format:"JJ:NN"},{period:"mm",format:"JJ:NN"},{period:"ss",format:"JJ:NN:SS"},{period:"fff",format:"JJ:NN:SS"}];AmCharts.applyTheme(this,a,this.cname)},categoryBalloonDateFormat:function(a){var b=
66
+ this.categoryBalloonDateFormats,c,d;for(d=0;d<b.length;d++)b[d].period==a&&(c=b[d].format);return c}});AmCharts.ChartScrollbarSettings=AmCharts.Class({construct:function(a){this.cname="ChartScrollbarSettings";this.height=40;this.enabled=!0;this.color="#FFFFFF";this.updateOnReleaseOnly=this.autoGridCount=!0;this.hideResizeGrips=!1;this.position="bottom";this.minDistance=1;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.LegendSettings=AmCharts.Class({construct:function(a){this.cname="LegendSettings";this.marginBottom=this.marginTop=0;this.usePositiveNegativeOnPercentsOnly=!0;this.positiveValueColor="#00CC00";this.negativeValueColor="#CC0000";this.autoMargins=this.equalWidths=this.textClickEnabled=!1;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.PanelsSettings=AmCharts.Class({construct:function(a){this.cname="PanelsSettings";this.marginBottom=this.marginTop=this.marginRight=this.marginLeft=0;this.backgroundColor="#FFFFFF";this.backgroundAlpha=0;this.panelSpacing=8;this.panEventsEnabled=!0;this.creditsPosition="top-right";AmCharts.applyTheme(this,a,this.cname)}});AmCharts.StockEventsSettings=AmCharts.Class({construct:function(a){this.cname="StockEventsSettings";this.type="sign";this.backgroundAlpha=1;this.backgroundColor="#DADADA";this.borderAlpha=1;this.borderColor="#888888";this.balloonColor=this.rollOverColor="#CC0000";AmCharts.applyTheme(this,a,this.cname)}});AmCharts.ValueAxesSettings=AmCharts.Class({construct:function(a){this.cname="ValueAxesSettings";this.tickLength=0;this.showFirstLabel=this.autoGridCount=this.inside=!0;this.showLastLabel=!1;this.axisAlpha=0;AmCharts.applyTheme(this,a,this.cname)}});AmCharts.getItemIndex=function(a,b){var c=-1,d;for(d=0;d<b.length;d++)a==b[d]&&(c=d);return c};AmCharts.addBr=function(a){a.appendChild(document.createElement("br"))};AmCharts.applyStyles=function(a,b){if(b&&a)for(var c in a){var d=c,e=b[d];if(void 0!==e)try{a[d]=e}catch(k){}}};
67
+ AmCharts.parseStockData=function(a,b,c,d,e){(new Date).getTime();var k={},f=a.dataProvider,h=a.categoryField;if(h){var g=AmCharts.getItemIndex(b,c),n=c.length,m,t=f.length,r,v={};for(m=g;m<n;m++)r=c[m],k[r]=[];var w={},l=a.fieldMappings,y=l.length;for(m=0;m<t;m++){var z=f[m],x=z[h],x=x instanceof Date?AmCharts.newDate(x,b):e?AmCharts.stringToDate(x,e):new Date(x),B=x.getTime(),A={};for(r=0;r<y;r++)A[l[r].toField]=z[l[r].fromField];var q;for(q=g;q<n;q++){r=c[q];var s=AmCharts.extractPeriod(r),C=s.period,
68
+ E=s.count,u,p;if(q==g||B>=v[r]||!v[r]){w[r]={};w[r].amCategoryIdField=String(AmCharts.resetDateToMin(x,C,E,d).getTime());var D;for(D=0;D<y;D++)s=l[D].toField,u=w[r],p=Number(A[s]),u[s+"Count"]=0,u[s+"Sum"]=0,isNaN(p)||(u[s+"Open"]=p,u[s+"Sum"]=p,u[s+"High"]=p,u[s+"Low"]=p,u[s+"Close"]=p,u[s+"Count"]=1,u[s+"Average"]=p);u.dataContext=z;k[r].push(w[r]);q>g&&(s=AmCharts.newDate(x,b),s=AmCharts.changeDate(s,C,E,!0),s=AmCharts.resetDateToMin(s,C,E,d),v[r]=s.getTime());if(q==g)for(var F in z)z.hasOwnProperty(F)&&
69
+ (w[r][F]=z[F]);w[r][h]=AmCharts.newDate(x,b)}else for(C=0;C<y;C++)s=l[C].toField,u=w[r],m==t-1&&(u[h]=AmCharts.newDate(x,b)),p=Number(A[s]),isNaN(p)||(isNaN(u[s+"Low"])&&(u[s+"Low"]=p),p<u[s+"Low"]&&(u[s+"Low"]=p),isNaN(u[s+"High"])&&(u[s+"High"]=p),p>u[s+"High"]&&(u[s+"High"]=p),u[s+"Close"]=p,E=AmCharts.getDecimals(u[s+"Sum"]),D=AmCharts.getDecimals(p),u[s+"Sum"]+=p,u[s+"Sum"]=AmCharts.roundTo(u[s+"Sum"],Math.max(E,D)),u[s+"Count"]++,u[s+"Average"]=u[s+"Sum"]/u[s+"Count"])}}}a.agregatedDataProviders=
70
+ k};
71
+ AmCharts.parseEvents=function(a,b,c,d,e,k){var f=a.stockEvents,h=a.agregatedDataProviders,g=b.length,n,m,t,r,v,w,l,y;for(n=0;n<g;n++){w=b[n];v=w.graphs;t=v.length;var z;for(m=0;m<t;m++)r=v[m],r.customBulletField="amCustomBullet"+r.id+"_"+w.id,r.bulletConfigField="amCustomBulletConfig"+r.id+"_"+w.id;for(var x=0;x<f.length;x++)if(l=f[x],z=l.graph,AmCharts.isString(z)&&(z=AmCharts.getObjById(v,z)))l.graph=z}for(var B in h)if(h.hasOwnProperty(B)){z=h[B];var A=AmCharts.extractPeriod(B),q=z.length,s;for(s=
72
+ 0;s<q;s++){var C=z[s];n=C[a.categoryField];y=n instanceof Date;k&&!y&&(n=AmCharts.stringToDate(n,k));var E=n.getTime();v=A.period;var x=A.count,u;u="fff"==v?n.getTime()+1:AmCharts.resetDateToMin(AmCharts.changeDate(new Date(n),A.period,A.count),v,x,d).getTime();for(n=0;n<g;n++)for(w=b[n],v=w.graphs,t=v.length,m=0;m<t;m++){r=v[m];var p={};p.eventDispatcher=e;p.eventObjects=[];p.letters=[];p.descriptions=[];p.shapes=[];p.backgroundColors=[];p.backgroundAlphas=[];p.borderColors=[];p.borderAlphas=[];
73
+ p.colors=[];p.rollOverColors=[];p.showOnAxis=[];p.values=[];p.showAts=[];for(x=0;x<f.length;x++){l=f[x];y=l.date instanceof Date;k&&!y&&(l.date=AmCharts.stringToDate(l.date,k));y=l.date.getTime();var D=!1;l.graph&&(l.graph.showEventsOnComparedGraphs&&l.graph.comparedGraphs[a.id]&&(D=!0),(r==l.graph||D)&&y>=E&&y<u&&(p.eventObjects.push(l),p.letters.push(l.text),p.descriptions.push(l.description),l.type?p.shapes.push(l.type):p.shapes.push(c.type),void 0!==l.backgroundColor?p.backgroundColors.push(l.backgroundColor):
74
+ p.backgroundColors.push(c.backgroundColor),isNaN(l.backgroundAlpha)?p.backgroundAlphas.push(c.backgroundAlpha):p.backgroundAlphas.push(l.backgroundAlpha),isNaN(l.borderAlpha)?p.borderAlphas.push(c.borderAlpha):p.borderAlphas.push(l.borderAlpha),void 0!==l.borderColor?p.borderColors.push(l.borderColor):p.borderColors.push(c.borderColor),void 0!==l.rollOverColor?p.rollOverColors.push(l.rollOverColor):p.rollOverColors.push(c.rollOverColor),void 0!==l.showAt?p.showAts.push(l.showAt):p.showAts.push(c.showAt),
75
+ p.colors.push(l.color),p.values.push(l.value),!l.panel&&l.graph&&(l.panel=l.graph.chart),p.showOnAxis.push(l.showOnAxis),p.date=new Date(l.date)));0<p.shapes.length&&(l="amCustomBullet"+r.id+"_"+w.id,y="amCustomBulletConfig"+r.id+"_"+w.id,C[l]=AmCharts.StackedBullet,C[y]=p)}}}}};AmCharts.StockLegend=AmCharts.Class({inherits:AmCharts.AmLegend,construct:function(a){AmCharts.StockLegend.base.construct.call(this,a);this.cname="StockLegend";this.valueTextComparing="[[percents.value]]%";this.valueTextRegular="[[value]]";AmCharts.applyTheme(this,a,this.cname)},drawLegend:function(){var a=this;AmCharts.StockLegend.base.drawLegend.call(a);var b=a.chart;if(b.allowTurningOff){var c=a.container,d=c.image(b.pathToImages+"xIcon.gif",b.realWidth-17,3,17,17),b=c.image(b.pathToImages+"xIconH.gif",
76
+ b.realWidth-17,3,17,17);b.hide();a.xButtonHover=b;d.mouseup(function(){a.handleXClick()}).mouseover(function(){a.handleXOver()});b.mouseup(function(){a.handleXClick()}).mouseout(function(){a.handleXOut()})}},handleXOver:function(){this.xButtonHover.show()},handleXOut:function(){this.xButtonHover.hide()},handleXClick:function(){var a=this.chart,b=a.stockChart;b.removePanel(a);b.validateNow()}});AmCharts.DataSetSelector=AmCharts.Class({construct:function(a){this.cname="DataSetSelector";this.theme=a;this.createEvents("dataSetSelected","dataSetCompared","dataSetUncompared");this.position="left";this.selectText="Select:";this.comboBoxSelectText="Select...";this.compareText="Compare to:";this.width=180;this.dataProvider=[];this.listHeight=150;this.listCheckBoxSize=14;this.rollOverBackgroundColor="#b2e1ff";this.selectedBackgroundColor="#7fceff";AmCharts.applyTheme(this,a,this.cname)},write:function(a){var b=
77
+ this,c,d=b.theme;a.className="amChartsDataSetSelector";var e=b.width;c=b.position;b.width=void 0;b.position=void 0;AmCharts.applyStyles(a.style,b);b.div=a;b.width=e;b.position=c;a.innerHTML="";var e=b.position,k;k="top"==e||"bottom"==e?!1:!0;b.vertical=k;var f;k&&(f=b.width+"px");var e=b.dataProvider,h,g;if(1<b.countDataSets("showInSelect")){c=document.createTextNode(AmCharts.lang.selectText||b.selectText);a.appendChild(c);k&&AmCharts.addBr(a);var n=document.createElement("select");f&&(n.style.width=
78
+ f);b.selectCB=n;d&&AmCharts.applyStyles(n.style,d.DataSetSelect);a.appendChild(n);AmCharts.isNN&&n.addEventListener("change",function(a){b.handleDataSetChange.call(b,a)},!0);AmCharts.isIE&&n.attachEvent("onchange",function(a){b.handleDataSetChange.call(b,a)});for(c=0;c<e.length;c++)if(h=e[c],!0===h.showInSelect){g=document.createElement("option");g.text=h.title;g.value=c;h==b.chart.mainDataSet&&(g.selected=!0);try{n.add(g,null)}catch(m){n.add(g)}}b.offsetHeight=n.offsetHeight}if(0<b.countDataSets("showInCompare")&&
79
+ 1<e.length)if(k?(AmCharts.addBr(a),AmCharts.addBr(a)):(c=document.createTextNode(" "),a.appendChild(c)),c=document.createTextNode(AmCharts.lang.compareText||b.compareText),a.appendChild(c),g=b.listCheckBoxSize,k){AmCharts.addBr(a);f=document.createElement("div");a.appendChild(f);f.className="amChartsCompareList";d&&AmCharts.applyStyles(f.style,d.DataSetCompareList);f.style.overflow="auto";f.style.overflowX="hidden";f.style.width=b.width-2+"px";f.style.maxHeight=b.listHeight+"px";for(c=0;c<e.length;c++)h=
80
+ e[c],!0===h.showInCompare&&h!=b.chart.mainDataSet&&(d=document.createElement("div"),d.style.padding="4px",d.style.position="relative",d.name="amCBContainer",d.dataSet=h,d.style.height=g+"px",h.compared&&(d.style.backgroundColor=b.selectedBackgroundColor),f.appendChild(d),k=document.createElement("div"),k.style.width=g+"px",k.style.height=g+"px",k.style.position="absolute",k.style.backgroundColor=h.color,d.appendChild(k),k=document.createElement("div"),k.style.width="100%",k.style.position="absolute",
81
+ k.style.left=g+10+"px",d.appendChild(k),h=document.createTextNode(h.title),k.style.whiteSpace="nowrap",k.style.cursor="default",k.appendChild(h),b.addEventListeners(d));AmCharts.addBr(a);AmCharts.addBr(a)}else{d=document.createElement("select");b.compareCB=d;f&&(d.style.width=f);a.appendChild(d);AmCharts.isNN&&d.addEventListener("change",function(a){b.handleCBSelect.call(b,a)},!0);AmCharts.isIE&&d.attachEvent("onchange",function(a){b.handleCBSelect.call(b,a)});g=document.createElement("option");g.text=
82
+ AmCharts.lang.comboBoxSelectText||b.comboBoxSelectText;try{d.add(g,null)}catch(t){d.add(g)}for(c=0;c<e.length;c++)if(h=e[c],!0===h.showInCompare&&h!=b.chart.mainDataSet){g=document.createElement("option");g.text=h.title;g.value=c;h.compared&&(g.selected=!0);try{d.add(g,null)}catch(r){d.add(g)}}b.offsetHeight=d.offsetHeight}},addEventListeners:function(a){var b=this;AmCharts.isNN&&(a.addEventListener("mouseover",function(a){b.handleRollOver.call(b,a)},!0),a.addEventListener("mouseout",function(a){b.handleRollOut.call(b,
83
+ a)},!0),a.addEventListener("click",function(a){b.handleClick.call(b,a)},!0));AmCharts.isIE&&(a.attachEvent("onmouseout",function(a){b.handleRollOut.call(b,a)}),a.attachEvent("onmouseover",function(a){b.handleRollOver.call(b,a)}),a.attachEvent("onclick",function(a){b.handleClick.call(b,a)}))},handleDataSetChange:function(){var a=this.selectCB,a=this.dataProvider[a.options[a.selectedIndex].value],b=this.chart;b.mainDataSet=a;b.zoomOutOnDataSetChange&&(b.startDate=void 0,b.endDate=void 0);b.validateData();
84
+ a={type:"dataSetSelected",dataSet:a,chart:this.chart};this.fire(a.type,a)},handleRollOver:function(a){a=this.getRealDiv(a);a.dataSet.compared||(a.style.backgroundColor=this.rollOverBackgroundColor)},handleRollOut:function(a){a=this.getRealDiv(a);a.dataSet.compared||(a.style.removeProperty&&a.style.removeProperty("background-color"),a.style.removeAttribute&&a.style.removeAttribute("backgroundColor"))},handleCBSelect:function(a){var b=this.compareCB,c=this.dataProvider,d,e;for(d=0;d<c.length;d++)e=
85
+ c[d],e.compared&&(a={type:"dataSetUncompared",dataSet:e}),e.compared=!1;c=b.selectedIndex;0<c&&(e=this.dataProvider[b.options[c].value],e.compared||(a={type:"dataSetCompared",dataSet:e}),e.compared=!0);b=this.chart;b.validateData();a.chart=b;this.fire(a.type,a)},handleClick:function(a){a=this.getRealDiv(a).dataSet;!0===a.compared?(a.compared=!1,a={type:"dataSetUncompared",dataSet:a}):(a.compared=!0,a={type:"dataSetCompared",dataSet:a});var b=this.chart;b.validateData();a.chart=b;this.fire(a.type,
86
+ a)},getRealDiv:function(a){a||(a=window.event);a=a.currentTarget?a.currentTarget:a.srcElement;"amCBContainer"==a.parentNode.name&&(a=a.parentNode);return a},countDataSets:function(a){var b=this.dataProvider,c=0,d;for(d=0;d<b.length;d++)!0===b[d][a]&&c++;return c}});AmCharts.StackedBullet=AmCharts.Class({construct:function(){this.fontSize=11;this.stackDown=!1;this.mastHeight=8;this.shapes=[];this.backgroundColors=[];this.backgroundAlphas=[];this.borderAlphas=[];this.borderColors=[];this.colors=[];this.rollOverColors=[];this.showOnAxiss=[];this.values=[];this.showAts=[];this.textColor="#000000";this.nextY=0;this.size=16},parseConfig:function(){var a=this.bulletConfig;this.eventObjects=a.eventObjects;this.letters=a.letters;this.shapes=a.shapes;this.backgroundColors=
87
+ a.backgroundColors;this.backgroundAlphas=a.backgroundAlphas;this.borderColors=a.borderColors;this.borderAlphas=a.borderAlphas;this.colors=a.colors;this.rollOverColors=a.rollOverColors;this.date=a.date;this.showOnAxiss=a.showOnAxis;this.axisCoordinate=a.minCoord;this.showAts=a.showAts;this.values=a.values},write:function(a){this.parseConfig();this.container=a;this.bullets=[];if(this.graph){var b=this.graph.fontSize;b&&(this.fontSize=b)}b=this.letters.length;(this.mastHeight+2*(this.fontSize/2+2))*
88
+ b>this.availableSpace&&(this.stackDown=!0);this.set=a.set();a=0;var c;for(c=0;c<b;c++)this.shape=this.shapes[c],this.backgroundColor=this.backgroundColors[c],this.backgroundAlpha=this.backgroundAlphas[c],this.borderAlpha=this.borderAlphas[c],this.borderColor=this.borderColors[c],this.rollOverColor=this.rollOverColors[c],this.showOnAxis=this.showOnAxiss[c],this.color=this.colors[c],this.value=this.values[c],this.showAt=this.showAts[c],this.addLetter(this.letters[c],a,c),this.showOnAxis||a++},addLetter:function(a,
89
+ b,c){var d=this.container;b=d.set();var e=-1,k=this.stackDown,f=this.graph.valueAxis;this.showOnAxis&&(this.stackDown=f.reversed?!0:!1);this.stackDown&&(e=1);var h=0,g=0,n=0,m,t=this.fontSize,r=this.mastHeight,v=this.shape,w=this.textColor;void 0!==this.color&&(w=this.color);void 0===a&&(a="");a=AmCharts.text(d,a,w,this.chart.fontFamily,this.fontSize);a.node.style.pointerEvents="none";d=a.getBBox();this.labelWidth=w=d.width;this.labelHeight=d.height;var l,d=0;switch(v){case "sign":l=this.drawSign(b);
90
+ h=r+4+t/2;d=r+t+4;1==e&&(h-=4);break;case "flag":l=this.drawFlag(b);g=w/2+3;h=r+4+t/2;d=r+t+4;1==e&&(h-=4);break;case "pin":l=this.drawPin(b);h=6+t/2;d=t+8;break;case "triangleUp":l=this.drawTriangleUp(b);h=-t-1;d=t+4;e=-1;break;case "triangleDown":l=this.drawTriangleDown(b);h=t+1;d=t+4;e=-1;break;case "triangleLeft":l=this.drawTriangleLeft(b);g=t;d=t+4;e=-1;break;case "triangleRight":l=this.drawTriangleRight(b);g=-t;e=-1;d=t+4;break;case "arrowUp":l=this.drawArrowUp(b);a.hide();break;case "arrowDown":l=
91
+ this.drawArrowDown(b);a.hide();d=t+4;break;case "text":e=-1;l=this.drawTextBackground(b,a);h=this.labelHeight+3;d=t+10;break;case "round":l=this.drawCircle(b)}this.bullets[c]=l;this.showOnAxis?(m=isNaN(this.nextAxisY)?this.axisCoordinate:this.nextY,n=h*e,this.nextAxisY=m+e*d):this.value?(m=this.value,f.recalculateToPercents&&(m=m/f.recBaseValue*100-100),m=f.getCoordinate(m)-this.bulletY,n=h*e):this.showAt?(l=this.graphDataItem.values,f.recalculateToPercents&&(l=this.graphDataItem.percents),l&&(m=
92
+ f.getCoordinate(l[this.showAt])-this.bulletY,n=h*e)):(m=this.nextY,n=h*e);a.translate(g,n);b.push(a);b.translate(0,m);this.addEventListeners(b,c);this.nextY=m+e*d;this.stackDown=k},addEventListeners:function(a,b){var c=this;a.click(function(){c.handleClick(b)}).mouseover(function(){c.handleMouseOver(b)}).touchend(function(){c.handleMouseOver(b,!0)}).mouseout(function(){c.handleMouseOut(b)})},drawPin:function(a){var b=-1;this.stackDown&&(b=1);var c=this.fontSize+4;return this.drawRealPolygon(a,[0,
93
+ c/2,c/2,-c/2,-c/2,0],[0,b*c/4,b*(c+c/4),b*(c+c/4),b*c/4,0])},drawSign:function(a){var b=-1;this.stackDown&&(b=1);var c=this.mastHeight*b,d=this.fontSize/2+2,e=AmCharts.line(this.container,[0,0],[0,c],this.borderColor,this.borderAlpha,1),k=AmCharts.circle(this.container,d,this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);k.translate(0,c+d*b);a.push(e);a.push(k);this.set.push(a);return k},drawFlag:function(a){var b=-1;this.stackDown&&(b=1);var c=this.fontSize+4,d=this.labelWidth+
94
+ 6,e=this.mastHeight,b=1==b?b*e:b*e-c,e=AmCharts.line(this.container,[0,0],[0,b],this.borderColor,this.borderAlpha,1),c=AmCharts.polygon(this.container,[0,d,d,0],[0,0,c,c],this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);c.translate(0,b);a.push(e);a.push(c);this.set.push(a);return c},drawTriangleUp:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,b/2,-b/2,0],[0,b,b,0])},drawArrowUp:function(a){var b=this.size,c=b/2,d=b/4;return this.drawRealPolygon(a,
95
+ [0,c,d,d,-d,-d,-c,0],[0,c,c,b,b,c,c,0])},drawArrowDown:function(a){var b=this.size,c=b/2,d=b/4;return this.drawRealPolygon(a,[0,c,d,d,-d,-d,-c,0],[0,-c,-c,-b,-b,-c,-c,0])},drawTriangleDown:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,b/2,-b/2,0],[0,-b,-b,0])},drawTriangleLeft:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,b,b,0],[0,-b/2,b/2])},drawTriangleRight:function(a){var b=this.fontSize+7;return this.drawRealPolygon(a,[0,-b,-b,0],[0,-b/2,b/2,0])},drawRealPolygon:function(a,
96
+ b,c){b=AmCharts.polygon(this.container,b,c,this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);a.push(b);this.set.push(a);return b},drawCircle:function(a){shape=AmCharts.circle(this.container,this.fontSize/2,this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);a.push(shape);this.set.push(a);return shape},drawTextBackground:function(a,b){var c=b.getBBox(),d=-c.width/2-5,e=c.width/2+5,c=-c.height-12;return this.drawRealPolygon(a,[d,-5,0,5,e,e,d,d],
97
+ [-5,-5,0,-5,-5,c,c,-5])},handleMouseOver:function(a,b){b||this.bullets[a].attr({fill:this.rollOverColors[a]});var c=this.eventObjects[a],d={type:"rollOverStockEvent",eventObject:c,graph:this.graph,date:this.date},e=this.bulletConfig.eventDispatcher;d.chart=e;e.fire(d.type,d);c.url&&this.bullets[a].setAttr("cursor","pointer");this.chart.showBalloon(AmCharts.fixNewLines(c.description),e.stockEventsSettings.balloonColor,!0)},handleClick:function(a){a=this.eventObjects[a];var b={type:"clickStockEvent",
93
98
  eventObject:a,graph:this.graph,date:this.date},c=this.bulletConfig.eventDispatcher;b.chart=c;c.fire(b.type,b);b=a.urlTarget;b||(b=c.stockEventsSettings.urlTarget);AmCharts.getURL(a.url,b)},handleMouseOut:function(a){this.bullets[a].attr({fill:this.backgroundColors[a]});a={type:"rollOutStockEvent",eventObject:this.eventObjects[a],graph:this.graph,date:this.date};var b=this.bulletConfig.eventDispatcher;a.chart=b;b.fire(a.type,a)}});
@@ -1,667 +1,855 @@
1
- AmCharts.AmExport = AmCharts.Class({
2
- construct: function(chart, cfg) {
3
- var _this = this;
4
- _this.DEBUG = false;
5
- _this.chart = chart;
6
- _this.canvas = null;
7
- _this.svgs = [];
8
- _this.cfg = {
9
- menuTop : 'auto',
10
- menuLeft : 'auto',
11
- menuRight : '0px',
12
- menuBottom : '0px',
13
- menuItems : [{
14
- textAlign : 'center',
15
- icon : _this.chart.pathToImages + 'export.png',
16
- iconTitle : 'Save chart as an image',
17
- format : 'png'
18
- }],
19
- menuItemStyle : {
20
- backgroundColor : 'transparent',
21
- rollOverBackgroundColor : '#EFEFEF',
22
- color : '#000000',
23
- rollOverColor : '#CC0000',
24
- paddingTop : '6px',
25
- paddingRight : '6px',
26
- paddingBottom : '6px',
27
- paddingLeft : '6px',
28
- marginTop : '0px',
29
- marginRight : '0px',
30
- marginBottom : '0px',
31
- marginLeft : '0px',
32
- textAlign : 'left',
33
- textDecoration : 'none',
34
- fontFamily : _this.chart.fontFamily,
35
- fontSize : _this.chart.fontSize + 'px'
36
- },
37
- menuItemOutput : {
38
- backgroundColor : '#FFFFFF',
39
- fileName : 'amChart',
40
- format : 'png',
41
- output : 'dataurlnewwindow',
42
- render : 'browser',
43
- dpi : 90,
44
- onclick : function(instance, config, event) {
45
- event.preventDefault();
46
- // Polify SVG; needs to wait
47
- instance.polifySVG();
48
- instance.output(config);
49
- }
50
- },
51
- removeImagery: false
52
- };
53
- _this.processing = {
54
- buffer: [],
55
- drawn: 0,
56
- timer: 0
57
- };
58
-
59
- // Config dependency adaption
60
- if (typeof(window.canvg) != 'undefined' && typeof(window.RGBColor) != 'undefined') {
61
- _this.cfg.menuItemOutput.render = 'canvg';
62
- }
63
- if (typeof(window.saveAs) != 'undefined') {
64
- _this.cfg.menuItemOutput.output = 'save';
65
- }
66
- if (AmCharts.isIE && AmCharts.IEversion < 10) {
67
- _this.cfg.menuItemOutput.output = 'dataurlnewwindow';
68
- }
69
-
70
- // Merge given configs
71
- if (cfg) {
72
- cfg.menuItemOutput = AmCharts.extend(_this.cfg.menuItemOutput, cfg.menuItemOutput || {});
73
- cfg.menuItemStyle = AmCharts.extend(_this.cfg.menuItemStyle, cfg.menuItemStyle || {});
74
- _this.cfg = AmCharts.extend(_this.cfg, cfg);
75
- }
76
-
77
- // Add reference to chart
78
- _this.chart.AmExport = _this;
79
-
80
- // Listen to the drawer
81
- _this.chart.addListener('rendered', function() {
82
- _this.setup();
83
- });
84
-
85
- // DEBUG; Public reference
86
- if (_this.DEBUG) {
87
- window.AmExport = _this;
88
- }
89
- },
90
-
91
- /*
92
- Simple log function for internal purpose
93
- @param **args
94
- */
95
- log: function() {
96
- console.log('AmExport: ', arguments);
97
- },
98
-
99
- /* PUBLIC
100
- Prepares everything to get exported
101
- @param none
102
- */
103
- setup: function() {
104
- var _this = this;
105
-
106
- if (_this.DEBUG == 10) {
107
- _this.log('SETUP START');
108
- } // DEBUG
109
-
110
-
111
- if (!AmCharts.isIE || (AmCharts.isIE && AmCharts.IEversion > 9)) {
112
- // Build Buttons
113
- _this.generateButtons();
114
- if (_this.DEBUG == 10) {
115
- _this.log('SETUP END');
116
- } // DEBUG
117
- } else {
118
- if (_this.DEBUG == 10) {
119
- _this.log('< IE10 NOT SUPPORTED');
120
- } // DEBUG
121
- }
122
- },
123
-
124
- /* PUBLIC
125
- Decodes base64 string to binary array
126
- @param base64_string
127
- @copyright Eli Grey, http://eligrey.com and Devin Samarin, https://github.com/eboyjr
128
- */
129
- generateBinaryArray: function(base64_string) {
130
- var
131
- len = base64_string.length,
132
- buffer = new Uint8Array(len / 4 * 3 | 0),
133
- i = 0,
134
- outptr = 0,
135
- last = [0, 0],
136
- state = 0,
137
- save = 0,
138
- rank, code, undef, base64_ranks = new Uint8Array([
139
- 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
140
- ]);
141
- while (len--) {
142
- code = base64_string.charCodeAt(i++);
143
- rank = base64_ranks[code - 43];
144
- if (rank !== 255 && rank !== undef) {
145
- last[1] = last[0];
146
- last[0] = code;
147
- save = (save << 6) | rank;
148
- state++;
149
- if (state === 4) {
150
- buffer[outptr++] = save >>> 16;
151
- if (last[1] !== 61 /* padding character */ ) {
152
- buffer[outptr++] = save >>> 8;
153
- }
154
- if (last[0] !== 61 /* padding character */ ) {
155
- buffer[outptr++] = save;
156
- }
157
- state = 0;
158
- }
159
- }
160
- }
161
- // 2/3 chance there's going to be some null bytes at the end, but that
162
- // doesn't really matter with most image formats.
163
- // If it somehow matters for you, truncate the buffer up outptr.
164
- return buffer;
165
- },
166
-
167
- /*
168
- Creates blob object
169
- @param base64_datastring string
170
- @param type string
171
- */
172
- generateBlob: function(datastring, type) {
173
- var _this = this,
174
- header_end = datastring.indexOf(',') + 1,
175
- header = datastring.substring(0, header_end),
176
- data = datastring,
177
- blob = new Blob();
178
-
179
- if (header.indexOf('base64') != -1) {
180
- data = _this.generateBinaryArray(datastring.substring(header_end));
181
- }
182
-
183
- // Fake blob for IE
184
- if (AmCharts.isIE && AmCharts.IEversion < 10) {
185
- blob.data = data;
186
- blob.size = data.length;
187
- blob.type = type;
188
- blob.encoding = 'base64';
189
- } else {
190
- blob = new Blob([data], {
191
- type: type
192
- });
193
- }
194
- return blob;
195
- },
196
-
197
- /*
198
- Creates PDF object
199
- @param config object
200
- */
201
- generatePDF: function(cfg) {
202
- var _this = this,
203
- pdf = {
204
- output: function() {
205
- return '';
206
- }
207
- },
208
- data = _this.canvas.toDataURL('image/jpeg'), // JSPDF ONLY SUPPORTS JPG
209
- width = (_this.canvas.width * 25.4) / cfg.dpi,
210
- height = (_this.canvas.height * 25.4) / cfg.dpi;
211
-
212
- // Check
213
- if (window.jsPDF) {
214
- pdf = new jsPDF();
215
- if (pdf.addImage) {
216
- pdf.addImage(data, 'JPEG', 0, 0, width, height);
217
- } else {
218
- alert("Missing jsPDF plugin; Please add the 'addImage' plugin.");
219
- }
220
- } else {
221
- alert("Missing jsPDF lib; Don't forget to add the addImage plugin.");
222
- }
223
-
224
- return pdf;
225
- },
226
-
227
- /*
228
- Creates the CANVAS to receive the image data
229
- @param format void()
230
- @param callback; given callback function which returns the blob or datastring of the configured ouput type
231
- */
232
- output: function(cfg, externalCallback) {
233
- var _this = this;
234
- cfg = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemOutput), cfg || {});
235
-
236
- /* PRIVATE
237
- Callback function which gets called after the drawing process is done
238
- @param none
239
- */
240
- function internalCallback() {
241
- var data = null;
242
- var blob;
243
- if (_this.DEBUG == 10) {
244
- _this.log('OUTPUT', format);
245
- } // DEBUG
246
-
247
- // SVG
248
- if (cfg.format == 'image/svg+xml' || cfg.format == 'svg') {
249
- for (var i = 0; i < _this.processing.buffer.length; i++) {
250
- data = new XMLSerializer().serializeToString(_this.processing.buffer[i][0]);
251
- blob = _this.generateBlob(data, 'image/svg+xml');
252
-
253
- if (cfg.output == 'save') {
254
- saveAs(blob, cfg.fileName + '.svg');
255
- } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
256
- blob = 'data:image/svg+xml;base64,' + btoa(data);
257
- } else if (cfg.output == 'dataurlnewwindow') {
258
- window.open('data:image/svg+xml;base64,' + btoa(data));
259
- } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
260
- location.href = 'data:image/svg+xml;base64,' + btoa(data);
261
- } else if (cfg.output == 'datastream') {
262
- location.href = 'data:image/octet-stream;base64,' + btoa(data);
263
- }
264
-
265
- if (externalCallback)
266
- externalCallback.apply(_this, [blob]);
267
- }
268
- // PDF
269
- } else if (cfg.format == 'application/pdf' || cfg.format == 'pdf') {
270
- data = _this.generatePDF(cfg).output('dataurlstring');
271
- blob = _this.generateBlob(data, 'application/pdf');
272
-
273
- if (cfg.output == 'save') {
274
- saveAs(blob, cfg.fileName + '.pdf');
275
- } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
276
- blob = data;
277
- } else if (cfg.output == 'dataurlnewwindow') {
278
- window.open(data);
279
- } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
280
- location.href = data;
281
- } else if (cfg.output == 'datastream') {
282
- location.href = data.replace('application/pdf', 'application/octet-stream');
283
- }
284
-
285
- if (externalCallback)
286
- externalCallback.apply(_this, [blob]);
287
-
288
- // PNG
289
- } else if (cfg.format == 'image/png' || cfg.format == 'png') {
290
- data = _this.canvas.toDataURL('image/png');
291
- blob = _this.generateBlob(data, 'image/png');
292
-
293
- if (cfg.output == 'save') {
294
- saveAs(blob, cfg.fileName + '.png');
295
- } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
296
- blob = data;
297
- } else if (cfg.output == 'dataurlnewwindow') {
298
- window.open(data);
299
- } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
300
- location.href = data;
301
- } else if (cfg.output == 'datastream') {
302
- location.href = data.replace('image/png', 'image/octet-stream');
303
- }
304
-
305
- if (externalCallback)
306
- externalCallback.apply(_this, [blob]);
307
-
308
- // JPG
309
- } else if (cfg.format == 'image/jpeg' || cfg.format == 'jpeg' || cfg.format == 'jpg') {
310
- data = _this.canvas.toDataURL('image/jpeg');
311
- blob = _this.generateBlob(data, 'image/jpeg');
312
-
313
- if (cfg.output == 'save') {
314
- saveAs(blob, cfg.fileName + '.jpg');
315
- } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
316
- blob = data;
317
- } else if (cfg.output == 'dataurlnewwindow') {
318
- window.open(data);
319
- } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
320
- location.href = data;
321
- } else if (cfg.output == 'datastream') {
322
- location.href = data.replace('image/jpeg', 'image/octet-stream');
323
- }
324
-
325
- if (externalCallback)
326
- externalCallback.apply(_this, [blob]);
327
- }
328
-
329
- }
330
-
331
- return _this.generateOutput(cfg, internalCallback);
332
- },
333
-
334
- /* PUBLIC
335
- Polifies missing attributes to the SVG and replaces images to embedded base64 images
336
- @param none
337
- */
338
- polifySVG: function() {
339
- var _this = this;
340
- var svgs = _this.chart.div.getElementsByTagName('svg');
341
-
342
- // Recursive function to force the attributes
343
- function recursiveChange(svg, tag) {
344
- var items = svg.getElementsByTagName(tag);
345
-
346
- for (var i = 0; i < items.length; i++) {
347
-
348
- if ( _this.cfg.removeImagery ) {
349
- items[i].parentNode.removeChild(items[i]);
350
-
351
- } else {
352
- var image = document.createElement('img');
353
- var canvas = document.createElement('canvas');
354
- var ctx = canvas.getContext('2d');
355
-
356
- canvas.width = items[i].getAttribute('width');
357
- canvas.height = items[i].getAttribute('height');
358
- image.src = items[i].getAttribute('xlink:href');
359
- image.width = items[i].getAttribute('width');
360
- image.height = items[i].getAttribute('height');
361
-
362
- try {
363
- ctx.drawImage(image, 0, 0, image.width, image.height);
364
- datastring = canvas.toDataURL(); // image.src; // canvas.toDataURL(); //
365
- } catch (err) {
366
- datastring = image.src; // image.src; // canvas.toDataURL(); //
367
-
368
- _this.log('Tainted canvas, reached browser CORS security; origin from imagery must be equal to the server!');
369
- throw new Error(err);
370
- }
371
-
372
- items[i].setAttribute('xlink:href', datastring);
373
- }
374
-
375
- if (_this.DEBUG == 10) {
376
- _this.log('POLIFIED', items[i]);
377
- } // DEBUG
378
- }
379
- }
380
-
381
- // Loop through svgs to add some standardization
382
- for (var i = 0; i < svgs.length; i++) {
383
- var parent = svgs[i].parentNode;
384
-
385
- // Put some attrs to it; fixed 20/03/14 xmlns is required to produce a valid svg file
386
- if ( !AmCharts.isIE ) {
387
- svgs[i].setAttribute('xmlns','http://www.w3.org/2000/svg');
388
- //svgs[i].setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
389
- }
390
- //svgs[i].setAttribute('width',parent.style.width);
391
- //svgs[i].setAttribute('height',parent.style.height);
392
-
393
- // DEBUG
394
- if (_this.DEBUG == 10) {
395
- _this.log('POLIFIED', svgs[i]);
396
- }
397
-
398
- // Force link adaption
399
- recursiveChange(svgs[i], 'pattern');
400
- recursiveChange(svgs[i], 'image');
401
-
402
- _this.svgs.push(svgs[i]);
403
- }
404
-
405
- return svgs;
406
- },
407
-
408
- /* PUBLIC
409
- Generates the canvas with the given SVGs and configured renderer
410
- @param callback; function(); gets called after drawing process on the canvas has been finished
411
- */
412
- generateOutput: function(cfg, callback) {
413
- var _this = this,
414
- svgs = _this.chart.div.getElementsByTagName('svg'),
415
- canvas = document.createElement('canvas'),
416
- context = canvas.getContext('2d'),
417
- offset = {
418
- y: 0,
419
- x: 0
420
- },
421
- tmp = {};
422
-
423
- // Reset
424
- _this.processing.buffer = [];
425
- _this.processing.drawn = 0;
426
- _this.canvas = canvas;
427
-
428
- // Walkthroug SVGs
429
- if (_this.DEBUG == 10) {
430
- _this.log('START EXPORT');
431
- } // DEBUG
432
- if (_this.DEBUG == 10) {
433
- _this.log('START BUFFERING');
434
- } // DEBUG
435
- for (var i = 0; i < svgs.length; i++) {
436
- var parent = svgs[i].parentNode,
437
- svgX = Number(parent.style.left.slice(0, -2)),
438
- svgY = Number(parent.style.top.slice(0, -2));
439
- tmp = AmCharts.extend({}, offset);
440
-
441
- // Overtake parent position if given; fixed 20/03/14 distinguish between relativ and others
442
- if ( parent.style.position == 'relative' ) {
443
- offset.x = svgX? svgX : offset.x;
444
- offset.y = svgY? svgY : offset.y;
445
- } else {
446
- offset.x = svgX;
447
- offset.y = svgY;
448
- }
449
-
450
- _this.processing.buffer.push([svgs[i], AmCharts.extend({}, offset)]);
451
-
452
- // Put back from "cache"
453
- if (svgY && svgX) {
454
- offset = tmp;
455
-
456
- // New offset for next one
457
- } else {
458
- offset.y += svgY ? 0 : parent.offsetHeight;
459
- }
460
-
461
- if (_this.DEBUG == 10) {
462
- _this.log('BUFFERED', svgs[i], offset);
463
- } // DEBUG
464
- }
465
- if (_this.DEBUG == 10) {
466
- _this.log('END BUFFERING');
467
- } // DEBUG
468
-
469
- // Apply background
470
- if (_this.DEBUG == 10) {
471
- _this.log('START DRAWING', cfg.render);
472
- } // DEBUG
473
- if (_this.DEBUG == 10) {
474
- _this.log('FILL BACKGROUND');
475
- } // DEBUG
476
- canvas.id = AmCharts.getUniqueId();
477
- canvas.width = _this.chart.divRealWidth;
478
- canvas.height = _this.chart.divRealHeight;
479
-
480
- // Set given background; jpeg default
481
- if (cfg.backgroundColor || format == 'image/jpeg') {
482
- context.fillStyle = cfg.backgroundColor || '#FFFFFF';
483
- context.fillRect(0, 0, canvas.width, canvas.height);
484
- }
485
-
486
- /* PRIVATE
487
- Recursive function to draw the images to the canvas;
488
- @param none;
489
- */
490
- function drawItWhenItsLoaded() {
491
- var img, buffer, offset, source;
492
-
493
- // DRAWING PROCESS DONE
494
- if (_this.processing.buffer.length == _this.processing.drawn) {
495
- if (_this.DEBUG == 10) {
496
- _this.log('END DRAWING');
497
- } // DEBUG
498
- return callback();
499
-
500
- // LOOPING LUI
501
- } else {
502
- if (_this.DEBUG == 10) {
503
- _this.log('DRAW', _this.processing.drawn + 1, 'OF', _this.processing.buffer.length);
504
- } // DEBUG
505
-
506
- buffer = _this.processing.buffer[_this.processing.drawn];
507
- source = new XMLSerializer().serializeToString(buffer[0]); //source = 'data:image/svg+xml;base64,' + btoa();
508
- offset = buffer[1];
509
-
510
- if (_this.DEBUG == 10) {
511
- _this.log('SOURCE', source);
512
- } // DEBUG
513
-
514
- // NATIVE
515
- if (cfg.render == 'browser') {
516
- img = new Image();
517
- img.id = AmCharts.getUniqueId();
518
- source = 'data:image/svg+xml;base64,' + btoa(source);
519
-
520
- //img.crossOrigin = "Anonymous";
521
- img.onload = function() {
522
- context.drawImage(this, buffer[1].x, buffer[1].y);
523
- _this.processing.drawn++;
524
-
525
- if (_this.DEBUG == 10) {
526
- _this.log('ONLOAD', this);
527
- } // DEBUG
528
- drawItWhenItsLoaded();
529
- };
530
- img.onerror = function() {
531
- if (_this.DEBUG == 10) {
532
- _this.log('ONERROR', this);
533
- } // DEBUG
534
- context.drawImage(this, buffer[1].x, buffer[1].y);
535
- _this.processing.drawn++;
536
- drawItWhenItsLoaded();
537
- };
538
- img.src = source;
539
-
540
- if (_this.DEBUG == 10) {
541
- _this.log('ADD', img);
542
- } // DEBUG
543
- if (img.complete || typeof(img.complete) == 'undefined' || img.complete === undefined) {
544
- if (_this.DEBUG == 10) {
545
- _this.log('FORCE ONLOAD', img);
546
- } // DEBUG
547
- img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
548
- img.src = source;
549
- }
550
-
551
- // CANVG
552
- } else if (cfg.render == 'canvg') {
553
- canvg(canvas, source, {
554
- offsetX: offset.x,
555
- offsetY: offset.y,
556
- ignoreMouse: true,
557
- ignoreAnimation: true,
558
- ignoreDimensions: true,
559
- ignoreClear: true,
560
- renderCallback: function() {
561
- _this.processing.drawn++;
562
- drawItWhenItsLoaded();
563
- }
564
- });
565
- }
566
- }
567
- }
568
- return drawItWhenItsLoaded();
569
- },
570
-
571
- /*
572
- Generates the export menu to trigger the exportation
573
- @param none;
574
- */
575
- generateButtons: function() {
576
- var _this = this,
577
- div = document.createElement('div'),
578
- lvl = 0;
579
-
580
- // Push sublings
581
- function createList(items) {
582
- var ul = document.createElement('ul');
583
-
584
- ul.setAttribute('style', 'list-style: none; margin: 0; padding: 0;');
585
-
586
- // Walkthrough items
587
- for (var i = 0; i < items.length; i++) {
588
- var li = document.createElement('li'),
589
- img = document.createElement('img'),
590
- a = document.createElement('a'),
591
- item = items[i],
592
- children = null,
593
- itemStyle = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemStyle), items[i]);
594
-
595
- // MERGE CFG
596
- item = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemOutput), item);
597
-
598
- // ICON
599
- if (item['icon']) {
600
- img.alt = '';
601
- img.src = item['icon'];
602
- img.setAttribute('style', 'margin: 0 auto;border: none;outline: none');
603
- if (item['iconTitle']) {
604
- img.title = item['iconTitle'];
605
- }
606
- a.appendChild(img);
607
- }
608
-
609
- // TITLE; STYLING
610
- a.href = '#';
611
- if (item['title']) {
612
- img.setAttribute('style', 'margin-right: 5px;');
613
- a.innerHTML += item.title;
614
- }
615
- a.setAttribute('style', 'display: block;');
616
- AmCharts.extend(a.style, itemStyle);
617
-
618
- // ONCLICK
619
- a.onclick = item.onclick.bind(a, _this, item);
620
- li.appendChild(a);
621
-
622
- // APPEND SIBLINGS
623
- if (item.items) {
624
- children = createList(item.items);
625
- li.appendChild(children);
626
-
627
- li.onmouseover = function() {
628
- children.style.display = 'block';
629
- };
630
- li.onmouseout = function() {
631
- children.style.display = 'none';
632
- };
633
- children.style.display = 'none';
634
- }
635
-
636
- // Append to parent
637
- ul.appendChild(li);
638
-
639
- // Apply hover
640
- a.onmouseover = function() {
641
- this.style.backgroundColor = itemStyle.rollOverBackgroundColor;
642
- this.style.color = itemStyle.rollOverColor;
643
- this.style.borderColor = itemStyle.rollOverBorderColor;
644
- };
645
- a.onmouseout = function() {
646
- this.style.backgroundColor = itemStyle.backgroundColor;
647
- this.style.color = itemStyle.color;
648
- this.style.borderColor = itemStyle.borderColor;
649
- };
650
- }
651
- lvl++;
652
-
653
- if (_this.DEBUG == 10) {
654
- _this.log('MENU', ul);
655
- } // DEBUG
656
-
657
- return ul;
658
- }
659
-
660
- // Style wrapper; Push into chart div
661
- div.setAttribute('style', 'width:39px; height:28px; position: absolute;top:' + _this.cfg.menuTop + ';right:' + _this.cfg.menuRight + ';bottom:' + _this.cfg.menuBottom + ';left:' + _this.cfg.menuLeft + ';box-shadow:0px 0px 1px 0px rgba(0,0,0,0);');
662
- div.setAttribute('class', 'amExportButton');
663
- div.appendChild(createList(_this.cfg.menuItems));
664
- //_this.chart.div.style.position = 'relative';
665
- _this.chart.containerDiv.appendChild(div);
666
- }
1
+ AmCharts.AmExport = AmCharts.Class({
2
+ construct: function(chart, cfg, init ) {
3
+ var _this = this;
4
+ _this.DEBUG = false;
5
+ _this.chart = chart;
6
+ _this.canvas = null;
7
+ _this.svgs = [];
8
+ _this.userCFG = cfg;
9
+
10
+ _this.buttonIcon = 'export.png';
11
+ _this.exportPNG = true;
12
+ _this.exportPDF = false;
13
+ _this.exportJPG = false;
14
+ _this.exportSVG = false;
15
+ //_this.left;
16
+ _this.right = 0;
17
+ //_this.bottom;
18
+ _this.top = 0;
19
+ //_this.color;
20
+ _this.buttonRollOverColor = "#EFEFEF";
21
+ //_this.buttonColor = "#FFFFFF";
22
+ //_this.buttonRollOverAlpha = 0.5;
23
+ _this.textRollOverColor = "#CC0000";
24
+ _this.buttonTitle = "Save chart as an image";
25
+ _this.buttonAlpha = 0.75;
26
+ _this.imageFileName = "amChart";
27
+ _this.imageBackgroundColor = "#FFFFFF";
28
+
29
+ if (init) {
30
+ _this.init();
31
+ }
32
+ },
33
+
34
+ toCoordinate:function(value){
35
+ if(value === undefined){
36
+ return "auto";
37
+ }
38
+ if(String(value).indexOf("%") != -1){
39
+ return value;
40
+ }
41
+ else{
42
+ return value + "px";
43
+ }
44
+ },
45
+
46
+ init: function(){
47
+ var _this = this;
48
+
49
+ var formats = [];
50
+ if (_this.exportPNG) {
51
+ formats.push("png");
52
+ }
53
+ if (_this.exportPDF) {
54
+ formats.push("pdf");
55
+ }
56
+ if (_this.exportJPG) {
57
+ formats.push("jpg");
58
+ }
59
+ if (_this.exportSVG) {
60
+ formats.push("svg");
61
+ }
62
+
63
+ var menuItems = [];
64
+ if(formats.length == 1){
65
+ var format = formats[0];
66
+ menuItems.push({format:format, iconTitle:_this.buttonTitle, icon:_this.chart.pathToImages + _this.buttonIcon})
67
+ }
68
+ else if(formats.length > 1){
69
+ var subItems = [];
70
+ for(var i = 0; i < formats.length; i++){
71
+ subItems.push({format:formats[i], title:formats[i].toUpperCase()});
72
+ }
73
+ menuItems.push({onclick: function() {}, icon:_this.chart.pathToImages + _this.buttonIcon, items:subItems})
74
+ }
75
+
76
+
77
+ var color = _this.color;
78
+ if(color === undefined){
79
+ color = _this.chart.color;
80
+ }
81
+
82
+ var buttonColor = _this.buttonColor;
83
+ if(buttonColor === undefined){
84
+ buttonColor = "transparent";
85
+ }
86
+
87
+
88
+ _this.cfg = {
89
+ menuTop : _this.toCoordinate(_this.top),
90
+ menuLeft : _this.toCoordinate(_this.left),
91
+ menuRight : _this.toCoordinate(_this.right),
92
+ menuBottom : _this.toCoordinate(_this.bottom),
93
+ menuItems : menuItems,
94
+ menuItemStyle: {
95
+ backgroundColor : buttonColor,
96
+ opacity :_this.buttonAlpha,
97
+ rollOverBackgroundColor : _this.buttonRollOverColor,
98
+ color : color,
99
+ rollOverColor : _this.textRollOverColor,
100
+ paddingTop : '6px',
101
+ paddingRight : '6px',
102
+ paddingBottom : '6px',
103
+ paddingLeft : '6px',
104
+ marginTop : '0px',
105
+ marginRight : '0px',
106
+ marginBottom : '0px',
107
+ marginLeft : '0px',
108
+ textAlign : 'left',
109
+ textDecoration : 'none',
110
+ fontFamily : _this.chart.fontFamily,
111
+ fontSize : _this.chart.fontSize + 'px'
112
+ },
113
+ menuItemOutput: {
114
+ backgroundColor : _this.imageBackgroundColor,
115
+ fileName : _this.imageFileName,
116
+ format : 'png',
117
+ output : 'dataurlnewwindow',
118
+ render : 'browser',
119
+ dpi : 90,
120
+ onclick : function(instance, config, event) {
121
+ event.preventDefault();
122
+ instance.output(config);
123
+ }
124
+ },
125
+ removeImagery: true
126
+ };
127
+
128
+ _this.processing = {
129
+ buffer: [],
130
+ drawn: 0,
131
+ timer: 0
132
+ };
133
+
134
+ // Config dependency adaption
135
+ if (typeof(window.canvg) != 'undefined' && typeof(window.RGBColor) != 'undefined') {
136
+ _this.cfg.menuItemOutput.render = 'canvg';
137
+ }
138
+ if (typeof(window.saveAs) != 'undefined') {
139
+ _this.cfg.menuItemOutput.output = 'save';
140
+ }
141
+ if (AmCharts.isIE && AmCharts.IEversion < 10) {
142
+ _this.cfg.menuItemOutput.output = 'dataurlnewwindow';
143
+ }
144
+
145
+ // Merge given configs
146
+ var cfg = _this.userCFG;
147
+ if (cfg) {
148
+ cfg.menuItemOutput = AmCharts.extend(_this.cfg.menuItemOutput, cfg.menuItemOutput || {});
149
+ cfg.menuItemStyle = AmCharts.extend(_this.cfg.menuItemStyle, cfg.menuItemStyle || {});
150
+ _this.cfg = AmCharts.extend(_this.cfg, cfg);
151
+ }
152
+
153
+ // Add reference to chart
154
+ _this.chart.AmExport = _this;
155
+
156
+ // Listen to the drawer
157
+ _this.chart.addListener('rendered', function() {
158
+ _this.setup();
159
+ });
160
+
161
+ // DEBUG; Public reference
162
+ if (_this.DEBUG) {
163
+ window.AmExport = _this;
164
+ }
165
+ },
166
+
167
+
168
+ /*
169
+ Simple log function for internal purpose
170
+ @param **args
171
+ */
172
+ log: function() {
173
+ console.log('AmExport: ', arguments);
174
+ },
175
+
176
+ /* PUBLIC
177
+ Prepares everything to get exported
178
+ @param none
179
+ */
180
+ setup: function() {
181
+ var _this = this;
182
+
183
+ if (_this.DEBUG == 10) {
184
+ _this.log('SETUP START');
185
+ } // DEBUG
186
+
187
+
188
+ if (!AmCharts.isIE || (AmCharts.isIE && AmCharts.IEversion > 9)) {
189
+ // Build Buttons
190
+ _this.generateButtons();
191
+ if (_this.DEBUG == 10) {
192
+ _this.log('SETUP END');
193
+ } // DEBUG
194
+ } else {
195
+ if (_this.DEBUG == 10) {
196
+ _this.log('< IE10 NOT SUPPORTED');
197
+ } // DEBUG
198
+ }
199
+ },
200
+
201
+ /* PUBLIC
202
+ Decodes base64 string to binary array
203
+ @param base64_string
204
+ @copyright Eli Grey, http://eligrey.com and Devin Samarin, https://github.com/eboyjr
205
+ */
206
+ generateBinaryArray: function(base64_string) {
207
+ var
208
+ len = base64_string.length,
209
+ buffer = new Uint8Array(len / 4 * 3 | 0),
210
+ i = 0,
211
+ outptr = 0,
212
+ last = [0, 0],
213
+ state = 0,
214
+ save = 0,
215
+ rank, code, undef, base64_ranks = new Uint8Array([
216
+ 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
217
+ ]);
218
+ while (len--) {
219
+ code = base64_string.charCodeAt(i++);
220
+ rank = base64_ranks[code - 43];
221
+ if (rank !== 255 && rank !== undef) {
222
+ last[1] = last[0];
223
+ last[0] = code;
224
+ save = (save << 6) | rank;
225
+ state++;
226
+ if (state === 4) {
227
+ buffer[outptr++] = save >>> 16;
228
+ if (last[1] !== 61 /* padding character */ ) {
229
+ buffer[outptr++] = save >>> 8;
230
+ }
231
+ if (last[0] !== 61 /* padding character */ ) {
232
+ buffer[outptr++] = save;
233
+ }
234
+ state = 0;
235
+ }
236
+ }
237
+ }
238
+ // 2/3 chance there's going to be some null bytes at the end, but that
239
+ // doesn't really matter with most image formats.
240
+ // If it somehow matters for you, truncate the buffer up outptr.
241
+ return buffer;
242
+ },
243
+
244
+ /*
245
+ Creates blob object
246
+ @param base64_datastring string
247
+ @param type string
248
+ */
249
+ generateBlob: function(datastring, type) {
250
+ var _this = this,
251
+ header_end = type!='image/svg+xml'?datastring.indexOf(',') + 1:0,
252
+ header = datastring.substring(0, header_end),
253
+ data = datastring,
254
+ blob = new Blob();
255
+
256
+ if (header.indexOf('base64') != -1) {
257
+ data = _this.generateBinaryArray(datastring.substring(header_end));
258
+ }
259
+
260
+ // Fake blob for IE
261
+ if (AmCharts.isIE && AmCharts.IEversion < 10) {
262
+ blob.data = data;
263
+ blob.size = data.length;
264
+ blob.type = type;
265
+ blob.encoding = 'base64';
266
+ } else {
267
+ blob = new Blob([data], {
268
+ type: type
269
+ });
270
+ }
271
+ return blob;
272
+ },
273
+
274
+ /*
275
+ Creates PDF object
276
+ @param config object
277
+ */
278
+ generatePDF: function(cfg) {
279
+ var _this = this,
280
+ pdf = {
281
+ output: function() {
282
+ return '';
283
+ }
284
+ },
285
+ data = _this.canvas.toDataURL('image/jpeg'), // JSPDF ONLY SUPPORTS JPG
286
+ width = (_this.canvas.width * 25.4) / cfg.dpi,
287
+ height = (_this.canvas.height * 25.4) / cfg.dpi;
288
+
289
+ // Check
290
+ if (window.jsPDF) {
291
+ pdf = new jsPDF();
292
+ if (pdf.addImage) {
293
+ pdf.addImage(data, 'JPEG', 0, 0, width, height);
294
+ } else {
295
+ alert("Missing jsPDF plugin; Please add the 'addImage' plugin.");
296
+ }
297
+ } else {
298
+ alert("Missing jsPDF lib; Don't forget to add the addImage plugin.");
299
+ }
300
+
301
+ return pdf;
302
+ },
303
+
304
+ /*
305
+ Creates the CANVAS to receive the image data
306
+ @param format void()
307
+ @param callback; given callback function which returns the blob or datastring of the configured ouput type
308
+ */
309
+ output: function(cfg, externalCallback) {
310
+ var _this = this;
311
+ cfg = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemOutput), cfg || {});
312
+
313
+ // Prepare chart
314
+ if(_this.chart.prepareForExport){
315
+ _this.chart.prepareForExport();
316
+ }
317
+
318
+ /* PRIVATE
319
+ Callback function which gets called after the drawing process is done
320
+ @param none
321
+ */
322
+ function internalCallback() {
323
+ var data = null;
324
+ var blob;
325
+ if (_this.DEBUG == 10) {
326
+ _this.log('OUTPUT', cfg.format);
327
+ } // DEBUG
328
+
329
+ // SVG
330
+ if (cfg.format == 'image/svg+xml' || cfg.format == 'svg') {
331
+ data = _this.generateSVG();
332
+ blob = _this.generateBlob(data, 'image/svg+xml');
333
+
334
+ if (cfg.output == 'save') {
335
+ saveAs(blob, cfg.fileName + '.svg');
336
+ } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
337
+ blob = 'data:image/svg+xml;base64,' + btoa(data);
338
+ } else if (cfg.output == 'dataurlnewwindow') {
339
+ window.open('data:image/svg+xml;base64,' + btoa(data));
340
+ } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
341
+ location.href = 'data:image/svg+xml;base64,' + btoa(data);
342
+ } else if (cfg.output == 'datastream') {
343
+ location.href = 'data:image/octet-stream;base64,' + data;
344
+ }
345
+
346
+ if (externalCallback)
347
+ externalCallback.apply(_this, [blob]);
348
+
349
+ // PDF
350
+ } else if (cfg.format == 'application/pdf' || cfg.format == 'pdf') {
351
+ data = _this.generatePDF(cfg).output('dataurlstring');
352
+ blob = _this.generateBlob(data, 'application/pdf');
353
+
354
+ if (cfg.output == 'save') {
355
+ saveAs(blob, cfg.fileName + '.pdf');
356
+ } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
357
+ blob = data;
358
+ } else if (cfg.output == 'dataurlnewwindow') {
359
+ window.open(data);
360
+ } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
361
+ location.href = data;
362
+ } else if (cfg.output == 'datastream') {
363
+ location.href = data.replace('application/pdf', 'application/octet-stream');
364
+ }
365
+
366
+ if (externalCallback)
367
+ externalCallback.apply(_this, [blob]);
368
+
369
+ // PNG
370
+ } else if (cfg.format == 'image/png' || cfg.format == 'png') {
371
+ data = _this.canvas.toDataURL('image/png');
372
+ blob = _this.generateBlob(data, 'image/png');
373
+
374
+ if (cfg.output == 'save') {
375
+ saveAs(blob, cfg.fileName + '.png');
376
+ } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
377
+ blob = data;
378
+ } else if (cfg.output == 'dataurlnewwindow') {
379
+ window.open(data);
380
+ } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
381
+ location.href = data;
382
+ } else if (cfg.output == 'datastream') {
383
+ location.href = data.replace('image/png', 'image/octet-stream');
384
+ }
385
+
386
+ if (externalCallback)
387
+ externalCallback.apply(_this, [blob]);
388
+
389
+ // JPG
390
+ } else if (cfg.format == 'image/jpeg' || cfg.format == 'jpeg' || cfg.format == 'jpg') {
391
+ data = _this.canvas.toDataURL('image/jpeg');
392
+ blob = _this.generateBlob(data, 'image/jpeg');
393
+
394
+ if (cfg.output == 'save') {
395
+ saveAs(blob, cfg.fileName + '.jpg');
396
+ } else if (cfg.output == 'datastring' || cfg.output == 'datauristring' || cfg.output == 'dataurlstring') {
397
+ blob = data;
398
+ } else if (cfg.output == 'dataurlnewwindow') {
399
+ window.open(data);
400
+ } else if (cfg.output == 'datauri' || cfg.output == 'dataurl') {
401
+ location.href = data;
402
+ } else if (cfg.output == 'datastream') {
403
+ location.href = data.replace('image/jpeg', 'image/octet-stream');
404
+ }
405
+
406
+ if (externalCallback)
407
+ externalCallback.apply(_this, [blob]);
408
+ }
409
+
410
+ }
411
+
412
+ return _this.generateOutput(cfg, internalCallback);
413
+ },
414
+
415
+ /* PUBLIC
416
+ Polifies missing attributes to the SVG and replaces images to embedded base64 images
417
+ @param none
418
+ */
419
+ polifySVG: function(svg) {
420
+ var _this = this;
421
+
422
+ // Recursive function to force the attributes
423
+ function recursiveChange(svg, tag) {
424
+ var items = svg.getElementsByTagName(tag);
425
+ var i = items.length;
426
+
427
+ while(i--) {
428
+ if (_this.cfg.removeImagery) {
429
+ items[i].parentNode.removeChild(items[i]);
430
+
431
+ } else {
432
+ var image = document.createElement('img');
433
+ var canvas = document.createElement('canvas');
434
+ var ctx = canvas.getContext('2d');
435
+
436
+ canvas.width = items[i].getAttribute('width');
437
+ canvas.height = items[i].getAttribute('height');
438
+ image.src = items[i].getAttribute('xlink:href');
439
+ image.width = items[i].getAttribute('width');
440
+ image.height = items[i].getAttribute('height');
441
+
442
+ try {
443
+ ctx.drawImage(image, 0, 0, image.width, image.height);
444
+ datastring = canvas.toDataURL(); // image.src; // canvas.toDataURL(); //
445
+ } catch (err) {
446
+ datastring = image.src; // image.src; // canvas.toDataURL(); //
447
+
448
+ _this.log('Tainted canvas, reached browser CORS security; origin from imagery must be equal to the server!');
449
+ throw new Error(err);
450
+ }
451
+
452
+ items[i].setAttribute('xlink:href', datastring);
453
+ }
454
+
455
+ if (_this.DEBUG == 10) {
456
+ _this.log('POLIFIED', items[i]);
457
+ } // DEBUG
458
+ }
459
+ }
460
+
461
+ // Put some attrs to it; fixed 20/03/14 xmlns is required to produce a valid svg file
462
+ if (AmCharts.IEversion == 0) {
463
+ svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
464
+ if ( !_this.cfg.removeImagery ) {
465
+ svg.setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
466
+ }
467
+ }
468
+
469
+ // DEBUG
470
+ if (_this.DEBUG == 10) {
471
+ _this.log('POLIFIED', svg);
472
+ }
473
+
474
+ // Force link adaption
475
+ recursiveChange(svg, 'pattern');
476
+ recursiveChange(svg, 'image');
477
+
478
+ _this.svgs.push(svg);
479
+
480
+ return svg;
481
+ },
482
+
483
+
484
+ /* PUBLIC
485
+ Stacks multiple SVGs into one
486
+ @param none
487
+ */
488
+ generateSVG: function() {
489
+ var _this = this;
490
+ var context = document.createElement('svg');
491
+ context.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
492
+ context.setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
493
+
494
+ for (var i = 0; i < _this.processing.buffer.length; i++) {
495
+ var group = document.createElement('g'),
496
+ data = _this.processing.buffer[i];
497
+
498
+ data[0].setAttribute('xmlns', 'http://www.w3.org/2000/svg');
499
+ data[0].setAttribute('xmlns:xlink','http://www.w3.org/1999/xlink');
500
+
501
+ group.setAttribute('transform', 'translate('+data[1].x+','+data[1].y+')');
502
+ group.appendChild(data[0]);
503
+ context.appendChild(group);
504
+ }
505
+
506
+ return new XMLSerializer().serializeToString(context);
507
+ },
508
+
509
+ /* PUBLIC
510
+ Generates the canvas with the given SVGs and configured renderer
511
+ @param callback; function(); gets called after drawing process on the canvas has been finished
512
+ */
513
+ generateOutput: function(cfg, callback) {
514
+ var _this = this,
515
+ coll = [],
516
+ svgs = [],
517
+ canvas = document.createElement('canvas'),
518
+ context = canvas.getContext('2d'),
519
+ offset = {
520
+ y: 0,
521
+ x: 0
522
+ },
523
+
524
+ // Push svgs into array
525
+ coll = _this.chart.div.getElementsByTagName('svg');
526
+ for ( var i = 0; i < coll.length; i++ ) svgs.push(coll[i]);
527
+
528
+ // Add external legend
529
+ if ( _this.chart.legend && _this.chart.legend.position == 'outside' ) {
530
+ _this.chart.legend.container.container.externalLegend = true
531
+ svgs.push(_this.chart.legend.container.container);
532
+
533
+ // Add offset
534
+ if ( _this.cfg.legendPosition == 'left' ) {
535
+ offset.x = _this.chart.legend.div.offsetWidth;
536
+ } else if ( _this.cfg.legendPosition == 'top' ) {
537
+ offset.y = _this.chart.legend.div.offsetHeight;
538
+ } else if ( typeof _this.cfg.legendPosition == 'object' ) {
539
+ offset.y = _this.cfg.legendPosition.chartTop;
540
+ offset.x = _this.cfg.legendPosition.chartLeft;
541
+ }
542
+ }
543
+
544
+ // Reset
545
+ _this.processing.buffer = [];
546
+ _this.processing.drawn = 0;
547
+ _this.canvas = canvas;
548
+ _this.svgs = [];
549
+
550
+ // Walkthroug SVGs
551
+ if (_this.DEBUG == 10) {
552
+ _this.log('START EXPORT');
553
+ } // DEBUG
554
+ if (_this.DEBUG == 10) {
555
+ _this.log('START BUFFERING');
556
+ } // DEBUG
557
+ for (var i = 0; i < svgs.length; i++) {
558
+ var parent = svgs[i].parentNode,
559
+ svgX = Number(parent.style.left.slice(0, -2)),
560
+ svgY = Number(parent.style.top.slice(0, -2)),
561
+ svgClone = _this.polifySVG(svgs[i].cloneNode(true)),
562
+ tmp = AmCharts.extend({}, offset);
563
+
564
+ // Add external legend
565
+ if ( svgs[i].externalLegend ) {
566
+ if ( _this.cfg.legendPosition == 'right' ) {
567
+ offset.y = 0;
568
+ offset.x = _this.chart.divRealWidth;
569
+
570
+ } else if ( _this.cfg.legendPosition == 'bottom' ) {
571
+ offset.y = svgY ? svgY : offset.y;
572
+
573
+ } else if ( typeof _this.cfg.legendPosition == 'object' ) {
574
+ offset.x = _this.cfg.legendPosition.left;
575
+ offset.y = _this.cfg.legendPosition.top;
576
+
577
+ } else {
578
+ offset.x = 0;
579
+ offset.y = 0;
580
+ }
581
+
582
+ // Overtake parent position if given; fixed 20/03/14 distinguish between relativ and others
583
+ } else {
584
+ if ( parent.style.position == 'relative' ) {
585
+ offset.x = svgX ? svgX : offset.x;
586
+ offset.y = svgY ? svgY : offset.y;
587
+ } else {
588
+ offset.x = svgX;
589
+ offset.y = svgY;
590
+ }
591
+ }
592
+
593
+ _this.processing.buffer.push([svgClone, AmCharts.extend({}, offset)]);
594
+
595
+ // Put back from "cache"
596
+ if (svgY && svgX) {
597
+ offset = tmp;
598
+
599
+ // New offset for next one
600
+ } else {
601
+ offset.y += svgY ? 0 : parent.offsetHeight;
602
+ }
603
+
604
+ if (_this.DEBUG == 10) {
605
+ _this.log('BUFFERED', svgs[i], offset);
606
+ } // DEBUG
607
+ }
608
+ if (_this.DEBUG == 10) {
609
+ _this.log('END BUFFERING');
610
+ } // DEBUG
611
+
612
+ // Apply background
613
+ if (_this.DEBUG == 10) {
614
+ _this.log('START DRAWING', cfg.render);
615
+ } // DEBUG
616
+ if (_this.DEBUG == 10) {
617
+ _this.log('FILL BACKGROUND');
618
+ } // DEBUG
619
+ canvas.id = AmCharts.getUniqueId();
620
+ canvas.width = _this.chart.divRealWidth;
621
+ canvas.height = _this.chart.divRealHeight;
622
+
623
+ // External legend exception
624
+ if ( _this.chart.legend && _this.chart.legend.position == "outside" ) {
625
+ if ( ['left','right'].indexOf(_this.cfg.legendPosition) != -1 ) {
626
+ canvas.width += _this.chart.legend.div.offsetWidth;
627
+
628
+ } else if ( typeof _this.cfg.legendPosition == 'object' ) {
629
+ canvas.width += _this.cfg.legendPosition.width;
630
+ canvas.height += _this.cfg.legendPosition.height;
631
+
632
+ } else {
633
+ canvas.height += _this.chart.legend.div.offsetHeight;
634
+ }
635
+ }
636
+
637
+ // Stockchart exception
638
+ var adapted = {
639
+ width: false,
640
+ height: false
641
+ };
642
+ if ( _this.chart.periodSelector ) {
643
+ if ( ['left','right'].indexOf(_this.chart.periodSelector.position) != -1 ) {
644
+ canvas.width -= _this.chart.periodSelector.div.offsetWidth + 16;
645
+ adapted.width = true;
646
+ } else {
647
+ canvas.height -= _this.chart.periodSelector.div.offsetHeight;
648
+ adapted.height = true;
649
+ }
650
+ }
651
+
652
+ if ( _this.chart.dataSetSelector ) {
653
+ if ( ['left','right'].indexOf(_this.chart.dataSetSelector.position) != -1 ) {
654
+ if ( !adapted.width ) {
655
+ canvas.width -= _this.chart.dataSetSelector.div.offsetWidth + 16;
656
+ }
657
+ } else {
658
+ canvas.height -= _this.chart.dataSetSelector.div.offsetHeight;
659
+ }
660
+ }
661
+
662
+ // Set given background; jpeg default
663
+ if (cfg.backgroundColor || cfg.format == 'image/jpeg') {
664
+ context.fillStyle = cfg.backgroundColor || '#FFFFFF';
665
+ context.fillRect(0, 0, canvas.width, canvas.height);
666
+ }
667
+
668
+ /* PRIVATE
669
+ Recursive function to draw the images to the canvas;
670
+ @param none;
671
+ */
672
+ function drawItWhenItsLoaded() {
673
+ var img, buffer, offset, source;
674
+
675
+ // DRAWING PROCESS DONE
676
+ if (_this.processing.buffer.length == _this.processing.drawn || cfg.format == 'svg' ) {
677
+ if (_this.DEBUG == 10) {
678
+ _this.log('END DRAWING');
679
+ } // DEBUG
680
+ return callback();
681
+
682
+ // LOOPING LUI
683
+ } else {
684
+ if (_this.DEBUG == 10) {
685
+ _this.log('DRAW', _this.processing.drawn + 1, 'OF', _this.processing.buffer.length);
686
+ } // DEBUG
687
+
688
+ buffer = _this.processing.buffer[_this.processing.drawn];
689
+ source = new XMLSerializer().serializeToString(buffer[0]); //source = 'data:image/svg+xml;base64,' + btoa();
690
+ offset = buffer[1];
691
+
692
+ if (_this.DEBUG == 10) {
693
+ _this.log('SOURCE', source);
694
+ } // DEBUG
695
+
696
+ // NATIVE
697
+ if (cfg.render == 'browser') {
698
+ img = new Image();
699
+ img.id = AmCharts.getUniqueId();
700
+ source = 'data:image/svg+xml;base64,' + btoa(source);
701
+
702
+ //img.crossOrigin = "Anonymous";
703
+ img.onload = function() {
704
+ context.drawImage(this, buffer[1].x, buffer[1].y);
705
+ _this.processing.drawn++;
706
+
707
+ if (_this.DEBUG == 10) {
708
+ _this.log('ONLOAD', this);
709
+ } // DEBUG
710
+ drawItWhenItsLoaded();
711
+ };
712
+ img.onerror = function() {
713
+ if (_this.DEBUG == 10) {
714
+ _this.log('ONERROR', this);
715
+ } // DEBUG
716
+ context.drawImage(this, buffer[1].x, buffer[1].y);
717
+ _this.processing.drawn++;
718
+ drawItWhenItsLoaded();
719
+ };
720
+ img.src = source;
721
+
722
+ if (_this.DEBUG == 10) {
723
+ _this.log('ADD', img);
724
+ } // DEBUG
725
+ if (img.complete || typeof(img.complete) == 'undefined' || img.complete === undefined) {
726
+ if (_this.DEBUG == 10) {
727
+ _this.log('FORCE ONLOAD', img);
728
+ } // DEBUG
729
+ img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
730
+ img.src = source;
731
+ }
732
+
733
+ // CANVG
734
+ } else if (cfg.render == 'canvg') {
735
+ canvg(canvas, source, {
736
+ offsetX: offset.x,
737
+ offsetY: offset.y,
738
+ ignoreMouse: true,
739
+ ignoreAnimation: true,
740
+ ignoreDimensions: true,
741
+ ignoreClear: true,
742
+ renderCallback: function() {
743
+ _this.processing.drawn++;
744
+ drawItWhenItsLoaded();
745
+ }
746
+ });
747
+ }
748
+ }
749
+ }
750
+ return drawItWhenItsLoaded();
751
+ },
752
+
753
+ /*
754
+ Generates the export menu to trigger the exportation
755
+ @param none;
756
+ */
757
+ generateButtons: function() {
758
+ var _this = this,lvl = 0;
759
+
760
+ if(_this.div){
761
+ div = _this.div;
762
+ div.innerHTML = "";
763
+ }
764
+ else{
765
+ div = document.createElement('div'),
766
+ _this.div = div;
767
+ }
768
+
769
+ // Push sublings
770
+ function createList(items) {
771
+ var ul = document.createElement('ul');
772
+
773
+ ul.setAttribute('style', 'list-style: none; margin: 0; padding: 0;');
774
+
775
+ // Walkthrough items
776
+ for (var i = 0; i < items.length; i++) {
777
+ var li = document.createElement('li'),
778
+ img = document.createElement('img'),
779
+ a = document.createElement('a'),
780
+ item = items[i],
781
+ children = null,
782
+ itemStyle = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemStyle), items[i]);
783
+
784
+ // MERGE CFG
785
+ item = AmCharts.extend(AmCharts.extend({}, _this.cfg.menuItemOutput), item);
786
+
787
+ // ICON
788
+ if (item['icon']) {
789
+ img.alt = '';
790
+ img.src = item['icon'];
791
+ img.setAttribute('style', 'margin: 0 auto;border: none;outline: none');
792
+ if (item['iconTitle']) {
793
+ img.title = item['iconTitle'];
794
+ }
795
+ a.appendChild(img);
796
+ }
797
+
798
+ // TITLE; STYLING
799
+ a.href = '#';
800
+ if (item['title']) {
801
+ img.setAttribute('style', 'margin: 0px 5px;');
802
+ a.innerHTML += item.title;
803
+ }
804
+ a.setAttribute('style', 'display: block;');
805
+ AmCharts.extend(a.style, itemStyle);
806
+
807
+ // ONCLICK
808
+ a.onclick = item.onclick.bind(a, _this, item);
809
+ li.appendChild(a);
810
+
811
+ // APPEND SIBLINGS
812
+ if (item.items) {
813
+ children = createList(item.items);
814
+ li.appendChild(children);
815
+
816
+ li.onmouseover = function() {
817
+ children.style.display = 'block';
818
+ };
819
+ li.onmouseout = function() {
820
+ children.style.display = 'none';
821
+ };
822
+ children.style.display = 'none';
823
+ }
824
+
825
+ // Append to parent
826
+ ul.appendChild(li);
827
+
828
+ // Apply hover
829
+ a.onmouseover = function() {
830
+ this.style.backgroundColor = itemStyle.rollOverBackgroundColor;
831
+ this.style.color = itemStyle.rollOverColor;
832
+ this.style.borderColor = itemStyle.rollOverBorderColor;
833
+ };
834
+ a.onmouseout = function() {
835
+ this.style.backgroundColor = itemStyle.backgroundColor;
836
+ this.style.color = itemStyle.color;
837
+ this.style.borderColor = itemStyle.borderColor;
838
+ };
839
+ }
840
+ lvl++;
841
+
842
+ if (_this.DEBUG == 10) {
843
+ _this.log('MENU', ul);
844
+ } // DEBUG
845
+
846
+ return ul;
847
+ }
848
+
849
+ // Style wrapper; Push into chart div
850
+ div.setAttribute('style', 'position: absolute;top:' + _this.cfg.menuTop + ';right:' + _this.cfg.menuRight + ';bottom:' + _this.cfg.menuBottom + ';left:' + _this.cfg.menuLeft + ';');
851
+ div.setAttribute('class', 'amExportButton');
852
+ div.appendChild(createList(_this.cfg.menuItems));
853
+ _this.chart.containerDiv.appendChild(div);
854
+ }
667
855
  });