//>>built define("dojo/_base/declare dijit/_WidgetBase dojox/gfx dojo/_base/array dojo/has dojo/has!dojo-bidi?../bidi/widget/Legend dojox/lang/functional dojo/dom dojo/dom-construct dojo/dom-class dijit/registry".split(" "),function(n,g,q,f,k,r,l,t,d,m,p){g=n(k("dojo-bidi")?"dojox.charting.widget.NonBidiLegend":"dojox.charting.widget.Legend",g,{chartRef:"",horizontal:!0,swatchSize:18,legendBody:null,postCreate:function(){!this.chart&&this.chartRef&&((this.chart=p.byId(this.chartRef)||p.byNode(t.byId(this.chartRef)))|| console.log("Could not find chart instance with id: "+this.chartRef));this.chart=this.chart.chart||this.chart;this.refresh()},buildRendering:function(){this.domNode=d.create("table",{role:"group","aria-label":"chart legend","class":"dojoxLegendNode"});this.legendBody=d.create("tbody",null,this.domNode);this.inherited(arguments)},destroy:function(){this._surfaces&&f.forEach(this._surfaces,function(a){a.destroy()});this.inherited(arguments)},refresh:function(){this._surfaces&&f.forEach(this._surfaces, function(c){c.destroy()});for(this._surfaces=[];this.legendBody.lastChild;)d.destroy(this.legendBody.lastChild);this.horizontal&&(m.add(this.domNode,"dojoxLegendHorizontal"),this._tr=d.create("tr",null,this.legendBody),this._inrow=0);var a=this.series||this.chart.series;if(0!=a.length)if("dojox.charting.plot2d.Pie"==a[0].chart.stack[0].declaredClass){var b=a[0].chart.stack[0];"number"==typeof b.run.data[0]?(a=l.map(b.run.data,"Math.max(x, 0)"),a=l.map(a,"/this",l.foldl(a,"+",0)),f.forEach(a,function(c, a){this._addLabel(b.dyn[a],b._getLabel(100*c)+"%")},this)):f.forEach(b.run.data,function(a,e){this._addLabel(b.dyn[e],a.legend||a.text||a.y)},this)}else f.forEach(a,function(a){this._addLabel(a.dyn,a.legend||a.name)},this)},_addLabel:function(a,b){var c=d.create("td"),e=d.create("div",null,c),h=d.create("label",null,c),f=d.create("div",{style:{width:this.swatchSize+"px",height:this.swatchSize+"px","float":"left"}},e);m.add(e,"dojoxLegendIcon dijitInline");m.add(h,"dojoxLegendText");this._tr?(this._tr.appendChild(c), ++this._inrow===this.horizontal&&(this._tr=d.create("tr",null,this.legendBody),this._inrow=0)):d.create("tr",null,this.legendBody).appendChild(c);this._makeIcon(f,a);h.innerHTML=String(b);k("dojo-bidi")&&(h.dir=this.getTextDir(b,h.dir))},_makeIcon:function(a,b){var c=this.swatchSize,e=this.swatchSize;a=q.createSurface(a,e,c);this._surfaces.push(a);if(b.fill)a.createRect({x:2,y:2,width:e-4,height:c-4}).setFill(b.fill).setStroke(b.stroke);else if(b.stroke||b.marker){var d={x1:0,y1:c/2,x2:e,y2:c/2}; b.stroke&&a.createLine(d).setStroke(b.stroke);b.marker&&a.createPath({path:"M"+e/2+" "+c/2+" "+b.marker}).setFill(b.markerFill).setStroke(b.markerStroke)}else a.createRect({x:2,y:2,width:e-4,height:c-4}).setStroke("black"),a.createLine({x1:2,y1:2,x2:e-2,y2:c-2}).setStroke("black"),a.createLine({x1:2,y1:c-2,x2:e-2,y2:2}).setStroke("black")}});return k("dojo-bidi")?n("dojox.charting.widget.Legend",[g,r]):g});