Skip to content

Commit

Permalink
Final report formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
linda-baker committed Dec 19, 2024
1 parent 53fc64b commit e3cb354
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const LaneDirectionDistanceGraph: React.FC<LaneDirectionDistanceGraphProps> = ({
return (
<Box sx={{ display: 'flex', justifyContent: 'center', width: '100%', height: 'auto' }}>
<Box>
<Typography variant="h6" align="center" sx={{ mt: 2 }}>Lane Direction Distance Distribution</Typography>
<Typography variant="h6" align="center" sx={{ mt: 2 }}>Deviation from Lane Centerline Distribution</Typography>
<BarChart
width={750}
height={450}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const LaneDirectionHeadingGraph: React.FC<LaneDirectionHeadingGraphProps> = ({ d

return (
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', height: 'auto' }}>
<Typography variant="h6" align="center" sx={{ mt: 2 }}>Lane Direction Heading Distribution</Typography>
<Typography variant="h6" align="center" sx={{ mt: 2 }}>Deviation from Lane Heading Distribution</Typography>
<BarChart
width={750}
height={450}
Expand Down
33 changes: 27 additions & 6 deletions gui/src/components/reports/pdf-generator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const captureGraph = async (pdf: jsPDF, elementId: string, position: { x: number
const addPageWithNumber = (pdf: jsPDF, pageNumber: number) => {
pdf.addPage();
pdf.setFontSize(10);
pdf.setFont('helvetica', 'normal');
pdf.text(`Page ${pageNumber}`, pdf.internal.pageSize.getWidth() - 20, pdf.internal.pageSize.getHeight() - 10);
};

Expand Down Expand Up @@ -96,6 +97,9 @@ export const generatePdf = async (report: ReportMetadata, setLoading: (loading:

pdf.setFontSize(36);
pdf.text('Conflict Monitor Report', pdfWidth / 2, pdfHeight / 2 - 50, { align: 'center' });
pdf.setFontSize(18);
pdf.text(`Intersection ${report?.intersectionID}`,
pdfWidth / 2, pdfHeight / 2 - 38, { align: 'center' });
pdf.setFontSize(12);
pdf.text(`${report?.reportStartTime ? format(new Date(report.reportStartTime), "yyyy-MM-dd' T'HH:mm:ss'Z'") : ''} - ${report?.reportStopTime ? format(new Date(report.reportStopTime), "yyyy-MM-dd' T'HH:mm:ss'Z'") : ''}`,
pdfWidth / 2, pdfHeight / 2 - 30, { align: 'center' });
Expand Down Expand Up @@ -147,7 +151,7 @@ export const generatePdf = async (report: ReportMetadata, setLoading: (loading:
pdf.text('Connection of Travel', pdf.internal.pageSize.getWidth() / 2, 20, { align: 'center' });
await captureGraph(pdf, 'connection-of-travel-graph', { x: 0, y: 25 }, setProgress, totalGraphs, ++currentGraph, signal);
setPdfDescriptionFormatting(pdf);
pdf.text('The number of events triggered when vehicles passed through the intersection.',
pdf.text('The number of events triggered when a vehicle entered and exited the intersection.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2, { align: 'center' });
addPageWithNumber(pdf, currentPage++);

Expand All @@ -170,15 +174,20 @@ export const generatePdf = async (report: ReportMetadata, setLoading: (loading:
pdf.text('A composite view comparing vehicles that stopped before passing through the intersection versus those that did not.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2, { align: 'center' });

await captureGraph(pdf, 'signal-state-conflict-graph', { x: 0, y: pdfHeight / 2 + 10 }, setProgress, totalGraphs, ++currentGraph, signal);
await captureGraph(pdf, 'signal-state-conflict-graph', { x: 0, y: pdfHeight / 2 + 5 }, setProgress, totalGraphs, ++currentGraph, signal);
setPdfDescriptionFormatting(pdf);
pdf.text('The number of times the system detected contradictory signal states, such as two perpendicular green lights.',
pdf.text('The number of times the system detected contradictory signal states, such as conflicting green lights.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight - 20, { align: 'center' });
pdf.text('Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight - 15, { align: 'center' });
addPageWithNumber(pdf, currentPage++);
addPageWithNumber(pdf, currentPage++);

await captureGraph(pdf, 'time-change-details-graph', { x: 0, y: 25 }, setProgress, totalGraphs, ++currentGraph, signal);
pdf.text('The number of times the system detected differences in timing between expected and actual signal state changes.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2, { align: 'center' });
pdf.text('Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2 + 5, { align: 'center' });

addPageWithNumber(pdf, currentPage++);

setPdfSectionTitleFormatting(pdf);
Expand All @@ -187,17 +196,24 @@ export const generatePdf = async (report: ReportMetadata, setLoading: (loading:
setPdfDescriptionFormatting(pdf);
pdf.text('The number of events flagging a mismatch between intersection ID and road regulator ID.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2, { align: 'center' });
pdf.text('Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2 + 5, { align: 'center' });
addPageWithNumber(pdf, currentPage++);

setPdfItemTitleFormatting(pdf);
pdf.text('MAP', pdf.internal.pageSize.getWidth() / 2, 20, { align: 'center' });
await captureGraph(pdf, 'map-broadcast-rate-graph', { x: 0, y: 25 }, setProgress, totalGraphs, ++currentGraph, signal);
setPdfDescriptionFormatting(pdf);
pdf.text('The number of times the system flagged more or less frequent MAP broadcasts than the expected rate of 1 Hz.',
pdf.text('The number of broadcast windows in which the system flagged more or less frequent MAP broadcasts than the expected',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2, { align: 'center' });
pdf.text('rate of 1 Hz. Each day has a total of 8,640 broadcast windows. Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2 + 5, { align: 'center' });
await captureGraph(pdf, 'map-minimum-data-graph', { x: 0, y: pdfHeight / 2 + 10 }, setProgress, totalGraphs, ++currentGraph, signal);
pdf.text('The number of times the system flagged MAP messages with missing or incomplete data.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight - 15, { align: 'center' });
pdf.text('Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight - 10, { align: 'center' });


// Process and add MAP Missing Data Elements page
if (report?.latestMapMinimumDataEventMissingElements?.length) {
Expand All @@ -223,11 +239,16 @@ export const generatePdf = async (report: ReportMetadata, setLoading: (loading:
pdf.text('SPaT', pdf.internal.pageSize.getWidth() / 2, 20, { align: 'center' });
await captureGraph(pdf, 'spat-broadcast-rate-graph', { x: 0, y: 25 }, setProgress, totalGraphs, ++currentGraph, signal);
setPdfDescriptionFormatting(pdf);
pdf.text('The number of times the system flagged more or less frequent SPaT broadcasts than the expected rate of 10 Hz.',
pdf.text('The number of broadcast windows in which the system flagged more or less frequent SPaT broadcasts than the expected',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2, { align: 'center' });
pdf.text('rate of 10 Hz. Each day has a total of 8,640 broadcast windows. Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight / 2 + 5, { align: 'center' });
await captureGraph(pdf, 'spat-minimum-data-graph', { x: 0, y: pdfHeight / 2 + 10 }, setProgress, totalGraphs, ++currentGraph, signal);
pdf.text('The number of times the system flagged SPaT messages with missing or incomplete data.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight - 15, { align: 'center' });
pdf.text('Lower numbers indicate better performance.',
pdf.internal.pageSize.getWidth() / 2, pdfHeight - 10, { align: 'center' });


// Process and add SPaT Missing Data Elements page
if (report?.latestSpatMinimumDataEventMissingElements?.length) {
Expand Down
23 changes: 15 additions & 8 deletions gui/src/components/reports/report-details-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ const ReportDetailsModal = ({ open, onClose, report }: ReportDetailsModalProps)
<ConnectionOfTravelGraph data={connectionOfTravelEventCounts} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of events triggered when vehicles passed through the intersection.
The number of events triggered when a vehicle entered and exited the intersection.
</Typography>

<Box id="valid-connection-of-travel-graph" sx={{ display: 'flex', justifyContent: 'center' }}>
Expand Down Expand Up @@ -297,14 +297,16 @@ const ReportDetailsModal = ({ open, onClose, report }: ReportDetailsModalProps)
<SignalStateConflictGraph data={signalStateConflictEventCount} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of times the system detected contradictory signal states, such as two perpendicular green lights.
The number of times the system detected contradictory signal states, such as conflicting green lights.<br />
Lower numbers indicate better performance.
</Typography>

<Box id="time-change-details-graph" sx={{ display: 'flex', justifyContent: 'center' }}>
<TimeChangeDetailsGraph data={timeChangeDetailsEventCount} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of times the system detected differences in timing between expected and actual signal state changes.
The number of times the system detected differences in timing between expected and actual signal state changes.<br />
Lower numbers indicate better performance.
</Typography>

<Typography variant="h4" align="center" sx={{ mt: 4 }}>Intersection Reference Alignments Per Day</Typography>
Expand All @@ -313,7 +315,8 @@ const ReportDetailsModal = ({ open, onClose, report }: ReportDetailsModalProps)
<IntersectionReferenceAlignmentGraph data={intersectionReferenceAlignmentEventCounts} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of events flagging a mismatch between intersection ID and road regulator ID.
The number of events flagging a mismatch between intersection ID and road regulator ID.<br />
Lower numbers indicate better performance.
</Typography>

<Typography variant="h4" align="center" sx={{ mt: 4 }}>MAP</Typography>
Expand All @@ -322,14 +325,16 @@ const ReportDetailsModal = ({ open, onClose, report }: ReportDetailsModalProps)
<MapBroadcastRateGraph data={mapBroadcastRateEventCount} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of times the system flagged more or less frequent MAP broadcasts than the expected rate of 1 Hz.
The number of broadcast windows in which the system flagged more or less frequent MAP broadcasts than the expected rate of 1 Hz.
Each day has a total of 8,640 broadcast windows. Lower numbers indicate better performance.
</Typography>

<Box id="map-minimum-data-graph" sx={{ display: 'flex', justifyContent: 'center' }}>
<MapMinimumDataGraph data={mapMinimumDataEventCount} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of times the system flagged MAP messages with missing or incomplete data.
The number of times the system flagged MAP messages with missing or incomplete data.<br />
Lower numbers indicate better performance.
</Typography>

{mapMissingElements.length > 0 && renderList('MAP Missing Data Elements', mapMissingElements)}
Expand All @@ -340,14 +345,16 @@ const ReportDetailsModal = ({ open, onClose, report }: ReportDetailsModalProps)
<SpatBroadcastRateGraph data={spatBroadcastRateEventCount} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of times the system flagged more or less frequent SPaT broadcasts than the expected rate of 10 Hz.
The number of broadcast windows in which the system flagged more or less frequent SPaT broadcasts than the expected rate of 10 Hz.
Each day has a total of 8,640 broadcast windows. Lower numbers indicate better performance.
</Typography>

<Box id="spat-minimum-data-graph" sx={{ display: 'flex', justifyContent: 'center' }}>
<SpatMinimumDataGraph data={spatMinimumDataEventCount} getInterval={getInterval} />
</Box>
<Typography variant="body2" align="center" sx={{ mt: 0.5, mb: 6, fontStyle: 'italic' }}>
The number of times the system flagged SPaT messages with missing or incomplete data.
The number of times the system flagged SPaT messages with missing or incomplete data.<br />
Lower numbers indicate better performance.
</Typography>

{spatMissingElements.length > 0 && renderList('SPaT Missing Data Elements', spatMissingElements)}
Expand Down

0 comments on commit e3cb354

Please sign in to comment.