//>>built
define("dojox/widget/DataPresentation",["dojo","dijit","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(f,H,q){f.provide("dojox.widget.DataPresentation");f.experimental("dojox.widget.DataPresentation");f.require("dojox.grid.DataGrid");f.require("dojox.charting.Chart2D");f.require("dojox.charting.widget.Legend");f.require("dojox.charting.action2d.Tooltip");
f.require("dojox.charting.action2d.Highlight");f.require("dojo.colors");f.require("dojo.data.ItemFileWriteStore");(function(){var D=function(b,c,a,e){var r=[{value:0,text:""}],f=b.length;if("ClusteredBars"!==a&&"StackedBars"!==a&&(a=e.offsetWidth,e=(""+b[0]).length*b.length*7,1==c))for(var h=1;500>h&&!(e/h<a);++h)++c;for(a=0;a<f;a++)r.push({value:a+1,text:!c||a%c?"":b[a]});r.push({value:f+1,text:""});return r},E=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},C=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},F=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},G=function(b,c,a,e,r,n,h,w,l,t,x){c||(b.innerHTML="",c=new q.charting.Chart2D(b));h&&(h._clone=function(){var a=new q.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:f.delegate(this.colors)});a.markers=this.markers;a._buildMarkerArray();return a},c.setTheme(h));var A=l.series_data[0].slice(0);e&&A.reverse();b=D(A,n,a,b);n={};t=h=null;x={};for(var v in c.runs)x[v]=!0;for(var d=l.series_name.length,g=0;g<d;g++)if(l.series_chart[g]&&0<l.series_data[g].length){var m=a,k=l.series_axis[g];"Hybrid"==m&&(m="line"==l.series_charttype[g]?
"Hybrid-Lines":"Hybrid-ClusteredColumns");n[k]||(n[k]={});if(!n[k][m]){var p=k+"-"+m;c.addPlot(p,F(m,k,r));var u={};"string"==typeof w?u.text=function(a){return f.replace(w,[a.element,a.run.name,A[a.index],"ClusteredBars"===m||"StackedBars"===m?a.x:a.y])}:"function"==typeof w&&(u.text=w);new q.charting.action2d.Tooltip(c,p,u);"Lines"!==m&&"Hybrid-Lines"!==m&&new q.charting.action2d.Highlight(c,p);n[k][m]=!0}for(var p=[],u=l.series_data[g].length,y=0;y<u;y++){var z=l.series_data[g][y];p.push(z);if(null===
h||z>h)h=z;if(null===t||z<t)t=z}e&&p.reverse();k={plot:k+"-"+m};l.series_linestyle[g]&&(k.stroke={style:l.series_linestyle[g]});c.addSeries(l.series_name[g],p,k);delete x[l.series_name[g]]}for(v in x)c.removeSeries(v);c.addAxis("independent",E(a,b));c.addAxis("dependent-primary",C(a,"primary",t,h));c.addAxis("dependent-secondary",C(a,"secondary",t,h));return c},B=function(b,c){var a=b;if(c)for(var e=c.split(/[.\[\]]+/),f=0,n=e.length;f<n;f++)a&&(a=a[e[f]]);return a};f.declare("dojox.widget.DataPresentation",
null,{type:"chart",chartType:"clusteredBars",reverse:!1,animate:null,labelMod:1,legendHorizontal:!0,constructor:function(b,c){f.mixin(this,c);this.domNode=f.byId(b);this[this.type+"Node"]=this.domNode;"string"==typeof this.theme&&(this.theme=f.getObject(this.theme));this.chartNode=f.byId(this.chartNode);this.legendNode=f.byId(this.legendNode);this.gridNode=f.byId(this.gridNode);this.titleNode=f.byId(this.titleNode);this.footerNode=f.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;f.xhrGet({url:this.url,content:this.urlContent,handleAs:"json-comment-optional",load:function(a,b){e.setData(a)},error:function(a,b){e.urlError&&"function"==typeof e.urlError&&e.urlError(a,b)}});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=[],r=[],n=[],h=[],w=[],l=[],t=[],x=[],q=[],v=0,d=0;d<a.length;d++)e[d]=B(this.data,a[d].datapoints),e[d]&&e[d].length>v&&(v=e[d].length),r[d]=[],n[d]=a[d].name||(a[d].namefield?B(this.data,a[d].namefield):
null)||"series "+d,h[d]=!1!==a[d].chart,w[d]=a[d].charttype||"bar",l[d]=a[d].linestyle,t[d]=a[d].axis||"primary",x[d]=!1!==a[d].grid,q[d]=a[d].gridformatter;var g,m,k,p,u=[];for(g=0;g<v;g++){m={index:g};for(d=0;d<a.length;d++)e[d]&&e[d].length>g&&(k=B(e[d][g],a[d].field),h[d]&&(p=parseFloat(k),isNaN(p)||(k=p)),m["data."+d]=k,r[d].push(k));u.push(m)}0>=v&&u.push({index:0});a=new f.data.ItemFileWriteStore({data:{identifier:"index",items:u}});this.data.title&&(a.title=this.data.title);this.data.footer&&
(a.footer=this.data.footer);a.series_data=r;a.series_name=n;a.series_chart=h;a.series_charttype=w;a.series_linestyle=l;a.series_axis=t;a.series_grid=x;a.series_gridformatter=q;this.setPreparedStore(a);if(c&&0<this.refreshInterval){var y=this;this.refreshIntervalPending=setInterval(function(){y.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=G(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 q.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 q.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="")}})})()});