| 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>Axis Zoom Control</title> |
| 18 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 19 |
<style type="text/css"> |
| 20 |
@import "../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../dijit/themes/tundra/tundra.css"; |
| 22 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 23 |
@import "../../form/resources/RangeSlider.css"; |
| 24 |
#hrXAxisSlider .dijitSliderProgressBar{ |
| 25 |
height: 12px; |
| 26 |
overflow: visible; |
| 27 |
margin-top: -5px; |
| 28 |
} |
| 29 |
</style> |
| 30 |
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
| 31 |
<script type="text/javascript"> |
| 32 |
var chart1, zoomAxis; |
| 33 |
|
| 34 |
require(["dojo/dom", "dojo/ready", "dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/Lines", |
| 35 |
"dojox/charting/plot2d/StackedAreas", "dojox/charting/plot2d/Grid", |
| 36 |
"dojox/charting/themes/PlotKit/orange", "dojox/charting/action2d/Tooltip", |
| 37 |
"dojox/charting/action2d/Magnify", "dojo/parser", "dojox/form/RangeSlider"], function(dom, ready, Chart, Default, Lines, StackedAreas, |
| 38 |
Grid, orange, Tooltip, Magnify){ |
| 39 |
zoomXAxis = function(){ |
| 40 |
chart1.zoomIn("x", arguments[0]); |
| 41 |
chart2.zoomIn("x", arguments[0]); |
| 42 |
dom.byId('minValue').value = arguments[0][0]; |
| 43 |
dom.byId('maxValue').value = arguments[0][1]; |
| 44 |
} |
| 45 |
ready(function(){ |
| 46 |
chart1 = new Chart("chart1"); |
| 47 |
chart1.setTheme(orange); |
| 48 |
chart1.addAxis("x", {fixLower: "minor", natural: true, stroke: "grey", |
| 49 |
majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); |
| 50 |
chart1.addAxis("y", {vertical: true, min: 0, max: 100, majorTickStep: 5, minorTickStep: 1, stroke: "grey", |
| 51 |
majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); |
| 52 |
chart1.addPlot("default", {type: Lines, markers: true}); |
| 53 |
chart1.addSeries("Series A", [ |
| 54 |
8, 7, 3, 2, 5, 7, 9, 10, 2, 10, |
| 55 |
14, 16, 18, 13, 16, 15, 20, 19, 15, 12, |
| 56 |
24, 20, 20, 26, 28, 26, 28, 29, 24, 29, |
| 57 |
31, 35, 37, 31, 35, 37, 37, 36, 31, 30, |
| 58 |
50, 49, 42, 46, 44, 40, 47, 43, 48, 47, |
| 59 |
51, 52, 52, 51, 54, 57, 58, 50, 54, 51, |
| 60 |
62, 68, 67, 62, 62, 65, 61, 66, 65, 62, |
| 61 |
74, 78, 78, 77, 74, 74, 72, 74, 70, 78, |
| 62 |
84, 83, 85, 86, 86, 89, 89, 85, 86, 86, |
| 63 |
98, 97, 93, 91, 92, 92, 99, 93, 94, 92 |
| 64 |
]); |
| 65 |
chart1.addPlot("grid", {type: Grid, hMinorLines:true}); |
| 66 |
new Tooltip(chart1, "default"); |
| 67 |
new Magnify(chart1,"default"); |
| 68 |
chart1.render(); |
| 69 |
chart2 = new Chart("chart2"); |
| 70 |
chart2.setTheme(orange); |
| 71 |
chart2.addAxis("x", {fixLower: "minor", natural: true, stroke: "grey", |
| 72 |
majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); |
| 73 |
chart2.addAxis("y", {vertical: true, min: 0, max: 200, majorTickStep: 5, minorTickStep: 1, stroke: "grey", |
| 74 |
majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); |
| 75 |
chart2.addPlot("default", {type: StackedAreas }); |
| 76 |
chart2.addSeries("Series A", [ |
| 77 |
8, 7, 3, 2, 5, 7, 9, 10, 2, 10, |
| 78 |
14, 16, 18, 13, 16, 15, 20, 19, 15, 12, |
| 79 |
24, 20, 20, 26, 28, 26, 28, 29, 24, 29, |
| 80 |
31, 35, 37, 31, 35, 37, 37, 36, 31, 30, |
| 81 |
50, 49, 42, 46, 44, 40, 47, 43, 48, 47, |
| 82 |
51, 52, 52, 51, 54, 57, 58, 50, 54, 51, |
| 83 |
62, 68, 67, 62, 62, 65, 61, 66, 65, 62, |
| 84 |
74, 78, 78, 77, 74, 74, 72, 74, 70, 78, |
| 85 |
84, 83, 85, 86, 86, 89, 89, 85, 86, 86, |
| 86 |
98, 97, 93, 91, 92, 92, 99, 93, 94, 92 |
| 87 |
]); |
| 88 |
chart2.addSeries("Series B", [ |
| 89 |
8, 7, 3, 2, 5, 7, 9, 10, 2, 10, |
| 90 |
14, 16, 18, 13, 16, 15, 20, 19, 15, 12, |
| 91 |
24, 20, 20, 26, 28, 26, 28, 29, 24, 29, |
| 92 |
31, 35, 37, 31, 35, 37, 37, 36, 31, 30, |
| 93 |
50, 49, 42, 46, 44, 40, 47, 43, 48, 47, |
| 94 |
51, 52, 52, 51, 54, 57, 58, 50, 54, 51, |
| 95 |
62, 68, 67, 62, 62, 65, 61, 66, 65, 62, |
| 96 |
74, 78, 78, 77, 74, 74, 72, 74, 70, 78, |
| 97 |
84, 83, 85, 86, 86, 89, 89, 85, 86, 86, |
| 98 |
98, 97, 93, 91, 92, 92, 99, 93, 94, 92 |
| 99 |
]); |
| 100 |
chart2.render(); |
| 101 |
}); |
| 102 |
}); |
| 103 |
</script> |
| 104 |
</head> |
| 105 |
<body class="tundra"> |
| 106 |
<h1>Axis Zoom Control</h1> |
| 107 |
Try to drag the slider endpoints and the bar to zoom X axis of the chart. |
| 108 |
<div style="margin:20px"> |
| 109 |
<div id="chart1" style="width: 800px; height: 400px;"></div> |
| 110 |
<div id="chart2" style="width: 800px; height: 400px;"></div> |
| 111 |
<div id="hrXAxisSlider" |
| 112 |
discreteValues="21" |
| 113 |
onChange="zoomXAxis" |
| 114 |
intermediateChanges="false" |
| 115 |
data-dojo-type="dojox.form.HorizontalRangeSlider" |
| 116 |
showButtons="false" |
| 117 |
style="width:748px;margin-left:40px" |
| 118 |
value="0,100"> |
| 119 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" container="topDecoration" style="height:1.2em;font-size:75%;color:gray;" count="11"> |
| 120 |
<li>0</li><li>10</li><li>20</li><li>30</li><li>40</li><li>50</li><li>60</li><li>70</li><li>80</li><li>90</li><li>100</li> |
| 121 |
</ol> |
| 122 |
<div data-dojo-type="dijit/form/HorizontalRule" container="topDecoration" count=11 style="height:10px;"></div> |
| 123 |
</div> |
| 124 |
</div> |
| 125 |
<p>X Axis Lower Value: <input readonly id="minValue" size="10" value="0"/></p> |
| 126 |
<p>X Axis Upper Value: <input readonly id="maxValue" size="10" value="100"/></p> |
| 127 |
<p>That's all Folks!</p> |
| 128 |
</body> |
| 129 |
</html> |