@@ -3,6 +3,22 @@ import {DASHBOARD_DATA_URL} from "../urls";
3
3
4
4
import { getJson } from "../utils/requests" ;
5
5
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
+
6
22
interface DashboardCompileBenchmarkCases {
7
23
clean_averages : [ number ] ;
8
24
base_incr_averages : [ number ] ;
@@ -44,8 +60,8 @@ function render(
44
60
} ,
45
61
yAxis : {
46
62
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 ,
49
65
} ,
50
66
xAxis : {
51
67
categories : versions ,
@@ -101,8 +117,8 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
101
117
} ,
102
118
yAxis : {
103
119
title : { text : "Miliseconds" } ,
104
- min : Math . min ( ... formattedData ) ,
105
- type : " logarithmic",
120
+ min : scale === "linear" ? 0 : undefined ,
121
+ type : scale === "log" ? " logarithmic" : undefined ,
106
122
} ,
107
123
xAxis : {
108
124
categories : versions . slice ( nullCount ) ,
@@ -128,8 +144,12 @@ function populate_data(response: DashboardResponse) {
128
144
renderRuntime ( "runtime-average-times" , data . runtime , data . versions ) ;
129
145
}
130
146
147
+ let response : DashboardResponse | null = null ;
131
148
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
+
133
153
populate_data ( response ) ;
134
154
}
135
155
0 commit comments