summaryrefslogtreecommitdiff
path: root/js/dojo-1.7.2/dojox/charting/widget/Sparkline.js
blob: 4dbe6ae81b19560689bed97f62a1a5b429339e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//>>built
define("dojox/charting/widget/Sparkline", ["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/html", "dojo/query", 
	"./Chart", "../themes/GreySkies", "../plot2d/Lines", "dojo/dom-prop"], 
	function(lang, arrayUtil, declare, html, query, Chart, GreySkies, Lines, domProp){
/*=====
var Chart = dojox.charting.widget.Chart;
=====*/

	declare("dojox.charting.widget.Sparkline", Chart, {
			theme: GreySkies,
			margins: { l: 0, r: 0, t: 0, b: 0 },
			type: "Lines",
			valueFn: "Number(x)",
			store: "",
			field: "",
			query: "",
			queryOptions: "",
			start: "0",
			count: "Infinity",
			sort: "",
			data: "",
			name: "default",
			buildRendering: function(){
				var n = this.srcNodeRef;
				if(	!n.childNodes.length || // shortcut the query
					!query("> .axis, > .plot, > .action, > .series", n).length){
					var plot = document.createElement("div");
					domProp.set(plot, {
						"class": "plot",
						"name": "default",
						"type": this.type
					});
					n.appendChild(plot);

					var series = document.createElement("div");
					domProp.set(series, {
						"class": "series",
						plot: "default",
						name: this.name,
						start: this.start,
						count: this.count,
						valueFn: this.valueFn
					});
					arrayUtil.forEach(
						["store", "field", "query", "queryOptions", "sort", "data"],
						function(i){
							if(this[i].length){
								domProp.set(series, i, this[i]);
							}
						},
						this
					);
					n.appendChild(series);
				}
				this.inherited(arguments);
			}
		}
	);
});