Skip to content

Fix: derive band/point scale domain from interval #68

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

Merged
merged 4 commits into from
May 27, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
catch and log Plot-level errors
  • Loading branch information
gka committed May 27, 2025
commit 9867cf0cfb6ef72768b167a89c613336aa766a22
150 changes: 81 additions & 69 deletions src/lib/Plot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,89 +91,101 @@
<!-- There's a bug triggering RangeError: Maximum call stack size exceeded
when using SveltePlot in ssr, so for now, we're disabling it -->

<Plot
{overlay}
{underlay}
{...restOptions}
header={userHeader ||
restOptions.title ||
restOptions.subtitle ||
restOptions.color?.legend ||
restOptions.symbol?.legend
? header
: null}
footer={userFooter || restOptions?.caption ? footer : null}
projection={projectionOpts}
implicitScales
{...scales}>
{#snippet children({
hasProjection,
hasExplicitAxisX,
hasExplicitAxisY,
hasExplicitGridX,
hasExplicitGridY,
options,
scales,
...restProps
})}
<svelte:boundary onerror={(err) => console.warn(err)}>
<!-- implicit axes -->
{#if !hasProjection && !hasExplicitAxisX}
{#if options.axes && (options.x.axis === 'top' || options.x.axis === 'both')}
<AxisX anchor="top" automatic />
<svelte:boundary>
<Plot
{overlay}
{underlay}
{...restOptions}
header={userHeader ||
restOptions.title ||
restOptions.subtitle ||
restOptions.color?.legend ||
restOptions.symbol?.legend
? header
: null}
footer={userFooter || restOptions?.caption ? footer : null}
projection={projectionOpts}
implicitScales
{...scales}>
{#snippet children({
hasProjection,
hasExplicitAxisX,
hasExplicitAxisY,
hasExplicitGridX,
hasExplicitGridY,
options,
scales,
...restProps
})}
<svelte:boundary onerror={(err) => console.warn(err)}>
<!-- implicit axes -->
{#if !hasProjection && !hasExplicitAxisX}
{#if options.axes && (options.x.axis === 'top' || options.x.axis === 'both')}
<AxisX anchor="top" automatic />
{/if}
{#if options.axes && (options.x.axis === 'bottom' || options.x.axis === 'both')}
<AxisX anchor="bottom" automatic />
{/if}
{/if}
{#if options.axes && (options.x.axis === 'bottom' || options.x.axis === 'both')}
<AxisX anchor="bottom" automatic />
{#if !hasProjection && !hasExplicitAxisY}
{#if options.axes && (options.y.axis === 'left' || options.y.axis === 'both')}
<AxisY anchor="left" automatic />
{/if}
{#if options.axes && (options.y.axis === 'right' || options.y.axis === 'both')}
<AxisY anchor="right" automatic />
{/if}
{/if}
{/if}
{#if !hasProjection && !hasExplicitAxisY}
{#if options.axes && (options.y.axis === 'left' || options.y.axis === 'both')}
<AxisY anchor="left" automatic />
<!-- implicit grids -->
{#if !hasExplicitGridX && (options.grid || options.x.grid)}
<GridX automatic />
{/if}
{#if options.axes && (options.y.axis === 'right' || options.y.axis === 'both')}
<AxisY anchor="right" automatic />
{#if !hasExplicitGridY && (options.grid || options.y.grid)}
<GridY automatic />
{/if}
{/if}
<!-- implicit grids -->
{#if !hasExplicitGridX && (options.grid || options.x.grid)}
<GridX automatic />
{/if}
{#if !hasExplicitGridY && (options.grid || options.y.grid)}
<GridY automatic />
{/if}
<!-- implicit frame -->
{#if options.frame}
<Frame automatic />
{/if}
{@render parentChildren?.({
options,
scales,
...restProps
})}
{#snippet failed(error, reset)}
<text class="error" transform="translate(10,10)">
{#each error.message.split('\n') as line, i (i)}
<tspan x="0" dy={i ? 14 : 0}>{line}</tspan>
{/each}
</text>{/snippet}
</svelte:boundary>
{/snippet}
{#snippet facetAxes()}
<FacetAxes />
<!-- implicit frame -->
{#if options.frame}
<Frame automatic />
{/if}
{@render parentChildren?.({
options,
scales,
...restProps
})}
{#snippet failed(error, reset)}
<text class="error" transform="translate(10,10)">
{#each error.message.split('\n') as line, i (i)}
<tspan x="0" dy={i ? 14 : 0}>{line}</tspan>
{/each}
</text>{/snippet}
</svelte:boundary>
{/snippet}
{#snippet facetAxes()}
<FacetAxes />
{/snippet}
</Plot>
{#snippet failed(error)}
<div class="error">Error: {error.message}</div>
{/snippet}
</Plot>
</svelte:boundary>

<style>
:root {
--plot-bg: white;
--plot-fg: currentColor;
}
text.error {
stroke: var(--plot-bg);
fill: crimson;
.error {
font-size: 11px;
stroke-width: 3px;
font-weight: bold;
}
text.error {
stroke: var(--plot-bg);
fill: crimson;
paint-order: stroke fill;
}
div.error {
color: crimson;
white-space: pre-wrap;
line-height: 1.1;
}
</style>
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy