Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand when only one graph is selected #1988

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions 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 @@ -416,7 +418,7 @@ export function renderPlots(
) {
const renderTitle = opts.renderTitle ?? true;
const hooks = opts.hooks ?? {};
const width = opts.width;
const {width, height} = opts;

normalizeData(data);

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

let plotOpts = genPlotOpts({
width,
height: 300,
height,
yAxisLabel,
series: seriesOpts,
commits: data.commits,
Expand Down Expand Up @@ -534,7 +536,7 @@ export function renderRuntimePlots(
) {
const renderTitle = opts.renderTitle ?? true;
const hooks = opts.hooks ?? {};
const width = opts.width;
const {width, height} = opts;

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

Expand Down Expand Up @@ -610,7 +612,7 @@ export function renderRuntimePlots(

let plotOpts = genPlotOpts({
width,
height: 300,
height,
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
64 changes: 48 additions & 16 deletions site/frontend/src/pages/graphs/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,30 @@ 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 parentWidth = wrapperRef.value.clientWidth;
let columns = countGraphs === 1 ? 1 : 4;

// Small display, reduce column count to 1
if (parentWidth < 1000) {
columns = 1;
}

// Calculate the width of each column.
// Provide a 10px buffer to avoid wrapping if the size is just at the limit
// of the parent.
const width = Math.floor(wrapperRef.value.clientWidth / columns) - 10;

const top = wrapperRef.value.getBoundingClientRect().top;
const height = countGraphs === 1 ? window.innerHeight - top - 100 : 300;

const opts = {
width,
height,
};

// If we select a smaller subset of benchmarks, then just show them.
if (hasSpecificSelection(selector)) {
Expand Down Expand Up @@ -115,8 +137,10 @@ function updateSelection(params: SelectionParams) {
const info: BenchmarkInfo = await loadBenchmarkInfo();

const loading = ref(true);
const wrapperRef = ref(null);

const selector: GraphsSelector = loadSelectorFromUrl(getUrlParams());

loadGraphData(selector, loading);
</script>

Expand All @@ -138,21 +162,29 @@ loadGraphData(selector, loading);
interpolated due to missing data. Interpolated data is simply the last known
data point repeated until another known data point is found.
</div>
<div v-if="loading">
<h2>Loading &amp; rendering data..</h2>
<h3>This may take a while!</h3>
</div>
<div v-else>
<div id="charts"></div>
<div
v-if="!hasSpecificSelection(selector)"
style="margin-top: 50px; border-top: 1px solid #ccc"
>
<div style="padding: 20px 0">
<strong>Benchmarks optimized for small binary size</strong>
<div class="wrapper" ref="wrapperRef">
<div v-if="loading">
<h2>Loading &amp; rendering data..</h2>
<h3>This may take a while!</h3>
</div>
<div v-else>
<div id="charts"></div>
<div
v-if="!hasSpecificSelection(selector)"
style="margin-top: 50px; border-top: 1px solid #ccc"
>
<div style="padding: 20px 0">
<strong>Benchmarks optimized for small binary size</strong>
</div>
<div id="size-charts"></div>
</div>
<div id="size-charts"></div>
<AsOf :info="info" />
</div>
<AsOf :info="info" />
</div>
</template>

<style lang="scss" scoped>
.wrapper {
width: 100%;
}
</style>
1 change: 1 addition & 0 deletions site/frontend/templates/pages/graphs.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
margin: 0;
}
</style>
<link rel="stylesheet" type="text/css" href="scripts/graphs.css">
{% endblock %}
{% block content %}
<div id="app"></div>
Expand Down
Loading