Commit b780d9804cbf6291c44cb3cce1230168e808f8c9
1 parent
11ab5596
Exists in
master
fix emission to emissions in emissions-per-distance.js
Showing
1 changed file
with
19 additions
and
19 deletions
Show diff stats
plots/emission-per-distance.js renamed to plots/emissions-per-distance.js
... | ... | @@ -21,12 +21,12 @@ function getBottomTicks(maxDistance) { |
21 | 21 | return range; |
22 | 22 | } |
23 | 23 | |
24 | -function getLeftTicks(maxEmission) { | |
25 | - return getTicks(maxEmission, Math.floor((maxEmission / 8) / 1000)* 1000) ; | |
24 | +function getLeftTicks(maxemissions) { | |
25 | + return getTicks(maxemissions, Math.floor((maxemissions / 8) / 1000)* 1000) ; | |
26 | 26 | } |
27 | 27 | |
28 | -function getRightTicks(maxEmissionPercent) { | |
29 | - return getTicks(maxEmissionPercent, 2); | |
28 | +function getRightTicks(maxemissionsPercent) { | |
29 | + return getTicks(maxemissionsPercent, 2); | |
30 | 30 | } |
31 | 31 | |
32 | 32 | function getAttendeeOnRight(sliceId, attendeeNumberPerGroup) |
... | ... | @@ -127,8 +127,8 @@ function addVerticalLineAndListenCursor(xScale, attendeeNumberPerGroup, attendee |
127 | 127 | |
128 | 128 | document.onreadystatechange = () => { |
129 | 129 | if (document.readyState === 'complete') { |
130 | - let maxEmission = 0; | |
131 | - let maxEmissionPercent = 0; | |
130 | + let maxemissions = 0; | |
131 | + let maxemissionsPercent = 0; | |
132 | 132 | let maxDistance = 0; |
133 | 133 | let svg = d3.select("#" + divId) |
134 | 134 | .append("svg") |
... | ... | @@ -139,9 +139,9 @@ document.onreadystatechange = () => { |
139 | 139 | .attr("transform", |
140 | 140 | "translate(" + margin.left + "," + margin.top + ")"); |
141 | 141 | |
142 | - let emissionPerGroup = []; | |
142 | + let emissionsPerGroup = []; | |
143 | 143 | let attendeeNumberPerGroup = []; |
144 | - let emissionSum = 0; | |
144 | + let emissionsSum = 0; | |
145 | 145 | let attendeeSum = 0; |
146 | 146 | let rows = []; |
147 | 147 | |
... | ... | @@ -162,11 +162,11 @@ document.onreadystatechange = () => { |
162 | 162 | } |
163 | 163 | rows.push(data); |
164 | 164 | maxDistance = Math.max(maxDistance, distance_km); |
165 | - emissionSum += co2_kg; | |
165 | + emissionsSum += co2_kg; | |
166 | 166 | }).then((() => { |
167 | 167 | for (let i = 0; i <= maxDistance/500; i++) |
168 | 168 | { |
169 | - emissionPerGroup[i] = 0; | |
169 | + emissionsPerGroup[i] = 0; | |
170 | 170 | attendeeNumberPerGroup[i] = 0; |
171 | 171 | } |
172 | 172 | rows.forEach((element, index) => { |
... | ... | @@ -175,13 +175,13 @@ document.onreadystatechange = () => { |
175 | 175 | let attendeeNumber = trainAttendee + planeAttendee; |
176 | 176 | let distance_km = element.distance_km / attendeeNumber; |
177 | 177 | let co2_kg = parseFloat(element.co2_kg); |
178 | - emissionPerGroup[Math.floor(distance_km/500)] += parseFloat(co2_kg); | |
178 | + emissionsPerGroup[Math.floor(distance_km/500)] += parseFloat(co2_kg); | |
179 | 179 | attendeeNumberPerGroup[Math.floor(distance_km/500)] += attendeeNumber; |
180 | 180 | attendeeSum += attendeeNumber; |
181 | 181 | }); |
182 | - emissionPerGroup.forEach((element, index) => { | |
183 | - maxEmission = Math.max(maxEmission, element); | |
184 | - maxEmissionPercent = Math.max(maxEmissionPercent, element / emissionSum * 100.0) | |
182 | + emissionsPerGroup.forEach((element, index) => { | |
183 | + maxemissions = Math.max(maxemissions, element); | |
184 | + maxemissionsPercent = Math.max(maxemissionsPercent, element / emissionsSum * 100.0) | |
185 | 185 | }); |
186 | 186 | maxDistance += 2000; |
187 | 187 | // console.log(maxDistance); |
... | ... | @@ -214,20 +214,20 @@ document.onreadystatechange = () => { |
214 | 214 | |
215 | 215 | // Y axis Left |
216 | 216 | let yl = d3.scaleLinear() |
217 | - .domain([0, maxEmission]) | |
217 | + .domain([0, maxemissions]) | |
218 | 218 | .range([height, 0]); |
219 | 219 | let ylAxis = d3.axisLeft(yl) |
220 | - .tickValues(getLeftTicks(maxEmission)); | |
220 | + .tickValues(getLeftTicks(maxemissions)); | |
221 | 221 | svg.append("g") |
222 | 222 | .attr("class", "yl axis") |
223 | 223 | .call(ylAxis); |
224 | 224 | |
225 | 225 | // Y axis Right |
226 | 226 | let yr = d3.scaleLinear() |
227 | - .domain([0, maxEmissionPercent]) | |
227 | + .domain([0, maxemissionsPercent]) | |
228 | 228 | .range([height, 0]); |
229 | 229 | let yrAxis = d3.axisRight(yr) |
230 | - .tickValues(getRightTicks(maxEmissionPercent)); | |
230 | + .tickValues(getRightTicks(maxemissionsPercent)); | |
231 | 231 | svg.append("g") |
232 | 232 | .attr("transform", "translate(" + width + ", 0)") |
233 | 233 | .attr("class", "yr axis") |
... | ... | @@ -263,7 +263,7 @@ document.onreadystatechange = () => { |
263 | 263 | let histolol = histogram(0); |
264 | 264 | // console.log(histolol); |
265 | 265 | let barSettings = []; |
266 | - emissionPerGroup.forEach((element, index) => { | |
266 | + emissionsPerGroup.forEach((element, index) => { | |
267 | 267 | barSettings[index]= |
268 | 268 | { |
269 | 269 | height : element, | ... | ... |