svelteplot 0.3.3 → 0.3.5-pr-121.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 (191) 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/constants.d.ts +1 -1
  6. package/dist/core/Facet.svelte +1 -1
  7. package/dist/core/Facet.svelte.d.ts +1 -1
  8. package/dist/core/FacetAxes.svelte +3 -1
  9. package/dist/core/FacetGrid.svelte +1 -1
  10. package/dist/core/FacetGrid.svelte.d.ts +1 -1
  11. package/dist/core/Plot.svelte +1 -1
  12. package/dist/core/Plot.svelte.d.ts +1 -1
  13. package/dist/helpers/autoScales.d.ts +1 -1
  14. package/dist/helpers/autoTicks.d.ts +1 -1
  15. package/dist/helpers/autoTicks.js +1 -1
  16. package/dist/helpers/callWithProps.d.ts +1 -1
  17. package/dist/helpers/colors.d.ts +2 -2
  18. package/dist/helpers/curves.d.ts +1 -1
  19. package/dist/helpers/facets.d.ts +1 -1
  20. package/dist/helpers/getBaseStyles.d.ts +4 -2
  21. package/dist/helpers/getBaseStyles.js +8 -0
  22. package/dist/helpers/group.d.ts +1 -1
  23. package/dist/helpers/index.d.ts +3 -3
  24. package/dist/helpers/isDataRecord.d.ts +1 -1
  25. package/dist/helpers/isRawValue.d.ts +1 -1
  26. package/dist/helpers/projection.d.ts +1 -1
  27. package/dist/helpers/reduce.d.ts +1 -1
  28. package/dist/helpers/regressionLoess.d.ts +1 -1
  29. package/dist/helpers/resolve.d.ts +3 -3
  30. package/dist/helpers/scales.d.ts +2 -2
  31. package/dist/helpers/typeChecks.d.ts +5 -5
  32. package/dist/marks/Area.svelte +14 -17
  33. package/dist/marks/Area.svelte.d.ts +91 -19
  34. package/dist/marks/AreaX.svelte +15 -12
  35. package/dist/marks/AreaX.svelte.d.ts +94 -3
  36. package/dist/marks/AreaY.svelte +15 -15
  37. package/dist/marks/AreaY.svelte.d.ts +94 -3
  38. package/dist/marks/Arrow.svelte +16 -19
  39. package/dist/marks/Arrow.svelte.d.ts +110 -38
  40. package/dist/marks/AxisX.svelte +60 -56
  41. package/dist/marks/AxisX.svelte.d.ts +98 -25
  42. package/dist/marks/AxisY.svelte +73 -54
  43. package/dist/marks/AxisY.svelte.d.ts +100 -27
  44. package/dist/marks/BarX.svelte +28 -30
  45. package/dist/marks/BarX.svelte.d.ts +89 -17
  46. package/dist/marks/BarY.svelte +27 -27
  47. package/dist/marks/BarY.svelte.d.ts +88 -16
  48. package/dist/marks/BollingerX.svelte +21 -16
  49. package/dist/marks/BollingerX.svelte.d.ts +17 -16
  50. package/dist/marks/BollingerY.svelte +21 -16
  51. package/dist/marks/BollingerY.svelte.d.ts +17 -16
  52. package/dist/marks/BoxX.svelte +5 -7
  53. package/dist/marks/BoxX.svelte.d.ts +5 -3
  54. package/dist/marks/BoxY.svelte +13 -16
  55. package/dist/marks/BoxY.svelte.d.ts +41 -28
  56. package/dist/marks/Brush.svelte +27 -30
  57. package/dist/marks/Brush.svelte.d.ts +20 -15
  58. package/dist/marks/BrushX.svelte +9 -7
  59. package/dist/marks/BrushX.svelte.d.ts +5 -2
  60. package/dist/marks/BrushY.svelte +9 -7
  61. package/dist/marks/BrushY.svelte.d.ts +5 -2
  62. package/dist/marks/Cell.svelte +17 -18
  63. package/dist/marks/Cell.svelte.d.ts +80 -8
  64. package/dist/marks/CellX.svelte +12 -8
  65. package/dist/marks/CellX.svelte.d.ts +5 -2
  66. package/dist/marks/CellY.svelte +12 -8
  67. package/dist/marks/CellY.svelte.d.ts +5 -2
  68. package/dist/marks/ColorLegend.svelte +5 -8
  69. package/dist/marks/ColorLegend.svelte.d.ts +2 -2
  70. package/dist/marks/CustomMark.svelte +23 -16
  71. package/dist/marks/CustomMark.svelte.d.ts +17 -14
  72. package/dist/marks/CustomMarkHTML.svelte +20 -18
  73. package/dist/marks/CustomMarkHTML.svelte.d.ts +29 -15
  74. package/dist/marks/DifferenceY.svelte +54 -18
  75. package/dist/marks/DifferenceY.svelte.d.ts +59 -28
  76. package/dist/marks/Dot.svelte +13 -14
  77. package/dist/marks/Dot.svelte.d.ts +84 -12
  78. package/dist/marks/DotX.svelte +9 -9
  79. package/dist/marks/DotX.svelte.d.ts +86 -4
  80. package/dist/marks/DotY.svelte +10 -9
  81. package/dist/marks/DotY.svelte.d.ts +87 -5
  82. package/dist/marks/Frame.svelte +20 -27
  83. package/dist/marks/Frame.svelte.d.ts +24 -10
  84. package/dist/marks/Geo.svelte +22 -15
  85. package/dist/marks/Geo.svelte.d.ts +97 -13
  86. package/dist/marks/Graticule.svelte +16 -19
  87. package/dist/marks/Graticule.svelte.d.ts +3 -3
  88. package/dist/marks/GridX.svelte +5 -8
  89. package/dist/marks/GridX.svelte.d.ts +79 -7
  90. package/dist/marks/GridY.svelte +5 -8
  91. package/dist/marks/GridY.svelte.d.ts +79 -7
  92. package/dist/marks/HTMLTooltip.svelte +9 -14
  93. package/dist/marks/HTMLTooltip.svelte.d.ts +25 -12
  94. package/dist/marks/Line.svelte +24 -29
  95. package/dist/marks/Line.svelte.d.ts +97 -25
  96. package/dist/marks/LineX.svelte +9 -4
  97. package/dist/marks/LineX.svelte.d.ts +99 -3
  98. package/dist/marks/LineY.svelte +11 -5
  99. package/dist/marks/LineY.svelte.d.ts +100 -4
  100. package/dist/marks/Link.svelte +35 -19
  101. package/dist/marks/Link.svelte.d.ts +107 -18
  102. package/dist/marks/Pointer.svelte +13 -18
  103. package/dist/marks/Pointer.svelte.d.ts +34 -21
  104. package/dist/marks/Rect.svelte +19 -19
  105. package/dist/marks/Rect.svelte.d.ts +86 -13
  106. package/dist/marks/RectX.svelte +10 -9
  107. package/dist/marks/RectX.svelte.d.ts +22 -6
  108. package/dist/marks/RectY.svelte +9 -10
  109. package/dist/marks/RectY.svelte.d.ts +22 -6
  110. package/dist/marks/RegressionX.svelte +1 -1
  111. package/dist/marks/RegressionX.svelte.d.ts +1 -1
  112. package/dist/marks/RegressionY.svelte +1 -1
  113. package/dist/marks/RegressionY.svelte.d.ts +1 -1
  114. package/dist/marks/RuleX.svelte +14 -16
  115. package/dist/marks/RuleX.svelte.d.ts +84 -12
  116. package/dist/marks/RuleY.svelte +12 -15
  117. package/dist/marks/RuleY.svelte.d.ts +84 -12
  118. package/dist/marks/Sphere.svelte +6 -7
  119. package/dist/marks/Sphere.svelte.d.ts +3 -2
  120. package/dist/marks/Spike.svelte +17 -9
  121. package/dist/marks/Spike.svelte.d.ts +94 -4
  122. package/dist/marks/SymbolLegend.svelte +1 -1
  123. package/dist/marks/Text.svelte +34 -124
  124. package/dist/marks/Text.svelte.d.ts +101 -20
  125. package/dist/marks/TickX.svelte +12 -13
  126. package/dist/marks/TickX.svelte.d.ts +92 -20
  127. package/dist/marks/TickY.svelte +11 -14
  128. package/dist/marks/TickY.svelte.d.ts +92 -20
  129. package/dist/marks/Vector.svelte +19 -23
  130. package/dist/marks/Vector.svelte.d.ts +93 -21
  131. package/dist/marks/helpers/AreaCanvas.svelte +1 -1
  132. package/dist/marks/helpers/AreaCanvas.svelte.d.ts +1 -1
  133. package/dist/marks/helpers/BaseAxisX.svelte +5 -3
  134. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -1
  135. package/dist/marks/helpers/BaseAxisY.svelte +10 -8
  136. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +3 -1
  137. package/dist/marks/helpers/CanvasLayer.svelte +1 -1
  138. package/dist/marks/helpers/DotCanvas.svelte +1 -1
  139. package/dist/marks/helpers/DotCanvas.svelte.d.ts +1 -1
  140. package/dist/marks/helpers/GeoCanvas.svelte +1 -1
  141. package/dist/marks/helpers/GeoCanvas.svelte.d.ts +1 -1
  142. package/dist/marks/helpers/LineCanvas.svelte +1 -1
  143. package/dist/marks/helpers/LineCanvas.svelte.d.ts +1 -1
  144. package/dist/marks/helpers/LinearGradientX.svelte +1 -1
  145. package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
  146. package/dist/marks/helpers/LinearGradientY.svelte +1 -1
  147. package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
  148. package/dist/marks/helpers/MarkerPath.svelte +1 -1
  149. package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
  150. package/dist/marks/helpers/MultilineText.svelte +158 -0
  151. package/dist/marks/helpers/MultilineText.svelte.d.ts +12 -0
  152. package/dist/marks/helpers/RectPath.svelte +29 -26
  153. package/dist/marks/helpers/RectPath.svelte.d.ts +39 -26
  154. package/dist/marks/helpers/Regression.svelte +7 -2
  155. package/dist/marks/helpers/Regression.svelte.d.ts +2 -5
  156. package/dist/marks/helpers/events.d.ts +1 -1
  157. package/dist/transforms/bin.d.ts +2 -2
  158. package/dist/transforms/bollinger.d.ts +2 -67
  159. package/dist/transforms/centroid.d.ts +8 -66
  160. package/dist/transforms/centroid.js +10 -7
  161. package/dist/transforms/filter.d.ts +1 -1
  162. package/dist/transforms/group.d.ts +5 -13
  163. package/dist/transforms/interval.d.ts +3 -123
  164. package/dist/transforms/jitter.d.ts +1 -1
  165. package/dist/transforms/map.d.ts +4 -184
  166. package/dist/transforms/normalize.d.ts +3 -123
  167. package/dist/transforms/recordize.d.ts +1 -1
  168. package/dist/transforms/rename.d.ts +2 -2
  169. package/dist/transforms/select.d.ts +8 -428
  170. package/dist/transforms/shift.d.ts +1 -1
  171. package/dist/transforms/sort.d.ts +4 -243
  172. package/dist/transforms/stack.d.ts +1 -1
  173. package/dist/transforms/window.d.ts +3 -131
  174. package/dist/types/channel.d.ts +11 -0
  175. package/dist/types/channel.js +1 -0
  176. package/dist/types/colorScheme.d.ts +1 -0
  177. package/dist/types/colorScheme.js +1 -0
  178. package/dist/types/data.d.ts +13 -0
  179. package/dist/types/data.js +1 -0
  180. package/dist/types/facet.d.ts +50 -0
  181. package/dist/types/facet.js +1 -0
  182. package/dist/types/index.d.ts +58 -0
  183. package/dist/types/index.js +7 -0
  184. package/dist/types/mark.d.ts +123 -0
  185. package/dist/types/mark.js +1 -0
  186. package/dist/types/plot.d.ts +459 -0
  187. package/dist/types/plot.js +1 -0
  188. package/dist/types/scale.d.ts +143 -0
  189. package/dist/types/scale.js +1 -0
  190. package/dist/types.d.ts +120 -127
  191. package/package.json +125 -120
package/dist/Mark.svelte CHANGED
@@ -1,6 +1,24 @@
1
- <script lang="ts">
2
- import { getContext, untrack, type Snippet } from 'svelte';
1
+ <script lang="ts" generics="Datum extends DataRecord">
2
+ interface MarkProps extends Partial<BaseMarkProps<Datum>> {
3
+ data?: Datum[];
4
+ automatic?: boolean;
5
+ type: MarkType;
6
+ channels?: ScaledChannelName[];
7
+ required?: ScaledChannelName[];
8
+ requiredScales?: Partial<Record<ScaleName, ScaleType[]>>;
9
+ children?: Snippet<
10
+ [
11
+ {
12
+ mark: Mark<GenericMarkOptions>;
13
+ usedScales: ReturnType<typeof getUsedScales>;
14
+ scaledData: ScaledDataRecord[];
15
+ }
16
+ ]
17
+ >;
18
+ defaults?: Partial<Record<ScaledChannelName, RawValue>>;
19
+ }
3
20
 
21
+ import { getContext, untrack, type Snippet } from 'svelte';
4
22
  import { CHANNEL_SCALE, INDEX } from './constants.js';
5
23
  import type {
6
24
  ScaledChannelName,
@@ -17,32 +35,12 @@
17
35
  ResolvedDataRecord,
18
36
  ScaledDataRecord,
19
37
  ScaleType
20
- } from './types.js';
38
+ } from './types/index.js';
21
39
  import { isEqual } from 'es-toolkit';
22
40
  import { getUsedScales, projectXY, projectX, projectY } from './helpers/scales.js';
23
41
  import { testFilter, isValid } from './helpers/index.js';
24
42
  import { resolveChannel, resolveProp } from './helpers/resolve.js';
25
43
 
26
- type MarkProps = {
27
- data?: DataRecord[];
28
- automatic?: boolean;
29
- type: MarkType;
30
- channels?: ScaledChannelName[];
31
- required?: ScaledChannelName[];
32
- requiredScales?: Partial<Record<ScaleName, ScaleType[]>>;
33
- children?: Snippet<
34
- [
35
- {
36
- mark: Mark<GenericMarkOptions>;
37
- usedScales: ReturnType<typeof getUsedScales>;
38
- scaledData: ScaledDataRecord[];
39
- }
40
- ]
41
- >;
42
- defaults?: Partial<Record<ScaledChannelName, RawValue>>;
43
- } & Partial<Record<ChannelName, ChannelAccessor>> &
44
- Partial<BaseMarkProps>;
45
-
46
44
  let {
47
45
  data = [],
48
46
  children,
@@ -134,13 +132,13 @@
134
132
  const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
135
133
  const testFacet = $derived(getTestFacet());
136
134
 
137
- const resolvedData: ResolvedDataRecord[] = $derived(
135
+ const resolvedData: ResolvedDataRecord<Datum>[] = $derived(
138
136
  data
139
137
  .map((d, i) => ({ ...d, [INDEX]: i }))
140
138
  .flatMap((row) => {
141
- const channels = options as Record<ChannelName, ChannelAccessor>;
139
+ const channels = options as Record<ChannelName, ChannelAccessor<Datum>>;
142
140
  if (!testFacet(row, channels) || !testFilter(row, channels)) return [];
143
- const out: ResolvedDataRecord = {
141
+ const out: ResolvedDataRecord<Datum> = {
144
142
  datum: row
145
143
  };
146
144
  for (const [channel] of Object.entries(CHANNEL_SCALE) as [
@@ -208,7 +206,7 @@
208
206
  */
209
207
  const scaledData = $derived(
210
208
  resolvedData.flatMap((row) => {
211
- const out: ScaledDataRecord = {
209
+ const out: ScaledDataRecord<Datum> = {
212
210
  datum: row.datum,
213
211
  valid: true
214
212
  };
@@ -1,22 +1,92 @@
1
1
  import { type Snippet } from 'svelte';
2
- import type { ScaledChannelName, MarkType, DataRecord, ChannelName, GenericMarkOptions, ChannelAccessor, BaseMarkProps, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types.js';
2
+ import type { ScaledChannelName, MarkType, DataRecord, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
3
3
  import { getUsedScales } from './helpers/scales.js';
4
- type MarkProps = {
5
- data?: DataRecord[];
6
- automatic?: boolean;
7
- type: MarkType;
8
- channels?: ScaledChannelName[];
9
- required?: ScaledChannelName[];
10
- requiredScales?: Partial<Record<ScaleName, ScaleType[]>>;
11
- children?: Snippet<[
12
- {
13
- mark: Mark<GenericMarkOptions>;
4
+ declare class __sveltets_Render<Datum extends DataRecord> {
5
+ props(): Partial<Partial<{
6
+ filter?: import("./types/index.js").ConstantAccessor<boolean, Datum>;
7
+ facet?: "auto" | "include" | "exclude";
8
+ fx: ChannelAccessor<Datum>;
9
+ fy: ChannelAccessor<Datum>;
10
+ dx: import("./types/index.js").ConstantAccessor<number, Datum>;
11
+ dy: import("./types/index.js").ConstantAccessor<number, Datum>;
12
+ fill: ChannelAccessor<Datum>;
13
+ fillOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
14
+ sort: {
15
+ channel: string;
16
+ order?: "ascending" | "descending";
17
+ } | ((a: RawValue, b: RawValue) => number) | import("./types/index.js").ConstantAccessor<RawValue, Datum>;
18
+ stroke: ChannelAccessor<Datum>;
19
+ strokeWidth: import("./types/index.js").ConstantAccessor<number, Datum>;
20
+ strokeOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
21
+ strokeLinejoin: import("./types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
22
+ strokeLinecap: import("./types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
23
+ strokeMiterlimit: import("./types/index.js").ConstantAccessor<number, Datum>;
24
+ opacity: ChannelAccessor<Datum>;
25
+ strokeDasharray: import("./types/index.js").ConstantAccessor<string, Datum>;
26
+ strokeDashoffset: import("./types/index.js").ConstantAccessor<number, Datum>;
27
+ mixBlendMode: import("./types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
+ clipPath: string;
29
+ imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
30
+ shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
+ paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
32
+ onclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
33
+ ondblclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
34
+ onmouseup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
35
+ onmousedown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
36
+ onmouseenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
37
+ onmousemove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
38
+ onmouseleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
39
+ onmouseout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
40
+ onmouseover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
41
+ onpointercancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
42
+ onpointerdown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
43
+ onpointerup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
44
+ onpointerenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
45
+ onpointerleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
46
+ onpointermove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
47
+ onpointerover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
48
+ onpointerout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
49
+ ondrag?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
50
+ ondrop?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
51
+ ondragstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
52
+ ondragenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
53
+ ondragleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
54
+ ondragover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
55
+ ondragend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
56
+ ontouchstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
57
+ ontouchmove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
58
+ ontouchend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
59
+ ontouchcancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
60
+ oncontextmenu?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
61
+ onwheel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
62
+ class: string | null;
63
+ cursor: import("./types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
64
+ }>> & {
65
+ data?: Datum[] | undefined;
66
+ automatic?: boolean;
67
+ type: MarkType;
68
+ channels?: ScaledChannelName[];
69
+ required?: ScaledChannelName[];
70
+ requiredScales?: Partial<Record<ScaleName, ScaleType[]>>;
71
+ children?: Snippet<[{
72
+ mark: any;
14
73
  usedScales: ReturnType<typeof getUsedScales>;
15
74
  scaledData: ScaledDataRecord[];
16
- }
17
- ]>;
18
- defaults?: Partial<Record<ScaledChannelName, RawValue>>;
19
- } & Partial<Record<ChannelName, ChannelAccessor>> & Partial<BaseMarkProps>;
20
- declare const Mark: import("svelte").Component<MarkProps, {}, "">;
21
- type Mark = ReturnType<typeof Mark>;
75
+ }]> | undefined;
76
+ defaults?: Partial<Record<ScaledChannelName, RawValue>>;
77
+ };
78
+ events(): {};
79
+ slots(): {};
80
+ bindings(): "";
81
+ exports(): {};
82
+ }
83
+ interface $$IsomorphicComponent {
84
+ 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']>> & {
85
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
86
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
87
+ <Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
88
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
89
+ }
90
+ declare const Mark: $$IsomorphicComponent;
91
+ type Mark<Datum extends DataRecord> = InstanceType<typeof Mark<Datum>>;
22
92
  export default Mark;
package/dist/Plot.svelte CHANGED
@@ -12,7 +12,7 @@
12
12
  <script lang="ts">
13
13
  import Plot from './core/Plot.svelte';
14
14
 
15
- import type { PlotDefaults, PlotOptions } from './types.js';
15
+ import type { PlotDefaults, PlotOptions } from './types/index.js';
16
16
 
17
17
  // implicit marks
18
18
  import AxisX from './marks/AxisX.svelte';
@@ -28,7 +28,6 @@
28
28
  import { autoScale, autoScaleColor } from './helpers/autoScales.js';
29
29
  import { namedProjection } from './helpers/autoProjection.js';
30
30
  import { isObject } from './helpers/index.js';
31
- import { getContext } from 'svelte';
32
31
 
33
32
  let {
34
33
  header: userHeader,
@@ -1,5 +1,5 @@
1
1
  import Plot from './core/Plot.svelte';
2
- import type { PlotOptions } from './types.js';
2
+ import type { PlotOptions } from './types/index.js';
3
3
  /**
4
4
  * The Plot component is the container for plots. It collects the marks with
5
5
  * their data and channels and computes the shared scales.
@@ -1,4 +1,4 @@
1
- import type { ScaleName, ScaleType, ScaledChannelName } from './types.js';
1
+ import type { ScaleName, ScaleType, ScaledChannelName } from './types/index.js';
2
2
  export declare const SCALE_TYPES: Record<ScaleName, symbol>;
3
3
  export declare const SCALES: ScaleName[];
4
4
  export declare const VALID_SCALE_TYPES: Record<ScaleName, Set<ScaleType>>;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { setContext, type Snippet } from 'svelte';
3
3
  import { resolveChannel } from '../helpers/resolve.js';
4
- import type { BaseMarkProps, DataRecord, RawValue } from '../types.js';
4
+ import type { BaseMarkProps, DataRecord, RawValue } from '../types/index.js';
5
5
 
6
6
  let {
7
7
  fx,
@@ -1,5 +1,5 @@
1
1
  import { type Snippet } from 'svelte';
2
- import type { RawValue } from '../types.js';
2
+ import type { RawValue } from '../types/index.js';
3
3
  type $$ComponentProps = {
4
4
  fx: RawValue;
5
5
  fy: RawValue;
@@ -4,7 +4,7 @@
4
4
  -->
5
5
  <script lang="ts">
6
6
  import { getContext } from 'svelte';
7
- import type { PlotContext } from '../types.js';
7
+ import type { PlotContext } from '../types/index.js';
8
8
  import { scaleBand } from 'd3-scale';
9
9
  import BaseAxisX from '../marks/helpers/BaseAxisX.svelte';
10
10
  import BaseAxisY from '../marks/helpers/BaseAxisY.svelte';
@@ -36,6 +36,7 @@
36
36
  scaleType="band"
37
37
  ticks={fxValues}
38
38
  tickFormat={(d) => d}
39
+ tickFontSize={11}
39
40
  tickSize={0}
40
41
  tickPadding={5}
41
42
  anchor={plot.options.fx.axis}
@@ -53,6 +54,7 @@
53
54
  scaleType="band"
54
55
  ticks={fyValues}
55
56
  tickFormat={(d) => d}
57
+ tickFontSize={11}
56
58
  tickSize={0}
57
59
  tickPadding={5}
58
60
  anchor={plot.options.fy.axis}
@@ -5,7 +5,7 @@
5
5
  -->
6
6
  <script lang="ts">
7
7
  import { getContext, type Snippet } from 'svelte';
8
- import type { PlotContext, GenericMarkOptions, Mark } from '../types.js';
8
+ import type { PlotContext, GenericMarkOptions, Mark } from '../types/index.js';
9
9
  import { scaleBand } from 'd3-scale';
10
10
  import Facet from './Facet.svelte';
11
11
  import { getEmptyFacets } from '../helpers/facets.js';
@@ -1,5 +1,5 @@
1
1
  import { type Snippet } from 'svelte';
2
- import type { GenericMarkOptions, Mark } from '../types.js';
2
+ import type { GenericMarkOptions, Mark } from '../types/index.js';
3
3
  type $$ComponentProps = {
4
4
  children: Snippet;
5
5
  marks: Mark<GenericMarkOptions>[];
@@ -22,7 +22,7 @@
22
22
  PlotDefaults,
23
23
  PlotState,
24
24
  RawValue
25
- } from '../types.js';
25
+ } from '../types/index.js';
26
26
  import FacetGrid from './FacetGrid.svelte';
27
27
 
28
28
  import mergeDeep from '../helpers/mergeDeep.js';
@@ -1,4 +1,4 @@
1
- import type { PlotOptions } from '../types.js';
1
+ import type { PlotOptions } from '../types/index.js';
2
2
  /**
3
3
  * The core Plot component handles the main layout of the plot but it does not
4
4
  * include smart automatic scales and marks. It is to be used in cases where
@@ -1,4 +1,4 @@
1
- import type { ColorScaleOptions, PlotDefaults, PlotOptions, RawValue, ScaleName, ScaleOptions, ScaleType } from '../types.js';
1
+ import type { ColorScaleOptions, PlotDefaults, PlotOptions, RawValue, ScaleName, ScaleOptions, ScaleType } from '../types/index.js';
2
2
  export declare function autoScale({ name, type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }: {
3
3
  name: ScaleName;
4
4
  type: ScaleType;
@@ -1,3 +1,3 @@
1
- import type { RawValue, ScaleType } from '../types.js';
1
+ import type { RawValue, ScaleType } from '../types/index.js';
2
2
  export declare function maybeInterval(interval: null | number | string | (<T>(d: T) => T)): any;
3
3
  export declare function autoTicks(type: ScaleType, ticks: RawValue[], interval: string | number | null, domain: RawValue[], scaleFn: any, count: number): any;
@@ -35,7 +35,7 @@ export function autoTicks(type, ticks, interval, domain, scaleFn, count) {
35
35
  if (interval) {
36
36
  const [lo, hi] = extent(domain);
37
37
  const I = maybeInterval(interval, type);
38
- return I.range(lo, I.offset(hi));
38
+ return I.range(lo, I.offset(hi)).filter((d) => d >= lo && d <= hi);
39
39
  }
40
40
  return typeof scaleFn.ticks === 'function' ? scaleFn.ticks(count) : [];
41
41
  }
@@ -1,4 +1,4 @@
1
- import type { RawValue } from '../types.js';
1
+ import type { RawValue } from '../types/index.js';
2
2
  type Setter = (v: any) => void;
3
3
  /**
4
4
  * Helper function to call a D3 "function class" while also calling
@@ -1,12 +1,12 @@
1
1
  import { interpolateBrBG } from 'd3-scale-chromatic';
2
- import type { ColorScheme } from '../types.js';
2
+ import type { ColorScheme } from '../types/index.js';
3
3
  export declare const categoricalSchemes: Map<string, readonly string[]>;
4
4
  export declare function isCategoricalScheme(scheme: string): boolean;
5
5
  type SchemeGetter = (n: number) => readonly string[];
6
6
  export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
7
7
  export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
8
8
  export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
9
- export declare function maybeBooleanRange(domain: boolean[], scheme?: string): unknown[] | undefined;
9
+ export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
10
10
  export declare function isQuantitativeScheme(scheme: string): boolean;
11
11
  export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
12
12
  export declare function isDivergingScheme(scheme: string): boolean;
@@ -1,3 +1,3 @@
1
- import type { Curve } from '../types.js';
1
+ import type { Curve } from '../types/index.js';
2
2
  import { type CurveFactory } from 'd3-shape';
3
3
  export declare function maybeCurve(curve: Curve | CurveFactory, tension: number): any;
@@ -1,4 +1,4 @@
1
- import type { GenericMarkOptions, Mark, RawValue } from '../types.js';
1
+ import type { GenericMarkOptions, Mark, RawValue } from '../types/index.js';
2
2
  /**
3
3
  * This function tracks which facets are "empty", meaning that they don't contain
4
4
  * any "facetted" data points. This can happen when fx and fy are combined and
@@ -1,7 +1,9 @@
1
- import type { Channels } from '../types.js';
2
- import type { DataRow } from '../types.js';
1
+ import type { Channels } from '../types/index.js';
2
+ import type { DataRow } from '../types/index.js';
3
3
  export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): {
4
4
  [k: string]: string | number;
5
5
  };
6
6
  export default function (datum: DataRow, props: Partial<Channels>): string;
7
7
  export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
8
+ export declare function maybeFromPixel(value: string | number): string | number;
9
+ export declare function maybeFromRem(value: string | number, rootFontSize?: number): string | number;
@@ -41,3 +41,11 @@ export function maybeToPixel(cssKey, value) {
41
41
  }
42
42
  return value;
43
43
  }
44
+ export function maybeFromPixel(value) {
45
+ return typeof value === 'string' && value.endsWith('px') ? +value.slice(0, -2) : value;
46
+ }
47
+ export function maybeFromRem(value, rootFontSize = 16) {
48
+ return typeof value === 'string' && value.endsWith('rem')
49
+ ? +value.slice(0, -3) * rootFontSize
50
+ : value;
51
+ }
@@ -1,4 +1,4 @@
1
- import type { Channels, DataRecord } from '../types.js';
1
+ import type { Channels, DataRecord } from '../types/index.js';
2
2
  /**
3
3
  * Groups the data by the fx, fy and z channels and calls the reduce function
4
4
  * for each group. Returns the new channels to be added in the transform.
@@ -1,10 +1,10 @@
1
- import type { ChannelAccessor, ChannelName, DataRecord, RawValue } from '../types.js';
1
+ import type { ChannelAccessor, ChannelName, DataRecord, RawValue } from '../types/index.js';
2
2
  import type { Snippet } from 'svelte';
3
3
  /**
4
4
  * Returns first argument that is not null or undefined
5
5
  */
6
- export declare function coalesce(...args: (RawValue | undefined | null)[]): RawValue | null;
7
- export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): string | number | boolean | symbol | Date | null;
6
+ export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
7
+ export declare function testFilter(datum: DataRecord, options: Record<ChannelName, ChannelAccessor>): any;
8
8
  export declare function randomId(): string;
9
9
  export declare function isSnippet(value: unknown): value is Snippet;
10
10
  export declare function isValid(value: RawValue | undefined): value is number | Date | string;
@@ -1,2 +1,2 @@
1
- import type { DataRecord } from '../types.js';
1
+ import type { DataRecord } from '../types/index.js';
2
2
  export default function (value: any): value is DataRecord;
@@ -1,2 +1,2 @@
1
- import type { RawValue } from '../types.js';
1
+ import type { RawValue } from '../types/index.js';
2
2
  export default function (value: any): value is RawValue;
@@ -1,4 +1,4 @@
1
- type Clip = boolean | null | number | 'frame';
1
+ export type Clip = boolean | null | number | 'frame';
2
2
  type ProjectionOptions = {
3
3
  type: string;
4
4
  domain: number[];
@@ -1,4 +1,4 @@
1
- import type { ChannelName, Channels, DataRecord, DataRow, RawValue } from '../types.js';
1
+ import type { ChannelName, Channels, DataRecord, DataRow, RawValue } from '../types/index.js';
2
2
  type ReducerFunc = (group: Iterable<DataRow>) => RawValue;
3
3
  type ReducerOption = ReducerName | ReducerFunc;
4
4
  type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
@@ -1,4 +1,4 @@
1
- import type { DataRow } from '../types.js';
1
+ import type { DataRow } from '../types/index.js';
2
2
  type AccessorFn = (d: any) => number;
3
3
  export default function (): {
4
4
  (data: DataRow[]): {
@@ -1,5 +1,5 @@
1
- import type { MarkStyleProps, PlotState, ScaledDataRecord } from '../types.js';
2
- import type { ScaleName, ChannelName, ScaledChannelName, ChannelAccessor, DataRow, RawValue, DataRecord, ConstantAccessor } from '../types.js';
1
+ import type { MarkStyleProps, PlotState, ScaledDataRecord } from '../types/index.js';
2
+ import type { ScaleName, ChannelName, ScaledChannelName, ChannelAccessor, DataRow, RawValue, DataRecord, ConstantAccessor } from '../types/index.js';
3
3
  type ChannelAlias = {
4
4
  channel: ScaledChannelName;
5
5
  };
@@ -10,7 +10,7 @@ type ChannelOptions = {
10
10
  channel?: ScaledChannelName | null;
11
11
  };
12
12
  export declare function toChannelOption(name: ScaledChannelName, channel: ChannelAccessor | ChannelAlias): ChannelOptions;
13
- export declare function resolveChannel(channel: ChannelName, datum: DataRow, channels: Partial<Record<ChannelName, ChannelAccessor | ChannelAlias>>): RawValue;
13
+ export declare function resolveChannel<T>(channel: ChannelName, datum: DataRow<T>, channels: Partial<Record<ChannelName, ChannelAccessor<T> | ChannelAlias>>): RawValue;
14
14
  export declare function resolveScaledStyleProps(datum: DataRecord, channels: Partial<Record<ScaledChannelName, ChannelAccessor>>, useScale: Record<ScaledChannelName, boolean>, plot: PlotState, defaultColorProp?: 'fill' | 'stroke' | null): any;
15
15
  export declare function resolveScaledStyles(datum: DataRecord, channels: Partial<Record<ScaledChannelName, ChannelAccessor> & {
16
16
  style: string;
@@ -1,4 +1,4 @@
1
- import type { ChannelAccessor, GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, ScaledChannelName, UsedScales } from '../types.js';
1
+ import type { ChannelAccessor, GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, ScaledChannelName, UsedScales } from '../types/index.js';
2
2
  /**
3
3
  * compute the plot scales
4
4
  */
@@ -15,7 +15,7 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
15
15
  autoTitle?: undefined;
16
16
  } | {
17
17
  type: ScaleType;
18
- domain: RawValue[] | [undefined, undefined];
18
+ domain: any;
19
19
  range: any;
20
20
  fn: any;
21
21
  skip: Map<ScaledChannelName, Set<symbol>>;
@@ -1,10 +1,10 @@
1
- import type { RawValue } from '../types.js';
2
- export declare function isBooleanOrNull(v: RawValue): v is boolean;
1
+ import type { RawValue } from '../types/index.js';
2
+ export declare function isBooleanOrNull(v: RawValue): boolean;
3
3
  export declare function isDate(v: RawValue): v is Date;
4
- export declare function isDateOrNull(v: RawValue | null | undefined): v is Date | null | undefined;
4
+ export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
5
5
  export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
6
6
  export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
7
- export declare function isStringOrNull(v: RawValue | null | undefined): v is string | null | undefined;
7
+ export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
8
8
  export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
9
- export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
9
+ export declare function isColorOrNull(v: RawValue | null | undefined): any;
10
10
  export declare function isOpacityOrNull(v: RawValue): boolean;
@@ -1,24 +1,21 @@
1
1
  <!-- @component
2
2
  Creates an area chart with filled regions between two x-y value pairs
3
3
  -->
4
- <script module lang="ts">
5
- export type AreaMarkProps = {
6
- data: DataRecord[];
7
- x1?: ChannelAccessor;
8
- x2?: ChannelAccessor;
9
- y1?: ChannelAccessor;
10
- y2?: ChannelAccessor;
11
- z?: ChannelAccessor;
4
+ <script lang="ts" generics="Datum extends DataRecord">
5
+ interface AreaMarkProps extends BaseMarkProps<Datum>, LinkableMarkProps<Datum> {
6
+ data: Datum[];
7
+ x1?: ChannelAccessor<Datum>;
8
+ x2?: ChannelAccessor<Datum>;
9
+ y1?: ChannelAccessor<Datum>;
10
+ y2?: ChannelAccessor<Datum>;
11
+ z?: ChannelAccessor<Datum>;
12
12
  curve?: CurveName | CurveFactory;
13
13
  tension?: number;
14
14
  sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
15
15
  stack?: Partial<StackOptions>;
16
16
  canvas?: boolean;
17
- } & BaseMarkProps &
18
- LinkableMarkProps;
19
- </script>
17
+ }
20
18
 
21
- <script lang="ts">
22
19
  import Mark from '../Mark.svelte';
23
20
  import GroupMultiple from './helpers/GroupMultiple.svelte';
24
21
  import { getContext } from 'svelte';
@@ -41,23 +38,23 @@
41
38
  ScaledDataRecord,
42
39
  LinkableMarkProps,
43
40
  PlotDefaults
44
- } from '../types.js';
45
- import type { RawValue } from '../types.js';
41
+ } from '../types/index.js';
42
+ import type { RawValue } from '../types/index.js';
46
43
  import type { StackOptions } from '../transforms/stack.js';
47
44
 
48
45
  let markProps: AreaMarkProps = $props();
49
46
 
50
47
  const DEFAULTS = {
51
48
  fill: 'currentColor',
52
- curve: 'linear',
49
+ curve: 'linear' as CurveName,
53
50
  tension: 0,
54
51
  ...getContext<PlotDefaults>('svelteplot/_defaults').area
55
52
  };
56
53
 
57
54
  const {
58
- data,
55
+ data = [{} as Datum],
59
56
  /** the curve */
60
- curve = 'linear',
57
+ curve = 'linear' as CurveName,
61
58
  tension = 0,
62
59
  class: className = '',
63
60
  canvas = false,