Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 9c8591c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Contributor
Bundle Size AnalysisUse-Case ScenariosCore (7 changed)
Base (agnostic) (4 changed)
Base (layer-specific) (3 changed)
Cartesian charts (27 changed)
Geo (3 changed)
Hierarchy (4 changed)
Graph / network (4 changed)
Components (2 changed)
Worst case (1 changed)
Understanding this report
|
Contributor
Preview deploymenthttps://pr-996-layerchart.techniq.workers.dev Built from 9c8591c. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #986
Adds
lazytoChart, which skips building a chart until its container is near the viewport. On a page of many charts, the ones far below the fold cost almost nothing until they're scrolled to.Behaviour
200pxof the viewport.lazy={{ rootMargin, threshold }}tunes this.ssr, the server renders the empty container.placeholdersnippet: rendered inside the sized container until the chart is built, e.g. a loading state.setSettings({ lazy: true })makeslazythe default for every chart below it. A chart's ownlazy, includingfalse, wins (same pattern asview).The viewport logic is a small internal attachment,
attachments/nearViewport.ts. It isn't exported.Numbers
lazy(benched against main, alternating runs): mount time is unchanged within noise.Chart.basegrows by about 300 B gzipped.Known limitation:
experimental.asyncWith Svelte's
experimental.async, a lazy chart that comes into view while anawaitelsewhere on the page is still pending can freeze the page. This is sveltejs/svelte#18997, which is still open; the fix is sveltejs/svelte#19030, not yet released. The Chart docs carry a note about it.The bug also showed up as a chart never building at all: in that situation its stored container element (
ref) read asundefined. To avoid that, the chart now measures the element the observer hands it when it activates, instead of relying onref.For the same reason, the docs keep
Example.svelte's own lazy loading rather than switching tosetSettings({ lazy: true }). With every example'sawaitstarting at page load,/docs/guides/transformfroze. That lazy loading also defers each example's data (about 1.5–1.7 MB up front on the GeoPath and transform pages), whichlazydoesn't. Worth revisiting once the Svelte fix is released.Docs
Chart/lazyexample: 100 charts in a scroll box, each with a placeholder.lazyadded to the settings example in the State guide.Tests
Chart.lazy.svelte.test.ts: on-screen charts build in the first pass, off-screen ones wait, a chart builds on scroll and stays built, the placeholder shows and goes away, the setting is used as the default, and a chart's ownlazy={false}overrides it.src/lib/bench/lazy.svelte.bench.ts.🤖 Generated with Claude Code