changeset 4711:13575ffb8c1f

hydrological_conditions: unify localization for brush and diagram
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 17 Oct 2019 12:07:06 +0200
parents 558417908b37
children 3b5268263c5b
files client/src/components/gauge/HydrologicalConditions.vue client/src/lib/datelocalization.js
diffstat 2 files changed, 21 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/gauge/HydrologicalConditions.vue	Thu Oct 17 11:51:23 2019 +0200
+++ b/client/src/components/gauge/HydrologicalConditions.vue	Thu Oct 17 12:07:06 2019 +0200
@@ -601,29 +601,30 @@
       return { x, y, x2, y2 };
     },
     getAxes({ scale, dimensions }) {
+      const dFormat = date => {
+        // make the x-axis label formats dynamic, based on zoom
+        // but never display year numbers since they don't make any sense in
+        // this diagram
+        return (d3.timeSecond(date) < date
+          ? d3.timeFormat(".%L")
+          : d3.timeMinute(date) < date
+          ? d3.timeFormat(":%S")
+          : d3.timeHour(date) < date
+          ? d3.timeFormat("%H:%M")
+          : d3.timeDay(date) < date
+          ? d3.timeFormat("%H")
+          : d3.timeMonth(date) < date
+          ? d3.timeWeek(date) < date
+            ? d3.timeFormat("%b %d")
+            : d3.timeFormat("%b %d")
+          : d3.timeFormat("%B"))(date);
+      };
       return {
         x: d3
           .axisTop(scale.x)
           .tickSizeInner(dimensions.mainHeight)
           .tickSizeOuter(0)
-          .tickFormat(date => {
-            // make the x-axis label formats dynamic, based on zoom
-            // but never display year numbers since they don't make any sense in
-            // this diagram
-            return (d3.timeSecond(date) < date
-              ? d3.timeFormat(".%L")
-              : d3.timeMinute(date) < date
-              ? d3.timeFormat(":%S")
-              : d3.timeHour(date) < date
-              ? d3.timeFormat("%H:%M")
-              : d3.timeDay(date) < date
-              ? d3.timeFormat("%H")
-              : d3.timeMonth(date) < date
-              ? d3.timeWeek(date) < date
-                ? d3.timeFormat("%b %d")
-                : d3.timeFormat("%b %d")
-              : d3.timeFormat("%B"))(date);
-          }),
+          .tickFormat(dFormat),
         y: d3
           .axisRight(scale.y)
           .tickSizeInner(dimensions.width)
@@ -634,7 +635,7 @@
           .tickSizeInner(3)
           .tickSizeOuter(0)
           .tickFormat(d => this.$options.filters.waterlevel(d)),
-        x2: d3.axisBottom(scale.x2)
+        x2: d3.axisBottom(scale.x2).tickFormat(dFormat)
       };
     },
     drawNowLines({ extent, diagram, scale, navigation }) {
--- a/client/src/lib/datelocalization.js	Thu Oct 17 11:51:23 2019 +0200
+++ b/client/src/lib/datelocalization.js	Thu Oct 17 12:07:06 2019 +0200
@@ -2,7 +2,7 @@
 const localeDateString = {
   dateTime: "%a %e %b %X %Y",
   date: "%d/%m/%Y",
-  time: app.$gettext("%H:%M:%S"),
+  time: "%H:%M:%S",
   periods: [app.$gettext("AM"), app.$gettext("PM")],
   days: [
     app.$gettext("Sunday"),