| 1 | <!DOCTYPE HTML> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <title>Axis Zoom Control</title> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 | <meta http-equiv="X-UA-Compatible" content="IE=Edge"> |
| 7 | <style type="text/css"> |
| 8 | @import "../../../../dojo/resources/dojo.css"; |
| 9 | @import "../../../../dijit/themes/claro/claro.css"; |
| 10 | @import "../../../../dijit/tests/css/dijitTests.css"; |
| 11 | @import "../../../form/resources/RangeSlider.css"; |
| 12 | #hrXAxisSlider .dijitSliderProgressBar{ |
| 13 | height: 12px; |
| 14 | overflow: visible; |
| 15 | margin-top: -5px; |
| 16 | } |
| 17 | </style> |
| 18 | <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: false, async: true"></script> |
| 19 | <script type="text/javascript"> |
| 20 | var zoomXAxis; |
| 21 | require([ |
| 22 | "dojo/parser", |
| 23 | "dojo/dom", |
| 24 | "dojox/charting/Chart", |
| 25 | "dojox/charting/action2d/Tooltip", |
| 26 | "dojox/charting/action2d/Magnify", |
| 27 | "dojox/charting/themes/PlotKit/orange", |
| 28 | // Used indirectly/by the parser. |
| 29 | "dojox/charting/axis2d/Default", |
| 30 | "dojox/charting/axis2d/Log", |
| 31 | "dojox/charting/plot2d/Lines", |
| 32 | "dojox/charting/plot2d/Grid", |
| 33 | "dojox/form/RangeSlider", |
| 34 | "dijit/form/HorizontalRuleLabels", |
| 35 | "dijit/form/HorizontalRule", |
| 36 | "dojo/domReady!" |
| 37 | ], function(parser, dom, Chart, Tooltip, Magnify, orangePlotKit){ |
| 38 | zoomXAxis = function(){ |
| 39 | var a = Math.pow(10, arguments[0][0] / 25 - 1), |
| 40 | b = Math.pow(10, arguments[0][1] / 25 - 1); |
| 41 | chart.zoomIn("x", [a, b]); |
| 42 | dom.byId('minValue').value = a; |
| 43 | dom.byId('maxValue').value = b; |
| 44 | } |
| 45 | |
| 46 | parser.parse(); |
| 47 | |
| 48 | chart = new Chart("chart"); |
| 49 | chart.setTheme(orangePlotKit); |
| 50 | chart.addAxis("x", {type: "Log", |
| 51 | fixLower: "minor", natural: true, stroke: "grey", |
| 52 | majorTick: {stroke: "black", length: 4}, |
| 53 | minorTick: {stroke: "gray", length: 2}}); |
| 54 | chart.addAxis("y", {vertical: true, type: "Log", |
| 55 | min: 1, max: 1000, stroke: "grey", |
| 56 | majorTick: {stroke: "black", length: 4}, |
| 57 | minorTick: {stroke: "gray", length: 2}}); |
| 58 | chart.addPlot("default", {type: "Lines", markers: true}); |
| 59 | chart.addSeries("Series A", [ |
| 60 | 8, 7, 3, 2, 5, 7, 9, 10, 2, 10, |
| 61 | 14, 16, 18, 13, 16, 15, 20, 19, 15, 12, |
| 62 | 24, 20, 20, 26, 28, 26, 28, 29, 24, 29, |
| 63 | 31, 35, 37, 31, 35, 37, 37, 36, 31, 30, |
| 64 | 50, 49, 42, 46, 44, 40, 47, 43, 48, 47, |
| 65 | 51, 52, 52, 51, 54, 57, 58, 50, 54, 51, |
| 66 | 62, 68, 67, 62, 62, 65, 61, 66, 65, 62, |
| 67 | 74, 78, 78, 77, 74, 74, 72, 74, 70, 78, |
| 68 | 84, 83, 85, 86, 86, 89, 89, 85, 86, 86, |
| 69 | 98, 97, 93, 91, 92, 92, 99, 93, 94, 92 |
| 70 | ]); |
| 71 | chart.addPlot("grid", {type:"Grid", hMinorLines:true}); |
| 72 | new Tooltip(chart, "default"); |
| 73 | new Magnify(chart, "default"); |
| 74 | chart.render(); |
| 75 | }); |
| 76 | </script> |
| 77 | </head> |
| 78 | <body class="claro"> |
| 79 | <h1>Axis Zoom Control</h1> |
| 80 | Try to drag the slider endpoints and the bar to zoom X axis of the chart. |
| 81 | <div style="margin: 20px"> |
| 82 | <div id="chart" style="width: 800px; height: 400px;"></div> |
| 83 | <div id="hrXAxisSlider" |
| 84 | data-dojo-props="discreteValues: 5, onChange: zoomXAxis, intermediateChanges: false, showButtons: false, value: [0,100]" |
| 85 | data-dojo-type="dojox/form/HorizontalRangeSlider" |
| 86 | style="width: 748px; margin-left: 40px"> |
| 87 | <ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props="container: 'topDecoration', count: 5" style="height: 1.2em; font-size: 75%; color: gray;"> |
| 88 | <li>0.1</li><li>1</li><li>10</li><li>100</li><li>1000</li> |
| 89 | </ol> |
| 90 | <div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props="container: 'topDecoration', count: 5" count="5" style="height: 10px;"></div> |
| 91 | </div> |
| 92 | </div> |
| 93 | <p>X Axis Lower Value: <input readonly id="minValue" size="10" value="0.1"/></p> |
| 94 | <p>X Axis Upper Value: <input readonly id="maxValue" size="10" value="1000"/></p> |
| 95 | <p>That's all Folks!</p> |
| 96 | </body> |
| 97 | </html> |