Skip to content

Commit 361043a

Browse files
committed
docs: add exmaples
1 parent 17f45dd commit 361043a

File tree

6 files changed

+44
-1
lines changed

6 files changed

+44
-1
lines changed

src/routes/examples/+layout.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const load: PageServerLoad = async ({ fetch }) => {
3030
'simpsons',
3131
'stocks',
3232
'unemployment',
33-
'sftemp'
33+
'sftemp',
34+
'wind'
3435
],
3536
fetch
3637
))

src/routes/examples/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ type MetrosRow = {
9494
highlight: number;
9595
};
9696

97+
type WindRow = {
98+
longitude: number;
99+
latitude: number;
100+
u: number;
101+
v: number;
102+
};
103+
97104
export type ExamplesData = {
98105
aapl: AaplRow[];
99106
simpsons: SimpsonsRow[];
@@ -107,4 +114,5 @@ export type ExamplesData = {
107114
beagle: BeagleRow[];
108115
riaa: RiaaRow[];
109116
metros: MetrosRow[];
117+
wind: WindRow[];
110118
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script module>
2+
export const title = 'Vector';
3+
</script>
4+
5+
<h1>Vector examples</h1>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script module>
2+
export const title = 'Wind Vectors';
3+
</script>
4+
5+
<script lang="ts">
6+
import { Plot, Vector } from 'svelteplot';
7+
import { page } from '$app/state';
8+
import type { ExamplesData } from '../types';
9+
10+
let { wind } = $derived(page.data.data) as ExamplesData;
11+
</script>
12+
13+
<Plot
14+
inset={10}
15+
aspectRatio={1}
16+
color={{
17+
label: 'Speed (m/s)',
18+
zero: true,
19+
legend: true
20+
}}>
21+
<Vector
22+
data={wind}
23+
x="longitude"
24+
y="latitude"
25+
rotate={({ u, v }) =>
26+
(Math.atan2(u, v) * 180) / Math.PI}
27+
length={({ u, v }) => Math.hypot(u, v)}
28+
stroke={({ u, v }) => Math.hypot(u, v)} />
29+
</Plot>

static/examples/vector/wind.dark.png

659 KB
Loading

static/examples/vector/wind.png

657 KB
Loading

0 commit comments

Comments
 (0)
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