Debian Codegraph @

dojox/geo/charting/tests/test_mapWithLegend.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>Chart: Map&Legend</title>
6 <style type="text/css">
7 @import "../../../../dojo/resources/dojo.css";
8 @import "../../../../dijit/tests/css/dijitTests.css";
9 @import "../../../../dijit/themes/tundra/tundra.css";
10 @import "../resources/Map.css";
11 </style>
12 <script type="text/javascript" data-dojo-config="parseOnLoad:true,gfxRenderer:'svg,canvas,vml,silverlight'" src="../../../../dojo/dojo.js"></script>
13 <script type="text/javascript">
14 var isTouchDevice = dojo.isIos || (navigator.userAgent.toLowerCase().indexOf("android") > -1)
15 || (navigator.userAgent.toLowerCase().indexOf("blackberry") > -1);
16 </script>
17 <script type="text/javascript">
18 dojo.require("dojox.geo.charting.Map");
19 dojo.require("dojox.geo.charting.widget.Legend");
20 dojo.require("dojo.data.ItemFileWriteStore");
21 dojo.require("dijit.form.RadioButton");
22 dojo.require("dijit.layout.BorderContainer");
23 dojo.require("dijit.layout.ContentPane");
24 dojo.requireIf(isTouchDevice,"dojox.geo.charting.TouchInteractionSupport");
25 dojo.requireIf(!isTouchDevice,"dojox.geo.charting.MouseInteractionSupport");
26 dojo.require("dojox.geo.charting.KeyboardInteractionSupport");
27
28 dojo.addOnLoad(function(){
29 //create new map
30 var map = new dojox.geo.charting.Map("USStates", "../resources/data/USStates.json");
31 //add outside map marker file
32 map.setMarkerData("../resources/markers/USStates.json");
33
34 // install mouse/touch navigation
35 if (!isTouchDevice) {
36 var mouseInteraction = new dojox.geo.charting.MouseInteractionSupport(map,{enablePan:true,enableZoom:true});
37 mouseInteraction.connect();
38 } else {
39 var touchInteraction = new dojox.geo.charting.TouchInteractionSupport(map,{});
40 touchInteraction.connect();
41 }
42 // install keyboard navigation
43 var keyboardInteraction = new dojox.geo.charting.KeyboardInteractionSupport(map, {enableZoom: true});
44 keyboardInteraction.connect();
45
46 //set data store to map
47 var dataStore = new dojo.data.ItemFileWriteStore({
48 url: "datastore/dataStore.json"
49 });
50
51 map.setDataStore(dataStore, "product A");
52
53 //add series to map
54 map.addSeries([{
55 name: "Low sales state(0~$3.0M)",
56 min: "0.0",
57 max: "3.0",
58 color: "#FFCE52"
59 }, {
60 name: "Normal sales state($3.0M~$6.0M)",
61 min: "3.0",
62 max: "6.0",
63 color: "#63A584"
64 }, {
65 name: "High sales state($6.0M~$10.0M)",
66 min: "6.0",
67 max: "9.0",
68 color: "#CE6342"
69 }]);
70 //declare associated legend
71 var legend = new dojox.geo.charting.widget.Legend({
72 map: map
73 });
74 //map marker customization
75 map.onFeatureOver = function(feature){
76 feature.markerText = map.mapObj.marker.markerData[feature.id] + ": $" + feature.value.toFixed(3) + "M";
77 };
78
79 dojo.connect(window,"onresize",this,function() {map.resize();});
80
81
82 changeProduct = function(radioButton) {
83 //console.log("change product called " + productName);
84 if (radioButton.checked) {
85 map.setDataBindingAttribute(radioButton.value);
86 }
87 };
88
89 function changeStoreValues() {
90 for (prop in map.mapObj.features) {
91 dataStore.fetchItemByIdentity({
92 identity: prop,
93 onItem: function(item) {
94 dataStore.setValue(item,"product A",Math.random() * 10);
95 //dataStore.setValue(item,"product B",Math.random() * 10);
96 //dataStore.setValue(item,"product C",Math.random() * 10);
97
98 },
99 onError: function(err) { console.info(err.message);}
100 });
101 }
102 }
103
104 // simulate product value changes
105 //setInterval(changeStoreValues,1000);
106
107 });
108
109
110 </script>
111 </head>
112 <body class="tundra" >
113 <h1>Map with series, data, legend</h1>
114 <p>Keyboard Tips: Use <b>TAB</b> to focus the map, then use <b>up/down/left/right</b> to go around the map, zoom in by <b>SPACE</b> and zoom out by <b>ESC</b>.</p>
115 <div id="USStates" style="width:900px;height:500px;border:1px solid;">
116 </div>
117 <table id="productChoice" cellspacing="10" style="border: 1px">
118 <tr>
119 <td><label>Show product :</label></td>
120 <td><input type="radio" dojoType="dijit.form.RadioButton" name="product" id="radioA" checked
121 onchange="changeProduct(this)"
122 value="product A" />
123 <label for="radioA">A</label>
124 </td>
125 <td><input type="radio" dojoType="dijit.form.RadioButton" name="product" id="radioB"
126 onchange="changeProduct(this)"
127 value="product B" />
128 <label for="radioB">B</label>
129 </td>
130 <td><input type="radio" dojoType="dijit.form.RadioButton" name="product" id="radioC"
131 onchange="changeProduct(this)"
132 value="product C" />
133 <label for="radioC">C</label>
134 </td>
135 </tr>
136 </table>
137 </body>
138 </html>