-
Notifications
You must be signed in to change notification settings - Fork 29
/
rules.html
120 lines (107 loc) · 2.6 KB
/
rules.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
<!doctype html>
<html lang="en">
<head>
<title>Esri <3 d3js</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">
<style type="text/css">
html, body {
height: 100%; width: 100%;
margin: 0; padding: 0;
}
body{
background-color: #fff; overflow:hidden;
font-family: sans-serif;
}
path {
fill: #08c;
stroke: #fff;
stroke-width:1px;
opacity: 1;
}
#map {
position:absolute;
width: 100%;
height: 100%;
}
path[data-cat="1"]{
fill: rgb(247,251,255);
}
path[data-cat="2"]{
fill: rgb(8,81,156);
}
path[data-cat="3"]{
fill: rgb(33,113,181);
}
path[data-cat="4"]{
fill: rgb(66,146,198);
}
path[data-cat="5"]{
fill: rgb(107,174,214);
}
path[data-cat="6"]{
fill: rgb(158,202,225);
}
path[data-cat="7"]{
fill: rgb(198,219,239);
}
path[data-cat="8"]{
fill: rgb(222,235,247);
}
path[data-cat="9"]{
fill: rgb(8,48,107);
}
</style>
<script>
var dojoConfig = {
parseOnLoad: true,
packages: [{
"name": "modules",
"location": location.origin + location.pathname.replace(/\/[^/]+$/, '')
}]
};
</script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://js.arcgis.com/3.13/"></script>
<script>
var cat = d3.scale.quantile()
.domain([0, 50])
.range(["1", "2", "3", "4", "5", "6", "7", "8", "9"]);
var path = d3.geo.path();
var map;
var layer;
require([
"esri/map",
"dojo/parser",
"modules/d3Layer",
"dojo/domReady!"
], function(
Map,
parser,
d3Layer
) {
parser.parse();
map = new Map("map", {
center: [-98, 39],
zoom: 4,
basemap: "gray"
});
layer = new d3Layer('us-counties.json', {
attrs: [
{ key: 'data-cat',
value: function(d){
/* console.log(path.area(d)); */
return Math.round(cat(path.area(d)));
}
}
]
});
map.addLayer(layer);
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>