| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
<![if gte IE 9]> |
| 13 |
<!DOCTYPE HTML> |
| 14 |
<html lang="en"> |
| 15 |
<head> |
| 16 |
<![endif]> |
| 17 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 18 |
<title>Chart: Selectable Legend test</title> |
| 19 |
<style type="text/css"> |
| 20 |
@import "../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 22 |
@import "../../../dijit/themes/claro/claro.css"; |
| 23 |
@import "../resources/Legend.css"; |
| 24 |
</style> |
| 25 |
<style> |
| 26 |
.bars{ |
| 27 |
width:300px; |
| 28 |
height:200px; |
| 29 |
} |
| 30 |
.columns{ |
| 31 |
width:300px; |
| 32 |
height:250px; |
| 33 |
} |
| 34 |
.pie { |
| 35 |
width:500px; |
| 36 |
height:300px; |
| 37 |
} |
| 38 |
.bubble{ |
| 39 |
width:320px; |
| 40 |
height:300px; |
| 41 |
} |
| 42 |
.spider { |
| 43 |
width:400px; |
| 44 |
height:400px; |
| 45 |
} |
| 46 |
|
| 47 |
</style> |
| 48 |
|
| 49 |
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
| 50 |
<script type="text/javascript"> |
| 51 |
dojo.require("dijit.dijit"); |
| 52 |
dojo.require("dojox.charting.Chart"); |
| 53 |
dojo.require("dojox.charting.axis2d.Default"); |
| 54 |
dojo.require("dojox.charting.plot2d.Lines"); |
| 55 |
dojo.require("dojox.charting.plot2d.StackedLines"); |
| 56 |
dojo.require("dojox.charting.plot2d.StackedAreas"); |
| 57 |
dojo.require("dojox.charting.plot2d.Bars"); |
| 58 |
dojo.require("dojox.charting.plot2d.ClusteredBars"); |
| 59 |
dojo.require("dojox.charting.plot2d.StackedBars"); |
| 60 |
dojo.require("dojox.charting.plot2d.Columns"); |
| 61 |
dojo.require("dojox.charting.plot2d.ClusteredColumns"); |
| 62 |
dojo.require("dojox.charting.plot2d.StackedColumns"); |
| 63 |
dojo.require("dojox.charting.plot2d.Candlesticks"); |
| 64 |
dojo.require("dojox.charting.plot2d.Spider"); |
| 65 |
dojo.require("dojox.charting.plot2d.Scatter"); |
| 66 |
|
| 67 |
dojo.require("dojox.charting.plot2d.Bubble"); |
| 68 |
dojo.require("dojox.charting.plot2d.Pie"); |
| 69 |
dojo.require("dojox.charting.themes.MiamiNice"); |
| 70 |
dojo.require("dojox.charting.widget.SelectableLegend"); |
| 71 |
dojo.require("dojox.charting.action2d.Highlight"); |
| 72 |
|
| 73 |
dojo.addOnLoad(function(){ |
| 74 |
var bars = new dojox.charting.Chart("bars"). |
| 75 |
setTheme(dojox.charting.themes.MiamiNice). |
| 76 |
addPlot("default",{type: "Bars",gap:2}). |
| 77 |
addAxis("x",{natural: true, includeZero: true}). |
| 78 |
addAxis("y",{natural: true, vertical:true}). |
| 79 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 80 |
addSeries("B",[2,4,6,8,3,5,7], {hide: true}). |
| 81 |
render(); |
| 82 |
var barsLegend = new dojox.charting.widget.SelectableLegend({chart: bars},"barsLegend"); |
| 83 |
|
| 84 |
var clusteredBars = new dojox.charting.Chart("clusteredBars"). |
| 85 |
setTheme(dojox.charting.themes.MiamiNice). |
| 86 |
addPlot("default",{type:"ClusteredBars",gap:2}). |
| 87 |
addAxis("x",{natural: true, includeZero: true}). |
| 88 |
addAxis("y",{natural: true, vertical:true}). |
| 89 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 90 |
addSeries("B",[2,4,6,8,3,5,7], {hide: true}). |
| 91 |
addSeries("C",[6,4,2,7,5,3,1]); |
| 92 |
new dojox.charting.action2d.Highlight(clusteredBars, "default"); |
| 93 |
clusteredBars.render(); |
| 94 |
var clusteredBarsLegend = new dojox.charting.widget.SelectableLegend({chart: clusteredBars},"clusteredBarsLegend"); |
| 95 |
|
| 96 |
var stackedBars = new dojox.charting.Chart("stackedBars"). |
| 97 |
setTheme(dojox.charting.themes.MiamiNice). |
| 98 |
addPlot("default", {type:"StackedBars",gap:2}). |
| 99 |
addAxis("x",{natual: true, includeZero: true, majorTickStep:1}). |
| 100 |
addAxis("y",{natual: true, vertical: true}). |
| 101 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 102 |
addSeries("B",[2,4,6,8,3,5,7], {hide: true}). |
| 103 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 104 |
render(); |
| 105 |
var stackedBarsLegend = new dojox.charting.widget.SelectableLegend({chart: stackedBars, autoScale: true},"stackedBarsLegend"); |
| 106 |
|
| 107 |
var lines = new dojox.charting.Chart("lines"). |
| 108 |
setTheme(dojox.charting.themes.MiamiNice). |
| 109 |
addPlot("default",{type: "Lines",markers:true}). |
| 110 |
addAxis("y",{natural: true, vertical:true,includeZero: true}). |
| 111 |
addAxis("x",{natural: true,includeZero: true}). |
| 112 |
addSeries("A",[2,4,6,8,3,5,7]). |
| 113 |
addSeries("B",[1,3,5,7,2,4,6],{hide: true}). |
| 114 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 115 |
render(); |
| 116 |
var linesLegend = new dojox.charting.widget.SelectableLegend({chart: lines},"linesLegend"); |
| 117 |
|
| 118 |
var stackedLines = new dojox.charting.Chart("stackedLines"). |
| 119 |
setTheme(dojox.charting.themes.MiamiNice). |
| 120 |
addPlot("default",{type: "StackedLines",markers:true}). |
| 121 |
addAxis("y",{natural: true, vertical:true,includeZero: true}). |
| 122 |
addAxis("x",{natural: true,includeZero: true}). |
| 123 |
addSeries("A",[2,4,6,8,3,5,7]). |
| 124 |
addSeries("B",[1,3,5,7,2,4,6],{hide: true}). |
| 125 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 126 |
render(); |
| 127 |
var stackedLinesLegend = new dojox.charting.widget.SelectableLegend({chart: stackedLines, autoScale: true},"stackedLinesLegend"); |
| 128 |
|
| 129 |
|
| 130 |
var stackedArea = new dojox.charting.Chart("stackedArea"). |
| 131 |
setTheme(dojox.charting.themes.MiamiNice). |
| 132 |
addPlot("default", {type:"StackedAreas",tension:4}). |
| 133 |
addAxis("y",{natural: true, includeZero: true, vertical:true}). |
| 134 |
addAxis("x",{natural: true}). |
| 135 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 136 |
addSeries("B",[2,4,6,8,3,5,7], {hide: true}). |
| 137 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 138 |
render(); |
| 139 |
var stackedAreaLegend = new dojox.charting.widget.SelectableLegend({chart: stackedArea, autoScale: true},"stackedAreaLegend"); |
| 140 |
|
| 141 |
var candleSticks = new dojox.charting.Chart("candleSticks"). |
| 142 |
setTheme(dojox.charting.themes.MiamiNice). |
| 143 |
addPlot("default", {type:"Candlesticks", gap: 3}). |
| 144 |
addAxis("y",{natural: true, includeZero: true, vertical:true}). |
| 145 |
addAxis("x",{natural: true}). |
| 146 |
addSeries("A",[ |
| 147 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 148 |
{ open: 16, close: 22, high: 26, low: 6, mid: 18 }, |
| 149 |
{ open: 22, close: 18, high: 22, low: 11, mid: 21 }, |
| 150 |
{ open: 18, close: 29, high: 32, low: 14, mid: 27 }, |
| 151 |
{ open: 29, close: 24, high: 29, low: 13, mid: 27 }, |
| 152 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 153 |
{ open: 8, close: 16, high: 22, low: 2 } |
| 154 |
]). |
| 155 |
addSeries("B",[ |
| 156 |
{ open: 24, close: 8, high: 24, low: 5 }, |
| 157 |
{ open: 8, close: 16, high: 22, low: 2 }, |
| 158 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 159 |
{ open: 12, close: 20, high: 22, low: 8 }, |
| 160 |
{ open: 20, close: 16, high: 22, low: 8 }, |
| 161 |
{ open: 16, close: 12, high: 19, low: 7 }, |
| 162 |
{ open: 12, close: 20, high: 22, low: 8 } |
| 163 |
], {hide: true}). |
| 164 |
render(); |
| 165 |
var candleSticksLegend = new dojox.charting.widget.SelectableLegend({chart: candleSticks},"candleSticksLegend"); |
| 166 |
|
| 167 |
var scatter = new dojox.charting.Chart("scatter"). |
| 168 |
setTheme(dojox.charting.themes.MiamiNice). |
| 169 |
addPlot("default",{type: "Scatter",markers:true}). |
| 170 |
addAxis("y",{natural: true, vertical:true,includeZero: true}). |
| 171 |
addAxis("x",{natural: true,includeZero: true}). |
| 172 |
addSeries("A",[2,4,6,8,3,5,7]). |
| 173 |
addSeries("B",[1,3,5,7,2,4,6],{hide: true}). |
| 174 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 175 |
render(); |
| 176 |
var scatterLegend = new dojox.charting.widget.SelectableLegend({chart: scatter},"scatterLegend"); |
| 177 |
|
| 178 |
|
| 179 |
var columns = new dojox.charting.Chart("columns"). |
| 180 |
setTheme(dojox.charting.themes.MiamiNice). |
| 181 |
addPlot("default",{type: "Columns",gap:2}). |
| 182 |
addAxis("y",{natural: true, includeZero: true, vertical:true}). |
| 183 |
addAxis("x",{natural: true}). |
| 184 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 185 |
addSeries("B",[2,4,6,8,3,5,7], {hide: true}). |
| 186 |
render(); |
| 187 |
var columnsLegend = new dojox.charting.widget.SelectableLegend({chart: columns},"columnsLegend"); |
| 188 |
|
| 189 |
var clusteredColumns = new dojox.charting.Chart("clusteredColumns"). |
| 190 |
setTheme(dojox.charting.themes.MiamiNice). |
| 191 |
addPlot("default",{type:"ClusteredColumns",gap:2}). |
| 192 |
addAxis("y",{natural: true, includeZero: true, vertical:true}). |
| 193 |
addAxis("x",{natural: true}). |
| 194 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 195 |
addSeries("B",[2,4,6,8,3,5,7], {hide: true}). |
| 196 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 197 |
render(); |
| 198 |
var clusteredColumnsLegend = new dojox.charting.widget.SelectableLegend({chart: clusteredColumns},"clusteredColumnsLegend"); |
| 199 |
|
| 200 |
var stackedColumns = new dojox.charting.Chart("stackedColumns"). |
| 201 |
setTheme(dojox.charting.themes.MiamiNice). |
| 202 |
addPlot("default", {type:"StackedColumns",gap:2}). |
| 203 |
addAxis("y",{natual: true, includeZero: true, majorTickStep:1, vertical: true}). |
| 204 |
addAxis("x",{natual: true}). |
| 205 |
addSeries("A",[1,3,5,7,2,4,6]). |
| 206 |
addSeries("B",[2,4,6,8,3,5,7], {hidden: true}). |
| 207 |
addSeries("C",[6,4,2,7,5,3,1]). |
| 208 |
render(); |
| 209 |
var stackedColumnsLegend = new dojox.charting.widget.SelectableLegend({chart: stackedColumns, autoScale: true},"stackedColumnsLegend"); |
| 210 |
|
| 211 |
var linesColumns = new dojox.charting.Chart("linesColumns"). |
| 212 |
setTheme(dojox.charting.themes.MiamiNice). |
| 213 |
addPlot("lines",{type: "Lines",markers:true}). |
| 214 |
addPlot("default",{type: "Columns",gap:2}). |
| 215 |
addAxis("y",{natural: true, vertical:true,includeZero: true}). |
| 216 |
addAxis("x",{natural: true,includeZero: true}). |
| 217 |
addSeries("A",[2,4,6,8,3,5,7]). |
| 218 |
addSeries("B",[1,3,5,7,2,4,6],{plot:"lines", hidden: true}). |
| 219 |
render(); |
| 220 |
var linesColumnsLegend = new dojox.charting.widget.SelectableLegend({chart: linesColumns},"linesColumnsLegend"); |
| 221 |
|
| 222 |
var pie = new dojox.charting.Chart("pie"). |
| 223 |
setTheme(dojox.charting.themes.MiamiNice). |
| 224 |
addPlot("default",{type:"Pie",radius:100,font: "normal normal 10pt Tahoma",htmlLabels:true,labelOffset:-20}). |
| 225 |
addSeries("A",[{ |
| 226 |
y: 12.1, |
| 227 |
text: "China" |
| 228 |
},{ |
| 229 |
y: 9.52, |
| 230 |
text: "India" |
| 231 |
}, { |
| 232 |
y: 2.66, |
| 233 |
text: "USA", |
| 234 |
hidden: true |
| 235 |
}, { |
| 236 |
y: 2.06, |
| 237 |
text: "Indonesia" |
| 238 |
}, { |
| 239 |
y: 1.63, |
| 240 |
text: "Brazil" |
| 241 |
},{ |
| 242 |
y: 1.48, |
| 243 |
text: "Russian" |
| 244 |
},{ |
| 245 |
y: 1.29, |
| 246 |
text: "Pakistan" |
| 247 |
},{ |
| 248 |
y: 1.25, |
| 249 |
text: "Japan" |
| 250 |
}]). |
| 251 |
render(); |
| 252 |
var ainm = new dojox.charting.action2d.Highlight(pie,"default"); |
| 253 |
var pieLegend = new dojox.charting.widget.SelectableLegend({chart: pie,horizontal:false, outline: true},"pieLegend"); |
| 254 |
|
| 255 |
var bubble = new dojox.charting.Chart("bubble"). |
| 256 |
setTheme(dojox.charting.themes.MiamiNice). |
| 257 |
addPlot("default",{type:"Bubble"}). |
| 258 |
addAxis("x",{natual:true, includeZero: true, max:7}). |
| 259 |
addAxis("y",{natual:true, vertical: true, includeZero: true,max:10}). |
| 260 |
addSeries("A",[{x:3,y:5,size:1},{x:1,y:7,size:1},{x:4,y:2,size:3}]). |
| 261 |
addSeries("B",[{x:5,y:5,size:2},{x:2,y:3,size:4},{x:6,y:2,size:1}], {hidden: true}). |
| 262 |
addSeries("C",[{x:2,y:7,size:3},{x:6,y:8,size:3}]). |
| 263 |
render(); |
| 264 |
var bubbleLegend = new dojox.charting.widget.SelectableLegend({chart: bubble, horizontal:false, outline:true},"bubbleLegend"); |
| 265 |
|
| 266 |
var spider = new dojox.charting.Chart("spider") |
| 267 |
.setTheme(dojox.charting.themes.MiamiNice) |
| 268 |
.addPlot("default", { |
| 269 |
type: "Spider", |
| 270 |
labelOffset: -10, |
| 271 |
divisions: 7, |
| 272 |
axisColor: "lightgray", |
| 273 |
spiderColor: "silver", |
| 274 |
seriesFillAlpha: 0.2, |
| 275 |
spiderOrigin: 0.16, |
| 276 |
markerSize: 3, |
| 277 |
precision: 0, |
| 278 |
spiderType: "polygon" |
| 279 |
}) |
| 280 |
.addSeries("China", {data: {"GDP": 2,"area": 6,"population": 2000,"inflation": 15,"growth": 12}}, { fill: "blue" }) |
| 281 |
.addSeries("France", {data: {"GDP": 6,"area": 15,"population": 500,"inflation": 5,"growth": 6}}, { fill: "red" }) |
| 282 |
.addSeries("USA", {data: {"GDP": 3,"area": 20,"population": 1500,"inflation": 10,"growth": 3}}, { fill: "green", hidden: true }) |
| 283 |
.addSeries("Japan", {data: {"GDP": 4,"area": 2,"population": 1000,"inflation": 20,"growth": 2}}, { fill: "yellow", hidden: true }) |
| 284 |
.addSeries("Korean", {data: {"GDP": 10,"area": 10,"population": 800,"inflation": 2,"growth": 18}}, { fill: "orange" }) |
| 285 |
.addSeries("Canada", {data: {"GDP": 1,"area": 18,"population": 300,"inflation": 3,"growth": 15}}, { fill: "purple" }) |
| 286 |
.render(); |
| 287 |
|
| 288 |
var spiderLegend = new dojox.charting.widget.SelectableLegend({chart: spider, horizontal: false}, "spiderLegend"); |
| 289 |
|
| 290 |
dojo.query("h2").forEach(function(node, i){ |
| 291 |
node.innerHTML = i+1 +" - "+node.innerHTML; |
| 292 |
}); |
| 293 |
}) |
| 294 |
|
| 295 |
</script> |
| 296 |
</head> |
| 297 |
<body class="claro"> |
| 298 |
<h1>Chart: Selectable Legend</h1> |
| 299 |
<h3>Click the legends</h3> |
| 300 |
<div style="clear:both;"> |
| 301 |
<div style="float:left;"> |
| 302 |
<h2>Bars</h2> |
| 303 |
<div id="bars" class="bars"></div> |
| 304 |
<div id="barsLegend"></div> |
| 305 |
</div> |
| 306 |
<div style="float:left;"> |
| 307 |
<h2>Clustered Bars</h2> |
| 308 |
<div id="clusteredBars" class="bars"></div> |
| 309 |
<div id="clusteredBarsLegend"></div> |
| 310 |
</div> |
| 311 |
<div style="float:left;"> |
| 312 |
<h2>Stacked Bars</h2> |
| 313 |
<div id="stackedBars" class="bars"></div> |
| 314 |
<div id="stackedBarsLegend"></div> |
| 315 |
</div> |
| 316 |
</div> |
| 317 |
<div style="clear:both;"> |
| 318 |
<div style="float:left;"> |
| 319 |
<h2>Columns</h2> |
| 320 |
<div id="columns" class="columns"></div> |
| 321 |
<div id="columnsLegend"></div> |
| 322 |
</div> |
| 323 |
<div style="float:left;"> |
| 324 |
<h2>Clustered Columns</h2> |
| 325 |
<div id="clusteredColumns" class="columns"></div> |
| 326 |
<div id="clusteredColumnsLegend"></div> |
| 327 |
</div> |
| 328 |
<div style="float:left;"> |
| 329 |
<h2>Stacked Columns</h2> |
| 330 |
<div id="stackedColumns" class="columns"></div> |
| 331 |
<div id="stackedColumnsLegend"></div> |
| 332 |
</div> |
| 333 |
</div> |
| 334 |
<div style="clear:both;"> |
| 335 |
<div style="float:left;"> |
| 336 |
<h2>Lines</h2> |
| 337 |
<div id="lines" class="bars"></div> |
| 338 |
<div id="linesLegend"></div> |
| 339 |
</div> |
| 340 |
<div style="float:left;"> |
| 341 |
<h2>Stacked Lines</h2> |
| 342 |
<div id="stackedLines" class="bars"></div> |
| 343 |
<div id="stackedLinesLegend"></div> |
| 344 |
</div> |
| 345 |
<div style="float:left;"> |
| 346 |
<h2>Stacked Area</h2> |
| 347 |
<div id="stackedArea" class="bars"></div> |
| 348 |
<div id="stackedAreaLegend"></div> |
| 349 |
</div> |
| 350 |
|
| 351 |
</div> |
| 352 |
<div style="clear:both;"> |
| 353 |
<div style="float:left;"> |
| 354 |
<h2>ClandeSticks</h2> |
| 355 |
<div id="candleSticks" class="columns"></div> |
| 356 |
<div id="candleSticksLegend"></div> |
| 357 |
</div> |
| 358 |
<div style="float:left;"> |
| 359 |
<h2>Scatter</h2> |
| 360 |
<div id="scatter" class="columns"></div> |
| 361 |
<div id="scatterLegend"></div> |
| 362 |
</div> |
| 363 |
<div style="float:left;"> |
| 364 |
<h2>Lines&Columns</h2> |
| 365 |
<div id="linesColumns" class="columns"></div> |
| 366 |
<div id="linesColumnsLegend"></div> |
| 367 |
</div> |
| 368 |
</div> |
| 369 |
<div style="clear:both;"> |
| 370 |
<div style="float:left;"> |
| 371 |
<h2>Pie</h2> |
| 372 |
<div id="pie" class="pie" style="float:left;"></div> |
| 373 |
<div style="float:left;"> |
| 374 |
<div id="pieLegend"></div> |
| 375 |
</div> |
| 376 |
</div> |
| 377 |
<div style="float:left;margin-left:40px"> |
| 378 |
<h2>Bubble</h2> |
| 379 |
<div id="bubble" class="bubble" style="float:left;"></div> |
| 380 |
<div style="float:left;"> |
| 381 |
<div id="bubbleLegend"></div> |
| 382 |
</div> |
| 383 |
</div> |
| 384 |
<div style="float:left;"> |
| 385 |
<h2>Spider</h2> |
| 386 |
<div id="spider" class="spider" style="float:left;"></div> |
| 387 |
<div style="float:left;"> |
| 388 |
<div id="spiderLegend"></div> |
| 389 |
</div> |
| 390 |
</div> |
| 391 |
|
| 392 |
</div> |
| 393 |
|
| 394 |
</body> |
| 395 |
</html> |