| 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 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 18 |
<title>Chart 2D rotated labels</title> |
| 19 |
<style type="text/css"> |
| 20 |
@import "../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 22 |
@import "../../../dijit/themes/tundra/tundra.css"; |
| 23 |
</style> |
| 24 |
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
| 25 |
<script type="text/javascript"> |
| 26 |
|
| 27 |
dojo.require("dijit.form.Button"); |
| 28 |
dojo.require("dijit.form.NumberSpinner"); |
| 29 |
|
| 30 |
dojo.require("dojox.charting.Chart"); |
| 31 |
dojo.require("dojox.charting.axis2d.Default"); |
| 32 |
dojo.require("dojox.charting.plot2d.Default"); |
| 33 |
dojo.require("dojox.charting.themes.PrimaryColors"); |
| 34 |
|
| 35 |
dojo.require("dojo.parser"); |
| 36 |
|
| 37 |
var charts = []; |
| 38 |
|
| 39 |
makeObjects = function(){ |
| 40 |
dojo.query(".chart").forEach(function(node, index){ |
| 41 |
charts[index] = new dojox.charting.Chart(node). |
| 42 |
setTheme(dojox.charting.themes.PrimaryColors). |
| 43 |
addPlot("default"). |
| 44 |
addSeries("Series A", [1, 3, 2, 5, 4]). |
| 45 |
addPlot("default2", {hAxis: "x2", vAxis: "y2"}). |
| 46 |
addSeries("Series B", [5, 3, 4, 1, 2], {plot: "default2"}); |
| 47 |
updateAxes(); |
| 48 |
}); |
| 49 |
}; |
| 50 |
|
| 51 |
dojo.addOnLoad(makeObjects); |
| 52 |
|
| 53 |
updateAxes = function(){ |
| 54 |
var rotation = dijit.byId("rotation").get("value"); |
| 55 |
dojo.forEach(charts, function(chart, index){ |
| 56 |
if(index == 0){ |
| 57 |
chart. |
| 58 |
addAxis("x", { |
| 59 |
htmlLabels: false, fixLower: "major", fixUpper: "major", min: 0, max: 6, |
| 60 |
labels: [ |
| 61 |
{value: 0, text: "zero"}, |
| 62 |
{value: 1, text: "one"}, |
| 63 |
{value: 2, text: "two"}, |
| 64 |
{value: 3, text: "three"}, |
| 65 |
{value: 4, text: "four"}, |
| 66 |
{value: 5, text: "five"}, |
| 67 |
{value: 6, text: "six"} |
| 68 |
], |
| 69 |
rotation: rotation |
| 70 |
}). |
| 71 |
addAxis("y", { |
| 72 |
htmlLabels: false, vertical: true, fixLower: "major", fixUpper: "major", natural: true, min: 0, max: 6, |
| 73 |
labels: [{value: 0, text: ""}, |
| 74 |
{value: 1, text: "January"}, {value: 2, text: "February"}, |
| 75 |
{value: 3, text: "March"}, {value: 4, text: "April"}, |
| 76 |
{value: 5, text: "May"}, {value: 6, text: "June"} |
| 77 |
], |
| 78 |
rotation: rotation |
| 79 |
}). |
| 80 |
addAxis("x2", { |
| 81 |
htmlLabels: false, fixLower: "major", fixUpper: "major", min: 0, max: 6, leftBottom: false, |
| 82 |
rotation: rotation |
| 83 |
}). |
| 84 |
addAxis("y2", { |
| 85 |
htmlLabels: false, vertical: true, fixLower: "major", fixUpper: "major", min: 0, max: 6, leftBottom: false, |
| 86 |
rotation: rotation |
| 87 |
}). |
| 88 |
render(); |
| 89 |
} |
| 90 |
else if(index == 1){ |
| 91 |
chart. |
| 92 |
addAxis("x", { |
| 93 |
htmlLabels: false, fixLower: "major", fixUpper: "major", min: 0, max: 6, |
| 94 |
labels: [ |
| 95 |
{value: 0, text: "zero"}, |
| 96 |
{value: 1, text: "one"}, |
| 97 |
{value: 2, text: "two"}, |
| 98 |
{value: 3, text: "three"}, |
| 99 |
{value: 4, text: "four"}, |
| 100 |
{value: 5, text: "five"}, |
| 101 |
{value: 6, text: "six"} |
| 102 |
], |
| 103 |
rotation: rotation, |
| 104 |
position: "center" |
| 105 |
}). |
| 106 |
addAxis("y", { |
| 107 |
htmlLabels: false, vertical: true, fixLower: "major", fixUpper: "major", natural: true, min: 0, max: 6, |
| 108 |
labels: [{value: 0, text: ""}, |
| 109 |
{value: 1, text: "January"}, {value: 2, text: "February"}, |
| 110 |
{value: 3, text: "March"}, {value: 4, text: "April"}, |
| 111 |
{value: 5, text: "May"}, {value: 6, text: "June"} |
| 112 |
], |
| 113 |
rotation: rotation, |
| 114 |
position: "center" |
| 115 |
}). |
| 116 |
addAxis("x2", { |
| 117 |
htmlLabels: false, fixLower: "major", fixUpper: "major", min: 0, max: 6, leftBottom: false, |
| 118 |
rotation: rotation |
| 119 |
}). |
| 120 |
addAxis("y2", { |
| 121 |
htmlLabels: false, vertical: true, fixLower: "major", fixUpper: "major", min: 0, max: 6, leftBottom: false, |
| 122 |
rotation: rotation |
| 123 |
}). |
| 124 |
render(); |
| 125 |
} |
| 126 |
}); |
| 127 |
} |
| 128 |
|
| 129 |
</script> |
| 130 |
</head> |
| 131 |
<body class="tundra"> |
| 132 |
<h1>Chart 2D rotated labels</h1> |
| 133 |
|
| 134 |
<p> |
| 135 |
Rotation: |
| 136 |
<input dojoType="dijit.form.NumberSpinner" id="rotation" value="0" constraints="{min: 0, max: 360, fractional: false}" style="width: 8em;"> |
| 137 |
|
| 138 |
<button dojoType="dijit.form.Button" onClick="updateAxes()">Apply</button> |
| 139 |
</p> |
| 140 |
<div class="chart" id="test1" style="width: 500px; height: 300px;"></div> |
| 141 |
<p> </p> |
| 142 |
<div class="chart" id="test2" style="width: 500px; height: 300px;"></div> |
| 143 |
<p>That's all Folks!</p> |
| 144 |
</body> |
| 145 |
</html> |