Skip to content

Commit 03e4bd1

Browse files
committed
Show absolute values on hover in fraction chart
1 parent 12f0a92 commit 03e4bd1

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

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

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,24 @@ function calculate_width(value: number, totalDuration: number): string {
3535
return `${(fraction * 100).toFixed(2)}%`;
3636
}
3737
38+
function getSectionByName(
39+
sections: CompilationSections,
40+
name: string
41+
): CompilationSection | null {
42+
const values = sections.sections.filter((s) => s.name === name);
43+
if (values.length === 0) {
44+
return null;
45+
}
46+
return values[0];
47+
}
48+
3849
function formatPercent(
3950
sections: CompilationSections,
4051
sectionName: string
4152
): string {
42-
const values = sections.sections.filter((s) => s.name === sectionName);
43-
if (values.length === 0) return "??";
44-
const value = values[0].value;
53+
const section = getSectionByName(sections, sectionName);
54+
if (section === null) return "??";
55+
const value = section.value;
4556
const total = calculateTotalSectionsDuration(sections);
4657
const percent = (value / total) * 100;
4758
return `${percent.toFixed(2)}%`;
@@ -107,8 +118,19 @@ function deactivate() {
107118
<b>{{ section.name }}</b>
108119
</div>
109120
<div>
110-
{{ formatPercent(props.before, section.name) }} ->
111-
{{ formatPercent(props.after, section.name) }}
121+
<div>
122+
{{ formatPercent(props.before, section.name) }} ->
123+
{{ formatPercent(props.after, section.name) }}
124+
</div>
125+
<div>
126+
{{
127+
getSectionByName(props.before, section.name)?.value ?? "??"
128+
}}
129+
->
130+
{{
131+
getSectionByName(props.after, section.name)?.value ?? "??"
132+
}}
133+
</div>
112134
</div>
113135
</div>
114136
</div>

0 commit comments

Comments
 (0)