Skip to content

Commit 83f0454

Browse files
committed
Make fraction chart relative
Before, it was being normalized w.r.t. the longest total duration between the before/after artifact, but that was confusing. Now the chart just shows the relative duration w.r.t. its corresponding artifact.
1 parent dc2ac6a commit 83f0454

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

site/frontend/src/pages/compare/compile/table/sections-chart.vue

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ const props = defineProps<{
77
after: CompilationSections;
88
}>();
99
10-
const maxTotalDuration = computed(() => {
11-
const before = calculateTotalSectionsDuration(props.before);
12-
const after = calculateTotalSectionsDuration(props.after);
13-
return Math.max(before, after);
14-
});
15-
1610
function calculateTotalSectionsDuration(sections: CompilationSections): number {
1711
return sections.sections.reduce((accum, section) => accum + section.value, 0);
1812
}
1913
14+
const beforeTotalWidth = computed(() => {
15+
return calculateTotalSectionsDuration(props.before);
16+
});
17+
const afterTotalWidth = computed(() => {
18+
return calculateTotalSectionsDuration(props.after);
19+
});
20+
2021
const SECTIONS_PALETTE = [
2122
"#7768AE",
2223
"#FFCf96",
@@ -29,8 +30,8 @@ function getSectionColor(index: number): string {
2930
return SECTIONS_PALETTE[index % SECTIONS_PALETTE.length];
3031
}
3132
32-
function calculate_width(value: number): string {
33-
const fraction = value / maxTotalDuration.value;
33+
function calculate_width(value: number, totalDuration: number): string {
34+
const fraction = value / totalDuration;
3435
return `${(fraction * 100).toFixed(2)}%`;
3536
}
3637
@@ -87,7 +88,10 @@ function deactivate() {
8788
@mouseenter="activate(section.name)"
8889
@mouseleave="deactivate"
8990
:style="{
90-
width: calculate_width(section.value),
91+
width: calculate_width(
92+
section.value,
93+
rowIndex == 0 ? beforeTotalWidth : afterTotalWidth
94+
),
9195
backgroundColor: getSectionColor(index),
9296
}"
9397
>
@@ -147,7 +151,6 @@ function deactivate() {
147151
width: calc(100% - 60px);
148152
display: flex;
149153
flex-direction: row;
150-
border-right: 1px dashed #333333;
151154
152155
.section {
153156
height: 30px;

0 commit comments

Comments
 (0)