1 | define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/html", "dojo/query", |
---|
2 | "./Chart", "../themes/GreySkies", "../plot2d/Lines", "dojo/dom-prop"], |
---|
3 | function(lang, arrayUtil, declare, html, query, Chart, GreySkies, Lines, domProp){ |
---|
4 | /*===== |
---|
5 | var Chart = dojox.charting.widget.Chart; |
---|
6 | =====*/ |
---|
7 | |
---|
8 | declare("dojox.charting.widget.Sparkline", Chart, { |
---|
9 | theme: GreySkies, |
---|
10 | margins: { l: 0, r: 0, t: 0, b: 0 }, |
---|
11 | type: "Lines", |
---|
12 | valueFn: "Number(x)", |
---|
13 | store: "", |
---|
14 | field: "", |
---|
15 | query: "", |
---|
16 | queryOptions: "", |
---|
17 | start: "0", |
---|
18 | count: "Infinity", |
---|
19 | sort: "", |
---|
20 | data: "", |
---|
21 | name: "default", |
---|
22 | buildRendering: function(){ |
---|
23 | var n = this.srcNodeRef; |
---|
24 | if( !n.childNodes.length || // shortcut the query |
---|
25 | !query("> .axis, > .plot, > .action, > .series", n).length){ |
---|
26 | var plot = document.createElement("div"); |
---|
27 | domProp.set(plot, { |
---|
28 | "class": "plot", |
---|
29 | "name": "default", |
---|
30 | "type": this.type |
---|
31 | }); |
---|
32 | n.appendChild(plot); |
---|
33 | |
---|
34 | var series = document.createElement("div"); |
---|
35 | domProp.set(series, { |
---|
36 | "class": "series", |
---|
37 | plot: "default", |
---|
38 | name: this.name, |
---|
39 | start: this.start, |
---|
40 | count: this.count, |
---|
41 | valueFn: this.valueFn |
---|
42 | }); |
---|
43 | arrayUtil.forEach( |
---|
44 | ["store", "field", "query", "queryOptions", "sort", "data"], |
---|
45 | function(i){ |
---|
46 | if(this[i].length){ |
---|
47 | domProp.set(series, i, this[i]); |
---|
48 | } |
---|
49 | }, |
---|
50 | this |
---|
51 | ); |
---|
52 | n.appendChild(series); |
---|
53 | } |
---|
54 | this.inherited(arguments); |
---|
55 | } |
---|
56 | } |
---|
57 | ); |
---|
58 | }); |
---|