svelteplot 0.3.1 → 0.3.2-pr-113.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 +25 -27
- package/dist/Mark.svelte.d.ts +87 -17
- package/dist/Plot.svelte +1 -2
- package/dist/Plot.svelte.d.ts +1 -1
- package/dist/core/Facet.svelte +1 -1
- package/dist/core/Facet.svelte.d.ts +1 -1
- package/dist/core/FacetAxes.svelte +1 -1
- package/dist/core/FacetGrid.svelte +1 -1
- package/dist/core/FacetGrid.svelte.d.ts +1 -1
- package/dist/core/Plot.svelte +1 -1
- package/dist/core/Plot.svelte.d.ts +1 -1
- package/dist/helpers/autoTicks.js +1 -1
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/getBaseStyles.d.ts +2 -0
- package/dist/helpers/getBaseStyles.js +8 -0
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/projection.d.ts +1 -1
- package/dist/helpers/resolve.d.ts +1 -1
- package/dist/helpers/scales.d.ts +1 -1
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte +14 -17
- package/dist/marks/Area.svelte.d.ts +91 -19
- package/dist/marks/AreaX.svelte +15 -12
- package/dist/marks/AreaX.svelte.d.ts +94 -3
- package/dist/marks/AreaY.svelte +15 -15
- package/dist/marks/AreaY.svelte.d.ts +94 -3
- package/dist/marks/Arrow.svelte +16 -19
- package/dist/marks/Arrow.svelte.d.ts +110 -38
- package/dist/marks/AxisX.svelte +41 -41
- package/dist/marks/AxisX.svelte.d.ts +97 -25
- package/dist/marks/AxisY.svelte +40 -40
- package/dist/marks/AxisY.svelte.d.ts +98 -27
- package/dist/marks/BarX.svelte +28 -30
- package/dist/marks/BarX.svelte.d.ts +89 -17
- package/dist/marks/BarY.svelte +27 -27
- package/dist/marks/BarY.svelte.d.ts +88 -16
- package/dist/marks/BollingerX.svelte +21 -16
- package/dist/marks/BollingerX.svelte.d.ts +17 -16
- package/dist/marks/BollingerY.svelte +21 -16
- package/dist/marks/BollingerY.svelte.d.ts +17 -16
- package/dist/marks/BoxX.svelte +5 -7
- package/dist/marks/BoxX.svelte.d.ts +5 -3
- package/dist/marks/BoxY.svelte +13 -16
- package/dist/marks/BoxY.svelte.d.ts +41 -28
- package/dist/marks/Brush.svelte +27 -30
- package/dist/marks/Brush.svelte.d.ts +20 -15
- package/dist/marks/BrushX.svelte +9 -7
- package/dist/marks/BrushX.svelte.d.ts +5 -2
- package/dist/marks/BrushY.svelte +9 -7
- package/dist/marks/BrushY.svelte.d.ts +5 -2
- package/dist/marks/Cell.svelte +17 -18
- package/dist/marks/Cell.svelte.d.ts +80 -8
- package/dist/marks/CellX.svelte +12 -8
- package/dist/marks/CellX.svelte.d.ts +5 -2
- package/dist/marks/CellY.svelte +12 -8
- package/dist/marks/CellY.svelte.d.ts +5 -2
- package/dist/marks/ColorLegend.svelte +5 -8
- package/dist/marks/ColorLegend.svelte.d.ts +2 -2
- package/dist/marks/CustomMark.svelte +23 -16
- package/dist/marks/CustomMark.svelte.d.ts +17 -14
- package/dist/marks/CustomMarkHTML.svelte +20 -18
- package/dist/marks/CustomMarkHTML.svelte.d.ts +29 -15
- package/dist/marks/DifferenceY.svelte +54 -18
- package/dist/marks/DifferenceY.svelte.d.ts +59 -28
- package/dist/marks/Dot.svelte +13 -14
- package/dist/marks/Dot.svelte.d.ts +84 -12
- package/dist/marks/DotX.svelte +9 -9
- package/dist/marks/DotX.svelte.d.ts +86 -4
- package/dist/marks/DotY.svelte +10 -9
- package/dist/marks/DotY.svelte.d.ts +87 -5
- package/dist/marks/Frame.svelte +20 -27
- package/dist/marks/Frame.svelte.d.ts +24 -10
- package/dist/marks/Geo.svelte +22 -15
- package/dist/marks/Geo.svelte.d.ts +97 -13
- package/dist/marks/Graticule.svelte +16 -19
- package/dist/marks/Graticule.svelte.d.ts +3 -3
- package/dist/marks/GridX.svelte +5 -8
- package/dist/marks/GridX.svelte.d.ts +79 -7
- package/dist/marks/GridY.svelte +5 -8
- package/dist/marks/GridY.svelte.d.ts +79 -7
- package/dist/marks/HTMLTooltip.svelte +9 -14
- package/dist/marks/HTMLTooltip.svelte.d.ts +25 -12
- package/dist/marks/Line.svelte +24 -29
- package/dist/marks/Line.svelte.d.ts +97 -25
- package/dist/marks/LineX.svelte +9 -4
- package/dist/marks/LineX.svelte.d.ts +99 -3
- package/dist/marks/LineY.svelte +11 -5
- package/dist/marks/LineY.svelte.d.ts +100 -4
- package/dist/marks/Link.svelte +35 -19
- package/dist/marks/Link.svelte.d.ts +107 -18
- package/dist/marks/Pointer.svelte +13 -18
- package/dist/marks/Pointer.svelte.d.ts +34 -21
- package/dist/marks/Rect.svelte +19 -19
- package/dist/marks/Rect.svelte.d.ts +86 -13
- package/dist/marks/RectX.svelte +10 -9
- package/dist/marks/RectX.svelte.d.ts +22 -6
- package/dist/marks/RectY.svelte +9 -10
- package/dist/marks/RectY.svelte.d.ts +22 -6
- package/dist/marks/RegressionX.svelte +1 -1
- package/dist/marks/RegressionX.svelte.d.ts +1 -1
- package/dist/marks/RegressionY.svelte +1 -1
- package/dist/marks/RegressionY.svelte.d.ts +1 -1
- package/dist/marks/RuleX.svelte +14 -16
- package/dist/marks/RuleX.svelte.d.ts +84 -12
- package/dist/marks/RuleY.svelte +12 -15
- package/dist/marks/RuleY.svelte.d.ts +84 -12
- package/dist/marks/Sphere.svelte +6 -7
- package/dist/marks/Sphere.svelte.d.ts +3 -2
- package/dist/marks/Spike.svelte +17 -9
- package/dist/marks/Spike.svelte.d.ts +94 -4
- package/dist/marks/SymbolLegend.svelte +1 -1
- package/dist/marks/Text.svelte +36 -125
- package/dist/marks/Text.svelte.d.ts +101 -20
- package/dist/marks/TickX.svelte +12 -13
- package/dist/marks/TickX.svelte.d.ts +92 -20
- package/dist/marks/TickY.svelte +11 -14
- package/dist/marks/TickY.svelte.d.ts +92 -20
- package/dist/marks/Vector.svelte +19 -23
- package/dist/marks/Vector.svelte.d.ts +93 -21
- package/dist/marks/helpers/AreaCanvas.svelte +1 -1
- package/dist/marks/helpers/AreaCanvas.svelte.d.ts +1 -1
- package/dist/marks/helpers/BaseAxisX.svelte +1 -2
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -1
- package/dist/marks/helpers/BaseAxisY.svelte +2 -3
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -1
- package/dist/marks/helpers/CanvasLayer.svelte +1 -1
- package/dist/marks/helpers/DotCanvas.svelte +1 -1
- package/dist/marks/helpers/DotCanvas.svelte.d.ts +1 -1
- package/dist/marks/helpers/GeoCanvas.svelte +1 -1
- package/dist/marks/helpers/GeoCanvas.svelte.d.ts +1 -1
- package/dist/marks/helpers/LineCanvas.svelte +1 -1
- package/dist/marks/helpers/LineCanvas.svelte.d.ts +1 -1
- package/dist/marks/helpers/LinearGradientX.svelte +1 -1
- package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte +1 -1
- package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
- package/dist/marks/helpers/MarkerPath.svelte +1 -1
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
- package/dist/marks/helpers/MultilineText.svelte +158 -0
- package/dist/marks/helpers/MultilineText.svelte.d.ts +12 -0
- package/dist/marks/helpers/RectPath.svelte +29 -26
- package/dist/marks/helpers/RectPath.svelte.d.ts +39 -26
- package/dist/marks/helpers/Regression.svelte +7 -2
- package/dist/marks/helpers/Regression.svelte.d.ts +2 -5
- package/dist/transforms/bollinger.d.ts +1 -66
- package/dist/transforms/centroid.d.ts +7 -65
- package/dist/transforms/centroid.js +10 -7
- package/dist/transforms/group.d.ts +4 -12
- package/dist/transforms/interval.d.ts +2 -122
- package/dist/transforms/map.d.ts +4 -184
- package/dist/transforms/normalize.d.ts +3 -123
- package/dist/transforms/select.d.ts +7 -427
- package/dist/transforms/sort.d.ts +3 -242
- package/dist/transforms/window.d.ts +2 -130
- package/dist/types/channel.d.ts +11 -0
- package/dist/types/channel.js +1 -0
- package/dist/types/colorScheme.d.ts +1 -0
- package/dist/types/colorScheme.js +1 -0
- package/dist/types/data.d.ts +13 -0
- package/dist/types/data.js +1 -0
- package/dist/types/facet.d.ts +50 -0
- package/dist/types/facet.js +1 -0
- package/dist/types/index.d.ts +58 -0
- package/dist/types/index.js +7 -0
- package/dist/types/mark.d.ts +123 -0
- package/dist/types/mark.js +1 -0
- package/dist/types/plot.d.ts +459 -0
- package/dist/types/plot.js +1 -0
- package/dist/types/scale.d.ts +143 -0
- package/dist/types/scale.js +1 -0
- package/dist/types.d.ts +120 -127
- package/package.json +125 -120
|
@@ -1,28 +1,100 @@
|
|
|
1
|
-
import type { DataRecord, BaseMarkProps, ChannelAccessor } from '../types.js';
|
|
2
1
|
type D3Path = ReturnType<typeof import('d3-path').path>;
|
|
3
2
|
export type ShapeRenderer = {
|
|
4
3
|
draw(context: D3Path, l: number, r: number): void;
|
|
5
4
|
};
|
|
6
|
-
|
|
7
|
-
data: DataRecord[];
|
|
8
|
-
x: ChannelAccessor;
|
|
9
|
-
y: ChannelAccessor;
|
|
10
|
-
r?: number;
|
|
11
|
-
length?: ChannelAccessor;
|
|
12
|
-
rotate?: ChannelAccessor;
|
|
13
|
-
/**
|
|
14
|
-
* Controls where the vector is anchored in relation to the x, y position.
|
|
15
|
-
* If set to 'start', the arrow will start at the x, y position. If set to
|
|
16
|
-
* 'middle', the arrow will be centered at the x, y position. If set to
|
|
17
|
-
* 'end', the arrow will end at the x, y position.
|
|
18
|
-
*/
|
|
19
|
-
anchor: 'start' | 'middle' | 'end';
|
|
20
|
-
shape?: 'arrow' | 'spike' | 'arrow-filled' | ShapeRenderer;
|
|
21
|
-
children?: Snippet;
|
|
22
|
-
canvas?: boolean;
|
|
23
|
-
};
|
|
5
|
+
import type { DataRecord, ChannelAccessor } from '../types/index.js';
|
|
24
6
|
import { type Snippet } from 'svelte';
|
|
7
|
+
declare class __sveltets_Render<Datum extends DataRecord> {
|
|
8
|
+
props(): Partial<{
|
|
9
|
+
filter?: import("../types/index.js").ConstantAccessor<boolean, Datum>;
|
|
10
|
+
facet?: "auto" | "include" | "exclude";
|
|
11
|
+
fx: ChannelAccessor<Datum>;
|
|
12
|
+
fy: ChannelAccessor<Datum>;
|
|
13
|
+
dx: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
14
|
+
dy: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
15
|
+
fill: ChannelAccessor<Datum>;
|
|
16
|
+
fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
17
|
+
sort: {
|
|
18
|
+
channel: string;
|
|
19
|
+
order?: "ascending" | "descending";
|
|
20
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Datum>;
|
|
21
|
+
stroke: ChannelAccessor<Datum>;
|
|
22
|
+
strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
23
|
+
strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
24
|
+
strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
|
|
25
|
+
strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
|
|
26
|
+
strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
27
|
+
opacity: ChannelAccessor<Datum>;
|
|
28
|
+
strokeDasharray: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
29
|
+
strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
|
|
30
|
+
mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
|
|
31
|
+
clipPath: string;
|
|
32
|
+
imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
33
|
+
shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
|
|
34
|
+
paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
|
|
35
|
+
onclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
36
|
+
ondblclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
37
|
+
onmouseup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
38
|
+
onmousedown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
39
|
+
onmouseenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
40
|
+
onmousemove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
41
|
+
onmouseleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
42
|
+
onmouseout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
43
|
+
onmouseover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
44
|
+
onpointercancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
45
|
+
onpointerdown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
46
|
+
onpointerup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
47
|
+
onpointerenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
48
|
+
onpointerleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
49
|
+
onpointermove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
50
|
+
onpointerover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
51
|
+
onpointerout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
52
|
+
ondrag?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
53
|
+
ondrop?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
54
|
+
ondragstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
55
|
+
ondragenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
56
|
+
ondragleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
57
|
+
ondragover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
58
|
+
ondragend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
59
|
+
ontouchstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
60
|
+
ontouchmove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
61
|
+
ontouchend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
62
|
+
ontouchcancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
63
|
+
oncontextmenu?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
64
|
+
onwheel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
|
|
65
|
+
class: string | null;
|
|
66
|
+
cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
|
|
67
|
+
}> & {
|
|
68
|
+
data: Datum[];
|
|
69
|
+
x: ChannelAccessor<Datum>;
|
|
70
|
+
y: ChannelAccessor<Datum>;
|
|
71
|
+
r?: number;
|
|
72
|
+
length?: ChannelAccessor<Datum>;
|
|
73
|
+
rotate?: ChannelAccessor<Datum>;
|
|
74
|
+
/**
|
|
75
|
+
* Controls where the vector is anchored in relation to the x, y position.
|
|
76
|
+
* If set to 'start', the arrow will start at the x, y position. If set to
|
|
77
|
+
* 'middle', the arrow will be centered at the x, y position. If set to
|
|
78
|
+
* 'end', the arrow will end at the x, y position.
|
|
79
|
+
*/
|
|
80
|
+
anchor?: "start" | "middle" | "end";
|
|
81
|
+
shape?: "arrow" | "spike" | "arrow-filled" | ShapeRenderer;
|
|
82
|
+
children?: Snippet;
|
|
83
|
+
canvas?: boolean;
|
|
84
|
+
};
|
|
85
|
+
events(): {};
|
|
86
|
+
slots(): {};
|
|
87
|
+
bindings(): "";
|
|
88
|
+
exports(): {};
|
|
89
|
+
}
|
|
90
|
+
interface $$IsomorphicComponent {
|
|
91
|
+
new <Datum extends DataRecord>(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']>> & {
|
|
92
|
+
$$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
|
|
93
|
+
} & ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
94
|
+
<Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
|
|
95
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
96
|
+
}
|
|
25
97
|
/** The vector mark lets you place shapes (like arrows) on your plot. */
|
|
26
|
-
declare const Vector:
|
|
27
|
-
type Vector =
|
|
98
|
+
declare const Vector: $$IsomorphicComponent;
|
|
99
|
+
type Vector<Datum extends DataRecord> = InstanceType<typeof Vector<Datum>>;
|
|
28
100
|
export default Vector;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
PlotContext,
|
|
6
6
|
ScaledDataRecord,
|
|
7
7
|
UsedScales
|
|
8
|
-
} from '../../types.js';
|
|
8
|
+
} from '../../types/index.js';
|
|
9
9
|
import { resolveProp, resolveScaledStyleProps } from '../../helpers/resolve.js';
|
|
10
10
|
import { getContext } from 'svelte';
|
|
11
11
|
import { type Area } from 'd3-shape';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types.js';
|
|
1
|
+
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types/index.js';
|
|
2
2
|
import { type Area } from 'd3-shape';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
mark: Mark<BaseMarkProps>;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
PlotState,
|
|
11
11
|
RawValue,
|
|
12
12
|
ScaleType
|
|
13
|
-
} from '../../types.js';
|
|
13
|
+
} from '../../types/index.js';
|
|
14
14
|
import { resolveProp, resolveStyles } from '../../helpers/resolve.js';
|
|
15
15
|
import { max } from 'd3-array';
|
|
16
16
|
import { randomId, testFilter } from '../../helpers/index.js';
|
|
@@ -223,7 +223,6 @@
|
|
|
223
223
|
stroke: currentColor;
|
|
224
224
|
}
|
|
225
225
|
text {
|
|
226
|
-
font-size: 11px;
|
|
227
226
|
opacity: 0.8;
|
|
228
227
|
fill: currentColor;
|
|
229
228
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChannelAccessor, ConstantAccessor, PlotState, RawValue, ScaleType } from '../../types.js';
|
|
1
|
+
import type { ChannelAccessor, ConstantAccessor, PlotState, RawValue, ScaleType } from '../../types/index.js';
|
|
2
2
|
type BaseAxisXProps = {
|
|
3
3
|
scaleFn: (d: RawValue) => number;
|
|
4
4
|
scaleType: ScaleType;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
PlotState,
|
|
10
10
|
RawValue,
|
|
11
11
|
ScaleType
|
|
12
|
-
} from '../../types.js';
|
|
12
|
+
} from '../../types/index.js';
|
|
13
13
|
|
|
14
14
|
type BaseAxisYProps = {
|
|
15
15
|
scaleFn: (d: RawValue) => number;
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
untrack(() => [$autoMarginTop]);
|
|
130
130
|
if (title) {
|
|
131
131
|
// add margin top to make some space for title
|
|
132
|
-
$autoMarginTop.set(id,
|
|
132
|
+
$autoMarginTop.set(id, 27);
|
|
133
133
|
} else {
|
|
134
134
|
// no need for extra margin top
|
|
135
135
|
$autoMarginTop.delete(id);
|
|
@@ -199,7 +199,6 @@
|
|
|
199
199
|
stroke: currentColor;
|
|
200
200
|
}
|
|
201
201
|
text {
|
|
202
|
-
font-size: 11px;
|
|
203
202
|
opacity: 0.8;
|
|
204
203
|
fill: currentColor;
|
|
205
204
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
|
-
import type { PlotContext } from '
|
|
3
|
+
import type { PlotContext } from '../..';
|
|
4
4
|
import { devicePixelRatio } from 'svelte/reactivity/window';
|
|
5
5
|
import { MediaQuery } from 'svelte/reactivity';
|
|
6
6
|
import type { Attachment } from 'svelte/attachments';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
BaseMarkProps,
|
|
6
6
|
ScaledDataRecord,
|
|
7
7
|
PlotContext
|
|
8
|
-
} from '../../types.js';
|
|
8
|
+
} from '../../types/index.js';
|
|
9
9
|
import { resolveProp } from '../../helpers/resolve.js';
|
|
10
10
|
import { maybeSymbol } from '../../helpers/symbols.js';
|
|
11
11
|
import { symbol as d3Symbol } from 'd3-shape';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
PlotContext,
|
|
6
6
|
ScaledDataRecord,
|
|
7
7
|
UsedScales
|
|
8
|
-
} from '../../types.js';
|
|
8
|
+
} from '../../types/index.js';
|
|
9
9
|
import { CSS_VAR } from '../../constants.js';
|
|
10
10
|
import { resolveProp, resolveScaledStyleProps } from '../../helpers/resolve.js';
|
|
11
11
|
import { getContext } from 'svelte';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types.js';
|
|
1
|
+
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types/index.js';
|
|
2
2
|
import { type GeoPath } from 'd3-geo';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
mark: Mark<BaseMarkProps>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
PlotContext,
|
|
6
6
|
ScaledDataRecord,
|
|
7
7
|
UsedScales
|
|
8
|
-
} from '../../types.js';
|
|
8
|
+
} from '../../types/index.js';
|
|
9
9
|
import { resolveProp, resolveScaledStyleProps } from '../../helpers/resolve.js';
|
|
10
10
|
import { getContext } from 'svelte';
|
|
11
11
|
import { type Line } from 'd3-shape';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types.js';
|
|
1
|
+
import type { Mark, BaseMarkProps, ScaledDataRecord, UsedScales } from '../../types/index.js';
|
|
2
2
|
import { type Line } from 'd3-shape';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
mark: Mark<BaseMarkProps>;
|
|
@@ -1,44 +1,4 @@
|
|
|
1
|
-
import { type MarkerShape } from './Marker.svelte';
|
|
2
|
-
import type { BaseMarkProps, ConstantAccessor, DataRecord, Mark, PlotScales } from '../../types.js';
|
|
3
|
-
type MarkerPathProps = BaseMarkProps & {
|
|
4
|
-
/**
|
|
5
|
-
* the datum associated with this path, usually the first
|
|
6
|
-
* element of the data array group
|
|
7
|
-
*/
|
|
8
|
-
datum: DataRecord;
|
|
9
|
-
/**
|
|
10
|
-
* the marker shape to use at the start of the path, defaults to
|
|
11
|
-
* circle
|
|
12
|
-
*/
|
|
13
|
-
markerStart?: boolean | MarkerShape;
|
|
14
|
-
/**
|
|
15
|
-
* the marker shape to use at the middle of the path, defaults to circle
|
|
16
|
-
*/
|
|
17
|
-
markerMid?: boolean | MarkerShape;
|
|
18
|
-
/**
|
|
19
|
-
* the marker shape to use at the end of the path, defaults to circle
|
|
20
|
-
*/
|
|
21
|
-
markerEnd?: boolean | MarkerShape;
|
|
22
|
-
/**
|
|
23
|
-
* shorthand for setting all markers
|
|
24
|
-
*/
|
|
25
|
-
marker?: boolean | MarkerShape;
|
|
26
|
-
/**
|
|
27
|
-
* path string
|
|
28
|
-
*/
|
|
29
|
-
d: string;
|
|
30
|
-
style: string;
|
|
31
|
-
startOffset: string;
|
|
32
|
-
textStyle: string;
|
|
33
|
-
textStyleClass?: string | null;
|
|
34
|
-
text: string;
|
|
35
|
-
transform: string;
|
|
36
|
-
color: string;
|
|
37
|
-
strokeWidth: ConstantAccessor<number>;
|
|
38
|
-
mark: Mark<BaseMarkProps>;
|
|
39
|
-
scales: PlotScales;
|
|
40
|
-
};
|
|
41
1
|
/** Helper component for paths with markers and optional text along the path. */
|
|
42
|
-
declare const MarkerPath: import("svelte").Component<
|
|
2
|
+
declare const MarkerPath: import("svelte").Component<any, {}, "">;
|
|
43
3
|
type MarkerPath = ReturnType<typeof MarkerPath>;
|
|
44
4
|
export default MarkerPath;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { resolveProp, resolveStyles } from '../../helpers/resolve';
|
|
3
|
+
import { getContext, type ComponentProps } from 'svelte';
|
|
4
|
+
import type { PlotContext, ScaledDataRecord, UsedScales } from '../..';
|
|
5
|
+
import type Text from '../Text.svelte';
|
|
6
|
+
import { CSS_VAR } from '../../constants';
|
|
7
|
+
import { maybeFromPixel, maybeFromRem } from '../../helpers/getBaseStyles';
|
|
8
|
+
|
|
9
|
+
const LINE_ANCHOR = {
|
|
10
|
+
bottom: 'auto',
|
|
11
|
+
middle: 'central',
|
|
12
|
+
top: 'hanging'
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
16
|
+
const plot = $derived(getPlotState());
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
textLines,
|
|
20
|
+
d,
|
|
21
|
+
args,
|
|
22
|
+
usedScales
|
|
23
|
+
}: {
|
|
24
|
+
textLines: string[];
|
|
25
|
+
d: ScaledDataRecord;
|
|
26
|
+
args: ComponentProps<typeof Text>;
|
|
27
|
+
usedScales: UsedScales;
|
|
28
|
+
} = $props();
|
|
29
|
+
|
|
30
|
+
const title = $derived(resolveProp(args.title, d.datum, ''));
|
|
31
|
+
const frameAnchor = $derived(resolveProp(args.frameAnchor, d.datum));
|
|
32
|
+
const isLeft = $derived(
|
|
33
|
+
frameAnchor === 'left' || frameAnchor === 'top-left' || frameAnchor === 'bottom-left'
|
|
34
|
+
);
|
|
35
|
+
const isRight = $derived(
|
|
36
|
+
frameAnchor === 'right' || frameAnchor === 'top-right' || frameAnchor === 'bottom-right'
|
|
37
|
+
);
|
|
38
|
+
const isTop = $derived(
|
|
39
|
+
frameAnchor === 'top' || frameAnchor === 'top-left' || frameAnchor === 'top-right'
|
|
40
|
+
);
|
|
41
|
+
const isBottom = $derived(
|
|
42
|
+
frameAnchor === 'bottom' || frameAnchor === 'bottom-left' || frameAnchor === 'bottom-right'
|
|
43
|
+
);
|
|
44
|
+
const lineAnchor = $derived(
|
|
45
|
+
resolveProp(
|
|
46
|
+
args.lineAnchor,
|
|
47
|
+
d.datum,
|
|
48
|
+
args.y != null ? 'middle' : isTop ? 'top' : isBottom ? 'bottom' : 'middle'
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
const textClassName = $derived(resolveProp(args.textClass, d.datum, null));
|
|
52
|
+
const [x, y] = $derived(
|
|
53
|
+
args.x != null && args.y != null
|
|
54
|
+
? [d.x, d.y]
|
|
55
|
+
: [
|
|
56
|
+
args.x != null
|
|
57
|
+
? d.x
|
|
58
|
+
: isLeft
|
|
59
|
+
? plot.options.marginLeft
|
|
60
|
+
: isRight
|
|
61
|
+
? plot.options.marginLeft + plot.facetWidth
|
|
62
|
+
: plot.options.marginLeft + plot.facetWidth * 0.5,
|
|
63
|
+
args.y != null
|
|
64
|
+
? d.y
|
|
65
|
+
: isTop
|
|
66
|
+
? plot.options.marginTop
|
|
67
|
+
: isBottom
|
|
68
|
+
? plot.options.marginTop + plot.facetHeight
|
|
69
|
+
: plot.options.marginTop + plot.facetHeight * 0.5
|
|
70
|
+
]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const dx = $derived(+resolveProp(args.dx, d.datum, 0));
|
|
74
|
+
const dy = $derived(+resolveProp(args.dy, d.datum, 0));
|
|
75
|
+
|
|
76
|
+
const [style, styleClass] = $derived(
|
|
77
|
+
resolveStyles(
|
|
78
|
+
plot,
|
|
79
|
+
{ ...d, __tspanIndex: 0 },
|
|
80
|
+
{
|
|
81
|
+
fontSize: 12,
|
|
82
|
+
fontWeight: 500,
|
|
83
|
+
strokeWidth: 1.6,
|
|
84
|
+
textAnchor: isLeft ? 'start' : isRight ? 'end' : 'middle',
|
|
85
|
+
...args
|
|
86
|
+
},
|
|
87
|
+
'fill',
|
|
88
|
+
usedScales
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const fontSize = $derived(
|
|
93
|
+
textLines.length > 1 ? (resolveProp(args.fontSize, d.datum) ?? 12) : 0
|
|
94
|
+
);
|
|
95
|
+
let textElement: SVGTextElement | null = $state(null);
|
|
96
|
+
|
|
97
|
+
const rootFontSize = $derived(
|
|
98
|
+
textElement?.ownerDocument?.documentElement && textLines.length > 1
|
|
99
|
+
? maybeFromPixel(getComputedStyle(textElement.ownerDocument.documentElement).fontSize)
|
|
100
|
+
: 14
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const computedFontSize = $derived(
|
|
104
|
+
textElement && textLines.length > 1 && CSS_VAR.test(fontSize)
|
|
105
|
+
? maybeFromRem(
|
|
106
|
+
maybeFromPixel(
|
|
107
|
+
getComputedStyle(textElement).getPropertyValue(
|
|
108
|
+
`--${fontSize.match(CSS_VAR)[1]}`
|
|
109
|
+
)
|
|
110
|
+
),
|
|
111
|
+
rootFontSize
|
|
112
|
+
)
|
|
113
|
+
: fontSize
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const lineHeight = $derived(
|
|
117
|
+
textLines.length > 1 ? (resolveProp(args.lineHeight, d.datum) ?? 1.2) : 0
|
|
118
|
+
);
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
{#if textLines.length > 1}
|
|
122
|
+
<!-- multiline text-->
|
|
123
|
+
<text
|
|
124
|
+
bind:this={textElement}
|
|
125
|
+
class={[textClassName]}
|
|
126
|
+
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
127
|
+
transform="translate({Math.round(x + dx)},{Math.round(
|
|
128
|
+
y +
|
|
129
|
+
dy -
|
|
130
|
+
(lineAnchor === 'bottom'
|
|
131
|
+
? textLines.length - 1
|
|
132
|
+
: lineAnchor === 'middle'
|
|
133
|
+
? (textLines.length - 1) * 0.5
|
|
134
|
+
: 0) *
|
|
135
|
+
computedFontSize *
|
|
136
|
+
lineHeight
|
|
137
|
+
)})"
|
|
138
|
+
>{#each textLines as line, l (l)}<tspan
|
|
139
|
+
x="0"
|
|
140
|
+
dy={l ? computedFontSize * lineHeight : 0}
|
|
141
|
+
class={styleClass}
|
|
142
|
+
{style}>{line}</tspan
|
|
143
|
+
>{/each}{#if title}<title>{title}</title>{/if}</text>
|
|
144
|
+
{:else}
|
|
145
|
+
<!-- singleline text-->
|
|
146
|
+
<text
|
|
147
|
+
class={[textClassName, styleClass]}
|
|
148
|
+
dominant-baseline={LINE_ANCHOR[lineAnchor]}
|
|
149
|
+
transform="translate({Math.round(x + dx)},{Math.round(y + dy)})"
|
|
150
|
+
{style}
|
|
151
|
+
>{textLines[0]}{#if title}<title>{title}</title>{/if}</text>
|
|
152
|
+
{/if}
|
|
153
|
+
|
|
154
|
+
<style>
|
|
155
|
+
text {
|
|
156
|
+
paint-order: stroke fill;
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ComponentProps } from 'svelte';
|
|
2
|
+
import type { ScaledDataRecord, UsedScales } from '../..';
|
|
3
|
+
import type Text from '../Text.svelte';
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
textLines: string[];
|
|
6
|
+
d: ScaledDataRecord;
|
|
7
|
+
args: ComponentProps<typeof Text>;
|
|
8
|
+
usedScales: UsedScales;
|
|
9
|
+
};
|
|
10
|
+
declare const MultilineText: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
+
type MultilineText = ReturnType<typeof MultilineText>;
|
|
12
|
+
export default MultilineText;
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
<!-- @component
|
|
2
2
|
Helper component for rendering rectangular marks in SVG
|
|
3
3
|
-->
|
|
4
|
-
<script lang="ts">
|
|
4
|
+
<script lang="ts" generics="Datum extends DataRecord">
|
|
5
|
+
interface RectPathProps {
|
|
6
|
+
datum: ScaledDataRecord<Datum>;
|
|
7
|
+
class: string | null;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
options: BaseRectMarkProps<Datum> & BaseMarkProps<Datum>;
|
|
13
|
+
/**
|
|
14
|
+
* By default, the `inset` property is applied to all four insets. Mark components
|
|
15
|
+
* can tweak this behavior for insetTop and insetBottom by setting the
|
|
16
|
+
* useInsetAsFallbackVertically prop to false.
|
|
17
|
+
*/
|
|
18
|
+
useInsetAsFallbackVertically?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* By default, the `inset` property is applied to all four insets. Mark components
|
|
21
|
+
* can tweak this behavior for insetLeft and insetRight by setting the
|
|
22
|
+
* useInsetAsFallbackHorizontally prop to false.
|
|
23
|
+
*/
|
|
24
|
+
useInsetAsFallbackHorizontally?: boolean;
|
|
25
|
+
usedScales: UsedScales;
|
|
26
|
+
fallbackStyle?: 'fill' | 'stroke';
|
|
27
|
+
}
|
|
28
|
+
|
|
5
29
|
import { resolveProp, resolveStyles } from '../../helpers/resolve';
|
|
6
30
|
import { roundedRect } from '../../helpers/roundedRect';
|
|
7
31
|
import type {
|
|
@@ -10,8 +34,9 @@ Helper component for rendering rectangular marks in SVG
|
|
|
10
34
|
BorderRadius,
|
|
11
35
|
ScaledDataRecord,
|
|
12
36
|
UsedScales,
|
|
13
|
-
PlotContext
|
|
14
|
-
|
|
37
|
+
PlotContext,
|
|
38
|
+
DataRecord
|
|
39
|
+
} from '../..';
|
|
15
40
|
import { addEventHandlers } from './events';
|
|
16
41
|
import { getContext } from 'svelte';
|
|
17
42
|
import Anchor from './Anchor.svelte';
|
|
@@ -28,29 +53,7 @@ Helper component for rendering rectangular marks in SVG
|
|
|
28
53
|
useInsetAsFallbackHorizontally = true,
|
|
29
54
|
usedScales,
|
|
30
55
|
fallbackStyle = 'fill'
|
|
31
|
-
}:
|
|
32
|
-
datum: ScaledDataRecord;
|
|
33
|
-
class: string | null;
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
options: BaseRectMarkProps & BaseMarkProps;
|
|
39
|
-
/**
|
|
40
|
-
* By default, the `inset` property is applied to all four insets. Mark components
|
|
41
|
-
* can tweak this behavior for insetTop and insetBottom by setting the
|
|
42
|
-
* useInsetAsFallbackVertically prop to false.
|
|
43
|
-
*/
|
|
44
|
-
useInsetAsFallbackVertically?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* By default, the `inset` property is applied to all four insets. Mark components
|
|
47
|
-
* can tweak this behavior for insetLeft and insetRight by setting the
|
|
48
|
-
* useInsetAsFallbackHorizontally prop to false.
|
|
49
|
-
*/
|
|
50
|
-
useInsetAsFallbackHorizontally?: boolean;
|
|
51
|
-
usedScales: UsedScales;
|
|
52
|
-
fallbackStyle?: 'fill' | 'stroke';
|
|
53
|
-
} = $props();
|
|
56
|
+
}: RectPathProps = $props();
|
|
54
57
|
|
|
55
58
|
const { getPlotState } = getContext<PlotContext>('svelteplot');
|
|
56
59
|
const plot = $derived(getPlotState());
|