Index of every page on this site: llms.txt
All skills
spences10 avatar

/svelte-layerchart

@5fe4989
Run it yourself

Svelte LayerChart patterns. Use for chart components with tooltip snippets, Chart context access, and all Svelte 5 snippet patterns for tooltips, gradients, highlights, and axes.

Use this Skill: https://skilld.dev/gh/spences10/svelte-skills-kit/svelte-layerchart

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencestooltip-modes.md

≈805 tokens on demand. Your agent reads this file only when SKILL.md points to it.

LayerChart Tooltip Modes

Required: Enable tooltip on Chart

The Chart component MUST have a tooltip prop to enable tooltip detection:

<!-- Bar charts with scaleBand -->
<Chart tooltip={{ mode: 'band' }} ...>

<!-- Area/Line charts with scaleTime -->
<Chart tooltip={{ mode: 'bisect-x' }} ...>
<Chart tooltip={{ mode: 'quadtree-x' }} ...>

<!-- Scatter plots -->
<Chart tooltip={{ mode: 'quadtree' }} ...>

All Tooltip Modes

Mode Use Case Notes
band Bar charts with scaleBand()
bisect-x Time-series area/line charts Requires sorted values
bisect-y Vertical time-series charts Requires sorted values
bisect-band Mixed band/continuous scales Requires sorted values
quadtree Scatter plots (finds nearest point)
quadtree-x Area charts (ignores y, finds nearest x)
quadtree-y Vertical charts (ignores x, finds nearest y)
bounds Duration/range charts
voronoi Complex scatter plots with voronoi cells
manual Custom tooltip control via context.tooltip Default mode

Tooltip with click handler

<Chart
	tooltip={{
		mode: 'band',
		onclick(e, { data }) {
			alert('Clicked: ' + JSON.stringify(data))
		},
	}}
>

TooltipContext Props

From the source (TooltipContext.svelte):

type TooltipContextProps = {
	mode?: TooltipMode // default: 'manual'
	findTooltipData?: 'closest' | 'left' | 'right' // default: 'closest'
	raiseTarget?: boolean // default: false
	locked?: boolean // default: false
	touchEvents?: 'none' | 'pan-x' | 'pan-y' | 'auto' // default: 'pan-y'
	radius?: number // default: Infinity (for quadtree/voronoi)
	debug?: boolean // default: false
	onclick?: (e: MouseEvent, { data }: { data: any }) => any
	hideDelay?: number // default: 0
}

Mode Selection Guide

For Bar Charts

<!-- Standard horizontal bars -->
<Chart yScale={scaleBand()} tooltip={{ mode: 'band' }}>

<!-- Grouped/stacked bars -->
<Chart yScale={scaleBand()} tooltip={{ mode: 'band' }}>

For Line/Area Charts

<!-- Time-series (sorted by date) -->
<Chart x="date" tooltip={{ mode: 'bisect-x' }}>

<!-- Alternative: quadtree for unsorted -->
<Chart x="date" tooltip={{ mode: 'quadtree-x' }}>

For Scatter Plots

<!-- Find nearest point -->
<Chart tooltip={{ mode: 'quadtree' }}>

<!-- With voronoi cells (visible regions) -->
<Chart tooltip={{ mode: 'voronoi' }}>

For Duration/Range Charts

<!-- Charts with start/end values -->
<Chart x={['start', 'end']} tooltip={{ mode: 'bounds' }}>

Debug Mode

Enable debug to see tooltip hit areas:

<Chart tooltip={{ mode: 'band', debug: true }}>

This shows red outlines around tooltip detection areas.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts25d3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides safe documentation and code patterns for using the LayerChart Svelte library, including component snippets for Svelte 5.

  • Socket25d

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 5fe4989. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago

README badge

README badge for spences10/svelte-skills-kit/svelte-layerchart