Debian Codegraph @

dojox/charting/tests/BidiSupport/mirror_DataSeries.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>DataSeries Test</title>
19
20 <style>
21 @import "../../../../dojo/resources/dojo.css";
22 @import "../../../../dijit/tests/css/dijitTests.css";
23 @import "../../../../dijit/themes/dijit.css";
24 @import "../../../../dijit/themes/tundra/tundra.css";
25
26 #spinners{
27 clear:both;
28 }
29 #spinners label{
30 width:60px;
31 line-height:30px;
32 margin-top:10px;
33 }
34 .tundra #spinners .dijitSpinner {
35 width:70px !important;
36 margin:5px !important;
37 }
38 .tundra #spinners .dijitSpinner{
39 width:80px !important;
40 }
41 .dijitSpinner{
42 padding:0px !important;
43 }
44 #spinners .dijitSpinnerButtonContainer{
45 line-height:23px;
46 }
47 .dj_ie #spinners .dijitSpinnerButtonContainer{
48 height:25px;
49 }
50 .dijitInputLayoutContainer .dijitInputField input{
51 padding:5px 0px 0px 5px;
52 }
53 .dj_webkit .dijitInputLayoutContainer .dijitInputField input{
54 padding:10px 0px 0px 5px;
55 }
56
57 .dojoxLegendNode {border: 1px solid #ccc; margin: 5px 10px 5px 10px; padding: 3px;}
58 .dojoxLegendText {vertical-align: text-top; padding-right: 10px}
59
60 #charts {
61 clear: both;
62 margin-bottom: 50px;
63 }
64 .chart-area {
65 float: left;
66 border: 1px solid #ccc;
67 width: 450px;
68 height: 350px;
69 margin: 3px;
70 }
71 .chart {
72 width: 450px;
73 height: 300px;
74 }
75 </style>
76
77 <script src="../../../../dojo/dojo.js" data-dojo-config="isDebug: false, parseOnLoad: true, has:{'dojo-bidi': true}"></script>
78
79 <script>
80 dojo.require("dojo.parser");
81 dojo.require("doh.runner");
82
83 dojo.require("dojox.charting.Chart2D");
84 dojo.require("dojox.charting.DataSeries");
85 dojo.require("dojox.charting.themes.ThreeD");
86 dojo.require("dojox.charting.widget.Legend");
87
88 dojo.require("dojox.charting.plot2d.Markers");
89 dojo.require("dojox.charting.plot2d.Columns");
90 dojo.require("dojox.charting.plot2d.Pie");
91
92 dojo.require("dojox.charting.action2d.Tooltip");
93 dojo.require("dojox.charting.action2d.MoveSlice");
94 dojo.require("dojox.charting.action2d.Magnify");
95 dojo.require("dojox.charting.action2d.Shake");
96
97 dojo.require("dojo.data.ItemFileWriteStore");
98
99 dojo.require("dijit.form.NumberSpinner");
100
101 var store = new dojo.data.ItemFileWriteStore({url: "stockHebrew.json"});
102
103 function addLegend(chart, node){
104 var legend = new dojox.charting.widget.Legend({chart: chart}, node);
105 dojo.connect(chart, "render", legend, "refresh");
106 }
107
108 var templates = {
109 low: "<strong>{0}</strong>: <strong>low {1}</strong> &ndash; {2} &ndash; {3}",
110 price: "<span dir='ltr'><strong>{0}</strong>: {1} &ndash; <strong>price {2}</strong> &ndash; {3}</span>",
111 high: "<strong>{0}</strong>: {1} &ndash; {2} &ndash; <strong>high {3}</strong>"
112 };
113
114 function valTrans(value, store, item){
115 return {
116 y: store.getValue(item, value),
117 tooltip: dojo.replace(
118 templates[value],
119 dojo.map(["symbol", "low", "price", "high"], function(field){
120 return store.getValue(item, field);
121 })
122 )
123 };
124 }
125
126 var chartL, chartC, chartP;
127
128 makeCharts = function(){
129 chartL = new dojox.charting.Chart2D("lines",{textDir:"auto", dir:"rtl"}).
130 setTheme(dojox.charting.themes.ThreeD).
131 addAxis("x", {fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 5}).
132 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true}).
133 addPlot("default", {type: dojox.charting.plot2d.Markers}).
134 addSeries("Price.", new dojox.charting.DataSeries(
135 store, {query: {symbol: "*"}}, "price")).
136 setDir("rtl").
137 render();
138 addLegend(chartL, "lines_legend");
139 new dojox.charting.action2d.Magnify(chartL);
140 new dojox.charting.action2d.Tooltip(chartL);
141
142 chartC = new dojox.charting.Chart2D("cols",{textDir:"rtl"}).
143 setTheme(dojox.charting.themes.ThreeD).
144 addAxis("x", {natural: true}).
145 addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true}).
146 addPlot("default", {type: dojox.charting.plot2d.Columns}).
147 addSeries("Low.", new dojox.charting.DataSeries(
148 store, {query: {symbol: "*"}}, dojo.hitch(null, valTrans, "low"))).
149 addSeries("\u05de\u05d7\u05d9\u05e8.", new dojox.charting.DataSeries(
150 store, {query: {symbol: "*"}}, dojo.hitch(null, valTrans, "price"))).
151 addSeries("High.", new dojox.charting.DataSeries(
152 store, {query: {symbol: "*"}}, dojo.hitch(null, valTrans, "high"))).
153 setDir("rtl").
154 render();
155 addLegend(chartC, "cols_legend");
156 new dojox.charting.action2d.Shake(chartC, "default", {shiftY: 0});
157 new dojox.charting.action2d.Tooltip(chartC);
158
159 chartP = new dojox.charting.Chart2D("pie",{textDir:"auto",htmlLabels:true}).
160 setTheme(dojox.charting.themes.ThreeD).
161 addPlot("default", {type: dojox.charting.plot2d.Pie, radius: 125}).
162 addSeries("Price", new dojox.charting.DataSeries(
163 store, {query: {symbol: "*"}}, {y: "price", text: "symbol", tooltip: "price"})).
164 setDir("rtl").
165 render();
166 addLegend(chartP, "pie_legend");
167 new dojox.charting.action2d.Tooltip(chartP);
168 new dojox.charting.action2d.MoveSlice(chartP);
169 };
170
171 makeSpinners = function(items){
172 dojo.forEach(items, function(m){
173 var nm = store.getLabel(m);
174 var num = store.getValue(m, "price");
175 console.log(nm, num);
176 var w = new dijit.form.NumberSpinner({
177 onChange: function(val){
178 val = val===0 ? 0.01 : val; //HACKS the no label-when-zero bug
179 console.log("OC:", nm, val);
180 store.setValue(m, "price", val);
181 //store.setValues(m, "historicPrice", store.getValues("historicPrice").push(val));
182 console.log("OC:", nm, val);
183 },
184 value: num,
185 constraints: {min:0, max:10,places:2},
186 className: "myField",
187 intermediateChanges: true
188 });
189 dojo.place('<label>'+nm+'</label>', dojo.byId("spinners"), "last")
190 dojo.place(w.domNode, "spinners", "last")
191 });
192
193 var labels = dojo.map(items, function(item, index){
194 return {
195 value: index + 1,
196 text: store.getLabel(item)
197 }
198 });
199 chartC.addAxis("x", {natural: true, labels: labels}).render();
200 }
201
202 dojo.addOnLoad(function(){
203 makeCharts();
204 store.fetch({query:{symbol:"*"}, onComplete: makeSpinners, onError:function(err){console.error(err)}})
205
206 doh.register("parse", function(){
207 dojo.parser.parse();
208 });
209
210 doh.run();
211 });
212 </script>
213
214 </head>
215
216 <body class="tundra" dir ="ltr">
217 <h1>DataSeries Test</h1>
218 <p>
219 Use the spinner fields at the bottom to change the data. The charts listen to store changes an update automatically.
220 </p>
221 <div id="charts">
222 <div class="chart-area">
223 <div id="lines_legend"></div>
224 <div id="lines" class="chart"></div>
225 </div>
226 <div class="chart-area" data-dojo-textdir="rtl">
227 <div id="cols_legend"></div>
228 <div id="cols" class="chart"></div>
229 </div>
230 <div class="chart-area">
231 <div id="pie_legend"></div>
232 <div id="pie" class="chart"></div>
233 </div>
234 </div>
235 <div id="spinners"></div>
236 </body>
237 </html>