-
Notifications
You must be signed in to change notification settings - Fork 2
/
dashboard.html
312 lines (279 loc) · 12.6 KB
/
dashboard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!doctype html>
<html lang="en">
<head>
<title>Demographix</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="%description%" />
<meta name="keywords" content="" />
<meta name="author" content="ComponentOne" />
<link href="http://cdn.wijmo.com/themes/aristo/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.wijmo.com/jquery.wijmo-open.0.8.2.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.wijmo.com/jquery.wijmo-complete.0.8.2.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/jquery.tmpl.min.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/jquery.glob.min.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/jquery.tmpl.min.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/raphael.js"></script>
<script type="text/javascript" src="http://cdn.wijmo.com/external/raphael-popup.js"></script>
<script src="http://cdn.wijmo.com/jquery.wijmo-open.0.8.2.min.js" type="text/javascript"></script>
<script src="http://cdn.wijmo.com/jquery.wijmo-complete.0.8.2.min.js" type="text/javascript"></script>
<!-- ArcGIS API for JavaScript -->
<script type="text/javascript"> var djConfig = { parseOnLoad: true };</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
<script type="text/javascript">
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.utils");
dojo.require("esri.tasks.query");
var map, queryTask, query, click;
var wd = 240;
var ht = 110;
var chartParams = { cht: "p3", chl: "White|Black|Hispanic|Asian|Other" };
var clicks = 0;
function init() {
map = new esri.Map("map", {
slider: false,
extent: new esri.geometry.Extent({ "xmin": -8276294, "ymin": 4953481, "xmax": -8196571, "ymax": 4999114, "spatialReference": { "wkid": 102100} })
});
map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer", { opacity: 0.4 }));
dojo.connect(map, "onClick", doQuery);
queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");
dojo.connect(queryTask, "onComplete", getChart);
dojo.connect(map.infoWindow, "onHide", function () { map.graphics.clear(); });
query = new esri.tasks.Query();
query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
query.outFields = ["NAME", "WHITE", "BLACK", "ASIAN", "HISPANIC", "OTHER"];
query.returnGeometry = true;
query.outSpatialReference = { "wkid": 102100 };
dojo.connect(map, "onLoad", function () {
console.log("Map onLoad event");
/*****************
* Hook up jQuery
*****************/
$(document).ready(jQueryReady);
});
var resizeTimer;
dojo.connect(map, 'onLoad', function (theMap) {
dojo.connect(dijit.byId('map'), 'resize', function () { //resize the map if the div is resized
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
map.resize();
map.reposition();
}, 500);
});
});
}
function jQueryReady() {
console.log("jQuery ready event");
$("#tipper").wijtooltip({ showCallOut: false }).wijtooltip("show");
$("#tabs").wijtabs();
$("#jqSlider").wijslider({
min: 0,
max: 17,
value: map.getLevel(),
orientation: "vertical",
change: function (event, ui) {
map.setLevel(ui.value);
}
});
dojo.connect(map, "onZoomEnd", function (evt) {
$("#jqSlider").wijslider("value", map.getLevel());
});
}
function doQuery(evt) {
$("#tipper").wijtooltip("option", "content", "Hardcore mapping action...").wijtooltip("show");
click = query.geometry = evt.mapPoint;
queryTask.execute(query);
}
function getChart(featureSet) {
var duration = 500;
var radiusOffset = 18;
var offset = {};
map.graphics.clear();
var features = featureSet.features;
var feature, attributes, white, black, asian, hispanic, other, total, graphic;
for (var i = 0; i < features.length; i++) {
feature = features[i];
attributes = feature.attributes;
if (clicks > 0) {
$("#chart").html("").wijpiechart("destroy");
}
$("#chart").html("").wijpiechart({
radius: 140,
legend: { visible: true },
hint: {
formatter: function () {
return this.data.label + " : " + $.format(this.value / this.total, "p2");
}
},
header: {
text: attributes["NAME"] + " County Demographics"
},
seriesList: [{
label: "White",
data: parseInt(attributes.WHITE)
}, {
label: "Black",
data: parseInt(attributes.BLACK)
}, {
label: "Asian",
data: parseInt(attributes.ASIAN)
}, {
label: "Hispanic",
data: parseInt(attributes.HISPANIC)
}, {
label: "Other",
data: parseInt(attributes.OTHER)
}]
});
if (clicks == 0) {
$("#chart").bind("wijpiechartmouseover", function (e, objData) {
if (objData != null) {
var series = objData;
var sector = $("#chart").wijpiechart("getSector", series.index);
var shadow = sector.shadow;
offset = sector.getOffset(radiusOffset);
sector.animate({
translation: offset.x + " " + offset.y
}, duration, "elastic");
if (shadow) {
shadow.animate({
translation: offset.x + " " + offset.y
}, duration, "elastic");
}
}
});
$("#chart").bind("wijpiechartmouseout", function (e, objData) {
if (objData != null) {
var series = objData;
var sector = $("#chart").wijpiechart("getSector", series.index);
var shadow = sector.shadow;
sector.animate({
translation: -offset.x + " " + offset.y * -1
}, duration, "elastic");
if (shadow) {
shadow.animate({
translation: -offset.x + " " + offset.y * -1
}, duration, "elastic");
}
offset = { x: 0, y: 0 };
}
});
$("#grid").wijgrid({
data: [
["White", parseInt(attributes.WHITE)],
["Black", parseInt(attributes.BLACK)],
["Asian", parseInt(attributes.ASIAN)],
["Hispanic", parseInt(attributes.HISPANIC)],
["Other", parseInt(attributes.OTHER)]
],
columns: [
{ headerText: "Demographic" }, { headerText: "Population", dataType: "number" }
]
});
$("#tabs").fadeIn(2000);
}
var mySymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([0, 0, 0]), 4), new dojo.Color([255, 255, 255, 0.5]));
feature.setSymbol(mySymbol);
map.graphics.add(feature);
clicks = 1;
}
$("#tipper").wijtooltip("hide");
}
dojo.addOnLoad(init);
//Display any errors that were caught when attempting to solve the rotue
function errorHandler(err) {
alert("An error occured\n" + err.message + "\n" + err.details.join("\n"));
}
</script>
<style type="text/css">
/*demo page css*/
html, body
{
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map
{
padding: 0;
}
#chart
{
background: #fff;
background: rgba(255,255,255,0.5);
}
body
{
font-size: 12px;
}
a img
{
border: none;
}
.header
{
position: absolute;
top: 10px;
left: 60px;
z-index: 98;
background: #000;
background: rgba(0,0,0,0.35);
padding: 5px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.header h1
{
color: #fff;
text-shadow: 0px 1px 5px rgba(0,0,0,1);
font-weight: 800;
font-size: 3em;
margin: 0;
padding: 0;
}
</style>
</head>
<body class="demo-single">
<div style="position: absolute; bottom: 10px; left: 10px; z-index: 99">
<div id="tabs" class="ui-helper-hidden" style="width: 400px; height: 350px;">
<ul>
<li><a href="#tabs-1">Chart</a></li>
<li><a href="#tabs-2">Grid</a></li>
</ul>
<div id="tabs-1">
<div id="chart" class="" style="width: 100%; height: 300px;">Click the map to see demographic data!
</div>
</div>
<div id="tabs-2">
<table id="grid">
</table>
</div>
</div>
</div>
<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%; margin: 0;">
<div id="map" dojotype="dijit.layout.ContentPane" region="center" style="overflow: hidden;">
<div style="position: absolute; left: 20px; top: 20px; z-index: 100;">
<div id="jqSlider" style="height: 200px">
</div>
</div>
</div>
</div>
<div class="ui-widget header">
<h1>
Demographix</h1>
</div>
<div id="working" style="position: absolute; top: 0; right: 10px; z-index: 99;">
<a id="tipper" href="#" title="Click the map to see demographics for a county!"> </a>
</div>
</body>
</html>