Debian Codegraph @

dojox/charting/tests/BidiSupport/mirror_fireEvent.html

raw symbols SCIP
1 <!--[if IE 7]>
2 <!DOCTYPE>
3 <html lang="en">
4 <head>
5 <![endif]-->
6 <!--[if IE 8]>
7 <!DOCTYPE>
8 <html lang="en">
9 <head>
10 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
11 <![endif]-->
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>Chart 2D: fireEvent test</title>
19 <style type="text/css">
20 @import "../../../../dojo/resources/dojo.css";
21 @import "../../../../dijit/tests/css/dijitTests.css";
22 @import "../../../../dijit/themes/tundra/tundra.css";
23
24 .dojoxLegendNode {border: 1px solid #ccc; margin: 5px 10px 5px 10px; padding: 3px}
25 .dojoxLegendText {vertical-align: text-top; padding-right: 10px}
26
27 .events {font-size: 11pt;}
28 .events th, .events td {padding: 0.25em 1em;}
29 .events th {font-weight: bold;}
30 </style>
31 <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true, has:{'dojo-bidi': true}"></script>
32 <script type="text/javascript">
33 dojo.require("dijit.form.Button");
34 dojo.require("dijit.form.Select");
35 dojo.require("dijit.form.NumberSpinner");
36
37 dojo.require("dojox.charting.Chart");
38 dojo.require("dojox.charting.axis2d.Default");
39 dojo.require("dojox.charting.plot2d.Columns");
40 dojo.require("dojox.charting.plot2d.ClusteredColumns");
41 dojo.require("dojox.charting.plot2d.StackedColumns");
42 dojo.require("dojox.charting.plot2d.Bars");
43 dojo.require("dojox.charting.plot2d.ClusteredBars");
44 dojo.require("dojox.charting.plot2d.StackedBars");
45 dojo.require("dojox.charting.plot2d.Lines");
46 dojo.require("dojox.charting.plot2d.StackedAreas");
47 dojo.require("dojox.charting.plot2d.Pie");
48 dojo.require("dojox.charting.plot2d.Grid");
49 dojo.require("dojox.charting.themes.CubanShirts");
50 dojo.require("dojox.charting.widget.Legend");
51 dojo.require("dojox.charting.action2d.Base");
52 dojo.require("dojox.charting.action2d.Highlight");
53 dojo.require("dojox.charting.action2d.Magnify");
54 dojo.require("dojox.charting.action2d.MoveSlice");
55 dojo.require("dojox.charting.action2d.Shake");
56 dojo.require("dojox.charting.action2d.Tooltip");
57
58 dojo.require("dojox.lang.functional.sequence");
59
60 dojo.require("dojo.parser");
61
62 var chart, legend, size = 10, magnitude = 30, none = "<em>none</em>";
63
64
65 var Listener = dojo.declare(dojox.charting.action2d.Base, {
66 constructor: function(chart, plot, tr){
67 this.tr = dojo.byId(tr);
68 this.connect();
69 },
70
71 process: function(o){
72 var t = [
73 o.plot ? o.plot.name : none,
74 o.type === "onindirect" ? o.type + " (" + (o.originalPlot ? o.originalPlot.name : none) + " : " + o.originalEvent + ")" : o.type,
75 o.event ? "object" : none,
76 o.hAxis || none,
77 o.vAxis || none,
78 o.run ? o.run.name : none,
79 "index" in o ? o.index : none,
80 "x" in o ? o.x : none,
81 "y" in o ? o.y : none
82 ];
83 dojo.query("td", this.tr).forEach(function(td, i){
84 td.innerHTML = t[i] + "";
85 });
86 }
87 });
88
89 function getData(){
90 var data = new Array(size);
91 for(var i = 0; i < size; ++i){
92 data[i] = Math.random() * magnitude;
93 }
94 return data;
95 };
96
97 function getZeroes(){
98 return dojox.lang.functional.repeat(size, "-> 0", 0);
99 };
100
101 var actions = [];
102
103 function addActions(chart){
104 dojox.lang.functional.forEach(actions, ".disconnect()");
105 actions = [
106 new dojox.charting.action2d.Highlight(chart),
107 new dojox.charting.action2d.Magnify(chart),
108 new dojox.charting.action2d.MoveSlice(chart),
109 new dojox.charting.action2d.Tooltip(chart),
110 new Listener(chart, "default", "def")
111 ];
112 }
113
114 function makeObjects(){
115 chart = new dojox.charting.Chart("test");
116 chart.setTheme(dojox.charting.themes.CubanShirts);
117
118 chart.addAxis("x", {natural: true, includeZero: true, fixUpper: "minor"});
119
120 chart.addAxis("y", {vertical: true, natural: true, includeZero: true, fixUpper: "minor"});
121
122 chart.addPlot("default", {type: dijit.byId("plot").get("value"), gap: 2});
123 addActions(chart);
124
125 chart.addPlot("empty"); // just to see indirect events
126 new Listener(chart, "empty", "emp");
127
128
129 chart.addPlot("grid", {type: "Grid", hMinorLines: true, vMinorLines: true});
130
131 for(var i = 1; i <= 5; ++i){
132 chart.addSeries("Series " + i, getData(), {stroke: {color: "black", width: 1}});
133 }
134
135 chart.setDir("rtl");chart.render();
136
137 legend = new dojox.charting.widget.Legend({chart: chart}, "legend");
138 };
139
140 dojo.addOnLoad(makeObjects);
141
142 changePlot = function(){
143 var type = dijit.byId("plot").get("value"),
144 opts = {type: type, gap: 2};
145 switch(type){
146 case "Lines":
147 case "StackedAreas":
148 opts.markers = true;
149 break;
150 case "Pie":
151 opts.radius = 150;
152 break;
153 }
154 chart.addPlot("default", opts);
155 addActions(chart);
156 chart.setDir("rtl");chart.render();
157 legend.refresh();
158 };
159
160 fireEvent = function(type){
161 chart.fireEvent(
162 dijit.byId("series").get("value"),
163 type,
164 dijit.byId("index").get("value")
165 );
166 }
167
168 </script>
169 </head>
170 <body class="tundra">
171
172 <h1>Chart 2D: fireEvent test</h1>
173
174 <p>
175 <span>Plot:&nbsp;</span>
176 <select dojoType="dijit.form.Select" id="plot" onChange="changePlot()">
177 <option value="Columns">Columns</option>
178 <option value="ClusteredColumns">ClusteredColumns</option>
179 <option value="StackedColumns">StackedColumns</option>
180 <option value="Bars">Bars</option>
181 <option value="ClusteredBars">ClusteredBars</option>
182 <option value="StackedBars">StackedBars</option>
183 <option value="Lines">Lines</option>
184 <option value="StackedAreas">StackedAreas</option>
185 <option value="Pie">Pie</option>
186 </select>
187 </p>
188
189 <table class="events" border="1">
190 <thead>
191 <tr>
192 <th>Plot</th><th>Event</th><th>Event Object</th><th>H. axis</th><th>V. axis</th><th>Series</th><th>Index</th><th>X value</th><th>Y value</th>
193 </tr>
194 </thead>
195 <tbody>
196 <tr id="def">
197 <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
198 </tr>
199 <tr id="emp">
200 <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
201 </tr>
202 </tbody>
203 </table>
204
205 <p>
206 <span>Fire event:&nbsp;</span>
207 <select dojoType="dijit.form.Select" id="series">
208 <option value="Series 1">Series 1</option>
209 <option value="Series 2">Series 2</option>
210 <option value="Series 3">Series 3</option>
211 <option value="Series 4">Series 4</option>
212 <option value="Series 5">Series 5</option>
213 </select>
214 <span>&nbsp;on index:&nbsp;</span>
215 <input dojoType="dijit.form.NumberSpinner" id="index" value="0" constraints="{min: 0, max: 9, fractional: false}" style="width: 5em;">
216 &nbsp;<button dojoType="dijit.form.Button" onClick="fireEvent('onmouseover')">onmouseover</button>
217 &nbsp;<button dojoType="dijit.form.Button" onClick="fireEvent('onmouseout')">onmouseout</button>
218 &nbsp;<button dojoType="dijit.form.Button" onClick="fireEvent('onclick')">onclick</button>
219 </p>
220
221 <p><em>Warning: the pie chart shows only the last series (Series 5).</em></p>
222
223 <div id="test" style="width: 600px; height: 400px;"></div>
224 <div id="legend"></div>
225
226 </body>
227 </html>