Skip to content

Commit

Permalink
add effect conditions to date guide effect
Browse files Browse the repository at this point in the history
  • Loading branch information
NXXR committed Jul 11, 2023
1 parent 68160db commit 0869bb0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/SimulationChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ export default function SimulationChart(): JSX.Element {
// Effect to add Guide when date selected
useEffect(
() => {
// Skip effect if chart is not initialized yet or no date is selected
if (!chartRef.current || !selectedDate) return;
// Skip effect if chart (or root) is not initialized yet or no date is selected
if (!chartRef.current || !rootRef.current || !selectedDate) return;

// Get xAxis from chart
const xAxis = chartRef.current.xAxes.getIndex(0) as DateAxis<AxisRendererX>;
Expand Down Expand Up @@ -398,7 +398,7 @@ export default function SimulationChart(): JSX.Element {
day: '2-digit',
}),
location: 0.5,
background: RoundedRectangle.new(rootRef.current as Root, {
background: RoundedRectangle.new(rootRef.current, {
fill: color(theme.palette.primary.main),
}),
// Put Label to the topmost layer to make sure it is drawn on top of the axis tick labels
Expand All @@ -410,8 +410,8 @@ export default function SimulationChart(): JSX.Element {
xAxis.axisRanges.removeValue(range);
};
},
// Re-run effect when selection changes (date/scenario/compartment/district) (theme and translation do not change after initialization)
[selectedDate, selectedScenario, selectedCompartment, selectedDistrict, theme, t, i18n.language]
// Re-run effect when selection changes (date/scenario/compartment/district) or when the active scenarios/filters change (theme and translation do not change after initialization)
[selectedDate, selectedScenario, selectedCompartment, selectedDistrict, activeScenarios, groupFilterList, theme, t, i18n.language]
);

// Effect to update Simulation and case data
Expand Down

0 comments on commit 0869bb0

Please sign in to comment.