fix(ui): prevent findings timeline axis overflow (#11545)

This commit is contained in:
Alan Buscaglia
2026-07-21 11:22:19 +02:00
committed by GitHub
parent 97233189c3
commit bb20f69a63
4 changed files with 54 additions and 0 deletions
@@ -0,0 +1 @@
Findings Severity Over Time chart Y-axis labels no longer overflow for large findings counts
+42
View File
@@ -0,0 +1,42 @@
import { describe, expect, it } from "vitest";
import { formatYAxisTick } from "./line-chart.utils";
describe("formatYAxisTick", () => {
describe("when findings counts are large", () => {
it("should compact six-digit values so Y-axis labels do not overflow", () => {
// Given
const tickValue = 150000;
// When
const formattedValue = formatYAxisTick(tickValue);
// Then
expect(formattedValue).toBe("150K");
});
it("should compact million-scale values", () => {
// Given
const tickValue = 1200000;
// When
const formattedValue = formatYAxisTick(tickValue);
// Then
expect(formattedValue).toBe("1.2M");
});
});
describe("when findings counts are small", () => {
it("should keep values below 1000 readable without compact notation", () => {
// Given
const tickValue = 999;
// When
const formattedValue = formatYAxisTick(tickValue);
// Then
expect(formattedValue).toBe("999");
});
});
});
+3
View File
@@ -17,6 +17,7 @@ import {
ChartTooltip,
} from "@/components/shadcn/chart/Chart";
import { formatYAxisTick } from "./line-chart.utils";
import { AlertPill } from "./shared/alert-pill";
import { ChartLegend } from "./shared/chart-legend";
import { CustomActiveDot, PointClickData } from "./shared/custom-active-dot";
@@ -222,6 +223,8 @@ export function LineChart({
tickLine={false}
axisLine={false}
tickMargin={8}
tickFormatter={formatYAxisTick}
width={56}
padding={{ top: 20 }}
tick={{
fill: "var(--color-text-neutral-secondary)",
+8
View File
@@ -0,0 +1,8 @@
const Y_AXIS_TICK_FORMATTER = new Intl.NumberFormat("en-US", {
notation: "compact",
maximumFractionDigits: 1,
});
export function formatYAxisTick(value: number) {
return Y_AXIS_TICK_FORMATTER.format(value);
}