Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Stop History chart axis labels crowding or repeating
rcourtmaned5914812c33
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 648f254159..52d585bf47 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -9195,6 +9195,16 @@ shows: a resize (or a full-page capture) re-reads the same series at the newcap while keeping its readings on screen with no loading state, and onlypointer inspection resets, since its pixel positions moved. A changed target,metric, range, organisation or lock still starts from nothing.+History axis labels must not crowd. The canvas chart draws as many evenly+spaced time labels as its plot fits at the measured label width, from four+down to the first and last time (`getHistoryChartTimeTickCount`), so a narrow+live I/O card no longer runs "12:04 PM12:07 PM..." together. Both the canvas+chart and the drawer charts blank a middle gridline label that repeats a+neighbour (`withoutRepeatedHistoryAxisLabels`): a quiet link reads "<1K/s"+once, not on two gridlines, and the gridline itself stays. The end labels+always remain. `guest-storage-2263.cjs` records each chart's drawn time+labels and checks they stand apart; `pbs-history-refresh.cjs` checks the+drawer's network axis.### Shared History single observationsdiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 7190f9c1f1..598f3cbaee 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -4030,7 +4030,9 @@ hides nothing from the shared history read and adds no read or timer. Theremoved "Refresh history" button took no read away: the 30-second poll isunchanged and "Retry history" still appears for a failed read. Its focushandoff reads `document.activeElement` once, as the Retry branch is disposed.-None adds a read or timer.+Repeated gridline labels are blanked from the three labels each panel already+formats, and the canvas chart measures the time labels it already draws to+choose how many fit. None adds a read or timer.The default stored-history legend resolves one latest timestamp from thatsame bounded, normalized panel index, then looks up each configured series atdiff --git a/frontend-modern/browser-tests/guest-storage-2263.cjs b/frontend-modern/browser-tests/guest-storage-2263.cjsindex 88df1632b8..65dcf2b55f 100644--- a/frontend-modern/browser-tests/guest-storage-2263.cjs+++ b/frontend-modern/browser-tests/guest-storage-2263.cjs@@ -116,6 +116,26 @@ const { chromium } = require('playwright');});// Disk charts poll every 10-30 seconds; the clock drives that here.await page.clock.install();+ // Canvas text is not in the DOM: record each chart's drawn labels since+ // its last clear, so the time axis can be checked for overlap.+ await page.addInitScript(() => {+ const proto = CanvasRenderingContext2D.prototype;+ const clear = proto.clearRect;+ const fill = proto.fillText;+ proto.clearRect = function (...args) {+ this.canvas.__labels = [];+ return clear.apply(this, args);+ };+ proto.fillText = function (text, x, y, ...rest) {+ (this.canvas.__labels ||= []).push({+ text: String(text),+ x,+ width: this.measureText(String(text)).width,+ time: this.textAlign === 'center' && this.textBaseline === 'bottom',+ });+ return fill.call(this, text, x, y, ...rest);+ };+ });await page.goto('http://127.0.0.1:5199/browser-tests/guest-storage-2263.html', {waitUntil: 'domcontentloaded',timeout: 120_000,@@ -176,6 +196,28 @@ const { chromium } = require('playwright');// with no Overview/History tabs to switch between.assert.equal(await page.getByRole('tab').count(), 0);assert.equal(await page.getByTestId('disk-detail-history').isVisible(), true);+ // Each chart's time labels stand apart, however narrow its card.+ const timeLabels = await page.evaluate(() =>+ Array.from(document.querySelectorAll('canvas'), (canvas) => ({+ chart: canvas.getAttribute('aria-label'),+ width: canvas.clientWidth,+ labels: (canvas.__labels || []).filter((label) => label.time),+ })),+ );+ for (const chart of timeLabels) {+ assert.ok(chart.labels.length >= 2, `${chart.chart} has its first and last time`);+ const sorted = [...chart.labels].sort((a, b) => a.x - b.x);+ for (let i = 1; i < sorted.length; i++) {+ const gap = sorted[i].x - sorted[i - 1].x - (sorted[i].width + sorted[i - 1].width) / 2;+ assert.ok(gap >= 4, `${chart.chart} time labels touch: ${JSON.stringify(sorted)}`);+ }+ }+ console.log(+ JSON.stringify({+ width,+ timeLabels: timeLabels.map((chart) => [chart.chart, chart.width, chart.labels.length]),+ }),+ );await page.locator('[data-testid="guest-physical-disk"] summary').click();await page.getByText('Reallocated Sectors').first().waitFor({ state: 'hidden' });assert.equal(diff --git a/frontend-modern/browser-tests/pbs-history-refresh.cjs b/frontend-modern/browser-tests/pbs-history-refresh.cjsindex be9cfd64b2..f0f34207a6 100644--- a/frontend-modern/browser-tests/pbs-history-refresh.cjs+++ b/frontend-modern/browser-tests/pbs-history-refresh.cjs@@ -123,6 +123,13 @@ const { chromium } = require('playwright'););await waitForPaths(7);console.log(JSON.stringify({ width, theme, stage: 'history loaded' }));+ // A quiet link's rate axis says "<1K/s" once: a repeated middle label is blank.+ assert.deepEqual(+ await detail+ .locator('[data-history-group="network"] [data-history-axis-label]')+ .allTextContents(),+ ['<1K/s', '', '0'],+ );const status = detail.getByRole('status', { name: 'History refresh status' });assert.equal(await status.count(), 1);assert.equal(await status.innerText(), '');diff --git a/frontend-modern/browser-verification/866db04bfd2e2011.json b/frontend-modern/browser-verification/866db04bfd2e2011.jsonnew file mode 100644index 0000000000..701a3557d6--- /dev/null+++ b/frontend-modern/browser-verification/866db04bfd2e2011.json@@ -0,0 +1,46 @@+{+ "version": 1,+ "base_sha": "ef486d54e657880bdd95d3e26ae4eaba9e330542",+ "verified_at": "2026-10-14T11:20:30Z",+ "result": "passed",+ "changed_paths": [+ "frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx",+ "frontend-modern/src/components/shared/historyChartModel.ts",+ "frontend-modern/src/components/shared/useHistoryChartState.ts"+ ],+ "content_sha256": {+ "frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx": "19f2635052a1261402aea2cd2913d4a72dcb779e121c886d270907d4444bb0ae",+ "frontend-modern/src/components/shared/historyChartModel.ts": "9bb10c35fdda9e224fb7b49fe33016b10d1e258eca6bde95f0ddacc21034a7dd",+ "frontend-modern/src/components/shared/useHistoryChartState.ts": "2d9963744c3a100a208979f414c917825bb0c911ab0e0919e7fbd9d819c7d9ef"+ },+ "routes": [+ "/browser-tests/guest-storage-2263.html (production DiskDetail HistoryChart canvases, Chromium via Playwright 1.56.1 on pulse-dev)",+ "/browser-tests/pbs-history-refresh.html (production GuestDrawerHistory renderer)"+ ],+ "viewports": [+ {+ "width": 1440,+ "height": 900+ },+ {+ "width": 390,+ "height": 844+ },+ {+ "width": 1365,+ "height": 900+ }+ ],+ "states": [+ "expanded disk at 1440: 314px History cards draw 4 time labels, 197px Live I/O cards draw 3, none touching (old code drew 4 overlapping)",+ "expanded disk at 390: every 288px card draws 4 time labels apart",+ "drawer network panel with sub-1K rates: axis reads <1K/s, blank middle, 0",+ "utilization axis keeps 100%, 50%, 0%",+ "light and dark drawer themes"+ ],+ "interactions": [+ "disk summary expand by keyboard, close and reopen by pointer",+ "viewport narrowed and restored",+ "drawer history poll, failure, retry and target switch (existing refresh proof flow)"+ ]+}diff --git a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsxindex 7535a3a309..0d04bdcc4b 100644--- a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx@@ -22,6 +22,7 @@ import {formatHistoryChartTooltipValue,formatHistoryRangeOptionLabel,formatHistoryChartTimeLabel,+ withoutRepeatedHistoryAxisLabels,} from '@/components/shared/historyChartModel';import { isRangeLocked, loadRuntimeCapabilities, maxHistoryDays } from '@/stores/license';import { getAPIReadAccessErrorMessage } from '@/utils/apiAccessError';@@ -382,6 +383,12 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps>props.group.unit,),);+ // Top, middle and bottom gridline labels; a repeated middle one is blank.+ const axisLabels = createMemo(() =>+ withoutRepeatedHistoryAxisLabels(+ [0, 0.5, 1].map((tick) => getAxisLabel(props.group.unit, tick, scale())),+ ),+ );const bounds = () => props.timeBounds;const hasStoredData = createMemo(() => observationTimes().length > 0 && bounds() !== null);const hoveredSeries = createMemo(() => {@@ -567,13 +574,14 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps><For each={[0, 0.5, 1]}>{(tick) => (<span+ data-history-axis-label// Centred on the SVG gridlines at y = 8, 41 and 74 of the 92-unit// viewBox (8.7%, 44.6%, 80.4%), so each label sits on its line.class={`pointer-events-none absolute left-0 w-8 -translate-y-1/2 text-right text-[10px] tabular-nums text-muted ${tick === 0 ? 'top-[8.7%]' : tick === 0.5 ? 'top-[44.6%]' : 'top-[80.4%]'}`}>- {getAxisLabel(props.group.unit, tick, scale())}+ {axisLabels()[tick === 0 ? 0 : tick === 0.5 ? 1 : 2]}</span>)}</For>diff --git a/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.window.test.tsx b/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.window.test.tsxindex 034d046980..7d9b471d95 100644--- a/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.window.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.window.test.tsx@@ -71,6 +71,29 @@ const selectSharedTime = (chart: HTMLElement) => {return chart.querySelector('[data-history-hover-marker]')!;};+describe('GuestDrawerHistory value axis', () => {+ it('labels a quiet link\'s rate axis once, not "<1K/s" on two gridlines', async () => {+ vi.spyOn(ChartsAPI, 'getMetricsHistory').mockResolvedValue(+ response({+ metrics: {+ cpu: [point(end - 10 * 60_000, 12), point(end - 5 * 60_000, 25)],+ netin: [point(end - 10 * 60_000, 200), point(end - 5 * 60_000, 400)],+ netout: [point(end - 10 * 60_000, 100), point(end - 5 * 60_000, 300)],+ },+ }),+ );+ mount();+ await screen.findByRole('slider', { name: 'Inspect Network I/O history' });+ const labels = (id: string) =>+ Array.from(+ group(id).querySelectorAll('[data-history-axis-label]'),+ (label) => label.textContent,+ );+ expect(labels('network')).toEqual(['<1K/s', '', '0']);+ expect(labels('utilization')).toEqual(['100%', '50%', '0%']);+ });+});+describe('GuestDrawerHistory shared time window', () => {it('does not stretch five minutes of stored CPU across a 24-hour query', async () => {vi.spyOn(ChartsAPI, 'getMetricsHistory').mockResolvedValue(response());diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsxindex 935871e28b..bf1f92255b 100644--- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx@@ -15,8 +15,11 @@ import type { HistoryChartState } from '@/components/shared/useHistoryChartStateimport { HistoryChart, HistoryChartHoverGroup } from '@/components/shared/HistoryChart';import {formatHistoryChartTooltipValue,+ getHistoryChartTimeTickCount,getHistoryChartTooltipLayout,+ getHistoryChartYAxisLabels,HISTORY_CHART_RANGES,+ withoutRepeatedHistoryAxisLabels,} from '@/components/shared/historyChartModel';it('distinguishes tiny positive percentage observations from zero in History labels', () => {@@ -126,6 +129,33 @@ vi.mock('@/api/charts', () => ({},}));+describe('History chart axis labels', () => {+ it('fits as many time labels as the plot holds without touching', () => {+ // "11:30 AM" is about 45px at 10px sans-serif; neighbours need 57px apart.+ expect(getHistoryChartTimeTickCount(600, 45)).toBe(4);+ expect(getHistoryChartTimeTickCount(171, 45)).toBe(4);+ expect(getHistoryChartTimeTickCount(170, 45)).toBe(3);+ expect(getHistoryChartTimeTickCount(150, 45)).toBe(3);+ expect(getHistoryChartTimeTickCount(100, 45)).toBe(2);+ expect(getHistoryChartTimeTickCount(30, 45)).toBe(2);+ expect(getHistoryChartTimeTickCount(0, 45)).toBe(4);+ });++ it('blanks a middle gridline label that repeats a neighbour', () => {+ expect(withoutRepeatedHistoryAxisLabels(['<1K/s', '<1K/s', '0'])).toEqual(['<1K/s', '', '0']);+ expect(withoutRepeatedHistoryAxisLabels(['1', '1', '0'])).toEqual(['1', '', '0']);+ expect(withoutRepeatedHistoryAxisLabels(['0', '0', '0'])).toEqual(['0', '', '0']);+ expect(withoutRepeatedHistoryAxisLabels(['0', '50', '100'])).toEqual(['0', '50', '100']);+ // A rounded range of 0-1 would read 0, 1, 1 bottom to top.+ expect(+ getHistoryChartYAxisLabels(+ { minValue: 0, maxValue: 1, isPercentLike: false, isByteLike: false },+ 'sectors',+ ).map((tick) => tick.label),+ ).toEqual(['0', '', '1']);+ });+});+describe('HistoryChart', () => {it('keeps the history chart on shell, runtime, and model owners', () => {expect(historyChartSource).toContain('useHistoryChartState');diff --git a/frontend-modern/src/components/shared/__tests__/historyChartModel.branchcov2.test.ts b/frontend-modern/src/components/shared/__tests__/historyChartModel.branchcov2.test.tsindex a2f9595624..573d919303 100644--- a/frontend-modern/src/components/shared/__tests__/historyChartModel.branchcov2.test.ts+++ b/frontend-modern/src/components/shared/__tests__/historyChartModel.branchcov2.test.ts@@ -18,6 +18,8 @@ import {getHistoryChartTooltipLayout,getHistoryChartYAxisLabels,} from '@/components/shared/historyChartModel';+import { DISK_DETAIL_HISTORY_RANGE_OPTIONS } from '@/features/storageBackups/diskDetailPresentation';+import { STORAGE_POOL_DETAIL_HISTORY_RANGE_OPTIONS } from '@/features/storageBackups/storagePoolDetailPresentation';const pt = (timestamp: number, value: number, min: number, max: number): AggregatedMetricPoint => ({timestamp,@@ -598,11 +600,7 @@ describe('getHistoryChartTooltipLayout', () => {});describe('formatHistoryRangeOptionLabel', () => {- it('names every range one way across drawer, disk and pool pickers', async () => {- const { DISK_DETAIL_HISTORY_RANGE_OPTIONS } =- await import('@/features/storageBackups/diskDetailPresentation');- const { STORAGE_POOL_DETAIL_HISTORY_RANGE_OPTIONS } =- await import('@/features/storageBackups/storagePoolDetailPresentation');+ it('names every range one way across drawer, disk and pool pickers', () => {expect(formatHistoryRangeOptionLabel('1h')).toBe('1 hour');expect(formatHistoryRangeOptionLabel('24h')).toBe('24 hours');expect(formatHistoryRangeOptionLabel('7d')).toBe('7 days');diff --git a/frontend-modern/src/components/shared/historyChartModel.ts b/frontend-modern/src/components/shared/historyChartModel.tsindex c9475114c3..402f7f8aaa 100644--- a/frontend-modern/src/components/shared/historyChartModel.ts+++ b/frontend-modern/src/components/shared/historyChartModel.ts@@ -213,7 +213,7 @@ export function getHistoryChartYAxisLabels(},unit?: string,) {- return [0, 0.5, 1].map((pct) => {+ const ticks = [0, 0.5, 1].map((pct) => {const scaleValue = minValue + pct * (maxValue - minValue);let label: string;if (isPercentLike) {@@ -225,6 +225,44 @@ export function getHistoryChartYAxisLabels(}return { pct, label };});+ const labels = withoutRepeatedHistoryAxisLabels(ticks.map((tick) => tick.label));+ return ticks.map((tick, index) => ({ ...tick, label: labels[index] }));+}++/**+ * Gridline labels in axis order. A middle label that reads the same as a+ * neighbour (a small range rounded, or "<1K/s" twice on a quiet link) says+ * nothing and crowds the axis, so it is left blank; the gridline stays. The+ * end labels always remain.+ */+export function withoutRepeatedHistoryAxisLabels(labels: string[]): string[] {+ return labels.map((label, index) =>+ index > 0 &&+ index < labels.length - 1 &&+ (label === labels[index - 1] || label === labels[index + 1])+ ? ''+ : label,+ );+}++const HISTORY_CHART_TIME_LABEL_GAP = 12;++/**+ * How many evenly spaced time labels fit along a plot of `plotWidth` pixels+ * when the widest label is `labelWidth` pixels, from `maxCount` down to the+ * first and last time. Labels are centred on their times, so neighbours need+ * a label's width plus a gap between their centres.+ */+export function getHistoryChartTimeTickCount(+ plotWidth: number,+ labelWidth: number,+ maxCount = 4,+): number {+ if (!(plotWidth > 0) || !(labelWidth > 0)) return maxCount;+ for (let count = maxCount; count > 2; count--) {+ if (plotWidth / (count - 1) >= labelWidth + HISTORY_CHART_TIME_LABEL_GAP) return count;+ }+ return 2;}export function getHistoryChartLeftInset(labelWidths: number[]) {diff --git a/frontend-modern/src/components/shared/useHistoryChartState.ts b/frontend-modern/src/components/shared/useHistoryChartState.tsindex c906379e42..9b9a4a70c0 100644--- a/frontend-modern/src/components/shared/useHistoryChartState.ts+++ b/frontend-modern/src/components/shared/useHistoryChartState.ts@@ -18,6 +18,7 @@ import {getHistoryChartRefreshIntervalMs,getHistoryChartRightInset,getHistoryChartScale,+ getHistoryChartTimeTickCount,getHistoryChartYAxisLabels,type HistoryChartProps,type HistoryChartHoverPoint,@@ -244,8 +245,19 @@ export function useHistoryChartState(const mainColor = getHistoryChartDefaultColor(props.metric, props.color);const scale = getHistoryChartScale(points, props.unit);const yAxisTicks = getHistoryChartYAxisLabels(scale, props.unit);- const labelCount = 4;- const timeAxisTicks =+ const timeTicks = (count: number) =>+ Array.from({ length: count }, (_, index) => {+ const timestamp =+ points[0].timestamp ++ ((points[points.length - 1].timestamp - points[0].timestamp) * index) / (count - 1);+ return { timestamp, label: formatHistoryChartTimeLabel(timestamp, range()) };+ });++ ctx.font = '10px sans-serif';+ chartLeftInset = getHistoryChartLeftInset(+ yAxisTicks.map((tick) => ctx.measureText(tick.label).width),+ );+ let timeAxisTicks =points.length === 1? [{@@ -254,24 +266,23 @@ export function useHistoryChartState(},]: points.length > 0- ? Array.from({ length: labelCount }, (_, index) => {- const timestamp =- points[0].timestamp +- ((points[points.length - 1].timestamp - points[0].timestamp) * index) /- (labelCount - 1);- return { timestamp, label: formatHistoryChartTimeLabel(timestamp, range()) };- })+ ? timeTicks(4): [];-- ctx.font = '10px sans-serif';- chartLeftInset = getHistoryChartLeftInset(- yAxisTicks.map((tick) => ctx.measureText(tick.label).width),- );chartRightInset = getHistoryChartRightInset(timeAxisTicks.length > 0? ctx.measureText(timeAxisTicks[timeAxisTicks.length - 1].label).width: 0,);+ // A narrow card fits fewer time labels: as many as fit without touching,+ // down to the first and last time.+ if (timeAxisTicks.length > 2) {+ const count = getHistoryChartTimeTickCount(+ width - chartLeftInset - chartRightInset,+ Math.max(...timeAxisTicks.map((tick) => ctx.measureText(tick.label).width)),+ timeAxisTicks.length,+ );+ if (count < timeAxisTicks.length) timeAxisTicks = timeTicks(count);+ }ctx.strokeStyle = gridColor;ctx.lineWidth = 1;