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.
Files changed (172) hide show
  1. package/dist/Mark.svelte +25 -27
  2. package/dist/Mark.svelte.d.ts +87 -17
  3. package/dist/Plot.svelte +1 -2
  4. package/dist/Plot.svelte.d.ts +1 -1
  5. package/dist/core/Facet.svelte +1 -1
  6. package/dist/core/Facet.svelte.d.ts +1 -1
  7. package/dist/core/FacetAxes.svelte +1 -1
  8. package/dist/core/FacetGrid.svelte +1 -1
  9. package/dist/core/FacetGrid.svelte.d.ts +1 -1
  10. package/dist/core/Plot.svelte +1 -1
  11. package/dist/core/Plot.svelte.d.ts +1 -1
  12. package/dist/helpers/autoTicks.js +1 -1
  13. package/dist/helpers/colors.d.ts +1 -1
  14. package/dist/helpers/getBaseStyles.d.ts +2 -0
  15. package/dist/helpers/getBaseStyles.js +8 -0
  16. package/dist/helpers/index.d.ts +2 -2
  17. package/dist/helpers/projection.d.ts +1 -1
  18. package/dist/helpers/resolve.d.ts +1 -1
  19. package/dist/helpers/scales.d.ts +1 -1
  20. package/dist/helpers/typeChecks.d.ts +4 -4
  21. package/dist/marks/Area.svelte +14 -17
  22. package/dist/marks/Area.svelte.d.ts +91 -19
  23. package/dist/marks/AreaX.svelte +15 -12
  24. package/dist/marks/AreaX.svelte.d.ts +94 -3
  25. package/dist/marks/AreaY.svelte +15 -15
  26. package/dist/marks/AreaY.svelte.d.ts +94 -3
  27. package/dist/marks/Arrow.svelte +16 -19
  28. package/dist/marks/Arrow.svelte.d.ts +110 -38
  29. package/dist/marks/AxisX.svelte +41 -41
  30. package/dist/marks/AxisX.svelte.d.ts +97 -25
  31. package/dist/marks/AxisY.svelte +40 -40
  32. package/dist/marks/AxisY.svelte.d.ts +98 -27
  33. package/dist/marks/BarX.svelte +28 -30
  34. package/dist/marks/BarX.svelte.d.ts +89 -17
  35. package/dist/marks/BarY.svelte +27 -27
  36. package/dist/marks/BarY.svelte.d.ts +88 -16
  37. package/dist/marks/BollingerX.svelte +21 -16
  38. package/dist/marks/BollingerX.svelte.d.ts +17 -16
  39. package/dist/marks/BollingerY.svelte +21 -16
  40. package/dist/marks/BollingerY.svelte.d.ts +17 -16
  41. package/dist/marks/BoxX.svelte +5 -7
  42. package/dist/marks/BoxX.svelte.d.ts +5 -3
  43. package/dist/marks/BoxY.svelte +13 -16
  44. package/dist/marks/BoxY.svelte.d.ts +41 -28
  45. package/dist/marks/Brush.svelte +27 -30
  46. package/dist/marks/Brush.svelte.d.ts +20 -15
  47. package/dist/marks/BrushX.svelte +9 -7
  48. package/dist/marks/BrushX.svelte.d.ts +5 -2
  49. package/dist/marks/BrushY.svelte +9 -7
  50. package/dist/marks/BrushY.svelte.d.ts +5 -2
  51. package/dist/marks/Cell.svelte +17 -18
  52. package/dist/marks/Cell.svelte.d.ts +80 -8
  53. package/dist/marks/CellX.svelte +12 -8
  54. package/dist/marks/CellX.svelte.d.ts +5 -2
  55. package/dist/marks/CellY.svelte +12 -8
  56. package/dist/marks/CellY.svelte.d.ts +5 -2
  57. package/dist/marks/ColorLegend.svelte +5 -8
  58. package/dist/marks/ColorLegend.svelte.d.ts +2 -2
  59. package/dist/marks/CustomMark.svelte +23 -16
  60. package/dist/marks/CustomMark.svelte.d.ts +17 -14
  61. package/dist/marks/CustomMarkHTML.svelte +20 -18
  62. package/dist/marks/CustomMarkHTML.svelte.d.ts +29 -15
  63. package/dist/marks/DifferenceY.svelte +54 -18
  64. package/dist/marks/DifferenceY.svelte.d.ts +59 -28
  65. package/dist/marks/Dot.svelte +13 -14
  66. package/dist/marks/Dot.svelte.d.ts +84 -12
  67. package/dist/marks/DotX.svelte +9 -9
  68. package/dist/marks/DotX.svelte.d.ts +86 -4
  69. package/dist/marks/DotY.svelte +10 -9
  70. package/dist/marks/DotY.svelte.d.ts +87 -5
  71. package/dist/marks/Frame.svelte +20 -27
  72. package/dist/marks/Frame.svelte.d.ts +24 -10
  73. package/dist/marks/Geo.svelte +22 -15
  74. package/dist/marks/Geo.svelte.d.ts +97 -13
  75. package/dist/marks/Graticule.svelte +16 -19
  76. package/dist/marks/Graticule.svelte.d.ts +3 -3
  77. package/dist/marks/GridX.svelte +5 -8
  78. package/dist/marks/GridX.svelte.d.ts +79 -7
  79. package/dist/marks/GridY.svelte +5 -8
  80. package/dist/marks/GridY.svelte.d.ts +79 -7
  81. package/dist/marks/HTMLTooltip.svelte +9 -14
  82. package/dist/marks/HTMLTooltip.svelte.d.ts +25 -12
  83. package/dist/marks/Line.svelte +24 -29
  84. package/dist/marks/Line.svelte.d.ts +97 -25
  85. package/dist/marks/LineX.svelte +9 -4
  86. package/dist/marks/LineX.svelte.d.ts +99 -3
  87. package/dist/marks/LineY.svelte +11 -5
  88. package/dist/marks/LineY.svelte.d.ts +100 -4
  89. package/dist/marks/Link.svelte +35 -19
  90. package/dist/marks/Link.svelte.d.ts +107 -18
  91. package/dist/marks/Pointer.svelte +13 -18
  92. package/dist/marks/Pointer.svelte.d.ts +34 -21
  93. package/dist/marks/Rect.svelte +19 -19
  94. package/dist/marks/Rect.svelte.d.ts +86 -13
  95. package/dist/marks/RectX.svelte +10 -9
  96. package/dist/marks/RectX.svelte.d.ts +22 -6
  97. package/dist/marks/RectY.svelte +9 -10
  98. package/dist/marks/RectY.svelte.d.ts +22 -6
  99. package/dist/marks/RegressionX.svelte +1 -1
  100. package/dist/marks/RegressionX.svelte.d.ts +1 -1
  101. package/dist/marks/RegressionY.svelte +1 -1
  102. package/dist/marks/RegressionY.svelte.d.ts +1 -1
  103. package/dist/marks/RuleX.svelte +14 -16
  104. package/dist/marks/RuleX.svelte.d.ts +84 -12
  105. package/dist/marks/RuleY.svelte +12 -15
  106. package/dist/marks/RuleY.svelte.d.ts +84 -12
  107. package/dist/marks/Sphere.svelte +6 -7
  108. package/dist/marks/Sphere.svelte.d.ts +3 -2
  109. package/dist/marks/Spike.svelte +17 -9
  110. package/dist/marks/Spike.svelte.d.ts +94 -4
  111. package/dist/marks/SymbolLegend.svelte +1 -1
  112. package/dist/marks/Text.svelte +36 -125
  113. package/dist/marks/Text.svelte.d.ts +101 -20
  114. package/dist/marks/TickX.svelte +12 -13
  115. package/dist/marks/TickX.svelte.d.ts +92 -20
  116. package/dist/marks/TickY.svelte +11 -14
  117. package/dist/marks/TickY.svelte.d.ts +92 -20
  118. package/dist/marks/Vector.svelte +19 -23
  119. package/dist/marks/Vector.svelte.d.ts +93 -21
  120. package/dist/marks/helpers/AreaCanvas.svelte +1 -1
  121. package/dist/marks/helpers/AreaCanvas.svelte.d.ts +1 -1
  122. package/dist/marks/helpers/BaseAxisX.svelte +1 -2
  123. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -1
  124. package/dist/marks/helpers/BaseAxisY.svelte +2 -3
  125. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -1
  126. package/dist/marks/helpers/CanvasLayer.svelte +1 -1
  127. package/dist/marks/helpers/DotCanvas.svelte +1 -1
  128. package/dist/marks/helpers/DotCanvas.svelte.d.ts +1 -1
  129. package/dist/marks/helpers/GeoCanvas.svelte +1 -1
  130. package/dist/marks/helpers/GeoCanvas.svelte.d.ts +1 -1
  131. package/dist/marks/helpers/LineCanvas.svelte +1 -1
  132. package/dist/marks/helpers/LineCanvas.svelte.d.ts +1 -1
  133. package/dist/marks/helpers/LinearGradientX.svelte +1 -1
  134. package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
  135. package/dist/marks/helpers/LinearGradientY.svelte +1 -1
  136. package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
  137. package/dist/marks/helpers/MarkerPath.svelte +1 -1
  138. package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
  139. package/dist/marks/helpers/MultilineText.svelte +158 -0
  140. package/dist/marks/helpers/MultilineText.svelte.d.ts +12 -0
  141. package/dist/marks/helpers/RectPath.svelte +29 -26
  142. package/dist/marks/helpers/RectPath.svelte.d.ts +39 -26
  143. package/dist/marks/helpers/Regression.svelte +7 -2
  144. package/dist/marks/helpers/Regression.svelte.d.ts +2 -5
  145. package/dist/transforms/bollinger.d.ts +1 -66
  146. package/dist/transforms/centroid.d.ts +7 -65
  147. package/dist/transforms/centroid.js +10 -7
  148. package/dist/transforms/group.d.ts +4 -12
  149. package/dist/transforms/interval.d.ts +2 -122
  150. package/dist/transforms/map.d.ts +4 -184
  151. package/dist/transforms/normalize.d.ts +3 -123
  152. package/dist/transforms/select.d.ts +7 -427
  153. package/dist/transforms/sort.d.ts +3 -242
  154. package/dist/transforms/window.d.ts +2 -130
  155. package/dist/types/channel.d.ts +11 -0
  156. package/dist/types/channel.js +1 -0
  157. package/dist/types/colorScheme.d.ts +1 -0
  158. package/dist/types/colorScheme.js +1 -0
  159. package/dist/types/data.d.ts +13 -0
  160. package/dist/types/data.js +1 -0
  161. package/dist/types/facet.d.ts +50 -0
  162. package/dist/types/facet.js +1 -0
  163. package/dist/types/index.d.ts +58 -0
  164. package/dist/types/index.js +7 -0
  165. package/dist/types/mark.d.ts +123 -0
  166. package/dist/types/mark.js +1 -0
  167. package/dist/types/plot.d.ts +459 -0
  168. package/dist/types/plot.js +1 -0
  169. package/dist/types/scale.d.ts +143 -0
  170. package/dist/types/scale.js +1 -0
  171. package/dist/types.d.ts +120 -127
  172. package/package.json +125 -120
@@ -1,11 +1,13 @@
1
- <script module lang="ts">
2
- export type BrushYMarkProps = Omit<BrushMarkProps, 'limitDimension'>;
3
- </script>
4
-
1
+ <!--
2
+ @component
3
+ For creating a brush that can be dragged vertically
4
+ -->
5
5
  <script lang="ts">
6
- import Brush, { type BrushMarkProps } from './Brush.svelte';
7
- import type { PlotDefaults } from '../types.js';
8
- import { getContext } from 'svelte';
6
+ import Brush from './Brush.svelte';
7
+ import type { PlotDefaults } from '../types/index.js';
8
+ import { getContext, type ComponentProps } from 'svelte';
9
+
10
+ interface BrushYMarkProps extends Omit<ComponentProps<typeof Brush>, 'limitDimension'> {}
9
11
 
10
12
  let { brush = $bindable({ enabled: false }), ...options }: BrushYMarkProps = $props();
11
13
  const DEFAULTS = {
@@ -1,5 +1,8 @@
1
- export type BrushYMarkProps = Omit<BrushMarkProps, 'limitDimension'>;
2
- import { type BrushMarkProps } from './Brush.svelte';
1
+ import Brush from './Brush.svelte';
2
+ import { type ComponentProps } from 'svelte';
3
+ interface BrushYMarkProps extends Omit<ComponentProps<typeof Brush>, 'limitDimension'> {
4
+ }
5
+ /** For creating a brush that can be dragged vertically */
3
6
  declare const BrushY: import("svelte").Component<BrushYMarkProps, {}, "brush">;
4
7
  type BrushY = ReturnType<typeof BrushY>;
5
8
  export default BrushY;
@@ -2,29 +2,28 @@
2
2
  @component
3
3
  For arbitrary rectangles, requires band x and y scales
4
4
  -->
5
- <script module lang="ts">
5
+ <script lang="ts" generics="Datum extends DataRecord">
6
+ interface CellMarkProps
7
+ extends BaseMarkProps<Datum>,
8
+ LinkableMarkProps<Datum>,
9
+ BaseRectMarkProps<Datum> {
10
+ data: Datum[];
11
+ x?: ChannelAccessor<Datum>;
12
+ y?: ChannelAccessor<Datum>;
13
+ }
6
14
  import type {
7
15
  PlotContext,
8
16
  DataRecord,
9
17
  BaseMarkProps,
10
18
  BaseRectMarkProps,
11
19
  ChannelAccessor,
12
- PlotDefaults
13
- } from '../types.js';
14
-
15
- export type CellMarkProps = BaseMarkProps &
16
- LinkableMarkProps &
17
- BaseRectMarkProps & {
18
- data: DataRecord[];
19
- x?: ChannelAccessor;
20
- y?: ChannelAccessor;
21
- };
22
- </script>
23
-
24
- <script lang="ts">
20
+ PlotDefaults,
21
+ LinkableMarkProps,
22
+ MarkType
23
+ } from '../types/index.js';
25
24
  import Mark from '../Mark.svelte';
26
25
  import { getContext } from 'svelte';
27
- import { recordizeY, sort } from '../index.js';
26
+ import { recordizeY, sort } from '..';
28
27
  import { resolveChannel } from '../helpers/resolve.js';
29
28
 
30
29
  import { isValid } from '../helpers/isValid.js';
@@ -37,7 +36,7 @@
37
36
  };
38
37
 
39
38
  const {
40
- data = [{}],
39
+ data = [{} as Datum],
41
40
  class: className = '',
42
41
  ...options
43
42
  }: CellMarkProps = $derived({
@@ -59,8 +58,8 @@
59
58
  sort: { channel: 'x' }
60
59
  }),
61
60
  sort: { channel: 'y' }
62
- }) as Props)
63
- );
61
+ }) as CellMarkProps)
62
+ ) as CellMarkProps;
64
63
  </script>
65
64
 
66
65
  <Mark
@@ -1,10 +1,82 @@
1
- import type { DataRecord, BaseMarkProps, BaseRectMarkProps, ChannelAccessor } from '../types.js';
2
- export type CellMarkProps = BaseMarkProps & LinkableMarkProps & BaseRectMarkProps & {
3
- data: DataRecord[];
4
- x?: ChannelAccessor;
5
- y?: ChannelAccessor;
6
- };
1
+ import type { DataRecord, BaseRectMarkProps, ChannelAccessor, LinkableMarkProps } from '../types/index.js';
2
+ declare class __sveltets_Render<Datum extends DataRecord> {
3
+ props(): Partial<{
4
+ filter?: import("../types/index.js").ConstantAccessor<boolean, Datum>;
5
+ facet?: "auto" | "include" | "exclude";
6
+ fx: ChannelAccessor<Datum>;
7
+ fy: ChannelAccessor<Datum>;
8
+ dx: import("../types/index.js").ConstantAccessor<number, Datum>;
9
+ dy: import("../types/index.js").ConstantAccessor<number, Datum>;
10
+ fill: ChannelAccessor<Datum>;
11
+ fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
12
+ sort: {
13
+ channel: string;
14
+ order?: "ascending" | "descending";
15
+ } | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Datum>;
16
+ stroke: ChannelAccessor<Datum>;
17
+ strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
18
+ strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
19
+ strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
20
+ strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
21
+ strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Datum>;
22
+ opacity: ChannelAccessor<Datum>;
23
+ strokeDasharray: import("../types/index.js").ConstantAccessor<string, Datum>;
24
+ strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
25
+ mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
26
+ clipPath: string;
27
+ imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
28
+ shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
29
+ paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
30
+ onclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
31
+ ondblclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
32
+ onmouseup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
33
+ onmousedown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
34
+ onmouseenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
35
+ onmousemove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
36
+ onmouseleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
37
+ onmouseout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
38
+ onmouseover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
39
+ onpointercancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
40
+ onpointerdown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
41
+ onpointerup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
42
+ onpointerenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
43
+ onpointerleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
44
+ onpointermove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
45
+ onpointerover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
46
+ onpointerout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
47
+ ondrag?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
48
+ ondrop?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
49
+ ondragstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
50
+ ondragenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
51
+ ondragleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
52
+ ondragover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
53
+ ondragend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
54
+ ontouchstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
55
+ ontouchmove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
56
+ ontouchend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
57
+ ontouchcancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
58
+ oncontextmenu?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
59
+ onwheel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
60
+ class: string | null;
61
+ cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
62
+ }> & LinkableMarkProps<Datum> & BaseRectMarkProps<Datum> & {
63
+ data: Datum[];
64
+ x?: ChannelAccessor<Datum>;
65
+ y?: ChannelAccessor<Datum>;
66
+ };
67
+ events(): {};
68
+ slots(): {};
69
+ bindings(): "";
70
+ exports(): {};
71
+ }
72
+ interface $$IsomorphicComponent {
73
+ 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']>> & {
74
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
75
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
76
+ <Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
77
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
78
+ }
7
79
  /** For arbitrary rectangles, requires band x and y scales */
8
- declare const Cell: import("svelte").Component<any, {}, "">;
9
- type Cell = ReturnType<typeof Cell>;
80
+ declare const Cell: $$IsomorphicComponent;
81
+ type Cell<Datum extends DataRecord> = InstanceType<typeof Cell<Datum>>;
10
82
  export default Cell;
@@ -1,18 +1,22 @@
1
- <script module lang="ts">
2
- export type CellXMarkProps = Omit<CellMarkProps, 'y'>;
3
- </script>
4
-
1
+ <!--
2
+ @component
3
+ For arbitrary rectangles with fixed y position, requires band x scale
4
+ -->
5
5
  <script lang="ts">
6
- import Cell, { type CellMarkProps } from './Cell.svelte';
7
- import { recordizeY } from '../index.js';
6
+ import Cell from './Cell.svelte';
7
+ import { recordizeY } from '..';
8
+ import type { ComponentProps } from 'svelte';
9
+ import type { TransformArgsRow } from '../types/index.js';
10
+
11
+ interface CellXMarkProps extends Omit<ComponentProps<typeof Cell>, 'y'> {}
8
12
 
9
13
  let { data = [{}], ...options }: CellXMarkProps = $props();
10
14
 
11
15
  const args = $derived(
12
- recordizeY<CellXMarkProps>({
16
+ recordizeY({
13
17
  data,
14
18
  ...options
15
- })
19
+ } as TransformArgsRow)
16
20
  );
17
21
  </script>
18
22
 
@@ -1,5 +1,8 @@
1
- export type CellXMarkProps = Omit<CellMarkProps, 'y'>;
2
- import { type CellMarkProps } from './Cell.svelte';
1
+ import Cell from './Cell.svelte';
2
+ import type { ComponentProps } from 'svelte';
3
+ interface CellXMarkProps extends Omit<ComponentProps<typeof Cell>, 'y'> {
4
+ }
5
+ /** For arbitrary rectangles with fixed y position, requires band x scale */
3
6
  declare const CellX: import("svelte").Component<CellXMarkProps, {}, "">;
4
7
  type CellX = ReturnType<typeof CellX>;
5
8
  export default CellX;
@@ -1,18 +1,22 @@
1
- <script module lang="ts">
2
- export type CellYMarkProps = Omit<CellMarkProps, 'x'>;
3
- </script>
4
-
1
+ <!--
2
+ @component
3
+ For arbitrary rectangles with fixed x position, requires band y scale
4
+ -->
5
5
  <script lang="ts">
6
- import Cell, { type CellMarkProps } from './Cell.svelte';
7
- import { recordizeX } from '../index.js';
6
+ import Cell from './Cell.svelte';
7
+ import { recordizeX } from '..';
8
+ import type { ComponentProps } from 'svelte';
9
+ import type { TransformArgsRow } from '../types/index.js';
10
+
11
+ interface CellYMarkProps extends Omit<ComponentProps<typeof Cell>, 'x'> {}
8
12
 
9
13
  let { data = [{}], ...options }: CellYMarkProps = $props();
10
14
 
11
15
  const args = $derived(
12
- recordizeX<CellYMarkProps>({
16
+ recordizeX({
13
17
  data,
14
18
  ...options
15
- })
19
+ } as TransformArgsRow)
16
20
  );
17
21
  </script>
18
22
 
@@ -1,5 +1,8 @@
1
- export type CellYMarkProps = Omit<CellMarkProps, 'x'>;
2
- import { type CellMarkProps } from './Cell.svelte';
1
+ import Cell from './Cell.svelte';
2
+ import type { ComponentProps } from 'svelte';
3
+ interface CellYMarkProps extends Omit<ComponentProps<typeof Cell>, 'x'> {
4
+ }
5
+ /** For arbitrary rectangles with fixed x position, requires band y scale */
3
6
  declare const CellY: import("svelte").Component<CellYMarkProps, {}, "">;
4
7
  type CellY = ReturnType<typeof CellY>;
5
8
  export default CellY;
@@ -1,17 +1,14 @@
1
- <script module lang="ts">
2
- export type ColorLegendMarkProps = {
3
- class: string | null;
4
- };
5
- </script>
6
-
7
1
  <script lang="ts">
2
+ interface ColorLegendMarkProps {
3
+ class: string | null;
4
+ }
8
5
  import { getContext } from 'svelte';
9
- import { Plot, AxisX, Frame } from '../index.js';
6
+ import { Plot, AxisX, Frame } from '..';
10
7
  import { symbol as d3Symbol } from 'd3-shape';
11
8
  import { range as d3Range, extent } from 'd3-array';
12
9
  import { maybeSymbol } from '../helpers/symbols.js';
13
10
 
14
- import type { PlotDefaults, PlotContext } from '../types.js';
11
+ import type { PlotDefaults, PlotContext } from '../types/index.js';
15
12
 
16
13
  let { class: className = null }: ColorLegendMarkProps = $props();
17
14
 
@@ -1,6 +1,6 @@
1
- export type ColorLegendMarkProps = {
1
+ interface ColorLegendMarkProps {
2
2
  class: string | null;
3
- };
3
+ }
4
4
  /**
5
5
  * The ColorLegend is an HTML mark that can be placed in the header, footer and overlay
6
6
  * snippets. You can activate an implicit ColorLegend above the chart using the global
@@ -2,21 +2,22 @@
2
2
  @component
3
3
  For showing custom SVG marks positioned at x/y coordinates
4
4
  -->
5
- <script module lang="ts">
6
- import type { ChannelAccessor, DataRow } from '../types.js';
7
- import type { Snippet } from 'svelte';
8
-
9
- export type HTMLMarkProps = {
10
- data: DataRow[];
11
- x?: ChannelAccessor;
12
- y?: ChannelAccessor;
13
- children: Snippet<{ datum: DataRow; x: number; y: number }>;
14
- };
15
- </script>
5
+ <script lang="ts" generics="Datum extends DataRecord">
6
+ interface CustomMarkProps extends BaseMarkProps<Datum> {
7
+ data: Datum[];
8
+ x?: ChannelAccessor<Datum>;
9
+ y?: ChannelAccessor<Datum>;
10
+ children: Snippet<[{ datum: Datum; x: number; y: number }]>;
11
+ }
16
12
 
17
- <script lang="ts">
18
13
  import { getContext } from 'svelte';
19
- import type { PlotContext } from '../types.js';
14
+ import type {
15
+ PlotContext,
16
+ DataRecord,
17
+ ChannelAccessor,
18
+ BaseMarkProps
19
+ } from '../types/index.js';
20
+ import type { Snippet } from 'svelte';
20
21
 
21
22
  const { getPlotState } = getContext<PlotContext>('svelteplot');
22
23
  let plot = $derived(getPlotState());
@@ -26,13 +27,19 @@
26
27
  import { isValid } from '../helpers/index.js';
27
28
  import GroupMultiple from './helpers/GroupMultiple.svelte';
28
29
 
29
- let { data = [{}], x, y, children, class: className = null }: HTMLMarkProps = $props();
30
+ let {
31
+ data = [{} as Datum],
32
+ x,
33
+ y,
34
+ children,
35
+ class: className = null
36
+ }: CustomMarkProps = $props();
30
37
  </script>
31
38
 
32
39
  <GroupMultiple class="g-custom-mark {className || ''}" length={className ? 2 : data.length}>
33
40
  {#each data as datum, i (i)}
34
- {@const x_ = resolveChannel('x', datum, { x, y })}
35
- {@const y_ = resolveChannel('y', datum, { x, y })}
41
+ {@const x_ = resolveChannel<Datum>('x', datum, { x, y })}
42
+ {@const y_ = resolveChannel<Datum>('y', datum, { x, y })}
36
43
  {#if isValid(x_) && isValid(y_)}
37
44
  {@const [px, py] = projectXY(plot.scales, x_, y_)}
38
45
  <g transform="translate({px}, {py})">
@@ -1,16 +1,19 @@
1
- import type { ChannelAccessor, DataRow } from '../types.js';
2
- import type { Snippet } from 'svelte';
3
- export type HTMLMarkProps = {
4
- data: DataRow[];
5
- x?: ChannelAccessor;
6
- y?: ChannelAccessor;
7
- children: Snippet<{
8
- datum: DataRow;
9
- x: number;
10
- y: number;
11
- }>;
12
- };
1
+ import type { DataRecord } from '../types/index.js';
2
+ declare class __sveltets_Render<Datum extends DataRecord> {
3
+ props(): any;
4
+ events(): {};
5
+ slots(): {};
6
+ bindings(): "";
7
+ exports(): {};
8
+ }
9
+ interface $$IsomorphicComponent {
10
+ 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']>> & {
11
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
12
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
13
+ <Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
14
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
15
+ }
13
16
  /** For showing custom SVG marks positioned at x/y coordinates */
14
- declare const CustomMark: import("svelte").Component<HTMLMarkProps, {}, "">;
15
- type CustomMark = ReturnType<typeof CustomMark>;
17
+ declare const CustomMark: $$IsomorphicComponent;
18
+ type CustomMark<Datum extends DataRecord> = InstanceType<typeof CustomMark<Datum>>;
16
19
  export default CustomMark;
@@ -2,14 +2,12 @@
2
2
  @component
3
3
  For showing custom HTML tooltips positioned at x/y coordinates
4
4
  -->
5
- <script module lang="ts">
6
- import type { ChannelAccessor, ConstantAccessor, DataRow } from '../types.js';
7
- import type { Snippet } from 'svelte';
8
5
 
9
- export type HTMLMarkProps = {
10
- data: DataRow[];
11
- x?: ChannelAccessor;
12
- y?: ChannelAccessor;
6
+ <script lang="ts" generics="Datum extends DataRecord">
7
+ interface CustomMarkHTMLProps {
8
+ data: Datum[];
9
+ x?: ChannelAccessor<Datum>;
10
+ y?: ChannelAccessor<Datum>;
13
11
  frameAnchor?: ConstantAccessor<
14
12
  | 'bottom'
15
13
  | 'top'
@@ -19,15 +17,19 @@
19
17
  | 'bottom-left'
20
18
  | 'top-right'
21
19
  | 'bottom-right'
22
- | 'center'
20
+ | 'center',
21
+ Datum
23
22
  >;
24
- children: Snippet<{ datum: DataRow; x: number; y: number }>;
25
- };
26
- </script>
27
-
28
- <script lang="ts">
29
- import { getContext } from 'svelte';
30
- import type { PlotContext } from '../types.js';
23
+ class: string | null;
24
+ children: Snippet<{ datum: Datum; x: number; y: number }>;
25
+ }
26
+ import { getContext, type Snippet } from 'svelte';
27
+ import type {
28
+ ChannelAccessor,
29
+ ConstantAccessor,
30
+ DataRecord,
31
+ PlotContext
32
+ } from '../types/index.js';
31
33
 
32
34
  const { getPlotState } = getContext<PlotContext>('svelteplot');
33
35
  const plot = $derived(getPlotState());
@@ -37,15 +39,15 @@
37
39
  import { isValid } from '../helpers/index.js';
38
40
 
39
41
  let {
40
- data = [{}],
42
+ data = [{} as Datum],
41
43
  x,
42
44
  y,
43
45
  frameAnchor,
44
46
  children,
45
47
  class: className = null
46
- }: HTMLMarkProps = $props();
48
+ }: CustomMarkHTMLProps = $props();
47
49
 
48
- function getXY(datum) {
50
+ function getXY(datum: Datum) {
49
51
  const fa = frameAnchor || 'center';
50
52
  const isLeft = fa.endsWith('left');
51
53
  const isRight = fa.endsWith('right');
@@ -1,17 +1,31 @@
1
- import type { ChannelAccessor, ConstantAccessor, DataRow } from '../types.js';
2
- import type { Snippet } from 'svelte';
3
- export type HTMLMarkProps = {
4
- data: DataRow[];
5
- x?: ChannelAccessor;
6
- y?: ChannelAccessor;
7
- frameAnchor?: ConstantAccessor<'bottom' | 'top' | 'left' | 'right' | 'top-left' | 'bottom-left' | 'top-right' | 'bottom-right' | 'center'>;
8
- children: Snippet<{
9
- datum: DataRow;
10
- x: number;
11
- y: number;
12
- }>;
13
- };
1
+ import { type Snippet } from 'svelte';
2
+ import type { ChannelAccessor, ConstantAccessor, DataRecord } from '../types/index.js';
3
+ declare class __sveltets_Render<Datum extends DataRecord> {
4
+ props(): {
5
+ data: Datum[];
6
+ x?: ChannelAccessor<Datum>;
7
+ y?: ChannelAccessor<Datum>;
8
+ frameAnchor?: ConstantAccessor<"bottom" | "top" | "left" | "right" | "center" | "top-left" | "bottom-left" | "top-right" | "bottom-right", Datum>;
9
+ class: string | null;
10
+ children: Snippet<{
11
+ datum: Datum;
12
+ x: number;
13
+ y: number;
14
+ }>;
15
+ };
16
+ events(): {};
17
+ slots(): {};
18
+ bindings(): "";
19
+ exports(): {};
20
+ }
21
+ interface $$IsomorphicComponent {
22
+ 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']>> & {
23
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
24
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
25
+ <Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
26
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
27
+ }
14
28
  /** For showing custom HTML tooltips positioned at x/y coordinates */
15
- declare const CustomMarkHtml: import("svelte").Component<HTMLMarkProps, {}, "">;
16
- type CustomMarkHtml = ReturnType<typeof CustomMarkHtml>;
29
+ declare const CustomMarkHtml: $$IsomorphicComponent;
30
+ type CustomMarkHtml<Datum extends DataRecord> = InstanceType<typeof CustomMarkHtml<Datum>>;
17
31
  export default CustomMarkHtml;
@@ -1,43 +1,59 @@
1
- <script module lang="ts">
2
- export type DifferenceYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity'> & {
3
- data: DataRecord[];
1
+ <script lang="ts" generics="Datum extends DataRecord">
2
+ interface DifferenceYMarkProps extends Omit<BaseMarkProps<Datum>, 'fill' | 'fillOpacity'> {
3
+ data: Datum[];
4
4
  /*
5
5
  * the horizontal position of the comparison; bound to the x scale
6
6
  */
7
- x1: ChannelAccessor;
7
+ x1: ChannelAccessor<Datum>;
8
8
  /**
9
9
  * the horizontal position of the metric; bound to the x scale
10
10
  */
11
- x2: ChannelAccessor;
12
- x: ChannelAccessor;
11
+ x2: ChannelAccessor<Datum>;
12
+ x: ChannelAccessor<Datum>;
13
13
  /**
14
14
  * the vertical position of the comparison; bound to the y scale
15
15
  */
16
- y1: ChannelAccessor;
16
+ y1: ChannelAccessor<Datum>;
17
17
  /**
18
18
  * the vertical position of the metric; bound to the y scale
19
19
  */
20
- y2: ChannelAccessor;
21
- y: ChannelAccessor;
20
+ y2: ChannelAccessor<Datum>;
21
+ y: ChannelAccessor<Datum>;
22
22
  fillOpacity?: number;
23
+ /**
24
+ * the stroke color of the "positive" area; defaults to 'blue'
25
+ */
23
26
  positiveFill?: string;
27
+ /**
28
+ * the fill opacity of the "positive" area; defaults to 1
29
+ */
24
30
  positiveFillOpacity?: number;
31
+ /**
32
+ * the stroke color of the "negative" area; defaults to 'red'
33
+ */
25
34
  negativeFill?: string;
35
+ /**
36
+ * the fill opacity of the "negative" area; defaults to 1
37
+ */
26
38
  negativeFillOpacity?: number;
39
+ /**
40
+ * curve type for the area; defaults to 'linear'
41
+ */
27
42
  curve?: CurveName | CurveFactory;
43
+ /**
44
+ * the tension of the area curve; defaults to 0
45
+ */
28
46
  tension?: number;
29
- };
30
- </script>
31
-
32
- <script lang="ts">
47
+ }
33
48
  import type {
34
49
  BaseMarkProps,
35
50
  ChannelAccessor,
36
51
  CurveName,
37
52
  DataRecord,
38
- PlotContext
39
- } from '../types.js';
40
- import { Line, Area } from '../index.js';
53
+ PlotContext,
54
+ PlotDefaults
55
+ } from '../types/index.js';
56
+ import { Line, Area } from './';
41
57
  import { randomId, coalesce } from '../helpers/index.js';
42
58
  import { getContext } from 'svelte';
43
59
  import { extent, max, min } from 'd3-array';
@@ -47,8 +63,28 @@
47
63
  const { getPlotState } = getContext<PlotContext>('svelteplot');
48
64
  let plot = $derived(getPlotState());
49
65
 
50
- let { data, stroke, class: className = null, ...options }: DifferenceYMarkProps = $props();
51
- let { x, x1, x2, y, y1, y2 } = $derived(options);
66
+ let markProps: DifferenceYMarkProps = $props();
67
+
68
+ const DEFAULTS = {
69
+ positiveFill: 'red',
70
+ positiveFillOpacity: 1,
71
+ negativeFill: 'blue',
72
+ negativeFillOpacity: 1,
73
+ curve: 'linear' as CurveName,
74
+ tension: 0,
75
+ ...getContext<PlotDefaults>('svelteplot/_defaults').differenceY
76
+ };
77
+
78
+ const {
79
+ data,
80
+ stroke,
81
+ class: className = null,
82
+ ...options
83
+ }: DifferenceYMarkProps = $derived({
84
+ ...DEFAULTS,
85
+ ...markProps
86
+ });
87
+ const { x, x1, x2, y, y1, y2 } = $derived(options);
52
88
 
53
89
  const x1x2Differ = $derived((x1 == null || x2 == null) && x1 !== x2);
54
90