| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
<![if gte IE 9]> |
| 13 |
<!DOCTYPE HTML> |
| 14 |
<html lang="en"> |
| 15 |
<head> |
| 16 |
<![endif]> |
| 17 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 18 |
<title>Spider 2D</title> |
| 19 |
<style type="text/css"> |
| 20 |
@import "../../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../../dijit/tests/css/dijitTests.css"; |
| 22 |
@import "../../../../dijit/themes/claro/claro.css"; |
| 23 |
@import "../../resources/Legend.css"; |
| 24 |
|
| 25 |
.dojoxLegendItem{ |
| 26 |
padding: 3px 5px 2px 5px; |
| 27 |
} |
| 28 |
.dojoxLegendItem .dojoxLegendText{ |
| 29 |
float: right; |
| 30 |
margin-top: 2px; |
| 31 |
} |
| 32 |
.dojoxLegendItem .dojoxLegendIcon{ |
| 33 |
float: left; |
| 34 |
} |
| 35 |
.dojoxLegendItemRtl{ |
| 36 |
padding: 3px 5px 2px 5px; |
| 37 |
} |
| 38 |
.dojoxLegendItemRtl .dojoxLegendText{ |
| 39 |
float: left; |
| 40 |
margin-top: 2px; |
| 41 |
} |
| 42 |
.dojoxLegendItemRtl .dojoxLegendIcon{ |
| 43 |
float: right; |
| 44 |
} |
| 45 |
.dojoxLegendHover{ |
| 46 |
background-color: #afd9ff; |
| 47 |
cursor: pointer; |
| 48 |
padding: 3px 5px 2px 5px; |
| 49 |
} |
| 50 |
.dojoxLegendActive{ |
| 51 |
cursor: pointer; |
| 52 |
border: 2px solid #7dbefa; |
| 53 |
padding: 1px 3px 0 3px; |
| 54 |
} |
| 55 |
</style> |
| 56 |
<script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, has:{'dojo-bidi': true}"></script> |
| 57 |
<script type="text/javascript"> |
| 58 |
dojo.require("dojo.parser"); |
| 59 |
dojo.require("doh.runner"); |
| 60 |
|
| 61 |
dojo.require("dojox.charting.Chart"); |
| 62 |
dojo.require("dojox.charting.plot2d.Spider"); |
| 63 |
dojo.require("dojox.charting.themes.PlotKit.blue"); |
| 64 |
dojo.require("dijit.form.CheckBox"); |
| 65 |
dojo.require("dijit.form.RadioButton"); |
| 66 |
dojo.require("dijit.form.Form"); |
| 67 |
dojo.require("dojo.fx.easing"); |
| 68 |
dojo.require("dojox.gfx.fx"); |
| 69 |
dojo.require("dojox.charting.widget.SelectableLegend"); |
| 70 |
|
| 71 |
var dc = dojox.charting, |
| 72 |
divisions = 7, |
| 73 |
stype = "polygon", |
| 74 |
easing = dojo.fx.easing.backOut; |
| 75 |
var empty = {}; |
| 76 |
var populateSelect = function(from, select){ |
| 77 |
var module = dojo.getObject(from); |
| 78 |
for(var name in module){ |
| 79 |
if(name in empty){ continue; } |
| 80 |
var fun = module[name]; |
| 81 |
if(dojo.isFunction(fun)){ |
| 82 |
dojo.create("option", { |
| 83 |
value: from + "." + name, |
| 84 |
selected: name == "backOut", |
| 85 |
innerHTML: from + "." + name |
| 86 |
}, select); |
| 87 |
} |
| 88 |
} |
| 89 |
}; |
| 90 |
|
| 91 |
var chart1, legend1; |
| 92 |
makeObjects = function(){ |
| 93 |
chart1 = new dojox.charting.Chart("test1",{textDir:"rtl"}); |
| 94 |
chart1.setTheme(dojox.charting.themes.PlotKit.blue); |
| 95 |
chart1.addPlot("default", { |
| 96 |
type: "Spider", |
| 97 |
labelOffset: -10, |
| 98 |
divisions: divisions, |
| 99 |
axisColor: "lightgray", |
| 100 |
spiderColor: "silver", |
| 101 |
seriesFillAlpha: 0.2, |
| 102 |
spiderOrigin: 0.16, |
| 103 |
markerSize: 3, |
| 104 |
precision: 0, |
| 105 |
spiderType: stype |
| 106 |
}); |
| 107 |
chart1.addSeries("China.", {data: {"GDP.": 2,"area.": 6,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 2000,"inflation.": 15,"growth.": 12}}, { fill: "blue" }); |
| 108 |
chart1.addSeries("\u05e6\u05e8\u05e4\u05ea.", {data: {"GDP.": 6,"area.": 15,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 500,"inflation.": 5,"growth.": 6}}, { fill: "red" }); |
| 109 |
chart1.addSeries("USA.", {data: {"GDP.": 3,"area.": 20,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 1500,"inflation.": 10,"growth.": 3}}, { fill: "green" }); |
| 110 |
chart1.addSeries("Start \u05e1\u05d5\u05e3.", {data: {"GDP.": 4,"area.": 2,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 1000,"inflation.": 20,"growth.": 2}}, { fill: "yellow" }); |
| 111 |
chart1.addSeries("\u05d4\u05ea\u05d7\u05dc\u05d4 end.", {data: {"GDP.": 10,"area.": 10,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 800,"inflation.": 2,"growth.": 18}}, { fill: "orange" }); |
| 112 |
chart1.addSeries("Canada.", {data: {"GDP.": 1,"area.": 18,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 300,"inflation.": 3,"growth.": 15}}, { fill: "purple" }); |
| 113 |
chart1.render(); |
| 114 |
|
| 115 |
legend1 = new dc.widget.SelectableLegend({chart: chart1, horizontal: true}, "legend1"); |
| 116 |
|
| 117 |
// prepare and enable controls |
| 118 |
populateSelect("dojo.fx.easing", "easing"); |
| 119 |
}; |
| 120 |
|
| 121 |
dojo.addOnLoad(function(){ |
| 122 |
makeObjects(); |
| 123 |
|
| 124 |
doh.register("parse", function(){ |
| 125 |
dojo.parser.parse(); |
| 126 |
}); |
| 127 |
|
| 128 |
doh.register("test textDir", [ |
| 129 |
{ |
| 130 |
name: "Spider chart and legend.", |
| 131 |
|
| 132 |
runTest: function(){ |
| 133 |
doh.is("rtl", chart1.textDir, "textDir of : chart1"); |
| 134 |
doh.is("rtl", legend1.textDir, "textDir of : legend1"); |
| 135 |
|
| 136 |
} |
| 137 |
} |
| 138 |
]); |
| 139 |
|
| 140 |
doh.run(); |
| 141 |
|
| 142 |
}); |
| 143 |
|
| 144 |
</script> |
| 145 |
|
| 146 |
<script type="text/javascript"> |
| 147 |
function switchData(val){ |
| 148 |
if(val == "b1"){ |
| 149 |
chart1.updateSeries("China", {data: {"GDP.": 2,"area.": 6,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 2000,"inflation.": 15,"growth.": 12}}, { fill: "blue" }); |
| 150 |
chart1.updateSeries("\u05e6\u05e8\u05e4\u05ea.", {data: {"GDP.": 6,"area.": 15,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 500,"inflation.": 5,"growth.": 6}}, { fill: "red" }); |
| 151 |
chart1.updateSeries("USA.", {data: {"GDP.": 3,"area.": 20,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 1500,"inflation.": 10,"growth.": 3}}, { fill: "green" }); |
| 152 |
chart1.updateSeries("Start \u05e1\u05d5\u05e3.", {data: {"GDP.": 4,"area.": 2,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 1000,"inflation.": 20,"growth.": 2}}, { fill: "yellow" }); |
| 153 |
chart1.updateSeries("\u05d4\u05ea\u05d7\u05dc\u05d4 end.", {data: {"GDP.": 10,"area.": 10,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 800,"inflation.": 2,"growth.": 18}}, { fill: "orange" }); |
| 154 |
chart1.updateSeries("Canada.", {data: {"GDP.": 1,"area.": 18,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 300,"inflation.": 3,"growth.": 15}}, { fill: "purple" }); |
| 155 |
}else{ |
| 156 |
chart1.updateSeries("China", {data: {"GDP.": 8,"area.": 2,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 500,"inflation.": 2,"growth.": 18}}, { fill: "blue" }); |
| 157 |
chart1.updateSeries("\u05e6\u05e8\u05e4\u05ea.", {data: {"GDP.": 10,"area.": 6,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 1000,"inflation.": 20,"growth.": 12}}, { fill: "red" }); |
| 158 |
chart1.updateSeries("USA.", {data: {"GDP.": 2,"area.": 5,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 1500,"inflation.": 12,"growth.": 6}}, { fill: "green" }); |
| 159 |
chart1.updateSeries("Start \u05e1\u05d5\u05e3.", {data: {"GDP.": 1,"area.": 20,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 500,"inflation.": 5,"growth.": 11}}, { fill: "yellow" }); |
| 160 |
chart1.updateSeries("\u05d4\u05ea\u05d7\u05dc\u05d4 end.", {data: {"GDP.": 4,"area.": 2,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 2000,"inflation.": 16,"growth.": 8}}, { fill: "orange" }); |
| 161 |
chart1.updateSeries("Canada.", {data: {"GDP.": 6,"area.": 10,"\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05d4.": 300,"inflation.": 3,"growth.": 2}}, { fill: "purple" }); |
| 162 |
} |
| 163 |
chart1.render(); |
| 164 |
legend1 && legend1.refresh && legend1.refresh(); |
| 165 |
} |
| 166 |
|
| 167 |
</script> |
| 168 |
|
| 169 |
<script type="text/javascript"> |
| 170 |
function switchSpider(val){ |
| 171 |
stype = document.getElementById("b11").checked ? "polygon" : "circle"; |
| 172 |
if(val == "b11"){ |
| 173 |
chart1.addPlot("default", { |
| 174 |
type: "Spider", |
| 175 |
divisions: divisions, |
| 176 |
spiderType: stype |
| 177 |
}); |
| 178 |
}else{ |
| 179 |
chart1.addPlot("default", { |
| 180 |
type: "Spider", |
| 181 |
divisions: divisions, |
| 182 |
spiderType: stype |
| 183 |
}); |
| 184 |
} |
| 185 |
chart1.render(); |
| 186 |
legend1 && legend1.refresh && legend1.refresh(); |
| 187 |
} |
| 188 |
|
| 189 |
</script> |
| 190 |
|
| 191 |
<script type="text/javascript"> |
| 192 |
function switchDivisions(val){ |
| 193 |
if(val == "b111"){ |
| 194 |
divisions = 7; |
| 195 |
chart1.addPlot("default", { |
| 196 |
type: "Spider", |
| 197 |
divisions: divisions, |
| 198 |
spiderType: stype |
| 199 |
}); |
| 200 |
}else{ |
| 201 |
divisions = 3; |
| 202 |
chart1.addPlot("default", { |
| 203 |
type: "Spider", |
| 204 |
divisions: divisions, |
| 205 |
spiderType: stype |
| 206 |
}); |
| 207 |
} |
| 208 |
chart1.render(); |
| 209 |
legend1 && legend1.refresh && legend1.refresh(); |
| 210 |
} |
| 211 |
|
| 212 |
</script> |
| 213 |
<script type="text/javascript"> |
| 214 |
function switchAnimation(val){ |
| 215 |
easing = dojo.getObject(dojo.byId("easing").value); |
| 216 |
chart1.addPlot("default", { |
| 217 |
type: "Spider", |
| 218 |
divisions: divisions, |
| 219 |
spiderType: stype, |
| 220 |
animationType: easing |
| 221 |
}); |
| 222 |
chart1.render(); |
| 223 |
legend1 && legend1.refresh && legend1.refresh(); |
| 224 |
} |
| 225 |
|
| 226 |
</script> |
| 227 |
|
| 228 |
</head> |
| 229 |
<body class="claro"> |
| 230 |
<h1>Spider 2D</h1> |
| 231 |
|
| 232 |
<h2> |
| 233 |
Spider 2D Demo: |
| 234 |
</h2> |
| 235 |
<p> |
| 236 |
<span> |
| 237 |
<span>Switch Year:</span> |
| 238 |
<span> |
| 239 |
<input dojoType="dijit.form.RadioButton" type=radio checked="checked" onClick="switchData(this.id)" name='a1' id='b1' value="1"/><label for='b1'> Figures in 2008 </label> |
| 240 |
<input dojoType="dijit.form.RadioButton" type=radio name='a1' onClick="switchData(this.id)" id='b2' value="2"/><label for='b2'> Figures in 2009 </label> |
| 241 |
|
| 242 |
<span><label>Animation Type: </label><select id="easing" onchange="switchAnimation()"></select></span> |
| 243 |
</span> |
| 244 |
</span> |
| 245 |
</p> |
| 246 |
<p> |
| 247 |
<span> |
| 248 |
<span>Switch Spider Type:</span> |
| 249 |
<span> |
| 250 |
<input dojoType="dijit.form.RadioButton" type=radio checked="checked" onClick="switchSpider(this.id)" name='a11' id='b11' value="polygon"/><label for='b11'> Polygon </label> |
| 251 |
<input dojoType="dijit.form.RadioButton" type=radio name='a11' onClick="switchSpider(this.id)" id='b22' value="circle"/><label for='b22'> Circle </label> |
| 252 |
</span> |
| 253 |
</span> |
| 254 |
|
| 255 |
<span> |
| 256 |
<span>Switch Divisions:</span> |
| 257 |
<span> |
| 258 |
<input dojoType="dijit.form.RadioButton" type=radio checked="checked" onClick="switchDivisions(this.id)" name='a111' id='b111' value="1"/><label for='b111'> Divisions = 7 </label> |
| 259 |
<input dojoType="dijit.form.RadioButton" type=radio name='a111' onClick="switchDivisions(this.id)" id='b222' value="2"/><label for='b222'> Divisions = 3 </label> |
| 260 |
</span> |
| 261 |
</span> |
| 262 |
</p> |
| 263 |
<h5> |
| 264 |
The following legends are selectable: |
| 265 |
</h5> |
| 266 |
<div id="legend1"></div> |
| 267 |
<p/> |
| 268 |
<div id="test1" style="width: 500px; height: 500px;"></div> |
| 269 |
<p/> |
| 270 |
</body> |
| 271 |
</html> |