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

fix: Prefare polish -- "via" diagram labels need abbreviating #1968

Merged
merged 10 commits into from
Feb 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const abbreviationList: {[string: string]: string} = {
"Government Center": "Gov't Center",
"Hynes Convention Center": "Hynes",
"Massachusetts Avenue": "Mass Ave",
"Tufts Medical Center": "Tufts Medical Ctr"
"Tufts Medical Center": "Tufts Medical Ctr",
"…via Government Center": "…via Gov't Center",
"…via Downtown Crossing": "…via Downtown Xng"
}

type DisruptionDiagramData =
Expand Down Expand Up @@ -709,8 +711,10 @@ const DisruptionDiagram: ComponentType<DisruptionDiagramData> = (props) => {
// First, scale x. Then, check if it needs abbreviating. Then scale y, given the abbreviation
const xScaleFactor = fullWidth / unscaledWidth;

const needsAbbreviating = !doAbbreviate &&
unscaledHeight * xScaleFactor + getEmphasisHeight(xScaleFactor) * simulationTransform > diagramContainerHeight;
// If xScaleFactor is less than 1, let's try abbreviating.
// Or, if the x scaling constrains the height, abbreviate
const needsAbbreviating = !doAbbreviate && (xScaleFactor < 1 ||
unscaledHeight * xScaleFactor + getEmphasisHeight(xScaleFactor) * simulationTransform > diagramContainerHeight);
if (needsAbbreviating) {
setDoAbbreviate(true);
// now scale y, which requires re-running this effect
Expand Down
Loading