Changeset 13730
- Timestamp:
- 05/13/08 16:09:17 (6 months ago)
- Files:
-
- 1 modified
-
dojox/trunk/charting/tests/test_win2d.html (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojox/trunk/charting/tests/test_win2d.html
r13717 r13730 1 1 <html> 2 2 <head> 3 <title>Sc rolling and scaling</title>3 <title>Scaling, scrolling, and panning.</title> 4 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 5 <style type="text/css"> … … 32 32 33 33 var df = dojox.lang.functional; 34 var chart, scaleX = 1, scaleY = 1, offsetX = 0, offsetY = 0;34 var chart, moveable, scaleX = 1, scaleY = 1, offsetX = 0, offsetY = 0; 35 35 36 var update = function(){ 37 chart.setWindow(scaleX, scaleY, offsetX, offsetY).render(); 38 36 var reflect = function(){ 39 37 df.forIn(chart.axes, function(axis){ 40 38 var scale = axis.getWindowScale(), 41 39 offset = Math.round(axis.getWindowOffset() * axis.getScaler().bounds.scale); 42 40 if(axis.vertical){ 43 setTimeout(function(){ 44 dijit.byId("scaleYSlider").setValue(scale); 45 dijit.byId("offsetYSlider").setValue(offset); 46 }, 25); 41 scaleY = scale; 42 offsetY = offset; 47 43 }else{ 48 setTimeout(function(){ 49 dijit.byId("scaleXSlider").setValue(scale); 50 dijit.byId("offsetXSlider").setValue(offset); 51 }, 25); 44 scaleX = scale; 45 offsetX = offset; 52 46 } 53 47 }); 48 setTimeout(function(){ 49 dijit.byId("scaleXSlider").setValue(scaleX); 50 dijit.byId("offsetXSlider").setValue(offsetX); 51 dijit.byId("scaleYSlider").setValue(scaleY); 52 dijit.byId("offsetYSlider").setValue(offsetY); 53 }, 25); 54 }; 55 56 var update = function(){ 57 chart.setWindow(scaleX, scaleY, offsetX, offsetY).render(); 58 reflect(); 54 59 }; 55 60 … … 78 83 }; 79 84 85 var _init = null; 86 var onMouseDown = function(e){ 87 _init = {x: e.clientX, y: e.clientY, ox: offsetX, oy: offsetY}; 88 dojo.stopEvent(e); 89 }; 90 91 var onMouseUp = function(e){ 92 if(_init){ 93 _init = null; 94 reflect(); 95 dojo.stopEvent(e); 96 } 97 }; 98 99 var onMouseMove = function(e){ 100 if(_init){ 101 var dx = e.clientX - _init.x, 102 dy = e.clientY - _init.y; 103 offsetX = _init.ox - dx; 104 offsetY = _init.oy + dy; 105 chart.setWindow(scaleX, scaleY, offsetX, offsetY).render(); 106 dojo.stopEvent(e); 107 } 108 }; 109 80 110 makeObjects = function(){ 81 111 chart = new dojox.charting.Chart2D("test"); 82 112 chart.setTheme(dojox.charting.themes.PlotKit.orange); 83 chart.addAxis("x", {fixLower: "minor", natural: true}); 84 chart.addAxis("y", {vertical: true, min: 0, max: 30, majorTickStep: 5, minorTickStep: 1}); 113 chart.addAxis("x", {fixLower: "minor", natural: true, stroke: "grey", 114 majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); 115 chart.addAxis("y", {vertical: true, min: 0, max: 30, majorTickStep: 5, minorTickStep: 1, stroke: "grey", 116 majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); 85 117 chart.addPlot("default", {type: "Areas"}); 86 118 chart.addSeries("Series A", [0, 25, 5, 20, 10, 15, 5, 20, 0, 25]); 87 chart.addSeries("Series B", [25, 0]); 119 chart.addAxis("x2", {fixLower: "minor", natural: true, leftBottom: false, stroke: "grey", 120 majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); 121 chart.addAxis("y2", {vertical: true, min: 0, max: 20, leftBottom: false, stroke: "grey", 122 majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}}); 123 chart.addPlot("plot2", {type: "Areas", hAxis: "x2", vAxis: "y2"}); 124 chart.addSeries("Series B", [15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15], {plot: "plot2"}); 88 125 chart.addPlot("grid", {type: "Grid", hMinorLines: true}); 89 126 chart.render(); … … 93 130 dojo.connect(dijit.byId("offsetXSlider"), "onChange", offsetXEvent); 94 131 dojo.connect(dijit.byId("offsetYSlider"), "onChange", offsetYEvent); 132 133 dojo.connect(dojo.byId("test"), "onmousedown", onMouseDown); 134 dojo.connect(dojo.byId("test"), "onmousemove", onMouseMove); 135 dojo.connect(dojo.byId("test"), "onmouseup", onMouseUp); 95 136 }; 96 137 … … 100 141 </head> 101 142 <body class="tundra"> 102 <h1>Sc rolling and scaling</h1>143 <h1>Scaling, scrolling, and panning.</h1> 103 144 <!--<p><button onclick="makeObjects();">Go</button></p>--> 104 145 <!-- intermediateChanges="true" -->