svelteplot 0.2.6-next.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Mark.svelte +1 -1
- package/dist/Plot.svelte +1 -1
- package/dist/core/FacetGrid.svelte +2 -2
- package/dist/core/Plot.svelte +1 -0
- package/dist/helpers/resolve.js +7 -4
- package/dist/helpers/scales.js +2 -1
- package/dist/marks/Area.svelte +17 -23
- package/dist/marks/Area.svelte.d.ts +9 -17
- package/dist/marks/AreaX.svelte +7 -6
- package/dist/marks/AreaX.svelte.d.ts +7 -6
- package/dist/marks/AreaY.svelte +7 -15
- package/dist/marks/AreaY.svelte.d.ts +7 -10
- package/dist/marks/Arrow.svelte +25 -25
- package/dist/marks/Arrow.svelte.d.ts +5 -8
- package/dist/marks/AxisX.svelte +50 -44
- package/dist/marks/AxisX.svelte.d.ts +4 -3
- package/dist/marks/AxisY.svelte +39 -31
- package/dist/marks/AxisY.svelte.d.ts +7 -4
- package/dist/marks/BarX.svelte +27 -12
- package/dist/marks/BarX.svelte.d.ts +17 -1
- package/dist/marks/BarY.svelte +21 -11
- package/dist/marks/BarY.svelte.d.ts +4 -4
- package/dist/marks/BollingerX.svelte +15 -7
- package/dist/marks/BollingerX.svelte.d.ts +3 -3
- package/dist/marks/BollingerY.svelte +9 -7
- package/dist/marks/BollingerY.svelte.d.ts +3 -3
- package/dist/marks/BoxX.svelte +3 -0
- package/dist/marks/BoxX.svelte.d.ts +1 -0
- package/dist/marks/BoxY.svelte +3 -0
- package/dist/marks/BoxY.svelte.d.ts +1 -0
- package/dist/marks/BrushX.svelte +5 -1
- package/dist/marks/BrushX.svelte.d.ts +2 -1
- package/dist/marks/BrushY.svelte +5 -1
- package/dist/marks/BrushY.svelte.d.ts +2 -1
- package/dist/marks/Cell.svelte +18 -21
- package/dist/marks/Cell.svelte.d.ts +3 -9
- package/dist/marks/CellX.svelte +7 -12
- package/dist/marks/CellX.svelte.d.ts +3 -1
- package/dist/marks/CellY.svelte +7 -12
- package/dist/marks/CellY.svelte.d.ts +3 -1
- package/dist/marks/ColorLegend.svelte +12 -9
- package/dist/marks/ColorLegend.svelte.d.ts +3 -5
- package/dist/marks/CustomMark.svelte +1 -1
- package/dist/marks/CustomMarkHTML.svelte +1 -1
- package/dist/marks/DifferenceY.svelte +22 -20
- package/dist/marks/DifferenceY.svelte.d.ts +5 -5
- package/dist/marks/Dot.svelte +17 -27
- package/dist/marks/Dot.svelte.d.ts +5 -15
- package/dist/marks/DotX.svelte +10 -9
- package/dist/marks/DotX.svelte.d.ts +4 -7
- package/dist/marks/DotY.svelte +9 -2
- package/dist/marks/DotY.svelte.d.ts +4 -3
- package/dist/marks/Frame.svelte +42 -31
- package/dist/marks/Frame.svelte.d.ts +8 -3
- package/dist/marks/Geo.svelte +18 -11
- package/dist/marks/Geo.svelte.d.ts +4 -3
- package/dist/marks/Graticule.svelte +15 -8
- package/dist/marks/Graticule.svelte.d.ts +2 -1
- package/dist/marks/GridX.svelte +11 -6
- package/dist/marks/GridX.svelte.d.ts +3 -2
- package/dist/marks/GridY.svelte +11 -3
- package/dist/marks/GridY.svelte.d.ts +3 -2
- package/dist/marks/HTMLTooltip.svelte +2 -1
- package/dist/marks/HTMLTooltip.svelte.d.ts +4 -0
- package/dist/marks/Line.svelte +8 -14
- package/dist/marks/Line.svelte.d.ts +5 -10
- package/dist/marks/LineX.svelte +5 -2
- package/dist/marks/LineX.svelte.d.ts +3 -2
- package/dist/marks/LineY.svelte +5 -2
- package/dist/marks/LineY.svelte.d.ts +3 -2
- package/dist/marks/Link.svelte +20 -19
- package/dist/marks/Link.svelte.d.ts +6 -6
- package/dist/marks/Rect.svelte +15 -12
- package/dist/marks/Rect.svelte.d.ts +3 -3
- package/dist/marks/RectX.svelte +10 -20
- package/dist/marks/RectX.svelte.d.ts +6 -12
- package/dist/marks/RectY.svelte +10 -20
- package/dist/marks/RectY.svelte.d.ts +6 -12
- package/dist/marks/RegressionX.svelte +10 -2
- package/dist/marks/RegressionX.svelte.d.ts +2 -0
- package/dist/marks/RegressionY.svelte +9 -2
- package/dist/marks/RegressionY.svelte.d.ts +2 -0
- package/dist/marks/RuleX.svelte +16 -13
- package/dist/marks/RuleX.svelte.d.ts +3 -4
- package/dist/marks/RuleY.svelte +16 -13
- package/dist/marks/RuleY.svelte.d.ts +3 -4
- package/dist/marks/Sphere.svelte +9 -2
- package/dist/marks/Sphere.svelte.d.ts +4 -4
- package/dist/marks/Spike.svelte +9 -1
- package/dist/marks/Spike.svelte.d.ts +2 -0
- package/dist/marks/SymbolLegend.svelte +1 -1
- package/dist/marks/Text.svelte +34 -35
- package/dist/marks/Text.svelte.d.ts +4 -7
- package/dist/marks/TickX.svelte +25 -20
- package/dist/marks/TickX.svelte.d.ts +3 -3
- package/dist/marks/TickY.svelte +25 -20
- package/dist/marks/TickY.svelte.d.ts +3 -3
- package/dist/marks/Vector.svelte +5 -5
- package/dist/marks/Vector.svelte.d.ts +2 -5
- package/dist/marks/helpers/BaseAxisX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte +1 -1
- package/dist/marks/helpers/RectPath.svelte +17 -13
- package/dist/marks/helpers/RectPath.svelte.d.ts +1 -0
- package/dist/marks/helpers/events.js +3 -6
- package/dist/transforms/recordize.js +4 -4
- package/dist/types.d.ts +13 -11
- package/dist/ui/RadioInput.svelte +1 -1
- package/dist/ui/Select.svelte +1 -1
- package/package.json +117 -118
package/dist/marks/RuleY.svelte
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders horizontal rule lines at specified y positions with customizable horizontal range
|
|
3
|
+
-->
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
export type RuleYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
6
|
+
data: DataRecord[];
|
|
7
|
+
y?: ChannelAccessor;
|
|
8
|
+
x1?: ChannelAccessor;
|
|
9
|
+
x2?: ChannelAccessor;
|
|
10
|
+
inset?: ConstantAccessor<number>;
|
|
11
|
+
insetLeft?: ConstantAccessor<number>;
|
|
12
|
+
insetRight?: ConstantAccessor<number>;
|
|
13
|
+
};
|
|
14
|
+
</script>
|
|
15
|
+
|
|
1
16
|
<script lang="ts">
|
|
2
17
|
import Mark from '../Mark.svelte';
|
|
3
18
|
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
@@ -12,18 +27,6 @@
|
|
|
12
27
|
ChannelAccessor
|
|
13
28
|
} from '../types.js';
|
|
14
29
|
|
|
15
|
-
type RuleYMarkProps = BaseMarkProps & {
|
|
16
|
-
data: DataRecord[];
|
|
17
|
-
y?: ChannelAccessor;
|
|
18
|
-
x1?: ChannelAccessor;
|
|
19
|
-
x2?: ChannelAccessor;
|
|
20
|
-
inset?: ConstantAccessor<number>;
|
|
21
|
-
insetLeft?: ConstantAccessor<number>;
|
|
22
|
-
insetRight?: ConstantAccessor<number>;
|
|
23
|
-
dx?: ConstantAccessor<number>;
|
|
24
|
-
dy?: ConstantAccessor<number>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
30
|
let { data = [{}], class: className = null, ...options }: RuleYMarkProps = $props();
|
|
28
31
|
|
|
29
32
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
<Mark type="ruleY" channels={['y', 'x1', 'x2', 'stroke', 'opacity', 'strokeOpacity']} {...args}>
|
|
35
38
|
{#snippet children({ scaledData, usedScales })}
|
|
36
39
|
<GroupMultiple class="rule-y {className || ''}" length={className ? 2 : args.data.length}>
|
|
37
|
-
{#each scaledData as d}
|
|
40
|
+
{#each scaledData as d, i (i)}
|
|
38
41
|
{@const inset = resolveProp(args.inset, d.datum, 0)}
|
|
39
42
|
{@const insetLeft = resolveProp(args.insetLeft, d.datum, 0)}
|
|
40
43
|
{@const insetRight = resolveProp(args.insetRight, d.datum, 0)}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type RuleYMarkProps = BaseMarkProps & {
|
|
1
|
+
export type RuleYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
3
2
|
data: DataRecord[];
|
|
4
3
|
y?: ChannelAccessor;
|
|
5
4
|
x1?: ChannelAccessor;
|
|
@@ -7,9 +6,9 @@ type RuleYMarkProps = BaseMarkProps & {
|
|
|
7
6
|
inset?: ConstantAccessor<number>;
|
|
8
7
|
insetLeft?: ConstantAccessor<number>;
|
|
9
8
|
insetRight?: ConstantAccessor<number>;
|
|
10
|
-
dx?: ConstantAccessor<number>;
|
|
11
|
-
dy?: ConstantAccessor<number>;
|
|
12
9
|
};
|
|
10
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
11
|
+
/** Renders horizontal rule lines at specified y positions with customizable horizontal range */
|
|
13
12
|
declare const RuleY: import("svelte").Component<RuleYMarkProps, {}, "">;
|
|
14
13
|
type RuleY = ReturnType<typeof RuleY>;
|
|
15
14
|
export default RuleY;
|
package/dist/marks/Sphere.svelte
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- @component
|
|
2
|
+
Geo mark with Sphere geometry object -->
|
|
3
|
+
|
|
4
|
+
<script module lang="ts">
|
|
2
5
|
import { type BaseMarkProps } from '../types.js';
|
|
6
|
+
export type SphereMarkProps = BaseMarkProps;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
3
10
|
import Geo from './Geo.svelte';
|
|
4
11
|
|
|
5
|
-
let { ...args }:
|
|
12
|
+
let { ...args }: SphereMarkProps = $props();
|
|
6
13
|
</script>
|
|
7
14
|
|
|
8
15
|
<Geo data={[{ type: 'Sphere' }]} {...args} geoType="sphere" />
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { type BaseMarkProps } from '../types.js';
|
|
2
|
+
export type SphereMarkProps = BaseMarkProps;
|
|
3
|
+
/** Geo mark with Sphere geometry object */
|
|
1
4
|
declare const Sphere: import("svelte").Component<Partial<{
|
|
2
5
|
filter?: import("../types.js").ConstantAccessor<boolean>;
|
|
3
6
|
facet?: "auto" | "include" | "exclude";
|
|
@@ -51,10 +54,7 @@ declare const Sphere: import("svelte").Component<Partial<{
|
|
|
51
54
|
ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
52
55
|
oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
53
56
|
onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
|
|
54
|
-
|
|
55
|
-
href: import("../types.js").ConstantAccessor<string>;
|
|
56
|
-
target: import("../types.js").ConstantAccessor<"_self" | "_blank" | string>;
|
|
57
|
-
class: string;
|
|
57
|
+
class: string | null;
|
|
58
58
|
cursor: import("../types.js").ConstantAccessor<import("csstype").Property.Cursor>;
|
|
59
59
|
}>, {}, "">;
|
|
60
60
|
type Sphere = ReturnType<typeof Sphere>;
|
package/dist/marks/Spike.svelte
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Wrapper around the vector mark with presets suitable for spike maps
|
|
4
|
+
-->
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type SpikeMarkProps = VectorMarkProps;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
1
9
|
<script lang="ts">
|
|
2
10
|
import Vector, { type VectorMarkProps } from './Vector.svelte';
|
|
3
|
-
let { data = [{}], ...options }:
|
|
11
|
+
let { data = [{}], ...options }: SpikeMarkProps = $props();
|
|
4
12
|
</script>
|
|
5
13
|
|
|
6
14
|
<Vector
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export type SpikeMarkProps = VectorMarkProps;
|
|
1
2
|
import { type VectorMarkProps } from './Vector.svelte';
|
|
3
|
+
/** Wrapper around the vector mark with presets suitable for spike maps */
|
|
2
4
|
declare const Spike: import("svelte").Component<VectorMarkProps, {}, "">;
|
|
3
5
|
type Spike = ReturnType<typeof Spike>;
|
|
4
6
|
export default Spike;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
{#if plot.scales.color.manualActiveMarks > 0}
|
|
21
21
|
<div class="symbol-legend">
|
|
22
|
-
{#each plot.scales.color.domain as value}
|
|
22
|
+
{#each plot.scales.color.domain as value (value)}
|
|
23
23
|
{@const symbolV = plot.scales.symbol.fn(value)}
|
|
24
24
|
{@const symbolType = maybeSymbol(symbolV)}
|
|
25
25
|
{@const color = plot.colorSymbolRedundant
|
package/dist/marks/Text.svelte
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
BaseMarkProps,
|
|
8
|
-
ConstantAccessor,
|
|
9
|
-
ChannelAccessor
|
|
10
|
-
} from '../types.js';
|
|
11
|
-
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
12
|
-
import Mark from '../Mark.svelte';
|
|
13
|
-
import { sort } from '../index.js';
|
|
14
|
-
|
|
15
|
-
type TextMarkProps = BaseMarkProps & {
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Useful for adding SVG text labels to your plot.
|
|
4
|
+
-->
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type TextMarkProps = BaseMarkProps & {
|
|
16
7
|
data: DataRecord[];
|
|
17
8
|
x: ChannelAccessor;
|
|
18
9
|
y: ChannelAccessor;
|
|
19
|
-
fill?: ChannelAccessor;
|
|
20
|
-
stroke?: ChannelAccessor;
|
|
21
10
|
children?: Snippet;
|
|
22
|
-
dx?: ConstantAccessor<number>;
|
|
23
|
-
dy?: ConstantAccessor<number>;
|
|
24
11
|
text: ConstantAccessor<string>;
|
|
25
12
|
title?: ConstantAccessor<string>;
|
|
26
13
|
/**
|
|
@@ -42,6 +29,21 @@
|
|
|
42
29
|
| 'bottom-right'
|
|
43
30
|
>;
|
|
44
31
|
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts">
|
|
35
|
+
import { getContext, type Snippet } from 'svelte';
|
|
36
|
+
import GroupMultiple from './helpers/GroupMultiple.svelte';
|
|
37
|
+
import type {
|
|
38
|
+
PlotContext,
|
|
39
|
+
DataRecord,
|
|
40
|
+
BaseMarkProps,
|
|
41
|
+
ConstantAccessor,
|
|
42
|
+
ChannelAccessor
|
|
43
|
+
} from '../types.js';
|
|
44
|
+
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
|
|
45
|
+
import Mark from '../Mark.svelte';
|
|
46
|
+
import { sort } from '../index.js';
|
|
45
47
|
|
|
46
48
|
let { data = [{}], class: className = null, ...options }: TextMarkProps = $props();
|
|
47
49
|
|
|
@@ -78,7 +80,7 @@
|
|
|
78
80
|
{...args}>
|
|
79
81
|
{#snippet children({ mark, scaledData, usedScales })}
|
|
80
82
|
<GroupMultiple class="text {className || null}" length={className ? 2 : args.data.length}>
|
|
81
|
-
{#each scaledData as d}
|
|
83
|
+
{#each scaledData as d, i (i)}
|
|
82
84
|
{#if d.valid}
|
|
83
85
|
{@const title = resolveProp(args.title, d.datum, '')}
|
|
84
86
|
{@const frameAnchor = resolveProp(args.frameAnchor, d.datum)}
|
|
@@ -148,20 +150,17 @@
|
|
|
148
150
|
<text
|
|
149
151
|
class={[textClassName]}
|
|
150
152
|
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
151
|
-
transform="translate({
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
163
|
-
]})"
|
|
164
|
-
>{#each textLines as line, l}<tspan
|
|
153
|
+
transform="translate({Math.round(x + dx)},{Math.round(
|
|
154
|
+
y +
|
|
155
|
+
dy -
|
|
156
|
+
(lineAnchor === 'bottom'
|
|
157
|
+
? textLines.length - 1
|
|
158
|
+
: lineAnchor === 'middle'
|
|
159
|
+
? (textLines.length - 1) * 0.5
|
|
160
|
+
: 0) *
|
|
161
|
+
fontSize
|
|
162
|
+
)})"
|
|
163
|
+
>{#each textLines as line, l (l)}<tspan
|
|
165
164
|
x="0"
|
|
166
165
|
dy={l ? fontSize : 0}
|
|
167
166
|
class={styleClass}
|
|
@@ -172,7 +171,7 @@
|
|
|
172
171
|
<text
|
|
173
172
|
class={[textClassName, styleClass]}
|
|
174
173
|
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
175
|
-
transform="translate({
|
|
174
|
+
transform="translate({Math.round(x + dx)},{Math.round(y + dy)})"
|
|
176
175
|
{style}
|
|
177
176
|
>{textLines[0]}{#if title}<title>{title}</title>{/if}</text>
|
|
178
177
|
{/if}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
3
|
-
type TextMarkProps = BaseMarkProps & {
|
|
1
|
+
export type TextMarkProps = BaseMarkProps & {
|
|
4
2
|
data: DataRecord[];
|
|
5
3
|
x: ChannelAccessor;
|
|
6
4
|
y: ChannelAccessor;
|
|
7
|
-
fill?: ChannelAccessor;
|
|
8
|
-
stroke?: ChannelAccessor;
|
|
9
5
|
children?: Snippet;
|
|
10
|
-
dx?: ConstantAccessor<number>;
|
|
11
|
-
dy?: ConstantAccessor<number>;
|
|
12
6
|
text: ConstantAccessor<string>;
|
|
13
7
|
title?: ConstantAccessor<string>;
|
|
14
8
|
/**
|
|
@@ -21,6 +15,9 @@ type TextMarkProps = BaseMarkProps & {
|
|
|
21
15
|
lineAnchor?: ConstantAccessor<'bottom' | 'top' | 'middle'>;
|
|
22
16
|
frameAnchor?: ConstantAccessor<'bottom' | 'top' | 'left' | 'right' | 'top-left' | 'bottom-left' | 'top-right' | 'bottom-right'>;
|
|
23
17
|
};
|
|
18
|
+
import { type Snippet } from 'svelte';
|
|
19
|
+
import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
|
|
20
|
+
/** Useful for adding SVG text labels to your plot. */
|
|
24
21
|
declare const Text: import("svelte").Component<TextMarkProps, {}, "">;
|
|
25
22
|
type Text = ReturnType<typeof Text>;
|
|
26
23
|
export default Text;
|
package/dist/marks/TickX.svelte
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
The TickX mark is useful for showing one-dimensional distributions along the x axis. The y axis must be a band scale.
|
|
4
|
+
-->
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type TickXMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
7
|
+
data: DataRow[];
|
|
8
|
+
/**
|
|
9
|
+
* the horizontal position; bound to the x scale
|
|
10
|
+
*/
|
|
11
|
+
x?: ChannelAccessor;
|
|
12
|
+
/**
|
|
13
|
+
* the vertical position; bound to the y scale, which must be band. If the y channel
|
|
14
|
+
* is not specified, the tick will span the full vertical extent of the frame.
|
|
15
|
+
*/
|
|
16
|
+
y?: ChannelAccessor;
|
|
17
|
+
/**
|
|
18
|
+
* if ticks are used on a non-bandwidth scale, this will determine the
|
|
19
|
+
* length of the tick. Defaults to 10 pixel
|
|
20
|
+
*/
|
|
21
|
+
tickLength?: ConstantAccessor<number>;
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
|
|
1
25
|
<script lang="ts">
|
|
2
26
|
import Mark from '../Mark.svelte';
|
|
3
27
|
import { getContext } from 'svelte';
|
|
@@ -17,25 +41,6 @@
|
|
|
17
41
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
18
42
|
let plot = $derived(getPlotState());
|
|
19
43
|
|
|
20
|
-
type TickXMarkProps = BaseMarkProps & {
|
|
21
|
-
data: DataRow[];
|
|
22
|
-
/**
|
|
23
|
-
* the horizontal position; bound to the x scale
|
|
24
|
-
*/
|
|
25
|
-
x?: ChannelAccessor;
|
|
26
|
-
/**
|
|
27
|
-
* the vertical position; bound to the y scale, which must be band. If the y channel
|
|
28
|
-
* is not specified, the tick will span the full vertical extent of the frame.
|
|
29
|
-
*/
|
|
30
|
-
y?: ChannelAccessor;
|
|
31
|
-
stroke?: ChannelAccessor;
|
|
32
|
-
/**
|
|
33
|
-
* if ticks are used on a non-bandwidth scale, this will determine the
|
|
34
|
-
* length of the tick. Defaults to 10 pixel
|
|
35
|
-
*/
|
|
36
|
-
tickLength?: ConstantAccessor<number>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
44
|
let { data = [{}], ...options }: TickXMarkProps = $props();
|
|
40
45
|
|
|
41
46
|
let args = $derived(recordizeX({ data, ...options }, { withIndex: false }));
|
|
@@ -47,7 +52,7 @@
|
|
|
47
52
|
<Mark type="tickX" channels={['x', 'y', 'stroke', 'opacity', 'strokeOpacity']} {...args}>
|
|
48
53
|
{#snippet children({ mark, usedScales })}
|
|
49
54
|
<g class="tick-x">
|
|
50
|
-
{#each args.data as datum}
|
|
55
|
+
{#each args.data as datum, i (i)}
|
|
51
56
|
{#if testFacet(datum, mark.options) && testFilter(datum, args)}
|
|
52
57
|
{@const x_ = resolveChannel('x', datum, args)}
|
|
53
58
|
{@const y_ = resolveChannel('y', datum, args)}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type TickXMarkProps = BaseMarkProps & {
|
|
1
|
+
export type TickXMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
3
2
|
data: DataRow[];
|
|
4
3
|
/**
|
|
5
4
|
* the horizontal position; bound to the x scale
|
|
@@ -10,13 +9,14 @@ type TickXMarkProps = BaseMarkProps & {
|
|
|
10
9
|
* is not specified, the tick will span the full vertical extent of the frame.
|
|
11
10
|
*/
|
|
12
11
|
y?: ChannelAccessor;
|
|
13
|
-
stroke?: ChannelAccessor;
|
|
14
12
|
/**
|
|
15
13
|
* if ticks are used on a non-bandwidth scale, this will determine the
|
|
16
14
|
* length of the tick. Defaults to 10 pixel
|
|
17
15
|
*/
|
|
18
16
|
tickLength?: ConstantAccessor<number>;
|
|
19
17
|
};
|
|
18
|
+
import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
|
|
19
|
+
/** The TickX mark is useful for showing one-dimensional distributions along the x axis. The y axis must be a band scale. */
|
|
20
20
|
declare const TickX: import("svelte").Component<TickXMarkProps, {}, "">;
|
|
21
21
|
type TickX = ReturnType<typeof TickX>;
|
|
22
22
|
export default TickX;
|
package/dist/marks/TickY.svelte
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
The TickY mark is useful for showing one-dimensional distributions along the y axis. The x axis must be a band scale.
|
|
4
|
+
-->
|
|
5
|
+
<script module lang="ts">
|
|
6
|
+
export type TickYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
7
|
+
data: DataRow[];
|
|
8
|
+
/**
|
|
9
|
+
* the vertical position; bound to the x scale
|
|
10
|
+
*/
|
|
11
|
+
y?: ChannelAccessor;
|
|
12
|
+
/**
|
|
13
|
+
* the horizontal position; bound to the x scale, which must be band. If the x channel
|
|
14
|
+
* is not specified, the tick will span the full horizontal extent of the frame.
|
|
15
|
+
*/
|
|
16
|
+
x?: ChannelAccessor;
|
|
17
|
+
/**
|
|
18
|
+
* if ticks are used on a non-bandwidth scale, this will determine the
|
|
19
|
+
* length of the tick. Defaults to 10 pixel
|
|
20
|
+
*/
|
|
21
|
+
tickLength?: ConstantAccessor<number>;
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
|
|
1
25
|
<script lang="ts">
|
|
2
26
|
import Mark from '../Mark.svelte';
|
|
3
27
|
import { getContext } from 'svelte';
|
|
@@ -18,25 +42,6 @@
|
|
|
18
42
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
19
43
|
let plot = $derived(getPlotState());
|
|
20
44
|
|
|
21
|
-
type TickYMarkProps = BaseMarkProps & {
|
|
22
|
-
data: DataRow[];
|
|
23
|
-
/**
|
|
24
|
-
* the vertical position; bound to the x scale
|
|
25
|
-
*/
|
|
26
|
-
y?: ChannelAccessor;
|
|
27
|
-
/**
|
|
28
|
-
* the horizontal position; bound to the x scale, which must be band. If the x channel
|
|
29
|
-
* is not specified, the tick will span the full horizontal extent of the frame.
|
|
30
|
-
*/
|
|
31
|
-
x?: ChannelAccessor;
|
|
32
|
-
stroke?: ChannelAccessor;
|
|
33
|
-
/**
|
|
34
|
-
* if ticks are used on a non-bandwidth scale, this will determine the
|
|
35
|
-
* length of the tick. Defaults to 10 pixel
|
|
36
|
-
*/
|
|
37
|
-
tickLength?: ConstantAccessor<number>;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
45
|
let { data = [{}], ...options }: TickYMarkProps = $props();
|
|
41
46
|
|
|
42
47
|
let args = $derived(recordizeY({ data, ...options }, { withIndex: false }));
|
|
@@ -48,7 +53,7 @@
|
|
|
48
53
|
<Mark type="tickY" channels={['x', 'y', 'stroke', 'opacity', 'strokeOpacity']} {...args}>
|
|
49
54
|
{#snippet children({ mark, usedScales })}
|
|
50
55
|
<g class="tick-y">
|
|
51
|
-
{#each args.data as datum}
|
|
56
|
+
{#each args.data as datum, i (i)}
|
|
52
57
|
{#if testFacet(datum, mark.options) && testFilter(datum, args)}
|
|
53
58
|
{@const y_ = resolveChannel('y', datum, args)}
|
|
54
59
|
{@const x_ = resolveChannel('x', datum, args)}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type TickYMarkProps = BaseMarkProps & {
|
|
1
|
+
export type TickYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
|
|
3
2
|
data: DataRow[];
|
|
4
3
|
/**
|
|
5
4
|
* the vertical position; bound to the x scale
|
|
@@ -10,13 +9,14 @@ type TickYMarkProps = BaseMarkProps & {
|
|
|
10
9
|
* is not specified, the tick will span the full horizontal extent of the frame.
|
|
11
10
|
*/
|
|
12
11
|
x?: ChannelAccessor;
|
|
13
|
-
stroke?: ChannelAccessor;
|
|
14
12
|
/**
|
|
15
13
|
* if ticks are used on a non-bandwidth scale, this will determine the
|
|
16
14
|
* length of the tick. Defaults to 10 pixel
|
|
17
15
|
*/
|
|
18
16
|
tickLength?: ConstantAccessor<number>;
|
|
19
17
|
};
|
|
18
|
+
import type { BaseMarkProps, ChannelAccessor, DataRow, ConstantAccessor } from '../types.js';
|
|
19
|
+
/** The TickY mark is useful for showing one-dimensional distributions along the y axis. The x axis must be a band scale. */
|
|
20
20
|
declare const TickY: import("svelte").Component<TickYMarkProps, {}, "">;
|
|
21
21
|
type TickY = ReturnType<typeof TickY>;
|
|
22
22
|
export default TickY;
|
package/dist/marks/Vector.svelte
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
The vector mark lets you place shapes (like arrows) on your plot.
|
|
4
|
+
-->
|
|
1
5
|
<script lang="ts" module>
|
|
2
6
|
import type {
|
|
3
7
|
PlotContext,
|
|
@@ -21,8 +25,6 @@
|
|
|
21
25
|
r?: number;
|
|
22
26
|
length?: ChannelAccessor;
|
|
23
27
|
rotate?: ChannelAccessor;
|
|
24
|
-
fill?: ChannelAccessor;
|
|
25
|
-
stroke?: ChannelAccessor;
|
|
26
28
|
/**
|
|
27
29
|
* Controls where the vector is anchored in relation to the x, y position.
|
|
28
30
|
* If set to 'start', the arrow will start at the x, y position. If set to
|
|
@@ -32,8 +34,6 @@
|
|
|
32
34
|
anchor: 'start' | 'middle' | 'end';
|
|
33
35
|
shape?: 'arrow' | 'spike' | 'arrow-filled' | ShapeRenderer;
|
|
34
36
|
children?: Snippet;
|
|
35
|
-
dx?: ConstantAccessor<number>;
|
|
36
|
-
dy?: ConstantAccessor<number>;
|
|
37
37
|
canvas?: boolean;
|
|
38
38
|
};
|
|
39
39
|
</script>
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
<text x="30" y="30" style="color:red"
|
|
171
171
|
>implement canvas rendering for vector mark</text>
|
|
172
172
|
{:else}
|
|
173
|
-
{#each scaledData as d}
|
|
173
|
+
{#each scaledData as d, i (i)}
|
|
174
174
|
{@const r = resolveChannel('r', d.datum, { r: 3, ...args })}
|
|
175
175
|
{#if d.valid && isValid(r)}
|
|
176
176
|
{@const dx = +resolveProp(args.dx, d.datum, 0)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataRecord, BaseMarkProps,
|
|
1
|
+
import type { DataRecord, BaseMarkProps, ChannelAccessor } from '../types.js';
|
|
2
2
|
type D3Path = ReturnType<typeof import('d3-path').path>;
|
|
3
3
|
export type ShapeRenderer = {
|
|
4
4
|
draw(context: D3Path, l: number, r: number): void;
|
|
@@ -10,8 +10,6 @@ export type VectorMarkProps = BaseMarkProps & {
|
|
|
10
10
|
r?: number;
|
|
11
11
|
length?: ChannelAccessor;
|
|
12
12
|
rotate?: ChannelAccessor;
|
|
13
|
-
fill?: ChannelAccessor;
|
|
14
|
-
stroke?: ChannelAccessor;
|
|
15
13
|
/**
|
|
16
14
|
* Controls where the vector is anchored in relation to the x, y position.
|
|
17
15
|
* If set to 'start', the arrow will start at the x, y position. If set to
|
|
@@ -21,11 +19,10 @@ export type VectorMarkProps = BaseMarkProps & {
|
|
|
21
19
|
anchor: 'start' | 'middle' | 'end';
|
|
22
20
|
shape?: 'arrow' | 'spike' | 'arrow-filled' | ShapeRenderer;
|
|
23
21
|
children?: Snippet;
|
|
24
|
-
dx?: ConstantAccessor<number>;
|
|
25
|
-
dy?: ConstantAccessor<number>;
|
|
26
22
|
canvas?: boolean;
|
|
27
23
|
};
|
|
28
24
|
import { type Snippet } from 'svelte';
|
|
25
|
+
/** The vector mark lets you place shapes (like arrows) on your plot. */
|
|
29
26
|
declare const Vector: import("svelte").Component<VectorMarkProps, {}, "">;
|
|
30
27
|
type Vector = ReturnType<typeof Vector>;
|
|
31
28
|
export default Vector;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<linearGradient {id} gradientUnits="userSpaceOnUse" x1={0} y2={0} y1={0} x2={plot.width}>
|
|
24
|
-
{#each projectedStops as { px, color }}
|
|
24
|
+
{#each projectedStops as { px, color }, i (i)}
|
|
25
25
|
<stop stop-color={color} offset={px} />
|
|
26
26
|
{/each}
|
|
27
27
|
</linearGradient>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<linearGradient {id} gradientUnits="userSpaceOnUse" x1={0} x2={0} y1={0} y2={plot.height}>
|
|
24
|
-
{#each projectedStops as { py, color }}
|
|
24
|
+
{#each projectedStops as { py, color }, i (i)}
|
|
25
25
|
<stop stop-color={color} offset={py} />
|
|
26
26
|
{/each}
|
|
27
27
|
</linearGradient>
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
class={className}
|
|
97
97
|
stroke-width={strokeWidth_}
|
|
98
98
|
use:addEventHandlers={{ getPlotState, options: mark.options, datum }}>
|
|
99
|
-
{#each Object.entries( { start: markerStart, mid: markerMid, end: markerEnd, all: marker } ) as [key, marker]}
|
|
99
|
+
{#each Object.entries( { start: markerStart, mid: markerMid, end: markerEnd, all: marker } ) as [key, marker] (key)}
|
|
100
100
|
{@const markerId = `marker-${key === 'all' ? '' : `${key}-`}${id}`}
|
|
101
101
|
{#if isSnippet(marker)}
|
|
102
102
|
{@render marker(markerId, color)}
|
|
@@ -25,7 +25,8 @@ Helper component for rendering rectangular marks in SVG
|
|
|
25
25
|
height,
|
|
26
26
|
useInsetAsFallbackVertically = true,
|
|
27
27
|
useInsetAsFallbackHorizontally = true,
|
|
28
|
-
usedScales
|
|
28
|
+
usedScales,
|
|
29
|
+
fallbackStyle = 'fill'
|
|
29
30
|
}: {
|
|
30
31
|
datum: ScaledDataRecord;
|
|
31
32
|
class: string | null;
|
|
@@ -47,39 +48,40 @@ Helper component for rendering rectangular marks in SVG
|
|
|
47
48
|
*/
|
|
48
49
|
useInsetAsFallbackHorizontally?: boolean;
|
|
49
50
|
usedScales: UsedScales;
|
|
51
|
+
fallbackStyle?: 'fill' | 'stroke';
|
|
50
52
|
} = $props();
|
|
51
53
|
|
|
52
54
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
53
55
|
const plot = $derived(getPlotState());
|
|
54
56
|
|
|
55
|
-
const dx = $derived(+(resolveProp(options.dx, datum
|
|
56
|
-
const dy = $derived(+(resolveProp(options.dy, datum
|
|
57
|
-
const inset = $derived(+(resolveProp(options.inset, datum
|
|
57
|
+
const dx = $derived(+(resolveProp(options.dx, datum?.datum, 0) as number));
|
|
58
|
+
const dy = $derived(+(resolveProp(options.dy, datum?.datum, 0) as number));
|
|
59
|
+
const inset = $derived(+(resolveProp(options.inset, datum?.datum, 0) as number));
|
|
58
60
|
const insetLeft = $derived(
|
|
59
61
|
+(resolveProp(
|
|
60
62
|
options.insetLeft,
|
|
61
|
-
datum
|
|
63
|
+
datum?.datum,
|
|
62
64
|
useInsetAsFallbackHorizontally ? inset : 0
|
|
63
65
|
) as number)
|
|
64
66
|
);
|
|
65
67
|
const insetRight = $derived(
|
|
66
68
|
+(resolveProp(
|
|
67
69
|
options.insetRight,
|
|
68
|
-
datum
|
|
70
|
+
datum?.datum,
|
|
69
71
|
useInsetAsFallbackHorizontally ? inset : 0
|
|
70
72
|
) as number)
|
|
71
73
|
);
|
|
72
74
|
const insetTop = $derived(
|
|
73
75
|
+(resolveProp(
|
|
74
76
|
options.insetTop,
|
|
75
|
-
datum
|
|
77
|
+
datum?.datum,
|
|
76
78
|
useInsetAsFallbackVertically ? inset : 0
|
|
77
79
|
) as number)
|
|
78
80
|
);
|
|
79
81
|
const insetBottom = $derived(
|
|
80
82
|
+(resolveProp(
|
|
81
83
|
options.insetBottom,
|
|
82
|
-
datum
|
|
84
|
+
datum?.datum,
|
|
83
85
|
useInsetAsFallbackVertically ? inset : 0
|
|
84
86
|
) as number)
|
|
85
87
|
);
|
|
@@ -94,12 +96,14 @@ Helper component for rendering rectangular marks in SVG
|
|
|
94
96
|
borderRadius.bottomLeft ?? 0
|
|
95
97
|
) > 0)
|
|
96
98
|
);
|
|
97
|
-
const [style, styleClass] = $derived(
|
|
99
|
+
const [style, styleClass] = $derived(
|
|
100
|
+
resolveStyles(plot, datum, options, fallbackStyle, usedScales)
|
|
101
|
+
);
|
|
98
102
|
</script>
|
|
99
103
|
|
|
100
104
|
{#if hasBorderRadius}
|
|
101
105
|
<path
|
|
102
|
-
transform="translate({
|
|
106
|
+
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
|
|
103
107
|
d={roundedRect(
|
|
104
108
|
0,
|
|
105
109
|
0,
|
|
@@ -112,11 +116,11 @@ Helper component for rendering rectangular marks in SVG
|
|
|
112
116
|
use:addEventHandlers={{
|
|
113
117
|
getPlotState,
|
|
114
118
|
options,
|
|
115
|
-
datum: datum
|
|
119
|
+
datum: datum?.datum
|
|
116
120
|
}} />
|
|
117
121
|
{:else}
|
|
118
122
|
<rect
|
|
119
|
-
transform="translate({
|
|
123
|
+
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
|
|
120
124
|
width={width - insetLeft - insetRight}
|
|
121
125
|
height={height - insetTop - insetBottom}
|
|
122
126
|
class={[styleClass, className]}
|
|
@@ -124,6 +128,6 @@ Helper component for rendering rectangular marks in SVG
|
|
|
124
128
|
use:addEventHandlers={{
|
|
125
129
|
getPlotState,
|
|
126
130
|
options,
|
|
127
|
-
datum: datum
|
|
131
|
+
datum: datum?.datum
|
|
128
132
|
}} />
|
|
129
133
|
{/if}
|
|
@@ -20,6 +20,7 @@ type $$ComponentProps = {
|
|
|
20
20
|
*/
|
|
21
21
|
useInsetAsFallbackHorizontally?: boolean;
|
|
22
22
|
usedScales: UsedScales;
|
|
23
|
+
fallbackStyle?: 'fill' | 'stroke';
|
|
23
24
|
};
|
|
24
25
|
/** Helper component for rendering rectangular marks in SVG */
|
|
25
26
|
declare const RectPath: import("svelte").Component<$$ComponentProps, {}, "">;
|