Skip to content

Commit 725ca02

Browse files
committed
expand when only one graph is selected
1 parent 1cbb6b3 commit 725ca02

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

site/frontend/src/graph/render.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ function normalizeData(data: CompileGraphData) {
400400
export type GraphRenderOpts = {
401401
// Width of the graph
402402
width: number;
403+
// Height of the graph
404+
height: number;
403405
// Render a title above the graph
404406
renderTitle?: boolean;
405407
// Function that can be used to hook into the rendering process
@@ -416,7 +418,7 @@ export function renderPlots(
416418
) {
417419
const renderTitle = opts.renderTitle ?? true;
418420
const hooks = opts.hooks ?? {};
419-
const width = opts.width;
421+
const {width, height} = opts;
420422

421423
normalizeData(data);
422424

@@ -504,7 +506,7 @@ export function renderPlots(
504506

505507
let plotOpts = genPlotOpts({
506508
width,
507-
height: 300,
509+
height,
508510
yAxisLabel,
509511
series: seriesOpts,
510512
commits: data.commits,
@@ -534,7 +536,7 @@ export function renderRuntimePlots(
534536
) {
535537
const renderTitle = opts.renderTitle ?? true;
536538
const hooks = opts.hooks ?? {};
537-
const width = opts.width;
539+
const {width, height} = opts;
538540

539541
const benchNames = Object.keys(data.benchmarks).sort();
540542

@@ -610,7 +612,7 @@ export function renderRuntimePlots(
610612

611613
let plotOpts = genPlotOpts({
612614
width,
613-
height: 300,
615+
height,
614616
yAxisLabel,
615617
series: seriesOpts,
616618
commits: data.commits,

site/frontend/src/pages/compare/compile/table/benchmark-detail-graph.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ async function renderGraph(
120120
) {
121121
const opts: GraphRenderOpts = {
122122
width: Math.min(window.innerWidth - 40, 465),
123+
height: 300,
123124
renderTitle: false,
124125
};
125126
if (date !== null) {

site/frontend/src/pages/compare/runtime/benchmark-detail-graph.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ async function renderGraph(
109109
) {
110110
const opts: GraphRenderOpts = {
111111
width: Math.min(window.innerWidth - 40, 465),
112+
height: 300,
112113
renderTitle: false,
113114
};
114115
if (date !== null) {

site/frontend/src/pages/graphs/page.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,26 @@ async function loadGraphData(selector: GraphsSelector, loading: Ref<boolean>) {
6868
// Then draw the plots.
6969
await nextTick();
7070
71-
const width = Math.max(Math.floor(window.innerWidth / 4) - 40, 380);
72-
const opts = {width};
71+
const countGraphs = Object.keys(graphData.benchmarks)
72+
.map((benchmark) => Object.keys(graphData.benchmarks[benchmark]).length)
73+
.reduce((sum, item) => sum + item, 0);
74+
75+
const columns = countGraphs === 1 ? 1 : 4;
76+
77+
const root = document.getElementById("app")!;
78+
const width = Math.max(Math.floor(root.clientWidth / columns), 380);
79+
80+
const bodyEl = document.querySelector("body.container")!;
81+
const chartsEl = document.getElementById("charts")!;
82+
const height =
83+
countGraphs === 1
84+
? window.innerHeight - bodyEl.clientHeight + chartsEl.clientHeight - 60
85+
: 300;
86+
87+
const opts = {
88+
width,
89+
height,
90+
};
7391
7492
// If we select a smaller subset of benchmarks, then just show them.
7593
if (hasSpecificSelection(selector)) {

0 commit comments

Comments
 (0)