diff --git a/site/frontend/src/pages/dashboard.ts b/site/frontend/src/pages/dashboard.ts index e0848d3f2..51d644c79 100644 --- a/site/frontend/src/pages/dashboard.ts +++ b/site/frontend/src/pages/dashboard.ts @@ -3,6 +3,22 @@ import {DASHBOARD_DATA_URL} from "../urls"; import {getJson} from "../utils/requests"; +type ScaleKind = "linear" | "log"; +let scale: ScaleKind = "linear"; + +const buttons = Array.from( + document.querySelectorAll("#scale-select-form input") +); + +buttons.map((button) => { + button.addEventListener("change", () => { + if (button.checked) { + scale = button.value as ScaleKind; + make_data(); + } + }); +}); + interface DashboardCompileBenchmarkCases { clean_averages: [number]; base_incr_averages: [number]; @@ -44,7 +60,8 @@ function render( }, yAxis: { title: {text: "Seconds"}, - min: 0, + min: scale === "linear" ? 0 : undefined, + type: scale === "log" ? "logarithmic" : undefined, }, xAxis: { categories: versions, @@ -100,7 +117,8 @@ function renderRuntime(element: string, data: [number], versions: [string]) { }, yAxis: { title: {text: "Miliseconds"}, - min: 0, + min: scale === "linear" ? 0 : undefined, + type: scale === "log" ? "logarithmic" : undefined, }, xAxis: { categories: versions.slice(nullCount), @@ -126,8 +144,12 @@ function populate_data(response: DashboardResponse) { renderRuntime("runtime-average-times", data.runtime, data.versions); } +let response: DashboardResponse | null = null; async function make_data() { - const response = await getJson(DASHBOARD_DATA_URL); + if (!response) { + response = await getJson(DASHBOARD_DATA_URL); + } + populate_data(response); } diff --git a/site/frontend/templates/pages/dashboard.html b/site/frontend/templates/pages/dashboard.html index 8010544be..b502addea 100644 --- a/site/frontend/templates/pages/dashboard.html +++ b/site/frontend/templates/pages/dashboard.html @@ -24,6 +24,17 @@ compiled by a given version of the Rust compiler. +
+ + +
+