Threat score has{" "}
@@ -178,8 +183,7 @@ export function ThreatScore({
Major gaps include {gaps.slice(0, 2).join(", ")}
diff --git a/ui/components/graphs/donut-chart.tsx b/ui/components/graphs/donut-chart.tsx
index 8bd0bf8181..54dfb406ce 100644
--- a/ui/components/graphs/donut-chart.tsx
+++ b/ui/components/graphs/donut-chart.tsx
@@ -18,6 +18,7 @@ interface DonutChartProps {
value: string | number;
label: string;
};
+ onSegmentClick?: (dataPoint: DonutDataPoint, index: number) => void;
}
const CustomTooltip = ({ active, payload }: any) => {
@@ -72,6 +73,7 @@ export function DonutChart({
outerRadius = 86,
showLegend = true,
centerLabel,
+ onSegmentClick,
}: DonutChartProps) {
const [hoveredIndex, setHoveredIndex] = useState(null);
@@ -137,14 +139,23 @@ export function DonutChart({
{(isEmpty ? emptyData : chartData).map((entry, index) => {
const opacity =
hoveredIndex === null ? 1 : hoveredIndex === index ? 1 : 0.5;
+ const isClickable = !isEmpty && onSegmentClick;
return (
setHoveredIndex(index)}
onMouseLeave={() => setHoveredIndex(null)}
+ onClick={() => {
+ if (isClickable) {
+ onSegmentClick(data[index], index);
+ }
+ }}
/>
);
})}
diff --git a/ui/components/graphs/horizontal-bar-chart.tsx b/ui/components/graphs/horizontal-bar-chart.tsx
index 9b1291fa60..a708e0151d 100644
--- a/ui/components/graphs/horizontal-bar-chart.tsx
+++ b/ui/components/graphs/horizontal-bar-chart.tsx
@@ -12,12 +12,14 @@ interface HorizontalBarChartProps {
height?: number;
title?: string;
labelWidth?: string;
+ onBarClick?: (dataPoint: BarDataPoint, index: number) => void;
}
export function HorizontalBarChart({
data,
title,
labelWidth = "w-20",
+ onBarClick,
}: HorizontalBarChartProps) {
const [hoveredIndex, setHoveredIndex] = useState(null);
@@ -58,12 +60,33 @@ export function HorizontalBarChart({
getSeverityColorByName(item.name) ||
"var(--bg-neutral-tertiary)";
+ const isClickable = !isEmpty && onBarClick;
return (
!isEmpty && setHoveredIndex(index)}
onMouseLeave={() => !isEmpty && setHoveredIndex(null)}
+ onClick={() => {
+ if (isClickable) {
+ const originalIndex = data.findIndex(
+ (d) => d.name === item.name,
+ );
+ onBarClick(data[originalIndex], originalIndex);
+ }
+ }}
+ onKeyDown={(e) => {
+ if (isClickable && (e.key === "Enter" || e.key === " ")) {
+ e.preventDefault();
+ const originalIndex = data.findIndex(
+ (d) => d.name === item.name,
+ );
+ onBarClick(data[originalIndex], originalIndex);
+ }
+ }}
>
{/* Label */}
|