Skip to content

Commit

Permalink
Refactor goal year extraction using Date object
Browse files Browse the repository at this point in the history
  • Loading branch information
lilia1891 committed Oct 25, 2024
1 parent 65b0e89 commit 27ecf6b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/indicators/IndicatorVisualisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ const generateTrendTrace = (indicator, traces, goals, i18n) => {
const highestDataYear = traces[0].y[traces[0].y.length - 1];
const highestGoalYear = Math.max(
...goals.map((goal) => {
const goalYear = goal.x[goal.x.length - 1];
return goalYear ? parseInt(goalYear.split('-')[0], 10) : NaN;
const goalDate = goal.x[goal.x.length - 1];
return goalDate ? new Date(goalDate).getFullYear() : NaN;
})
);

Expand Down

0 comments on commit 27ecf6b

Please sign in to comment.