Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.

Commit ad268bb

Browse files
committed
replace hard coded data with request to Bridge Troll
1 parent cc6050e commit ad268bb

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
== Workshop of the World Visualization ==
22

3-
The [location data](https://docs.google.com/a/ultrasaurus.com/spreadsheet/ccc?key=0AjPWVMj9wWa6dDJOVE5DVTRxbjc2Vy1PMVlQTlh4eFE#gid=0)
4-
was gathered from [Bridge Troll](http://www.bridgetroll.org/) and other reports of activity from workshop leaders who use alternate registration systems. Contact Sarah Allen (@ultrasaurus) if you know of a city that is not representated.
3+
The location data has been gathered from [Bridge Troll](http://www.bridgetroll.org/). Contact Sarah Allen (@ultrasaurus) if you know of a city that is not representated.
54

65
To run locally, here's a list of [HTTP server one-liners](https://gist.github.com/willurd/5720255)
76

8-
## Wish List
7+
### Running data in map locally with Bridge Troll
8+
* start Bridge Troll locally using `rails server`
9+
10+
* Update BridgeTroll and workshop-map source code
11+
* within BridgeTroll source code:
12+
* update `allow_insecure?` to `true`
13+
* `config/application.rb` add your local server
14+
* Ex: I am using `python -m SimpleHTTPServer`, so I added 'localhost:8000'. Resulting in: `origins 'bridgefoundry.org', 'localhost:8000'`
15+
* within this "workshop-map" repo
16+
* update `workshop-map.js` to include`.defer(d3.json, "http://localhost:3000/events.json?type=past")`, instead of `defer(d3.json, "https://bridgetroll.orb/events.json?type=all")`
17+
* you can set the `type` query param to "all", "past" or "future".
918

19+
## Wish List
1020
* The title should be part of the map, rather than on the index page, to make
1121
it easier to embed.
1222
* Link to this repo in small text in the lower-right
1323
* Resize map based on width and height. Note that currently the map is artfully
1424
cropped since we haven't had any workshops in the north and south poles, and
15-
we should keep that feature while allowing for setting width/height to
25+
we should keep that feature while allowing for setting width/height to
1626
grow or shrink the map. This would enable it to fit nicely in a blog post
1727
and be easily viewed on mobile devices.
1828
* Show the map in the README
@@ -32,3 +42,4 @@ Credits
3242
* Lillie Chilen, Travis Grathwell: Bridge Troll external events & events.csv API
3343
* Mary Jenn: 2015-2016 historical data wrangling
3444
* Tim Garcia: more d3 wizardry
45+

workshop-map.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ function workshopMap() {
1717
var tooltipDiv = d3.select("body").append("div")
1818
.attr("class", "tooltip hide")
1919

20-
// source: https://docs.google.com/spreadsheet/pub?key=0AjPWVMj9wWa6dDJOVE5DVTRxbjc2Vy1PMVlQTlh4eFE&single=true&gid=0&output=csv
21-
// google spreadsheets no longer allows cross-domain access
2220
d3.queue()
2321
.defer(d3.json, "data/world-50m.json")
24-
.defer(d3.csv, "data/workshop-data.csv")
22+
// see Readme for setting up test environment for making this GET request locally
23+
// .defer(d3.json, "http://localhost:3000/events.json?type=past")
24+
.defer(d3.json, "https://bridgetroll.org/events.json?type=all")
25+
26+
2527
.await(ready);
2628

2729
// load and display the World
@@ -36,19 +38,14 @@ function workshopMap() {
3638
.datum(topojson.feature(world, world.objects.countries))
3739
.attr("d", path);
3840

39-
40-
4141
circles = svg.selectAll("circle")
4242
.data(workshops)
4343
.enter().append("circle")
4444
.attr("class", "symbol")
45-
.attr("cx", d => projection([d.longitude, d.latitude])[0])
46-
.attr("cy", d => projection([d.longitude, d.latitude])[1])
45+
.attr("cx", d => projection([d.location.longitude, d.location.latitude])[0])
46+
.attr("cy", d => projection([d.location.longitude, d.location.latitude])[1])
4747
.attr("r", d => 5)
4848
.on("mouseover", function(d) {
49-
var html = `${d.city}<br/>`;
50-
//if (d["number (2013?)"]) { html += `${d["number (2013?)"]} Workshop`; }
51-
//if (+d["number (2013?)"] > 1) { html += "s"; }
5249
tooltipDiv.html(html);
5350
tooltipDiv.style("opacity", 0);
5451
tooltipDiv.attr("class", "tooltip");
@@ -57,7 +54,9 @@ function workshopMap() {
5754
tooltipDiv.style("left", `${d3.event.pageX - (width / 2)}px`);
5855
tooltipDiv.style("top", `${d3.event.pageY - height - 20}px`);
5956
tooltipDiv.style("opacity",1);
60-
console.log(`City: ${d.city}, # of Workshops: ${d["number (2013?)"]}`);
57+
// while 'events_count' is available on the locations table, we do not currently have available through the API JSON response
58+
// I have added this within BridgeTroll and will make a PR for this updated response
59+
// console.log(`City: ${d.location.city}, # of Workshops: ${d.location.events_count}`);
6160
})
6261
.on("mouseout", d => {
6362
tooltipDiv.attr("class", "tooltip hide");

0 commit comments

Comments
 (0)