| 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 plot 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, has:{'dojo-bidi': 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("Plot 1 / Series A", [{x: 3, y: 3, size: 4}], {plot: "Plot 1"}). |
| 45 |
addPlot("Plot 2", {type: "Bubble"}). |
| 46 |
addSeries("Plot 2 / Series B", [{x: 5, y: 5, size: 4}], {plot: "Plot 2"}). |
| 47 |
//addSeries("Plot 2 / Series B1", [{x: 5, y: 6, size: 3}], {plot: "Plot 2"}). |
| 48 |
//addSeries("Plot 2 / Series B2", [{x: 4, y: 4, size: 3}], {plot: "Plot 2"}). |
| 49 |
//addSeries("Plot 2 / Series B3", [{x: 6, y: 4, size: 3}], {plot: "Plot 2"}). |
| 50 |
addPlot("Plot 3", {type: "Bubble"}). |
| 51 |
addSeries("Plot 3 / Series C", [{x: 7, y: 7, size: 4}], {plot: "Plot 3"}). |
| 52 |
setDir("rtl"). |
| 53 |
render(); |
| 54 |
|
| 55 |
var legend1 = new dojox.charting.widget.Legend({chart: chart1, horizontal: false}, "legend1"); |
| 56 |
dojo.connect(chart1, "render", legend1, "refresh"); |
| 57 |
|
| 58 |
var plots = new dojo.dnd.Source("dnd1"), noUpdate = false; |
| 59 |
plots.insertNodes(false, chart1.getPlotOrder()); |
| 60 |
dojo.connect(plots, "onDropInternal", function(){ |
| 61 |
var newOrder = this.getAllNodes().map(function(node){ |
| 62 |
return node.innerHTML; |
| 63 |
}) |
| 64 |
chart1.setPlotOrder(newOrder); |
| 65 |
noUpdate = true; |
| 66 |
chart1.render(); |
| 67 |
noUpdate = false; |
| 68 |
}); |
| 69 |
dojo.connect(chart1, "render", function(){ |
| 70 |
if(!noUpdate){ |
| 71 |
plots.getAllNodes().orphan(); |
| 72 |
plots.sync(); |
| 73 |
plots.insertNodes(false, chart1.getPlotOrder()); |
| 74 |
} |
| 75 |
}); |
| 76 |
|
| 77 |
dojo.forEach(["p1", "p2", "p3"], function(id, i){ |
| 78 |
dojo.query("button", id).forEach(function(btn){ |
| 79 |
if(btn.innerHTML == "Front"){ |
| 80 |
dojo.connect(btn, "onclick", function(){ |
| 81 |
chart1.movePlotToFront("Plot " + (i + 1)); |
| 82 |
chart1.setDir("rtl"); |
| 83 |
chart1.render(); |
| 84 |
}); |
| 85 |
}else{ |
| 86 |
dojo.connect(btn, "onclick", function(){ |
| 87 |
chart1.movePlotToBack("Plot " + (i + 1)); |
| 88 |
chart1.setDir("rtl"); |
| 89 |
chart1.render(); |
| 90 |
}); |
| 91 |
} |
| 92 |
}); |
| 93 |
}); |
| 94 |
}; |
| 95 |
|
| 96 |
dojo.ready(makeObjects); |
| 97 |
|
| 98 |
</script> |
| 99 |
</head> |
| 100 |
<body> |
| 101 |
<h1>Testing plot order</h1> |
| 102 |
|
| 103 |
<p>Chart:</p> |
| 104 |
<div id="chart1" style="width: 200px; height: 200px;"></div> |
| 105 |
<div id="legend1"></div> |
| 106 |
<p id="p1">Plot 1: <button>Front</button> <button>Back</button></p> |
| 107 |
<p id="p2">Plot 2: <button>Front</button> <button>Back</button></p> |
| 108 |
<p id="p3">Plot 3: <button>Front</button> <button>Back</button></p> |
| 109 |
<p>Plots (rearrange using drag-and-drop):</p> |
| 110 |
<div id="dnd1" class="container"></div> |
| 111 |
<p>That's all Folks!</p> |
| 112 |
</body> |
| 113 |
</html> |