Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1372 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
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:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.charting.Chart");
13
dojo.provide("dojo.charting.Chart");
12
dojo.require("dojo.lang.common");
14
dojo.require("dojo.lang.common");
13
dojo.require("dojo.charting.PlotArea");
15
dojo.require("dojo.charting.PlotArea");
14
dojo.charting.Chart = function (node, title, description) {
16
dojo.charting.Chart = function (node, title, description) {
15
	this.node = node || null;
17
	this.node = node || null;
16
	this.title = title || "Chart";
18
	this.title = title || "Chart";
17
	this.description = description || "";
19
	this.description = description || "";
18
	this.plotAreas = [];
20
	this.plotAreas = [];
19
};
21
};
20
dojo.extend(dojo.charting.Chart, {addPlotArea:function (obj, doRender) {
22
dojo.extend(dojo.charting.Chart, {addPlotArea:function (obj, doRender) {
21
	if (obj.x != null && obj.left == null) {
23
	if (obj.x != null && obj.left == null) {
22
		obj.left = obj.x;
24
		obj.left = obj.x;
23
	}
25
	}
24
	if (obj.y != null && obj.top == null) {
26
	if (obj.y != null && obj.top == null) {
25
		obj.top = obj.y;
27
		obj.top = obj.y;
26
	}
28
	}
27
	this.plotAreas.push(obj);
29
	this.plotAreas.push(obj);
28
	if (doRender) {
30
	if (doRender) {
29
		this.render();
31
		this.render();
30
	}
32
	}
31
}, onInitialize:function (chart) {
33
}, onInitialize:function (chart) {
32
}, onRender:function (chart) {
34
}, onRender:function (chart) {
33
}, onDestroy:function (chart) {
35
}, onDestroy:function (chart) {
34
}, initialize:function () {
36
}, initialize:function () {
35
	if (!this.node) {
37
	if (!this.node) {
36
		dojo.raise("dojo.charting.Chart.initialize: there must be a root node defined for the Chart.");
38
		dojo.raise("dojo.charting.Chart.initialize: there must be a root node defined for the Chart.");
37
	}
39
	}
38
	this.destroy();
40
	this.destroy();
39
	this.render();
41
	this.render();
40
	this.onInitialize(this);
42
	this.onInitialize(this);
41
}, render:function () {
43
}, render:function () {
42
	if (this.node.style.position != "absolute") {
44
	if (this.node.style.position != "absolute") {
43
		this.node.style.position = "relative";
45
		this.node.style.position = "relative";
44
	}
46
	}
45
	for (var i = 0; i < this.plotAreas.length; i++) {
47
	for (var i = 0; i < this.plotAreas.length; i++) {
46
		var area = this.plotAreas[i].plotArea;
48
		var area = this.plotAreas[i].plotArea;
47
		var node = area.initialize();
49
		var node = area.initialize();
48
		node.style.position = "absolute";
50
		node.style.position = "absolute";
49
		node.style.top = this.plotAreas[i].top + "px";
51
		node.style.top = this.plotAreas[i].top + "px";
50
		node.style.left = this.plotAreas[i].left + "px";
52
		node.style.left = this.plotAreas[i].left + "px";
51
		this.node.appendChild(node);
53
		this.node.appendChild(node);
52
		area.render();
54
		area.render();
53
	}
55
	}
54
}, destroy:function () {
56
}, destroy:function () {
55
	for (var i = 0; i < this.plotAreas.length; i++) {
57
	for (var i = 0; i < this.plotAreas.length; i++) {
56
		this.plotAreas[i].plotArea.destroy();
58
		this.plotAreas[i].plotArea.destroy();
57
	}
59
	}
58
	while (this.node && this.node.childNodes && this.node.childNodes.length > 0) {
60
	while (this.node && this.node.childNodes && this.node.childNodes.length > 0) {
59
		this.node.removeChild(this.node.childNodes[0]);
61
		this.node.removeChild(this.node.childNodes[0]);
60
	}
62
	}
61
}});
63
}});
62
 
64