Debian Codegraph @

dojox/charting/tests/test_chart2d.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 <title>Chart 2D</title>
18 <style type="text/css">
19 @import "../../../dojo/resources/dojo.css";
20 @import "../../../dijit/tests/css/dijitTests.css";
21 </style>
22 <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script>
23 <script type="text/javascript">
24 dojo.require("dojox.charting.Chart");
25 dojo.require("dojox.charting.axis2d.Default");
26 dojo.require("dojox.charting.plot2d.Default");
27 dojo.require("dojox.charting.plot2d.Areas");
28 dojo.require("dojox.charting.plot2d.Markers");
29 dojo.require("dojox.charting.plot2d.MarkersOnly");
30 dojo.require("dojox.charting.plot2d.StackedLines");
31 dojo.require("dojox.charting.plot2d.StackedAreas");
32 dojo.require("dojox.charting.plot2d.Bars");
33 dojo.require("dojox.charting.plot2d.ClusteredBars");
34 dojo.require("dojox.charting.plot2d.StackedBars");
35 dojo.require("dojox.charting.plot2d.ClusteredColumns");
36 dojo.require("dojox.charting.plot2d.StackedColumns");
37 dojo.require("dojox.charting.plot2d.Bubble");
38 dojo.require("dojox.charting.plot2d.Grid");
39 dojo.require("dojox.charting.plot2d.Candlesticks");
40 dojo.require("dojox.charting.plot2d.OHLC");
41 dojo.require("dojox.charting.plot2d.Scatter");
42
43 dojo.require("dojox.charting.themes.Shrooms");
44 dojo.require("dojox.charting.themes.PlotKit.blue");
45 dojo.require("dojox.charting.themes.PlotKit.cyan");
46 dojo.require("dojox.charting.themes.PlotKit.green");
47 dojo.require("dojox.charting.themes.Ireland");
48 dojo.require("dojox.charting.themes.SageToLime");
49 dojo.require("dojox.charting.themes.Minty");
50 dojo.require("dojox.charting.themes.Tufte");
51
52 dojo.require("dojox.dtl");
53 dojo.require("dojox.dtl.Context");
54 charts = [
55 {
56 description: "Clustered columns with positive and negative values, readable theme.",
57 makeChart: function(node){
58 (new dojox.charting.Chart(node)).
59 setTheme(dojox.charting.themes.Tufte).
60 addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }).
61 addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true }).
62 addPlot("default", { type: "ClusteredColumns", gap: 10 }).
63 addSeries("Series A", [ 2, 1, 0.5, -1, -2 ] ).
64 addSeries("Series B", [ -2, -1, -0.5, 1, 2 ] ).
65 addSeries("Series C", [ 1, 0.5, -1, -2, -3 ] ).
66 addSeries("Series D", [ 0.7, 1.5, -1.2, -1.25, 3 ] ).
67 render();
68 }
69 },
70 {
71 description: "Bubble chart, green theme.",
72 makeChart: function(node){
73 (new dojox.charting.Chart(node)).
74 setTheme(dojox.charting.themes.SageToLime).
75 addPlot("default", { type: "Bubble", shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]} }).
76 addAxis("x", {
77 min: 0,
78 max: 6,
79 majorTick: { stroke: "black", length: 3 },
80 minorTick: { stroke: "gray", length: 3 }
81 }).
82 addAxis("y", {
83 vertical: true,
84 min: 0,
85 max: 10,
86 majorTick: { stroke: "black", length: 3 },
87 minorTick: { stroke: "gray", length: 3 }
88 }).
89 addSeries("Series A", [
90 { x: 0.5, y: 5, size: 1.4 },
91 { x: 1.5, y: 1.5, size: 4.5 },
92 { x: 2, y: 9, size:1.5 },
93 { x: 5, y: 0.3, size:0.8 }
94 ]).
95 addSeries("Series B", [
96 { x: 0.3, y: 8, size: 2.5 },
97 { x: 4, y: 6, size:1.1 },
98 { x: 5.5, y: 2, size: 3.2 }
99 ]).
100 render();
101 }
102 },
103 {
104 description: "Lines, calculated labels",
105 makeChart: function(node){
106 (new dojox.charting.Chart(node)).
107 addAxis("x", {
108 majorLabels: true,
109 minorLabels: true,
110 includeZero: true,
111 minorTicks: false,
112 microTicks: false,
113 majorTickStep: 2,
114 htmlLabels: true,
115 labelFunc: function(value){
116 return value + " s";
117 },
118 maxLabelSize: 30,
119 fixUpper: "major", fixLower: "major",
120 majorTick: { length: 3 }
121 }).
122 addAxis("y", {
123 labelFunc: function(value){
124 return value + " thingers";
125 },
126 maxLabelSize: 50,
127 vertical: true,
128 // htmlLabels: false,
129 microTicks: true,
130 minorTicks: true,
131 majorTick: { stroke: "black", length: 3 }
132 }).
133 addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]).
134 addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]).
135 render();
136 }
137 },
138 {
139 description: "Lines, pre-computed labels",
140 makeChart: function(node){
141 (new dojox.charting.Chart(node)).
142 addAxis("x", {
143 majorLabels: true,
144 minorLabels: true,
145 includeZero: true,
146 minorTicks: false,
147 microTicks: false,
148 majorTickStep: 2,
149 labels: [
150 { value: 0, text: "nada" },
151 { value: 2, text: "2 units" },
152 { value: 4, text: "4 units" },
153 { value: 8, text: "2*4 units" }
154 ],
155 htmlLabels: true,
156 fixUpper: "major", fixLower: "major",
157 majorTick: { length: 3 }
158 }).
159 addAxis("y", {
160 labels: [
161 { value: 0, text: "nada" },
162 { value: 1.1, text: "hrmm" },
163 { value: 1.2, text: "?" },
164 { value: 2, text: "2!" }
165 ],
166 vertical: true,
167 // htmlLabels: false,
168 microTicks: true,
169 minorTicks: true,
170 majorTick: { stroke: "black", length: 3 }
171 }).
172 addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]).
173 addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]).
174 render();
175 }
176 },
177 {
178 description: "Defaults: lines, no axes.",
179 makeChart: function(node){
180 (new dojox.charting.Chart(node)).
181 addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]).
182 addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]).
183 render();
184 }
185 },
186 {
187 description: "Defaults: lines, no axes, and custom strokes.",
188 makeChart: function(node){
189 (new dojox.charting.Chart(node)).
190 addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ], {stroke: "red"}).
191 addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ], {stroke: "blue"}).
192 render();
193 }
194 },
195 {
196 description: "Areas, Happy theme, no axes.",
197 makeChart: function(node){
198 (new dojox.charting.Chart(node)).
199 addPlot("default", {type: "Areas", tension:"X"}).
200 setTheme(dojox.charting.themes.Shrooms).
201 addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]).
202 addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]).
203 addSeries("Series C", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2]).
204 render();
205 }
206 },
207 {
208 description: "Areas, Negative Values.",
209 makeChart: function(node){
210 (new dojox.charting.Chart(node)).
211 addPlot("default", {type: "Areas", tension:"X", zeroLine: 0}).
212 setTheme(dojox.charting.themes.Shrooms).
213 addAxis("x", {
214 majorLabels: true,
215 minorLabels: true,
216 minorTicks: false,
217 microTicks: false,
218 }).
219 addAxis("y", {
220 vertical: true,
221 microTicks: true,
222 minorTicks: true
223 }).
224 addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]).
225 addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]).
226 addSeries("Series C", [-6.3, -1.8, -3, -0.5, -4.4, -2.7, -2]).
227 render();
228 }
229 },
230 {
231 description: "Areas, no axes, custom strokes and fills.",
232 makeChart: function(node){
233 (new dojox.charting.Chart(node)).
234 addPlot("default", {type: "Areas"}).
235 addSeries("Series A",
236 [1, 2, 1, 2, 1, 2, 1],
237 {
238 stroke: {color: "red", width: 2 },
239 fill: "lightpink"
240 }
241 ).
242 addSeries("Series B",
243 [ 2, 1, 2, 1, 2, 1, 2 ],
244 {
245 stroke: { color: "blue", width: 2 },
246 fill: "lightblue"
247 }
248 ).
249 render();
250 }
251 },
252 {
253 description: "Lines, axes, blue theme.",
254 makeChart: function(node){
255 (new dojox.charting.Chart(node)).
256 setTheme(dojox.charting.themes.PlotKit.blue).
257 addAxis("x").
258 addAxis("y", {vertical: true}).
259 addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]).
260 addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
261 render();
262 }
263 },
264 {
265 description: "Lines, axes (aligned on minor ticks), cyan theme.",
266 makeChart: function(node){
267 (new dojox.charting.Chart(node)).
268 setTheme(dojox.charting.themes.PlotKit.cyan).
269 addAxis("x", {
270 fixLower: "minor", fixUpper: "minor"
271 }).
272 addAxis("y", {
273 vertical: true, fixLower: "minor", fixUpper: "minor"
274 }).
275 addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]).
276 addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
277 render();
278 }
279 },
280 {
281 description: "Lines, axes (aligned on major ticks), green theme.",
282 makeChart: function(node){
283 (new dojox.charting.Chart(node)).
284 setTheme(dojox.charting.themes.PlotKit.green).
285 addAxis("x", {
286 fixLower: "major", fixUpper: "major"
287 }).
288 addAxis("y", {
289 vertical: true, fixLower: "major", fixUpper: "major"
290 }).
291 addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]).
292 addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
293 render();
294 }
295 },
296 {
297 description: "Lines and markers, no axes, purple theme, custom min/max.",
298 makeChart: function(node){
299 (new dojox.charting.Chart(node)).
300 setTheme(dojox.charting.themes.SageToLime).
301 addPlot("default", {type: "Markers"}).
302 addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3}).
303 addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
304 render();
305 }
306 },
307 {
308 description: "Markers only, no axes, custom theme, custom markers, custom min/max.",
309 makeChart: function(node){
310 (new dojox.charting.Chart(node)).
311 addPlot("default", { type: "MarkersOnly" }).
312 addSeries("Series A",
313 [ 1, 2, 1, 2, 1, 2, 1 ],
314 {
315 min: 0,
316 max: 3,
317 stroke: {color: "red", width: 2},
318 fill: "red",
319 marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"
320 }
321 ).
322 addSeries("Series B",
323 [ 2, 1, 2, 1, 2, 1, 2 ],
324 {
325 stroke: {color: "blue", width: 2},
326 fill: "blue",
327 marker: "m-3,-3 l0,6 6,0 0,-6 z"
328 }
329 ).
330 render();
331 }
332 },
333 {
334 description: "Lines and markers, shadows, no axes, custom theme, custom markers, custom min/max.",
335 makeChart: function(node){
336 (new dojox.charting.Chart(node)).
337 addPlot("default", {
338 type: "Markers", shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]}
339 }).
340 addSeries("Series A",
341 [ 1, 2, 1, 2, 1, 2, 1 ],
342 {
343 min: 0,
344 max: 3,
345 stroke: {color: "red", width: 2, join: "round"},
346 fill: "red",
347 marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"
348 }
349 ).
350 addSeries("Series B",
351 [ 2, 1, 2, 1, 2, 1, 2 ],
352 {
353 stroke: {color: "blue", width: 2, join: "round"},
354 fill: "blue",
355 marker: "m-3,-3 l0,6 6,0 0,-6 z"
356 }
357 ).
358 render();
359 }
360 },
361 {
362 description: "Stacked lines, markers, shadows, no axes, custom strokes, fills, and markers.",
363 makeChart: function(node){
364 (new dojox.charting.Chart(node)).
365 addPlot("default", {
366 type: "StackedLines",
367 markers: true,
368 tension:"S",
369 shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]}
370 }).
371 addSeries("Series A",
372 [ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ],
373 {
374 stroke: { color: "red", width: 2 },
375 fill: "lightpink",
376 marker: "m-3,-3 l0,6 6,0 0,-6 z"
377 }
378 ).
379 addSeries("Series B",
380 [ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ],
381 {
382 stroke: { color: "blue", width: 2 },
383 fill: "lightblue",
384 marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"
385 }
386 ).
387 addSeries("Series C",
388 [ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ],
389 {
390 stroke: { color: "green", width: 2 },
391 fill: "lightgreen",
392 marker: "m0,-3 l3,3 -3,3 -3,-3 z"
393 }
394 ).
395 render();
396 }
397 },
398 {
399 description: "Stacked areas, axes (aligned on major ticks), custom strokes and fills.",
400 makeChart: function(node){
401 (new dojox.charting.Chart(node)).
402 addAxis("x", {fixLower: "major", fixUpper: "major"}).
403 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0}).
404 addPlot("default", { type: "StackedAreas", tension:"S" }).
405 addSeries("Series A",
406 [ -2, 1.1, 1.2, 1.3, 1.4, 1.5, -1.6 ],
407 { stroke: {color: "red", width: 2}, fill: "lightpink" }
408 ).
409 addSeries("Series B",
410 [ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ],
411 { stroke: {color: "blue", width: 2}, fill: "lightblue" }
412 ).
413 addSeries("Series C",
414 [ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ],
415 { stroke: {color: "green", width: 2}, fill: "lightgreen" }
416 ).
417 render();
418 }
419 },
420 {
421 description: "Candlesticks with gaps, custom strokes and fills, optional mid points.",
422 makeChart: function(node){
423 (new dojox.charting.Chart(node)).
424 addPlot("default", {type: "Candlesticks", gap: 1}).
425 addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}).
426 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}).
427 addSeries("Series A", [
428 { open: 20, close: 16, high: 22, low: 8 },
429 { open: 16, close: 22, high: 26, low: 6, mid: 18 },
430 { open: 22, close: 18, high: 22, low: 11, mid: 21 },
431 { open: 18, close: 29, high: 32, low: 14, mid: 27 },
432 { open: 29, close: 24, high: 29, low: 13, mid: 27 },
433 { open: 24, close: 8, high: 24, low: 5 },
434 { open: 8, close: 16, high: 22, low: 2 },
435 { open: 16, close: 12, high: 19, low: 7 },
436 { open: 12, close: 20, high: 22, low: 8 },
437 { open: 20, close: 16, high: 22, low: 8 },
438 { open: 16, close: 22, high: 26, low: 6, mid: 18 },
439 { open: 22, close: 18, high: 22, low: 11, mid: 21 },
440 { open: 18, close: 29, high: 32, low: 14, mid: 27 },
441 { open: 29, close: 24, high: 29, low: 13, mid: 27 },
442 { open: 24, close: 8, high: 24, low: 5 },
443 { open: 8, close: 16, high: 22, low: 2 },
444 { open: 16, close: 12, high: 19, low: 7 },
445 { open: 12, close: 20, high: 22, low: 8 },
446 { open: 20, close: 16, high: 22, low: 8 },
447 { open: 16, close: 22, high: 26, low: 6 },
448 { open: 22, close: 18, high: 22, low: 11 },
449 { open: 18, close: 29, high: 32, low: 14 },
450 { open: 29, close: 24, high: 29, low: 13 },
451 { open: 24, close: 8, high: 24, low: 5 },
452 { open: 8, close: 16, high: 22, low: 2 },
453 { open: 16, close: 12, high: 19, low: 7 },
454 { open: 12, close: 20, high: 22, low: 8 },
455 { open: 20, close: 16, high: 22, low: 8 }
456 ],
457 { stroke: { color: "green" }, fill: "lightgreen" }
458 ).
459 render();
460 }
461 },
462 {
463 description: "Open/High/Low/Close with gaps, custom strokes and fills.",
464 makeChart: function(node){
465 (new dojox.charting.Chart(node)).
466 addPlot("default", {type: "OHLC", gap: 2}).
467 addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}).
468 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}).
469 addSeries("Series A", [
470 { open: 20, close: 16, high: 22, low: 8 },
471 { open: 16, close: 22, high: 26, low: 6 },
472 { open: 22, close: 18, high: 22, low: 11 },
473 { open: 18, close: 29, high: 32, low: 14 },
474 { open: 29, close: 24, high: 29, low: 13 },
475 { open: 24, close: 8, high: 24, low: 5 },
476 { open: 8, close: 16, high: 22, low: 2 },
477 { open: 16, close: 12, high: 19, low: 7 },
478 { open: 12, close: 20, high: 22, low: 8 },
479 { open: 20, close: 16, high: 22, low: 8 },
480 { open: 16, close: 22, high: 26, low: 6 },
481 { open: 22, close: 18, high: 22, low: 11 },
482 { open: 18, close: 29, high: 32, low: 14 },
483 { open: 29, close: 24, high: 29, low: 13 },
484 { open: 24, close: 8, high: 24, low: 5 },
485 { open: 8, close: 16, high: 22, low: 2 },
486 { open: 16, close: 12, high: 19, low: 7 },
487 { open: 12, close: 20, high: 22, low: 8 },
488 { open: 20, close: 16, high: 22, low: 8 },
489 { open: 16, close: 22, high: 26, low: 6 },
490 { open: 22, close: 18, high: 22, low: 11 },
491 { open: 18, close: 29, high: 32, low: 14 },
492 { open: 29, close: 24, high: 29, low: 13 },
493 { open: 24, close: 8, high: 24, low: 5 },
494 { open: 8, close: 16, high: 22, low: 2 },
495 { open: 16, close: 12, high: 19, low: 7 },
496 { open: 12, close: 20, high: 22, low: 8 },
497 { open: 20, close: 16, high: 22, low: 8 }
498 ],
499 { stroke: { color: "blue" }, fill: "blue" }
500 ).
501 render();
502 }
503 },
504 {
505 description: "Columns, no axes, custom strokes and fills.",
506 makeChart: function(node){
507 (new dojox.charting.Chart(node)).
508 addPlot("default", {type: "Columns"}).
509 addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }).
510 addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }).
511 render();
512 }
513 },
514 {
515 description: "Columns with gaps beetwen them, vertical axis aligned on major ticks, custom strokes, fills.",
516 makeChart: function(node){
517 (new dojox.charting.Chart(node)).
518 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"}).
519 addPlot("default", {type: "Columns", gap: 2}).
520 addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: {color: "red"}, fill: "lightpink" }).
521 addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }).
522 render();
523 }
524 },
525 {
526 description: "Stacked columns, no axes, custom strokes and fills.",
527 makeChart: function(node){
528 (new dojox.charting.Chart(node)).
529 addPlot("default", {type: "StackedColumns"}).
530 addSeries("Series A", [ 1, 2, 3, 4, 5 ], {stroke: { color: "red" }, fill: "lightpink" }).
531 addSeries("Series B", [ 2, 1, 2, 1, 2 ], {stroke: { color: "blue" }, fill: "lightblue" }).
532 render();
533 }
534 },
535 {
536 description: "Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills.",
537 makeChart: function(node){
538 (new dojox.charting.Chart(node)).
539 addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}).
540 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}).
541 addPlot("default", {type: "Bars"}).
542 addSeries("Series A",
543 [1, 2, 3, 4, 5],
544 { stroke: {color: "red"}, fill: "lightpink" }
545 ).
546 addSeries("Series B",
547 [5, 4, 3, 2, 1],
548 { stroke: {color: "blue"}, fill: "lightblue" }
549 ).
550 render();
551 }
552 },
553 {
554 description: "Stacked bars, no axes, custom strokes and fills.",
555 makeChart: function(node){
556 (new dojox.charting.Chart(node)).
557 addPlot("default", {type: "StackedBars"}).
558 addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }).
559 addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }).
560 render();
561 }
562 },
563 {
564 description: "Clustered columns, custom axes, custom strokes, fills, and gap.",
565 makeChart: function(node){
566 (new dojox.charting.Chart(node)).
567 addAxis("x", {
568 fixLower: "minor", fixUpper: "minor", natural: true
569 }).
570 addAxis("y", {
571 vertical: true, fixLower: "major", fixUpper: "major", includeZero: true
572 }).
573 addPlot("default", {type: "ClusteredColumns", gap: 10}).
574 addSeries("Series A",
575 [ 1, 2, 3, 4, 5 ],
576 { stroke: {color: "red"}, fill: "lightpink" }
577 ).
578 addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}).
579 render();
580 }
581 },
582 {
583 description: "Clustered bars, custom axes, custom strokes, fills, and gap.",
584 makeChart: function(node){
585 (new dojox.charting.Chart(node)).
586 addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}).
587 addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor", natural: true}).
588 addPlot("default", { type: "ClusteredBars", gap: 5 }).
589 addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }).
590 addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }).
591 render();
592 }
593 },
594 {
595 description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes.",
596 makeChart: function(node){
597 (new dojox.charting.Chart(node)).
598 addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }).
599 addAxis("y", {
600 vertical: true,
601 fixLower: "major",
602 fixUpper: "major",
603 minorTicks: false,
604 includeZero: true
605 }).
606 addPlot("front_grid", { type: "Grid", hMajorLines: true, vMajorLines: false }).
607 addPlot("default", { type: "Columns", gap: 10 }).
608 addPlot("back_grid", { type: "Grid", hMajorLines: false, vMajorLines: true }).
609 addSeries("Series A",
610 [ 1, 2, 3, 4, 5 ],
611 { stroke: { color: "red" }, fill: "lightpink" }
612 ).
613 addSeries("Series B",
614 [ 5, 4, 3, 2, 1 ],
615 { stroke: { color: "blue" }, fill: "lightblue" }
616 ).
617 render();
618 }
619 },
620 {
621 description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes, with min=0, max=8, and manually specified ticks on the vertical axis.",
622 makeChart: function(node){
623 (new dojox.charting.Chart(node)).
624 addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true}).
625 addAxis("y", {
626 vertical: true, fixLower: "major", fixUpper: "major",
627 includeZero: true, min: 0, max: 8, minorLabels: false,
628 majorTicks: true, minorTicks: true, microTicks: false,
629 majorTickStep: 2, minorTickStep: 1, microTickStep: 0.5
630 }).
631 addPlot("front_grid", {
632 type: "Grid", hMajorLines: true, vMajorLines: false
633 }).
634 addPlot("default", {type: "Columns", gap: 10}).
635 addPlot("back_grid", {
636 type: "Grid", hMajorLines: false, vMajorLines: true
637 }).
638 addSeries("Series A",
639 [ 1, 2, 3, 4, 5 ],
640 { stroke: {color: "red"}, fill: "lightpink" }
641 ).
642 addSeries("Series B",
643 [ 5, 4, 3, 2, 1 ],
644 { stroke: {color: "blue"}, fill: "lightblue" }
645 ).
646 render();
647 }
648 },
649 {
650 description: "Columns with positive and negative values, axes, and grid.",
651 makeChart: function(node){
652 (new dojox.charting.Chart(node)).
653 addAxis("x").
654 addAxis("y", { vertical: true }).
655 addPlot("default", { type: "Columns", gap: 10 }).
656 addPlot("grid", { type: "Grid" }).
657 addSeries("Series A",
658 [ 2, 1, 0.5, -1, -2 ],
659 { stroke: {color: "red"}, fill: "lightpink" }
660 ).
661 addSeries("Series B",
662 [ -2, -1, -0.5, 1, 2 ],
663 { stroke: {color: "blue"}, fill: "lightblue" }
664 ).
665 render();
666 }
667 },
668 {
669 description: "Clustered columns with positive and negative values, axes, and grid.",
670 makeChart: function(node){
671 (new dojox.charting.Chart(node)).
672 addAxis("x").
673 addAxis("y", { vertical: true }).
674 addPlot("default", { type: "ClusteredColumns", gap: 10 }).
675 addPlot("grid", { type: "Grid" }).
676 addSeries("Series A",
677 [ 2, 1, 0.5, -1, -2 ],
678 { stroke: {color: "red"}, fill: "lightpink" }
679 ).
680 addSeries("Series B",
681 [ -2, -1, -0.5, 1, 2 ],
682 { stroke: {color: "blue"}, fill: "lightblue" }
683 ).
684 addSeries("Series C",
685 [ 1, 0.5, -1, -2, -3 ],
686 { stroke: {color: "green"}, fill: "lightgreen" }
687 ).
688 render();
689 }
690 },
691 {
692 description: "Bars with positive and negative values, axes, and grid.",
693 makeChart: function(node){
694 (new dojox.charting.Chart(node)).
695 addAxis("x").
696 addAxis("y", { vertical: true }).
697 addPlot("default", { type: "Bars", gap: 10 }).
698 addPlot("grid", { type: "Grid" }).
699 addSeries("Series A",
700 [ 2, 1, 0.5, -1, -2 ],
701 { stroke: {color: "red"}, fill: "lightpink" }
702 ).
703 addSeries("Series B",
704 [ -2, -1, -0.5, 1, 2 ],
705 { stroke: {color: "blue"}, fill: "lightblue" }
706 ).
707 render();
708 }
709 },
710 {
711 description: "Clustered bars with positive and negative values, axes, and grid.",
712 makeChart: function(node){
713 (new dojox.charting.Chart(node)).
714 addAxis("x").
715 addAxis("y", { vertical: true }).
716 addPlot("default", { type: "ClusteredBars", gap: 10 }).
717 addPlot("grid", { type: "Grid" }).
718 addSeries("Series A",
719 [ 2, 1, 0.5, -1, -2 ],
720 { stroke: { color: "red" }, fill: "lightpink" }
721 ).
722 addSeries("Series B",
723 [ -2, -1, -0.5, 1, 2 ],
724 { stroke: { color: "blue" }, fill: "lightblue" }
725 ).
726 addSeries("Series C",
727 [ 1, 0.5, -1, -2, -3 ],
728 { stroke: { color: "green" }, fill: "lightgreen" }
729 ).
730 render();
731 }
732 },
733 {
734 description: "Default lines with 2D data, custom axis, red theme.",
735 makeChart: function(node){
736 (new dojox.charting.Chart(node)).
737 setTheme(dojox.charting.themes.Minty).
738 addAxis("x", {
739 min: 0,
740 max: 6,
741 majorTick: { stroke: "black", length: 3 },
742 minorTick: { stroke: "gray", length: 3 }
743 }).
744 addAxis("y", {
745 vertical: true,
746 min: 0,
747 max: 10,
748 majorTick: { stroke: "black", length: 3 },
749 minorTick: { stroke: "gray", length: 3 }
750 }).
751 addSeries("Series A", [
752 { x: 0.5, y: 5 },
753 { x: 1.5, y: 1.5 },
754 { x: 2, y: 9 },
755 { x: 5, y: 0.3 }
756 ]).
757 addSeries("Series B", [
758 { x: 0.3, y: 8 },
759 { x: 4, y: 6 },
760 { x: 5.5, y: 2 }
761 ]).
762 render();
763 }
764 },
765 {
766 description: "Scatter chart, custom axis, purple theme.",
767 makeChart: function(node){
768 (new dojox.charting.Chart(node)).
769 setTheme(dojox.charting.themes.Ireland).
770 addPlot("default", {type: "Scatter"}).
771 addAxis("x", {
772 min: 0,
773 max: 6,
774 majorTick: { stroke: "black", length: 3 },
775 minorTick: { stroke: "gray", length: 3 }
776 }).
777 addAxis("y", {
778 vertical: true,
779 min: 0,
780 max: 10,
781 majorTick: { stroke: "black", length: 3 },
782 minorTick: { stroke: "gray", length: 3 }
783 }).
784 addSeries("Series A", [
785 { x: 0.5, y: 5 },
786 { x: 1.5, y: 1.5 },
787 { x: 2, y: 9 },
788 { x: 5, y: 0.3 }
789 ]).
790 addSeries("Series B", [
791 { x: 0.3, y: 8 },
792 { x: 4, y: 6 },
793 { x: 5.5, y: 2 }
794 ]).
795 render();
796 }
797 },
798 {
799 description: "Markers, lines, 2D data, custom axis, blue theme.",
800 makeChart: function(node){
801 (new dojox.charting.Chart(node)).
802 setTheme(dojox.charting.themes.PlotKit.blue).
803 addPlot("default", {
804 type: "Default",
805 lines: true,
806 markers: true,
807 tension: 2
808 }).
809 addAxis("x", {
810 min: 0,
811 max: 6,
812 majorTick: { stroke: "black", length: 3 },
813 minorTick: { stroke: "gray", length: 3 }
814 }).
815 addAxis("y", {
816 vertical: true,
817 min: 0,
818 max: 10,
819 majorTick: { stroke: "black", length: 3 },
820 minorTick: { stroke: "gray", length: 3 }
821 }).
822 addSeries("Series A", [
823 { x: 0.5, y: 5 },
824 { x: 1.5, y: 1.5 },
825 { x: 2, y: 9 },
826 { x: 5, y: 0.3 }
827 ]).
828 addSeries("Series B", [
829 { x: 0.3, y: 8 },
830 { x: 4, y: 6 },
831 { x: 5.5, y: 2 }
832 ]).
833 render();
834 }
835 },
836 {
837 description: "Markers, lines, 2D data, custom centered axis, blue theme.",
838 makeChart: function(node){
839 (new dojox.charting.Chart(node)).
840 setTheme(dojox.charting.themes.PlotKit.blue).
841 addPlot("default", {
842 type: "Default",
843 lines: true,
844 markers: true,
845 tension: 2
846 }).
847 addAxis("x", {
848 min: 0,
849 max: 6,
850 majorTick: { stroke: "black", length: 3 },
851 minorTick: { stroke: "gray", length: 3 },
852 position: "center"
853 }).
854 addAxis("y", {
855 vertical: true,
856 min: 0,
857 max: 10,
858 majorTick: { stroke: "black", length: 3 },
859 minorTick: { stroke: "gray", length: 3 },
860 position: "center"
861 }).
862 addSeries("Series A", [
863 { x: 0.5, y: 5 },
864 { x: 1.5, y: 1.5 },
865 { x: 2, y: 9 },
866 { x: 5, y: 0.3 }
867 ]).
868 addSeries("Series B", [
869 { x: 0.3, y: 8 },
870 { x: 4, y: 6 },
871 { x: 5.5, y: 2 }
872 ]).
873 render();
874 }
875 }
876 ];
877 var now = function(){
878 return (new Date()).getTime();
879 };
880
881
882 dojo.addOnLoad(function(){
883 var defaultStyle = { width: "400px", height: "200px" };
884 var tmpl = new dojox.dtl.Template(dojo.byId("template").value);
885 var context = new dojox.dtl.Context({ charts: charts });
886 dojo.byId("charts").innerHTML = tmpl.render(context);
887
888 dojo.forEach(charts, function(item, idx){
889 var start = now();
890 var n = dojo.byId("chart_" + (idx + 1));
891 dojo.style(n, item.style||defaultStyle);
892 item.makeChart(n);
893 console.debug((now()-start), "ms to create:", (idx+1)+":", item.description);
894 });
895 });
896
897 </script>
898 </head>
899 <body>
900 <textarea id="template" style="display: none;">
901 {% for item in charts %}
902 <p>{{ forloop.counter }}: {{ item.description }}</p>
903 <div id="chart_{{ forloop.counter }}"></div>
904 {% endfor %}
905 </textarea>
906
907 <h1>Chart 2D</h1>
908
909 <div id="charts"></div>
910 </body>
911 </html>