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