Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | 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.PlotArea");
14
dojo.require("dojo.lang.common");
15
if (dojo.render.svg.capable) {
16
	dojo.require("dojo.svg");
17
	dojo.extend(dojo.charting.PlotArea, {resize:function () {
18
		var area = this.getArea();
19
		this.nodes.area.setAttribute("width", this.size.width);
20
		this.nodes.area.setAttribute("height", this.size.height);
21
		var rect = this.nodes.area.getElementsByTagName("rect")[0];
22
		rect.setAttribute("x", area.left);
23
		rect.setAttribute("y", area.top);
24
		rect.setAttribute("width", area.right - area.left);
25
		rect.setAttribute("height", area.bottom - area.top);
26
		this.nodes.background.setAttribute("width", this.size.width);
27
		this.nodes.background.setAttribute("height", this.size.height);
28
		if (this.nodes.plots) {
29
			this.nodes.area.removeChild(this.nodes.plots);
30
			this.nodes.plots = null;
31
		}
32
		this.nodes.plots = document.createElementNS(dojo.svg.xmlns.svg, "g");
33
		this.nodes.plots.setAttribute("id", this.getId() + "-plots");
34
		this.nodes.plots.setAttribute("style", "clip-path:url(#" + this.getId() + "-clip);");
35
		this.nodes.area.appendChild(this.nodes.plots);
36
		for (var i = 0; i < this.plots.length; i++) {
37
			this.nodes.plots.appendChild(this.initializePlot(this.plots[i]));
38
		}
39
		if (this.nodes.axes) {
40
			this.nodes.area.removeChild(this.nodes.axes);
41
			this.nodes.axes = null;
42
		}
43
		this.nodes.axes = document.createElementNS(dojo.svg.xmlns.svg, "g");
44
		this.nodes.axes.setAttribute("id", this.getId() + "-axes");
45
		this.nodes.area.appendChild(this.nodes.axes);
46
		var axes = this.getAxes();
47
		for (var p in axes) {
48
			var obj = axes[p];
49
			this.nodes.axes.appendChild(obj.axis.initialize(this, obj.plot, obj.drawAgainst, obj.plane));
50
		}
51
	}, initializePlot:function (plot) {
52
		plot.destroy();
53
		plot.dataNode = document.createElementNS(dojo.svg.xmlns.svg, "g");
54
		plot.dataNode.setAttribute("id", plot.getId());
55
		return plot.dataNode;
56
	}, initialize:function () {
57
		this.destroy();
58
		this.nodes.main = document.createElement("div");
59
		this.nodes.area = document.createElementNS(dojo.svg.xmlns.svg, "svg");
60
		this.nodes.area.setAttribute("id", this.getId());
61
		this.nodes.main.appendChild(this.nodes.area);
62
		var defs = document.createElementNS(dojo.svg.xmlns.svg, "defs");
63
		var clip = document.createElementNS(dojo.svg.xmlns.svg, "clipPath");
64
		clip.setAttribute("id", this.getId() + "-clip");
65
		var rect = document.createElementNS(dojo.svg.xmlns.svg, "rect");
66
		clip.appendChild(rect);
67
		defs.appendChild(clip);
68
		this.nodes.area.appendChild(defs);
69
		this.nodes.background = document.createElementNS(dojo.svg.xmlns.svg, "rect");
70
		this.nodes.background.setAttribute("id", this.getId() + "-background");
71
		this.nodes.background.setAttribute("fill", "#fff");
72
		this.nodes.area.appendChild(this.nodes.background);
73
		this.resize();
74
		return this.nodes.main;
75
	}});
76
}
77