Skip to content

Commit b4f6ba6

Browse files
committed
add toggle between linear and log
1 parent 8f93b9b commit b4f6ba6

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

site/frontend/src/pages/dashboard.ts

+25-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ import {DASHBOARD_DATA_URL} from "../urls";
33

44
import {getJson} from "../utils/requests";
55

6+
type ScaleKind = "linear" | "log";
7+
let scale: ScaleKind = "linear";
8+
9+
const buttons = Array.from(
10+
document.querySelectorAll<HTMLInputElement>("#scale-select-form input")
11+
);
12+
13+
buttons.map((button) => {
14+
button.addEventListener("change", () => {
15+
if (button.checked) {
16+
scale = button.value as ScaleKind;
17+
make_data();
18+
}
19+
});
20+
});
21+
622
interface DashboardCompileBenchmarkCases {
723
clean_averages: [number];
824
base_incr_averages: [number];
@@ -44,8 +60,8 @@ function render(
4460
},
4561
yAxis: {
4662
title: {text: "Seconds"},
47-
min: Math.min(...Object.keys(data).flatMap((key) => data[key])),
48-
type: "logarithmic",
63+
min: scale === "linear" ? 0 : undefined,
64+
type: scale === "log" ? "logarithmic" : undefined,
4965
},
5066
xAxis: {
5167
categories: versions,
@@ -101,8 +117,8 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
101117
},
102118
yAxis: {
103119
title: {text: "Miliseconds"},
104-
min: Math.min(...formattedData),
105-
type: "logarithmic",
120+
min: scale === "linear" ? 0 : undefined,
121+
type: scale === "log" ? "logarithmic" : undefined,
106122
},
107123
xAxis: {
108124
categories: versions.slice(nullCount),
@@ -128,8 +144,12 @@ function populate_data(response: DashboardResponse) {
128144
renderRuntime("runtime-average-times", data.runtime, data.versions);
129145
}
130146

147+
let response: DashboardResponse | null = null;
131148
async function make_data() {
132-
const response = await getJson<DashboardResponse>(DASHBOARD_DATA_URL);
149+
if (!response) {
150+
response = await getJson<DashboardResponse>(DASHBOARD_DATA_URL);
151+
}
152+
133153
populate_data(response);
134154
}
135155

site/frontend/templates/pages/dashboard.html

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
compiled by a given version of the Rust compiler.
2525
</details>
2626

27+
<form id="scale-select-form">
28+
<label>
29+
<input type="radio" name="scale-select" value="linear" checked />
30+
Linear-scale
31+
</label>
32+
<label>
33+
<input type="radio" name="scale-select" value="log" />
34+
Log-scale
35+
</label>
36+
</form>
37+
2738
<div class="graphs">
2839
<div id="check-average-times"></div>
2940
<div id="debug-average-times"></div>

0 commit comments

Comments
 (0)