Debian Codegraph @

dojox/charting/tests/test_spider2d.html

raw symbols SCIP
1 <!--[if IE 7]>
2 <!DOCTYPE>
3 <html lang="en">
4 <head>
5 <![endif]-->
6 <!--[if IE 8]>
7 <!DOCTYPE>
8 <html lang="en">
9 <head>
10 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
11 <![endif]-->
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"></script>
57 <script type="text/javascript">
58 var switchData, switchSpider, switchDivisions, switchAnimation;
59
60 require(["dojo/_base/kernel", "dojo/dom", "dojo/dom-construct", "dojo/ready", "dojox/charting/Chart", "dojox/charting/plot2d/Spider", "dojox/charting/themes/PlotKit/blue",
61 "dojox/charting/action2d/Tooltip", "dojox/charting/action2d/Highlight", "dojox/charting/action2d/Magnify",
62 "dijit/form/CheckBox", "dijit/form/RadioButton", "dijit/form/Form", "dojox/charting/widget/SelectableLegend",
63 "dojo/fx/easing"],
64 function(kernel, dom, domConstruct, ready, Chart, Spider, blue, Tooltip, Highlight, Magnify, CheckBox,
65 RadioButton, Form, SelectableLegend, easing){
66
67 var divisions = 7,
68 stype = "polygon",
69 easing = easing.backOut;
70 var empty = {};
71 var populateSelect = function(from, select){
72 var module = kernel.getObject(from);
73 for(var name in module){
74 if(name in empty){ continue; }
75 var fun = module[name];
76 if(kernel.isFunction(fun)){
77 domConstruct.create("option", {
78 value: from + "." + name,
79 selected: name == "backOut",
80 innerHTML: from + "." + name
81 }, select);
82 }
83 }
84 }
85
86 var chart1, legend1;
87
88 switchData = function(val){
89 if(val == "b1"){
90 chart1.updateSeries("China", {data: {"GDP": 2,"area": 6,"population": 2000,"inflation": 15,"growth": 12}}, { fill: "blue" });
91 chart1.updateSeries("France", {data: {"GDP": 6,"area": 15,"population": 500,"inflation": 5,"growth": 6}}, { fill: "red" });
92 chart1.updateSeries("USA", {data: {"GDP": 3,"area": 20,"population": 1500,"inflation": 10,"growth": 3}}, { fill: "green" });
93 chart1.updateSeries("Japan", {data: {"GDP": 4,"area": 2,"population": 1000,"inflation": 20,"growth": 2}}, { fill: "yellow" });
94 chart1.updateSeries("Korean", {data: {"GDP": 10,"area": 10,"population": 800,"inflation": 2,"growth": 18}}, { fill: "orange" });
95 chart1.updateSeries("Canada", {data: {"GDP": 1,"area": 18,"population": 300,"inflation": 3,"growth": 15}}, { fill: "purple" });
96 }else{
97 chart1.updateSeries("China", {data: {"GDP": 8,"area": 2,"population": 500,"inflation": 2,"growth": 18}}, { fill: "blue" });
98 chart1.updateSeries("France", {data: {"GDP": 10,"area": 6,"population": 1000,"inflation": 20,"growth": 12}}, { fill: "red" });
99 chart1.updateSeries("USA", {data: {"GDP": 2,"area": 5,"population": 1500,"inflation": 12,"growth": 6}}, { fill: "green" });
100 chart1.updateSeries("Japan", {data: {"GDP": 1,"area": 20,"population": 500,"inflation": 5,"growth": 11}}, { fill: "yellow" });
101 chart1.updateSeries("Korean", {data: {"GDP": 4,"area": 2,"population": 2000,"inflation": 16,"growth": 8}}, { fill: "orange" });
102 chart1.updateSeries("Canada", {data: {"GDP": 6,"area": 10,"population": 300,"inflation": 3,"growth": 2}}, { fill: "purple" });
103 }
104 chart1.render();
105 legend1 && legend1.refresh && legend1.refresh();
106 }
107
108 switchSpider = function(val){
109 stype = document.getElementById("b11").checked ? "polygon" : "circle";
110 if(val == "b11"){
111 chart1.addPlot("default", {
112 type: "Spider",
113 divisions: divisions,
114 spiderType: stype
115 });
116 }else{
117 chart1.addPlot("default", {
118 type: "Spider",
119 divisions: divisions,
120 spiderType: stype
121 });
122 }
123 chart1.render();
124 legend1 && legend1.refresh && legend1.refresh();
125 }
126
127 switchDivisions = function(val){
128 if(val == "b111"){
129 divisions = 7;
130 chart1.addPlot("default", {
131 type: "Spider",
132 divisions: divisions,
133 spiderType: stype
134 });
135 }else{
136 divisions = 3;
137 chart1.addPlot("default", {
138 type: "Spider",
139 divisions: divisions,
140 spiderType: stype
141 });
142 }
143 chart1.render();
144 legend1 && legend1.refresh && legend1.refresh();
145 }
146
147 switchAnimation = function(val){
148 easing = kernel.getObject(dom.byId("easing").value);
149 chart1.addPlot("default", {
150 type: "Spider",
151 divisions: divisions,
152 spiderType: stype,
153 animationType: easing
154 });
155 chart1.render();
156 legend1 && legend1.refresh && legend1.refresh();
157 }
158
159 ready(function(){
160 chart1 = new Chart("test1");
161 chart1.setTheme(blue);
162 chart1.addPlot("default", {
163 type: Spider,
164 labelOffset: -10,
165 divisions: divisions,
166 axisColor: "lightgray",
167 spiderColor: "silver",
168 seriesFillAlpha: 0.2,
169 spiderOrigin: 0.16,
170 markerSize: 3,
171 precision: 0,
172 spiderType: stype
173 });
174 chart1.addSeries("China", {data: {"GDP": 2,"area": 6,"population": 2000,"inflation": 15,"growth": 12}}, { fill: "blue" });
175 chart1.addSeries("France", {data: {"GDP": 6,"area": 15,"population": 500,"inflation": 5,"growth": 6}}, { fill: "red" });
176 chart1.addSeries("USA", {data: {"GDP": 3,"area": 20,"population": 1500,"inflation": 10,"growth": 3}}, { fill: "green" });
177 chart1.addSeries("Japan", {data: {"GDP": 4,"area": 2,"population": 1000,"inflation": 20,"growth": 2}}, { fill: "yellow" });
178 chart1.addSeries("Korean", {data: {"GDP": 10,"area": 10,"population": 800,"inflation": 2,"growth": 18}}, { fill: "orange" });
179 chart1.addSeries("Canada", {data: {"GDP": 1,"area": 18,"population": 300,"inflation": 3,"growth": 15}}, { fill: "purple" });
180 new Tooltip(chart1);
181 new Highlight(chart1);
182 new Magnify(chart1, "default", {duration: 800, scale: 1.5});
183 chart1.render();
184
185 legend1 = new SelectableLegend({chart: chart1, horizontal: true}, "legend1");
186
187 // prepare and enable controls
188 populateSelect("dojo.fx.easing", "easing");
189 });
190 });
191 </script>
192
193 <script type="text/javascript">
194
195 </script>
196
197 </head>
198 <body class="claro">
199 <h1>Spider 2D</h1>
200 <h5>
201 A spider chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point. The relative position and angle of the axes is typically uninformative.
202 </h5>
203 <ul>
204 <li>
205 It consists of a sequence of equi-angular spokes, called radii, with each spoke representing one of the variables. The data length of a spoke is proportional to the magnitude of the variable for the data point relative to the maximum magnitude of the variable across all data points.
206 A line is drawn connecting the data values for each spoke. This gives the plot a star-like appearance and the origin of the name of this plot.
207 </li>
208 <li>
209 Spider charts are useful when you want to look at several different factors all related to one item. spider charts have multiple axes along which data can be plotted
210 </li>
211 </ul>
212
213 <h5>
214 Application
215 </h5>
216 <ul>
217
218 <li>
219 The "spider chart" can be a format commonly used by management consultants to show their clients how an organization compares with those in similar companies.
220 </li>
221 <li>
222 It also can be used as the control of quality improvement to display the performance metrics of any ongoing program.
223 </li>
224 <li>
225 Furthermore, it is also being used in sports to chart players' strengths and weaknesses.
226 </li>
227 <li>
228 For example, you could use a spider chart to compile data about a wide receiver on a professional football team. On one axis, you could plot the percentage of passes caught.
229 Another axis would show his yards per completion; another, his completions per 100 plays; another, blocks made; and a final axis might show his interceptions
230 So far as we can see, the spider has a broad application area.
231 </li>
232 </ul>
233 <h5>
234 Comparison with radar chart in dojox.charting
235 </h5>
236 <ul>
237 <li>
238 Spider charts differ from radar chart in that a spider chart is a chart that has N "y" axes while radar chart has only one "y" axis, all radiating from a central point,
239 where each "y" axis represents a specific category. For example, there are 5 "y" axes: GDP, area, population, inflation and growth here.
240 </li>
241 <li>
242 The radar chart, however, instead of being drawn in a typical linear X/Y space, the radar chart is drawn using a circular plot, with specific X values being shown using an arbitrary number of spokes drawn from a center point.
243 These charts are useful for showing data over a cyclical set of values (for instance, hours of a day, minutes in an hour, etc.). With a radar chart, data is plotted in much the same way as with a typical line or area chart.
244 </li>
245 <li><strong>
246 Actually, the radar chart is somewhat similar with line chart, the major difference between them is: line chart has a "straight" X axis while radar chart has a "circular" X axis, and the orientation of their Y axis is opposite.
247 </strong></li>
248 </ul>
249 <hr/>
250 <h2>
251 Spider 2D Demo:
252 </h2>
253 <p>
254 <span>
255 <span>Switch Year:</span>
256 <span>
257 <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>
258 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input dojoType="dijit.form.RadioButton" type=radio name='a1' onClick="switchData(this.id)" id='b2' value="2"/><label for='b2'> Figures in 2009 </label>
259 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
260 <span><label>Animation Type:&nbsp;</label><select id="easing" onchange="switchAnimation()"></select></span>&nbsp;
261 </span>
262 </span>
263 </p>
264 <p>
265 <span>
266 <span>Switch Spider Type:</span>
267 <span>
268 <input dojoType="dijit.form.RadioButton" type=radio checked="checked" onClick="switchSpider(this.id)" name='a11' id='b11' value="polygon"/><label for='b11'> Polygon </label>
269 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input dojoType="dijit.form.RadioButton" type=radio name='a11' onClick="switchSpider(this.id)" id='b22' value="circle"/><label for='b22'> Circle </label>
270 </span>
271 </span>
272 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
273 <span>
274 <span>Switch Divisions:</span>
275 <span>
276 <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>
277 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input dojoType="dijit.form.RadioButton" type=radio name='a111' onClick="switchDivisions(this.id)" id='b222' value="2"/><label for='b222'> Divisions = 3 </label>
278 </span>
279 </span>
280 </p>
281 <h5>
282 The following legends are selectable:
283 </h5>
284 <div id="legend1"></div>
285 <p/>
286 <div id="test1" style="width: 500px; height: 500px;"></div>
287 <p/>
288 </body>
289 </html>