Skip to content

Commit

Permalink
expand when only one graph is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
s7tya committed Oct 8, 2024
1 parent de7ce9e commit 92bc848
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
5 changes: 4 additions & 1 deletion site/frontend/src/graph/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ function normalizeData(data: CompileGraphData) {
export type GraphRenderOpts = {
// Width of the graph
width: number;
// Height of the graph
height: number;
// Render a title above the graph
renderTitle?: boolean;
// Function that can be used to hook into the rendering process
Expand All @@ -417,6 +419,7 @@ export function renderPlots(
const renderTitle = opts.renderTitle ?? true;
const hooks = opts.hooks ?? {};
const width = opts.width;
const height = opts.height;

normalizeData(data);

Expand Down Expand Up @@ -504,7 +507,7 @@ export function renderPlots(

let plotOpts = genPlotOpts({
width,
height: 300,
height: height ?? 300,
yAxisLabel,
series: seriesOpts,
commits: data.commits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ async function renderGraph(
) {
const opts: GraphRenderOpts = {
width: Math.min(window.innerWidth - 40, 465),
height: 300,
renderTitle: false,
};
if (date !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ async function renderGraph(
) {
const opts: GraphRenderOpts = {
width: Math.min(window.innerWidth - 40, 465),
height: 300,
renderTitle: false,
};
if (date !== null) {
Expand Down
22 changes: 20 additions & 2 deletions site/frontend/src/pages/graphs/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,26 @@ async function loadGraphData(selector: GraphsSelector, loading: Ref<boolean>) {
// Then draw the plots.
await nextTick();
const width = Math.max(Math.floor(window.innerWidth / 4) - 40, 380);
const opts = {width};
const countGraphs = Object.keys(graphData.benchmarks)
.map((benchmark) => Object.keys(graphData.benchmarks[benchmark]).length)
.reduce((sum, item) => sum + item, 0);
const columns = countGraphs === 1 ? 1 : 4;
const root = document.getElementById("app")!;
const width = Math.max(Math.floor(root.clientWidth / columns), 380);
const bodyEl = document.querySelector("body.container")!;
const chartsEl = document.getElementById("charts")!;
const height =
countGraphs === 1
? window.innerHeight - bodyEl.clientHeight + chartsEl.clientHeight - 60
: 300;
const opts = {
width,
height,
};
// If we select a smaller subset of benchmarks, then just show them.
if (hasSpecificSelection(selector)) {
Expand Down

0 comments on commit 92bc848

Please sign in to comment.