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
@@ -0,0 +1,143 @@
1
+ import type { ScaleBand, ScaleLinear, ScaleOrdinal } from 'd3-scale';
2
+ import type { ChannelAccessor, RawValue, ScaledChannelName } from '.';
3
+ export type AxisXAnchor = 'bottom' | 'top' | 'both';
4
+ export type AxisYAnchor = 'left' | 'right' | 'both';
5
+ export type ScaleName = 'x' | 'y' | 'r' | 'color' | 'opacity' | 'length' | 'symbol' | 'fx' | 'fy' | 'projection';
6
+ export type ScaleOptions = {
7
+ /**
8
+ * Override the automatic scale type detection.
9
+ */
10
+ type: ScaleType | 'auto';
11
+ /**
12
+ * Set a custom domain for the scale instead of auto-computing the domain
13
+ * from the mark data channels.
14
+ */
15
+ domain?: RawValue[];
16
+ /**
17
+ * Set a custom range for the scale.
18
+ */
19
+ range?: RawValue[];
20
+ /**
21
+ * Reverse the scale.
22
+ */
23
+ reverse: boolean;
24
+ label?: string;
25
+ interval?: string | number;
26
+ clamp: boolean;
27
+ nice: boolean;
28
+ zero: boolean;
29
+ round: boolean;
30
+ percent: boolean;
31
+ transform?: (d: RawValue) => RawValue;
32
+ /**
33
+ * set the padding for band scales
34
+ */
35
+ padding: number;
36
+ /**
37
+ * set the align for band or point scales
38
+ */
39
+ align: number;
40
+ /**
41
+ * set the inner padding for band scales
42
+ */
43
+ paddingInner?: number;
44
+ /**
45
+ * set the outer padding for band scales
46
+ */
47
+ paddingOuter?: number;
48
+ insetLeft?: number;
49
+ insetRight?: number;
50
+ insetTop?: number;
51
+ insetBottom?: number;
52
+ ticks?: (number | Date)[];
53
+ tickSpacing: number;
54
+ base?: number;
55
+ sort?: ChannelAccessor | ((a: RawValue, b: RawValue) => number) | {
56
+ channel: string;
57
+ order: 'ascending' | 'descending';
58
+ };
59
+ constant?: number;
60
+ };
61
+ export type ColorScaleOptions = ScaleOptions & {
62
+ legend: boolean;
63
+ type: ScaleType | 'categorical' | 'sequential' | 'cyclical' | 'threshold' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
64
+ scheme: string;
65
+ /**
66
+ * fallback color used for null/undefined
67
+ */
68
+ unknown: string;
69
+ /**
70
+ * center value for diverging scales
71
+ */
72
+ pivot: number;
73
+ /**
74
+ * number of colors for quantize and quantile-threshold scales
75
+ */
76
+ n: number;
77
+ interpolate: (d: any) => typeof d;
78
+ /**
79
+ * The tick format for the color scale legend.
80
+ */
81
+ tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
82
+ };
83
+ export type ScaleType = 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
84
+ export type XScaleOptions = ScaleOptions & {
85
+ /**
86
+ * Activate the implicit GridX mark. For more control over the grid styling
87
+ * and layering, add an explicit GridX mark to your plot instead of using the
88
+ * implicit grids.
89
+ */
90
+ grid: boolean;
91
+ /**
92
+ * Controls the position of the implicit AxisX mark, or set to false to disable
93
+ * the implicit AxisX mark. For more control over the axis styling and layering
94
+ * add an explicit AxisX mark to your plot instead of using the implicit axes.
95
+ */
96
+ axis: AxisXAnchor | false;
97
+ /**
98
+ * rotate the axis ticks
99
+ */
100
+ tickRotate: number;
101
+ labelAnchor: 'auto' | 'left' | 'center' | 'right';
102
+ tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
103
+ };
104
+ export type YScaleOptions = ScaleOptions & {
105
+ /**
106
+ * Activate the implicit GridY mark. For more control over the grid styling
107
+ * and layering, add an explicit GridY mark to your plot instead of using the
108
+ * implicit grids.
109
+ */
110
+ grid: boolean;
111
+ /**
112
+ * Controls the position of the implicit AxisY mark, or set to false to disable
113
+ * the implicit AxisY mark. For more control over the axis styling and layering
114
+ * add an explicit AxisY mark to your plot instead of using the implicit axes.
115
+ */
116
+ axis: AxisYAnchor | false;
117
+ tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
118
+ /**
119
+ * rotate the axis ticks
120
+ */
121
+ tickRotate: number;
122
+ labelAnchor: 'auto' | 'bottom' | 'middle' | 'top';
123
+ };
124
+ export type LegendScaleOptions = ScaleOptions & {
125
+ legend: boolean;
126
+ };
127
+ export type PlotScale = {
128
+ type: ScaleType;
129
+ domain: RawValue[];
130
+ range: RawValue[];
131
+ autoTitle?: string;
132
+ /**
133
+ * The number of marks that are using this scale.
134
+ */
135
+ manualActiveMarks: number;
136
+ /**
137
+ * Set of accessors used in channels that are bound to this scale.
138
+ */
139
+ uniqueScaleProps: Set<ChannelAccessor>;
140
+ skip: Map<ScaledChannelName, Set<symbol>>;
141
+ fn: ScaleLinear<RawValue, number> & ScaleBand<RawValue> & ScaleOrdinal<string | Date, number> & ScaleOrdinal<string | Date, string>;
142
+ };
143
+ export type PlotScales = Record<ScaleName, PlotScale>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -1,40 +1,12 @@
1
1
  import type { ScaleBand, ScaleLinear, ScaleOrdinal } from 'd3-scale';
2
- import type { Snippet } from 'svelte';
2
+ import type { ComponentProps, Snippet } from 'svelte';
3
3
  import type { MouseEventHandler } from 'svelte/elements';
4
4
  import type { MarkerShape } from './marks/helpers/Marker.svelte';
5
5
  import type { Writable } from 'svelte/store';
6
6
  import type * as CSS from 'csstype';
7
- import type { AreaMarkProps } from './marks/Area.svelte';
8
- import type { ArrowMarkProps } from './marks/Arrow.svelte';
9
- import type { AxisXMarkProps } from './marks/AxisX.svelte';
10
- import type { AxisYMarkProps } from './marks/AxisY.svelte';
11
- import type { BarXMarkProps } from './marks/BarX.svelte';
12
- import type { CellMarkProps } from './marks/Cell.svelte';
13
- import type { DotMarkProps } from './marks/Dot.svelte';
14
- import type { FrameMarkProps } from './marks/Frame.svelte';
15
- import type { GeoMarkProps } from './marks/Geo.svelte';
16
- import type { GraticuleMarkProps } from './marks/Graticule.svelte';
17
- import type { LineMarkProps } from './marks/Line.svelte';
18
- import type { LinkMarkProps } from './marks/Link.svelte';
19
- import type { RectMarkProps } from './marks/Rect.svelte';
20
- import type { RuleXMarkProps } from './marks/RuleX.svelte';
21
- import type { SphereMarkProps } from './marks/Sphere.svelte';
22
- import type { SpikeMarkProps } from './marks/Spike.svelte';
23
- import type { TextMarkProps } from './marks/Text.svelte';
24
- import type { TickXMarkProps } from './marks/TickX.svelte';
25
- import type { VectorMarkProps } from './marks/Vector.svelte';
26
- import type { BrushMarkProps } from './marks/Brush.svelte';
27
- import type { BrushXMarkProps } from './marks/BrushX.svelte';
28
- import type { BrushYMarkProps } from './marks/BrushY.svelte';
29
- import type { RectXMarkProps } from './marks/RectX.svelte';
30
- import type { RectYMarkProps } from './marks/RectY.svelte';
31
- import type { RuleYMarkProps } from './marks/RuleY.svelte';
32
- import type { TickYMarkProps } from './marks/TickY.svelte';
33
- import type { GridYMarkProps } from './marks/GridY.svelte';
34
- import type { GridXMarkProps } from './marks/GridX.svelte';
35
- import type { PointerMarkProps } from './marks/Pointer.svelte';
36
- import type { BoxXMarkProps } from './marks/BoxX.svelte';
37
- import type { BoxYMarkProps } from './marks/BoxY.svelte';
7
+ import type { Area, AreaX, AreaY, Arrow, AxisX, AxisY, BarX, BarY, BoxX, BoxY, Brush, BrushX, BrushY, Cell, Dot, Frame, Geo, Graticule, GridX, GridY, Line, Link, Pointer, Rect, RectX, RectY, RuleX, RuleY, Sphere, Spike, Text, TickX, TickY, Vector } from './marks';
8
+ import type { GeoProjection } from 'd3-geo';
9
+ import type { Clip } from './helpers/projection';
38
10
  export type MarkType = 'area' | 'arrow' | 'axisX' | 'axisY' | 'barX' | 'barY' | 'cell' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY';
39
11
  export type ScaleName = 'x' | 'y' | 'r' | 'color' | 'opacity' | 'length' | 'symbol' | 'fx' | 'fy' | 'projection';
40
12
  export type ScaleType = 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
@@ -43,7 +15,7 @@ export type Mark<T> = {
43
15
  type: MarkType;
44
16
  channels: ScaledChannelName[];
45
17
  scales: Set<ScaleName>;
46
- data: DataRecord[];
18
+ data: DataRecord<T>[];
47
19
  options: T;
48
20
  };
49
21
  export type ScaledChannelName = 'fill' | 'fillOpacity' | 'opacity' | 'r' | 'length' | 'stroke' | 'strokeOpacity' | 'symbol' | 'fx' | 'fy' | 'x' | 'x1' | 'x2' | 'y' | 'y1' | 'y2';
@@ -121,6 +93,10 @@ export type ColorScaleOptions = ScaleOptions & {
121
93
  */
122
94
  n: number;
123
95
  interpolate: (d: any) => typeof d;
96
+ /**
97
+ * The tick format for the color scale legend.
98
+ */
99
+ tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
124
100
  };
125
101
  export type AxisXAnchor = 'bottom' | 'top' | 'both';
126
102
  export type AxisYAnchor = 'left' | 'right' | 'both';
@@ -142,7 +118,7 @@ export type XScaleOptions = ScaleOptions & {
142
118
  */
143
119
  tickRotate: number;
144
120
  labelAnchor: 'auto' | 'left' | 'center' | 'right';
145
- tickFormat: 'auto' | string | ((d: RawValue) => string);
121
+ tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
146
122
  };
147
123
  export type YScaleOptions = ScaleOptions & {
148
124
  /**
@@ -157,7 +133,7 @@ export type YScaleOptions = ScaleOptions & {
157
133
  * add an explicit AxisY mark to your plot instead of using the implicit axes.
158
134
  */
159
135
  axis: AxisYAnchor | false;
160
- tickFormat: string | ((d: RawValue) => string);
136
+ tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
161
137
  /**
162
138
  * rotate the axis ticks
163
139
  */
@@ -247,7 +223,18 @@ export type PlotOptions = {
247
223
  /**
248
224
  * Geo-projection
249
225
  */
250
- projection: string | null;
226
+ projection: string | null | {
227
+ type?: string;
228
+ rotate?: [number, number] | [number, number, number];
229
+ domain?: object;
230
+ inset?: number;
231
+ clip?: Clip;
232
+ } | {
233
+ type: (d: {
234
+ width: number;
235
+ height: number;
236
+ }) => GeoProjection;
237
+ };
251
238
  /**
252
239
  * if not null, computes a default height such that a variation of one
253
240
  * unit in the x dimension is represented by the corresponding number
@@ -262,7 +249,7 @@ export type PlotOptions = {
262
249
  * The data to facet by. Turns on automatic faceting for all marks that
263
250
  * use the exact same data (===)
264
251
  */
265
- data: DataRecord[];
252
+ data: DataRecord<any>[];
266
253
  x: ChannelAccessor;
267
254
  y: ChannelAccessor;
268
255
  }>;
@@ -332,17 +319,17 @@ export type PlotOptions = {
332
319
  css: (d: string) => string | undefined;
333
320
  };
334
321
  export type GenericMarkOptions = Record<string | symbol, any>;
335
- export type DataRecord = Record<string | symbol, RawValue> & {
322
+ export type DataRecord<T = Record<string | symbol, RawValue>> = T & {
336
323
  ___orig___?: RawValue | [RawValue, RawValue];
337
324
  };
338
- export type ResolvedDataRecord = Partial<Record<ScaledChannelName, any>> & {
339
- datum: DataRecord;
325
+ export type ResolvedDataRecord<T = Record<string | symbol, RawValue>> = Partial<Record<ScaledChannelName, any>> & {
326
+ datum: DataRecord<T>;
340
327
  };
341
- export type ScaledDataRecord = Partial<Record<ScaledChannelName, number | string | boolean | undefined>> & {
342
- datum: DataRecord;
328
+ export type ScaledDataRecord<T = Record<string | symbol, RawValue>> = Partial<Record<ScaledChannelName, number | string | boolean | undefined>> & {
329
+ datum: DataRecord<T>;
343
330
  valid: Boolean;
344
331
  };
345
- export type DataRow = DataRecord | RawValue | [number, number] | null;
332
+ export type DataRow<T = Record<string | symbol, RawValue>> = DataRecord<T> | RawValue | [number, number] | null;
346
333
  export type PlotScale = {
347
334
  type: ScaleType;
348
335
  domain: RawValue[];
@@ -379,8 +366,14 @@ export type MarkerOptions = {
379
366
  marker?: boolean | MarkerShape | Snippet;
380
367
  };
381
368
  export type PlotScales = Record<ScaleName, PlotScale>;
382
- export type ChannelAccessor = RawValue | ((d: DataRow) => RawValue) | null | undefined;
383
- export type ConstantAccessor<T> = T | ((d: DataRow) => T) | null | undefined;
369
+ export type ChannelAccessor<T = Record<string | symbol, RawValue>> = ChannelValue<T> | {
370
+ /** the channel value */
371
+ value: ChannelValue<T>;
372
+ /** you can bypass the scale by passing null */
373
+ scale: boolean | null;
374
+ };
375
+ export type ChannelValue<T = Record<string | symbol, RawValue>> = RawValue | keyof T | ((d: T) => RawValue) | null | undefined;
376
+ export type ConstantAccessor<T, D = Record<string | symbol, RawValue>> = T | ((d: D) => T) | null | undefined;
384
377
  export type PlotState = {
385
378
  width: number;
386
379
  height: number;
@@ -465,7 +458,7 @@ type FacetState = {
465
458
  /**
466
459
  * Test if the given data record is visible in the current facet.
467
460
  */
468
- type TestFacetFunction = (datum: DataRecord, channels: Record<ChannelName, ChannelAccessor>) => boolean;
461
+ type TestFacetFunction = (datum: DataRecord<any>, channels: Record<ChannelName, ChannelAccessor>) => boolean;
469
462
  export type FacetContext = {
470
463
  /**
471
464
  * Returns a stateful function that tests whether a specific data
@@ -474,65 +467,65 @@ export type FacetContext = {
474
467
  getTestFacet: () => TestFacetFunction;
475
468
  getFacetState: () => FacetState;
476
469
  };
477
- export type LinkableMarkProps = {
470
+ export type LinkableMarkProps<T> = {
478
471
  /**
479
472
  * if set, the mark element will be wrapped in a <a> link element
480
473
  */
481
- href?: ConstantAccessor<string>;
474
+ href?: ConstantAccessor<string, T>;
482
475
  /**
483
476
  * the relationship of the target object to the link object (e.g. "noopener")
484
477
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#rel
485
478
  */
486
- rel?: ConstantAccessor<string>;
479
+ rel?: ConstantAccessor<string, T>;
487
480
  /**
488
481
  * the link target mime type, e.g. "text/csv"
489
482
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#type
490
483
  */
491
- type?: ConstantAccessor<string>;
484
+ type?: ConstantAccessor<string, T>;
492
485
  /**
493
486
  * the target of the link, e.g. "_blank" or "_self"
494
487
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#target
495
488
  */
496
- target?: ConstantAccessor<'_self' | '_blank' | '_parent' | '_top' | string>;
489
+ target?: ConstantAccessor<'_self' | '_blank' | '_parent' | '_top' | string, T>;
497
490
  /**
498
491
  * if set to true, the link will be downloaded instead of navigating to it
499
492
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download
500
493
  */
501
- download?: ConstantAccessor<boolean>;
502
- [key: `data-sveltekit-${string}`]: string | boolean;
494
+ download?: ConstantAccessor<boolean, T>;
495
+ [key: `data-sveltekit-${string}`]: string | boolean | undefined;
503
496
  };
504
- export type BaseMarkProps = Partial<{
497
+ export type BaseMarkProps<T> = Partial<{
505
498
  /**
506
499
  * Filter the data without modifying the inferred scales
507
500
  */
508
- filter?: ConstantAccessor<boolean>;
501
+ filter?: ConstantAccessor<boolean, T>;
509
502
  facet?: 'auto' | 'include' | 'exclude';
510
- fx: ChannelAccessor;
511
- fy: ChannelAccessor;
512
- dx: ConstantAccessor<number>;
513
- dy: ConstantAccessor<number>;
514
- fill: ConstantAccessor<string>;
515
- fillOpacity: ConstantAccessor<number>;
516
- sort: string | ConstantAccessor<RawValue> | ((a: RawValue, b: RawValue) => number) | {
503
+ fx: ChannelAccessor<T>;
504
+ fy: ChannelAccessor<T>;
505
+ dx: ConstantAccessor<number, T>;
506
+ dy: ConstantAccessor<number, T>;
507
+ fill: ChannelAccessor<T>;
508
+ fillOpacity: ConstantAccessor<number, T>;
509
+ sort: string | ConstantAccessor<RawValue, T> | ((a: RawValue, b: RawValue) => number) | {
517
510
  /** sort data using an already defined channel */
518
511
  channel: string;
519
512
  /** sort order */
520
513
  order?: 'ascending' | 'descending';
521
514
  };
522
- stroke: ConstantAccessor<string>;
523
- strokeWidth: ConstantAccessor<number>;
524
- strokeOpacity: ConstantAccessor<number>;
525
- strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin>;
526
- strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap>;
527
- strokeMiterlimit: ConstantAccessor<number>;
528
- opacity: ConstantAccessor<number>;
529
- strokeDasharray: ConstantAccessor<string>;
530
- strokeDashoffset: ConstantAccessor<number>;
531
- mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode>;
515
+ stroke: ChannelAccessor<T>;
516
+ strokeWidth: ConstantAccessor<number, T>;
517
+ strokeOpacity: ConstantAccessor<number, T>;
518
+ strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin, T>;
519
+ strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap, T>;
520
+ strokeMiterlimit: ConstantAccessor<number, T>;
521
+ opacity: ChannelAccessor<T>;
522
+ strokeDasharray: ConstantAccessor<string, T>;
523
+ strokeDashoffset: ConstantAccessor<number, T>;
524
+ mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, T>;
532
525
  clipPath: string;
533
- imageFilter: ConstantAccessor<string>;
534
- shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering>;
535
- paintOrder: ConstantAccessor<string>;
526
+ imageFilter: ConstantAccessor<string, T>;
527
+ shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, T>;
528
+ paintOrder: ConstantAccessor<string, T>;
536
529
  onclick?: MouseEventHandler<SVGPathElement>;
537
530
  ondblclick?: MouseEventHandler<SVGPathElement>;
538
531
  onmouseup?: MouseEventHandler<SVGPathElement>;
@@ -567,7 +560,7 @@ export type BaseMarkProps = Partial<{
567
560
  * if you want to give your mark element an extra CSS class
568
561
  */
569
562
  class: string | null;
570
- cursor: ConstantAccessor<CSS.Property.Cursor>;
563
+ cursor: ConstantAccessor<CSS.Property.Cursor, T>;
571
564
  }>;
572
565
  export type BorderRadius = number | {
573
566
  topLeft?: number;
@@ -575,20 +568,20 @@ export type BorderRadius = number | {
575
568
  bottomRight?: number;
576
569
  bottomLeft?: number;
577
570
  };
578
- export type BaseRectMarkProps = {
579
- inset?: ConstantAccessor<number>;
580
- insetLeft?: ConstantAccessor<number>;
581
- insetTop?: ConstantAccessor<number>;
582
- insetRight?: ConstantAccessor<number>;
583
- insetBottom?: ConstantAccessor<number>;
571
+ export type BaseRectMarkProps<T> = {
572
+ inset?: ConstantAccessor<number, T>;
573
+ insetLeft?: ConstantAccessor<number, T>;
574
+ insetTop?: ConstantAccessor<number, T>;
575
+ insetRight?: ConstantAccessor<number, T>;
576
+ insetBottom?: ConstantAccessor<number, T>;
584
577
  borderRadius?: BorderRadius;
585
578
  };
586
- export type Channels = Record<string, ChannelAccessor | ConstantAccessor<string | number | boolean | symbol>>;
587
- export type TransformArg<K> = Channels & BaseMarkProps & {
588
- data: K[];
579
+ export type Channels<T> = Record<string, ChannelAccessor<T> | ConstantAccessor<string | number | boolean | symbol, T>>;
580
+ export type TransformArg<T> = Channels<T> & BaseMarkProps<T> & {
581
+ data: T[];
589
582
  };
590
- export type MapArg<K> = Channels & {
591
- data: K[];
583
+ export type MapArg<T> = Channels<T> & {
584
+ data: T[];
592
585
  };
593
586
  export type TransformArgsRow = Partial<Channels> & {
594
587
  data: DataRow[];
@@ -660,177 +653,177 @@ export type PlotDefaults = {
660
653
  /**
661
654
  * default props for area marks, applied to area, areaX, and areaY marks
662
655
  */
663
- area: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
656
+ area: Partial<Omit<ComponentProps<typeof Area>, IgnoreDefaults>>;
664
657
  /**
665
658
  * default props for areaX marks
666
659
  */
667
- areaX: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
660
+ areaX: Partial<Omit<ComponentProps<typeof AreaX>, IgnoreDefaults>>;
668
661
  /**
669
662
  * default props for areaY marks
670
663
  */
671
- areaY: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
664
+ areaY: Partial<Omit<ComponentProps<typeof AreaY>, IgnoreDefaults>>;
672
665
  /**
673
666
  * default props for arrow marks
674
667
  */
675
- arrow: Partial<Omit<ArrowMarkProps, IgnoreDefaults>>;
668
+ arrow: Partial<Omit<ComponentProps<typeof Arrow>, IgnoreDefaults>>;
676
669
  /**
677
670
  * default props for axis marks, applied to both axisX and axisY marks
678
671
  */
679
- axis: Partial<Omit<AxisXMarkProps, 'data' | 'facet' | ChannelName | 'facetAnchor' | 'labelAnchor' | 'anchor'> & {
672
+ axis: Partial<Omit<ComponentProps<typeof AxisX>, 'data' | 'facet' | ChannelName | 'facetAnchor' | 'labelAnchor' | 'anchor'> & {
680
673
  implicit: boolean;
681
674
  }>;
682
675
  /**
683
676
  * default props for axisX marks
684
677
  */
685
- axisX: Partial<Omit<AxisXMarkProps, IgnoreDefaults> & {
678
+ axisX: Partial<Omit<ComponentProps<typeof AxisX>, IgnoreDefaults> & {
686
679
  implicit: boolean;
687
680
  }>;
688
681
  /**
689
682
  * default props for axisY marks
690
683
  */
691
- axisY: Partial<Omit<AxisYMarkProps, IgnoreDefaults> & {
684
+ axisY: Partial<Omit<ComponentProps<typeof AxisY>, IgnoreDefaults> & {
692
685
  implicit: boolean;
693
686
  }>;
694
687
  /**
695
688
  * default props for bar marks, applied to both barX and barY marks
696
689
  */
697
- bar: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
690
+ bar: Partial<Omit<ComponentProps<typeof BarX>, IgnoreDefaults>>;
698
691
  /**
699
692
  * default props for barX marks
700
693
  */
701
- barX: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
694
+ barX: Partial<Omit<ComponentProps<typeof BarX>, IgnoreDefaults>>;
702
695
  /**
703
696
  * default props for barY marks
704
697
  */
705
- barY: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
698
+ barY: Partial<Omit<ComponentProps<typeof BarY>, IgnoreDefaults>>;
706
699
  /**
707
700
  * default props for box marks, applied to boxX and boxY marks
708
701
  */
709
- box: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
702
+ box: Partial<Omit<ComponentProps<typeof BoxX>, IgnoreDefaults>>;
710
703
  /**
711
704
  * default props for boxX marks
712
705
  */
713
- boxX: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
706
+ boxX: Partial<Omit<ComponentProps<typeof BoxX>, IgnoreDefaults>>;
714
707
  /**
715
708
  * default props for boxY marks
716
709
  */
717
- boxY: Partial<Omit<BoxYMarkProps, IgnoreDefaults>>;
710
+ boxY: Partial<Omit<ComponentProps<typeof BoxY>, IgnoreDefaults>>;
718
711
  /**
719
712
  * default props for brush marks, applied to brush, brushX and brushY marks
720
713
  */
721
- brush: Partial<Omit<BrushMarkProps, IgnoreDefaults | 'limitDimension'>>;
714
+ brush: Partial<Omit<ComponentProps<typeof Brush>, IgnoreDefaults | 'limitDimension'>>;
722
715
  /**
723
716
  * default props for brushX marks
724
717
  */
725
- brushX: Partial<Omit<BrushXMarkProps, IgnoreDefaults>>;
718
+ brushX: Partial<Omit<ComponentProps<typeof BrushX>, IgnoreDefaults>>;
726
719
  /**
727
720
  * default props for brushY marks
728
721
  */
729
- brushY: Partial<Omit<BrushYMarkProps, IgnoreDefaults>>;
722
+ brushY: Partial<Omit<ComponentProps<typeof BrushY>, IgnoreDefaults>>;
730
723
  /**
731
724
  * default props for cell marks
732
725
  */
733
- cell: Partial<Omit<CellMarkProps, IgnoreDefaults>>;
726
+ cell: Partial<Omit<ComponentProps<typeof Cell>, IgnoreDefaults>>;
734
727
  /**
735
728
  * default props for dot marks
736
729
  */
737
- dot: Partial<Omit<DotMarkProps, IgnoreDefaults>>;
730
+ dot: Partial<Omit<ComponentProps<typeof Dot>, IgnoreDefaults>>;
738
731
  /**
739
732
  * default props for frame marks
740
733
  */
741
- frame: Partial<FrameMarkProps & {
734
+ frame: Partial<ComponentProps<typeof Frame> & {
742
735
  implicit: boolean;
743
736
  }>;
744
737
  /**
745
738
  * default props for geo marks
746
739
  */
747
- geo: Partial<Omit<GeoMarkProps, IgnoreDefaults>>;
740
+ geo: Partial<Omit<ComponentProps<typeof Geo>, IgnoreDefaults>>;
748
741
  /**
749
742
  * default props for graticule marks
750
743
  */
751
- graticule: Partial<Omit<GraticuleMarkProps, IgnoreDefaults>>;
744
+ graticule: Partial<Omit<ComponentProps<typeof Graticule>, IgnoreDefaults>>;
752
745
  /**
753
746
  * default props for grid marks, applied to both gridX and gridY marks
754
747
  */
755
- grid: Partial<Omit<GridXMarkProps, IgnoreDefaults> & {
748
+ grid: Partial<Omit<ComponentProps<typeof GridX>, IgnoreDefaults> & {
756
749
  implicit: boolean;
757
750
  }>;
758
751
  /**
759
752
  * default props for gridX marks
760
753
  */
761
- gridX: Partial<Omit<GridXMarkProps, IgnoreDefaults> & {
754
+ gridX: Partial<Omit<ComponentProps<typeof GridX>, IgnoreDefaults> & {
762
755
  implicit: boolean;
763
756
  }>;
764
757
  /**
765
758
  * default props for gridY marks
766
759
  */
767
- gridY: Partial<Omit<GridYMarkProps, IgnoreDefaults> & {
760
+ gridY: Partial<Omit<ComponentProps<typeof GridY>, IgnoreDefaults> & {
768
761
  implicit: boolean;
769
762
  }>;
770
763
  /**
771
764
  * default props for line marks
772
765
  */
773
- line: Partial<Omit<LineMarkProps, IgnoreDefaults>>;
766
+ line: Partial<Omit<ComponentProps<typeof Line>, IgnoreDefaults>>;
774
767
  /**
775
768
  * default props for link marks
776
769
  */
777
- link: Partial<Omit<LinkMarkProps, IgnoreDefaults>>;
770
+ link: Partial<Omit<ComponentProps<typeof Link>, IgnoreDefaults>>;
778
771
  /**
779
772
  * default props for pointer marks
780
773
  */
781
- pointer: Partial<Omit<PointerMarkProps, IgnoreDefaults>>;
774
+ pointer: Partial<Omit<ComponentProps<typeof Pointer>, IgnoreDefaults>>;
782
775
  /**
783
776
  * default props for rect marks, applied to rect and rectX marks
784
777
  */
785
- rect: Partial<Omit<RectMarkProps, IgnoreDefaults>>;
778
+ rect: Partial<Omit<ComponentProps<typeof Rect>, IgnoreDefaults>>;
786
779
  /**
787
780
  * default props for rectX marks
788
781
  */
789
- rectX: Partial<Omit<RectXMarkProps, IgnoreDefaults>>;
782
+ rectX: Partial<Omit<ComponentProps<typeof RectX>, IgnoreDefaults>>;
790
783
  /**
791
784
  * default props for rectY marks
792
785
  */
793
- rectY: Partial<Omit<RectYMarkProps, IgnoreDefaults>>;
786
+ rectY: Partial<Omit<ComponentProps<typeof RectY>, IgnoreDefaults>>;
794
787
  /**
795
788
  * default props for rule marks
796
789
  */
797
- rule: Partial<Omit<RuleXMarkProps, IgnoreDefaults>>;
790
+ rule: Partial<Omit<ComponentProps<typeof RuleX>, IgnoreDefaults>>;
798
791
  /**
799
792
  * default props for rule marks
800
793
  */
801
- ruleX: Partial<Omit<RuleXMarkProps, IgnoreDefaults>>;
794
+ ruleX: Partial<Omit<ComponentProps<typeof RuleX>, IgnoreDefaults>>;
802
795
  /**
803
796
  * default props for rule marks
804
797
  */
805
- ruleY: Partial<Omit<RuleYMarkProps, IgnoreDefaults>>;
798
+ ruleY: Partial<Omit<ComponentProps<typeof RuleY>, IgnoreDefaults>>;
806
799
  /**
807
800
  * default props for sphere marks
808
801
  */
809
- sphere: Partial<SphereMarkProps>;
802
+ sphere: Partial<ComponentProps<typeof Sphere>>;
810
803
  /**
811
804
  * default props for spike marks
812
805
  */
813
- spike: Partial<Omit<SpikeMarkProps, IgnoreDefaults>>;
806
+ spike: Partial<Omit<ComponentProps<typeof Spike>, IgnoreDefaults>>;
814
807
  /**
815
808
  * default props for text marks
816
809
  */
817
- text: Partial<Omit<TextMarkProps, IgnoreDefaults>>;
810
+ text: Partial<Omit<ComponentProps<typeof Text>, IgnoreDefaults>>;
818
811
  /**
819
812
  * default props for tick marks, applied to tickX and tickY marks
820
813
  */
821
- tick: Partial<Omit<TickXMarkProps, IgnoreDefaults>>;
814
+ tick: Partial<Omit<ComponentProps<typeof TickX>, IgnoreDefaults>>;
822
815
  /**
823
816
  * default props for tickX marks
824
817
  */
825
- tickX: Partial<Omit<TickXMarkProps, IgnoreDefaults>>;
818
+ tickX: Partial<Omit<ComponentProps<typeof TickX>, IgnoreDefaults>>;
826
819
  /**
827
820
  * default props for tickY marks
828
821
  */
829
- tickY: Partial<Omit<TickYMarkProps, IgnoreDefaults>>;
822
+ tickY: Partial<Omit<ComponentProps<typeof TickY>, IgnoreDefaults>>;
830
823
  /**
831
824
  * default props for vector marks
832
825
  */
833
- vector: Partial<Omit<VectorMarkProps, IgnoreDefaults>>;
826
+ vector: Partial<Omit<ComponentProps<typeof Vector>, IgnoreDefaults>>;
834
827
  };
835
828
  export type MapIndexObject = {
836
829
  mapIndex: (I: number[], S: RawValue[], T: RawValue[]) => void;