Skip to content

Commit

Permalink
Generate uniform titles for maps and plots
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher87 committed Mar 6, 2024
1 parent b8aaa95 commit 37fad14
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/components/MainWindow/LinePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const LinePlot: React.FC<ILinePlotProps> = (props) => {
);
}

const chartTitle = `${regionLongname} - ${varLongname}`;
const yAxisTitle = props.selectedSatelliteVariable.labelPlotYaxis;

// WARNING: It is _critical_ that the data is copied before passing to
Expand Down Expand Up @@ -137,24 +136,17 @@ const LinePlot: React.FC<ILinePlotProps> = (props) => {
},
];

const ytdSeriesLastNonNullPoint = ytdSeries.filter(p => p[1] !== null).slice(-1)[0];
const ytdSeriesLastDate = new Date(ytdSeriesLastNonNullPoint[0]);
const chartOptions: Highcharts.Options = {
chart: {
height: '95%',
height: '90%',
type: 'line',
},
accessibility: {
// TODO: Add units text
description: `${varLongname} plotted over the current water year.`,
},
title: {
text: chartTitle,
style: {fontSize: '20px'},
},
subtitle: {
text: `As of ${ytdSeriesLastDate.toISOString().split('T')[0]}`,
style: {fontSize: '16px'},
text: undefined,
},
tooltip: {
shared: true,
Expand Down
10 changes: 10 additions & 0 deletions src/components/MainWindow/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ const Tile: React.FC<ITileProps> = (props) => {
FallbackComponent={ErrorFallbackTileComponent}
resetKeys={[selectedTileType, selectedRegion, selectedSatelliteVariableId]}
>
<div className='tile-title'>
<h1><b>{selectedTileType == "map" ? selectedSatelliteVariable.longName : selectedSatelliteVariable.longNamePlot}</b></h1>

Check failure on line 72 in src/components/MainWindow/Tile.tsx

View workflow job for this annotation

GitHub Actions / Run tests

Expected '===' and instead saw '=='
<h2><b>{selectedRegion.longName}</b> as of <b>{selectedSatelliteVariable.lastDateWithData}</b></h2>
<h3>
Climatology calculated over{' '}
<b>{selectedSatelliteVariable.historicWaterYearRange[0]}</b>
{' '}to{' '}
<b>{selectedSatelliteVariable.historicWaterYearRange[1]}</b>
</h3>
</div>
<Suspense fallback={<LoadingIcon size={200} />}>
{content}
</Suspense>
Expand Down
16 changes: 16 additions & 0 deletions src/style/Tile.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@
flex-direction: column;
}

.tile-title h1, .tile-title h2, .tile-title h3 {
text-align: center;
line-height: 1em;
margin: 0;
}
.tile-title h1 {
font-size: 1.5em;
}
.tile-title h2 {
font-size: 1.3em;
}
.tile-title h3 {
font-size: 1em;
}

.tile-citation {
/* line-height */
font-size: 14px;
background: white;
}
Expand Down

0 comments on commit 37fad14

Please sign in to comment.