| 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>Testing series order</title> |
| 19 |
<style type="text/css"> |
| 20 |
@import "../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../dojo/resources/dnd.css"; |
| 22 |
@import "../../../dojo/tests/dnd/dndDefault.css"; |
| 23 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 24 |
</style> |
| 25 |
<script src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
| 26 |
<script> |
| 27 |
|
| 28 |
dojo.require("dojox.charting.Chart"); |
| 29 |
dojo.require("dojox.charting.axis2d.Default"); |
| 30 |
dojo.require("dojox.charting.plot2d.Bubble"); |
| 31 |
dojo.require("dojox.charting.themes.ThreeD"); |
| 32 |
dojo.require("dojox.charting.widget.Legend"); |
| 33 |
|
| 34 |
dojo.require("dojo.dnd.Source"); |
| 35 |
|
| 36 |
makeObjects = function(){ |
| 37 |
dojo.query("button").style("disabled", true); |
| 38 |
|
| 39 |
var chart1 = new dojox.charting.Chart("chart1"). |
| 40 |
setTheme(dojox.charting.themes.ThreeD). |
| 41 |
addAxis("x", {min: 0, max: 10}). |
| 42 |
addAxis("y", {vertical: true, min: 0, max: 10}). |
| 43 |
addPlot("Plot 1", {type: "Bubble"}). |
| 44 |
addSeries("Series A", [{x: 3, y: 3, size: 4}], {plot: "Plot 1", color: "red"}). |
| 45 |
addSeries("Series B", [{x: 5, y: 5, size: 4}], {plot: "Plot 1", color: "green"}). |
| 46 |
addSeries("Series C", [{x: 7, y: 7, size: 4}], {plot: "Plot 1", color: "blue"}). |
| 47 |
render(); |
| 48 |
|
| 49 |
var series = new dojo.dnd.Source("dnd1"), noUpdate = false; |
| 50 |
series.insertNodes(false, chart1.getSeriesOrder("Plot 1")); |
| 51 |
dojo.connect(series, "onDropInternal", function(){ |
| 52 |
var newOrder = this.getAllNodes().map(function(node){ |
| 53 |
return node.innerHTML; |
| 54 |
}) |
| 55 |
chart1.setSeriesOrder(newOrder); |
| 56 |
noUpdate = true; |
| 57 |
chart1.render(); |
| 58 |
noUpdate = false; |
| 59 |
}); |
| 60 |
dojo.connect(chart1, "render", function(){ |
| 61 |
if(!noUpdate){ |
| 62 |
series.getAllNodes().orphan(); |
| 63 |
series.sync(); |
| 64 |
series.insertNodes(false, chart1.getSeriesOrder("Plot 1")); |
| 65 |
} |
| 66 |
}); |
| 67 |
|
| 68 |
dojo.forEach(["s1", "s2", "s3"], function(id, i){ |
| 69 |
dojo.query("button", id).forEach(function(btn){ |
| 70 |
if(btn.innerHTML == "Front"){ |
| 71 |
dojo.connect(btn, "onclick", function(){ |
| 72 |
chart1.moveSeriesToFront("Series " + "ABCDEFG".charAt(i)); |
| 73 |
chart1.render(); |
| 74 |
}); |
| 75 |
}else{ |
| 76 |
dojo.connect(btn, "onclick", function(){ |
| 77 |
chart1.moveSeriesToBack("Series " + "ABCDEFG".charAt(i)); |
| 78 |
chart1.render(); |
| 79 |
}); |
| 80 |
} |
| 81 |
}); |
| 82 |
}); |
| 83 |
}; |
| 84 |
|
| 85 |
dojo.ready(makeObjects); |
| 86 |
|
| 87 |
</script> |
| 88 |
</head> |
| 89 |
<body> |
| 90 |
<h1>Testing series order</h1> |
| 91 |
|
| 92 |
<p>Chart:</p> |
| 93 |
<div id="chart1" style="width: 200px; height: 200px;"></div> |
| 94 |
<div id="legend1"></div> |
| 95 |
<p id="s1">Series A: <button>Front</button> <button>Back</button></p> |
| 96 |
<p id="s2">Series B: <button>Front</button> <button>Back</button></p> |
| 97 |
<p id="s3">Series C: <button>Front</button> <button>Back</button></p> |
| 98 |
<p>Series (rearrange using drag-and-drop):</p> |
| 99 |
<div id="dnd1" class="container"></div> |
| 100 |
<p>That's all Folks!</p> |
| 101 |
</body> |
| 102 |
</html> |