Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Green line slow zones #911

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion modules/slowzones/SlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export function SlowZonesDetails() {
const totalSlowTimeReady =
!delayTotals.isError && delayTotals.data && startDateUTC && endDateUTC && lineShort && line;
const segmentsReady = !allSlow.isError && allSlow.data && startDateUTC && lineShort;
const canShowSlowZonesMap = lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange';
const canShowSlowZonesMap =
lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange' || lineShort === 'Green';
const isDesktop = useBreakpoint('lg');

if (!endDateUTC || !startDateUTC) {
Expand Down
4 changes: 3 additions & 1 deletion modules/slowzones/SystemSlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export function SystemSlowZonesDetails({ showTitle = false }: SystemSlowZonesDet

const [lineShort, setLineShort] = useState<LineShort>('Red');
const line = `line-${lineShort.toLowerCase()}` as Line;
const canShowSlowZonesMap = lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange';
const canShowSlowZonesMap =
lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange' || lineShort === 'Green';
const isDesktop = useBreakpoint('lg');

const {
Expand Down Expand Up @@ -116,6 +117,7 @@ export function SystemSlowZonesDetails({ showTitle = false }: SystemSlowZonesDet
Red: 'Red',
Orange: 'Orange',
Blue: 'Blue',
Green: 'Green',
})}
/>
</WidgetDiv>
Expand Down
8 changes: 8 additions & 0 deletions modules/slowzones/charts/TotalSlowTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export const TotalSlowTime: React.FC<TotalSlowTimeProps> = ({
pointRadius: 0,
tension: 0.1,
},
{
label: `Green Line (D)`,
data: data?.map((d) => (d['Green'] / 60).toFixed(2)),
borderColor: LINE_COLORS['line-green'],
backgroundColor: LINE_COLORS['line-green'],
pointRadius: 0,
tension: 0.1,
},
];
return (
<ChartBorder>
Expand Down
20 changes: 20 additions & 0 deletions modules/slowzones/map/SlowZonesMap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,29 @@
},
];

const slowZonesGreenResponses: SlowZoneResponse[] = [
{

Check failure on line 42 in modules/slowzones/map/SlowZonesMap.stories.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

Type '{ color: "Green"; fr_id: string; to_id: string; start: string; end: string; delay: number; mean_metric: number; baseline: number; duration: number; }' is missing the following properties from type 'SlowZoneResponse': latest_delay, previous_delay
color: 'Green',
fr_id: '70257',
to_id: '70508',
start: '2023-03-12T00:00:00Z',
end: '2023-04-01T00:00:00Z',
delay: 42.5,
mean_metric: 172.929,
baseline: 135.0,
duration: 20,
},
];

export const Primary = () => {
return (
<>
<SlowZonesMap
lineName="Green"
slowZones={slowZonesGreenResponses}
direction="vertical"
speedRestrictions={[]}
/>
<SlowZonesMap
lineName="Red"
slowZones={slowZonesResponses}
Expand Down
2 changes: 1 addition & 1 deletion modules/slowzones/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const SLOW_ZONES_LINES = ['Red', 'Blue', 'Orange'] as const;
const SLOW_ZONES_LINES = ['Red', 'Blue', 'Orange', 'Green'] as const;

export type SlowZonesLineName = (typeof SLOW_ZONES_LINES)[number];
Loading