2
2
title : Markers
3
3
---
4
4
5
- Markers can be used with the [ line] ( /marks/line ) and [ link] ( /marks/link ) marks.
5
+ Markers can be used with the [ line] ( /marks/line ) and [ link] ( /marks/link ) marks. Markers are automatically scaled with the line width:
6
6
7
7
``` svelte live
8
8
<script>
@@ -11,6 +11,7 @@ Markers can be used with the [line](/marks/line) and [link](/marks/link) marks.
11
11
import Slider from '$lib/ui/Slider.svelte';
12
12
13
13
let marker = $state('circle-stroke');
14
+ let strokeWidth = $state(1.5);
14
15
15
16
const options = [
16
17
'dot',
@@ -30,13 +31,16 @@ Markers can be used with the [line](/marks/line) and [link](/marks/link) marks.
30
31
<Select
31
32
label="Marker:"
32
33
bind:value={marker}
33
- {options} /><br />
34
+ {options} />
35
+ <Slider label="Stroke width" bind:value={strokeWidth} min={1} max={5} step={0.1} />
36
+ <br />
34
37
<Plot inset={10} grid>
35
38
<Line
36
39
data={crimea}
37
40
x="date"
38
41
y="deaths"
39
42
stroke="cause"
43
+ {strokeWidth}
40
44
{marker} />
41
45
</Plot>
42
46
```
@@ -48,10 +52,13 @@ Markers can be used with the [line](/marks/line) and [link](/marks/link) marks.
48
52
x="date"
49
53
y="deaths"
50
54
stroke="cause"
55
+ strokeWidth={1.5}
51
56
marker="dot" />
52
57
</Plot>
53
58
```
54
59
60
+ ## Marker options
61
+
55
62
The supported marker options are:
56
63
57
64
- ** markerStart** - the marker for the starting point of a line segment
@@ -76,7 +83,7 @@ Note that for the interpolation methods `basis`, `bundle`, and `step`, the marke
76
83
77
84
``` svelte live
78
85
<script lang="ts">
79
- import { Plot, LineY, Dot } from '$lib/index.js ';
86
+ import { Plot, LineY, Dot } from 'svelteplot ';
80
87
import Slider from '$lib/ui/Slider.svelte';
81
88
import Select from '$lib/ui/Select.svelte';
82
89
import type { CurveName } from '$lib/types.js';
@@ -115,6 +122,7 @@ Note that for the interpolation methods `basis`, `bundle`, and `step`, the marke
115
122
<DotY data={numbers} symbol="plus" />
116
123
</Plot>
117
124
```
125
+ [ fork] ( https://svelte.dev/playground/0be2cc3070c844e692a3300d87212f58?version=5.28.2 )
118
126
119
127
## Custom markers
120
128
@@ -165,6 +173,7 @@ You can also specify a custom marker icon using the `marker` snippet:
165
173
</Line>
166
174
</Plot>
167
175
```
176
+ [ fork] ( https://svelte.dev/playground/2e63a26ff02646db90f2e33849668033?version=5.28.2 )
168
177
169
178
And since the marker snippets contain regular Svelte code, you can do whatever you want with the markers, like animate them, for instance:
170
179
@@ -228,3 +237,4 @@ And since the marker snippets contain regular Svelte code, you can do whatever y
228
237
{/snippet}
229
238
<!-- </Line></Plot> -->
230
239
```
240
+ [ fork] ( https://svelte.dev/playground/f02d094c5761416ca1c2f14e1f6d168d?version=5.28.2 )
0 commit comments