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
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.charting.Chart");
14
dojo.require("dojo.lang.common");
15
dojo.require("dojo.charting.PlotArea");
16
dojo.charting.Chart = function (node, title, description) {
17
	this.node = node || null;
18
	this.title = title || "Chart";
19
	this.description = description || "";
20
	this.plotAreas = [];
21
};
22
dojo.extend(dojo.charting.Chart, {addPlotArea:function (obj, doRender) {
23
	if (obj.x != null && obj.left == null) {
24
		obj.left = obj.x;
25
	}
26
	if (obj.y != null && obj.top == null) {
27
		obj.top = obj.y;
28
	}
29
	this.plotAreas.push(obj);
30
	if (doRender) {
31
		this.render();
32
	}
33
}, onInitialize:function (chart) {
34
}, onRender:function (chart) {
35
}, onDestroy:function (chart) {
36
}, initialize:function () {
37
	if (!this.node) {
38
		dojo.raise("dojo.charting.Chart.initialize: there must be a root node defined for the Chart.");
39
	}
40
	this.destroy();
41
	this.render();
42
	this.onInitialize(this);
43
}, render:function () {
44
	if (this.node.style.position != "absolute") {
45
		this.node.style.position = "relative";
46
	}
47
	for (var i = 0; i < this.plotAreas.length; i++) {
48
		var area = this.plotAreas[i].plotArea;
49
		var node = area.initialize();
50
		node.style.position = "absolute";
51
		node.style.top = this.plotAreas[i].top + "px";
52
		node.style.left = this.plotAreas[i].left + "px";
53
		this.node.appendChild(node);
54
		area.render();
55
	}
56
}, destroy:function () {
57
	for (var i = 0; i < this.plotAreas.length; i++) {
58
		this.plotAreas[i].plotArea.destroy();
59
	}
60
	while (this.node && this.node.childNodes && this.node.childNodes.length > 0) {
61
		this.node.removeChild(this.node.childNodes[0]);
62
	}
63
}});
64