]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5834'
authorTom Hughes <tom@compton.nu>
Fri, 21 Mar 2025 17:44:37 +0000 (17:44 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 21 Mar 2025 17:44:37 +0000 (17:44 +0000)
1  2 
app/assets/javascripts/heatmap.js

index 9c8d65cf46d0201cccab45c1d411bb893b6f0460,240707609217c6bb834ea62194b30982564a58aa..831ac4b6e18df2a2b0348741aa61edd671feecb0
@@@ -11,14 -11,11 +11,13 @@@ document.addEventListener("DOMContentLo
      return;
    }
  
 +  /** @type {{date: string; max_id: number; total_changes: number}[]} */
    const heatmapData = heatmapElement.dataset.heatmap ? JSON.parse(heatmapElement.dataset.heatmap) : [];
    const displayName = heatmapElement.dataset.displayName;
    const colorScheme = document.documentElement.getAttribute("data-bs-theme") ?? "auto";
 -  const rangeColors = ["#14432a", "#166b34", "#37a446", "#4dd05a"];
 +  const rangeColorsDark = ["#14432a", "#4dd05a"];
 +  const rangeColorsLight = ["#4dd05a", "#14432a"];
    const startDate = new Date(Date.now() - (365 * 24 * 60 * 60 * 1000));
-   const monthNames = OSM.i18n.t("date.abbr_month_names");
  
    const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
  
@@@ -36,7 -33,7 +35,7 @@@
          type: "month",
          gutter: 4,
          label: {
-           text: (timestamp) => monthNames[new Date(timestamp).getUTCMonth() + 1],
+           text: (timestamp) => new Date(timestamp).toLocaleString(OSM.i18n.locale, { timeZone: "UTC", month: "short" }),
            position: "top",
            textAlign: "middle"
          },
@@@ -61,9 -58,9 +60,9 @@@
        },
        scale: {
          color: {
 -          type: "threshold",
 -          range: currentTheme === "dark" ? rangeColors : Array.from(rangeColors).reverse(),
 -          domain: [10, 20, 30, 40]
 +          type: "sqrt",
 +          range: currentTheme === "dark" ? rangeColorsDark : rangeColorsLight,
 +          domain: [0, Math.max(0, ...heatmapData.map(d => d.total_changes))]
          }
        }
      }, [