Subversion Repositories Applications.papyrus

Rev

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