/public/javascripts/dojo/release/dojo/dojox/charting/tests/test_chart2d.html

http://enginey.googlecode.com/ · HTML · 680 lines · 642 code · 6 blank · 32 comment · 0 complexity · a85ee3a3c78710465bfa383f113b1c9e MD5 · raw file

  1. <html>
  2. <head>
  3. <title>Chart 2D</title>
  4. <style type="text/css">
  5. @import "../../../dojo/resources/dojo.css";
  6. @import "../../../dijit/tests/css/dijitTests.css";
  7. </style>
  8. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
  9. <!--
  10. <script type="text/javascript" src="../../lang/functional.js"></script>
  11. <script type="text/javascript" src="../../lang/utils.js"></script>
  12. <script type="text/javascript" src="../Theme.js"></script>
  13. <script type="text/javascript" src="../scaler/primitive.js"></script>
  14. <script type="text/javascript" src="../scaler/linear.js"></script>
  15. <script type="text/javascript" src="../Element.js"></script>
  16. <script type="text/javascript" src="../axis2d/common.js"></script>
  17. <script type="text/javascript" src="../axis2d/Base.js"></script>
  18. <script type="text/javascript" src="../axis2d/Default.js"></script>
  19. <script type="text/javascript" src="../plot2d/common.js"></script>
  20. <script type="text/javascript" src="../plot2d/Base.js"></script>
  21. <script type="text/javascript" src="../plot2d/Default.js"></script>
  22. <script type="text/javascript" src="../plot2d/Lines.js"></script>
  23. <script type="text/javascript" src="../plot2d/Areas.js"></script>
  24. <script type="text/javascript" src="../plot2d/Markers.js"></script>
  25. <script type="text/javascript" src="../plot2d/MarkersOnly.js"></script>
  26. <script type="text/javascript" src="../plot2d/Scatter.js"></script>
  27. <script type="text/javascript" src="../plot2d/Stacked.js"></script>
  28. <script type="text/javascript" src="../plot2d/StackedLines.js"></script>
  29. <script type="text/javascript" src="../plot2d/StackedAreas.js"></script>
  30. <script type="text/javascript" src="../plot2d/Columns.js"></script>
  31. <script type="text/javascript" src="../plot2d/StackedColumns.js"></script>
  32. <script type="text/javascript" src="../plot2d/ClusteredColumns.js"></script>
  33. <script type="text/javascript" src="../plot2d/Bars.js"></script>
  34. <script type="text/javascript" src="../plot2d/StackedBars.js"></script>
  35. <script type="text/javascript" src="../plot2d/ClusteredBars.js"></script>
  36. <script type="text/javascript" src="../plot2d/Bubble.js"></script>
  37. <script type="text/javascript" src="../plot2d/Grid.js"></script>
  38. <script type="text/javascript" src="../plot2d/Pie.js"></script>
  39. <script type="text/javascript" src="../Chart2D.js"></script>
  40. -->
  41. <script type="text/javascript">
  42. dojo.require("dojox.charting.Chart2D");
  43. dojo.require("dojox.charting.themes.Shrooms");
  44. dojo.require("dojox.charting.themes.PlotKit.blue");
  45. dojo.require("dojox.charting.themes.PlotKit.cyan");
  46. dojo.require("dojox.charting.themes.PlotKit.green");
  47. dojo.require("dojox.charting.themes.Ireland");
  48. dojo.require("dojox.charting.themes.SageToLime");
  49. dojo.require("dojox.charting.themes.Minty");
  50. dojo.require("dojox.charting.themes.Tufte");
  51. dojo.require("dojox.dtl");
  52. dojo.require("dojox.dtl.Context");
  53. charts = [
  54. {
  55. description: "Clustered columns with positive and negative values, readable theme.",
  56. makeChart: function(node){
  57. (new dojox.charting.Chart2D(node)).
  58. setTheme(dojox.charting.themes.Tufte).
  59. addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }).
  60. addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true }).
  61. addPlot("default", { type: "ClusteredColumns", gap: 10 }).
  62. addSeries("Series A", [ 2, 1, 0.5, -1, -2 ] ).
  63. addSeries("Series B", [ -2, -1, -0.5, 1, 2 ] ).
  64. addSeries("Series C", [ 1, 0.5, -1, -2, -3 ] ).
  65. addSeries("Series D", [ 0.7, 1.5, -1.2, -1.25, 3 ] ).
  66. render();
  67. }
  68. },
  69. {
  70. description: "Bubble chart, green theme.",
  71. makeChart: function(node){
  72. (new dojox.charting.Chart2D(node)).
  73. setTheme(dojox.charting.themes.SageToLime).
  74. addPlot("default", { type: "Bubble", shadows: { dx: 2, dy: 2, dw: 2 } }).
  75. addAxis("x", {
  76. min: 0,
  77. max: 6,
  78. majorTick: { stroke: "black", length: 3 },
  79. minorTick: { stroke: "gray", length: 3 }
  80. }).
  81. addAxis("y", {
  82. vertical: true,
  83. min: 0,
  84. max: 10,
  85. majorTick: { stroke: "black", length: 3 },
  86. minorTick: { stroke: "gray", length: 3 }
  87. }).
  88. addSeries("Series A", [
  89. { x: 0.5, y: 5, size: 1.4 },
  90. { x: 1.5, y: 1.5, size: 4.5 },
  91. { x: 2, y: 9, size:1.5 },
  92. { x: 5, y: 0.3, size:0.8 }
  93. ]).
  94. addSeries("Series B", [
  95. { x: 0.3, y: 8, size: 2.5 },
  96. { x: 4, y: 6, size:1.1 },
  97. { x: 5.5, y: 2, size: 3.2 }
  98. ]).
  99. render();
  100. }
  101. },
  102. {
  103. description: "Defaults: lines, no axes.",
  104. makeChart: function(node){
  105. (new dojox.charting.Chart2D(node)).
  106. addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ]).
  107. addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ]).
  108. render();
  109. }
  110. },
  111. {
  112. description: "Defaults: lines, no axes, and custom strokes.",
  113. makeChart: function(node){
  114. (new dojox.charting.Chart2D(node)).
  115. addSeries("Series A", [ 1, 2, 1, 2, 1, 2, 1 ], {stroke: "red"}).
  116. addSeries("Series B", [ 2, 1, 2, 1, 2, 1, 2 ], {stroke: "blue"}).
  117. render();
  118. }
  119. },
  120. {
  121. description: "Areas, Happy theme, no axes.",
  122. makeChart: function(node){
  123. (new dojox.charting.Chart2D(node)).
  124. addPlot("default", {type: "Areas", tension:"X"}).
  125. setTheme(dojox.charting.themes.Shrooms).
  126. addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]).
  127. addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]).
  128. addSeries("Series C", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2]).
  129. render();
  130. }
  131. },
  132. {
  133. description: "Areas, no axes, custom strokes and fills.",
  134. makeChart: function(node){
  135. (new dojox.charting.Chart2D(node)).
  136. addPlot("default", {type: "Areas"}).
  137. addSeries("Series A",
  138. [1, 2, 1, 2, 1, 2, 1],
  139. {
  140. stroke: {color: "red", width: 2 },
  141. fill: "lightpink"
  142. }
  143. ).
  144. addSeries("Series B",
  145. [ 2, 1, 2, 1, 2, 1, 2 ],
  146. {
  147. stroke: { color: "blue", width: 2 },
  148. fill: "lightblue"
  149. }
  150. ).
  151. render();
  152. }
  153. },
  154. {
  155. description: "Lines, axes, blue theme.",
  156. makeChart: function(node){
  157. (new dojox.charting.Chart2D(node)).
  158. setTheme(dojox.charting.themes.PlotKit.blue).
  159. addAxis("x").
  160. addAxis("y", {vertical: true}).
  161. addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]).
  162. addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
  163. render();
  164. }
  165. },
  166. {
  167. description: "Lines, axes (aligned on minor ticks), cyan theme.",
  168. makeChart: function(node){
  169. (new dojox.charting.Chart2D(node)).
  170. setTheme(dojox.charting.themes.PlotKit.cyan).
  171. addAxis("x", {
  172. fixLower: "minor", fixUpper: "minor"
  173. }).
  174. addAxis("y", {
  175. vertical: true, fixLower: "minor", fixUpper: "minor"
  176. }).
  177. addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]).
  178. addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
  179. render();
  180. }
  181. },
  182. {
  183. description: "Lines, axes (aligned on major ticks), green theme.",
  184. makeChart: function(node){
  185. (new dojox.charting.Chart2D(node)).
  186. setTheme(dojox.charting.themes.PlotKit.green).
  187. addAxis("x", {
  188. fixLower: "major", fixUpper: "major"
  189. }).
  190. addAxis("y", {
  191. vertical: true, fixLower: "major", fixUpper: "major"
  192. }).
  193. addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]).
  194. addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
  195. render();
  196. }
  197. },
  198. {
  199. description: "Lines and markers, no axes, purple theme, custom min/max.",
  200. makeChart: function(node){
  201. (new dojox.charting.Chart2D(node)).
  202. setTheme(dojox.charting.themes.SageToLime).
  203. addPlot("default", {type: "Markers"}).
  204. addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3}).
  205. addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]).
  206. render();
  207. }
  208. },
  209. {
  210. description: "Markers only, no axes, custom theme, custom markers, custom min/max.",
  211. makeChart: function(node){
  212. (new dojox.charting.Chart2D(node)).
  213. addPlot("default", { type: "MarkersOnly" }).
  214. addSeries("Series A",
  215. [ 1, 2, 1, 2, 1, 2, 1 ],
  216. {
  217. min: 0,
  218. max: 3,
  219. stroke: { color: "red", width: 2 },
  220. marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"
  221. }
  222. ).
  223. addSeries("Series B",
  224. [ 2, 1, 2, 1, 2, 1, 2 ],
  225. {
  226. stroke: { color: "blue", width: 2 },
  227. marker: "m-3,-3 l0,6 6,0 0,-6 z"
  228. }
  229. ).
  230. render();
  231. }
  232. },
  233. {
  234. description: "Lines and markers, shadows, no axes, custom theme, custom markers, custom min/max.",
  235. makeChart: function(node){
  236. (new dojox.charting.Chart2D(node)).
  237. addPlot("default", {
  238. type: "Markers", shadows: { dx: 2, dy: 2, dw: 2 }
  239. }).
  240. addSeries("Series A",
  241. [ 1, 2, 1, 2, 1, 2, 1 ],
  242. {
  243. min: 0,
  244. max: 3,
  245. stroke: { color: "red", width: 2, join: "round" },
  246. marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"
  247. }
  248. ).
  249. addSeries("Series B",
  250. [ 2, 1, 2, 1, 2, 1, 2 ],
  251. {
  252. stroke: { color: "blue", width: 2, join: "round" },
  253. marker: "m-3,-3 l0,6 6,0 0,-6 z"
  254. }
  255. ).
  256. render();
  257. }
  258. },
  259. {
  260. description: "Stacked lines, markers, shadows, no axes, custom strokes, fills, and markers.",
  261. makeChart: function(node){
  262. (new dojox.charting.Chart2D(node)).
  263. addPlot("default", {
  264. type: "StackedLines",
  265. markers: true,
  266. tension:"S",
  267. shadows: {dx: 2, dy: 2, dw: 2}
  268. }).
  269. addSeries("Series A",
  270. [ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ],
  271. {
  272. stroke: { color: "red", width: 2 },
  273. fill: "lightpink",
  274. marker: "m-3,-3 l0,6 6,0 0,-6 z"
  275. }
  276. ).
  277. addSeries("Series B",
  278. [ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ],
  279. {
  280. stroke: { color: "blue", width: 2 },
  281. fill: "lightblue",
  282. marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"
  283. }
  284. ).
  285. addSeries("Series C",
  286. [ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ],
  287. {
  288. stroke: { color: "green", width: 2 },
  289. fill: "lightgreen",
  290. marker: "m0,-3 l3,3 -3,3 -3,-3 z"
  291. }
  292. ).
  293. render();
  294. }
  295. },
  296. {
  297. description: "Stacked areas, axes (aligned on major ticks), custom strokes and fills.",
  298. makeChart: function(node){
  299. (new dojox.charting.Chart2D(node)).
  300. addAxis("x", {fixLower: "major", fixUpper: "major"}).
  301. addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0}).
  302. addPlot("default", { type: "StackedAreas", tension:"S" }).
  303. addSeries("Series A",
  304. [ -2, 1.1, 1.2, 1.3, 1.4, 1.5, -1.6 ],
  305. { stroke: {color: "red", width: 2}, fill: "lightpink" }
  306. ).
  307. addSeries("Series B",
  308. [ 1, 1.6, 1.3, 1.4, 1.1, 1.5, 1.1 ],
  309. { stroke: {color: "blue", width: 2}, fill: "lightblue" }
  310. ).
  311. addSeries("Series C",
  312. [ 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 ],
  313. { stroke: {color: "green", width: 2}, fill: "lightgreen" }
  314. ).
  315. render();
  316. }
  317. },
  318. {
  319. description: "Columns, no axes, custom strokes and fills.",
  320. makeChart: function(node){
  321. (new dojox.charting.Chart2D(node)).
  322. addPlot("default", {type: "Columns"}).
  323. addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }).
  324. addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }).
  325. render();
  326. }
  327. },
  328. {
  329. description: "Columns with gaps beetwen them, vertical axis aligned on major ticks, custom strokes, fills.",
  330. makeChart: function(node){
  331. (new dojox.charting.Chart2D(node)).
  332. addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"}).
  333. addPlot("default", {type: "Columns", gap: 2}).
  334. addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: {color: "red"}, fill: "lightpink" }).
  335. addSeries("Series B", [ 5, 4, 3, 2, 1 ], { stroke: {color: "blue"}, fill: "lightblue" }).
  336. render();
  337. }
  338. },
  339. {
  340. description: "Stacked columns, no axes, custom strokes and fills.",
  341. makeChart: function(node){
  342. (new dojox.charting.Chart2D(node)).
  343. addPlot("default", {type: "StackedColumns"}).
  344. addSeries("Series A", [ 1, 2, 3, 4, 5 ], {stroke: { color: "red" }, fill: "lightpink" }).
  345. addSeries("Series B", [ 2, 1, 2, 1, 2 ], {stroke: { color: "blue" }, fill: "lightblue" }).
  346. render();
  347. }
  348. },
  349. {
  350. description: "Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills.",
  351. makeChart: function(node){
  352. (new dojox.charting.Chart2D(node)).
  353. addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}).
  354. addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true}).
  355. addPlot("default", {type: "Bars"}).
  356. addSeries("Series A",
  357. [1, 2, 3, 4, 5],
  358. { stroke: {color: "red"}, fill: "lightpink" }
  359. ).
  360. addSeries("Series B",
  361. [5, 4, 3, 2, 1],
  362. { stroke: {color: "blue"}, fill: "lightblue" }
  363. ).
  364. render();
  365. }
  366. },
  367. {
  368. description: "Stacked bars, no axes, custom strokes and fills.",
  369. makeChart: function(node){
  370. (new dojox.charting.Chart2D(node)).
  371. addPlot("default", {type: "StackedBars"}).
  372. addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }).
  373. addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }).
  374. render();
  375. }
  376. },
  377. {
  378. description: "Clustered columns, custom axes, custom strokes, fills, and gap.",
  379. makeChart: function(node){
  380. (new dojox.charting.Chart2D(node)).
  381. addAxis("x", {
  382. fixLower: "minor", fixUpper: "minor", natural: true
  383. }).
  384. addAxis("y", {
  385. vertical: true, fixLower: "major", fixUpper: "major", includeZero: true
  386. }).
  387. addPlot("default", {type: "ClusteredColumns", gap: 10}).
  388. addSeries("Series A",
  389. [ 1, 2, 3, 4, 5 ],
  390. { stroke: {color: "red"}, fill: "lightpink" }
  391. ).
  392. addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}).
  393. render();
  394. }
  395. },
  396. {
  397. description: "Clustered bars, custom axes, custom strokes, fills, and gap.",
  398. makeChart: function(node){
  399. (new dojox.charting.Chart2D(node)).
  400. addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true}).
  401. addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor", natural: true}).
  402. addPlot("default", { type: "ClusteredBars", gap: 5 }).
  403. addSeries("Series A", [ 1, 2, 3, 4, 5 ], { stroke: { color: "red" }, fill: "lightpink" }).
  404. addSeries("Series B", [ 2, 1, 2, 1, 2 ], { stroke: { color: "blue" }, fill: "lightblue" }).
  405. render();
  406. }
  407. },
  408. {
  409. description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes.",
  410. makeChart: function(node){
  411. (new dojox.charting.Chart2D(node)).
  412. addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }).
  413. addAxis("y", {
  414. vertical: true,
  415. fixLower: "major",
  416. fixUpper: "major",
  417. minorTicks: false,
  418. includeZero: true
  419. }).
  420. addPlot("front_grid", { type: "Grid", hMajorLines: true, vMajorLines: false }).
  421. addPlot("default", { type: "Columns", gap: 10 }).
  422. addPlot("back_grid", { type: "Grid", hMajorLines: false, vMajorLines: true }).
  423. addSeries("Series A",
  424. [ 1, 2, 3, 4, 5 ],
  425. { stroke: { color: "red" }, fill: "lightpink" }
  426. ).
  427. addSeries("Series B",
  428. [ 5, 4, 3, 2, 1 ],
  429. { stroke: { color: "blue" }, fill: "lightblue" }
  430. ).
  431. render();
  432. }
  433. },
  434. {
  435. description: "Columns with gaps beetwen them, grids, custom strokes, fills, axes, with min=0, max=8, and manually specified ticks on the vertical axis.",
  436. makeChart: function(node){
  437. (new dojox.charting.Chart2D(node)).
  438. addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true}).
  439. addAxis("y", {
  440. vertical: true, fixLower: "major", fixUpper: "major",
  441. includeZero: true, min: 0, max: 8, minorLabels: false,
  442. majorTicks: true, minorTicks: true, microTicks: false,
  443. majorTickStep: 2, minorTickStep: 1, microTickStep: 0.5
  444. }).
  445. addPlot("front_grid", {
  446. type: "Grid", hMajorLines: true, vMajorLines: false
  447. }).
  448. addPlot("default", {type: "Columns", gap: 10}).
  449. addPlot("back_grid", {
  450. type: "Grid", hMajorLines: false, vMajorLines: true
  451. }).
  452. addSeries("Series A",
  453. [ 1, 2, 3, 4, 5 ],
  454. { stroke: {color: "red"}, fill: "lightpink" }
  455. ).
  456. addSeries("Series B",
  457. [ 5, 4, 3, 2, 1 ],
  458. { stroke: {color: "blue"}, fill: "lightblue" }
  459. ).
  460. render();
  461. }
  462. },
  463. {
  464. description: "Columns with positive and negative values, axes, and grid.",
  465. makeChart: function(node){
  466. (new dojox.charting.Chart2D(node)).
  467. addAxis("x").
  468. addAxis("y", { vertical: true }).
  469. addPlot("default", { type: "Columns", gap: 10 }).
  470. addPlot("grid", { type: "Grid" }).
  471. addSeries("Series A",
  472. [ 2, 1, 0.5, -1, -2 ],
  473. { stroke: {color: "red"}, fill: "lightpink" }
  474. ).
  475. addSeries("Series B",
  476. [ -2, -1, -0.5, 1, 2 ],
  477. { stroke: {color: "blue"}, fill: "lightblue" }
  478. ).
  479. render();
  480. }
  481. },
  482. {
  483. description: "Clustered columns with positive and negative values, axes, and grid.",
  484. makeChart: function(node){
  485. (new dojox.charting.Chart2D(node)).
  486. addAxis("x").
  487. addAxis("y", { vertical: true }).
  488. addPlot("default", { type: "ClusteredColumns", gap: 10 }).
  489. addPlot("grid", { type: "Grid" }).
  490. addSeries("Series A",
  491. [ 2, 1, 0.5, -1, -2 ],
  492. { stroke: {color: "red"}, fill: "lightpink" }
  493. ).
  494. addSeries("Series B",
  495. [ -2, -1, -0.5, 1, 2 ],
  496. { stroke: {color: "blue"}, fill: "lightblue" }
  497. ).
  498. addSeries("Series C",
  499. [ 1, 0.5, -1, -2, -3 ],
  500. { stroke: {color: "green"}, fill: "lightgreen" }
  501. ).
  502. render();
  503. }
  504. },
  505. {
  506. description: "Bars with positive and negative values, axes, and grid.",
  507. makeChart: function(node){
  508. (new dojox.charting.Chart2D(node)).
  509. addAxis("x").
  510. addAxis("y", { vertical: true }).
  511. addPlot("default", { type: "Bars", gap: 10 }).
  512. addPlot("grid", { type: "Grid" }).
  513. addSeries("Series A",
  514. [ 2, 1, 0.5, -1, -2 ],
  515. { stroke: {color: "red"}, fill: "lightpink" }
  516. ).
  517. addSeries("Series B",
  518. [ -2, -1, -0.5, 1, 2 ],
  519. { stroke: {color: "blue"}, fill: "lightblue" }
  520. ).
  521. render();
  522. }
  523. },
  524. {
  525. description: "Clustered bars with positive and negative values, axes, and grid.",
  526. makeChart: function(node){
  527. (new dojox.charting.Chart2D(node)).
  528. addAxis("x").
  529. addAxis("y", { vertical: true }).
  530. addPlot("default", { type: "ClusteredBars", gap: 10 }).
  531. addPlot("grid", { type: "Grid" }).
  532. addSeries("Series A",
  533. [ 2, 1, 0.5, -1, -2 ],
  534. { stroke: { color: "red" }, fill: "lightpink" }
  535. ).
  536. addSeries("Series B",
  537. [ -2, -1, -0.5, 1, 2 ],
  538. { stroke: { color: "blue" }, fill: "lightblue" }
  539. ).
  540. addSeries("Series C",
  541. [ 1, 0.5, -1, -2, -3 ],
  542. { stroke: { color: "green" }, fill: "lightgreen" }
  543. ).
  544. render();
  545. }
  546. },
  547. {
  548. description: "Default lines with 2D data, custom axis, red theme.",
  549. makeChart: function(node){
  550. (new dojox.charting.Chart2D(node)).
  551. setTheme(dojox.charting.themes.Minty).
  552. addAxis("x", {
  553. min: 0,
  554. max: 6,
  555. majorTick: { stroke: "black", length: 3 },
  556. minorTick: { stroke: "gray", length: 3 }
  557. }).
  558. addAxis("y", {
  559. vertical: true,
  560. min: 0,
  561. max: 10,
  562. majorTick: { stroke: "black", length: 3 },
  563. minorTick: { stroke: "gray", length: 3 }
  564. }).
  565. addSeries("Series A", [
  566. { x: 0.5, y: 5 },
  567. { x: 1.5, y: 1.5 },
  568. { x: 2, y: 9 },
  569. { x: 5, y: 0.3 }
  570. ]).
  571. addSeries("Series B", [
  572. { x: 0.3, y: 8 },
  573. { x: 4, y: 6 },
  574. { x: 5.5, y: 2 }
  575. ]).
  576. render();
  577. }
  578. },
  579. {
  580. description: "Scatter chart, custom axis, purple theme.",
  581. makeChart: function(node){
  582. (new dojox.charting.Chart2D(node)).
  583. setTheme(dojox.charting.themes.Ireland).
  584. addPlot("default", {type: "Scatter"}).
  585. addAxis("x", {
  586. min: 0,
  587. max: 6,
  588. majorTick: { stroke: "black", length: 3 },
  589. minorTick: { stroke: "gray", length: 3 }
  590. }).
  591. addAxis("y", {
  592. vertical: true,
  593. min: 0,
  594. max: 10,
  595. majorTick: { stroke: "black", length: 3 },
  596. minorTick: { stroke: "gray", length: 3 }
  597. }).
  598. addSeries("Series A", [
  599. { x: 0.5, y: 5 },
  600. { x: 1.5, y: 1.5 },
  601. { x: 2, y: 9 },
  602. { x: 5, y: 0.3 }
  603. ]).
  604. addSeries("Series B", [
  605. { x: 0.3, y: 8 },
  606. { x: 4, y: 6 },
  607. { x: 5.5, y: 2 }
  608. ]).
  609. render();
  610. }
  611. },
  612. {
  613. description: "Markers, lines, 2D data, custom axis, blue theme.",
  614. makeChart: function(node){
  615. (new dojox.charting.Chart2D(node)).
  616. setTheme(dojox.charting.themes.PlotKit.blue).
  617. addPlot("default", {
  618. type: "Default",
  619. lines: true,
  620. markers: true,
  621. tension: 2
  622. }).
  623. addAxis("x", {
  624. min: 0,
  625. max: 6,
  626. majorTick: { stroke: "black", length: 3 },
  627. minorTick: { stroke: "gray", length: 3 }
  628. }).
  629. addAxis("y", {
  630. vertical: true,
  631. min: 0,
  632. max: 10,
  633. majorTick: { stroke: "black", length: 3 },
  634. minorTick: { stroke: "gray", length: 3 }
  635. }).
  636. addSeries("Series A", [
  637. { x: 0.5, y: 5 },
  638. { x: 1.5, y: 1.5 },
  639. { x: 2, y: 9 },
  640. { x: 5, y: 0.3 }
  641. ]).
  642. addSeries("Series B", [
  643. { x: 0.3, y: 8 },
  644. { x: 4, y: 6 },
  645. { x: 5.5, y: 2 }
  646. ]).
  647. render();
  648. }
  649. }
  650. ];
  651. dojo.addOnLoad(function(){
  652. var defaultStyle = { width: "400px", height: "200px" };
  653. var tmpl = new dojox.dtl.Template(dojo.byId("template").value);
  654. var context = new dojox.dtl.Context({ charts: charts });
  655. dojo.byId("charts").innerHTML = tmpl.render(context);
  656. dojo.forEach(charts, function(item, idx){
  657. var n = dojo.byId("chart_"+idx);
  658. dojo.style(n, item.style||defaultStyle);
  659. item.makeChart(n);
  660. });
  661. });
  662. </script>
  663. </head>
  664. <body>
  665. <textarea id="template" style="display: none;">
  666. {% for item in charts %}
  667. <p>{{ forloop.counter }}: {{ item.description }}</p>
  668. <div id="chart_{{ forloop.counter0 }}"></div>
  669. {% endfor %}
  670. </textarea>
  671. <h1>Chart 2D</h1>
  672. <div id="charts"></div>
  673. </body>
  674. </html>