Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / geo / charting / widget / Legend.js

History | View | Annotate | Download (1.83 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.geo.charting.widget.Legend"]){
9
dojo._hasResource["dojox.geo.charting.widget.Legend"]=true;
10
dojo.provide("dojox.geo.charting.widget.Legend");
11
dojo.require("dijit._Widget");
12
dojo.require("dijit._Templated");
13
dojo.require("dojox.lang.functional.array");
14
dojo.require("dojox.lang.functional.fold");
15
dojo.declare("dojox.geo.charting.widget.Legend",[dijit._Widget,dijit._Templated],{templateString:"<table dojoAttachPoint='legendNode' class='dojoxLegendNode'><tbody dojoAttachPoint='legendBody'></tbody></table>",horizontal:true,legendNode:null,legendBody:null,swatchSize:18,postCreate:function(){
16
if(!this.map){
17
return;
18
}
19
this.series=this.map.series;
20
dojo.byId(this.map.container).appendChild(this.domNode);
21
this.refresh();
22
},refresh:function(){
23
while(this.legendBody.lastChild){
24
dojo.destroy(this.legendBody.lastChild);
25
}
26
if(this.horizontal){
27
dojo.addClass(this.legendNode,"dojoxLegendHorizontal");
28
this._tr=dojo.doc.createElement("tr");
29
this.legendBody.appendChild(this._tr);
30
}
31
var s=this.series;
32
if(s.length==0){
33
return;
34
}
35
dojo.forEach(s,function(x){
36
this._addLabel(x.color,x.name);
37
},this);
38
},_addLabel:function(_1,_2){
39
var _3=dojo.doc.createElement("td");
40
var _4=dojo.doc.createElement("td");
41
var _5=dojo.doc.createElement("div");
42
dojo.addClass(_3,"dojoxLegendIcon");
43
dojo.addClass(_4,"dojoxLegendText");
44
_5.style.width=this.swatchSize+"px";
45
_5.style.height=this.swatchSize+"px";
46
_3.appendChild(_5);
47
if(this.horizontal){
48
this._tr.appendChild(_3);
49
this._tr.appendChild(_4);
50
}else{
51
var tr=dojo.doc.createElement("tr");
52
this.legendBody.appendChild(tr);
53
tr.appendChild(_3);
54
tr.appendChild(_4);
55
}
56
_5.style.background=_1;
57
_4.innerHTML=String(_2);
58
}});
59
}