//>>built
define("dojox/widget/DataPresentation",["dijit","dojo","dojox","dojo/require!dojox/grid/DataGrid,dojox/charting/Chart2D,dojox/charting/widget/Legend,dojox/charting/action2d/Tooltip,dojox/charting/action2d/Highlight,dojo/colors,dojo/data/ItemFileWriteStore"],function(I,g,y){g.provide("dojox.widget.DataPresentation");g.experimental("dojox.widget.DataPresentation");g.require("dojox.grid.DataGrid");g.require("dojox.charting.Chart2D");g.require("dojox.charting.widget.Legend");g.require("dojox.charting.action2d.Tooltip");
g.require("dojox.charting.action2d.Highlight");g.require("dojo.colors");g.require("dojo.data.ItemFileWriteStore");(function(){var E=function(b,c,a,e){var f=[{value:0,text:""}],k=b.length;if("ClusteredBars"!==a&&"StackedBars"!==a&&(a=e.offsetWidth,e=(""+b[0]).length*b.length*7,1==c))for(var l=1;500>l&&!(e/l<a);++l)++c;for(a=0;a<k;a++)f.push({value:a+1,text:!c||a%c?"":b[a]});f.push({value:k+1,text:""});return f},F=function(b,c){var a={vertical:!1,labels:c,min:0,max:c.length-1,majorTickStep:1,minorTickStep:1};
if("ClusteredBars"===b||"StackedBars"===b)a.vertical=!0;if("Lines"===b||"Areas"===b||"StackedAreas"===b)a.min++,a.max--;return a},D=function(b,c,a,e){var f={vertical:!0,fixLower:"major",fixUpper:"major",natural:!0};"secondary"===c&&(f.leftBottom=!1);if("ClusteredBars"===b||"StackedBars"===b)f.vertical=!1;a==e&&(f.min=a-1,f.max=e+1);return f},G=function(b,c,a){c={type:b,hAxis:"independent",vAxis:"dependent-"+c,gap:4,lines:!1,areas:!1,markers:!1};if("ClusteredBars"===b||"StackedBars"===b)c.hAxis=c.vAxis,
c.vAxis="independent";if("Lines"===b||"Hybrid-Lines"===b||"Areas"===b||"StackedAreas"===b)c.lines=!0;if("Areas"===b||"StackedAreas"===b)c.areas=!0;"Lines"===b&&(c.markers=!0);"Hybrid-Lines"===b&&(c.shadows={dx:2,dy:2,dw:2},c.type="Lines");"Hybrid-ClusteredColumns"===b&&(c.type="ClusteredColumns");a&&(c.animate=a);return c},H=function(b,c,a,e,f,k,l,w,m,r,x){c||(b.innerHTML="",c=new y.charting.Chart2D(b));l&&(l._clone=function(){var t=new y.charting.Theme({chart:this.chart,plotarea:this.plotarea,axis:this.axis,
series:this.series,marker:this.marker,antiAlias:this.antiAlias,assignColors:this.assignColors,assignMarkers:this.assigneMarkers,colors:g.delegate(this.colors)});t.markers=this.markers;t._buildMarkerArray();return t},c.setTheme(l));var z=m.series_data[0].slice(0);e&&z.reverse();b=E(z,k,a,b);k={};r=l=null;x={};for(var u in c.runs)x[u]=!0;for(var d=m.series_name.length,h=0;h<d;h++)if(m.series_chart[h]&&0<m.series_data[h].length){var n=a,p=m.series_axis[h];"Hybrid"==n&&(n="line"==m.series_charttype[h]?
"Hybrid-Lines":"Hybrid-ClusteredColumns");k[p]||(k[p]={});if(!k[p][n]){var q=p+"-"+n;c.addPlot(q,G(n,p,f));var v={};"string"==typeof w?v.text=function(t){return g.replace(w,[t.element,t.run.name,z[t.index],"ClusteredBars"===n||"StackedBars"===n?t.x:t.y])}:"function"==typeof w&&(v.text=w);new y.charting.action2d.Tooltip(c,q,v);"Lines"!==n&&"Hybrid-Lines"!==n&&new y.charting.action2d.Highlight(c,q);k[p][n]=!0}q=[];v=m.series_data[h].length;for(var A=0;A<v;A++){var B=m.series_data[h][A];q.push(B);if(null===
l||B>l)l=B;if(null===r||B<r)r=B}e&&q.reverse();p={plot:p+"-"+n};m.series_linestyle[h]&&(p.stroke={style:m.series_linestyle[h]});c.addSeries(m.series_name[h],q,p);delete x[m.series_name[h]]}for(u in x)c.removeSeries(u);c.addAxis("independent",F(a,b));c.addAxis("dependent-primary",D(a,"primary",r,l));c.addAxis("dependent-secondary",D(a,"secondary",r,l));return c},C=function(b,c){var a=b;if(c)for(var e=c.split(/[.\[\]]+/),f=0,k=e.length;f<k;f++)a&&(a=a[e[f]]);return a};g.declare("dojox.widget.DataPresentation",
null,{type:"chart",chartType:"clusteredBars",reverse:!1,animate:null,labelMod:1,legendHorizontal:!0,constructor:function(b,c){g.mixin(this,c);this.domNode=g.byId(b);this[this.type+"Node"]=this.domNode;"string"==typeof this.theme&&(this.theme=g.getObject(this.theme));this.chartNode=g.byId(this.chartNode);this.legendNode=g.byId(this.legendNode);this.gridNode=g.byId(this.gridNode);this.titleNode=g.byId(this.titleNode);this.footerNode=g.byId(this.footerNode);this.legendVertical&&(this.legendHorizontal=
!this.legendVertical);this.url?this.setURL(null,null,this.refreshInterval):this.data?this.setData(null,this.refreshInterval):this.setStore()},setURL:function(b,c,a){a&&this.cancelRefresh();this.url=b||this.url;this.urlContent=c||this.urlContent;this.refreshInterval=a||this.refreshInterval;var e=this;g.xhrGet({url:this.url,content:this.urlContent,handleAs:"json-comment-optional",load:function(f,k){e.setData(f)},error:function(f,k){e.urlError&&"function"==typeof e.urlError&&e.urlError(f,k)}});a&&0<
this.refreshInterval&&(this.refreshIntervalPending=setInterval(function(){e.setURL()},this.refreshInterval))},setData:function(b,c){c&&this.cancelRefresh();this.data=b||this.data;this.refreshInterval=c||this.refreshInterval;for(var a="function"==typeof this.series?this.series(this.data):this.series,e=[],f=[],k=[],l=[],w=[],m=[],r=[],x=[],z=[],u=0,d=0;d<a.length;d++)e[d]=C(this.data,a[d].datapoints),e[d]&&e[d].length>u&&(u=e[d].length),f[d]=[],k[d]=a[d].name||(a[d].namefield?C(this.data,a[d].namefield):
null)||"series "+d,l[d]=!1!==a[d].chart,w[d]=a[d].charttype||"bar",m[d]=a[d].linestyle,r[d]=a[d].axis||"primary",x[d]=!1!==a[d].grid,z[d]=a[d].gridformatter;var h,n=[];for(h=0;h<u;h++){var p={index:h};for(d=0;d<a.length;d++)if(e[d]&&e[d].length>h){var q=C(e[d][h],a[d].field);if(l[d]){var v=parseFloat(q);isNaN(v)||(q=v)}p["data."+d]=q;f[d].push(q)}n.push(p)}0>=u&&n.push({index:0});a=new g.data.ItemFileWriteStore({data:{identifier:"index",items:n}});this.data.title&&(a.title=this.data.title);this.data.footer&&
(a.footer=this.data.footer);a.series_data=f;a.series_name=k;a.series_chart=l;a.series_charttype=w;a.series_linestyle=m;a.series_axis=r;a.series_grid=x;a.series_gridformatter=z;this.setPreparedStore(a);if(c&&0<this.refreshInterval){var A=this;this.refreshIntervalPending=setInterval(function(){A.setData()},this.refreshInterval)}},refresh:function(){this.url?this.setURL(this.url,this.urlContent,this.refreshInterval):this.data&&this.setData(this.data,this.refreshInterval)},cancelRefresh:function(){this.refreshIntervalPending&&
(clearInterval(this.refreshIntervalPending),this.refreshIntervalPending=void 0)},setStore:function(b,c,a){this.setPreparedStore(b,c,a)},setPreparedStore:function(b,c,a){this.preparedstore=b||this.store;this.query=c||this.query;this.queryOptions=a||this.queryOptions;if(this.preparedstore){this.chartNode&&(this.chartWidget=H(this.chartNode,this.chartWidget,this.chartType,this.reverse,this.animate,this.labelMod,this.theme,this.tooltip,this.preparedstore,this.query,this.queryOptions),this.renderChartWidget());
this.legendNode&&((b=this.legendWidget)?b.refresh():b=new y.charting.widget.Legend({chart:this.chartWidget,horizontal:this.legendHorizontal},this.legendNode),this.legendWidget=b);if(this.gridNode){b=this.preparedstore;a=this.query;var e=this.queryOptions;c=this.gridWidget||new y.grid.DataGrid({},this.gridNode);c.startup();c.setStore(b,a,e);a=[];for(e=0;e<b.series_name.length;e++)b.series_grid[e]&&0<b.series_data[e].length&&a.push({field:"data."+e,name:b.series_name[e],width:"auto",formatter:b.series_gridformatter[e]});
c.setStructure(a);this.gridWidget=c;this.renderGridWidget()}this.titleNode&&(b=this.preparedstore,b.title&&(this.titleNode.innerHTML=b.title));this.footerNode&&(b=this.preparedstore,b.footer&&(this.footerNode.innerHTML=b.footer))}},renderChartWidget:function(){this.chartWidget&&this.chartWidget.render()},renderGridWidget:function(){this.gridWidget&&this.gridWidget.render()},getChartWidget:function(){return this.chartWidget},getGridWidget:function(){return this.gridWidget},destroy:function(){this.cancelRefresh();
this.chartWidget&&(this.chartWidget.destroy(),delete this.chartWidget);this.legendWidget&&delete this.legendWidget;this.gridWidget&&delete this.gridWidget;this.chartNode&&(this.chartNode.innerHTML="");this.legendNode&&(this.legendNode.innerHTML="");this.gridNode&&(this.gridNode.innerHTML="");this.titleNode&&(this.titleNode.innerHTML="");this.footerNode&&(this.footerNode.innerHTML="")}})})()});