svelteplot 0.10.3 → 0.11.0
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 +42 -25
- package/dist/Mark.svelte.d.ts +111 -32
- package/dist/Plot.svelte +21 -15
- package/dist/core/Facet.svelte +1 -1
- package/dist/core/FacetAxes.svelte +13 -8
- package/dist/core/FacetGrid.svelte +4 -4
- package/dist/core/Plot.svelte +41 -35
- package/dist/helpers/autoScales.d.ts +3 -3
- package/dist/helpers/autoScales.js +28 -18
- package/dist/helpers/autoTicks.js +2 -0
- package/dist/helpers/callWithProps.d.ts +1 -2
- package/dist/helpers/facets.js +0 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/mergeDeep.d.ts +1 -3
- package/dist/helpers/mergeDeep.js +15 -16
- package/dist/helpers/projection.d.ts +4 -3
- package/dist/helpers/projection.js +17 -5
- package/dist/helpers/reduce.d.ts +4 -4
- package/dist/helpers/reduce.js +6 -4
- package/dist/helpers/regressionLoess.js +2 -1
- package/dist/helpers/resolve.d.ts +6 -3
- package/dist/helpers/resolve.js +25 -16
- package/dist/helpers/scales.d.ts +10 -10
- package/dist/helpers/scales.js +43 -13
- package/dist/helpers/time.d.ts +10 -3
- package/dist/helpers/time.js +2 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/plotDefaults.d.ts +3 -1
- package/dist/hooks/plotDefaults.js +33 -1
- package/dist/hooks/usePlot.svelte.d.ts +10 -25
- package/dist/hooks/usePlot.svelte.js +8 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/marks/Area.svelte +24 -13
- package/dist/marks/Area.svelte.d.ts +118 -34
- package/dist/marks/AreaX.svelte +42 -8
- package/dist/marks/AreaX.svelte.d.ts +154 -71
- package/dist/marks/AreaY.svelte +42 -8
- package/dist/marks/AreaY.svelte.d.ts +154 -71
- package/dist/marks/Arrow.svelte +42 -23
- package/dist/marks/Arrow.svelte.d.ts +114 -35
- package/dist/marks/AxisX.svelte +43 -28
- package/dist/marks/AxisX.svelte.d.ts +125 -40
- package/dist/marks/AxisY.svelte +43 -26
- package/dist/marks/AxisY.svelte.d.ts +127 -40
- package/dist/marks/BarX.svelte +12 -10
- package/dist/marks/BarX.svelte.d.ts +104 -32
- package/dist/marks/BarY.svelte +11 -10
- package/dist/marks/BarY.svelte.d.ts +106 -34
- package/dist/marks/BollingerX.svelte +4 -7
- package/dist/marks/BollingerX.svelte.d.ts +105 -30
- package/dist/marks/BollingerY.svelte +3 -0
- package/dist/marks/BollingerY.svelte.d.ts +105 -30
- package/dist/marks/BoxX.svelte +3 -3
- package/dist/marks/BoxY.svelte +12 -9
- package/dist/marks/BoxY.svelte.d.ts +128 -53
- package/dist/marks/Brush.svelte +26 -21
- package/dist/marks/Brush.svelte.d.ts +119 -60
- package/dist/marks/Cell.svelte +13 -9
- package/dist/marks/Cell.svelte.d.ts +105 -30
- package/dist/marks/CellX.svelte +2 -1
- package/dist/marks/CellX.svelte.d.ts +105 -32
- package/dist/marks/CellY.svelte +2 -1
- package/dist/marks/CellY.svelte.d.ts +105 -32
- package/dist/marks/ColorLegend.svelte +24 -13
- package/dist/marks/ColorLegend.svelte.d.ts +1 -0
- package/dist/marks/CustomMark.svelte +16 -10
- package/dist/marks/CustomMark.svelte.d.ts +112 -31
- package/dist/marks/CustomMarkHTML.svelte +8 -2
- package/dist/marks/CustomMarkHTML.svelte.d.ts +8 -2
- package/dist/marks/DifferenceY.svelte +31 -20
- package/dist/marks/DifferenceY.svelte.d.ts +134 -55
- package/dist/marks/Dot.svelte +21 -11
- package/dist/marks/Dot.svelte.d.ts +117 -38
- package/dist/marks/DotX.svelte +2 -0
- package/dist/marks/DotX.svelte.d.ts +136 -62
- package/dist/marks/DotY.svelte +1 -0
- package/dist/marks/DotY.svelte.d.ts +135 -62
- package/dist/marks/Frame.svelte +47 -9
- package/dist/marks/Frame.svelte.d.ts +124 -41
- package/dist/marks/Geo.svelte +21 -12
- package/dist/marks/Geo.svelte.d.ts +105 -30
- package/dist/marks/Graticule.svelte +3 -0
- package/dist/marks/Graticule.svelte.d.ts +3 -0
- package/dist/marks/GridX.svelte +31 -16
- package/dist/marks/GridX.svelte.d.ts +108 -32
- package/dist/marks/GridY.svelte +30 -15
- package/dist/marks/GridY.svelte.d.ts +108 -32
- package/dist/marks/HTMLTooltip.svelte +14 -7
- package/dist/marks/HTMLTooltip.svelte.d.ts +7 -0
- package/dist/marks/Image.svelte +50 -25
- package/dist/marks/Image.svelte.d.ts +117 -35
- package/dist/marks/Line.svelte +67 -44
- package/dist/marks/Line.svelte.d.ts +119 -30
- package/dist/marks/LineX.svelte +2 -1
- package/dist/marks/LineX.svelte.d.ts +142 -69
- package/dist/marks/LineY.svelte +2 -1
- package/dist/marks/LineY.svelte.d.ts +142 -69
- package/dist/marks/Link.svelte +70 -46
- package/dist/marks/Link.svelte.d.ts +126 -41
- package/dist/marks/Pointer.svelte +24 -15
- package/dist/marks/Pointer.svelte.d.ts +7 -0
- package/dist/marks/Rect.svelte +13 -5
- package/dist/marks/Rect.svelte.d.ts +116 -35
- package/dist/marks/RectX.svelte +6 -3
- package/dist/marks/RectX.svelte.d.ts +158 -12
- package/dist/marks/RectY.svelte +6 -3
- package/dist/marks/RectY.svelte.d.ts +158 -12
- package/dist/marks/RegressionX.svelte +13 -6
- package/dist/marks/RegressionX.svelte.d.ts +8 -3
- package/dist/marks/RegressionY.svelte +13 -6
- package/dist/marks/RegressionY.svelte.d.ts +8 -3
- package/dist/marks/RuleX.svelte +18 -11
- package/dist/marks/RuleX.svelte.d.ts +112 -32
- package/dist/marks/RuleY.svelte +19 -12
- package/dist/marks/RuleY.svelte.d.ts +114 -34
- package/dist/marks/Spike.svelte +11 -5
- package/dist/marks/Spike.svelte.d.ts +146 -68
- package/dist/marks/Text.svelte +24 -7
- package/dist/marks/Text.svelte.d.ts +253 -75
- package/dist/marks/TickX.svelte +56 -48
- package/dist/marks/TickX.svelte.d.ts +114 -40
- package/dist/marks/TickY.svelte +59 -51
- package/dist/marks/TickY.svelte.d.ts +117 -43
- package/dist/marks/Trail.svelte +25 -13
- package/dist/marks/Trail.svelte.d.ts +116 -33
- package/dist/marks/Vector.svelte +20 -11
- package/dist/marks/Vector.svelte.d.ts +116 -35
- package/dist/marks/WaffleX.svelte +18 -16
- package/dist/marks/WaffleX.svelte.d.ts +131 -57
- package/dist/marks/WaffleY.svelte +16 -15
- package/dist/marks/WaffleY.svelte.d.ts +129 -56
- package/dist/marks/helpers/Anchor.svelte +17 -2
- package/dist/marks/helpers/Anchor.svelte.d.ts +16 -1
- package/dist/marks/helpers/AreaCanvas.svelte +8 -8
- package/dist/marks/helpers/BaseAxisX.svelte +38 -41
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +11 -17
- package/dist/marks/helpers/BaseAxisY.svelte +35 -35
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +12 -15
- package/dist/marks/helpers/Box.svelte +35 -28
- package/dist/marks/helpers/Box.svelte.d.ts +122 -50
- package/dist/marks/helpers/DotCanvas.svelte +11 -9
- package/dist/marks/helpers/GeoCanvas.svelte +7 -6
- package/dist/marks/helpers/LineCanvas.svelte +7 -7
- package/dist/marks/helpers/LinearGradientX.svelte +2 -2
- package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +2 -2
- package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
- package/dist/marks/helpers/Marker.svelte +2 -2
- package/dist/marks/helpers/MarkerPath.svelte +15 -12
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +105 -32
- package/dist/marks/helpers/MultilineText.svelte +24 -17
- package/dist/marks/helpers/MultilineText.svelte.d.ts +1 -1
- package/dist/marks/helpers/RectCanvas.svelte +31 -26
- package/dist/marks/helpers/RectPath.svelte +2 -2
- package/dist/marks/helpers/Regression.svelte +176 -86
- package/dist/marks/helpers/Regression.svelte.d.ts +20 -8
- package/dist/marks/helpers/RuleCanvas.svelte +9 -6
- package/dist/marks/helpers/TextCanvas.svelte +13 -9
- package/dist/marks/helpers/TextCanvas.svelte.d.ts +6 -6
- package/dist/marks/helpers/TickCanvas.svelte +6 -5
- package/dist/marks/helpers/TrailCanvas.svelte +16 -18
- package/dist/marks/helpers/TrailCanvas.svelte.d.ts +3 -5
- package/dist/marks/helpers/canvas.js +16 -9
- package/dist/marks/helpers/events.d.ts +2 -2
- package/dist/marks/helpers/events.js +14 -7
- package/dist/marks/helpers/waffle.d.ts +3 -3
- package/dist/marks/helpers/waffle.js +6 -4
- package/dist/regression/polynomial.d.ts +1 -1
- package/dist/regression/polynomial.js +5 -5
- package/dist/regression/utils/determination.d.ts +1 -1
- package/dist/regression/utils/determination.js +1 -1
- package/dist/regression/utils/geometry.d.ts +1 -1
- package/dist/regression/utils/interpose.d.ts +1 -1
- package/dist/regression/utils/interpose.js +1 -1
- package/dist/regression/utils/points.d.ts +1 -1
- package/dist/transforms/bin.d.ts +3 -3
- package/dist/transforms/bin.js +29 -20
- package/dist/transforms/bollinger.d.ts +8 -0
- package/dist/transforms/bollinger.js +9 -1
- package/dist/transforms/centroid.d.ts +4 -0
- package/dist/transforms/centroid.js +4 -0
- package/dist/transforms/density.d.ts +4 -4
- package/dist/transforms/density.js +20 -13
- package/dist/transforms/dodge.d.ts +12 -1
- package/dist/transforms/dodge.js +15 -6
- package/dist/transforms/group.d.ts +141 -4
- package/dist/transforms/group.js +4 -1
- package/dist/transforms/interval.d.ts +204 -60
- package/dist/transforms/jitter.d.ts +421 -4
- package/dist/transforms/jitter.js +10 -1
- package/dist/transforms/map.d.ts +412 -4
- package/dist/transforms/map.js +3 -3
- package/dist/transforms/normalize.d.ts +276 -5
- package/dist/transforms/normalize.js +5 -3
- package/dist/transforms/recordize.d.ts +17 -5
- package/dist/transforms/recordize.js +13 -9
- package/dist/transforms/rename.d.ts +11 -4
- package/dist/transforms/rename.js +7 -2
- package/dist/transforms/select.d.ts +722 -210
- package/dist/transforms/select.js +13 -1
- package/dist/transforms/shift.d.ts +8 -0
- package/dist/transforms/shift.js +20 -6
- package/dist/transforms/sort.d.ts +13 -258
- package/dist/transforms/sort.js +13 -10
- package/dist/transforms/stack.d.ts +58 -9
- package/dist/transforms/stack.js +27 -11
- package/dist/transforms/window.d.ts +221 -66
- package/dist/transforms/window.js +8 -2
- package/dist/types/axes.d.ts +43 -0
- package/dist/types/axes.js +1 -0
- package/dist/types/channel.d.ts +30 -2
- package/dist/types/data.d.ts +14 -1
- package/dist/types/facet.d.ts +5 -0
- package/dist/types/index.d.ts +33 -8
- package/dist/types/index.js +11 -7
- package/dist/types/mark.d.ts +124 -35
- package/dist/types/plot.d.ts +118 -16
- package/dist/types/scale.d.ts +125 -8
- package/package.json +178 -175
- package/dist/helpers/autoTicks.d.ts +0 -12
package/dist/marks/TickX.svelte
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
The TickX mark is useful for showing one-dimensional distributions along the x axis. The y axis must be a band scale.
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
<script lang="ts" generics="Datum
|
|
6
|
+
<script lang="ts" generics="Datum = DataRecord | RawValue">
|
|
7
7
|
interface TickXMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
|
|
8
|
+
/** the input data array; each element becomes one vertical tick */
|
|
8
9
|
data: Datum[];
|
|
9
10
|
/**
|
|
10
11
|
* the horizontal position; bound to the x scale
|
|
@@ -20,23 +21,21 @@
|
|
|
20
21
|
* length of the tick. Defaults to 10 pixel
|
|
21
22
|
*/
|
|
22
23
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
24
|
+
/** if true, renders using Canvas instead of SVG */
|
|
23
25
|
canvas?: boolean;
|
|
24
26
|
}
|
|
25
27
|
import Mark from '../Mark.svelte';
|
|
26
28
|
import TickCanvas from './helpers/TickCanvas.svelte';
|
|
27
|
-
import {
|
|
28
|
-
import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
|
|
29
|
+
import { resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
|
|
29
30
|
import type {
|
|
30
31
|
BaseMarkProps,
|
|
31
32
|
ChannelAccessor,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
ConstantAccessor,
|
|
34
|
+
DataRecord,
|
|
35
|
+
RawValue
|
|
35
36
|
} from '../types/index.js';
|
|
36
37
|
import { recordizeX } from '../index.js';
|
|
37
|
-
import {
|
|
38
|
-
import { isValid } from '../helpers/index.js';
|
|
39
|
-
import { testFilter, parseInset } from '../helpers/index.js';
|
|
38
|
+
import { parseInset } from '../helpers/index.js';
|
|
40
39
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
41
40
|
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
42
41
|
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
...getPlotDefaults().tickX
|
|
49
48
|
};
|
|
50
49
|
const {
|
|
51
|
-
data = [{}],
|
|
50
|
+
data = [{} as Datum],
|
|
52
51
|
class: className = '',
|
|
53
52
|
canvas = false,
|
|
54
53
|
...options
|
|
@@ -57,51 +56,60 @@
|
|
|
57
56
|
...markProps
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
let args = $derived(recordizeX({ data, ...options }, { withIndex: false }));
|
|
61
|
-
|
|
62
|
-
const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
|
|
63
|
-
let testFacet = $derived(getTestFacet());
|
|
59
|
+
let args = $derived(recordizeX({ data, ...options } as any, { withIndex: false }));
|
|
64
60
|
</script>
|
|
65
61
|
|
|
66
62
|
<Mark
|
|
67
63
|
type="tickX"
|
|
68
64
|
channels={['x', 'y', 'stroke', 'opacity', 'strokeOpacity']}
|
|
69
|
-
{...markProps}
|
|
70
|
-
{...args}>
|
|
71
|
-
{#snippet children({
|
|
65
|
+
{...markProps as any}
|
|
66
|
+
{...args as any}>
|
|
67
|
+
{#snippet children({ usedScales, scaledData })}
|
|
72
68
|
{#if canvas}
|
|
73
|
-
<TickCanvas
|
|
69
|
+
<TickCanvas
|
|
70
|
+
data={scaledData}
|
|
71
|
+
options={args as any}
|
|
72
|
+
{usedScales}
|
|
73
|
+
orientation="vertical" />
|
|
74
74
|
{:else}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{@const inset_ = resolveProp(args.inset, datum, 0)}
|
|
81
|
-
{@const tickLength_ =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
75
|
+
{@const yUsesBand = usedScales.y && plot.scales.y.type === 'band'}
|
|
76
|
+
{@const yBandwidth = yUsesBand ? plot.scales.y.fn.bandwidth() : 0}
|
|
77
|
+
<g class="tick-x {className || ''}">
|
|
78
|
+
{#each scaledData as d, i (i)}
|
|
79
|
+
{#if d.valid && d.x != null}
|
|
80
|
+
{@const inset_ = resolveProp(args.inset, d.datum, 0)}
|
|
81
|
+
{@const tickLength_ = Number(
|
|
82
|
+
resolveProp(args.tickLength, d.datum, 10) ?? 10
|
|
83
|
+
)}
|
|
84
|
+
{@const y1 =
|
|
85
|
+
args.y != null && d.y != null
|
|
86
|
+
? yUsesBand
|
|
87
|
+
? d.y - yBandwidth * 0.5
|
|
88
|
+
: d.y
|
|
89
|
+
: plot.options.marginTop}
|
|
90
|
+
{@const y2 =
|
|
91
|
+
args.y != null && d.y != null
|
|
92
|
+
? yUsesBand
|
|
93
|
+
? d.y + yBandwidth * 0.5
|
|
94
|
+
: d.y
|
|
95
|
+
: plot.options.marginTop + plot.plotHeight}
|
|
96
|
+
{@const insetValue =
|
|
97
|
+
typeof inset_ === 'number' || typeof inset_ === 'string' ? inset_ : 0}
|
|
98
|
+
{@const inset = parseInset(insetValue, Math.abs(y2 - y1))}
|
|
99
|
+
{@const tickOffset = y1 === y2 ? tickLength_ * 0.5 : 0}
|
|
100
|
+
{@const xTransform = d.x}
|
|
101
|
+
{@const yTransform = args.y == null ? d.dy : 0}
|
|
102
|
+
<line
|
|
103
|
+
transform="translate({xTransform}, {yTransform})"
|
|
104
|
+
style={resolveScaledStyles(
|
|
105
|
+
d.datum,
|
|
106
|
+
args as any,
|
|
107
|
+
usedScales,
|
|
108
|
+
plot,
|
|
109
|
+
'stroke'
|
|
110
|
+
)}
|
|
111
|
+
y1={y1 + inset + tickOffset}
|
|
112
|
+
y2={y2 - inset - tickOffset} />
|
|
105
113
|
{/if}
|
|
106
114
|
{/each}
|
|
107
115
|
</g>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChannelAccessor,
|
|
2
|
-
declare function $$render<Datum
|
|
1
|
+
import type { ChannelAccessor, ConstantAccessor, DataRecord, RawValue } from '../types/index.js';
|
|
2
|
+
declare function $$render<Datum = DataRecord | RawValue>(): {
|
|
3
3
|
props: Omit<Partial<{
|
|
4
4
|
filter: ConstantAccessor<boolean, Datum>;
|
|
5
5
|
facet: "auto" | "include" | "exclude";
|
|
@@ -7,14 +7,24 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
7
7
|
fy: ChannelAccessor<Datum>;
|
|
8
8
|
dx: ConstantAccessor<number, Datum>;
|
|
9
9
|
dy: ConstantAccessor<number, Datum>;
|
|
10
|
-
dodgeX: import("../transforms/dodge").DodgeXOptions;
|
|
11
|
-
dodgeY: import("../transforms/dodge").DodgeYOptions;
|
|
10
|
+
dodgeX: import("../transforms/dodge.js").DodgeXOptions;
|
|
11
|
+
dodgeY: import("../transforms/dodge.js").DodgeYOptions;
|
|
12
12
|
fill: ChannelAccessor<Datum>;
|
|
13
13
|
fillOpacity: ConstantAccessor<number, Datum>;
|
|
14
|
-
|
|
14
|
+
fontFamily: ConstantAccessor<import("csstype").Property.FontFamily, Datum>;
|
|
15
|
+
fontSize: ConstantAccessor<number | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "math" | (string & {}) | "large" | "medium" | "small" | "x-large" | "x-small" | "xx-large" | "xx-small" | "xxx-large" | "larger" | "smaller", Datum>;
|
|
16
|
+
fontStyle: ConstantAccessor<import("csstype").Property.FontStyle, Datum>;
|
|
17
|
+
fontVariant: ConstantAccessor<import("csstype").Property.FontVariant, Datum>;
|
|
18
|
+
fontWeight: ConstantAccessor<import("csstype").Property.FontWeight, Datum>;
|
|
19
|
+
letterSpacing: ConstantAccessor<import("csstype").Property.LetterSpacing<0 | (string & {})>, Datum>;
|
|
20
|
+
wordSpacing: ConstantAccessor<import("csstype").Property.WordSpacing<0 | (string & {})>, Datum>;
|
|
21
|
+
textAnchor: ConstantAccessor<import("csstype").Property.TextAnchor, Datum>;
|
|
22
|
+
textTransform: ConstantAccessor<import("csstype").Property.TextTransform, Datum>;
|
|
23
|
+
textDecoration: ConstantAccessor<import("csstype").Property.TextDecoration<0 | (string & {})>, Datum>;
|
|
24
|
+
sort: ((a: RawValue, b: RawValue) => number) | {
|
|
15
25
|
channel: string;
|
|
16
26
|
order?: "ascending" | "descending";
|
|
17
|
-
} | ConstantAccessor<
|
|
27
|
+
} | ConstantAccessor<RawValue, Datum>;
|
|
18
28
|
stroke: ChannelAccessor<Datum>;
|
|
19
29
|
strokeWidth: ConstantAccessor<number, Datum>;
|
|
20
30
|
strokeOpacity: ConstantAccessor<number, Datum>;
|
|
@@ -24,46 +34,109 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
24
34
|
opacity: ChannelAccessor<Datum>;
|
|
25
35
|
strokeDasharray: ConstantAccessor<string, Datum>;
|
|
26
36
|
strokeDashoffset: ConstantAccessor<number, Datum>;
|
|
37
|
+
blend: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
27
38
|
mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
28
39
|
clipPath: string;
|
|
29
40
|
mask: string;
|
|
30
41
|
imageFilter: ConstantAccessor<string, Datum>;
|
|
31
42
|
shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
32
43
|
paintOrder: ConstantAccessor<string, Datum>;
|
|
33
|
-
onclick:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
onclick: (event: Event & {
|
|
45
|
+
currentTarget: SVGPathElement;
|
|
46
|
+
}, datum: Datum, index: number) => void;
|
|
47
|
+
ondblclick: (event: Event & {
|
|
48
|
+
currentTarget: SVGPathElement;
|
|
49
|
+
}, datum: Datum, index: number) => void;
|
|
50
|
+
onmouseup: (event: Event & {
|
|
51
|
+
currentTarget: SVGPathElement;
|
|
52
|
+
}, datum: Datum, index: number) => void;
|
|
53
|
+
onmousedown: (event: Event & {
|
|
54
|
+
currentTarget: SVGPathElement;
|
|
55
|
+
}, datum: Datum, index: number) => void;
|
|
56
|
+
onmouseenter: (event: Event & {
|
|
57
|
+
currentTarget: SVGPathElement;
|
|
58
|
+
}, datum: Datum, index: number) => void;
|
|
59
|
+
onmousemove: (event: Event & {
|
|
60
|
+
currentTarget: SVGPathElement;
|
|
61
|
+
}, datum: Datum, index: number) => void;
|
|
62
|
+
onmouseleave: (event: Event & {
|
|
63
|
+
currentTarget: SVGPathElement;
|
|
64
|
+
}, datum: Datum, index: number) => void;
|
|
65
|
+
onmouseout: (event: Event & {
|
|
66
|
+
currentTarget: SVGPathElement;
|
|
67
|
+
}, datum: Datum, index: number) => void;
|
|
68
|
+
onmouseover: (event: Event & {
|
|
69
|
+
currentTarget: SVGPathElement;
|
|
70
|
+
}, datum: Datum, index: number) => void;
|
|
71
|
+
onpointercancel: (event: Event & {
|
|
72
|
+
currentTarget: SVGPathElement;
|
|
73
|
+
}, datum: Datum, index: number) => void;
|
|
74
|
+
onpointerdown: (event: Event & {
|
|
75
|
+
currentTarget: SVGPathElement;
|
|
76
|
+
}, datum: Datum, index: number) => void;
|
|
77
|
+
onpointerup: (event: Event & {
|
|
78
|
+
currentTarget: SVGPathElement;
|
|
79
|
+
}, datum: Datum, index: number) => void;
|
|
80
|
+
onpointerenter: (event: Event & {
|
|
81
|
+
currentTarget: SVGPathElement;
|
|
82
|
+
}, datum: Datum, index: number) => void;
|
|
83
|
+
onpointerleave: (event: Event & {
|
|
84
|
+
currentTarget: SVGPathElement;
|
|
85
|
+
}, datum: Datum, index: number) => void;
|
|
86
|
+
onpointermove: (event: Event & {
|
|
87
|
+
currentTarget: SVGPathElement;
|
|
88
|
+
}, datum: Datum, index: number) => void;
|
|
89
|
+
onpointerover: (event: Event & {
|
|
90
|
+
currentTarget: SVGPathElement;
|
|
91
|
+
}, datum: Datum, index: number) => void;
|
|
92
|
+
onpointerout: (event: Event & {
|
|
93
|
+
currentTarget: SVGPathElement;
|
|
94
|
+
}, datum: Datum, index: number) => void;
|
|
95
|
+
ondrag: (event: Event & {
|
|
96
|
+
currentTarget: SVGPathElement;
|
|
97
|
+
}, datum: Datum, index: number) => void;
|
|
98
|
+
ondrop: (event: Event & {
|
|
99
|
+
currentTarget: SVGPathElement;
|
|
100
|
+
}, datum: Datum, index: number) => void;
|
|
101
|
+
ondragstart: (event: Event & {
|
|
102
|
+
currentTarget: SVGPathElement;
|
|
103
|
+
}, datum: Datum, index: number) => void;
|
|
104
|
+
ondragenter: (event: Event & {
|
|
105
|
+
currentTarget: SVGPathElement;
|
|
106
|
+
}, datum: Datum, index: number) => void;
|
|
107
|
+
ondragleave: (event: Event & {
|
|
108
|
+
currentTarget: SVGPathElement;
|
|
109
|
+
}, datum: Datum, index: number) => void;
|
|
110
|
+
ondragover: (event: Event & {
|
|
111
|
+
currentTarget: SVGPathElement;
|
|
112
|
+
}, datum: Datum, index: number) => void;
|
|
113
|
+
ondragend: (event: Event & {
|
|
114
|
+
currentTarget: SVGPathElement;
|
|
115
|
+
}, datum: Datum, index: number) => void;
|
|
116
|
+
ontouchstart: (event: Event & {
|
|
117
|
+
currentTarget: SVGPathElement;
|
|
118
|
+
}, datum: Datum, index: number) => void;
|
|
119
|
+
ontouchmove: (event: Event & {
|
|
120
|
+
currentTarget: SVGPathElement;
|
|
121
|
+
}, datum: Datum, index: number) => void;
|
|
122
|
+
ontouchend: (event: Event & {
|
|
123
|
+
currentTarget: SVGPathElement;
|
|
124
|
+
}, datum: Datum, index: number) => void;
|
|
125
|
+
ontouchcancel: (event: Event & {
|
|
126
|
+
currentTarget: SVGPathElement;
|
|
127
|
+
}, datum: Datum, index: number) => void;
|
|
128
|
+
oncontextmenu: (event: Event & {
|
|
129
|
+
currentTarget: SVGPathElement;
|
|
130
|
+
}, datum: Datum, index: number) => void;
|
|
131
|
+
onwheel: (event: Event & {
|
|
132
|
+
currentTarget: SVGPathElement;
|
|
133
|
+
}, datum: Datum, index: number) => void;
|
|
63
134
|
class: string;
|
|
64
135
|
style: string;
|
|
65
136
|
cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
|
|
137
|
+
title: ConstantAccessor<string, Datum>;
|
|
66
138
|
}>, "fill" | "fillOpacity"> & {
|
|
139
|
+
/** the input data array; each element becomes one vertical tick */
|
|
67
140
|
data: Datum[];
|
|
68
141
|
/**
|
|
69
142
|
* the horizontal position; bound to the x scale
|
|
@@ -79,6 +152,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
79
152
|
* length of the tick. Defaults to 10 pixel
|
|
80
153
|
*/
|
|
81
154
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
155
|
+
/** if true, renders using Canvas instead of SVG */
|
|
82
156
|
canvas?: boolean;
|
|
83
157
|
};
|
|
84
158
|
exports: {};
|
|
@@ -86,7 +160,7 @@ declare function $$render<Datum extends DataRow>(): {
|
|
|
86
160
|
slots: {};
|
|
87
161
|
events: {};
|
|
88
162
|
};
|
|
89
|
-
declare class __sveltets_Render<Datum
|
|
163
|
+
declare class __sveltets_Render<Datum = DataRecord | RawValue> {
|
|
90
164
|
props(): ReturnType<typeof $$render<Datum>>['props'];
|
|
91
165
|
events(): ReturnType<typeof $$render<Datum>>['events'];
|
|
92
166
|
slots(): ReturnType<typeof $$render<Datum>>['slots'];
|
|
@@ -94,13 +168,13 @@ declare class __sveltets_Render<Datum extends DataRow> {
|
|
|
94
168
|
exports(): {};
|
|
95
169
|
}
|
|
96
170
|
interface $$IsomorphicComponent {
|
|
97
|
-
new <Datum
|
|
171
|
+
new <Datum = DataRecord | RawValue>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Datum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Datum>['props']>, ReturnType<__sveltets_Render<Datum>['events']>, ReturnType<__sveltets_Render<Datum>['slots']>> & {
|
|
98
172
|
$$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
|
|
99
173
|
} & ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
100
|
-
<Datum
|
|
174
|
+
<Datum = DataRecord | RawValue>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
101
175
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
102
176
|
}
|
|
103
177
|
/** The TickX mark is useful for showing one-dimensional distributions along the x axis. The y axis must be a band scale. */
|
|
104
178
|
declare const TickX: $$IsomorphicComponent;
|
|
105
|
-
type TickX<Datum
|
|
179
|
+
type TickX<Datum = DataRecord | RawValue> = InstanceType<typeof TickX<Datum>>;
|
|
106
180
|
export default TickX;
|
package/dist/marks/TickY.svelte
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
@component
|
|
3
3
|
The TickY mark is useful for showing one-dimensional distributions along the y axis. The x axis must be a band scale.
|
|
4
4
|
-->
|
|
5
|
-
<script lang="ts" generics="Datum
|
|
5
|
+
<script lang="ts" generics="Datum = DataRecord | RawValue">
|
|
6
6
|
interface TickYMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
|
|
7
|
+
/** the input data array; each element becomes one horizontal tick */
|
|
7
8
|
data: Datum[];
|
|
8
9
|
/**
|
|
9
|
-
* the vertical position; bound to the
|
|
10
|
+
* the vertical position; bound to the y scale
|
|
10
11
|
*/
|
|
11
12
|
y?: ChannelAccessor<Datum>;
|
|
12
13
|
/**
|
|
13
|
-
* the horizontal position; bound to the
|
|
14
|
-
* is not specified, the tick will span the full
|
|
14
|
+
* the horizontal position; bound to the x scale, which must be band. If the x channel
|
|
15
|
+
* is not specified, the tick will span the full horizontal extent of the frame.
|
|
15
16
|
*/
|
|
16
17
|
x?: ChannelAccessor<Datum>;
|
|
17
18
|
/**
|
|
@@ -19,23 +20,21 @@
|
|
|
19
20
|
* length of the tick. Defaults to 10 pixel
|
|
20
21
|
*/
|
|
21
22
|
tickLength?: ConstantAccessor<number, Datum>;
|
|
23
|
+
/** if true, renders using Canvas instead of SVG */
|
|
22
24
|
canvas?: boolean;
|
|
23
25
|
}
|
|
24
26
|
import Mark from '../Mark.svelte';
|
|
25
27
|
import TickCanvas from './helpers/TickCanvas.svelte';
|
|
26
|
-
import {
|
|
27
|
-
import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
|
|
28
|
+
import { resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
|
|
28
29
|
import type {
|
|
29
30
|
BaseMarkProps,
|
|
30
31
|
ChannelAccessor,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
ConstantAccessor,
|
|
33
|
+
DataRecord,
|
|
34
|
+
RawValue
|
|
34
35
|
} from '../types/index.js';
|
|
35
36
|
import { recordizeY } from '../index.js';
|
|
36
|
-
import {
|
|
37
|
-
import { isValid } from '../helpers/index.js';
|
|
38
|
-
import { testFilter, parseInset } from '../helpers/index.js';
|
|
37
|
+
import { parseInset } from '../helpers/index.js';
|
|
39
38
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
40
39
|
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
41
40
|
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
...getPlotDefaults().tickY
|
|
48
47
|
};
|
|
49
48
|
const {
|
|
50
|
-
data = [{}],
|
|
49
|
+
data = [{} as Datum],
|
|
51
50
|
class: className = '',
|
|
52
51
|
canvas = false,
|
|
53
52
|
...options
|
|
@@ -56,51 +55,60 @@
|
|
|
56
55
|
...markProps
|
|
57
56
|
});
|
|
58
57
|
|
|
59
|
-
let args = $derived(recordizeY({ data, ...options }, { withIndex: false }));
|
|
60
|
-
|
|
61
|
-
const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
|
|
62
|
-
let testFacet = $derived(getTestFacet());
|
|
58
|
+
let args = $derived(recordizeY({ data, ...options } as any, { withIndex: false }));
|
|
63
59
|
</script>
|
|
64
60
|
|
|
65
61
|
<Mark
|
|
66
62
|
type="tickY"
|
|
67
63
|
channels={['x', 'y', 'stroke', 'opacity', 'strokeOpacity']}
|
|
68
|
-
{...markProps}
|
|
69
|
-
{...args}>
|
|
70
|
-
{#snippet children({
|
|
64
|
+
{...markProps as any}
|
|
65
|
+
{...args as any}>
|
|
66
|
+
{#snippet children({ usedScales, scaledData })}
|
|
71
67
|
{#if canvas}
|
|
72
|
-
<TickCanvas
|
|
68
|
+
<TickCanvas
|
|
69
|
+
data={scaledData}
|
|
70
|
+
options={args as any}
|
|
71
|
+
{usedScales}
|
|
72
|
+
orientation="horizontal" />
|
|
73
73
|
{:else}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{@const inset_ = resolveProp(args.inset, datum, 0)}
|
|
80
|
-
{@const tickLength_ =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
74
|
+
{@const xUsesBand = usedScales.x && plot.scales.x.type === 'band'}
|
|
75
|
+
{@const xBandwidth = xUsesBand ? plot.scales.x.fn.bandwidth() : 0}
|
|
76
|
+
<g class="tick-y {className || ''}">
|
|
77
|
+
{#each scaledData as d, i (i)}
|
|
78
|
+
{#if d.valid && d.y != null}
|
|
79
|
+
{@const inset_ = resolveProp(args.inset, d.datum, 0)}
|
|
80
|
+
{@const tickLength_ = Number(
|
|
81
|
+
resolveProp(args.tickLength, d.datum, 10) ?? 10
|
|
82
|
+
)}
|
|
83
|
+
{@const x1 =
|
|
84
|
+
args.x != null && d.x != null
|
|
85
|
+
? xUsesBand
|
|
86
|
+
? d.x - xBandwidth * 0.5
|
|
87
|
+
: d.x
|
|
88
|
+
: plot.options.marginLeft}
|
|
89
|
+
{@const x2 =
|
|
90
|
+
args.x != null && d.x != null
|
|
91
|
+
? xUsesBand
|
|
92
|
+
? d.x + xBandwidth * 0.5
|
|
93
|
+
: d.x
|
|
94
|
+
: plot.options.marginLeft + plot.facetWidth}
|
|
95
|
+
{@const insetValue =
|
|
96
|
+
typeof inset_ === 'number' || typeof inset_ === 'string' ? inset_ : 0}
|
|
97
|
+
{@const inset = parseInset(insetValue, Math.abs(x2 - x1))}
|
|
98
|
+
{@const tickOffset = x1 === x2 ? tickLength_ * 0.5 : 0}
|
|
99
|
+
{@const xTransform = args.x == null ? d.dx : 0}
|
|
100
|
+
{@const yTransform = d.y}
|
|
101
|
+
<line
|
|
102
|
+
transform="translate({xTransform}, {yTransform})"
|
|
103
|
+
style={resolveScaledStyles(
|
|
104
|
+
d.datum,
|
|
105
|
+
args as any,
|
|
106
|
+
usedScales,
|
|
107
|
+
plot,
|
|
108
|
+
'stroke'
|
|
109
|
+
)}
|
|
110
|
+
x1={x1 + inset + tickOffset}
|
|
111
|
+
x2={x2 - inset - tickOffset} />
|
|
104
112
|
{/if}
|
|
105
113
|
{/each}
|
|
106
114
|
</g>
|