Skip to content

Commit

Permalink
Merge pull request #422 from kausaltech/fix/trend-line-width
Browse files Browse the repository at this point in the history
Fix trend line not extending to the goal year
  • Loading branch information
lilia1891 authored Oct 25, 2024
2 parents 7cf6e49 + 27ecf6b commit 133da20
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/indicators/IndicatorVisualisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ const generateTrendTrace = (indicator, traces, goals, i18n) => {

const highestDataYear = traces[0].y[traces[0].y.length - 1];
const highestGoalYear = Math.max(
...goals.map((goal) => goal.x[goal.x.length - 1])
...goals.map((goal) => {
const goalDate = goal.x[goal.x.length - 1];
return goalDate ? new Date(goalDate).getFullYear() : NaN;
})
);

if (highestGoalYear && highestGoalYear > highestDataYear) {
predictedTrace.x.push(highestGoalYear);
}
Expand Down

0 comments on commit 133da20

Please sign in to comment.