Skip to content

Commit 9cb29cb

Browse files
committed
fix: a couple of UI fixes
* Fixes that tooltips were being cropped in the report list and removes a workaround. * Only shows tooltips on the stacked chart if there is no legend.
1 parent e78580b commit 9cb29cb

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

report-app/src/app/app.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
.report-content {
4343
flex-grow: 1;
44-
overflow-y: auto;
4544
min-width: 700px;
4645
min-height: 100vh;
4746
}

report-app/src/app/pages/report-viewer/report-viewer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ expansion-panel {
187187
border-radius: var(--border-radius);
188188
padding: 10px;
189189
max-height: 300px;
190-
overflow-y: auto;
190+
overflow: auto;
191191
}
192192

193193
.no-failed-checks {

report-app/src/app/shared/visualization/stacked-bar-chart.ts

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export type StackedBarChartData = Array<{
1919
class="segment"
2020
[style.width.%]="asPercent(item.value)"
2121
[style.background-color]="item.color"
22-
(click)="toggleDisplayMode(item)"
23-
[attr.data-tooltip]="getTooltipText(item)"
22+
(click)="toggleDisplayMode()"
23+
[attr.data-tooltip]="showLegend() ? null : item.label"
2424
>
25-
{{ getItemDisplayValue(item, displayPercentage()) }}
25+
{{ getItemDisplayValue(item) }}
2626
</div>
2727
}
2828
}
@@ -53,7 +53,6 @@ export type StackedBarChartData = Array<{
5353
.chart-container {
5454
width: 100%;
5555
background-color: var(--card-bg-color);
56-
border-radius: 12px;
5756
}
5857
5958
.stacked-bar {
@@ -112,6 +111,7 @@ export type StackedBarChartData = Array<{
112111
align-items: center;
113112
font-size: 14px;
114113
color: var(--text-secondary);
114+
white-space: nowrap;
115115
}
116116
117117
.legend-color {
@@ -121,7 +121,7 @@ export type StackedBarChartData = Array<{
121121
margin-right: 8px;
122122
}
123123
124-
.segment::before {
124+
.segment[data-tooltip]::before {
125125
content: attr(data-tooltip); /* Use a data attribute for the text */
126126
position: absolute;
127127
bottom: 110%; /* Position it above the segment */
@@ -141,12 +141,6 @@ export type StackedBarChartData = Array<{
141141
z-index: 10;
142142
}
143143
144-
.segment:last-child:not(:only-child)::before {
145-
right: 0;
146-
left: auto;
147-
transform: none;
148-
}
149-
150144
/* Show tooltip on hover */
151145
.segment:hover::before,
152146
.segment:hover::after {
@@ -163,6 +157,7 @@ export class StackedBarChart {
163157
total = computed(() =>
164158
this.data().reduce((acc, item) => acc + item.value, 0)
165159
);
160+
166161
protected displayPercentage = signal(false);
167162

168163
asPercent(value: number) {
@@ -171,23 +166,14 @@ export class StackedBarChart {
171166
return parseFloat(percentage.toFixed(percentage % 1 === 0 ? 0 : 1));
172167
}
173168

174-
toggleDisplayMode(item: StackedBarChartData[0]): void {
169+
toggleDisplayMode(): void {
175170
this.displayPercentage.update((current) => !current);
176171
}
177172

178-
getItemDisplayValue(
179-
item: StackedBarChartData[0],
180-
showPercent: boolean
181-
): string {
173+
getItemDisplayValue(item: StackedBarChartData[0]): string {
182174
if (item.value === 0) return '';
183-
return showPercent ? `${this.asPercent(item.value)}%` : `${item.value}`;
184-
}
185-
186-
getTooltipText(item: StackedBarChartData[0]) {
187-
if (!this.showLegend()) {
188-
return item.label;
189-
}
190-
191-
return this.getItemDisplayValue(item, !this.displayPercentage());
175+
return this.displayPercentage()
176+
? `${this.asPercent(item.value)}%`
177+
: `${item.value}`;
192178
}
193179
}

0 commit comments

Comments
 (0)