@@ -72,10 +72,18 @@ async function loadGraphData(selector: GraphsSelector, loading: Ref<boolean>) {
72
72
.map ((benchmark ) => Object .keys (graphData .benchmarks [benchmark ]).length )
73
73
.reduce ((sum , item ) => sum + item , 0 );
74
74
75
- const columns = countGraphs === 1 ? 1 : 4 ;
75
+ const parentWidth = wrapperRef .value .clientWidth ;
76
+ let columns = countGraphs === 1 ? 1 : 4 ;
76
77
77
- const root = document .getElementById (" app" )! ;
78
- const width = Math .max (Math .floor (root .clientWidth / columns ), 380 );
78
+ // Small display, reduce column count to 1
79
+ if (parentWidth < 1000 ) {
80
+ columns = 1 ;
81
+ }
82
+
83
+ // Calculate the width of each column.
84
+ // Provide a 10px buffer to avoid wrapping if the size is just at the limit
85
+ // of the parent.
86
+ const width = Math .floor (wrapperRef .value .clientWidth / columns ) - 10 ;
79
87
80
88
const bodyEl = document .querySelector (" body.container" )! ;
81
89
const chartsEl = document .getElementById (" charts" )! ;
@@ -133,8 +141,10 @@ function updateSelection(params: SelectionParams) {
133
141
const info: BenchmarkInfo = await loadBenchmarkInfo ();
134
142
135
143
const loading = ref (true );
144
+ const wrapperRef = ref (null );
136
145
137
146
const selector: GraphsSelector = loadSelectorFromUrl (getUrlParams ());
147
+
138
148
loadGraphData (selector , loading );
139
149
</script >
140
150
@@ -156,21 +166,29 @@ loadGraphData(selector, loading);
156
166
interpolated due to missing data. Interpolated data is simply the last known
157
167
data point repeated until another known data point is found.
158
168
</div >
159
- <div v-if =" loading" >
160
- <h2 >Loading & ; rendering data..</h2 >
161
- <h3 >This may take a while!</h3 >
162
- </div >
163
- <div v-else >
164
- <div id =" charts" ></div >
165
- <div
166
- v-if =" !hasSpecificSelection(selector)"
167
- style =" margin-top : 50px ; border-top : 1px solid #ccc "
168
- >
169
- <div style =" padding : 20px 0 " >
170
- <strong >Benchmarks optimized for small binary size</strong >
169
+ <div class =" wrapper" ref =" wrapperRef" >
170
+ <div v-if =" loading" >
171
+ <h2 >Loading & ; rendering data..</h2 >
172
+ <h3 >This may take a while!</h3 >
173
+ </div >
174
+ <div v-else >
175
+ <div id =" charts" ></div >
176
+ <div
177
+ v-if =" !hasSpecificSelection(selector)"
178
+ style =" margin-top : 50px ; border-top : 1px solid #ccc "
179
+ >
180
+ <div style =" padding : 20px 0 " >
181
+ <strong >Benchmarks optimized for small binary size</strong >
182
+ </div >
183
+ <div id =" size-charts" ></div >
171
184
</div >
172
- <div id = " size-charts " ></ div >
185
+ <AsOf :info = " info " / >
173
186
</div >
174
- <AsOf :info =" info" />
175
187
</div >
176
188
</template >
189
+
190
+ <style lang="scss" scoped>
191
+ .wrapper {
192
+ width : 100% ;
193
+ }
194
+ </style >
0 commit comments