Skip to content

Commit 46ce25d

Browse files
committed
scatterplot fixes
1 parent 0357168 commit 46ce25d

5 files changed

Lines changed: 11 additions & 69 deletions

File tree

src/components/ScrollScatter.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import Range from "$components/helpers/Range.svelte";
2323
import { onMount } from 'svelte';
2424
import { HUMAN_ANCHOR_BENCHMARK } from "$utils/agents.js";
25+
import { SCATTER_MAX_WIDTH_HEIGHT_RATIO } from "$utils/constants.js";
2526
2627
const MODULE_LEVEL_KEYS = new Set([
2728
"module-level",
@@ -64,9 +65,13 @@
6465
let windowW;
6566
let rangeW;
6667
let rangeH;
68+
let scatterHeight;
6769
6870
let reduceMotion = false;
6971
72+
// Calculate max width based on height and ratio constraint
73+
$: maxScatterWidth = scatterHeight ? scatterHeight * SCATTER_MAX_WIDTH_HEIGHT_RATIO : null;
74+
7075
onMount(() => {
7176
const media = window.matchMedia('(prefers-reduced-motion: reduce)');
7277
reduceMotion = media.matches;
@@ -170,7 +175,7 @@
170175
171176
<svelte:window bind:innerWidth={windowW} />
172177
173-
<section id="scatter">
178+
<section id="scatter" bind:clientHeight={scatterHeight} style:max-width={maxScatterWidth ? `${maxScatterWidth}px` : 'none'}>
174179
<div class="chart-container" id="scatterplot">
175180
{#if (typeof chartScrollIndex === "number" && chartScrollIndex >= 14) || chartScrollIndex == "exit"}
176181
<div class="range-wrapper" bind:offsetWidth={rangeW} bind:offsetHeight={rangeH}>
@@ -234,7 +239,7 @@
234239
flex-wrap: wrap;
235240
justify-content: center;
236241
align-items: center;
237-
margin-bottom: 5rem;
242+
margin: 0 auto 5rem auto;
238243
overflow: hidden;
239244
}
240245

0 commit comments

Comments
 (0)