-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #456 from openclimatefix/issue/identical-zoom-for-…
…all-charts Feat: global zoom for all charts
- Loading branch information
Showing
8 changed files
with
170 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// tools for the chart | ||
import { ChartData } from "../charts/remix-line"; | ||
|
||
// get the zoomYMax for either sites or national view | ||
export const getZoomYMax = (filteredPreppedData: ChartData[]) => { | ||
// if no probabilistic max value, get the max between the generation and the forecast as the zoomYMax | ||
if (!filteredPreppedData.some((d) => d.PROBABILISTIC_UPPER_BOUND)) { | ||
let genMax = | ||
filteredPreppedData | ||
.map((d) => d.GENERATION_UPDATED || d.GENERATION) | ||
.filter((n) => typeof n === "number") | ||
.sort((a, b) => Number(b) - Number(a))[0] || 0; | ||
let forecastMax = | ||
filteredPreppedData | ||
.map((d) => d.PAST_FORECAST || d.FORECAST) | ||
.sort((a, b) => Number(b) - Number(a))[0] || 0; | ||
return Math.max(genMax, forecastMax); | ||
} else { | ||
return filteredPreppedData | ||
.map((d) => d.PROBABILISTIC_UPPER_BOUND || d.GENERATION) | ||
.filter((n) => typeof n === "number") | ||
.sort((a, b) => Number(b) - Number(a))[0]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters