diff --git a/src/routes/heatmap/+page.svelte b/src/routes/heatmap/+page.svelte
index 33345d36..d01caeac 100644
--- a/src/routes/heatmap/+page.svelte
+++ b/src/routes/heatmap/+page.svelte
@@ -12,27 +12,40 @@
let selectedFormat: "png" | "jpeg" | "svg" = "png";
let selectedTimePeriod = "1D";
let iframeUrl: string;
+ let loading = true;
async function getHeatMap() {
- const cachedData = getCache(selectedTimePeriod, "getHeatmap");
- if (cachedData) {
- rawData = cachedData;
- } else {
- const postData = { params: selectedTimePeriod };
- const response = await fetch("/api/heatmap", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(postData),
- });
+ loading = true;
+ try {
+ const cachedData = getCache(selectedTimePeriod, "getHeatmap");
+ if (cachedData) {
+ rawData = cachedData;
+ } else {
+ const postData = { params: selectedTimePeriod };
+ const response = await fetch("/api/heatmap", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(postData),
+ });
- rawData = await response.json();
- setCache(selectedTimePeriod, rawData, "getHeatmap");
+ rawData = await response.json();
+ setCache(selectedTimePeriod, rawData, "getHeatmap");
+ }
+
+ const htmlContent = rawData;
+
+ const blob = new Blob([htmlContent], { type: "text/html" });
+ if (iframeUrl) {
+ URL.revokeObjectURL(iframeUrl);
+ }
+ iframeUrl = URL.createObjectURL(blob);
+ } catch (error) {
+ console.error("Error loading heatmap:", error);
+ } finally {
+ loading = false;
}
-
- const blob = new Blob([rawData], { type: "text/html" });
- iframeUrl = URL.createObjectURL(blob);
}
async function downloadPlot(item) {
@@ -92,10 +105,6 @@
}
-
-
-
-
+ {#if loading}
+
+ {/if}
+
{#if rawData}
@@ -240,3 +262,13 @@
+
+