Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.charting.svg.Plotters");
14
dojo.require("dojo.lang.common");
15
if (dojo.render.svg.capable) {
16
	dojo.require("dojo.svg");
17
	dojo.mixin(dojo.charting.Plotters, {Bar:function (plotarea, plot, kwArgs, applyTo) {
18
		var area = plotarea.getArea();
19
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
20
		var n = plot.series.length;
21
		var data = [];
22
		for (var i = 0; i < n; i++) {
23
			var tmp = plot.series[i].data.evaluate(kwArgs);
24
			data.push(tmp);
25
		}
26
		var space = 8;
27
		var nPoints = data[0].length;
28
		if (nPoints == 0) {
29
			return group;
30
		}
31
		var width = ((area.right - area.left) - (space * (nPoints - 1))) / nPoints;
32
		var barWidth = width / n;
33
		var yOrigin = plot.axisY.getCoord(plot.axisX.origin, plotarea, plot);
34
		for (var i = 0; i < nPoints; i++) {
35
			var xStart = area.left + (width * i) + (space * i);
36
			for (var j = 0; j < n; j++) {
37
				var value = data[j][i].y;
38
				var yA = yOrigin;
39
				var x = xStart + (barWidth * j);
40
				var y = plot.axisY.getCoord(value, plotarea, plot);
41
				var h = Math.abs(yA - y);
42
				if (value < plot.axisX.origin) {
43
					yA = y;
44
					y = yOrigin;
45
				}
46
				var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
47
				bar.setAttribute("fill", data[j][i].series.color);
48
				bar.setAttribute("stroke-width", "0");
49
				bar.setAttribute("x", x);
50
				bar.setAttribute("y", y);
51
				bar.setAttribute("width", barWidth);
52
				bar.setAttribute("height", h);
53
				bar.setAttribute("fill-opacity", "0.6");
54
				if (applyTo) {
55
					applyTo(bar, data[j][i].src);
56
				}
57
				group.appendChild(bar);
58
			}
59
		}
60
		return group;
61
	}, HorizontalBar:function (plotarea, plot, kwArgs, applyTo) {
62
		var area = plotarea.getArea();
63
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
64
		var n = plot.series.length;
65
		var data = [];
66
		for (var i = 0; i < n; i++) {
67
			var tmp = plot.series[i].data.evaluate(kwArgs);
68
			data.push(tmp);
69
		}
70
		var space = 6;
71
		var nPoints = data[0].length;
72
		if (nPoints == 0) {
73
			return group;
74
		}
75
		var h = ((area.bottom - area.top) - (space * (nPoints - 1))) / nPoints;
76
		var barH = h / n;
77
		var xOrigin = plot.axisX.getCoord(0, plotarea, plot);
78
		for (var i = 0; i < nPoints; i++) {
79
			var yStart = area.top + (h * i) + (space * i);
80
			for (var j = 0; j < n; j++) {
81
				var value = data[j][i].y;
82
				var y = yStart + (barH * j);
83
				var xA = xOrigin;
84
				var x = plot.axisX.getCoord(value, plotarea, plot);
85
				var w = Math.abs(x - xA);
86
				if (value > 0) {
87
					x = xOrigin;
88
				}
89
				var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
90
				bar.setAttribute("fill", data[j][i].series.color);
91
				bar.setAttribute("stroke-width", "0");
92
				bar.setAttribute("x", xA);
93
				bar.setAttribute("y", y);
94
				bar.setAttribute("width", w);
95
				bar.setAttribute("height", barH);
96
				bar.setAttribute("fill-opacity", "0.6");
97
				if (applyTo) {
98
					applyTo(bar, data[j][i].src);
99
				}
100
				group.appendChild(bar);
101
			}
102
		}
103
		return group;
104
	}, Gantt:function (plotarea, plot, kwArgs, applyTo) {
105
		var area = plotarea.getArea();
106
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
107
		var n = plot.series.length;
108
		var data = [];
109
		for (var i = 0; i < n; i++) {
110
			var tmp = plot.series[i].data.evaluate(kwArgs);
111
			data.push(tmp);
112
		}
113
		var space = 2;
114
		var nPoints = data[0].length;
115
		if (nPoints == 0) {
116
			return group;
117
		}
118
		var h = ((area.bottom - area.top) - (space * (nPoints - 1))) / nPoints;
119
		var barH = h / n;
120
		for (var i = 0; i < nPoints; i++) {
121
			var yStart = area.top + (h * i) + (space * i);
122
			for (var j = 0; j < n; j++) {
123
				var high = data[j][i].high;
124
				var low = data[j][i].low;
125
				if (low > high) {
126
					var t = high;
127
					high = low;
128
					low = t;
129
				}
130
				var x = plot.axisX.getCoord(low, plotarea, plot);
131
				var w = plot.axisX.getCoord(high, plotarea, plot) - x;
132
				var y = yStart + (barH * j);
133
				var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
134
				bar.setAttribute("fill", data[j][i].series.color);
135
				bar.setAttribute("stroke-width", "0");
136
				bar.setAttribute("x", x);
137
				bar.setAttribute("y", y);
138
				bar.setAttribute("width", w);
139
				bar.setAttribute("height", barH);
140
				bar.setAttribute("fill-opacity", "0.6");
141
				if (applyTo) {
142
					applyTo(bar, data[j][i].src);
143
				}
144
				group.appendChild(bar);
145
			}
146
		}
147
		return group;
148
	}, StackedArea:function (plotarea, plot, kwArgs, applyTo) {
149
		var area = plotarea.getArea();
150
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
151
		var n = plot.series.length;
152
		var data = [];
153
		var totals = [];
154
		for (var i = 0; i < n; i++) {
155
			var tmp = plot.series[i].data.evaluate(kwArgs);
156
			for (var j = 0; j < tmp.length; j++) {
157
				if (i == 0) {
158
					totals.push(tmp[j].y);
159
				} else {
160
					totals[j] += tmp[j].y;
161
				}
162
				tmp[j].y = totals[j];
163
			}
164
			data.push(tmp);
165
		}
166
		for (var i = n - 1; i >= 0; i--) {
167
			var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
168
			path.setAttribute("fill", data[i][0].series.color);
169
			path.setAttribute("fill-opacity", "0.4");
170
			path.setAttribute("stroke", data[i][0].series.color);
171
			path.setAttribute("stroke-width", "1");
172
			path.setAttribute("stroke-opacity", "0.85");
173
			var cmd = [];
174
			var r = 3;
175
			for (var j = 0; j < data[i].length; j++) {
176
				var values = data[i];
177
				var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
178
				var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
179
				if (j == 0) {
180
					cmd.push("M");
181
				} else {
182
					cmd.push("L");
183
				}
184
				cmd.push(x + "," + y);
185
				var c = document.createElementNS(dojo.svg.xmlns.svg, "circle");
186
				c.setAttribute("cx", x);
187
				c.setAttribute("cy", y);
188
				c.setAttribute("r", "3");
189
				c.setAttribute("fill", values[j].series.color);
190
				c.setAttribute("fill-opacity", "0.6");
191
				c.setAttribute("stroke-width", "1");
192
				c.setAttribute("stroke-opacity", "0.85");
193
				group.appendChild(c);
194
				if (applyTo) {
195
					applyTo(c, data[i].src);
196
				}
197
			}
198
			if (i == 0) {
199
				cmd.push("L");
200
				cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
201
				cmd.push("L");
202
				cmd.push(plot.axisX.getCoord(data[0][0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
203
				cmd.push("Z");
204
			} else {
205
				var values = data[i - 1];
206
				cmd.push("L");
207
				cmd.push(x + "," + Math.round(plot.axisY.getCoord(values[values.length - 1].y, plotarea, plot)));
208
				for (var j = values.length - 2; j >= 0; j--) {
209
					var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
210
					var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
211
					cmd.push("L");
212
					cmd.push(x + "," + y);
213
				}
214
			}
215
			path.setAttribute("d", cmd.join(" ") + " Z");
216
			group.appendChild(path);
217
		}
218
		return group;
219
	}, StackedCurvedArea:function (plotarea, plot, kwArgs, applyTo) {
220
		var tension = 3;
221
		var area = plotarea.getArea();
222
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
223
		var n = plot.series.length;
224
		var data = [];
225
		var totals = [];
226
		for (var i = 0; i < n; i++) {
227
			var tmp = plot.series[i].data.evaluate(kwArgs);
228
			for (var j = 0; j < tmp.length; j++) {
229
				if (i == 0) {
230
					totals.push(tmp[j].y);
231
				} else {
232
					totals[j] += tmp[j].y;
233
				}
234
				tmp[j].y = totals[j];
235
			}
236
			data.push(tmp);
237
		}
238
		for (var i = n - 1; i >= 0; i--) {
239
			var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
240
			path.setAttribute("fill", data[i][0].series.color);
241
			path.setAttribute("fill-opacity", "0.4");
242
			path.setAttribute("stroke", data[i][0].series.color);
243
			path.setAttribute("stroke-width", "1");
244
			path.setAttribute("stroke-opacity", "0.85");
245
			var cmd = [];
246
			var r = 3;
247
			for (var j = 0; j < data[i].length; j++) {
248
				var values = data[i];
249
				var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
250
				var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
251
				var dx = area.left + 1;
252
				var dy = area.bottom;
253
				if (j > 0) {
254
					dx = x - plot.axisX.getCoord(values[j - 1].x, plotarea, plot);
255
					dy = plot.axisY.getCoord(values[j - 1].y, plotarea, plot);
256
				}
257
				if (j == 0) {
258
					cmd.push("M");
259
				} else {
260
					cmd.push("C");
261
					var cx = x - (tension - 1) * (dx / tension);
262
					cmd.push(cx + "," + dy);
263
					cx = x - (dx / tension);
264
					cmd.push(cx + "," + y);
265
				}
266
				cmd.push(x + "," + y);
267
				var c = document.createElementNS(dojo.svg.xmlns.svg, "circle");
268
				c.setAttribute("cx", x);
269
				c.setAttribute("cy", y);
270
				c.setAttribute("r", "3");
271
				c.setAttribute("fill", values[j].series.color);
272
				c.setAttribute("fill-opacity", "0.6");
273
				c.setAttribute("stroke-width", "1");
274
				c.setAttribute("stroke-opacity", "0.85");
275
				group.appendChild(c);
276
				if (applyTo) {
277
					applyTo(c, data[i].src);
278
				}
279
			}
280
			if (i == 0) {
281
				cmd.push("L");
282
				cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
283
				cmd.push("L");
284
				cmd.push(plot.axisX.getCoord(data[0][0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
285
				cmd.push("Z");
286
			} else {
287
				var values = data[i - 1];
288
				cmd.push("L");
289
				cmd.push(x + "," + Math.round(plot.axisY.getCoord(values[values.length - 1].y, plotarea, plot)));
290
				for (var j = values.length - 2; j >= 0; j--) {
291
					var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
292
					var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
293
					var dx = x - plot.axisX.getCoord(values[j + 1].x, plotarea, plot);
294
					var dy = plot.axisY.getCoord(values[j + 1].y, plotarea, plot);
295
					cmd.push("C");
296
					var cx = x - (tension - 1) * (dx / tension);
297
					cmd.push(cx + "," + dy);
298
					cx = x - (dx / tension);
299
					cmd.push(cx + "," + y);
300
					cmd.push(x + "," + y);
301
				}
302
			}
303
			path.setAttribute("d", cmd.join(" ") + " Z");
304
			group.appendChild(path);
305
		}
306
		return group;
307
	}, DataBar:function (data, plotarea, plot, applyTo) {
308
		var area = plotarea.getArea();
309
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
310
		var n = data.length;
311
		var w = (area.right - area.left) / (plot.axisX.range.upper - plot.axisX.range.lower);
312
		var yOrigin = plot.axisY.getCoord(plot.axisX.origin, plotarea, plot);
313
		for (var i = 0; i < n; i++) {
314
			var value = data[i].y;
315
			var yA = yOrigin;
316
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w / 2);
317
			var y = plot.axisY.getCoord(value, plotarea, plot);
318
			var h = Math.abs(yA - y);
319
			if (value < plot.axisX.origin) {
320
				yA = y;
321
				y = yOrigin;
322
			}
323
			var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
324
			bar.setAttribute("fill", data[i].series.color);
325
			bar.setAttribute("stroke-width", "0");
326
			bar.setAttribute("x", x);
327
			bar.setAttribute("y", y);
328
			bar.setAttribute("width", w);
329
			bar.setAttribute("height", h);
330
			bar.setAttribute("fill-opacity", "0.6");
331
			if (applyTo) {
332
				applyTo(bar, data[i].src);
333
			}
334
			group.appendChild(bar);
335
		}
336
		return group;
337
	}, Line:function (data, plotarea, plot, applyTo) {
338
		var area = plotarea.getArea();
339
		var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
340
		if (data.length == 0) {
341
			return line;
342
		}
343
		var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
344
		line.appendChild(path);
345
		path.setAttribute("fill", "none");
346
		path.setAttribute("stroke", data[0].series.color);
347
		path.setAttribute("stroke-width", "2");
348
		path.setAttribute("stroke-opacity", "0.85");
349
		if (data[0].series.label != null) {
350
			path.setAttribute("title", data[0].series.label);
351
		}
352
		var cmd = [];
353
		for (var i = 0; i < data.length; i++) {
354
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
355
			var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
356
			if (i == 0) {
357
				cmd.push("M");
358
			} else {
359
				cmd.push("L");
360
			}
361
			cmd.push(x + "," + y);
362
			var c = document.createElementNS(dojo.svg.xmlns.svg, "circle");
363
			c.setAttribute("cx", x);
364
			c.setAttribute("cy", y);
365
			c.setAttribute("r", "3");
366
			c.setAttribute("fill", data[i].series.color);
367
			c.setAttribute("fill-opacity", "0.6");
368
			c.setAttribute("stroke-width", "1");
369
			c.setAttribute("stroke-opacity", "0.85");
370
			line.appendChild(c);
371
			if (applyTo) {
372
				applyTo(c, data[i].src);
373
			}
374
		}
375
		path.setAttribute("d", cmd.join(" "));
376
		return line;
377
	}, CurvedLine:function (data, plotarea, plot, applyTo) {
378
		var tension = 3;
379
		var area = plotarea.getArea();
380
		var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
381
		if (data.length == 0) {
382
			return line;
383
		}
384
		var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
385
		line.appendChild(path);
386
		path.setAttribute("fill", "none");
387
		path.setAttribute("stroke", data[0].series.color);
388
		path.setAttribute("stroke-width", "2");
389
		path.setAttribute("stroke-opacity", "0.85");
390
		if (data[0].series.label != null) {
391
			path.setAttribute("title", data[0].series.label);
392
		}
393
		var cmd = [];
394
		for (var i = 0; i < data.length; i++) {
395
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
396
			var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
397
			var dx = area.left + 1;
398
			var dy = area.bottom;
399
			if (i > 0) {
400
				dx = x - plot.axisX.getCoord(data[i - 1].x, plotarea, plot);
401
				dy = plot.axisY.getCoord(data[i - 1].y, plotarea, plot);
402
			}
403
			if (i == 0) {
404
				cmd.push("M");
405
			} else {
406
				cmd.push("C");
407
				var cx = x - (tension - 1) * (dx / tension);
408
				cmd.push(cx + "," + dy);
409
				cx = x - (dx / tension);
410
				cmd.push(cx + "," + y);
411
			}
412
			cmd.push(x + "," + y);
413
			var c = document.createElementNS(dojo.svg.xmlns.svg, "circle");
414
			c.setAttribute("cx", x);
415
			c.setAttribute("cy", y);
416
			c.setAttribute("r", "3");
417
			c.setAttribute("fill", data[i].series.color);
418
			c.setAttribute("fill-opacity", "0.6");
419
			c.setAttribute("stroke-width", "1");
420
			c.setAttribute("stroke-opacity", "0.85");
421
			line.appendChild(c);
422
			if (applyTo) {
423
				applyTo(c, data[i].src);
424
			}
425
		}
426
		path.setAttribute("d", cmd.join(" "));
427
		return line;
428
	}, Area:function (data, plotarea, plot, applyTo) {
429
		var area = plotarea.getArea();
430
		var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
431
		if (data.length == 0) {
432
			return line;
433
		}
434
		var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
435
		line.appendChild(path);
436
		path.setAttribute("fill", data[0].series.color);
437
		path.setAttribute("fill-opacity", "0.4");
438
		path.setAttribute("stroke", data[0].series.color);
439
		path.setAttribute("stroke-width", "1");
440
		path.setAttribute("stroke-opacity", "0.85");
441
		if (data[0].series.label != null) {
442
			path.setAttribute("title", data[0].series.label);
443
		}
444
		var cmd = [];
445
		for (var i = 0; i < data.length; i++) {
446
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
447
			var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
448
			if (i == 0) {
449
				cmd.push("M");
450
			} else {
451
				cmd.push("L");
452
			}
453
			cmd.push(x + "," + y);
454
			var c = document.createElementNS(dojo.svg.xmlns.svg, "circle");
455
			c.setAttribute("cx", x);
456
			c.setAttribute("cy", y);
457
			c.setAttribute("r", "3");
458
			c.setAttribute("fill", data[i].series.color);
459
			c.setAttribute("fill-opacity", "0.6");
460
			c.setAttribute("stroke-width", "1");
461
			c.setAttribute("stroke-opacity", "0.85");
462
			line.appendChild(c);
463
			if (applyTo) {
464
				applyTo(c, data[i].src);
465
			}
466
		}
467
		cmd.push("L");
468
		cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
469
		cmd.push("L");
470
		cmd.push(plot.axisX.getCoord(data[0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
471
		cmd.push("Z");
472
		path.setAttribute("d", cmd.join(" "));
473
		return line;
474
	}, CurvedArea:function (data, plotarea, plot, applyTo) {
475
		var tension = 3;
476
		var area = plotarea.getArea();
477
		var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
478
		if (data.length == 0) {
479
			return line;
480
		}
481
		var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
482
		line.appendChild(path);
483
		path.setAttribute("fill", data[0].series.color);
484
		path.setAttribute("fill-opacity", "0.4");
485
		path.setAttribute("stroke", data[0].series.color);
486
		path.setAttribute("stroke-width", "1");
487
		path.setAttribute("stroke-opacity", "0.85");
488
		if (data[0].series.label != null) {
489
			path.setAttribute("title", data[0].series.label);
490
		}
491
		var cmd = [];
492
		for (var i = 0; i < data.length; i++) {
493
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
494
			var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
495
			var dx = area.left + 1;
496
			var dy = area.bottom;
497
			if (i > 0) {
498
				dx = x - plot.axisX.getCoord(data[i - 1].x, plotarea, plot);
499
				dy = plot.axisY.getCoord(data[i - 1].y, plotarea, plot);
500
			}
501
			if (i == 0) {
502
				cmd.push("M");
503
			} else {
504
				cmd.push("C");
505
				var cx = x - (tension - 1) * (dx / tension);
506
				cmd.push(cx + "," + dy);
507
				cx = x - (dx / tension);
508
				cmd.push(cx + "," + y);
509
			}
510
			cmd.push(x + "," + y);
511
			var c = document.createElementNS(dojo.svg.xmlns.svg, "circle");
512
			c.setAttribute("cx", x);
513
			c.setAttribute("cy", y);
514
			c.setAttribute("r", "3");
515
			c.setAttribute("fill", data[i].series.color);
516
			c.setAttribute("fill-opacity", "0.6");
517
			c.setAttribute("stroke-width", "1");
518
			c.setAttribute("stroke-opacity", "0.85");
519
			line.appendChild(c);
520
			if (applyTo) {
521
				applyTo(c, data[i].src);
522
			}
523
		}
524
		cmd.push("L");
525
		cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
526
		cmd.push("L");
527
		cmd.push(plot.axisX.getCoord(data[0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
528
		cmd.push("Z");
529
		path.setAttribute("d", cmd.join(" "));
530
		return line;
531
	}, HighLow:function (data, plotarea, plot, applyTo) {
532
		var area = plotarea.getArea();
533
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
534
		var n = data.length;
535
		var part = ((area.right - area.left) / (plot.axisX.range.upper - plot.axisX.range.lower)) / 4;
536
		var w = part * 2;
537
		for (var i = 0; i < n; i++) {
538
			var high = data[i].high;
539
			var low = data[i].low;
540
			if (low > high) {
541
				var t = low;
542
				low = high;
543
				high = t;
544
			}
545
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w / 2);
546
			var y = plot.axisY.getCoord(high, plotarea, plot);
547
			var h = plot.axisY.getCoord(low, plotarea, plot) - y;
548
			var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
549
			bar.setAttribute("fill", data[i].series.color);
550
			bar.setAttribute("stroke-width", "0");
551
			bar.setAttribute("x", x);
552
			bar.setAttribute("y", y);
553
			bar.setAttribute("width", w);
554
			bar.setAttribute("height", h);
555
			bar.setAttribute("fill-opacity", "0.6");
556
			if (applyTo) {
557
				applyTo(bar, data[i].src);
558
			}
559
			group.appendChild(bar);
560
		}
561
		return group;
562
	}, HighLowClose:function (data, plotarea, plot, applyTo) {
563
		var area = plotarea.getArea();
564
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
565
		var n = data.length;
566
		var part = ((area.right - area.left) / (plot.axisX.range.upper - plot.axisX.range.lower)) / 4;
567
		var w = part * 2;
568
		for (var i = 0; i < n; i++) {
569
			var high = data[i].high;
570
			var low = data[i].low;
571
			if (low > high) {
572
				var t = low;
573
				low = high;
574
				high = t;
575
			}
576
			var c = data[i].close;
577
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w / 2);
578
			var y = plot.axisY.getCoord(high, plotarea, plot);
579
			var h = plot.axisY.getCoord(low, plotarea, plot) - y;
580
			var close = plot.axisY.getCoord(c, plotarea, plot);
581
			var g = document.createElementNS(dojo.svg.xmlns.svg, "g");
582
			var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
583
			bar.setAttribute("fill", data[i].series.color);
584
			bar.setAttribute("stroke-width", "0");
585
			bar.setAttribute("x", x);
586
			bar.setAttribute("y", y);
587
			bar.setAttribute("width", w);
588
			bar.setAttribute("height", h);
589
			bar.setAttribute("fill-opacity", "0.6");
590
			g.appendChild(bar);
591
			var line = document.createElementNS(dojo.svg.xmlns.svg, "line");
592
			line.setAttribute("x1", x);
593
			line.setAttribute("x2", x + w + (part * 2));
594
			line.setAttribute("y1", close);
595
			line.setAttribute("y2", close);
596
			line.setAttribute("style", "stroke:" + data[i].series.color + ";stroke-width:1px;stroke-opacity:0.6;");
597
			g.appendChild(line);
598
			if (applyTo) {
599
				applyTo(g, data[i].src);
600
			}
601
			group.appendChild(g);
602
		}
603
		return group;
604
	}, HighLowOpenClose:function (data, plotarea, plot, applyTo) {
605
		var area = plotarea.getArea();
606
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
607
		var n = data.length;
608
		var part = ((area.right - area.left) / (plot.axisX.range.upper - plot.axisX.range.lower)) / 4;
609
		var w = part * 2;
610
		for (var i = 0; i < n; i++) {
611
			var high = data[i].high;
612
			var low = data[i].low;
613
			if (low > high) {
614
				var t = low;
615
				low = high;
616
				high = t;
617
			}
618
			var o = data[i].open;
619
			var c = data[i].close;
620
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w / 2);
621
			var y = plot.axisY.getCoord(high, plotarea, plot);
622
			var h = plot.axisY.getCoord(low, plotarea, plot) - y;
623
			var open = plot.axisY.getCoord(o, plotarea, plot);
624
			var close = plot.axisY.getCoord(c, plotarea, plot);
625
			var g = document.createElementNS(dojo.svg.xmlns.svg, "g");
626
			var bar = document.createElementNS(dojo.svg.xmlns.svg, "rect");
627
			bar.setAttribute("fill", data[i].series.color);
628
			bar.setAttribute("stroke-width", "0");
629
			bar.setAttribute("x", x);
630
			bar.setAttribute("y", y);
631
			bar.setAttribute("width", w);
632
			bar.setAttribute("height", h);
633
			bar.setAttribute("fill-opacity", "0.6");
634
			g.appendChild(bar);
635
			var line = document.createElementNS(dojo.svg.xmlns.svg, "line");
636
			line.setAttribute("x1", x - (part * 2));
637
			line.setAttribute("x2", x + w);
638
			line.setAttribute("y1", open);
639
			line.setAttribute("y2", open);
640
			line.setAttribute("style", "stroke:" + data[i].series.color + ";stroke-width:1px;stroke-opacity:0.6;");
641
			g.appendChild(line);
642
			var line = document.createElementNS(dojo.svg.xmlns.svg, "line");
643
			line.setAttribute("x1", x);
644
			line.setAttribute("x2", x + w + (part * 2));
645
			line.setAttribute("y1", close);
646
			line.setAttribute("y2", close);
647
			line.setAttribute("style", "stroke:" + data[i].series.color + ";stroke-width:1px;stroke-opacity:0.6;");
648
			g.appendChild(line);
649
			if (applyTo) {
650
				applyTo(g, data[i].src);
651
			}
652
			group.appendChild(g);
653
		}
654
		return group;
655
	}, Scatter:function (data, plotarea, plot, applyTo) {
656
		var r = 7;
657
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
658
		for (var i = 0; i < data.length; i++) {
659
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
660
			var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
661
			var point = document.createElementNS(dojo.svg.xmlns.svg, "path");
662
			point.setAttribute("fill", data[i].series.color);
663
			point.setAttribute("stroke-width", "0");
664
			point.setAttribute("d", "M " + x + "," + (y - r) + " " + "Q " + x + "," + y + " " + (x + r) + "," + y + " " + "Q " + x + "," + y + " " + x + "," + (y + r) + " " + "Q " + x + "," + y + " " + (x - r) + "," + y + " " + "Q " + x + "," + y + " " + x + "," + (y - r) + " " + "Z");
665
			if (applyTo) {
666
				applyTo(point, data[i].src);
667
			}
668
			group.appendChild(point);
669
		}
670
		return group;
671
	}, Bubble:function (data, plotarea, plot, applyTo) {
672
		var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
673
		var sizeFactor = 1;
674
		for (var i = 0; i < data.length; i++) {
675
			var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
676
			var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
677
			if (i == 0) {
678
				var raw = data[i].size;
679
				var dy = plot.axisY.getCoord(data[i].y + raw, plotarea, plot) - y;
680
				sizeFactor = dy / raw;
681
			}
682
			if (sizeFactor < 1) {
683
				sizeFactor = 1;
684
			}
685
			var point = document.createElementNS(dojo.svg.xmlns.svg, "circle");
686
			point.setAttribute("fill", data[i].series.color);
687
			point.setAttribute("fill-opacity", "0.8");
688
			point.setAttribute("stroke", data[i].series.color);
689
			point.setAttribute("stroke-width", "1");
690
			point.setAttribute("cx", x);
691
			point.setAttribute("cy", y);
692
			point.setAttribute("r", (data[i].size / 2) * sizeFactor);
693
			if (applyTo) {
694
				applyTo(point, data[i].src);
695
			}
696
			group.appendChild(point);
697
		}
698
		return group;
699
	}});
700
	dojo.charting.Plotters["Default"] = dojo.charting.Plotters.Line;
701
}
702