adding optional parameters to the Single set area chart to allow for clamping the graph so that large numbers do cause it to zoom etremely far out

This commit is contained in:
csawatzky 2026-04-14 16:01:52 -06:00
parent 0556fe2d8b
commit f7b5a59c98
2 changed files with 8 additions and 3 deletions

View file

@ -38,10 +38,12 @@ interface Props {
multiGraphZoom?: (domain: number[] | string[]) => void; multiGraphZoom?: (domain: number[] | string[]) => void;
colourAboveZero?: ColourData colourAboveZero?: ColourData
colourBelowZero?: ColourData colourBelowZero?: ColourData
minY?: string | number
maxY?: string | number
} }
export default function SingleSetAreaChart(props: Props) { export default function SingleSetAreaChart(props: Props) {
const { data, maxRef, minRef, newXDomain, multiGraphZoom, yAxisLabel, colourAboveZero, colourBelowZero, tooltipLabel, tooltipUnit } = props; const { data, maxRef, minRef, newXDomain, multiGraphZoom, yAxisLabel, colourAboveZero, colourBelowZero, tooltipLabel, tooltipUnit, minY, maxY } = props;
const [xDomain, setXDomain] = useState<string[] | number[]>(["dataMin", "dataMax"]); const [xDomain, setXDomain] = useState<string[] | number[]>(["dataMin", "dataMax"]);
const [refLeft, setRefLeft] = useState<number | undefined>(); const [refLeft, setRefLeft] = useState<number | undefined>();
const [refRight, setRefRight] = useState<number | undefined>(); const [refRight, setRefRight] = useState<number | undefined>();
@ -152,7 +154,8 @@ export default function SingleSetAreaChart(props: Props) {
/> />
<YAxis <YAxis
type="number" type="number"
domain={["auto", "auto"]} allowDataOverflow
domain={[minY ?? "auto", maxY ?? "auto"]}
label={{ label={{
value: yAxisLabel, value: yAxisLabel,
position: "insideLeft", position: "insideLeft",

View file

@ -211,6 +211,8 @@ export default function GateDeltaTempGraph(props: Props){
/> />
<SingleSetAreaChart <SingleSetAreaChart
data={data} data={data}
minY={-40} //-40C is the same as -40F
maxY={(user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? 104 : 40)}
tooltipLabel="Delta Temp" tooltipLabel="Delta Temp"
tooltipUnit={user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C"} tooltipUnit={user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C"}
yAxisLabel={"Delta T" + (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C")} yAxisLabel={"Delta T" + (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT ? " °F" : " °C")}