Commit e4138b414895888ad5c512957d6dfcabd5371e3a
1 parent
910464a0
Exists in
master
chore: cleanup
Showing
1 changed file
with
8 additions
and
11 deletions
Show diff stats
flaskr/static/js/plots/emissions-per-distance.js
@@ -144,19 +144,19 @@ function draw_emissions_per_distance(divId, csvUrl) { | @@ -144,19 +144,19 @@ function draw_emissions_per_distance(divId, csvUrl) { | ||
144 | let attendeeSum = 0; | 144 | let attendeeSum = 0; |
145 | let rows = []; | 145 | let rows = []; |
146 | 146 | ||
147 | - const on_csv_loading = function (data) { | ||
148 | - let trainAttendee = parseInt(data["train trips_amount"]); | ||
149 | - let planeAttendee = parseInt(data["plane trips_amount"]); | 147 | + const on_csv_datum = function (datum) { |
148 | + let trainAttendee = parseInt(datum["train trips_amount"]); | ||
149 | + let planeAttendee = parseInt(datum["plane trips_amount"]); | ||
150 | if (trainAttendee === 0 && planeAttendee === 0) { | 150 | if (trainAttendee === 0 && planeAttendee === 0) { |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | let attendeeNumber = trainAttendee + planeAttendee; | 153 | let attendeeNumber = trainAttendee + planeAttendee; |
154 | - let distance_km = data.distance_km / attendeeNumber; | ||
155 | - let co2_kg = parseFloat(data.co2_kg); | 154 | + let distance_km = datum.distance_km / attendeeNumber; |
155 | + let co2_kg = parseFloat(datum.co2_kg); | ||
156 | if (co2_kg === "NaN" || distance_km / 500 > 37 || distance_km === "NaN") { | 156 | if (co2_kg === "NaN" || distance_km / 500 > 37 || distance_km === "NaN") { |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | - rows.push(data); | 159 | + rows.push(datum); |
160 | maxDistance = Math.max(maxDistance, distance_km); | 160 | maxDistance = Math.max(maxDistance, distance_km); |
161 | emissionsSum += co2_kg; | 161 | emissionsSum += co2_kg; |
162 | 162 | ||
@@ -290,11 +290,8 @@ function draw_emissions_per_distance(divId, csvUrl) { | @@ -290,11 +290,8 @@ function draw_emissions_per_distance(divId, csvUrl) { | ||
290 | addVerticalLineAndListenCursor(x, attendeeNumberPerGroup, attendeeSum); | 290 | addVerticalLineAndListenCursor(x, attendeeNumberPerGroup, attendeeSum); |
291 | }; | 291 | }; |
292 | 292 | ||
293 | - d3.csv(csvUrl, on_csv_loading).then(on_csv_ready); | ||
294 | - // d3.queue() | ||
295 | - // .defer(d3.csv, csvUrl, on_csv_loading) | ||
296 | - // .await(on_csv_ready); | ||
297 | - | 293 | + d3.csv(csvUrl, on_csv_datum) |
294 | + .then(on_csv_ready); | ||
298 | } | 295 | } |
299 | }; | 296 | }; |
300 | 297 |