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

Commit b4d02a3

Browse files
committed
replace hard coded data with request to Bridge Troll
1 parent ae407ca commit b4d02a3

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ 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
2830
function ready(error, world, workshops) {
29-
console.log("world.objects")
30-
console.log(world.objects)
3131
if (error) return console.log("there was an error loading the data: " + error);
3232
var zoom,
3333
circles;
@@ -38,19 +38,14 @@ function workshopMap() {
3838
.datum(topojson.feature(world, world.objects.countries))
3939
.attr("d", path);
4040

41-
42-
4341
circles = svg.selectAll("circle")
4442
.data(workshops)
4543
.enter().append("circle")
4644
.attr("class", "symbol")
47-
.attr("cx", d => projection([d.longitude, d.latitude])[0])
48-
.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])
4947
.attr("r", d => 5)
5048
.on("mouseover", function(d) {
51-
var html = `${d.city}<br/>`;
52-
//if (d["number (2013?)"]) { html += `${d["number (2013?)"]} Workshop`; }
53-
//if (+d["number (2013?)"] > 1) { html += "s"; }
5449
tooltipDiv.html(html);
5550
tooltipDiv.style("opacity", 0);
5651
tooltipDiv.attr("class", "tooltip");
@@ -59,7 +54,9 @@ function workshopMap() {
5954
tooltipDiv.style("left", `${d3.event.pageX - (width / 2)}px`);
6055
tooltipDiv.style("top", `${d3.event.pageY - height - 20}px`);
6156
tooltipDiv.style("opacity",1);
62-
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}`);
6360
})
6461
.on("mouseout", d => {
6562
tooltipDiv.attr("class", "tooltip hide");

0 commit comments

Comments
 (0)