-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimpacts.html
More file actions
581 lines (528 loc) · 36.3 KB
/
impacts.html
File metadata and controls
581 lines (528 loc) · 36.3 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
<!DOCTYPE html>
<html>
<head>
<title>Demo Website</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&family=Manrope:wght@200..800&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<!-- linking css file-->
<link href="styles/styles.css" rel="stylesheet" />
<!-- D3.js library -->
<script src="https://d3js.org/d3.v7.min.js"></script>
</head>
<body>
<!-- Disclaimer Banner -->
<div class="disclaim-banner"><img src="images/logo_white_red.svg" alt="City of Boston" class="banner-logo"><span class="banner-text">This is not an official City of Boston website. This is an academic project created by Harvard Kennedy School students.</span></div>
<header class="top-header">
<div class="header-inner">
<img src="images/logo.svg" alt="City of Boston" class="site-logo">
<nav class="site-nav" role="navigation" aria-label="Primary">
<ul class="site-nav-list">
<li><a href="index.html">Home</a></li>
<li><a href="impacts.html">Impacts</a></li>
<li><a href="recommendations.html">Recommendations</a></li>
<li><a href="method.html">Methodology</a></li>
<li><a href="sources.html">Sources</a></li>
<li><a href="our-team.html">Our Team</a></li>
</ul>
</nav>
</div>
</header>
<!-- Main Page Title -->
<h1>Pay-As-You-Throw in Boston</h1>
<p class="intro-text">How might implementing a Pay-As-You-Throw (PAYT) program impact the City of Boston?</p>
<div class="squiggle" aria-hidden="true"></div>
<p>To estimate the impact of a PAYT program on Boston's trash tonnage and revenue, our team...</p>
<ul class="badge-list">
<li><span class="mini-badge">1</span> Calculated how much trash Boston households produced in 2024 and how much the city spent to incinerate it.</li>
<li><span class="mini-badge">2</span> Estimated the potential trash reduction and how much the city could save in incineration costs from the reduction alone.</li>
<li><span class="mini-badge">3</span> Boston estimates were generated from reductions seen in other municipalities.</li>
<li><span class="mini-badge">4</span> Estimated how much Boston could generate in revenue from PAYT-bag sales based on the city of Malden.</li>
</ul>
<!-- Section: Boston 2024 vs PAYT side-by-side -->
<div class="impact-compare">
<div class="impact-column">
<div class="sectionbanner"><span class="banner-badge">1</span><strong>Without</strong> Pay-As-You-Throw (2024)</div>
<!-- Result Cards Column -->
<div class="stat-blocks stack">
<div class="stat-block">
<h3 class="block-title">Boston disposed of</h3>
<p class="block-reduction"><span class="reduction-percent">186,305 tons of trash in 2024</span> </p>
<p class="block-description">This includes household and bulky waste</p>
</div>
<div class="stat-block">
<h3 class="block-title">Each household disposed of</h3>
<p class="block-reduction"><span class="reduction-percent">0.68 tons of trash in 2024</span> </p>
<p class="block-description">This is an average per household</p>
</div>
<div class="stat-block">
<h3 class="block-title">Boston spent</h3>
<p class="block-reduction"><span class="reduction-percent">$19,260,210.90</span></p>
<p class="block-description">on incinerating all household trash in 2024</p>
</div>
</div>
</div>
<div class="impact-column">
<div class="sectionbanner"><span class="banner-badge">2</span><strong>With</strong> Pay-As-You-Throw (by 2031)</div>
<div class="stat-blocks stack">
<div class="stat-block">
<h3 class="block-title">Boston could dispose of</h3>
<p class="block-reduction"><span class="reduction-percent">102,675 tons of trash (45% less) by 2031</span></p>
<p class="block-description">Estimated based on reductions seen in other municipalities</p>
</div>
<div class="stat-block">
<h3 class="block-title">Each household could dispose of</h3>
<p class="block-reduction"><span class="reduction-percent">0.36 fewer tons of trash by 2031</span></p>
<p class="block-description">This is an average per household</p>
</div>
<div class="stat-block">
<h3 class="block-title">Boston could save</h3>
<p class="block-reduction"><span class="reduction-percent">$1,729,131.19</span></p>
<p class="block-description">in annual trash incineration costs with this 44.95% reduction in tonnage alone.</p>
</div>
</div>
</div>
</div>
<div class="method-banner">
<button class="method-toggle" aria-expanded="false">What Are These Numbers? <span class="chev">▾</span></button>
<div class="method-content" hidden>
<h4>Terminology</h4>
<ul style="margin-bottom: 20px;">
<li><strong>Tipping Fee:</strong> The cost per ton that municipalities pay to dispose of trash at incineration or landfill facilities. Boston's tipping fee is $103.38 per ton.</li>
<li><strong>Municipal Solid Waste:</strong> Trash collected through Boston's municipal waste management program.</li>
<li><strong>Household:</strong> A residential unit participating in Boston's municipal trash program. 322,000 households participated in 2024.</li>
<li><strong>Tonnage:</strong> The total weight of trash disposed by participating households, measured in tons. Boston disposed of 186,305 tons in 2024, which converts to 372,610,000 pounds.</li>
<li><strong>Average Reduction:</strong> How much trash 5 cities reduced per household after 5 years with PAYT = 0.260 tons per household.</li>
<li><strong>Percent Reduction:</strong> How much less trash households threw away = 44.95%.</li>
<li><strong>Projected Reduction:</strong> How much trash Boston could reduce if it does as well as other cities = 83,629.87 tons over 5 years.</li>
</ul>
<p style="margin-top: 15px; font-size: 14px;">For more information on the methodology, visit the <a href="method.html">Methodology page</a>.</p>
</div>
</div>
</div>
<!-- Section: PAYT Results in Other Municipalities -->
<section class="stats-fullpage">
<div class="sectionbanner"><span class="banner-badge">3</span>PAYT Results in Other Massachusetts Municipalities</div>
<div class="stat-blocks">
<div class="stat-block">
<h3 class="block-title">Hinsdale</h3>
<p class="block-reduction">Reduced yearly household tonnage by <span class="reduction-percent">43.48%</span></p>
<p class="block-description">over a 5 year time period of implementing PAYT.</p>
<p class="block-description"><strong>PAYT Model:</strong> Stickers</p>
</div>
<div class="stat-block">
<h3 class="block-title">Peru</h3>
<p class="block-reduction">Reduced yearly household tonnage by <span class="reduction-percent">11.4%</span></p>
<p class="block-description">over a 5 year time period of implementing PAYT.</p>
<p class="block-description"><strong>PAYT Model:</strong> Stickers</p>
</div>
<div class="stat-block">
<h3 class="block-title">Heath</h3>
<p class="block-reduction">Reduced yearly household tonnage by <span class="reduction-percent">47.57%</span></p>
<p class="block-description">over a 5 year time period of implementing PAYT.</p>
<p class="block-description"><strong>PAYT Model:</strong> Stickers</p>
</div>
<div class="stat-block">
<h3 class="block-title">Chicopee</h3>
<p class="block-reduction">Reduced yearly household tonnage by <span class="reduction-percent">16.25%</span></p>
<p class="block-description">over a 5 year time period of implementing PAYT.</p>
<p class="block-description"><strong>PAYT Model:</strong> Bags and Carts</p>
</div>
<div class="stat-block">
<h3 class="block-title">Harvard</h3>
<p class="block-reduction">Reduced yearly household tonnage by <span class="reduction-percent">39.74%</span></p>
<p class="block-description">over a 5 year time period of implementing PAYT.</p>
<p class="block-description"><strong>PAYT Model:</strong> Bags and Punch Cart</p>
</div>
</div>
<div class="section-note">Pre-Post Effect of PAYT Within a 5-year Time Period</div>
<div class="graph-container">
<figure class="graph-figure">
<div id="d3-graph"></div>
<figcaption>Data Sources: <a href="https://www.mass.gov/lists/recycling-solid-waste-data-for-massachusetts-cities-towns" target="_blank">Massachusetts Department of Environmental Protection's 2024 Municipal Solid Waste and Recycling Survey</a>, <a href="https://dls-gw.dor.state.ma.us/reports/rdpage.aspx?rdreport=socioeconomic.population.population_main" target="_blank">Massachusetts Department of Revenue</a>, & <a href="https://www.mass.gov/lists/pay-as-you-throw-payt" target="_blank">Massachusetts Municipal PAYT Programs</a></figcaption>
</figure>
</div>
<!-- Methodology Banner -->
<div class="method-banner">
<button class="method-toggle" aria-expanded="false">What Are These Numbers?<span class="chev">▾</span></button>
<div class="method-content" hidden>
<h4>Terminology</h4>
<ul style="margin-bottom: 20px;">
<li><strong>Pre-PAYT Period:</strong> The years before a city started PAYT, showing how much trash households threw away normally.</li>
<li><strong>Post-PAYT Period:</strong> The years after a city implemented PAYT, showing how much trash households threw away with the program.</li>
<li><strong>Parallel Trends:</strong> Comparing cities with similar amounts of data before and after PAYT to ensure fair comparison.</li>
<li><strong>Tons Per Household:</strong> The average amount of trash one household threw away each year, calculated for each city.</li>
</ul>
<p style="margin-top: 15px; font-size: 14px;">For more information on the methodology, visit the <a href="method.html">Methodology page</a>.</p>
</div>
</div>
</div>
<!-- Section: Case Study of Malden -->
<div class="sectionbanner"><span class="banner-badge">4</span>Potential Revenue from PAYT: A Case Study of Malden</div>
<p>We used the city of Malden as a case study to estimate the potential revenue Boston could generate if they implemented a similar PAYT program. Malden residents have two options to dispose of their trash: 1) Buy <strong>blue PAYT trash bags </strong>that can be placed in any barrel, or 2) Buy an <strong>annual "trash tag"</strong> to stick to a 35-gallon city-issued trash cart and continue using standard trash bags.<a href="https://www.cityofmalden.org/238/Trash-Recycling"><sup>1</sup></a></p>
<div class="two-column-divider">
<div class="column-left">
<h3>
<img src="images/trash.jpg" alt="PAYT trash bag" class="column-image">
2024 PROPOSED REVENUE FROM PAYT BAG SALES
</h3>
<div class="large-text">
$12,837,475
</div>
<div class="asteric">Statistic includes household and bulky waste for the City of Malden</div>
</div>
<div class="divider-line"></div>
<div class="column-right">
<h3>
<img src="images/tag.jpg" alt="Trash disposal tag" class="column-image">
2024 PROPOSED REVENUE FROM PAYT TRASH TAGS
</h3>
<div class="large-text">
$8,518,760
</div>
<div class="asteric">Statistic includes household and bulky waste for the City of Malden</div>
</div>
</div>
<div class="footnote">Revenue projections are based on the city of Malden's PAYT revenue from PAYT bag and tag sales for participating households only. The city of Malden is a densely populated municipality, with a smaller population size than the city of Boston. For more information on the methodology, visit the <a href="method.html">Methodology page</a>.</div>
<div class="method-banner">
<button class="method-toggle" aria-expanded="false">What Are These Numbers? <span class="chev">▾</span></button>
<div class="method-content" hidden>
<h4>Terminology</h4>
<ul style="margin-bottom: 20px;">
<li><strong>Per-Household Revenue:</strong> How much money each household generates through PAYT bag and tag sales in Malden.</li>
<li><strong>Revenue Source:</strong> The different ways cities earn money from PAYT, like bag sales or trash tag sales.</li>
<li><strong>Scaling:</strong> Using Malden's revenue earned per household to estimate how much Boston could earn.</li>
<li><strong>Illustrative:</strong> This is an example calculation, not a prediction of what will actually happen.</li>
</ul>
<p style="margin-top: 15px; font-size: 14px;">For more information on the methodology, visit the <a href="method.html">Methodology page</a>.</p>
</div>
</div>
<div class="footnote">Interviews with officials from the Massachusetts Department of Environmental Protection, the City of Boston's Zero Waste Initiative team, the University of New Hampshire, the City of Brockton, and the City of Malden have informed the analysis on this page. For works cited, see the <a href="sources.html">Sources page</a>.</div>
<script>
var lastBannerHeight = null;
function syncHeaderPosition(){
var banner = document.querySelector('.disclaim-banner');
var header = document.querySelector('.top-header');
if(!banner || !header) return;
var bannerHeight = banner.offsetHeight;
if(bannerHeight !== lastBannerHeight) {
lastBannerHeight = bannerHeight;
header.style.top = bannerHeight + 'px';
document.body.style.paddingTop = 'calc(24px + ' + bannerHeight + 'px + 64px)';
}
}
// Poll on every frame (16ms) to catch text reflow immediately
setInterval(syncHeaderPosition, 16);
window.addEventListener('load', syncHeaderPosition);
window.addEventListener('resize', syncHeaderPosition);
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
// D3 Interactive Graph - Pre-Post PAYT Effect
const graphData = [
// Chicopee (PAYT 2017, years_payt: -4 to 5)
{ municipality: 'Chicopee', year: -4, tonnage: 0.7393617, type: 'pre' },
{ municipality: 'Chicopee', year: -3, tonnage: 0.7267905, type: 'pre' },
{ municipality: 'Chicopee', year: -2, tonnage: 0.7201172, type: 'pre' },
{ municipality: 'Chicopee', year: -1, tonnage: 0.7240520, type: 'pre' },
{ municipality: 'Chicopee', year: 0, tonnage: 0.5886695, type: 'post' },
{ municipality: 'Chicopee', year: 1, tonnage: 0.6204813, type: 'post' },
{ municipality: 'Chicopee', year: 2, tonnage: 0.5576872, type: 'post' },
{ municipality: 'Chicopee', year: 3, tonnage: 0.6272738, type: 'post' },
{ municipality: 'Chicopee', year: 4, tonnage: 0.6468433, type: 'post' },
{ municipality: 'Chicopee', year: 5, tonnage: 0.6151788, type: 'post' },
// Harvard (PAYT 2019, years_payt: -5 to 5)
{ municipality: 'Harvard', year: -5, tonnage: 0.8311209, type: 'pre' },
{ municipality: 'Harvard', year: -4, tonnage: 0.8260870, type: 'pre' },
{ municipality: 'Harvard', year: -3, tonnage: 0.9753580, type: 'pre' },
{ municipality: 'Harvard', year: -2, tonnage: 0.8177323, type: 'pre' },
{ municipality: 'Harvard', year: -1, tonnage: 0.8061971, type: 'pre' },
{ municipality: 'Harvard', year: 0, tonnage: 0.6302390, type: 'post' },
{ municipality: 'Harvard', year: 1, tonnage: 0.5599200, type: 'post' },
{ municipality: 'Harvard', year: 2, tonnage: 0.5020960, type: 'post' },
{ municipality: 'Harvard', year: 3, tonnage: 0.4425517, type: 'post' },
{ municipality: 'Harvard', year: 4, tonnage: 0.4455224, type: 'post' },
{ municipality: 'Harvard', year: 5, tonnage: 0.4975635, type: 'post' },
// Heath (PAYT 2017, years_payt: -5 to 5)
{ municipality: 'Heath', year: -5, tonnage: 0.9145299, type: 'pre' },
{ municipality: 'Heath', year: -4, tonnage: 0.7803922, type: 'pre' },
{ municipality: 'Heath', year: -3, tonnage: 0.7142857, type: 'pre' },
{ municipality: 'Heath', year: -2, tonnage: 0.7811877, type: 'pre' },
{ municipality: 'Heath', year: -1, tonnage: 0.6587726, type: 'pre' },
{ municipality: 'Heath', year: 0, tonnage: 0.5249527, type: 'post' },
{ municipality: 'Heath', year: 1, tonnage: 0.3610714, type: 'post' },
{ municipality: 'Heath', year: 2, tonnage: 0.3556857, type: 'post' },
{ municipality: 'Heath', year: 3, tonnage: 0.4209174, type: 'post' },
{ municipality: 'Heath', year: 4, tonnage: 0.4009621, type: 'post' },
{ municipality: 'Heath', year: 5, tonnage: 0.3579228, type: 'post' },
// Hinsdale (PAYT 2017, years_payt: -4 to 5)
{ municipality: 'Hinsdale', year: -4, tonnage: 0.8728448, type: 'pre' },
{ municipality: 'Hinsdale', year: -3, tonnage: 0.9290323, type: 'pre' },
{ municipality: 'Hinsdale', year: -2, tonnage: 0.9652903, type: 'pre' },
{ municipality: 'Hinsdale', year: -1, tonnage: 0.9324731, type: 'pre' },
{ municipality: 'Hinsdale', year: 0, tonnage: 0.6558077, type: 'post' },
{ municipality: 'Hinsdale', year: 1, tonnage: 0.4879636, type: 'post' },
{ municipality: 'Hinsdale', year: 2, tonnage: 0.4927273, type: 'post' },
{ municipality: 'Hinsdale', year: 3, tonnage: 0.5397254, type: 'post' },
{ municipality: 'Hinsdale', year: 4, tonnage: 0.5259774, type: 'post' },
{ municipality: 'Hinsdale', year: 5, tonnage: 0.4343286, type: 'post' },
// Peru (PAYT 2017, years_payt: -5 to 4)
{ municipality: 'Peru', year: -5, tonnage: 0.6625000, type: 'pre' },
{ municipality: 'Peru', year: -4, tonnage: 0.6781250, type: 'pre' },
{ municipality: 'Peru', year: -3, tonnage: 0.6375000, type: 'pre' },
{ municipality: 'Peru', year: -2, tonnage: 0.6742813, type: 'pre' },
{ municipality: 'Peru', year: -1, tonnage: 0.5378307, type: 'pre' },
{ municipality: 'Peru', year: 0, tonnage: 0.7028621, type: 'post' },
{ municipality: 'Peru', year: 1, tonnage: 0.6156156, type: 'post' },
{ municipality: 'Peru', year: 2, tonnage: 0.5544776, type: 'post' },
{ municipality: 'Peru', year: 3, tonnage: 0.5881493, type: 'post' },
{ municipality: 'Peru', year: 4, tonnage: 0.5265373, type: 'post' }
];
const margin = { top: 20, right: 30, bottom: 70, left: 90 };
const width = 900 - margin.left - margin.right;
const height = 500 - margin.top - margin.bottom;
const svg = d3.select('#d3-graph')
.append('svg')
.attr('width', width + margin.left + margin.right)
.attr('height', height + margin.top + margin.bottom)
.attr('viewBox', `0 0 ${width + margin.left + margin.right} ${height + margin.top + margin.bottom}`)
.attr('preserveAspectRatio', 'xMidYMid meet')
.style('max-width', '100%')
.style('height', 'auto')
.append('g')
.attr('transform', `translate(${margin.left},${margin.top})`);
// Scales
const xScale = d3.scaleLinear()
.domain([-5, 5])
.range([0, width]);
const yScale = d3.scaleLinear()
.domain([0, 1.5])
.range([height, 0]);
const colorScale = d3.scaleOrdinal()
.domain(['Hinsdale', 'Peru', 'Heath', 'Chicopee', 'Harvard'])
.range(['#D4DDE6', '#BADFF5', '#FFCCC5', '#D9EBFF', '#C5DAEB']);
const darkerColors = {
'Hinsdale': '#091F2F',
'Peru': '#1871BD',
'Heath': '#FB4D42',
'Chicopee': '#51ACFF',
'Harvard': '#45789C'
};
// Line generator
const line = d3.line()
.x(d => xScale(d.year))
.y(d => yScale(d.tonnage));
// Group data by municipality
const municipalities = d3.group(graphData, d => d.municipality);
// Draw lines for each municipality
municipalities.forEach((data, municipality) => {
svg.append('path')
.datum(data)
.attr('fill', 'none')
.attr('stroke', colorScale(municipality))
.attr('stroke-width', 2.5)
.attr('d', line)
.attr('class', 'graph-line')
.style('opacity', 0.7)
.on('mouseover', function() {
d3.select(this)
.attr('stroke', darkerColors[municipality])
.style('opacity', 1)
.attr('stroke-width', 3.5);
})
.on('mouseout', function() {
d3.select(this)
.attr('stroke', colorScale(municipality))
.style('opacity', 0.7)
.attr('stroke-width', 2.5);
});
// Draw circles for data points
svg.selectAll(`.dots-${municipality}`)
.data(data)
.enter()
.append('circle')
.attr('cx', d => xScale(d.year))
.attr('cy', d => yScale(d.tonnage))
.attr('r', 4)
.attr('fill', colorScale(municipality))
.attr('class', `dots-${municipality}`)
.on('mouseover', function(event, d) {
d3.select(this)
.attr('r', 6)
.attr('fill', darkerColors[municipality]);
// Create background box
svg.append('rect')
.attr('class', 'tooltip-box')
.attr('x', xScale(d.year) - 55)
.attr('y', yScale(d.tonnage) - 28)
.attr('width', 110)
.attr('height', 22)
.attr('fill', '#ffffff')
.attr('stroke', '#333')
.attr('stroke-width', 1)
.attr('rx', 4);
// Create text
svg.append('text')
.attr('class', 'tooltip')
.attr('x', xScale(d.year))
.attr('y', yScale(d.tonnage) - 10)
.attr('text-anchor', 'middle')
.attr('font-size', '12px')
.style('font-family', 'Lora, serif')
.attr('fill', '#333')
.text(municipality + ': ' + d.tonnage.toFixed(2) + ' tons');
})
.on('mouseout', function() {
d3.select(this)
.attr('r', 4)
.attr('fill', colorScale(municipality));
svg.selectAll('.tooltip').remove();
svg.selectAll('.tooltip-box').remove();
});
});
// X-axis
const xAxis = svg.append('g')
.attr('transform', `translate(0,${height})`)
.call(d3.axisBottom(xScale).tickValues([-5, -3, 0, 3, 5]).tickFormat(d => {
if (d === 0) return 'Implementation Year';
if (d < 0) return `${Math.abs(d)}yr Pre`;
return `${d}yr Post`;
}));
xAxis.selectAll('text')
.style('font-family', 'Lora, serif')
.style('font-size', '13px');
xAxis.append('text')
.attr('x', width / 2)
.attr('y', 40)
.attr('dy', '1em')
.attr('fill', '#333')
.style('font-family', 'Montserrat, sans-serif')
.attr('font-size', '14px')
.attr('font-weight', '500')
.attr('text-anchor', 'middle')
.text('Years Since PAYT Adoption');
// Y-axis
const yAxis = svg.append('g')
.call(d3.axisLeft(yScale));
yAxis.selectAll('text')
.style('font-family', 'Lora, serif')
.style('font-size', '13px');
yAxis.append('text')
.attr('transform', 'rotate(-90)')
.attr('y', 0 - margin.left)
.attr('x', 0 - (height / 2))
.attr('dy', '1em')
.attr('fill', '#333')
.style('font-family', 'Montserrat, sans-serif')
.attr('font-size', '14px')
.attr('font-weight', '500')
.attr('text-anchor', 'middle')
.text('Tons per Household');
// Legend
const legend = svg.selectAll('.legend')
.data(['Hinsdale', 'Peru', 'Heath', 'Chicopee', 'Harvard'])
.enter()
.append('g')
.attr('class', 'legend')
.attr('transform', (d, i) => `translate(${width - 140}, ${10 + i * 20})`);
legend.append('line')
.attr('x1', 0)
.attr('x2', 20)
.attr('y1', 0)
.attr('y2', 0)
.attr('stroke', d => darkerColors[d])
.attr('stroke-width', 2.5);
legend.append('text')
.attr('x', 25)
.attr('y', 4)
.attr('font-size', '12px')
.style('font-family', 'Lora, serif')
.text(d => d);
document.querySelectorAll('.method-toggle').forEach(function (btn) {
var content = btn.parentElement.querySelector('.method-content');
btn.addEventListener('click', function () {
var expanded = btn.getAttribute('aria-expanded') === 'true';
btn.setAttribute('aria-expanded', String(!expanded));
if (!expanded) {
content.classList.add('open');
content.removeAttribute('hidden');
} else {
content.classList.remove('open');
// keep transition: collapse then hide after transition
setTimeout(function () { content.setAttribute('hidden', ''); }, 300);
}
});
});
// set inline min-height on .stats-fullpage so it fills remaining viewport below its top
function setStatsFullpageHeight() {
var section = document.querySelector('.stats-fullpage');
if (!section) return;
// measure distance from top of viewport to top of section
var rect = section.getBoundingClientRect();
// remaining viewport height below the section's top
var remaining = Math.max(window.innerHeight - rect.top, Math.round(window.innerHeight * 0.45)); // at least 45% viewport
// cap the computed height so the section doesn't become excessively tall on large screens
var cap = Math.round(window.innerHeight * 0.75); // no more than 75% of viewport
var applied = Math.min(remaining, cap);
// apply inline min-height to guarantee full-page feel without creating a huge gap
section.style.minHeight = applied + 'px';
// debug: uncomment to see values in console
// console.log('setStatsFullpageHeight', { rectTop: rect.top, remaining: remaining, cap: cap, applied: applied });
}
// Measure the actual banner height and publish it to CSS so the
// header can sit directly beneath the banner even when the banner
// grows to multiple lines.
function setBannerHeightVar() {
var banner = document.querySelector('.disclaim-banner');
if (!banner) return;
var h = banner.offsetHeight || 0;
// write the measured value as a CSS variable on :root
document.documentElement.style.setProperty('--top-banner-height', h + 'px');
}
// run after full page load and on resize (and when fonts/images settle)
window.addEventListener('load', function () { setBannerHeightVar(); setStatsFullpageHeight(); });
window.addEventListener('resize', function () { setBannerHeightVar(); setStatsFullpageHeight(); });
// run shortly after DOM ready in case load already occurred
setTimeout(function () { setBannerHeightVar(); setStatsFullpageHeight(); }, 120);
// Hide the nav when its contents no longer fit (prevents words being cut off)
function debounce(fn, wait) {
var t;
return function () { clearTimeout(t); t = setTimeout(fn, wait); };
}
function updateNavVisibility() {
var navList = document.querySelector('.site-nav-list');
var headerInner = document.querySelector('.header-inner');
if (!navList || !headerInner) return;
// ensure visible for measurement
navList.style.display = '';
navList.removeAttribute('aria-hidden');
// measure nav's natural width
var naturalWidth = navList.scrollWidth;
// compute available space for nav: from nav's left edge to header-inner right edge
var headerRect = headerInner.getBoundingClientRect();
var navRect = navList.getBoundingClientRect();
var available = Math.max(0, headerRect.right - navRect.left - 12); // small margin
// Only auto-hide on reasonably narrow viewports to avoid unexpected hiding on desktop
var smallViewportThreshold = 980; // px
var willOverflow = naturalWidth > (available - 2);
if (willOverflow && window.innerWidth <= smallViewportThreshold) {
navList.style.display = 'none';
navList.setAttribute('aria-hidden', 'true');
} else {
navList.style.display = '';
navList.setAttribute('aria-hidden', 'false');
}
}
var debouncedNavCheck = debounce(updateNavVisibility, 100);
// run on load, resize, and once fonts are ready (font load can change measurements)
window.addEventListener('load', function () { setBannerHeightVar(); debouncedNavCheck(); });
window.addEventListener('resize', function () { setBannerHeightVar(); debouncedNavCheck(); });
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(function () { setBannerHeightVar(); debouncedNavCheck(); });
}
// quick run after DOM ready to catch initial state
setTimeout(function () { setBannerHeightVar(); debouncedNavCheck(); }, 200);
});
</script>
</body>
</html>