-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb.js
More file actions
executable file
·58 lines (46 loc) · 1.85 KB
/
Copy pathb.js
File metadata and controls
executable file
·58 lines (46 loc) · 1.85 KB
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
var width = $("svg").width();
var height = $("svg").height();
var colors = ["#FD8110", "#26A625", "#D22829", "#9166C3", "#895844", "#E277C8", "#7E7E7E"];
var projection = d3.geo.mercator()
.scale(250)
.center([-60, -20])
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
d3.json("world-110m.json", function(error, world) {
if (error) return console.error(error);
d3.selectAll("svg").append("path")
.datum(topojson.feature(world, world.objects.countries))
.attr("d", path);
});
var companies = [];
d3.json("http://localhost:8983/solr/jobposts/select?q=id%3A*+AND+location2_s%3A*&rows=0&wt=json&facet=true&facet.field=company_s", function(error, resp) {
if (error) return console.error(error);
var results = resp.facet_counts.facet_fields.company_s;
for (var i = 0; i < 3; i++) {
companies.push(results[(i+1) * 2]);
}
});
$("input:radio").click(function() {
d3.selectAll("circle").remove();
d3.selectAll("button").remove();
var start = $(this).attr("data-start");
var end = $(this).attr("data-end");
var svg = d3.select("svg");
companies.forEach(function(comp, i) {
var key = $("<button/>").attr("type", "button").addClass("btn btn-xs map-key-button").css("background-color", colors[i]).text(comp);
$(".map-key").append(key);
var query = 'id:*0 AND location2_s:* AND company_s:"' + comp
+ '" AND postedDate_dt:[' + start + ' TO ' + end + ']';
var url = "http://localhost:8983/solr/jobposts/select?q=" + encodeURIComponent(query) + "&rows=1000&fl=longitude_d%2C+latitude_d&wt=json";
d3.json(url, function(error, resp) {
if (error) return console.error(error);
resp.response.docs.forEach(function(loc) {
svg.append("circle")
.attr("r", 2.5)
.attr("transform", "translate(" + projection([loc.longitude_d, loc.latitude_d]) + ")")
.style("fill", colors[i]);
});
});
});
});