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