@@ -3,6 +3,22 @@ import {DASHBOARD_DATA_URL} from "../urls";
33
44import { 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+
622interface 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 ;
131148async 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
0 commit comments