Ext.define('Ext.pivot.d3.HeatMap',{extend:'Ext.d3.HeatMap',xtype:'pivotheatmap',requires:['Ext.pivot.matrix.Local','Ext.pivot.matrix.Remote'],padding:{top:20,right:30,bottom:20,left:80},config:{defaultFormatter:'number("0.00")',matrix:{type:'local',rowGrandTotalsPosition:'none',colGrandTotalsPosition:'none'},xAxis:{axis:{orient:'bottom'},scale:{type:'band'},step:100},yAxis:{axis:{orient:'left'},scale:{type:'band'},step:100},colorAxis:{scale:{type:'linear',range:['white','green']}},tiles:{attr:{'stroke':'green','stroke-width':1},labels:!0},legend:{docked:'bottom',padding:60,items:{count:10,slice:[1],size:{x:40,y:20}}}},destroy:function(){this.setMatrix(null);this.callParent()},applyMatrix:function(a){if(a){if(!a.isPivotMatrix){if(!a.type){a.type='local'}a.cmp=this;a=Ext.Factory.pivotmatrix(a)}}return a},updateMatrix:function(b,c){var a=this;Ext.destroy(c,a.matrixListeners);a.matrixListeners=null;if(b){a.matrixListeners=b.on({done:a.onMatrixDataReady,scope:a,destroyable:!0})}},updateStore:Ext.emptyFn,updateXAxis:Ext.emptyFn,updateYAxis:Ext.emptyFn,updateColorAxis:Ext.emptyFn,onMatrixDataReady:function(b){var e=this,c=e.getXAxis(),d=e.getYAxis(),f=e.getColorAxis(),g=b.topAxis.dimensions,h=b.leftAxis.dimensions,i=b.aggregate,a;if(g.getCount()&&c){a=g.getAt(0);c.setField(a.getDataIndex());c.setTitle({text:a.getHeader()})}if(h.getCount()&&d){a=h.getAt(0);d.setField(a.getDataIndex());d.setTitle({text:a.getHeader()})}if(i.getCount()&&f){a=i.getAt(0);f.setField(a.getId())}this.processData();this.performLayout()},bindFormatter:function(a,b){var c=this;return function(d){return a(d,b||c.resolveListenerScope())}},getStoreData:function(){var c=this,h=c.getMatrix(),i=h.leftAxis.getTree(),n=i.length,j=h.topAxis.getTree(),o=j.length,l=[],r=c.getXAxis(),s=c.getYAxis(),m=c.getColorAxis(),p=r.getField(),q=s.getField(),k=m.getField(),d,e,f,g,b,a;for(d=0;d<n;d++){f=i[d];for(e=0;e<o;e++){g=j[e];b=h.results.get(f.key,g.key);a={data:{}};a.data[p]=g.name;a.data[q]=f.name;a.data[k]=b?b.getValue(k):null;a.data.records=b?b.records.length:0;l.push(a)}}return l},onUpdateTiles:function(e){var b=this,f=b.getMatrix(),i=b.getColorAxis(),h=i.getField(),c,a,g,d;if(f.aggregate.getCount()){c=f.aggregate.getAt(0);a=c.getFormatter()||b.getDefaultFormatter();g=c.getScope();d=Ext.app.bind.Parser.fly(a);a=b.bindFormatter(d.compileFormat(),g);d.release()}b.callParent([e]);e.select('text').text(function(d){var b=d.data[h]||null;if(b!==null&&c&&a){b=a(b)}return b!==null?b:null})}});Ext.define('Ext.pivot.d3.AbstractContainer',{extend:'Ext.panel.Panel',requires:['Ext.pivot.d3.HeatMap','Ext.pivot.plugin.Configurator'],isPivotComponent:!0,config:{matrix:{type:'local'},drawing:{xtype:'pivotheatmap'},configurator:null},destroy:function(){this.setMatrix(null);this.callParent()},addDrawing:function(){this.add(Ext.applyIf({matrix:this.getMatrix()},this.getDrawing()))},applyMatrix:function(a,b){Ext.destroy(b);if(a==null){return a}if(a&&a.isPivotMatrix){a.cmp=this;return a}Ext.applyIf(a,{type:'local'});a.cmp=this;return Ext.Factory.pivotmatrix(a)},applyConfigurator:function(a){return a?this.addPlugin(a):null},updateConfigurator:function(b,a){if(a){this.removePlugin(a)}}});Ext.define('Ext.pivot.d3.TreeMap',{extend:'Ext.d3.hierarchy.TreeMap',xtype:'pivottreemap',requires:['Ext.pivot.matrix.Local','Ext.pivot.matrix.Remote'],config:{autoExpand:!0,matrix:{type:'local',rowGrandTotalsPosition:'none',colGrandTotalsPosition:'none'},store:{type:'tree',fields:['name','value',{name:'records',type:'int'}],root:{expanded:!0,name:'Root',children:[]}},nodeValue:function(a){return a.data.value},colorAxis:{scale:{range:['#E45649','#ECECEC','#50A14F']},processor:function(e,b,c,d){var a=c.data;return a.isLeaf()?b(a.get('depth')-5):'#ececec'}}},destroy:function(){this.setMatrix(null);this.callParent()},applyMatrix:function(a){if(a){if(!a.isPivotMatrix){if(!a.type){a.type='local'}a.cmp=this;a=Ext.Factory.pivotmatrix(a)}}return a},updateMatrix:function(b,c){var a=this;Ext.destroy(c,a.matrixListeners);a.matrixListeners=null;if(b){a.matrixListeners=b.on({done:a.onMatrixDataReady,scope:a,destroyable:!0})}},onMatrixDataReady:function(d){var a=this,e=a.getColorAxis(),g=d.aggregate,b=a.getStore().getRoot(),c,f;if(g.getCount()&&e){c=g.getAt(0).getId();e.setField(c)}f=a.getTreeStoreData(d.leftAxis.getTree(),c);if(b){b.removeAll();b.appendChild(f)}a.performLayout()},getTreeStoreData:function(f,g){var i=[],e=this.getMatrix(),j=this.getAutoExpand(),d,h,b,c,a;if(f&&e){h=f.length;for(d=0;d<h;d++){b=f[d];a=e.results.get(b.key,e.grandTotalKey);if(a){c={path:b.key,name:b.name,value:a?a.getValue(g):null,records:a&&a.records?a.records.length:0};if(b.children){c.children=this.getTreeStoreData(b.children,g);c.expanded=j}else {c.leaf=!0}i.push(c)}}}return i}});Ext.define('Ext.pivot.d3.Container',{extend:'Ext.pivot.d3.AbstractContainer',xtype:'pivotd3container',config:{configurator:{id:'configurator',ptype:'pivotconfigurator'}},layout:'fit',beforeRender:function(){this.addDrawing();this.callParent()}});