Skip to content

Commit 793bdf4

Browse files
carlosthe19916mrizzi
authored andcommitted
fix: Add a numeration prefix to each Bar name to avoid collision
1 parent 1ce8d54 commit 793bdf4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

spog/ui/crates/donut/js/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spog/ui/crates/donut/patternfly-charts/src/SbomStackChart.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ interface StackChartProps {
3333
};
3434
}
3535

36+
const generateSbomBarName = (sbom: StackChartProps, index: number) => {
37+
return `${Math.abs(index - 10)}. ${sbom.sbom_name}`;
38+
};
39+
3640
export const SbomStackChartRenderer = (htmlElement: HTMLElement, props: StackChartProps[]) => {
3741
const showTickValues = props.every((item) => {
3842
return (
@@ -95,7 +99,9 @@ export const SbomStackChartRenderer = (htmlElement: HTMLElement, props: StackCha
9599
events={{
96100
onClick: (event) => {
97101
const sbom_name = (event.target as any).innerHTML as string | null;
98-
const sbom = props.find((item) => item.sbom_name === sbom_name);
102+
const sbom = props.find(
103+
(item, index) => generateSbomBarName(item, index) === sbom_name,
104+
);
99105
if (sbom) {
100106
const sbomDetailsPage = `/sbom/content/${sbom.sbom_id}`;
101107

@@ -132,12 +138,12 @@ export const SbomStackChartRenderer = (htmlElement: HTMLElement, props: StackCha
132138
<ChartBar
133139
key={legend.name}
134140
labelComponent={<ChartTooltip constrainToVisibleArea />}
135-
data={props.map((sbom) => {
141+
data={props.map((sbom, index) => {
136142
const severityKey = legend.severity;
137143
const count = sbom.vulnerabilities[severityKey] as number;
138144
return {
139145
name: legend.name,
140-
x: sbom.sbom_name,
146+
x: generateSbomBarName(sbom, index),
141147
y: count,
142148
label: `${legend.name}: ${count}`,
143149
};

0 commit comments

Comments
 (0)