Skip to content

Commit

Permalink
accept latest timeseries from store
Browse files Browse the repository at this point in the history
  • Loading branch information
adamscarberry committed Jul 19, 2023
1 parent 5e9d137 commit bfdea22
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/app-components/charts/dam-profile-chart/chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRef, useEffect, useState } from 'react';
import DamProfileChart from '../../../_charts/dam-profile-chart/dam-profile-chart';
import { mapObjectArrayByKey } from '../../../helpers/misc-helpers';

export default function ReactDamProfileChart({ location }) {
export default function ReactDamProfileChart({ location, timeseries }) {
const debug = parseInt(import.meta.env.VITE_APP_DEBUG);
const ref = createRef(); // element where DamProfileChart will be rendered
const [info, setInfo] = useState(null); // information DamProfileChart needs to draw itself
Expand Down Expand Up @@ -46,10 +46,8 @@ export default function ReactDamProfileChart({ location }) {
),
'slug'
);
// console.log('-----');
// console.log(levelsMap);

const timeseriesMap = mapObjectArrayByKey(location?.timeseries, 'label');
const timeseriesMap = mapObjectArrayByKey(timeseries, 'label');

const _info = {
// levels: [
Expand Down Expand Up @@ -92,7 +90,7 @@ export default function ReactDamProfileChart({ location }) {
null,
};
setInfo(_info);
}, [location, location.timeseries]);
}, [location, timeseries]);

useEffect(() => {
if (info) {
Expand All @@ -102,7 +100,7 @@ export default function ReactDamProfileChart({ location }) {
}
DamProfileChart(info, ref.current);
}
}, [info, ref]);
}, [info, ref, debug]);

return (
<>
Expand Down

0 comments on commit bfdea22

Please sign in to comment.