-
-
Notifications
You must be signed in to change notification settings - Fork 13
feat: pass scales and options to overlay snippet #127
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
Conversation
📦 Preview package for this PR is published! Version: Install it with: npm install svelteplot@pr-127
# or install the specific version
npm install svelteplot@0.3.6-pr-127.0 |
✅ Deploy Preview for svelteplot ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the overlay snippet by passing richer plot context (dimensions, options, scales, and axis/grid flags) into the render call.
- Expanded the
overlay
type inPlotOptions
to carry structured context. - Updated
Plot.svelte
to forward new parameters (mapXY
, projection and explicit axis/grid flags) to the overlay renderer.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/lib/types/plot.ts | Updated overlay property to Snippet<…> with context |
src/lib/core/Plot.svelte | Passed additional parameters into {@render overlay} |
@@ -466,7 +466,7 @@ export type PlotOptions = { | |||
* The overlay snippet is useful for adding a layer of custom HTML markup | |||
* in front of the SVG body of your plot, e.g. for HTML tooltips. | |||
*/ | |||
overlay: Snippet; | |||
overlay: Snippet<[{ width: number; height: number; options: PlotOptions; scales: PlotScales }]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overlay
signature only includes width
, height
, options
, and scales
, but the Svelte invocation also passes mapXY
, hasProjection
, and the explicit axis/grid flags. Update the generic type to include those additional properties or consolidate into a named OverlayContext
type.
overlay: Snippet<[{ width: number; height: number; options: PlotOptions; scales: PlotScales }]>; | |
overlay: Snippet<[OverlayContext]>; |
Copilot uses AI. Check for mistakes.
@@ -519,7 +519,20 @@ | |||
{/if} | |||
</FacetGrid> | |||
</svg> | |||
{#if overlay}<div class="plot-overlay">{@render overlay?.()}</div>{/if} | |||
{#if overlay}<div class="plot-overlay"> | |||
{@render overlay?.({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call site treats overlay
as a single-object argument, but the type expects an array of arguments (Snippet<[OverlayContext]>
). Align the invocation with the updated signature, e.g., overlay?.([ { … } ])
, or adjust the type to accept an object directly.
Copilot uses AI. Check for mistakes.
This pull request enhances the functionality of the overlay snippet by passing additional contextual data.
Enhancements to overlay functionality:
Plot.svelte
: The overlay snippet now receives additional parameters, including plot dimensions (width
,height
), options (plotOptions
), scales, and flags indicating explicit axes and grid presence. This enables more dynamic and context-aware overlays.PlotOptions
type inplot.ts
: Theoverlay
property type was updated to include a structured snippet that accepts an array with detailed plot state information, enhancing type safety and usability.