kokhlo commented on code in PR #44701:
URL: https://github.com/apache/superset/pull/44701#discussion_r4185575911


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts:
##########
@@ -406,3 +406,34 @@ export function getXAxisDomain(
   });
   return [domainMin, domainMax];
 }
+
+/**
+ * Wraps a temporal x-axis formatter so ticks that fall outside the data
+ * domain — the sub-second noise ECharts adds when it pads a time axis
+ * beyond the data extent — are floored to the second before formatting,
+ * instead of triggering smart_date's millisecond tier ('.943ms', #44698).
+ * Ticks inside the data domain are passed through untouched: a genuine
+ * sub-second timestamp is real data and keeps its precision.
+ */
+export function createPaddedExtentFloorFormatter(
+  formatter: XAxisFormatterFn | undefined,
+  domainMin: number | undefined,
+  domainMax: number | undefined,
+): (value: number | string) => string {
+  const wrapper = (value: number | string) => {
+    if (
+      typeof value === 'number' &&
+      formatter &&
+      (value < (domainMin ?? -Infinity) || value > (domainMax ?? Infinity))
+    ) {
+      return formatter(Math.floor(value / 1000) * 1000);
+    }
+    return typeof formatter === 'function'
+      ? (formatter as Function)(value)
+      : String(value);
+  };
+  if (typeof formatter === 'function' && 'id' in formatter) {
+    (wrapper as { id?: unknown }).id = (formatter as { id?: unknown }).id;
+  }

Review Comment:
   Both taken.
   
   The duplication is now one `copyFormatterId` helper, since all three 
factories have to honour the same contract. The domain scan is behind the 
`xAxisType === AxisType.Time` check in both transformProps — the two formatters 
that read its result only run for a time axis, so a category axis no longer 
walks the records on every render. Added a test that pins the scan behind that 
check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to