| 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"></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 |
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]}, labels: true }). |
| 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 |
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 |
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 |
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 |
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 |
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 |
render(); |
| 213 |
} |
| 214 |
}, |
| 215 |
{ |
| 216 |
description: "Areas, Negative Values.", |
| 217 |
makeChart: function(node){ |
| 218 |
(new Chart(node)). |
| 219 |
addPlot("default", {type: "Areas", tension:"X", zeroLine: 0}). |
| 220 |
setTheme(Shrooms). |
| 221 |
addAxis("x", { |
| 222 |
majorLabels: true, |
| 223 |
minorLabels: true, |
| 224 |
minorTicks: false, |
| 225 |
microTicks: false, |
| 226 |
}). |
| 227 |
addAxis("y", { |
| 228 |
vertical: true, |
| 229 |
microTicks: true, |
| 230 |
minorTicks: true |
| 231 |
}). |
| 232 |
addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]). |
| 233 |
addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]). |
| 234 |
addSeries("Series C", [-6.3, -1.8, -3, -0.5, -4.4, -2.7, -2]). |
| 235 |
render(); |
| 236 |
} |
| 237 |
}, |
| 238 |
{ |
| 239 |
description: "Areas, no axes, custom strokes and fills.", |
| 240 |
makeChart: function(node){ |
| 241 |
(new Chart(node)). |
| 242 |
addPlot("default", {type: "Areas"}). |
| 243 |
addSeries("Series A", |
| 244 |
[1, 2, 1, 2, 1, 2, 1], |
| 245 |
{ |
| 246 |
stroke: {color: "red", width: 2 }, |
| 247 |
fill: "lightpink" |
| 248 |
} |
| 249 |
). |
| 250 |
addSeries("Series B", |
| 251 |
[ 2, 1, 2, 1, 2, 1, 2 ], |
| 252 |
{ |
| 253 |
stroke: { color: "blue", width: 2 }, |
| 254 |
fill: "lightblue" |
| 255 |
} |
| 256 |
). |
| 257 |
render(); |
| 258 |
} |
| 259 |
}, |
| 260 |
{ |
| 261 |
description: "Lines, axes, blue theme.", |
| 262 |
makeChart: function(node){ |
| 263 |
(new Chart(node)). |
| 264 |
setTheme(blue). |
| 265 |
addAxis("x"). |
| 266 |
addAxis("y", {vertical: true}). |
| 267 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]). |
| 268 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 269 |
render(); |
| 270 |
} |
| 271 |
}, |
| 272 |
{ |
| 273 |
description: "Lines, axes (aligned on minor ticks), cyan theme.", |
| 274 |
makeChart: function(node){ |
| 275 |
(new Chart(node)). |
| 276 |
setTheme(cyan). |
| 277 |
addAxis("x", { |
| 278 |
fixLower: "minor", fixUpper: "minor" |
| 279 |
}). |
| 280 |
addAxis("y", { |
| 281 |
vertical: true, fixLower: "minor", fixUpper: "minor" |
| 282 |
}). |
| 283 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]). |
| 284 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 285 |
render(); |
| 286 |
} |
| 287 |
}, |
| 288 |
{ |
| 289 |
description: "Lines, axes (aligned on major ticks), green theme.", |
| 290 |
makeChart: function(node){ |
| 291 |
(new Chart(node)). |
| 292 |
setTheme(green). |
| 293 |
addAxis("x", { |
| 294 |
fixLower: "major", fixUpper: "major" |
| 295 |
}). |
| 296 |
addAxis("y", { |
| 297 |
vertical: true, fixLower: "major", fixUpper: "major" |
| 298 |
}). |
| 299 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]). |
| 300 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 301 |
render(); |
| 302 |
} |
| 303 |
}, |
| 304 |
{ |
| 305 |
description: "Lines and markers, no axes, purple theme, custom min/max.", |
| 306 |
makeChart: function(node){ |
| 307 |
(new Chart(node)). |
| 308 |
setTheme(SageToLime). |
| 309 |
addPlot("default", {type: "Markers"}). |
| 310 |
addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3}). |
| 311 |
addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]). |
| 312 |
render(); |
| 313 |
} |
| 314 |
}, |
| 315 |
{ |
| 316 |
description: "Markers only, no axes, custom theme, custom markers, custom min/max.", |
| 317 |
makeChart: function(node){ |
| 318 |
(new Chart(node)). |
| 319 |
addPlot("default", { type: "MarkersOnly" }). |
| 320 |
addSeries("Series A", |
| 321 |
[ 1, 2, 1, 2, 1, 2, 1 ], |
| 322 |
{ |
| 323 |
min: 0, |
| 324 |
max: 3, |
| 325 |
stroke: {color: "red", width: 2}, |
| 326 |
fill: "red", |
| 327 |
marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" |
| 328 |
} |
| 329 |
). |
| 330 |
addSeries("Series B", |
| 331 |
[ 2, 1, 2, 1, 2, 1, 2 ], |
| 332 |
{ |
| 333 |
stroke: {color: "blue", width: 2}, |
| 334 |
fill: "blue", |
| 335 |
marker: "m-3,-3 l0,6 6,0 0,-6 z" |
| 336 |
} |
| 337 |
). |
| 338 |
render(); |
| 339 |
} |
| 340 |
}, |
| 341 |
{ |
| 342 |
description: "Lines and markers, shadows, no axes, custom theme, custom markers, custom min/max.", |
| 343 |
makeChart: function(node){ |
| 344 |
(new Chart(node)). |
| 345 |
addPlot("default", { |
| 346 |
type: "Markers", shadow: {dx: 1, dy: 1, width: 5, color: [100, 0, 0, 1]} |
| 347 |
}). |
| 348 |
addSeries("Series A", |
| 349 |
[ 1, 2, 1, 2, 1, 2, 1 ], |
| 350 |
{ |
| 351 |
min: 0, |
| 352 |
max: 3, |
| 353 |
stroke: {color: "red", width: 2, join: "round"}, |
| 354 |
fill: "red", |
| 355 |
marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" |
| 356 |
} |
| 357 |
). |
| 358 |
addSeries("Series B", |
| 359 |
[ 2, 1, 2, 1, 2, 1, 2 ], |
| 360 |
{ |
| 361 |
stroke: {color: "blue", width: 2, join: "round"}, |
| 362 |
fill: "blue", |
| 363 |
marker: "m-3,-3 l0,6 6,0 0,-6 z" |
| 364 |
} |
| 365 |
). |
| 366 |
render(); |
| 367 |
} |
| 368 |
}, |
| 369 |
{ |
| 370 |
description: "Stacked lines, markers, shadows, no axes, custom strokes, fills, and markers.", |
| 371 |
makeChart: function(node){ |
| 372 |
(new Chart(node)). |
| 373 |
addPlot("default", { |
| 374 |
type: "StackedLines", |
| 375 |
markers: true, |
| 376 |
tension:"S", |
| 377 |
shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]} |
| 378 |
}). |
| 379 |
addSeries("Series A", |
| 380 |
[ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ], |
| 381 |
{ |
| 382 |
stroke: { color: "red", width: 2 }, |
| 383 |
fill: "lightpink", |
| 384 |
marker: "m-3,-3 l0,6 6,0 0,-6 z" |
| 385 |
} |
| 386 |
). |
| 387 |
addSeries("Series B", |
| 388 |
[ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ], |
| 389 |
{ |
| 390 |
stroke: { color: "blue", width: 2 }, |
| 391 |
fill: "lightblue", |
| 392 |
marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" |
| 393 |
} |
| 394 |
). |
| 395 |
addSeries("Series C", |
| 396 |
[ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ], |
| 397 |
{ |
| 398 |
stroke: { color: "green", width: 2 }, |
| 399 |
fill: "lightgreen", |
| 400 |
marker: "m0,-3 l3,3 -3,3 -3,-3 z" |
| 401 |
} |
| 402 |
). |
| 403 |
render(); |
| 404 |
} |
| 405 |
}, |
| 406 |
{ |
| 407 |
description: "Stacked areas, axes (aligned on major ticks), custom strokes and fills.", |
| 408 |
makeChart: function(node){ |
| 409 |
(new Chart(node)). |
| 410 |
addAxis("x", {fixLower: "major", fixUpper: "major"}). |
| 411 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0}). |
| 412 |
addPlot("default", { type: "StackedAreas", tension:"S" }). |
| 413 |
addSeries("Series A", |
| 414 |
[ -2, 1.1, 1.2, 1.3, 1.4, 1.5, -1.6 ], |
| 415 |
{ stroke: {color: "red", width: 2}, fill: "lightpink" } |
| 416 |
). |
| 417 |
addSeries("Series B", |
| 418 |
[ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ], |
| 419 |
{ stroke: {color: "blue", width: 2}, fill: "lightblue" } |
| 420 |
). |
| 421 |
addSeries("Series C", |
| 422 |
[ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ], |
| 423 |
{ stroke: {color: "green", width: 2}, fill: "lightgreen" } |
| 424 |
). |
| 425 |
render(); |
| 426 |
} |
| 427 |
}, |
| 428 |
{ |
| 429 |
description: "Candlesticks with gaps, custom strokes and fills, optional mid points.", |
| 430 |
makeChart: function(node){ |
| 431 |
(new Chart(node)). |
| 432 |
addPlot("default", {type: "Candlesticks", gap: 1}). |
| 433 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 434 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 435 |
addSeries("Series A", [ |
| 436 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 437 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 438 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 439 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 440 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 441 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 442 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 443 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 444 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 445 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 446 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 447 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 448 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 449 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 450 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 451 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 452 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 453 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 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 |
], |
| 465 |
{ stroke: { color: "green" }, fill: "lightgreen" } |
| 466 |
). |
| 467 |
render(); |
| 468 |
} |
| 469 |
}, |
| 470 |
{ |
| 471 |
description: "Open/High/Low/Close with gaps, custom strokes and fills.", |
| 472 |
makeChart: function(node){ |
| 473 |
(new Chart(node)). |
| 474 |
addPlot("default", {type: "OHLC", gap: 2}). |
| 475 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 476 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 477 |
addSeries("Series A", [ |
| 478 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 479 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 480 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 481 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 482 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 483 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 484 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 485 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 486 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 487 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 488 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 489 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 490 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 491 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 492 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 493 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 494 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 495 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 496 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 497 |
{ open: 16, close: 22, high: 26, low: 6 }, |
| 498 |
{ open: 22, close: 18, high: 22, low: 11 }, |
| 499 |
{ open: 18, close: 29, high: 32, low: 14 }, |
| 500 |
{ open: 29, close: 24, high: 29, low: 13 }, |
| 501 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 502 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 503 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 504 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 505 |
{ open: 20, close: 16, high: 22, low: 8 } |
| 506 |
], |
| 507 |
{ stroke: { color: "blue" }, fill: "blue" } |
| 508 |
). |
| 509 |
render(); |
| 510 |
} |
| 511 |
}, |
| 512 |
{ |
| 513 |
description: "Columns, no axes, custom strokes and fills.", |
| 514 |
makeChart: function(node){ |
| 515 |
(new Chart(node)). |
| 516 |
addPlot("default", {type: "Columns" }). |
| 517 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }). |
| 518 |
addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }). |
| 519 |
render(); |
| 520 |
} |
| 521 |
}, |
| 522 |
{ |
| 523 |
description: "Columns with gaps beetwen them, vertical axis aligned on major ticks, custom strokes, fills.", |
| 524 |
makeChart: function(node){ |
| 525 |
(new Chart(node)). |
| 526 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"}). |
| 527 |
addPlot("default", {type: "Columns", gap: 2}). |
| 528 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: {color: "red"}, fill: "lightpink" }). |
| 529 |
addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }). |
| 530 |
render(); |
| 531 |
} |
| 532 |
}, |
| 533 |
{ |
| 534 |
description: "Stacked columns, no axes, custom strokes and fills.", |
| 535 |
makeChart: function(node){ |
| 536 |
(new Chart(node)). |
| 537 |
addPlot("default", {type: "StackedColumns"}). |
| 538 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], {stroke: { color: "red" }, fill: "lightpink" }). |
| 539 |
addSeries("Series B", [ 2, 1, 2, 1, 2 ], {stroke: { color: "blue" }, fill: "lightblue" }). |
| 540 |
render(); |
| 541 |
} |
| 542 |
}, |
| 543 |
{ |
| 544 |
description: "Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills.", |
| 545 |
makeChart: function(node){ |
| 546 |
(new Chart(node)). |
| 547 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 548 |
addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}). |
| 549 |
addPlot("default", {type: "Bars"}). |
| 550 |
addSeries("Series A", |
| 551 |
[1, 2, 3, 4, 5], |
| 552 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 553 |
). |
| 554 |
addSeries("Series B", |
| 555 |
[5, 4, 3, 2, 1], |
| 556 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 557 |
). |
| 558 |
render(); |
| 559 |
} |
| 560 |
}, |
| 561 |
{ |
| 562 |
description: "Stacked bars, no axes, custom strokes and fills.", |
| 563 |
makeChart: function(node){ |
| 564 |
(new Chart(node)).setTheme(blue). |
| 565 |
addPlot("default", {type: "StackedBars"}). |
| 566 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }). |
| 567 |
addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }). |
| 568 |
render(); |
| 569 |
} |
| 570 |
}, |
| 571 |
{ |
| 572 |
description: "Clustered columns, custom axes, custom strokes, fills, and gap.", |
| 573 |
makeChart: function(node){ |
| 574 |
(new Chart(node)). |
| 575 |
addAxis("x", { |
| 576 |
fixLower: "minor", fixUpper: "minor", natural: true |
| 577 |
}). |
| 578 |
addAxis("y", { |
| 579 |
vertical: true, fixLower: "major", fixUpper: "major", includeZero: true |
| 580 |
}). |
| 581 |
addPlot("default", {type: "ClusteredColumns", gap: 10, labels: true}). |
| 582 |
addSeries("Series A", |
| 583 |
[ 1, 2, 3, 4, 5 ], |
| 584 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 585 |
). |
| 586 |
addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}). |
| 587 |
render(); |
| 588 |
} |
| 589 |
}, |
| 590 |
{ |
| 591 |
description: "Clustered bars, custom axes, custom strokes, fills, and gap.", |
| 592 |
makeChart: function(node){ |
| 593 |
(new Chart(node)). |
| 594 |
addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}). |
| 595 |
addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor", natural: true}). |
| 596 |
addPlot("default", { type: "ClusteredBars", gap: 5 }). |
| 597 |
addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }). |
| 598 |
addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }). |
| 599 |
render(); |
| 600 |
} |
| 601 |
}, |
| 602 |
{ |
| 603 |
description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes.", |
| 604 |
makeChart: function(node){ |
| 605 |
(new Chart(node)). |
| 606 |
addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }). |
| 607 |
addAxis("y", { |
| 608 |
vertical: true, |
| 609 |
fixLower: "major", |
| 610 |
fixUpper: "major", |
| 611 |
minorTicks: false, |
| 612 |
includeZero: true |
| 613 |
}). |
| 614 |
addPlot("front_grid", { type: "Grid", hMajorLines: true, vMajorLines: false }). |
| 615 |
addPlot("default", { type: "Columns", gap: 10 }). |
| 616 |
addPlot("back_grid", { type: "Grid", hMajorLines: false, vMajorLines: true }). |
| 617 |
addSeries("Series A", |
| 618 |
[ 1, 2, 3, 4, 5 ], |
| 619 |
{ stroke: { color: "red" }, fill: "lightpink" } |
| 620 |
). |
| 621 |
addSeries("Series B", |
| 622 |
[ 5, 4, 3, 2, 1 ], |
| 623 |
{ stroke: { color: "blue" }, fill: "lightblue" } |
| 624 |
). |
| 625 |
render(); |
| 626 |
} |
| 627 |
}, |
| 628 |
{ |
| 629 |
description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes, with min=0, max=8, and manually specified ticks on the vertical axis.", |
| 630 |
makeChart: function(node){ |
| 631 |
(new Chart(node)). |
| 632 |
addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true}). |
| 633 |
addAxis("y", { |
| 634 |
vertical: true, fixLower: "major", fixUpper: "major", |
| 635 |
includeZero: true, min: 0, max: 8, minorLabels: false, |
| 636 |
majorTicks: true, minorTicks: true, microTicks: false, |
| 637 |
majorTickStep: 2, minorTickStep: 1, microTickStep: 0.5 |
| 638 |
}). |
| 639 |
addPlot("front_grid", { |
| 640 |
type: "Grid", hMajorLines: true, vMajorLines: false |
| 641 |
}). |
| 642 |
addPlot("default", {type: "Columns", gap: 10}). |
| 643 |
addPlot("back_grid", { |
| 644 |
type: "Grid", hMajorLines: false, vMajorLines: true |
| 645 |
}). |
| 646 |
addSeries("Series A", |
| 647 |
[ 1, 2, 3, 4, 5 ], |
| 648 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 649 |
). |
| 650 |
addSeries("Series B", |
| 651 |
[ 5, 4, 3, 2, 1 ], |
| 652 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 653 |
). |
| 654 |
render(); |
| 655 |
} |
| 656 |
}, |
| 657 |
{ |
| 658 |
description: "Columns with positive and negative values, axes, and grid.", |
| 659 |
makeChart: function(node){ |
| 660 |
(new Chart(node)). |
| 661 |
addAxis("x"). |
| 662 |
addAxis("y", { vertical: true }). |
| 663 |
addPlot("default", { type: "Columns", gap: 10 }). |
| 664 |
addPlot("grid", { type: "Grid" }). |
| 665 |
addSeries("Series A", |
| 666 |
[ 2, 1, 0.5, -1, -2 ], |
| 667 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 668 |
). |
| 669 |
addSeries("Series B", |
| 670 |
[ -2, -1, -0.5, 1, 2 ], |
| 671 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 672 |
). |
| 673 |
render(); |
| 674 |
} |
| 675 |
}, |
| 676 |
{ |
| 677 |
description: "Clustered columns with positive and negative values, axes, and grid.", |
| 678 |
makeChart: function(node){ |
| 679 |
(new Chart(node)). |
| 680 |
addAxis("x"). |
| 681 |
addAxis("y", { vertical: true }). |
| 682 |
addPlot("default", { type: "ClusteredColumns", gap: 10 }). |
| 683 |
addPlot("grid", { type: "Grid" }). |
| 684 |
addSeries("Series A", |
| 685 |
[ 2, 1, 0.5, -1, -2 ], |
| 686 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 687 |
). |
| 688 |
addSeries("Series B", |
| 689 |
[ -2, -1, -0.5, 1, 2 ], |
| 690 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 691 |
). |
| 692 |
addSeries("Series C", |
| 693 |
[ 1, 0.5, -1, -2, -3 ], |
| 694 |
{ stroke: {color: "green"}, fill: "lightgreen" } |
| 695 |
). |
| 696 |
render(); |
| 697 |
} |
| 698 |
}, |
| 699 |
{ |
| 700 |
description: "Bars with positive and negative values, axes, and grid.", |
| 701 |
makeChart: function(node){ |
| 702 |
(new Chart(node)). |
| 703 |
addAxis("x"). |
| 704 |
addAxis("y", { vertical: true }). |
| 705 |
addPlot("default", { type: "Bars", gap: 10 }). |
| 706 |
addPlot("grid", { type: "Grid" }). |
| 707 |
addSeries("Series A", |
| 708 |
[ 2, 1, 0.5, -1, -2 ], |
| 709 |
{ stroke: {color: "red"}, fill: "lightpink" } |
| 710 |
). |
| 711 |
addSeries("Series B", |
| 712 |
[ -2, -1, -0.5, 1, 2 ], |
| 713 |
{ stroke: {color: "blue"}, fill: "lightblue" } |
| 714 |
). |
| 715 |
render(); |
| 716 |
} |
| 717 |
}, |
| 718 |
{ |
| 719 |
description: "Clustered bars with positive and negative values, axes, and grid.", |
| 720 |
makeChart: function(node){ |
| 721 |
(new Chart(node)). |
| 722 |
addAxis("x"). |
| 723 |
addAxis("y", { vertical: true }). |
| 724 |
addPlot("default", { type: "ClusteredBars", gap: 10 }). |
| 725 |
addPlot("grid", { type: "Grid" }). |
| 726 |
addSeries("Series A", |
| 727 |
[ 2, 1, 0.5, -1, -2 ], |
| 728 |
{ stroke: { color: "red" }, fill: "lightpink" } |
| 729 |
). |
| 730 |
addSeries("Series B", |
| 731 |
[ -2, -1, -0.5, 1, 2 ], |
| 732 |
{ stroke: { color: "blue" }, fill: "lightblue" } |
| 733 |
). |
| 734 |
addSeries("Series C", |
| 735 |
[ 1, 0.5, -1, -2, -3 ], |
| 736 |
{ stroke: { color: "green" }, fill: "lightgreen" } |
| 737 |
). |
| 738 |
render(); |
| 739 |
} |
| 740 |
}, |
| 741 |
{ |
| 742 |
description: "Default lines with 2D data, custom axis, red theme.", |
| 743 |
makeChart: function(node){ |
| 744 |
(new Chart(node)). |
| 745 |
setTheme(Minty). |
| 746 |
addAxis("x", { |
| 747 |
min: 0, |
| 748 |
max: 6, |
| 749 |
majorTick: { stroke: "black", length: 3 }, |
| 750 |
minorTick: { stroke: "gray", length: 3 }, |
| 751 |
minorLabels: false |
| 752 |
}). |
| 753 |
addAxis("y", { |
| 754 |
vertical: true, |
| 755 |
min: 0, |
| 756 |
max: 10, |
| 757 |
majorTick: { stroke: "black", length: 3 }, |
| 758 |
minorTick: { stroke: "gray", length: 3 }, |
| 759 |
minorLabels: false |
| 760 |
}). |
| 761 |
addSeries("Series A", [ |
| 762 |
{ x: 0.5, y: 5 }, |
| 763 |
{ x: 1.5, y: 1.5 }, |
| 764 |
{ x: 2, y: 9 }, |
| 765 |
{ x: 5, y: 0.3 } |
| 766 |
]). |
| 767 |
addSeries("Series B", [ |
| 768 |
{ x: 0.3, y: 8 }, |
| 769 |
{ x: 4, y: 6 }, |
| 770 |
{ x: 5.5, y: 2 } |
| 771 |
]). |
| 772 |
render(); |
| 773 |
} |
| 774 |
}, |
| 775 |
{ |
| 776 |
description: "Scatter chart, custom axis, purple theme.", |
| 777 |
makeChart: function(node){ |
| 778 |
(new Chart(node)). |
| 779 |
setTheme(Ireland). |
| 780 |
addPlot("default", {type: "Scatter"}). |
| 781 |
addAxis("x", { |
| 782 |
min: 0, |
| 783 |
max: 6, |
| 784 |
majorTick: { stroke: "black", length: 3 }, |
| 785 |
minorTick: { stroke: "gray", length: 3 }, |
| 786 |
minorLabels: false |
| 787 |
}). |
| 788 |
addAxis("y", { |
| 789 |
vertical: true, |
| 790 |
min: 0, |
| 791 |
max: 10, |
| 792 |
majorTick: { stroke: "black", length: 3 }, |
| 793 |
minorTick: { stroke: "gray", length: 3 }, |
| 794 |
minorLabels: false |
| 795 |
}). |
| 796 |
addSeries("Series A", [ |
| 797 |
{ x: 0.5, y: 5 }, |
| 798 |
{ x: 1.5, y: 1.5 }, |
| 799 |
{ x: 2, y: 9 }, |
| 800 |
{ x: 5, y: 0.3 } |
| 801 |
]). |
| 802 |
addSeries("Series B", [ |
| 803 |
{ x: 0.3, y: 8 }, |
| 804 |
{ x: 4, y: 6 }, |
| 805 |
{ x: 5.5, y: 2 } |
| 806 |
]). |
| 807 |
render(); |
| 808 |
} |
| 809 |
}, |
| 810 |
{ |
| 811 |
description: "Markers, lines, 2D data, custom axis, blue theme.", |
| 812 |
makeChart: function(node){ |
| 813 |
(new Chart(node)). |
| 814 |
setTheme(blue). |
| 815 |
addPlot("default", { |
| 816 |
type: "Default", |
| 817 |
lines: true, |
| 818 |
markers: true, |
| 819 |
tension: 2 |
| 820 |
}). |
| 821 |
addAxis("x", { |
| 822 |
min: 0, |
| 823 |
max: 6, |
| 824 |
majorTick: { stroke: "black", length: 3 }, |
| 825 |
minorTick: { stroke: "gray", length: 3 }, |
| 826 |
minorLabels: false |
| 827 |
}). |
| 828 |
addAxis("y", { |
| 829 |
vertical: true, |
| 830 |
min: 0, |
| 831 |
max: 10, |
| 832 |
majorTick: { stroke: "black", length: 3 }, |
| 833 |
minorTick: { stroke: "gray", length: 3 }, |
| 834 |
minorLabels: false |
| 835 |
}). |
| 836 |
addSeries("Series A", [ |
| 837 |
{ x: 0.5, y: 5 }, |
| 838 |
{ x: 1.5, y: 1.5 }, |
| 839 |
{ x: 2, y: 9 }, |
| 840 |
{ x: 5, y: 0.3 } |
| 841 |
]). |
| 842 |
addSeries("Series B", [ |
| 843 |
{ x: 0.3, y: 8 }, |
| 844 |
{ x: 4, y: 6 }, |
| 845 |
{ x: 5.5, y: 2 } |
| 846 |
]). |
| 847 |
render(); |
| 848 |
} |
| 849 |
}, |
| 850 |
{ |
| 851 |
description: "Markers, lines, 2D data, custom centered axis, blue theme.", |
| 852 |
makeChart: function(node){ |
| 853 |
(new Chart(node)). |
| 854 |
setTheme(blue). |
| 855 |
addPlot("default", { |
| 856 |
type: "Default", |
| 857 |
lines: true, |
| 858 |
markers: true, |
| 859 |
tension: 2 |
| 860 |
}). |
| 861 |
addAxis("x", { |
| 862 |
min: 0, |
| 863 |
max: 6, |
| 864 |
majorTick: { stroke: "black", length: 3 }, |
| 865 |
minorTick: { stroke: "gray", length: 3 }, |
| 866 |
minorLabels: false, |
| 867 |
position: "center" |
| 868 |
}). |
| 869 |
addAxis("y", { |
| 870 |
vertical: true, |
| 871 |
min: 0, |
| 872 |
max: 10, |
| 873 |
majorTick: { stroke: "black", length: 3 }, |
| 874 |
minorTick: { stroke: "gray", length: 3 }, |
| 875 |
minorLabels: false, |
| 876 |
position: "center" |
| 877 |
}). |
| 878 |
addSeries("Series A", [ |
| 879 |
{ x: 0.5, y: 5 }, |
| 880 |
{ x: 1.5, y: 1.5 }, |
| 881 |
{ x: 2, y: 9 }, |
| 882 |
{ x: 5, y: 0.3 } |
| 883 |
]). |
| 884 |
addSeries("Series B", [ |
| 885 |
{ x: 0.3, y: 8 }, |
| 886 |
{ x: 4, y: 6 }, |
| 887 |
{ x: 5.5, y: 2 } |
| 888 |
]). |
| 889 |
render(); |
| 890 |
} |
| 891 |
} |
| 892 |
]; |
| 893 |
var now = function(){ |
| 894 |
return (new Date()).getTime(); |
| 895 |
}; |
| 896 |
|
| 897 |
|
| 898 |
ready(function(){ |
| 899 |
var defaultStyle = { width: "400px", height: "200px" }; |
| 900 |
var tmpl = new dtl.Template(dom.byId("template").value); |
| 901 |
var context = new Context({ charts: charts }); |
| 902 |
dom.byId("charts").innerHTML = tmpl.render(context); |
| 903 |
|
| 904 |
arr.forEach(charts, function(item, idx){ |
| 905 |
var start = now(); |
| 906 |
var n = dom.byId("chart_"+ (idx + 1)); |
| 907 |
domStyle.set(n, item.style||defaultStyle); |
| 908 |
item.makeChart(n); |
| 909 |
console.debug((now()-start), "ms to create:", (idx+1)+":", item.description); |
| 910 |
}); |
| 911 |
}); |
| 912 |
}); |
| 913 |
</script> |
| 914 |
</head> |
| 915 |
<body> |
| 916 |
<textarea id="template" style="display: none;"> |
| 917 |
{% for item in charts %} |
| 918 |
<p>{{ forloop.counter }}: {{ item.description }}</p> |
| 919 |
<div id="chart_{{ forloop.counter }}"></div> |
| 920 |
{% endfor %} |
| 921 |
</textarea> |
| 922 |
|
| 923 |
<h1>Chart 2D</h1> |
| 924 |
|
| 925 |
<div id="charts"></div> |
| 926 |
</body> |
| 927 |
</html> |