| 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>Example Dojo Chart Types</title> |
| 19 |
<style> |
| 20 |
@import "../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 22 |
#chartContainer { |
| 23 |
position: relative; |
| 24 |
height: 660px; |
| 25 |
} |
| 26 |
.chart { |
| 27 |
position: absolute; |
| 28 |
top: 0; |
| 29 |
left: 0; |
| 30 |
width: 300px; |
| 31 |
height: 200px; |
| 32 |
} |
| 33 |
#lines, #area, #columns { |
| 34 |
left: 320px; |
| 35 |
} |
| 36 |
#bubbles, #area, #pieLin { |
| 37 |
top: 220px; |
| 38 |
} |
| 39 |
#pieLin, #pieFan, #ohlc { |
| 40 |
left: 640px; |
| 41 |
} |
| 42 |
#candle, #columns, #ohlc { |
| 43 |
top: 440px; |
| 44 |
} |
| 45 |
#candle svg, |
| 46 |
#ohlc svg { |
| 47 |
shape-rendering: crispEdges; |
| 48 |
} |
| 49 |
</style> |
| 50 |
<script src="../../../dojo/dojo.js" data-dojo-config="isDebug: false, async: true, gfxRenderer: 'svg,silverlight,vml,canvas'"></script> |
| 51 |
<script> |
| 52 |
require(["dojo/_base/window", "dojo/dom", "dojo/dom-construct", "dojo/dom-style", "dojo/ready", "dojo/on", "dojo/query", |
| 53 |
"dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/ClusteredBars", |
| 54 |
"dojox/charting/plot2d/ClusteredColumns", "dojox/charting/plot2d/Default", "dojox/charting/plot2d/StackedAreas", |
| 55 |
"dojox/charting/plot2d/Bubble", "dojox/charting/plot2d/Candlesticks", "dojox/charting/plot2d/OHLC", |
| 56 |
"dojox/charting/plot2d/Pie"], |
| 57 |
function(win, dom, domConstruct, domStyle, ready, on, query, Chart, Default, ClusteredBars, |
| 58 |
ClusteredColumns, Lines, StackedAreas, Bubble, Candlesticks, OHLC, Pie){ |
| 59 |
|
| 60 |
var charts = {}, backgroundImage, backgroundColor, color, lastThemeName = ""; |
| 61 |
|
| 62 |
function update(name){ |
| 63 |
// change the theme based on the select change. |
| 64 |
var select = dom.byId("themeChooser"), |
| 65 |
usePageStyle = dom.byId("pageStyleChooser").checked; |
| 66 |
|
| 67 |
var test = false; |
| 68 |
if(name){ |
| 69 |
// make sure it's in the list first. |
| 70 |
for(var i=0, l=select.options.length; i<l; i++){ |
| 71 |
if(select.options[i].value == name){ |
| 72 |
select.options[i].selected = true; |
| 73 |
test = true; |
| 74 |
break; |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
if(!test){ |
| 80 |
name = select.options[select.selectedIndex].value; |
| 81 |
} |
| 82 |
|
| 83 |
require(["dojox/charting/themes/" + name.replace(".", "/")], function(theme){ |
| 84 |
|
| 85 |
var chartStyle = theme.chart; |
| 86 |
|
| 87 |
// set the suggested page style |
| 88 |
if(usePageStyle && chartStyle.pageStyle){ |
| 89 |
domStyle.set(win.body(), chartStyle.pageStyle); |
| 90 |
}else{ |
| 91 |
domStyle.set(win.body(), { |
| 92 |
backgroundColor: backgroundColor, |
| 93 |
backgroundImage: backgroundImage, |
| 94 |
color: color |
| 95 |
}); |
| 96 |
} |
| 97 |
// set the theme |
| 98 |
if(lastThemeName != name){ |
| 99 |
lastThemeName = name; |
| 100 |
if(theme){ |
| 101 |
for(var chartName in charts){ |
| 102 |
charts[chartName].setTheme(theme).render(); |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
}); |
| 107 |
} |
| 108 |
|
| 109 |
function init(){ |
| 110 |
// retrieve initial values for fg/bg |
| 111 |
backgroundImage = domStyle.get(win.body(), "backgroundImage"); |
| 112 |
backgroundColor = domStyle.get(win.body(), "backgroundColor"); |
| 113 |
color = domStyle.get(win.body(), "color"); |
| 114 |
|
| 115 |
charts.bars = new Chart("bars"). |
| 116 |
addAxis("y", {fixLower: "minor", fixUpper: "minor", natural: true}). |
| 117 |
addAxis("x", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true}). |
| 118 |
addPlot("default", {type: ClusteredBars, gap: 5}). |
| 119 |
addSeries("Series A", [0.53, 0.51]). |
| 120 |
addSeries("Series B", [0.84, 0.79]). |
| 121 |
addSeries("Series C", [0.68, 0.95]). |
| 122 |
addSeries("Series D", [0.77, 0.66]); |
| 123 |
|
| 124 |
charts.columns = new Chart("columns"). |
| 125 |
addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true}). |
| 126 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true}). |
| 127 |
addPlot("default", {type: ClusteredColumns, gap: 5}). |
| 128 |
addSeries("Series A", [0.53, 0.51]). |
| 129 |
addSeries("Series B", [0.84, 0.79]). |
| 130 |
addSeries("Series C", [0.68, 0.95]). |
| 131 |
addSeries("Series D", [0.77, 0.66]); |
| 132 |
|
| 133 |
charts.lines = new Chart("lines"). |
| 134 |
addAxis("x", {min: 0, max: 6, fixLower: "minor", fixUpper: "minor", natural: true}). |
| 135 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true, max: 1}). |
| 136 |
addPlot("default", {type: Lines, lines: true, markers: true, tension: "X"}). |
| 137 |
addSeries("Series A", [{x: 0.5, y: 0.2}, {x: 1.5, y: 0.4}, {x: 2.0, y: 0.1}, {x: 5.0, y: 0.9}]). |
| 138 |
addSeries("Series B", [{x: 0.3, y: 0.6}, {x: 3.0, y: 0.5}, {x: 4.0, y: 0.9}, {x: 5.5, y: 0.7}]). |
| 139 |
addSeries("Series C", [{x: 0.8, y: 0.8}, {x: 3.4, y: 0.2}, {x: 5.3, y: 0.3}]). |
| 140 |
addSeries("Series D", [{x: 0.6, y: 0.9}, {x: 3.2, y: 0.8}, {x: 5.0, y: 0.1}]); |
| 141 |
|
| 142 |
charts.pieFan = new Chart("pieFan"). |
| 143 |
addPlot("default", {type: Pie, radius: 60, labelOffset: -20, radGrad: dojox.gfx.renderer == "vml" ? "fan" : "native"}). |
| 144 |
addSeries("Series A", [0.35, 0.25, 0.42, 0.53, 0.69]); |
| 145 |
|
| 146 |
charts.bubbles = new Chart("bubbles"). |
| 147 |
addAxis("x", {min: 0, max: 6, fixLower: "minor", fixUpper: "minor", natural: true}). |
| 148 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true}). |
| 149 |
addPlot("default", {type: Bubble}). |
| 150 |
addSeries("Series A", [{x: 0.5, y: 5.0, size: 1.4}, {x: 1.5, y: 1.5, size: 4.5}, {x: 2.0, y: 9.0, size: 1.5}, {x: 5.0, y: 0.3, size: 0.8}]). |
| 151 |
addSeries("Series B", [{x: 0.3, y: 8.0, size: 2.5}, {x: 4.0, y: 6.0, size: 2.1}, {x: 5.5, y: 2.0, size: 3.2}]). |
| 152 |
addSeries("Series C", [{x: 2.0, y: 5.5, size: 2.5}, {x: 3.5, y: 2.5, size: 3.5}, {x: 5.2, y: 7.0, size: 3.0}]). |
| 153 |
addSeries("Series D", [{x: 3.2, y: 8.0, size: 2.0}]); |
| 154 |
|
| 155 |
charts.area = new Chart("area"). |
| 156 |
addAxis("x", {fixLower: "major", fixUpper: "major"}). |
| 157 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0}). |
| 158 |
addPlot("default", {type: StackedAreas, tension: "X"}). |
| 159 |
addSeries("Series A", [-2, 1.1, 1.2, 1.3, 1.4, 1.5, -1.6]). |
| 160 |
addSeries("Series B", [1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1]). |
| 161 |
addSeries("Series C", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6]); |
| 162 |
|
| 163 |
charts.pieLin = new Chart("pieLin"). |
| 164 |
addPlot("default", {type: Pie, radius: 60, labelOffset: -20, radGrad: "linear"}). |
| 165 |
addSeries("Series A", [0.35, 0.25, 0.42, 0.53, 0.69]); |
| 166 |
|
| 167 |
charts.candle = new Chart("candle"). |
| 168 |
addPlot("default", {type: Candlesticks, gap: 1}). |
| 169 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 170 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 171 |
addSeries("Series A", [ |
| 172 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 173 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 174 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 175 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 176 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 177 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 178 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 179 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 180 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 181 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 182 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 183 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 184 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 185 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 186 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 187 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 188 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 189 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 190 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 191 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 192 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 193 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 194 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 195 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 196 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 197 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 198 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 199 |
{ open: 20, close: 16, high: 22, low: 8 }]); |
| 200 |
charts.ohlc = new Chart("ohlc"). |
| 201 |
addPlot("default", {type: OHLC, gap: 1}). |
| 202 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 203 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 204 |
addSeries("Series A", [ |
| 205 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 206 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 207 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 208 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 209 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 210 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 211 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 212 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 213 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 214 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 215 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 216 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 217 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 218 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 219 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 220 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 221 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 222 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 223 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 224 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 225 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 226 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 227 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 228 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 229 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 230 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 231 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 232 |
{ open: 20, close: 16, high: 22, low: 8 }]); |
| 233 |
var name; |
| 234 |
if(window.location.search.indexOf("?")>-1){ |
| 235 |
name = window.location.search.substring(1); |
| 236 |
domConstruct.create("span", { |
| 237 |
style: "display: inline-block; margin-left: 1em;", |
| 238 |
innerHTML: '<a href="theme_preview-amd.html">Back to the Theme Previewer »»</a>' |
| 239 |
}, query("p.controls")[0]); |
| 240 |
} |
| 241 |
|
| 242 |
update(name); |
| 243 |
|
| 244 |
on(dom.byId("themeChooser"), "change", update); |
| 245 |
on(dom.byId("pageStyleChooser"), "click", update); |
| 246 |
} |
| 247 |
ready(init); |
| 248 |
}); |
| 249 |
</script> |
| 250 |
</head> |
| 251 |
<body> |
| 252 |
<h1>Example Dojo Chart Types</h1> |
| 253 |
<p>Choose a theme from the list below, a theme will be loaded dynamically, and the charts will be rendered using it.</p> |
| 254 |
<p class="controls"><label for="themeChooser">Available themes: </label> |
| 255 |
<select id="themeChooser"> |
| 256 |
<optgroup label="Gradients"> |
| 257 |
<option value="Julie" selected="selected">Julie</option> |
| 258 |
<option value="ThreeD">ThreeD</option> |
| 259 |
<option value="Chris">Chris</option> |
| 260 |
<option value="Tom">Tom</option> |
| 261 |
<option value="Claro">Claro</option> |
| 262 |
<option value="PrimaryColors">PrimaryColors</option> |
| 263 |
<option value="Electric">Electric</option> |
| 264 |
<option value="Charged">Charged</option> |
| 265 |
<option value="Renkoo">Renkoo</option> |
| 266 |
</optgroup> |
| 267 |
<optgroup label="Classic"> |
| 268 |
<option value="Adobebricks">Adobebricks</option> |
| 269 |
<option value="Algae">Algae</option> |
| 270 |
<option value="Bahamation">Bahamation</option> |
| 271 |
<option value="BlueDusk">BlueDusk</option> |
| 272 |
<option value="CubanShirts">CubanShirts</option> |
| 273 |
<option value="Desert">Desert</option> |
| 274 |
<option value="Distinctive">Distinctive</option> |
| 275 |
<option value="Dollar">Dollar</option> |
| 276 |
<option value="Grasshopper">Grasshopper</option> |
| 277 |
<option value="Grasslands">Grasslands</option> |
| 278 |
<option value="GreySkies">GreySkies</option> |
| 279 |
<option value="Harmony">Harmony</option> |
| 280 |
<option value="IndigoNation">IndigoNation</option> |
| 281 |
<option value="Ireland">Ireland</option> |
| 282 |
<option value="MiamiNice">MiamiNice</option> |
| 283 |
<option value="Midwest">Midwest</option> |
| 284 |
<option value="Minty">Minty</option> |
| 285 |
<option value="PurpleRain">PurpleRain</option> |
| 286 |
<option value="RoyalPurples">RoyalPurples</option> |
| 287 |
<option value="SageToLime">SageToLime</option> |
| 288 |
<option value="Shrooms">Shrooms</option> |
| 289 |
<option value="Tufte">Tufte</option> |
| 290 |
<option value="WatersEdge">WatersEdge</option> |
| 291 |
<option value="Wetland">Wetland</option> |
| 292 |
</optgroup> |
| 293 |
<optgroup label="PlotKit"> |
| 294 |
<option value="PlotKit.blue">PlotKit.blue</option> |
| 295 |
<option value="PlotKit.cyan">PlotKit.cyan</option> |
| 296 |
<option value="PlotKit.green">PlotKit.green</option> |
| 297 |
<option value="PlotKit.orange">PlotKit.orange</option> |
| 298 |
<option value="PlotKit.purple">PlotKit.purple</option> |
| 299 |
<option value="PlotKit.red">PlotKit.red</option> |
| 300 |
</optgroup> |
| 301 |
</select> |
| 302 |
|
| 303 |
<input id="pageStyleChooser" type="checkbox" checked="checked" value=""> |
| 304 |
<label for="pageStyleChooser"> use suggested page style</label> |
| 305 |
</p> |
| 306 |
<div id="chartContainer"> |
| 307 |
<div class="chart" id="bars"></div> |
| 308 |
<div class="chart" id="lines"></div> |
| 309 |
<div class="chart" id="pieFan"></div> |
| 310 |
<div class="chart" id="bubbles"></div> |
| 311 |
<div class="chart" id="area"></div> |
| 312 |
<div class="chart" id="pieLin"></div> |
| 313 |
<div class="chart" id="columns"></div> |
| 314 |
<div class="chart" id="candle"></div> |
| 315 |
<div class="chart" id="ohlc"></div> |
| 316 |
<div class="chart" id="scatter"></div> |
| 317 |
</div> |
| 318 |
</body> |
| 319 |
</html> |