@@ -72,10 +72,18 @@ async function loadGraphData(selector: GraphsSelector, loading: Ref<boolean>) {
7272    .map ((benchmark ) =>  Object .keys (graphData .benchmarks [benchmark ]).length ) 
7373    .reduce ((sum , item ) =>  sum  +  item , 0 ); 
7474
75-   const   columns =  countGraphs  ===  1  ?  1  :  4 ; 
75+   const   parentWidth =  wrapperRef .value .clientWidth ; 
76+   let  columns =  countGraphs  ===  1  ?  1  :  4 ; 
7677
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 ; 
7987
8088  const   bodyEl =  document .querySelector (" body.container"  )! ; 
8189  const   chartsEl =  document .getElementById (" charts"  )! ; 
@@ -133,8 +141,10 @@ function updateSelection(params: SelectionParams) {
133141const   info:  BenchmarkInfo  =  await  loadBenchmarkInfo ();
134142
135143const   loading =  ref (true );
144+ const   wrapperRef =  ref (null );
136145
137146const   selector:  GraphsSelector  =  loadSelectorFromUrl (getUrlParams ());
147+ 
138148loadGraphData (selector , loading );
139149 </script >
140150
@@ -156,21 +166,29 @@ loadGraphData(selector, loading);
156166    interpolated due to missing data. Interpolated data is simply the last known
157167    data point repeated until another known data point is found.
158168  </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 >
171184      </div >
172-       <div   id = " size-charts " ></ div >
185+       <AsOf   :info = " info "  / >
173186    </div >
174-     <AsOf  :info =" info"   />
175187  </div >
176188</template >
189+ 
190+ <style  lang="scss" scoped>
191+ .wrapper  {
192+   width  : 100%  ; 
193+ } 
194+  </style >
0 commit comments