| 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</title> |
| 18 |
<style type="text/css"> |
| 19 |
@import "../../../../dojo/resources/dojo.css"; |
| 20 |
@import "../../../../dijit/tests/css/dijitTests.css"; |
| 21 |
</style> |
| 22 |
|
| 23 |
<script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, async: true, has:{'dojo-bidi': true}"></script> |
| 24 |
<script type="text/javascript"> |
| 25 |
require([ |
| 26 |
"dojo/_base/array", |
| 27 |
"dojo/dom", |
| 28 |
"dojo/dom-style", |
| 29 |
"dojo/ready", |
| 30 |
"dojox/charting/Chart", |
| 31 |
"dojox/charting/themes/Shrooms", |
| 32 |
"dojox/charting/themes/PlotKit/blue", |
| 33 |
"dojox/charting/themes/PlotKit/cyan", |
| 34 |
"dojox/charting/themes/PlotKit/green", |
| 35 |
"dojox/charting/themes/Ireland", |
| 36 |
"dojox/charting/themes/SageToLime", |
| 37 |
"dojox/charting/themes/Minty", |
| 38 |
"dojox/charting/themes/Tufte", |
| 39 |
"dojox/dtl", |
| 40 |
"dojox/dtl/Context", |
| 41 |
"dojox/dtl/tag/logic", |
| 42 |
"dojox/charting/axis2d/Default", |
| 43 |
"dojox/charting/plot2d/Default", |
| 44 |
"dojox/charting/plot2d/Areas", |
| 45 |
"dojox/charting/plot2d/Markers", |
| 46 |
"dojox/charting/plot2d/MarkersOnly", |
| 47 |
"dojox/charting/plot2d/StackedLines", |
| 48 |
"dojox/charting/plot2d/StackedAreas", |
| 49 |
"dojox/charting/plot2d/Bars", |
| 50 |
"dojox/charting/plot2d/ClusteredBars", |
| 51 |
"dojox/charting/plot2d/StackedBars", |
| 52 |
"dojox/charting/plot2d/ClusteredColumns", |
| 53 |
"dojox/charting/plot2d/StackedColumns", |
| 54 |
"dojox/charting/plot2d/Bubble", |
| 55 |
"dojox/charting/plot2d/Grid", |
| 56 |
"dojox/charting/plot2d/Candlesticks", |
| 57 |
"dojox/charting/plot2d/OHLC", |
| 58 |
"dojox/charting/plot2d/Scatter"], |
| 59 |
function(arr, dom, domStyle, ready, Chart, Shrooms, blue, cyan, green, Ireland, SageToLime, Minty, Tufte, |
| 60 |
dtl, Context){ |
| 61 |
|
| 62 |
var charts = [ |
| 63 |
{ |
| 64 |
description: "Clustered columns with positive and negative values, readable theme.", |
| 65 |
makeChart: function(node){ |
| 66 |
(new Chart(node)). |
| 67 |
setTheme(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 }). |
| 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").render(); |
| 76 |
} |
| 77 |
}, |
| 78 |
{ |
| 79 |
description: "Bubble chart, green theme.", |
| 80 |
makeChart: function(node){ |
| 81 |
(new Chart(node)). |
| 82 |
setTheme(SageToLime). |
| 83 |
addPlot("default", { type: "Bubble", shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]} }). |
| 84 |
addAxis("x", { |
| 85 |
min: 0, |
| 86 |
max: 6, |
| 87 |
majorTick: { stroke: "black", length: 3 }, |
| 88 |
minorTick: { stroke: "gray", length: 3 } |
| 89 |
}). |
| 90 |
addAxis("y", { |
| 91 |
vertical: true, |
| 92 |
min: 0, |
| 93 |
max: 10, |
| 94 |
majorTick: { stroke: "black", length: 3 }, |
| 95 |
minorTick: { stroke: "gray", length: 3 } |
| 96 |
}). |
| 97 |
addSeries("Series A", [ |
| 98 |
{ x: 0.5, y: 5, size: 1.4 }, |
| 99 |
{ x: 1.5, y: 1.5, size: 4.5 }, |
| 100 |
{ x: 2, y: 9, size:1.5 }, |
| 101 |
{ x: 5, y: 0.3, size:0.8 } |
| 102 |
]). |
| 103 |
addSeries("Series B", [ |
| 104 |
{ x: 0.3, y: 8, size: 2.5 }, |
| 105 |
{ x: 4, y: 6, size:1.1 }, |
| 106 |
{ x: 5.5, y: 2, size: 3.2 } |
| 107 |
]). |
| 108 |
setDir("rtl").render(); |
| 109 |
} |
| 110 |
}, |
| 111 |
{ |
| 112 |
description: "Lines, calculated labels", |
| 113 |
makeChart: function(node){ |
| 114 |
(new Chart(node)). |
| 115 |
addAxis("x", { |
| 116 |
majorLabels: true, |
| 117 |
minorLabels: true, |
| 118 |
includeZero: true, |
| 119 |
minorTicks: false, |
| 120 |
microTicks: false, |
| 121 |
majorTickStep: 2, |
| 122 |
htmlLabels: true, |
| 123 |
labelFunc: function(value){ |
| 124 |
return value + " s"; |
| 125 |
}, |
| 126 |
maxLabelSize: 30, |
| 127 |
fixUpper: "major", fixLower: "major", |
| 128 |
majorTick: { length: 3 } |
| 129 |
}). |
| 130 |
addAxis("y", { |
| 131 |
labelFunc: function(value){ |
| 132 |
return value + " thingers"; |
| 133 |
}, |
| 134 |
maxLabelSize: 50, |
| 135 |
vertical: true, |
| 136 |
// htmlLabels: false, |
| 137 |
microTicks: true, |
| 138 |
minorTicks: true, |
| 139 |
majorTick: { stroke: "black", length: 3 } |
| 140 |
}). |
| 141 |
addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]). |
| 142 |
addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]). |
| 143 |
setDir("rtl").render(); |
| 144 |
} |
| 145 |
}, |
| 146 |
{ |
| 147 |
description: "Lines, pre-computed labels", |
| 148 |
makeChart: function(node){ |
| 149 |
(new Chart(node)). |
| 150 |
addAxis("x", { |
| 151 |
majorLabels: true, |
| 152 |
minorLabels: true, |
| 153 |
includeZero: true, |
| 154 |
minorTicks: false, |
| 155 |
microTicks: false, |
| 156 |
majorTickStep: 2, |
| 157 |
labels: [ |
| 158 |
{ value: 0, text: "nada" }, |
| 159 |
{ value: 2, text: "2 units" }, |
| 160 |
{ value: 4, text: "4 units" }, |
| 161 |
{ value: 8, text: "2*4 units" } |
| 162 |
], |
| 163 |
htmlLabels: true, |
| 164 |
fixUpper: "major", fixLower: "major", |
| 165 |
majorTick: { length: 3 } |
| 166 |
}). |
| 167 |
addAxis("y", { |
| 168 |
labels: [ |
| 169 |
{ value: 0, text: "nada" }, |
| 170 |
{ value: 1.1, text: "hrmm" }, |
| 171 |
{ value: 1.2, text: "?" }, |
| 172 |
{ value: 2, text: "2!" } |
| 173 |
], |
| 174 |
vertical: true, |
| 175 |
// htmlLabels: false, |
| 176 |
microTicks: true, |
| 177 |
minorTicks: true, |
| 178 |
majorTick: { stroke: "black", length: 3 } |
| 179 |
}). |
| 180 |
addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]). |
| 181 |
addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]). |
| 182 |
setDir("rtl").render(); |
| 183 |
} |
| 184 |
}, |
| 185 |
{ |
| 186 |
description: "Defaults: lines, no axes.", |
| 187 |
makeChart: function(node){ |
| 188 |
(new Chart(node)). |
| 189 |
addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]). |
| 190 |
addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]). |
| 191 |
setDir("rtl").render(); |
| 192 |
} |
| 193 |
}, |
| 194 |
{ |
| 195 |
description: "Defaults: lines, no axes, and custom strokes.", |
| 196 |
makeChart: function(node){ |
| 197 |
(new Chart(node)). |
| 198 |
addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ], {stroke: "red"}). |
| 199 |
addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ], {stroke: "blue"}). |
| 200 |
setDir("rtl").render(); |
| 201 |
} |
| 202 |
}, |
| 203 |
{ |
| 204 |
description: "Areas, Happy theme, no axes.", |
| 205 |
makeChart: function(node){ |
| 206 |
(new Chart(node)). |
| 207 |
addPlot("default", {type: "Areas", tension:"X"}). |
| 208 |
setTheme(Shrooms). |
| 209 |
addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]). |
| 210 |
addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]). |
| 211 |
addSeries("Series C", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2]). |
| 212 |
setDir("rtl").render(); |
| 213 |
} |
| 214 |
}, |
| 215 |
{ |
| 216 |
description: "Areas, no axes, custom strokes and fills.", |
| 217 |
makeChart: function(node){ |
| 218 |
(new Chart(node)). |
| 219 |
addPlot("default", {type: "Areas"}). |
| 220 |
addSeries("Series A", |
| 221 |
[1, 2, 1, 2, 1, 2, 1], |
| 222 |
{ |
| 223 |
stroke: {color: "red", width: 2 }, |
| 224 |
fill: "lightpink" |
| 225 |
} |
| 226 |
). |
| 227 |
addSeries("Series B", |
| 228 |
[ 2, 1, 2, 1, 2, 1, 2 ], |
| 229 |
{ |
| 230 |
stroke: { color: "blue", width: 2 }, |
| 231 |
fill: "lightblue" |
| 232 |
} |
| 233 |
). |
| 234 |
setDir("rtl").render(); |
| 235 |
} |
| 236 |
}, |
| 237 |
{ |
| 238 |
description: "Lines, axes, blue theme.", |
| 239 |
makeChart: function(node){ |
| 240 |
(new Chart(node)). |
| 241 |
setTheme(blue). |
| 242 |
addAxis("x"). |
| 243 |
addAxis("y", {vertical: true}). |
| 244 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]). |
| 245 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 246 |
setDir("rtl").render(); |
| 247 |
} |
| 248 |
}, |
| 249 |
{ |
| 250 |
description: "Lines, axes (aligned on minor ticks), cyan theme.", |
| 251 |
makeChart: function(node){ |
| 252 |
(new Chart(node)). |
| 253 |
setTheme(cyan). |
| 254 |
addAxis("x", { |
| 255 |
fixLower: "minor", fixUpper: "minor" |
| 256 |
}). |
| 257 |
addAxis("y", { |
| 258 |
vertical: true, fixLower: "minor", fixUpper: "minor" |
| 259 |
}). |
| 260 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]). |
| 261 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 262 |
setDir("rtl").render(); |
| 263 |
} |
| 264 |
}, |
| 265 |
{ |
| 266 |
description: "Lines, axes (aligned on major ticks), green theme.", |
| 267 |
makeChart: function(node){ |
| 268 |
(new Chart(node)). |
| 269 |
setTheme(green). |
| 270 |
addAxis("x", { |
| 271 |
fixLower: "major", fixUpper: "major" |
| 272 |
}). |
| 273 |
addAxis("y", { |
| 274 |
vertical: true, fixLower: "major", fixUpper: "major" |
| 275 |
}). |
| 276 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]). |
| 277 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 278 |
setDir("rtl").render(); |
| 279 |
} |
| 280 |
}, |
| 281 |
{ |
| 282 |
description: "Lines and markers, no axes, purple theme, custom min/max.", |
| 283 |
makeChart: function(node){ |
| 284 |
(new Chart(node)). |
| 285 |
setTheme(SageToLime). |
| 286 |
addPlot("default", {type: "Markers"}). |
| 287 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3}). |
| 288 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 289 |
setDir("rtl").render(); |
| 290 |
} |
| 291 |
}, |
| 292 |
{ |
| 293 |
description: "Markers only, no axes, custom theme, custom markers, custom min/max.", |
| 294 |
makeChart: function(node){ |
| 295 |
(new Chart(node)). |
| 296 |
addPlot("default", { type: "MarkersOnly" }). |
| 297 |
addSeries("Series A", |
| 298 |
[ 1, 2, 1, 2, 1, 2, 1 ], |
| 299 |
{ |
| 300 |
min: 0, |
| 301 |
max: 3, |
| 302 |
stroke: {color: "red", width: 2}, |
| 303 |
fill: "red", |
| 304 |
marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" |
| 305 |
} |
| 306 |
). |
| 307 |
addSeries("Series B", |
| 308 |
[ 2, 1, 2, 1, 2, 1, 2 ], |
| 309 |
{ |
| 310 |
stroke: {color: "blue", width: 2}, |
| 311 |
fill: "blue", |
| 312 |
marker: "m-3,-3 l0,6 6,0 0,-6 z" |
| 313 |
} |
| 314 |
). |
| 315 |
setDir("rtl").render(); |
| 316 |
} |
| 317 |
}, |
| 318 |
{ |
| 319 |
description: "Lines and markers, shadows, no axes, custom theme, custom markers, custom min/max.", |
| 320 |
makeChart: function(node){ |
| 321 |
(new Chart(node)). |
| 322 |
addPlot("default", { |
| 323 |
type: "Markers", shadow: {dx: 1, dy: 1, width: 5, color: [100, 0, 0, 1]} |
| 324 |
}). |
| 325 |
addSeries("Series A", |
| 326 |
[ 1, 2, 1, 2, 1, 2, 1 ], |
| 327 |
{ |
| 328 |
min: 0, |
| 329 |
max: 3, |
| 330 |
stroke: {color: "red", width: 2, join: "round"}, |
| 331 |
fill: "red", |
| 332 |
marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" |
| 333 |
} |
| 334 |
). |
| 335 |
addSeries("Series B", |
| 336 |
[ 2, 1, 2, 1, 2, 1, 2 ], |
| 337 |
{ |
| 338 |
stroke: {color: "blue", width: 2, join: "round"}, |
| 339 |
fill: "blue", |
| 340 |
marker: "m-3,-3 l0,6 6,0 0,-6 z" |
| 341 |
} |
| 342 |
). |
| 343 |
setDir("rtl").render(); |
| 344 |
} |
| 345 |
}, |
| 346 |
{ |
| 347 |
description: "Stacked lines, markers, shadows, no axes, custom strokes, fills, and markers.", |
| 348 |
makeChart: function(node){ |
| 349 |
(new Chart(node)). |
| 350 |
addPlot("default", { |
| 351 |
type: "StackedLines", |
| 352 |
markers: true, |
| 353 |
tension:"S", |
| 354 |
shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]} |
| 355 |
}). |
| 356 |
addSeries("Series A", |
| 357 |
[ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ], |
| 358 |
{ |
| 359 |
stroke: { color: "red", width: 2 }, |
| 360 |
fill: "lightpink", |
| 361 |
marker: "m-3,-3 l0,6 6,0 0,-6 z" |
| 362 |
} |
| 363 |
). |
| 364 |
addSeries("Series B", |
| 365 |
[ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ], |
| 366 |
{ |
| 367 |
stroke: { color: "blue", width: 2 }, |
| 368 |
fill: "lightblue", |
| 369 |
marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" |
| 370 |
} |
| 371 |
). |
| 372 |
addSeries("Series C", |
| 373 |
[ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ], |
| 374 |
{ |
| 375 |
stroke: { color: "green", width: 2 }, |
| 376 |
fill: "lightgreen", |
| 377 |
marker: "m0,-3 l3,3 -3,3 -3,-3 z" |
| 378 |
} |
| 379 |
). |
| 380 |
setDir("rtl").render(); |
| 381 |
} |
| 382 |
}, |
| 383 |
{ |
| 384 |
description: "Stacked areas, axes (aligned on major ticks), custom strokes and fills.", |
| 385 |
makeChart: function(node){ |
| 386 |
(new Chart(node)). |
| 387 |
addAxis("x", {fixLower: "major", fixUpper: "major"}). |
| 388 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0}). |
| 389 |
addPlot("default", { type: "StackedAreas", tension:"S" }). |
| 390 |
addSeries("Series A", |
| 391 |
[ -2, 1.1, 1.2, 1.3, 1.4, 1.5, -1.6 ], |
| 392 |
{ stroke: {color: "red", width: 2}, fill: "lightpink" } |
| 393 |
). |
| 394 |
addSeries("Series B", |
| 395 |
[ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ], |
| 396 |
{ stroke: {color: "blue", width: 2}, fill: "lightblue" } |
| 397 |
). |
| 398 |
addSeries("Series C", |
| 399 |
[ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ], |
| 400 |
{ stroke: {color: "green", width: 2}, fill: "lightgreen" } |
| 401 |
).setDir("rtl").render(); |
| 402 |
} |
| 403 |
}, |
| 404 |
{ |
| 405 |
description: "Candlesticks with gaps, custom strokes and fills, optional mid points.", |
| 406 |
makeChart: function(node){ |
| 407 |
(new Chart(node)). |
| 408 |
addPlot("default", {type: "Candlesticks", gap: 1}). |
| 409 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 410 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 411 |
addSeries("Series A", [ |
| 412 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 413 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 414 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 415 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 416 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 417 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 418 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 419 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 420 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 421 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 422 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 423 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 424 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 425 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 426 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 427 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 428 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 429 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 430 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 431 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 432 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 433 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 434 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 435 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 436 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 437 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 438 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 439 |
{ open: 20, close: 16, high: 22, low: 8 } |
| 440 |
], |
| 441 |
{ stroke: { color: "green" }, fill: "lightgreen" } |
| 442 |
). |
| 443 |
setDir("rtl").render(); |
| 444 |
} |
| 445 |
}, |
| 446 |
{ |
| 447 |
description: "Open/High/Low/Close with gaps, custom strokes and fills.", |
| 448 |
makeChart: function(node){ |
| 449 |
(new Chart(node)). |
| 450 |
addPlot("default", {type: "OHLC", gap: 2}). |
| 451 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 452 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 453 |
addSeries("Series A", [ |
| 454 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 455 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 456 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 457 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 458 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 459 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 460 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 461 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 462 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 463 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 464 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 465 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 466 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 467 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 468 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 469 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 470 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 471 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 472 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 473 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 474 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 475 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 476 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 477 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 478 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 479 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 480 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 481 |
{ open: 20, close: 16, high: 22, low: 8 } |
| 482 |
], |
| 483 |
{ stroke: { color: "blue" }, fill: "blue" } |
| 484 |
). |
| 485 |
setDir("rtl").render(); |
| 486 |
} |
| 487 |
}, |
| 488 |
{ |
| 489 |
description: "Columns, no axes, custom strokes and fills.", |
| 490 |
makeChart: function(node){ |
| 491 |
(new Chart(node)). |
| 492 |
addPlot("default", {type: "Columns"}). |
| 493 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }). |
| 494 |
addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }). |
| 495 |
setDir("rtl").render(); |
| 496 |
} |
| 497 |
}, |
| 498 |
{ |
| 499 |
description: "Columns with gaps beetwen them, vertical axis aligned on major ticks, custom strokes, fills.", |
| 500 |
makeChart: function(node){ |
| 501 |
(new Chart(node)). |
| 502 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"}). |
| 503 |
addPlot("default", {type: "Columns", gap: 2}). |
| 504 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: {color: "red"}, fill: "lightpink" }). |
| 505 |
addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }). |
| 506 |
setDir("rtl").render(); |
| 507 |
} |
| 508 |
}, |
| 509 |
{ |
| 510 |
description: "Stacked columns, no axes, custom strokes and fills.", |
| 511 |
makeChart: function(node){ |
| 512 |
(new Chart(node)). |
| 513 |
addPlot("default", {type: "StackedColumns"}). |
| 514 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], {stroke: { color: "red" }, fill: "lightpink" }). |
| 515 |
addSeries("Series B", [ 2, 1, 2, 1, 2 ], {stroke: { color: "blue" }, fill: "lightblue" }). |
| 516 |
setDir("rtl").render(); |
| 517 |
} |
| 518 |
}, |
| 519 |
{ |
| 520 |
description: "Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills.", |
| 521 |
makeChart: function(node){ |
| 522 |
(new Chart(node)). |
| 523 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 524 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 525 |
addPlot("default", {type: "Bars"}). |
| 526 |
addSeries("Series A", |
| 527 |
[1, 2, 3, 4, 5], |
| 528 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 529 |
). |
| 530 |
addSeries("Series B", |
| 531 |
[5, 4, 3, 2, 1], |
| 532 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 533 |
). |
| 534 |
setDir("rtl").render(); |
| 535 |
} |
| 536 |
}, |
| 537 |
{ |
| 538 |
description: "Stacked bars, no axes, custom strokes and fills.", |
| 539 |
makeChart: function(node){ |
| 540 |
(new Chart(node)).setTheme(blue). |
| 541 |
addPlot("default", {type: "StackedBars"}). |
| 542 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }). |
| 543 |
addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }). |
| 544 |
setDir("rtl").render(); |
| 545 |
} |
| 546 |
}, |
| 547 |
{ |
| 548 |
description: "Clustered columns, custom axes, custom strokes, fills, and gap.", |
| 549 |
makeChart: function(node){ |
| 550 |
(new Chart(node)). |
| 551 |
addAxis("x", { |
| 552 |
fixLower: "minor", fixUpper: "minor", natural: true |
| 553 |
}). |
| 554 |
addAxis("y", { |
| 555 |
vertical: true, fixLower: "major", fixUpper: "major", includeZero: true |
| 556 |
}). |
| 557 |
addPlot("default", {type: "ClusteredColumns", gap: 10}). |
| 558 |
addSeries("Series A", |
| 559 |
[ 1, 2, 3, 4, 5 ], |
| 560 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 561 |
). |
| 562 |
addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}). |
| 563 |
setDir("rtl").render(); |
| 564 |
} |
| 565 |
}, |
| 566 |
{ |
| 567 |
description: "Clustered bars, custom axes, custom strokes, fills, and gap.", |
| 568 |
makeChart: function(node){ |
| 569 |
(new Chart(node)). |
| 570 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 571 |
addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor", natural: true}). |
| 572 |
addPlot("default", { type: "ClusteredBars", gap: 5 }). |
| 573 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }). |
| 574 |
addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }). |
| 575 |
setDir("rtl").render(); |
| 576 |
} |
| 577 |
}, |
| 578 |
{ |
| 579 |
description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes.", |
| 580 |
makeChart: function(node){ |
| 581 |
(new Chart(node)). |
| 582 |
addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }). |
| 583 |
addAxis("y", { |
| 584 |
vertical: true, |
| 585 |
fixLower: "major", |
| 586 |
fixUpper: "major", |
| 587 |
minorTicks: false, |
| 588 |
includeZero: true |
| 589 |
}). |
| 590 |
addPlot("front_grid", { type: "Grid", hMajorLines: true, vMajorLines: false }). |
| 591 |
addPlot("default", { type: "Columns", gap: 10 }). |
| 592 |
addPlot("back_grid", { type: "Grid", hMajorLines: false, vMajorLines: true }). |
| 593 |
addSeries("Series A", |
| 594 |
[ 1, 2, 3, 4, 5 ], |
| 595 |
{ stroke: { color: "red" }, fill: "lightpink" } |
| 596 |
). |
| 597 |
addSeries("Series B", |
| 598 |
[ 5, 4, 3, 2, 1 ], |
| 599 |
{ stroke: { color: "blue" }, fill: "lightblue" } |
| 600 |
). |
| 601 |
setDir("rtl").render(); |
| 602 |
} |
| 603 |
}, |
| 604 |
{ |
| 605 |
description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes, with min=0, max=8, and manually specified ticks on the vertical axis.", |
| 606 |
makeChart: function(node){ |
| 607 |
(new Chart(node)). |
| 608 |
addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true}). |
| 609 |
addAxis("y", { |
| 610 |
vertical: true, fixLower: "major", fixUpper: "major", |
| 611 |
includeZero: true, min: 0, max: 8, minorLabels: false, |
| 612 |
majorTicks: true, minorTicks: true, microTicks: false, |
| 613 |
majorTickStep: 2, minorTickStep: 1, microTickStep: 0.5 |
| 614 |
}). |
| 615 |
addPlot("front_grid", { |
| 616 |
type: "Grid", hMajorLines: true, vMajorLines: false |
| 617 |
}). |
| 618 |
addPlot("default", {type: "Columns", gap: 10}). |
| 619 |
addPlot("back_grid", { |
| 620 |
type: "Grid", hMajorLines: false, vMajorLines: true |
| 621 |
}). |
| 622 |
addSeries("Series A", |
| 623 |
[ 1, 2, 3, 4, 5 ], |
| 624 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 625 |
). |
| 626 |
addSeries("Series B", |
| 627 |
[ 5, 4, 3, 2, 1 ], |
| 628 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 629 |
). |
| 630 |
setDir("rtl").render(); |
| 631 |
} |
| 632 |
}, |
| 633 |
{ |
| 634 |
description: "Columns with positive and negative values, axes, and grid.", |
| 635 |
makeChart: function(node){ |
| 636 |
(new Chart(node)). |
| 637 |
addAxis("x"). |
| 638 |
addAxis("y", { vertical: true }). |
| 639 |
addPlot("default", { type: "Columns", gap: 10 }). |
| 640 |
addPlot("grid", { type: "Grid" }). |
| 641 |
addSeries("Series A", |
| 642 |
[ 2, 1, 0.5, -1, -2 ], |
| 643 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 644 |
). |
| 645 |
addSeries("Series B", |
| 646 |
[ -2, -1, -0.5, 1, 2 ], |
| 647 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 648 |
). |
| 649 |
setDir("rtl").render(); |
| 650 |
} |
| 651 |
}, |
| 652 |
{ |
| 653 |
description: "Clustered columns with positive and negative values, axes, and grid.", |
| 654 |
makeChart: function(node){ |
| 655 |
(new Chart(node)). |
| 656 |
addAxis("x"). |
| 657 |
addAxis("y", { vertical: true }). |
| 658 |
addPlot("default", { type: "ClusteredColumns", gap: 10 }). |
| 659 |
addPlot("grid", { type: "Grid" }). |
| 660 |
addSeries("Series A", |
| 661 |
[ 2, 1, 0.5, -1, -2 ], |
| 662 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 663 |
). |
| 664 |
addSeries("Series B", |
| 665 |
[ -2, -1, -0.5, 1, 2 ], |
| 666 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 667 |
). |
| 668 |
addSeries("Series C", |
| 669 |
[ 1, 0.5, -1, -2, -3 ], |
| 670 |
{ stroke: {color: "green"}, fill: "lightgreen" } |
| 671 |
). |
| 672 |
setDir("rtl").render(); |
| 673 |
} |
| 674 |
}, |
| 675 |
{ |
| 676 |
description: "Bars with positive and negative values, axes, and grid.", |
| 677 |
makeChart: function(node){ |
| 678 |
(new Chart(node)). |
| 679 |
addAxis("x"). |
| 680 |
addAxis("y", { vertical: true }). |
| 681 |
addPlot("default", { type: "Bars", gap: 10 }). |
| 682 |
addPlot("grid", { type: "Grid" }). |
| 683 |
addSeries("Series A", |
| 684 |
[ 2, 1, 0.5, -1, -2 ], |
| 685 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 686 |
). |
| 687 |
addSeries("Series B", |
| 688 |
[ -2, -1, -0.5, 1, 2 ], |
| 689 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 690 |
). |
| 691 |
setDir("rtl").render(); |
| 692 |
} |
| 693 |
}, |
| 694 |
{ |
| 695 |
description: "Clustered bars with positive and negative values, axes, and grid.", |
| 696 |
makeChart: function(node){ |
| 697 |
(new Chart(node)). |
| 698 |
addAxis("x"). |
| 699 |
addAxis("y", { vertical: true }). |
| 700 |
addPlot("default", { type: "ClusteredBars", gap: 10 }). |
| 701 |
addPlot("grid", { type: "Grid" }). |
| 702 |
addSeries("Series A", |
| 703 |
[ 2, 1, 0.5, -1, -2 ], |
| 704 |
{ stroke: { color: "red" }, fill: "lightpink" } |
| 705 |
). |
| 706 |
addSeries("Series B", |
| 707 |
[ -2, -1, -0.5, 1, 2 ], |
| 708 |
{ stroke: { color: "blue" }, fill: "lightblue" } |
| 709 |
). |
| 710 |
addSeries("Series C", |
| 711 |
[ 1, 0.5, -1, -2, -3 ], |
| 712 |
{ stroke: { color: "green" }, fill: "lightgreen" } |
| 713 |
). |
| 714 |
setDir("rtl").render(); |
| 715 |
} |
| 716 |
}, |
| 717 |
{ |
| 718 |
description: "Default lines with 2D data, custom axis, red theme.", |
| 719 |
makeChart: function(node){ |
| 720 |
(new Chart(node)). |
| 721 |
setTheme(Minty). |
| 722 |
addAxis("x", { |
| 723 |
min: 0, |
| 724 |
max: 6, |
| 725 |
majorTick: { stroke: "black", length: 3 }, |
| 726 |
minorTick: { stroke: "gray", length: 3 }, |
| 727 |
minorLabels: false |
| 728 |
}). |
| 729 |
addAxis("y", { |
| 730 |
vertical: true, |
| 731 |
min: 0, |
| 732 |
max: 10, |
| 733 |
majorTick: { stroke: "black", length: 3 }, |
| 734 |
minorTick: { stroke: "gray", length: 3 }, |
| 735 |
minorLabels: false |
| 736 |
}). |
| 737 |
addSeries("Series A", [ |
| 738 |
{ x: 0.5, y: 5 }, |
| 739 |
{ x: 1.5, y: 1.5 }, |
| 740 |
{ x: 2, y: 9 }, |
| 741 |
{ x: 5, y: 0.3 } |
| 742 |
]). |
| 743 |
addSeries("Series B", [ |
| 744 |
{ x: 0.3, y: 8 }, |
| 745 |
{ x: 4, y: 6 }, |
| 746 |
{ x: 5.5, y: 2 } |
| 747 |
]). |
| 748 |
setDir("rtl").render(); |
| 749 |
} |
| 750 |
}, |
| 751 |
|
| 752 |
{ |
| 753 |
description: "Scatter chart, custom axis, purple theme.", |
| 754 |
makeChart: function(node){ |
| 755 |
(new Chart(node)). |
| 756 |
setTheme(Ireland). |
| 757 |
addPlot("default", {type: "Scatter"}). |
| 758 |
addAxis("x", { |
| 759 |
min: 0, |
| 760 |
max: 6, |
| 761 |
majorTick: { stroke: "black", length: 3 }, |
| 762 |
minorTick: { stroke: "gray", length: 3 }, |
| 763 |
minorLabels: false |
| 764 |
}). |
| 765 |
addAxis("y", { |
| 766 |
vertical: true, |
| 767 |
min: 0, |
| 768 |
max: 10, |
| 769 |
majorTick: { stroke: "black", length: 3 }, |
| 770 |
minorTick: { stroke: "gray", length: 3 }, |
| 771 |
minorLabels: false |
| 772 |
}). |
| 773 |
addSeries("Series A", [ |
| 774 |
{ x: 0.5, y: 5 }, |
| 775 |
{ x: 1.5, y: 1.5 }, |
| 776 |
{ x: 2, y: 9 }, |
| 777 |
{ x: 5, y: 0.3 } |
| 778 |
]). |
| 779 |
addSeries("Series B", [ |
| 780 |
{ x: 0.3, y: 8 }, |
| 781 |
{ x: 4, y: 6 }, |
| 782 |
{ x: 5.5, y: 2 } |
| 783 |
]). |
| 784 |
setDir("rtl").render(); |
| 785 |
} |
| 786 |
}, |
| 787 |
|
| 788 |
{ |
| 789 |
description: "Markers, lines, 2D data, custom axis, blue theme.", |
| 790 |
makeChart: function(node){ |
| 791 |
(new Chart(node)). |
| 792 |
setTheme(blue). |
| 793 |
addPlot("default", { |
| 794 |
type: "Default", |
| 795 |
lines: true, |
| 796 |
markers: true, |
| 797 |
tension: 2 |
| 798 |
}). |
| 799 |
addAxis("x", { |
| 800 |
min: 0, |
| 801 |
max: 6, |
| 802 |
majorTick: { stroke: "black", length: 3 }, |
| 803 |
minorTick: { stroke: "gray", length: 3 }, |
| 804 |
minorLabels: false |
| 805 |
}). |
| 806 |
addAxis("y", { |
| 807 |
vertical: true, |
| 808 |
min: 0, |
| 809 |
max: 10, |
| 810 |
majorTick: { stroke: "black", length: 3 }, |
| 811 |
minorTick: { stroke: "gray", length: 3 }, |
| 812 |
minorLabels: false |
| 813 |
}). |
| 814 |
addSeries("Series A", [ |
| 815 |
{ x: 0.5, y: 5 }, |
| 816 |
{ x: 1.5, y: 1.5 }, |
| 817 |
{ x: 2, y: 9 }, |
| 818 |
{ x: 5, y: 0.3 } |
| 819 |
]). |
| 820 |
addSeries("Series B", [ |
| 821 |
{ x: 0.3, y: 8 }, |
| 822 |
{ x: 4, y: 6 }, |
| 823 |
{ x: 5.5, y: 2 } |
| 824 |
]). |
| 825 |
setDir("rtl").render(); |
| 826 |
} |
| 827 |
} |
| 828 |
]; |
| 829 |
var now = function(){ |
| 830 |
return (new Date()).getTime(); |
| 831 |
}; |
| 832 |
|
| 833 |
|
| 834 |
ready(function(){ |
| 835 |
var defaultStyle = { width: "400px", height: "200px" }; |
| 836 |
var tmpl = new dtl.Template(dom.byId("template").value); |
| 837 |
var context = new Context({ charts: charts }); |
| 838 |
dom.byId("charts").innerHTML = tmpl.render(context); |
| 839 |
|
| 840 |
arr.forEach(charts, function(item, idx){ |
| 841 |
var start = now(); |
| 842 |
var n = dom.byId("chart_"+idx); |
| 843 |
domStyle.set(n, item.style||defaultStyle); |
| 844 |
item.makeChart(n); |
| 845 |
console.debug((now()-start), "ms to create:", (idx+1)+":", item.description); |
| 846 |
}); |
| 847 |
}); |
| 848 |
}); |
| 849 |
</script> |
| 850 |
</head> |
| 851 |
<body> |
| 852 |
<textarea id="template" style="display: none;"> |
| 853 |
{% for item in charts %} |
| 854 |
<p>{{ forloop.counter }}: {{ item.description }}</p> |
| 855 |
<div id="chart_{{ forloop.counter0 }}"></div> |
| 856 |
{% endfor %} |
| 857 |
</textarea> |
| 858 |
|
| 859 |
<h1>Chart 2D</h1> |
| 860 |
|
| 861 |
<div id="charts"></div> |
| 862 |
</body> |
| 863 |
</html> |