Skip to content

Commit 3b63d58

Browse files
author
jacquesbach
committed
Highlight active forecast point
1 parent f73281a commit 3b63d58

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

static/js/script.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,19 @@ function getTodayForecastPoint(forecastData) {
957957
return forecastData.find(d => d.date === todayStr);
958958
}
959959

960+
function getForecastIndex(forecastData, targetDate) {
961+
return forecastData.findIndex(d => d.date === targetDate);
962+
}
963+
964+
function highlightForecastPoint(chart, index) {
965+
if (!chart || index < 0) return;
966+
chart.setActiveElements([{
967+
datasetIndex: 0,
968+
index: index
969+
}]);
970+
chart.update();
971+
}
972+
960973
async function loadForecast() {
961974

962975
const response = await fetch("/api/forecast");
@@ -1140,15 +1153,18 @@ async function loadForecast() {
11401153
if (points.length) {
11411154
const index = points[0].index;
11421155
showShapDetails(forecast[index]);
1156+
highlightForecastPoint(forecastChart, index);
1157+
11431158
}
11441159
},
11451160
}
11461161
});
11471162
const todayPoint = getTodayForecastPoint(data.forecast) || data.forecast[0];
11481163
if (todayPoint) {
1149-
showShapDetails(todayPoint);
1150-
document.getElementById("shapDetailCard").style.display = "block";
1151-
};
1164+
showShapDetails(todayPoint);
1165+
const index = getForecastIndex(data.forecast, todayPoint.date);
1166+
highlightForecastPoint(forecastChart, index);
1167+
}
11521168
}
11531169

11541170
async function loadFeatureImportance() {

0 commit comments

Comments
 (0)