Skip to content

Commit 8fe97e5

Browse files
author
jacquesbach
committed
Forecast Chart Highlight active point
1 parent 3b63d58 commit 8fe97e5

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

static/js/script.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,12 @@ async function loadHourlyHeatmap(month) {
852852
// Beim Laden der Seite aufrufen
853853
document.addEventListener("DOMContentLoaded", initHourlyHeatmap);
854854

855+
// =========================
856+
// FORECAST JS
857+
// =========================
858+
859+
let activeForecastIndex = 0; // Default = erster Punkt
860+
855861
function prettyFeatureName(key) {
856862
const featureNames = {
857863
clouds: "Mittlerer Bewölkungsgrad",
@@ -868,9 +874,7 @@ function prettyFeatureName(key) {
868874
return featureNames[key] || key;
869875
}
870876

871-
// =========================
872877
// 🔒 VALIDATION + ERROR UI
873-
// =========================
874878

875879
function validateForecastData(forecast) {
876880

@@ -957,12 +961,9 @@ function getTodayForecastPoint(forecastData) {
957961
return forecastData.find(d => d.date === todayStr);
958962
}
959963

960-
function getForecastIndex(forecastData, targetDate) {
961-
return forecastData.findIndex(d => d.date === targetDate);
962-
}
963-
964-
function highlightForecastPoint(chart, index) {
964+
function setActivePoint(chart, index) {
965965
if (!chart || index < 0) return;
966+
activeForecastIndex = index;
966967
chart.setActiveElements([{
967968
datasetIndex: 0,
968969
index: index
@@ -1153,18 +1154,19 @@ async function loadForecast() {
11531154
if (points.length) {
11541155
const index = points[0].index;
11551156
showShapDetails(forecast[index]);
1156-
highlightForecastPoint(forecastChart, index);
1157-
1157+
setActivePoint(forecastChart, index);
11581158
}
11591159
},
11601160
}
11611161
});
11621162
const todayPoint = getTodayForecastPoint(data.forecast) || data.forecast[0];
11631163
if (todayPoint) {
1164-
showShapDetails(todayPoint);
1165-
const index = getForecastIndex(data.forecast, todayPoint.date);
1166-
highlightForecastPoint(forecastChart, index);
1167-
}
1164+
showShapDetails(todayPoint);
1165+
document.getElementById("shapDetailCard").style.display = "block";
1166+
setTimeout(() => {
1167+
setActivePoint(forecastChart, 0);
1168+
}, 100);
1169+
};
11681170
}
11691171

11701172
async function loadFeatureImportance() {

0 commit comments

Comments
 (0)