Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
test-graph-view | added force map update on conditions map to trigger…
Browse files Browse the repository at this point in the history
… "referesh"
  • Loading branch information
marcosantiagomuro committed Oct 8, 2023
1 parent 2505497 commit 58d656f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/src/Components/Map/ForceMapUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ForceMapUpdate: React.FC<Props> = ({ triggerUpdate, position }) => {
const map = useMap();

useEffect(() => {
console.log('hello');
map.invalidateSize();
}, [triggerUpdate]);

Expand Down
11 changes: 8 additions & 3 deletions frontend/src/Components/RoadConditions/ConditionsMap.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import MapWrapper from '../Map/MapWrapper';
import { FC } from 'react';
import '../../css/road_conditions.css';
import ForceMapUpdate from '../Map/ForceMapUpdate';

interface Props {}
interface Props {
triggerUpdate: number;
}

const ConditionsMap: FC<Props> = () => {
const ConditionsMap: FC<Props> = ({ triggerUpdate }) => {
//TODO trigger redrwaw the plot

return (
<div className="road-conditions-map">
<MapWrapper></MapWrapper>
<MapWrapper>
<ForceMapUpdate triggerUpdate={triggerUpdate} />
</MapWrapper>
</div>
);
};
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/pages/RoadConditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getConditionsWay } from '../queries/conditions';
const RoadConditions = () => {
const [wayData, setWayData] =
useState<ChartData<'scatter', number[], number>>();
const [triggerUpdate, setTriggerUpdate] = useState<number>(0);

console.log(wayData);

Expand Down Expand Up @@ -60,9 +61,12 @@ const RoadConditions = () => {
sizes={[45, 55]}
minSize={150}
snapOffset={10}
onDragEnd={() => {
setTriggerUpdate((prev) => prev + 1);
}}
// dragInterval={50}
>
<ConditionsMap />
<ConditionsMap triggerUpdate={triggerUpdate} />
<ConditionsGraph data={wayData} />
</Split>
</GraphProvider>
Expand Down

0 comments on commit 58d656f

Please sign in to comment.