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