| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
<![if gte IE 9]> |
| 13 |
<!DOCTYPE HTML> |
| 14 |
<html lang="en"> |
| 15 |
<head> |
| 16 |
<![endif]> |
| 17 |
<title>Chart 2D: Animation tests</title> |
| 18 |
<style type="text/css"> |
| 19 |
@import "../../../../dojo/resources/dojo.css"; |
| 20 |
@import "../../../../dijit/tests/css/dijitTests.css"; |
| 21 |
</style> |
| 22 |
<script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, has:{'dojo-bidi': true}"></script> |
| 23 |
<script type="text/javascript"> |
| 24 |
|
| 25 |
dojo.require("dojox.charting.Chart"); |
| 26 |
dojo.require("dojox.charting.axis2d.Default"); |
| 27 |
dojo.require("dojox.charting.plot2d.ClusteredColumns"); |
| 28 |
dojo.require("dojox.charting.plot2d.StackedAreas"); |
| 29 |
dojo.require("dojox.charting.plot2d.Grid"); |
| 30 |
dojo.require("dojox.charting.plot2d.Indicator"); |
| 31 |
|
| 32 |
dojo.require("dojox.charting.themes.Shrooms"); |
| 33 |
dojo.require("dojox.charting.themes.PlotKit.blue"); |
| 34 |
dojo.require("dojox.charting.themes.PlotKit.cyan"); |
| 35 |
dojo.require("dojox.charting.themes.PlotKit.green"); |
| 36 |
dojo.require("dojox.charting.themes.Ireland"); |
| 37 |
dojo.require("dojox.charting.themes.SageToLime"); |
| 38 |
dojo.require("dojox.charting.themes.Minty"); |
| 39 |
dojo.require("dojox.charting.themes.Tufte"); |
| 40 |
|
| 41 |
dojo.require("dojox.dtl"); |
| 42 |
dojo.require("dojox.dtl.Context"); |
| 43 |
|
| 44 |
charts = [ |
| 45 |
{ |
| 46 |
description: "Columns, grid and indicators.", |
| 47 |
makeChart: function(node){ |
| 48 |
(new dojox.charting.Chart(node)). |
| 49 |
setTheme(dojox.charting.themes.Tufte). |
| 50 |
addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }). |
| 51 |
addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true }). |
| 52 |
addPlot("default", { type: "ClusteredColumns", gap: 10, animate: { duration: 1000 } }). |
| 53 |
addPlot("indicator", { type: "Indicator", values: 1.5, lineStroke: { color: "red" }, precision: 1, animate: { duration: 1000 } }). |
| 54 |
addPlot("grid", { type: "Grid", animate: { duration: 1000 } }). |
| 55 |
addSeries("Series A", [ 2, 1, 0.5, -1, -2 ] ). |
| 56 |
addSeries("Series B", [ -2, -1, -0.5, 1, 2 ] ). |
| 57 |
addSeries("Series C", [ 1, 0.5, -1, -2, -3 ] ). |
| 58 |
addSeries("Series D", [ 0.7, 1.5, -1.2, -1.25, 3 ] ). |
| 59 |
setDir("rtl"). |
| 60 |
render(); |
| 61 |
} |
| 62 |
}, |
| 63 |
{ |
| 64 |
description: "Clustered columns with positive and negative values, readable theme, 1-second animate-in.", |
| 65 |
makeChart: function(node){ |
| 66 |
(new dojox.charting.Chart(node)). |
| 67 |
setTheme(dojox.charting.themes.Tufte). |
| 68 |
addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }). |
| 69 |
addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true }). |
| 70 |
addPlot("default", { type: "ClusteredColumns", gap: 10, animate: { duration: 1000 } }). |
| 71 |
addSeries("Series A", [ 2, 1, 0.5, -1, -2 ] ). |
| 72 |
addSeries("Series B", [ -2, -1, -0.5, 1, 2 ] ). |
| 73 |
addSeries("Series C", [ 1, 0.5, -1, -2, -3 ] ). |
| 74 |
addSeries("Series D", [ 0.7, 1.5, -1.2, -1.25, 3 ] ). |
| 75 |
setDir("rtl"). |
| 76 |
render(); |
| 77 |
} |
| 78 |
}, |
| 79 |
|
| 80 |
{ |
| 81 |
description: "StackedAreas 3-second animate-in.", |
| 82 |
makeChart: function(node){ |
| 83 |
(new dojox.charting.Chart(node)). |
| 84 |
setTheme(dojox.charting.themes.Tufte). |
| 85 |
addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }). |
| 86 |
addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true }). |
| 87 |
addPlot("default", { type: "StackedAreas", gap: 10, animate: { duration: 3000 } }). |
| 88 |
addSeries("Series A", [ 2, 1, 0.5, 1, 1.5 ] ). |
| 89 |
addSeries("Series B", [ 0, 1, 0.5, 1, 0.5 ] ). |
| 90 |
addSeries("Series C", [ 1, 0.5, 0, 2, 3 ] ). |
| 91 |
addSeries("Series D", [ 0.7, 1.5, 1.2, 1.25, 1 ] ). |
| 92 |
setDir("rtl"). |
| 93 |
render(); |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
]; |
| 99 |
var now = function(){ |
| 100 |
return (new Date()).getTime(); |
| 101 |
}; |
| 102 |
|
| 103 |
|
| 104 |
dojo.addOnLoad(function(){ |
| 105 |
var defaultStyle = { width: "400px", height: "200px" }; |
| 106 |
var tmpl = new dojox.dtl.Template(dojo.byId("template").value); |
| 107 |
var context = new dojox.dtl.Context({ charts: charts }); |
| 108 |
dojo.byId("charts").innerHTML = tmpl.render(context); |
| 109 |
|
| 110 |
dojo.forEach(charts, function(item, idx){ |
| 111 |
var start = now(); |
| 112 |
var n = dojo.byId("chart_"+idx); |
| 113 |
dojo.style(n, item.style||defaultStyle); |
| 114 |
item.makeChart(n); |
| 115 |
console.debug((now()-start), "ms to create:", (idx+1)+":", item.description); |
| 116 |
}); |
| 117 |
}); |
| 118 |
|
| 119 |
</script> |
| 120 |
</head> |
| 121 |
<body> |
| 122 |
<textarea id="template" style="display: none;"> |
| 123 |
{% for item in charts %} |
| 124 |
<p>{{ forloop.counter }}: {{ item.description }}</p> |
| 125 |
<div id="chart_{{ forloop.counter0 }}"></div> |
| 126 |
{% endfor %} |
| 127 |
</textarea> |
| 128 |
|
| 129 |
<h1>Chart 2D: Animation tests</h1> |
| 130 |
|
| 131 |
<div id="charts"></div> |
| 132 |
</body> |
| 133 |
</html> |