Skip to content

Commit 63b2a69

Browse files
committed
fix(ui): chart tooltip header reads a month bucket key as its month
The axis already read `2025-10` as `Oct 2025`; the tooltip header beside it still showed the raw key. ChartTooltipContent now runs its header through formatMonthBucketLabel in the display locale, and any other label reads as written. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzKuj2HUUN2wUhZ9Go
1 parent 644c6e3 commit 63b2a69

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎.changeset/27520-dashboard-readability.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Metadata-protocol: none
1010
Dashboard numbers and chart labels stay readable on a phone:
1111

1212
- **KPI value.** A dataset-bound KPI tile's value now shrinks to fit its tile, the way the plain metric tiles already did, instead of being cut with an ellipsis (`$1,090,00...` on a phone). Past the smallest size it keeps the ellipsis and shows the full figure as a tooltip. A short value looks as before.
13-
- **Month axis.** A chart over a month-bucketed date dimension labels its axis `Oct 2025` in the reader's locale, not the raw bucket key `2025-10`. The key itself is unchanged in the data, so drill-through and ordering are unaffected. `@object-ui/core` adds `formatMonthBucketLabel(value, locale)`, which answers that label for a `YYYY-MM` key and `undefined` for anything else.
13+
- **Month axis.** A chart over a month-bucketed date dimension labels its axis `Oct 2025` in the reader's locale, not the raw bucket key `2025-10`. The chart tooltip's header reads the same label. The key itself is unchanged in the data, so drill-through and ordering are unaffected. `@object-ui/core` adds `formatMonthBucketLabel(value, locale)`, which answers that label for a `YYYY-MM` key and `undefined` for anything else.
1414
- **Legend swatches.** A bar or area chart's legend draws a colour swatch for every series; it drew none, because those marks fill from a gradient. A comparison (`compareTo`) series' swatch is drawn hollow, so it reads apart from the solid swatch of the series it overlays in the same colour.
1515
- **Horizontal bar labels.** A horizontal bar chart's category labels are drawn in full on a phone, wrapped to at most two lines inside the axis, instead of cut to eight characters (`In Progr…`). A label still too long ends in an ellipsis and shows the full text as a tooltip.

‎ui/packages/plugin-charts/src/AdvancedChartImpl.dashboardReadability-27520.test.tsx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ vi.mock('recharts', async () => {
3232
});
3333

3434
import AdvancedChartImpl from './AdvancedChartImpl';
35+
import { ChartContainer, ChartTooltipContent } from './ChartContainerImpl';
3536

3637
const DESKTOP_WIDTH = window.innerWidth;
3738

@@ -218,3 +219,23 @@ describe('a lone bar series painted per category (row 15 control)', () => {
218219
});
219220
});
220221

222+
223+
describe('the tooltip header names a month bucket the way the axis does (objectstack#27520 row 15)', () => {
224+
const header = (label: string) => {
225+
const { container } = render(
226+
<ChartContainer config={{ amount: { label: 'Amount' } }}>
227+
<ChartTooltipContent active label={label} payload={[{ value: 5, name: 'amount', dataKey: 'amount', payload: {} }]} />
228+
</ChartContainer>,
229+
);
230+
return container.querySelector('.font-medium')?.textContent;
231+
};
232+
233+
it('reads `Oct 2025` for the bucket key `2025-10`', () => {
234+
expect(header('2025-10')).toBe('Oct 2025');
235+
});
236+
237+
it('CONTROL: any other category reads as written', () => {
238+
expect(header('2025-Q4')).toBe('2025-Q4');
239+
expect(header('In Progress')).toBe('In Progress');
240+
});
241+
});

‎ui/packages/plugin-charts/src/ChartContainerImpl.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import * as React from "react"
1212
import { ResponsiveContainer, Tooltip, Legend } from "recharts"
1313
import { useDisplayLocale } from "@object-ui/i18n"
14+
import { formatMonthBucketLabel } from "@object-ui/core"
1415

1516
// Utility function to merge class names (inline to avoid external dependency)
1617
const cn = (...classes: (string | undefined)[]) => classes.filter(Boolean).join(' ')
@@ -348,7 +349,12 @@ function ChartTooltipContent({
348349
return null
349350
}
350351

351-
return <div className={cn("font-medium", labelClassName)}>{value}</div>
352+
// A month bucket key (`2025-10`) reads as the axis beside it does,
353+
// `Oct 2025`; the row keeps its key (objectstack#27520).
354+
const shown =
355+
typeof value === "string" ? formatMonthBucketLabel(value, displayLocale) ?? value : value
356+
357+
return <div className={cn("font-medium", labelClassName)}>{shown}</div>
352358
}, [
353359
label,
354360
labelFormatter,
@@ -357,6 +363,7 @@ function ChartTooltipContent({
357363
labelClassName,
358364
config,
359365
labelKey,
366+
displayLocale,
360367
])
361368

362369
if (!active || !payload?.length) {

0 commit comments

Comments
 (0)