Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ui): keep last pulse and dashboard date labels on-canvas (#16263)

Nikita Kabardinbf9a07f48e5a
diff --git a/web/src/features/events/components/outlier-strip/OutlierBarStrip.stories.tsx b/web/src/features/events/components/outlier-strip/OutlierBarStrip.stories.tsx
index 63b92a1aa5..b4b10c67e6 100644
--- a/web/src/features/events/components/outlier-strip/OutlierBarStrip.stories.tsx
+++ b/web/src/features/events/components/outlier-strip/OutlierBarStrip.stories.tsx
@@ -1,7 +1,8 @@
-import { fn } from "storybook/test";
+import { expect, fn, waitFor } from "storybook/test";
import preview from "../../../../../.storybook/preview";
import { OutlierBarStrip } from "./OutlierBarStrip";
import { makeFixtureSeries } from "./lib/fixtures";
+import { prepareOutlierSeries, type OutlierStripBin } from "./lib/binning";
/**
* Design surface for the outlier strip above the trace table (LFE-14451).
@@ -145,3 +146,65 @@ export const MinimalNoLabels = meta.story({
showTimeLabels: false,
},
});
+
+/** Last bucket is also a tick: a start-anchored date would clip off the svg. */
+function lastBinTickSeries(widthPx: number) {
+ const stepSeconds = 86400;
+ const t0 = 0;
+ const n = 45;
+ const bins: OutlierStripBin[] = Array.from({ length: n }, (_, i) => ({
+ bucketStart: new Date(t0 + i * stepSeconds * 1000),
+ count: 4 + (i % 7),
+ values: {
+ count_count: 4 + (i % 7),
+ sum_totalCost: 0.02 * (1 + (i % 5)),
+ p95_latency: 400 + (i % 9) * 80,
+ p50_latency: 200 + (i % 9) * 40,
+ },
+ }));
+ return {
+ ...prepareOutlierSeries({
+ bins,
+ metric: "latency",
+ fromMs: t0,
+ toMs: t0 + n * stepSeconds * 1000,
+ stepSeconds,
+ widthPx,
+ }),
+ stepMs: stepSeconds * 1000,
+ widthPx,
+ };
+}
+
+export const LastDateAtEdge = meta.story({
+ args: {
+ ...lastBinTickSeries(450),
+ metric: "latency",
+ },
+});
+
+export const TestLastDateFullyVisible = meta.story({
+ name: "(Test) Last Date Fully Visible",
+ args: {
+ ...lastBinTickSeries(450),
+ metric: "latency",
+ },
+ play: async ({ canvasElement }) => {
+ await waitFor(() => {
+ const svg = canvasElement.querySelector("svg");
+ expect(svg).toBeTruthy();
+ });
+ const svg = canvasElement.querySelector("svg");
+ if (!svg) throw new Error("plot svg not found");
+ const svgBox = svg.getBoundingClientRect();
+ const timeLabels = [...svg.querySelectorAll("text")].filter((el) =>
+ /^[A-Z][a-z]{2} \d/.test(el.textContent ?? ""),
+ );
+ await expect(timeLabels.length).toBeGreaterThan(0);
+ for (const label of timeLabels) {
+ const box = label.getBoundingClientRect();
+ await expect(box.right).toBeLessThanOrEqual(svgBox.right + 1);
+ await expect(box.left).toBeGreaterThanOrEqual(svgBox.left - 1);
+ }
+ },
+});
diff --git a/web/src/features/events/components/outlier-strip/OutlierBarStrip.tsx b/web/src/features/events/components/outlier-strip/OutlierBarStrip.tsx
index 93852205f5..85a7e8e297 100644
--- a/web/src/features/events/components/outlier-strip/OutlierBarStrip.tsx
+++ b/web/src/features/events/components/outlier-strip/OutlierBarStrip.tsx
@@ -264,8 +264,9 @@ export function OutlierBarStrip({
ticks.map((tick) => (
<text
key={`label-${tick.index}`}
- x={tick.index * slotPx + 3}
+ x={tick.x}
y={heightPx + 9}
+ textAnchor={tick.textAnchor}
className="fill-muted-foreground/80 font-sans"
fontSize={9}
>
diff --git a/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts b/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts
index 88b475931f..fef494ee96 100644
--- a/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts
+++ b/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts
@@ -219,9 +219,41 @@ describe("prepareOutlierSeries", () => {
expect(tick.index).toBeGreaterThan(0);
expect(tick.index).toBeLessThan(dense.length);
expect(tick.label).toMatch(/^[A-Z][a-z]{2} \d{1,2}$/); // "MMM d"
+ expect(tick.x).toBeGreaterThanOrEqual(0);
+ expect(tick.x).toBeLessThanOrEqual(600);
}
});
+ it("end-anchors a last-bin date so the label stays on-canvas", () => {
+ // 45 daily buckets in 450px → 10px slots, ticks every 11 bins. Epoch-aligned
+ // so a tick lands on the last bin: a start-anchored "MMM d" (~36px) would
+ // start at x=443 and clip off the svg ("Aug 11" → "Aug 1" / "Au").
+ const step = 86400;
+ const t0 = 0;
+ const n = 45;
+ const widthPx = 450;
+ const bins = Array.from({ length: n }, (_, i) =>
+ bin(t0 + i * 86400_000, 1),
+ );
+ const { dense, ticks } = prepareOutlierSeries({
+ bins,
+ metric: "cost",
+ fromMs: t0,
+ toMs: t0 + n * 86400_000,
+ stepSeconds: step,
+ widthPx,
+ });
+
+ expect(dense).toHaveLength(n);
+ const last = ticks[ticks.length - 1];
+ expect(last.index).toBe(n - 1);
+ const startX = last.index * (widthPx / n) + 3;
+ expect(startX + last.label.length * 6).toBeGreaterThan(widthPx);
+ expect(last.textAnchor).toBe("end");
+ expect(last.x).toBeLessThanOrEqual(widthPx);
+ expect(last.x).toBeGreaterThan(widthPx - 8);
+ });
+
it("aligns the grid to the epoch, not to `from`", () => {
const step = 60;
const t0 = Math.floor(Date.UTC(2025, 2, 10, 10, 0, 0) / 60000) * 60000;
diff --git a/web/src/features/events/components/outlier-strip/lib/binning.ts b/web/src/features/events/components/outlier-strip/lib/binning.ts
index 414e2dc1dc..f1418a88c2 100644
--- a/web/src/features/events/components/outlier-strip/lib/binning.ts
+++ b/web/src/features/events/components/outlier-strip/lib/binning.ts
@@ -78,6 +78,12 @@ const MAX_STRIP_BUCKETS = 2000;
const MAX_DENSE_BINS = 4000;
/** Minimum horizontal pixels between gridline ticks / labels. */
const TICK_MIN_SPACING_PX = 110;
+/** 9px sans, generous per-glyph width so we end-anchor before the svg clips. */
+const TICK_LABEL_PX_PER_CHAR = 6;
+/** Left inset for a start-anchored tick (matches the visualiser). */
+const TICK_LABEL_START_INSET_PX = 3;
+/** Right inset for an end-anchored tick so the last glyph isn't flush-clipped. */
+const TICK_LABEL_END_INSET_PX = 4;
/**
* Picks the finest granularity preset that fits the range into the available
@@ -328,7 +334,31 @@ export type OutlierStripDenseBin = {
};
/** A prepared gridline tick: dense-bin index + presentation-ready label. */
-export type OutlierStripTick = { index: number; label: string };
+export type OutlierStripTick = {
+ index: number;
+ label: string;
+ /** SVG x of the label (already inset / end-flipped so it stays on-canvas). */
+ x: number;
+ /** `end` when a start-anchored label would overflow the plot's right edge. */
+ textAnchor: "start" | "end";
+};
+
+function layoutOutlierStripTick(params: {
+ index: number;
+ label: string;
+ slotPx: number;
+ widthPx: number;
+}): Pick<OutlierStripTick, "x" | "textAnchor"> {
+ const startX = params.index * params.slotPx + TICK_LABEL_START_INSET_PX;
+ const estimatedWidth = params.label.length * TICK_LABEL_PX_PER_CHAR;
+ if (startX + estimatedWidth > params.widthPx) {
+ return {
+ x: params.widthPx - TICK_LABEL_END_INSET_PX,
+ textAnchor: "end",
+ };
+ }
+ return { x: startX, textAnchor: "start" };
+}
/** A bucket's tooltip time range, day-scale buckets without the time part. */
export const formatBucketRange = (fromMs: number, stepMs: number): string => {
@@ -428,12 +458,19 @@ export function prepareOutlierSeries(params: {
const tickStepMs = pickTickStepMs(stepMs, slotPx, TICK_MIN_SPACING_PX);
for (let i = 1; i < dense.length; i++) {
if ((dense[i].bucketStartMs - phase) % tickStepMs === 0) {
+ const label = format(
+ new Date(dense[i].bucketStartMs),
+ tickStepMs >= 86_400_000 ? "MMM d" : "HH:mm",
+ );
ticks.push({
index: i,
- label: format(
- new Date(dense[i].bucketStartMs),
- tickStepMs >= 86_400_000 ? "MMM d" : "HH:mm",
- ),
+ label,
+ ...layoutOutlierStripTick({
+ index: i,
+ label,
+ slotPx,
+ widthPx: params.widthPx,
+ }),
});
}
}
diff --git a/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx b/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx
index 59296064a2..8837ca330c 100644
--- a/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx
+++ b/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx
@@ -21,6 +21,7 @@ import {
prepareIsolatedPoints,
} from "@/src/features/widgets/chart-library/prepareDenseSeries";
import { prepareTimeAxis } from "@/src/features/widgets/chart-library/prepareTimeAxis";
+import { temporalAxisTickProp } from "@/src/features/widgets/chart-library/TimeAxisTick";
import { prepareVisibleSeries } from "@/src/features/widgets/chart-library/prepareVisibleSeries";
import {
seriesColor,
@@ -151,6 +152,10 @@ export const AreaChartTimeSeries: React.FC<ChartProps> = ({
interval={timeAxis.interval}
tickFormatter={timeAxis.formatTick}
{...timeAxis.tickProps}
+ {...temporalAxisTickProp(
+ timeAxis,
+ groupedData.at(-1)?.time_dimension,
+ )}
/>
<YAxis
type="number"
diff --git a/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx b/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx
index cdaebad406..d8d2c0cd87 100644
--- a/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx
+++ b/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx
@@ -34,6 +34,7 @@ import {
prepareIsolatedPoints,
} from "@/src/features/widgets/chart-library/prepareDenseSeries";
import { prepareTimeAxis } from "@/src/features/widgets/chart-library/prepareTimeAxis";
+import { temporalAxisTickProp } from "@/src/features/widgets/chart-library/TimeAxisTick";
import { prepareVisibleSeries } from "@/src/features/widgets/chart-library/prepareVisibleSeries";
import {
seriesColor,
@@ -327,6 +328,10 @@ export const LineChartTimeSeries: React.FC<ChartProps> = ({
interval={timeAxis.interval}
tickFormatter={timeAxis.formatTick}
{...timeAxis.tickProps}
+ {...temporalAxisTickProp(
+ timeAxis,
+ groupedData.at(-1)?.time_dimension,
+ )}
/>
<YAxis
type="number"
diff --git a/web/src/features/widgets/chart-library/TimeAxisTick.clienttest.tsx b/web/src/features/widgets/chart-library/TimeAxisTick.clienttest.tsx
new file mode 100644
index 0000000000..32becacd1e
--- /dev/null
+++ b/web/src/features/widgets/chart-library/TimeAxisTick.clienttest.tsx
@@ -0,0 +1,68 @@
+import { describe, expect, it } from "vitest";
+import { renderToStaticMarkup } from "react-dom/server";
+import type { XAxisTickContentProps } from "recharts";
+import { timeAxisTick } from "./TimeAxisTick";
+
+const Tick = timeAxisTick((value) => `Aug ${value}`, "2");
+
+const tickPayload = (index: number, coordinate: number) => ({
+ coordinate,
+ value: String(index),
+ index,
+ offset: 0,
+});
+
+function renderTick(props: {
+ x: number;
+ y: number;
+ index: number;
+ visibleTicksCount: number;
+ payload: ReturnType<typeof tickPayload>;
+}) {
+ return renderToStaticMarkup(
+ <svg>
+ <Tick {...(props as XAxisTickContentProps)} />
+ </svg>,
+ );
+}
+
+describe("TimeAxisTick", () => {
+ it("end-anchors the last data bucket so the date stays on-canvas", () => {
+ const html = renderTick({
+ x: 400,
+ y: 0,
+ index: 2,
+ payload: tickPayload(2, 400),
+ visibleTicksCount: 3,
+ });
+
+ expect(html).toContain('text-anchor="end"');
+ expect(html).toContain("Aug 2");
+ });
+
+ it("keeps earlier ticks centered", () => {
+ const html = renderTick({
+ x: 200,
+ y: 0,
+ index: 1,
+ payload: tickPayload(1, 200),
+ visibleTicksCount: 3,
+ });
+
+ expect(html).toContain('text-anchor="middle"');
+ expect(html).toContain("Aug 1");
+ });
+
+ it("keeps a thinned last-rendered tick centered when it is not the last bucket", () => {
+ const html = renderTick({
+ x: 320,
+ y: 0,
+ index: 5,
+ payload: tickPayload(20, 320),
+ visibleTicksCount: 6,
+ });
+
+ expect(html).toContain('text-anchor="middle"');
+ expect(html).toContain("Aug 20");
+ });
+});
diff --git a/web/src/features/widgets/chart-library/TimeAxisTick.tsx b/web/src/features/widgets/chart-library/TimeAxisTick.tsx
new file mode 100644
index 0000000000..f0b21ab994
--- /dev/null
+++ b/web/src/features/widgets/chart-library/TimeAxisTick.tsx
@@ -0,0 +1,70 @@
+import type { ReactNode } from "react";
+import type { XAxisTickContentProps } from "recharts";
+
+type TimeAxisTickViewProps = {
+ x?: number | string;
+ y?: number | string;
+ payload?: { value?: unknown };
+};
+
+function tickCoord(value: number | string | undefined): number | null {
+ if (value == null) return null;
+ const n = typeof value === "number" ? value : Number(value);
+ return Number.isFinite(n) ? n : null;
+}
+
+/**
+ * Temporal x-axis tick. A centered label on the last *bucket* clips at the
+ * plot edge ("Aug 11" → "Aug 1"). End-anchor only that last-bucket tick;
+ * thinned ticks that are not the last bucket stay centered on their gridline.
+ */
+function TimeAxisTick({
+ x,
+ y,
+ payload,
+ formatter,
+ lastValue,
+}: TimeAxisTickViewProps & {
+ formatter: (raw: unknown) => string;
+ lastValue: unknown;
+}) {
+ const tickX = tickCoord(x);
+ const tickY = tickCoord(y);
+ if (tickX == null || tickY == null) return null;
+ const isLastBucket =
+ lastValue != null && String(payload?.value) === String(lastValue);
+ return (
+ <text
+ x={tickX}
+ y={tickY}
+ dy={8}
+ textAnchor={isLastBucket ? "end" : "middle"}
+ className="fill-muted-foreground/90"
+ fontSize={12}
+ >
+ {formatter(payload?.value)}
+ </text>
+ );
+}
+
+export function timeAxisTick(
+ formatter: (raw: unknown) => string,
+ lastValue: unknown,
+): (props: XAxisTickContentProps) => ReactNode {
+ return function TimeAxisTickRenderer(props: XAxisTickContentProps) {
+ return (
+ <TimeAxisTick {...props} formatter={formatter} lastValue={lastValue} />
+ );
+ };
+}
+
+/** Visualiser helper: custom tick only on temporal axes (preparer stays React-free). */
+export function temporalAxisTickProp(
+ timeAxis: { mode: string; formatTick: (raw: unknown) => string },
+ lastValue: unknown,
+):
+ | { tick: (props: XAxisTickContentProps) => ReactNode }
+ | Record<string, never> {
+ if (timeAxis.mode === "category") return {};
+ return { tick: timeAxisTick(timeAxis.formatTick, lastValue) };
+}
diff --git a/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.stories.tsx b/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.stories.tsx
index d62e92b55b..3e849cb105 100644
--- a/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.stories.tsx
+++ b/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.stories.tsx
@@ -1,3 +1,4 @@
+import { expect, waitFor } from "storybook/test";
import preview from "../../../../.storybook/preview";
import { type ChartProps, type DataPoint } from "./chart-props";
import { VerticalBarChartTimeSeries } from "./VerticalBarChartTimeSeries";
@@ -50,3 +51,60 @@ export const Default = meta.story({
legendPosition: "auto",
},
});
+
+/** 13 daily buckets so a 3-day tick step lands on the last bar (Aug 13). */
+const dailyStacked: DataPoint[] = Array.from({ length: 13 }, (_, day) => {
+ const time_dimension = new Date(Date.UTC(2026, 7, 1 + day)).toISOString();
+ return [
+ {
+ time_dimension,
+ dimension: "gpt-4o",
+ metric: 40_000 + day * 1_200,
+ },
+ {
+ time_dimension,
+ dimension: "gpt-4o-mini",
+ metric: 65_000 + day * 800,
+ },
+ ];
+}).flat();
+
+export const LastDateAtEdge = meta.story({
+ parameters: { controls: { disable: true } },
+ render: () => (
+ <div className="bg-background h-[220px] w-[480px] overflow-hidden rounded-lg border p-4">
+ <VerticalBarChartTimeSeries data={dailyStacked} legendPosition="none" />
+ </div>
+ ),
+});
+
+export const TestLastDateFullyVisible = meta.story({
+ name: "(Test) Last Date Fully Visible",
+ parameters: { controls: { disable: true } },
+ render: () => (
+ <div className="bg-background h-[220px] w-[480px] overflow-hidden rounded-lg border p-4">
+ <VerticalBarChartTimeSeries data={dailyStacked} legendPosition="none" />
+ </div>
+ ),
+ play: async ({ canvasElement }) => {
+ await waitFor(() => {
+ const svg = canvasElement.querySelector("svg");
+ expect(svg).toBeTruthy();
+ });
+ const svg = canvasElement.querySelector("svg");
+ if (!svg) throw new Error("chart svg not found");
+ const svgBox = svg.getBoundingClientRect();
+ const timeLabels = [...svg.querySelectorAll("text")].filter((el) =>
+ /^[A-Z][a-z]{2} \d/.test(el.textContent ?? ""),
+ );
+ await expect(timeLabels.length).toBeGreaterThan(0);
+ const lastLabel = timeLabels.at(-1);
+ if (!lastLabel) throw new Error("no date tick found");
+ await expect(lastLabel.textContent).toMatch(/Aug 1[13]/);
+ for (const label of timeLabels) {
+ const box = label.getBoundingClientRect();
+ await expect(box.right).toBeLessThanOrEqual(svgBox.right + 1);
+ await expect(box.left).toBeGreaterThanOrEqual(svgBox.left - 1);
+ }
+ },
+});
diff --git a/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx b/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx
index 3f73249903..afd903281d 100644
--- a/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx
+++ b/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx
@@ -23,6 +23,7 @@ import {
TimeSeriesLegend,
useSeriesLegend,
} from "@/src/features/widgets/chart-library/TimeSeriesLegend";
+import { temporalAxisTickProp } from "@/src/features/widgets/chart-library/TimeAxisTick";
/**
* VerticalBarChartTimeSeries component
@@ -136,6 +137,10 @@ export const VerticalBarChartTimeSeries: React.FC<ChartProps> = ({
interval={timeAxis.interval}
tickFormatter={timeAxis.formatTick}
{...timeAxis.tickProps}
+ {...temporalAxisTickProp(
+ timeAxis,
+ groupedData.at(-1)?.time_dimension,
+ )}
/>
<YAxis
type="number"
diff --git a/web/src/features/widgets/chart-library/prepareTimeAxis.clienttest.ts b/web/src/features/widgets/chart-library/prepareTimeAxis.clienttest.ts
index b08b38ea2b..673775a229 100644
--- a/web/src/features/widgets/chart-library/prepareTimeAxis.clienttest.ts
+++ b/web/src/features/widgets/chart-library/prepareTimeAxis.clienttest.ts
@@ -182,22 +182,34 @@ describe("prepareTimeAxis", () => {
expect(axis.formatTooltip(runs[1])).toBe(runs[1]);
});
- it("short categorical labels are not truncated and time ticks stay flat + numeric (dashboards unchanged)", () => {
+ it("short categorical labels are not truncated and time ticks stay flat + numeric", () => {
const shortCategories = prepareTimeAxis(["run-a", "run-b", "run-c"], 6);
expect(shortCategories.formatTick("run-a")).toBe("run-a");
expect(shortCategories.tickProps.angle).toBeLessThan(0);
- // Time-mode ticks are unchanged: flat tickProps AND a numeric index step, so
- // dashboards render pixel-identically (no width-aware equidistant thinning).
+ // Time-mode ticks stay flat with a numeric index step (no width-aware
+ // equidistant thinning). They also pad the right edge so the last date
+ // has a small gutter past the end-anchored label.
const start = Date.UTC(2026, 5, 28, 0);
const timeVals = Array.from({ length: 24 }, (_, h) =>
iso(start + h * HOUR),
);
const timeAxis = prepareTimeAxis(timeVals, 6);
- expect(timeAxis.tickProps).toEqual({});
+ expect(timeAxis.tickProps.angle).toBeUndefined();
+ expect(timeAxis.tickProps.padding?.right).toBeGreaterThanOrEqual(16);
expect(typeof timeAxis.interval).toBe("number");
});
+ it("date-mode axes also pad the right edge so the last date is not clipped", () => {
+ const values = Array.from({ length: 14 }, (_, d) =>
+ iso(Date.UTC(2026, 7, 1) + d * DAY),
+ );
+ const axis = prepareTimeAxis(values, 6);
+ expect(axis.mode).toBe("date");
+ expect(axis.tickProps.padding?.right).toBeGreaterThanOrEqual(16);
+ expect(axis.tickProps.angle).toBeUndefined();
+ });
+
it("hideCategoryTickLabels blanks the entity axis but keeps the full name in the tooltip", () => {
// Opt-in for the experiments / dataset-compare charts: long entity names are
// hidden from the axis and surfaced only on hover.
diff --git a/web/src/features/widgets/chart-library/prepareTimeAxis.ts b/web/src/features/widgets/chart-library/prepareTimeAxis.ts
index d34a2ecade..7df08943ca 100644
--- a/web/src/features/widgets/chart-library/prepareTimeAxis.ts
+++ b/web/src/features/widgets/chart-library/prepareTimeAxis.ts
@@ -49,6 +49,14 @@ const MAX_CATEGORY_LABEL_CHARS = 24;
*/
const CATEGORY_MIN_TICK_GAP_PX = 16;
+/**
+ * Extra category-axis padding (px) on a temporal x-axis. The last tick is
+ * also end-anchored (see TimeAxisTick) so a date sitting on the last bucket
+ * stays on-canvas; this pad is only a small gutter past that last glyph.
+ * Categorical axes skip this — they are already end-anchored.
+ */
+const TEMPORAL_TICK_RIGHT_PADDING_PX = 16;
+
/** End-truncate a long categorical label ("foo-bar-…"). Entity names carry
* their distinguishing token early (e.g. "…-run-2-…"), so keeping the head and
* dropping the tail preserves what tells ticks apart; the tooltip has the full
@@ -151,11 +159,12 @@ export type TimeAxis = {
showVerticalGrid: boolean;
/**
* Tick-label props the visualiser spreads onto the recharts `XAxis`.
- * Time / date / month ticks are short single-units rendered flat (`{}` → the
- * spread is a no-op, so dashboards are unchanged). Categorical entity names
- * are long, so we render them angled + end-anchored — the standard way to fit
- * long category labels — and set a `minTickGap` so the (width-aware thinned)
- * ticks keep a real gap between them. (LFE-10583)
+ * Time / date / month ticks are short single-units rendered flat. A right
+ * `padding` keeps the centered last date on-canvas (otherwise "Aug 11"
+ * clips to "Aug 1"). Categorical entity names are long, so we render them
+ * angled + end-anchored — the standard way to fit long category labels —
+ * and set a `minTickGap` so the (width-aware thinned) ticks keep a real
+ * gap between them. (LFE-10583)
*/
tickProps: {
angle?: number;
@@ -164,6 +173,8 @@ export type TimeAxis = {
height?: number;
/** Minimum px gap recharts leaves between two shown ticks. */
minTickGap?: number;
+ /** Inset the category scale so a centered last tick label stays on-canvas. */
+ padding?: { left?: number; right?: number };
};
};
@@ -323,14 +334,17 @@ export function prepareTimeAxis(
});
};
- // Time / date / month ticks are short single-units — rendered flat, exactly
- // as the dashboards do today (no orientation change → pixel-identical).
+ // Time / date / month ticks are short single-units — rendered flat. The
+ // last tick sits on the last bucket, flush with the plot's right edge;
+ // without a right pad a centered "Aug 11" clips to "Aug 1".
return {
interval,
formatTick,
formatTooltip,
mode,
showVerticalGrid: true,
- tickProps: {},
+ tickProps: {
+ padding: { left: 0, right: TEMPORAL_TICK_RIGHT_PADDING_PX },
+ },
};
}