Skip to content

Commit d35b89f

Browse files
Release SlowZones (#186)
* Sort Slowzones * fix build * add derailments * add emoji * add alt text * add FAQ * add css * change faq css * tweak css * Warning icon fix maybe (#187) * Add attribution * allow dashboard links that are 18 months * chance faq text Co-authored-by: Preston Mueller <skierjunk@gmail.com>
1 parent 6a6f8f0 commit d35b89f

6 files changed

Lines changed: 359 additions & 32 deletions

File tree

src/App.css

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,72 @@ button:disabled,
622622
font-size: 14px;
623623
}
624624

625+
.derailment-footer {
626+
padding-left: 4em;
627+
font-size: 14px;
628+
display: flex;
629+
padding-bottom: 10px;
630+
}
631+
632+
.derailment-footer-text {
633+
align-self: center;
634+
}
635+
636+
.accordion > li {
637+
list-style: none;
638+
}
639+
640+
.accordion > a {
641+
text-decoration: none;
642+
}
643+
644+
.accordion {
645+
padding-top: 10px;
646+
max-width: 1000px;
647+
height: auto;
648+
overflow: hidden;
649+
font-size: 14px;
650+
padding-left: 2em;
651+
}
652+
653+
.accordion .accordion-item-header{
654+
display: flex;
655+
align-items: center;
656+
flex-direction: row;
657+
padding: 10px;
658+
border-bottom: 1px solid #cecece;
659+
position: relative;
660+
color: black;
661+
font-weight: 600;
662+
}
663+
664+
.accordion .accordion-item-header:after {
665+
content: "•";
666+
position: absolute;
667+
right: 0;
668+
display: none;
669+
font-size: 14px;
670+
}
671+
672+
.accordion .accordion-item-header .accordion-item-active-marker {
673+
margin-left: auto;
674+
}
675+
676+
.accordion .accordion-text {
677+
overflow: hidden;
678+
max-height: 0;
679+
transition: max-height 300ms ease-in-out;
680+
font-style: italic;
681+
}
682+
683+
.accordion .accordion-text p {
684+
padding: 10px;
685+
}
686+
687+
.accordion-item:target .accordion-text{
688+
max-height: 300px;
689+
}
690+
691+
.accordion-item:target .accordion-item-header:after {
692+
display: block;
693+
}

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { SingleDaySet, AggregateSet } from './ChartSets';
33
import StationConfiguration from './StationConfiguration';
4-
import { withRouter } from 'react-router-dom';
4+
import { Link, withRouter } from 'react-router-dom';
55
import { lookup_station_by_id, get_stop_ids_for_stations, line_name } from './stations';
66
import { trainDateRange, busDateRange } from './constants';
77
import { recognize } from './alerts/AlertFilter';
@@ -394,7 +394,7 @@ class App extends React.Component {
394394
return <div className="main-column">
395395
<div className="empty-state">
396396
{error_message && <>{error_message}</>}
397-
{/* <div id="slowzone-container"> Check out our new <Link to='/slowzones'><button id="slowzone-button">Slow Zone Tracker</button></Link></div> */}
397+
<div id="slowzone-container"> Check out our new <Link to='/slowzones'><button id="slowzone-button">Slow Zone Tracker</button></Link></div>
398398
{!error_message && <>See MBTA rapid transit performance data, including travel times between stations, headways,
399399
and dwell times, for any given day. <span style={{fontWeight: "bold"}}>Select a line, station pair, and date above to get started.</span><div style={{marginTop: 10}}>Looking for something interesting? <span style={{fontWeight: "bold"}}>Try one of these dates:</span></div>
400400
<Select

src/OpenSource.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ export default function OpenSource() {
175175
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
176176
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />
177177
SOFTWARE.<br />
178-
178+
179+
180+
<hr />
181+
Highcharts:<br />
182+
Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)<br />
183+
<br />
184+
Copyright (c) 2022 Highsoft<br />
179185
</div>
180186
);
181187
}

src/constants.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,3 +1206,22 @@ export const stations = {
12061206
]
12071207
}
12081208
};
1209+
1210+
export const derailments = {
1211+
Red: {
1212+
start: "2019-06-11T00:00:00Z",
1213+
end: "2019-09-21T00:00:00Z",
1214+
color: "Red",
1215+
title: "Red line derailment",
1216+
description:
1217+
"A red line train derailment at JFK/UMass destroyed important signal infrastructure that took months to repair.",
1218+
},
1219+
Orange: {
1220+
start: "2021-03-16T00:00:00Z",
1221+
end: "2021-04-16T00:00:00Z",
1222+
color: "Orange",
1223+
title: "Orange line derailment",
1224+
description:
1225+
"An orange line train derailment damaged a switch, requiring track replacement. A speed restriction followed in order to give the new track time to settle.",
1226+
},
1227+
};

src/slowzones/SlowZones.tsx

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useEffect, useMemo, useState } from "react";
22
import { ChartView, Direction, SlowZone } from "./types";
3-
import { useHistory, useLocation } from "react-router-dom";
3+
import { Link, useHistory, useLocation } from "react-router-dom";
44
import Highcharts from "highcharts";
55
import HighchartsReact from "highcharts-react-official";
66
import xrange from "highcharts/modules/xrange";
77
import exporting from "highcharts/modules/exporting";
8-
8+
import annotations from "highcharts/modules/annotations";
99
import {
1010
formatSlowZones,
1111
generateLineOptions,
@@ -18,6 +18,7 @@ import moment from "moment";
1818

1919
xrange(Highcharts);
2020
exporting(Highcharts);
21+
annotations(Highcharts);
2122

2223
export const optionsForSelect = () => {
2324
const lines = subway_lines();
@@ -37,6 +38,7 @@ function useQuery() {
3738
}
3839

3940
export const SlowZones = () => {
41+
document.title = "Data Dashboard - Slow zones";
4042
const params = useQuery();
4143
const history = useHistory();
4244
const [options, setOptions] = useState<Highcharts.Options>();
@@ -160,12 +162,104 @@ export const SlowZones = () => {
160162
/>
161163
{options && (
162164
<HighchartsReact
163-
containerProps={{ style: { height: "75vh", paddingTop: "5px" } }}
165+
containerProps={{
166+
style: { "min-height": "83vh", paddingTop: "1em" },
167+
}}
164168
options={options}
165169
highcharts={Highcharts}
166170
immutable={true}
167171
/>
168172
)}
173+
{chartView === "xrange" && (
174+
<div className="derailment-footer">
175+
⚠️
176+
<span className="derailment-footer-text">
177+
= Affected by a derailment
178+
</span>
179+
</div>
180+
)}
181+
182+
<div className="accordion">
183+
<li className="accordion-item" id="what-is-this">
184+
<a className="accordion-item-header" href="#what-is-this">
185+
What is this?
186+
</a>
187+
<div className="accordion-text">
188+
<p>
189+
This is a tool to help find and track slow zones. That is, areas
190+
where trains have lower-than-usual speeds due to track conditions,
191+
signal issues, or other infrastructure problems.
192+
</p>
193+
</div>
194+
</li>
195+
<li className="accordion-item" id="how-do-we-calculate-this">
196+
<a className="accordion-item-header" href="#how-do-we-calculate-this">
197+
How do we calculate this?
198+
</a>
199+
<div className="accordion-text">
200+
<p>
201+
We look at the daily median travel time + dwell time for each
202+
segment along a route. Whenever that trip time is at least 10%
203+
slower than the baseline for 3 or more days in a row, it gets
204+
flagged as a slow zone. Currently, our baseline is the median
205+
value in our data, which goes back to 2016. It’s not a perfect
206+
system, but various algorithmic improvements are in the works.
207+
Frontend
208+
</p>
209+
</div>
210+
</li>
211+
<li className="accordion-item" id="how-do-we-build-this">
212+
<a className="accordion-item-header" href="#how-do-we-build-this">
213+
How do we build this?
214+
</a>
215+
<div className="accordion-text">
216+
<p>
217+
ReactJS + HighchartsJS and Highcharts Gantt from
218+
<a href="highcharts.com"> Highcharts</a> <br />
219+
See our <Link to="/opensource"> Attribution</Link> page for more
220+
information.
221+
</p>
222+
</div>
223+
</li>
224+
<li className="accordion-item" id="why-did-we-build-this">
225+
<a className="accordion-item-header" href="#why-did-we-build-this">
226+
Why did we build this?
227+
</a>
228+
<div className="accordion-text">
229+
<p>
230+
There’s power in data, but it’s only useful when you can tell a
231+
story. Slow zones are a nice story to tell: they tie our
232+
observable results to a cause. With so much data available, it can
233+
be difficult to find the interesting bits. So we’ve built this
234+
tool to help us locate and track this type of issue (slow zones),
235+
and monitor the severity over time.
236+
</p>
237+
</div>
238+
</li>
239+
<li className="accordion-item" id="how-can-you-use-this">
240+
<a className="accordion-item-header" href="#how-can-you-use-this">
241+
How can you use this?
242+
</a>
243+
<div className="accordion-text">
244+
<p>
245+
Share it. Bring the data to public meetings. Pressure the T to do
246+
better, but also give them credit where it’s due.
247+
</p>
248+
</div>
249+
</li>
250+
<li className="accordion-item" id="green-line">
251+
<a className="accordion-item-header" href="#green-line">
252+
What about the Green Line?
253+
</a>
254+
<div className="accordion-text">
255+
<p>
256+
Due to variable traffic, much of the Green Line doesn’t have
257+
consistent enough trip times to measure. As for the main trunk and
258+
the D line? Coming “soon”.
259+
</p>
260+
</div>
261+
</li>
262+
</div>
169263
</>
170264
);
171265
};

0 commit comments

Comments
 (0)