Skip to content

feature: apply mark defaults #110

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 21 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
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
docs: add arrow example
  • Loading branch information
gka committed Jun 3, 2025
commit 6e7efd42cc66890331776d981881c920c745c419
1 change: 1 addition & 0 deletions src/routes/examples/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const load: PageServerLoad = async ({ fetch }) => {
'co2',
'crimea',
'driving',
'metros',
'languages',
'penguins',
'riaa',
Expand Down
5 changes: 5 additions & 0 deletions src/routes/examples/arrow/_index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script module>
export const title = 'Arrow';
</script>

<h1>Arrow examples</h1>
64 changes: 64 additions & 0 deletions src/routes/examples/arrow/metro.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script module>
export const title = 'Bended arrows';
</script>

<script lang="ts">
import { Plot, Arrow, Text } from '$lib/index.js';
import { page } from '$app/state';
import { setContext } from 'svelte';
import { type PlotDefaults } from 'svelteplot/types';
let { metros } = $derived(page.data.data);

setContext<Partial<PlotDefaults>>(
'svelteplot/defaults',
{
arrow: {
headAngle: 45
}
}
);

let hl = $state(false);
</script>

<Plot
grid
marginRight={20}
inset={10}
height={450}
x={{ type: 'log', label: 'P..opulation' }}
y={{ label: 'Inequality' }}
color={{
label: 'Change in inequality from 1980 to 2015',
legend: true,
tickFormat: '+f'
}}>
<Arrow
data={metros}
x1="POP_1980"
y1="R90_10_1980"
x2="POP_2015"
y2="R90_10_2015"
bend
style="transition: opacity 0.2s ease-in"
opacity={{
scale: null,
value: (d) =>
!hl || hl.Metro === d.Metro ? 1 : 0.1
}}
onmouseenter={(evt, d) => (hl = d)}
onmouseleave={() => (hl = null)}
stroke={(d) => d.R90_10_2015 - d.R90_10_1980} />
<Text
data={metros}
x="POP_2015"
y="R90_10_2015"
filter={(d) =>
hl ? hl.Metro === d.Metro : d.highlight}
text="nyt_display"
fill="currentColor"
stroke="var(--svelteplot-bg)"
strokeWidth={4}
lineAnchor="bottom"
dy={-6} />
</Plot>
Loading
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