bito-code-review[bot] commented on code in PR #44701:
URL: https://github.com/apache/superset/pull/44701#discussion_r4184695516
##########
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:
<div>
<div id="suggestion">
<div id="issue"><b>duplicated formatter-id propagation</b></div>
<div id="fix">
The `'id' in formatter` propagation block is now duplicated in three wrapper
factories (`createDedupXAxisFormatter`, `createSpacedXAxisFormatter`,
`createPaddedExtentFloorFormatter`). Extract a small shared helper (e.g.
`copyFormatterId(wrapper, formatter)`) so the ECharts formatter-id contract
stays in one place.
</div>
</div>
<small><i>Code Review Run #0fd67a</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]