svelteplot 0.2.9 → 0.2.10-pr-110.1

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 (83) hide show
  1. package/README.md +1 -1
  2. package/dist/Mark.svelte +5 -4
  3. package/dist/Plot.svelte +3 -2
  4. package/dist/core/Plot.svelte +37 -20
  5. package/dist/helpers/colors.d.ts +1 -1
  6. package/dist/helpers/index.d.ts +2 -2
  7. package/dist/helpers/scales.d.ts +1 -1
  8. package/dist/helpers/scales.js +9 -1
  9. package/dist/helpers/typeChecks.d.ts +4 -4
  10. package/dist/marks/Area.svelte +31 -29
  11. package/dist/marks/AreaX.svelte +7 -3
  12. package/dist/marks/AreaX.svelte.d.ts +1 -6
  13. package/dist/marks/AreaY.svelte +7 -2
  14. package/dist/marks/AreaY.svelte.d.ts +1 -9
  15. package/dist/marks/Arrow.svelte +24 -7
  16. package/dist/marks/AxisX.svelte +24 -21
  17. package/dist/marks/AxisX.svelte.d.ts +3 -4
  18. package/dist/marks/AxisY.svelte +23 -20
  19. package/dist/marks/AxisY.svelte.d.ts +3 -4
  20. package/dist/marks/BarX.svelte +18 -2
  21. package/dist/marks/BarX.svelte.d.ts +2 -2
  22. package/dist/marks/BarY.svelte +18 -3
  23. package/dist/marks/BarY.svelte.d.ts +2 -2
  24. package/dist/marks/BollingerX.svelte.d.ts +1 -1
  25. package/dist/marks/BollingerY.svelte.d.ts +1 -1
  26. package/dist/marks/BoxX.svelte +23 -9
  27. package/dist/marks/BoxX.svelte.d.ts +3 -2
  28. package/dist/marks/BoxY.svelte +20 -10
  29. package/dist/marks/BoxY.svelte.d.ts +3 -3
  30. package/dist/marks/Brush.svelte +30 -10
  31. package/dist/marks/BrushX.svelte +9 -3
  32. package/dist/marks/BrushX.svelte.d.ts +1 -1
  33. package/dist/marks/BrushY.svelte +9 -3
  34. package/dist/marks/BrushY.svelte.d.ts +1 -1
  35. package/dist/marks/Cell.svelte +17 -2
  36. package/dist/marks/Cell.svelte.d.ts +2 -2
  37. package/dist/marks/ColorLegend.svelte +3 -2
  38. package/dist/marks/Dot.svelte +29 -24
  39. package/dist/marks/Dot.svelte.d.ts +2 -2
  40. package/dist/marks/Frame.svelte +24 -4
  41. package/dist/marks/Frame.svelte.d.ts +2 -2
  42. package/dist/marks/Geo.svelte +41 -37
  43. package/dist/marks/Geo.svelte.d.ts +4 -2
  44. package/dist/marks/Graticule.svelte +14 -5
  45. package/dist/marks/GridX.svelte +16 -2
  46. package/dist/marks/GridY.svelte +16 -2
  47. package/dist/marks/Line.svelte +22 -8
  48. package/dist/marks/Link.svelte +12 -4
  49. package/dist/marks/Pointer.svelte +12 -3
  50. package/dist/marks/Rect.svelte +17 -2
  51. package/dist/marks/Rect.svelte.d.ts +2 -2
  52. package/dist/marks/RectX.svelte +16 -2
  53. package/dist/marks/RectY.svelte +16 -2
  54. package/dist/marks/RuleX.svelte +15 -2
  55. package/dist/marks/RuleY.svelte +15 -2
  56. package/dist/marks/Sphere.svelte +17 -4
  57. package/dist/marks/Sphere.svelte.d.ts +3 -58
  58. package/dist/marks/Text.svelte +22 -4
  59. package/dist/marks/TickX.svelte +15 -2
  60. package/dist/marks/TickY.svelte +15 -2
  61. package/dist/marks/Vector.svelte +13 -5
  62. package/dist/marks/helpers/Anchor.svelte +37 -0
  63. package/dist/marks/helpers/Anchor.svelte.d.ts +15 -0
  64. package/dist/marks/helpers/BaseAxisX.svelte +59 -53
  65. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -0
  66. package/dist/marks/helpers/BaseAxisY.svelte +24 -18
  67. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -0
  68. package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
  69. package/dist/marks/helpers/RectPath.svelte +33 -30
  70. package/dist/marks/helpers/Regression.svelte +1 -1
  71. package/dist/transforms/bollinger.d.ts +1 -8
  72. package/dist/transforms/centroid.d.ts +1 -8
  73. package/dist/transforms/group.d.ts +4 -12
  74. package/dist/transforms/interval.d.ts +2 -6
  75. package/dist/transforms/map.d.ts +4 -10
  76. package/dist/transforms/normalize.d.ts +2 -6
  77. package/dist/transforms/select.d.ts +7 -21
  78. package/dist/transforms/sort.d.ts +5 -17
  79. package/dist/transforms/sort.js +23 -13
  80. package/dist/transforms/window.d.ts +2 -14
  81. package/dist/types.d.ts +251 -78
  82. package/dist/ui/ExamplesGrid.svelte +1 -1
  83. package/package.json +121 -120
@@ -1,61 +1,6 @@
1
- import { type BaseMarkProps } from '../types.js';
2
- export type SphereMarkProps = BaseMarkProps;
1
+ import { type BaseMarkProps, type LinkableMarkProps } from '../types.js';
2
+ export type SphereMarkProps = BaseMarkProps & LinkableMarkProps;
3
3
  /** Geo mark with Sphere geometry object */
4
- declare const Sphere: import("svelte").Component<Partial<{
5
- filter?: import("../types.js").ConstantAccessor<boolean>;
6
- facet?: "auto" | "include" | "exclude";
7
- fx: import("../types.js").ChannelAccessor;
8
- fy: import("../types.js").ChannelAccessor;
9
- dx: import("../types.js").ConstantAccessor<number>;
10
- dy: import("../types.js").ConstantAccessor<number>;
11
- fill: import("../types.js").ConstantAccessor<string>;
12
- fillOpacity: import("../types.js").ConstantAccessor<number>;
13
- stroke: import("../types.js").ConstantAccessor<string>;
14
- strokeWidth: import("../types.js").ConstantAccessor<number>;
15
- strokeOpacity: import("../types.js").ConstantAccessor<number>;
16
- strokeLinejoin: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin>;
17
- strokeLinecap: import("../types.js").ConstantAccessor<import("csstype").Property.StrokeLinecap>;
18
- strokeMiterlimit: import("../types.js").ConstantAccessor<number>;
19
- opacity: import("../types.js").ConstantAccessor<number>;
20
- strokeDasharray: import("../types.js").ConstantAccessor<string>;
21
- strokeDashoffset: import("../types.js").ConstantAccessor<number>;
22
- mixBlendMode: import("../types.js").ConstantAccessor<import("csstype").Property.MixBlendMode>;
23
- clipPath: string;
24
- imageFilter: import("../types.js").ConstantAccessor<string>;
25
- shapeRendering: import("../types.js").ConstantAccessor<import("csstype").Property.ShapeRendering>;
26
- paintOrder: import("../types.js").ConstantAccessor<string>;
27
- onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
28
- ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
29
- onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
30
- onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
31
- onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
32
- onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
33
- onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
- onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- class: string | null;
58
- cursor: import("../types.js").ConstantAccessor<import("csstype").Property.Cursor>;
59
- }>, {}, "">;
4
+ declare const Sphere: import("svelte").Component<any, {}, "">;
60
5
  type Sphere = ReturnType<typeof Sphere>;
61
6
  export default Sphere;
@@ -39,13 +39,30 @@
39
39
  DataRecord,
40
40
  BaseMarkProps,
41
41
  ConstantAccessor,
42
- ChannelAccessor
42
+ ChannelAccessor,
43
+ PlotDefaults
43
44
  } from '../types.js';
44
45
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
45
46
  import Mark from '../Mark.svelte';
46
47
  import { sort } from '../index.js';
47
48
 
48
- let { data = [{}], class: className = null, ...options }: TextMarkProps = $props();
49
+ const DEFAULTS = {
50
+ fontSize: 12,
51
+ fontWeight: 500,
52
+ strokeWidth: 1.6,
53
+ ...getContext<PlotDefaults>('svelteplot/_defaults').text
54
+ };
55
+
56
+ let markProps: TextMarkProps = $props();
57
+
58
+ const {
59
+ data = [{}],
60
+ class: className = '',
61
+ ...options
62
+ }: TextMarkProps = $derived({
63
+ ...DEFAULTS,
64
+ ...markProps
65
+ });
49
66
 
50
67
  const { getPlotState } = getContext<PlotContext>('svelteplot');
51
68
  let plot = $derived(getPlotState());
@@ -54,7 +71,7 @@
54
71
  bottom: 'auto',
55
72
  middle: 'central',
56
73
  top: 'hanging'
57
- };
74
+ } as const;
58
75
 
59
76
  const args = $derived(
60
77
  sort({
@@ -77,9 +94,10 @@
77
94
  'strokeOpacity',
78
95
  'fillOpacity'
79
96
  ]}
97
+ required={['x', 'y']}
80
98
  {...args}>
81
99
  {#snippet children({ mark, scaledData, usedScales })}
82
- <GroupMultiple class="text {className || null}" length={className ? 2 : args.data.length}>
100
+ <GroupMultiple class="text {className}" length={className ? 2 : args.data.length}>
83
101
  {#each scaledData as d, i (i)}
84
102
  {#if d.valid}
85
103
  {@const title = resolveProp(args.title, d.datum, '')}
@@ -31,7 +31,8 @@
31
31
  BaseMarkProps,
32
32
  ChannelAccessor,
33
33
  DataRow,
34
- FacetContext
34
+ FacetContext,
35
+ PlotDefaults
35
36
  } from '../types.js';
36
37
  import { recordizeX } from '../index.js';
37
38
  import { projectX, projectY } from '../helpers/scales.js';
@@ -41,7 +42,19 @@
41
42
  const { getPlotState } = getContext<PlotContext>('svelteplot');
42
43
  let plot = $derived(getPlotState());
43
44
 
44
- let { data = [{}], ...options }: TickXMarkProps = $props();
45
+ let markProps: TickXMarkProps = $props();
46
+ const DEFAULTS = {
47
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tick,
48
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tickX
49
+ };
50
+ const {
51
+ data = [{}],
52
+ class: className = '',
53
+ ...options
54
+ }: TickXMarkProps = $derived({
55
+ ...DEFAULTS,
56
+ ...markProps
57
+ });
45
58
 
46
59
  let args = $derived(recordizeX({ data, ...options }, { withIndex: false }));
47
60
 
@@ -32,7 +32,8 @@
32
32
  ChannelAccessor,
33
33
  DataRow,
34
34
  FacetContext,
35
- ConstantAccessor
35
+ ConstantAccessor,
36
+ PlotDefaults
36
37
  } from '../types.js';
37
38
  import { recordizeY } from '../index.js';
38
39
  import { projectX, projectY } from '../helpers/scales.js';
@@ -42,7 +43,19 @@
42
43
  const { getPlotState } = getContext<PlotContext>('svelteplot');
43
44
  let plot = $derived(getPlotState());
44
45
 
45
- let { data = [{}], ...options }: TickYMarkProps = $props();
46
+ let markProps: TickYMarkProps = $props();
47
+ const DEFAULTS = {
48
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tick,
49
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tickY
50
+ };
51
+ const {
52
+ data = [{}],
53
+ class: className = '',
54
+ ...options
55
+ }: TickYMarkProps = $derived({
56
+ ...DEFAULTS,
57
+ ...markProps
58
+ });
46
59
 
47
60
  let args = $derived(recordizeY({ data, ...options }, { withIndex: false }));
48
61
 
@@ -9,7 +9,8 @@
9
9
  BaseMarkProps,
10
10
  ConstantAccessor,
11
11
  ChannelAccessor,
12
- FacetContext
12
+ FacetContext,
13
+ PlotDefaults
13
14
  } from '../types.js';
14
15
 
15
16
  type D3Path = ReturnType<typeof import('d3-path').path>;
@@ -53,19 +54,26 @@
53
54
  const defaultRadius = 3.5;
54
55
 
55
56
  // The size of the arrowhead is proportional to its length, but we still allow
56
- // the relative size of the head to be controlled via the marks width option;
57
+ // the relative size of the head to be controlled via the mark's width option;
57
58
  // doubling the default radius will produce an arrowhead that is twice as big.
58
- // That said, well probably want a arrow with a fixed head size, too.
59
+ // That said, we'll probably want a arrow with a fixed head size, too.
59
60
  const wingRatio = defaultRadius * 5;
60
61
 
61
- let {
62
+ let markProps: VectorMarkProps = $props();
63
+ const DEFAULTS = {
64
+ ...getContext<PlotDefaults>('svelteplot/_defaults').vector
65
+ };
66
+ const {
62
67
  data = [{}],
63
68
  canvas,
64
69
  shape = 'arrow',
65
70
  anchor = 'middle',
66
71
  r = defaultRadius,
67
72
  ...options
68
- }: VectorMarkProps = $props();
73
+ }: VectorMarkProps = $derived({
74
+ ...DEFAULTS,
75
+ ...markProps
76
+ });
69
77
 
70
78
  const { getPlotState } = getContext<PlotContext>('svelteplot');
71
79
  const plot = $derived(getPlotState());
@@ -0,0 +1,37 @@
1
+ <script>
2
+ import { resolveProp } from '../../helpers/resolve';
3
+
4
+ let { datum = {}, options = {}, children } = $props();
5
+
6
+ const href = $derived(resolveProp(options.href, datum, null));
7
+ const target = $derived(resolveProp(options.target, datum, null));
8
+ const rel = $derived(resolveProp(options.rel, datum, null));
9
+ const type = $derived(resolveProp(options.type, datum, null));
10
+ const download = $derived(resolveProp(options.download, datum, null));
11
+
12
+ // filter data attributes from options
13
+ const dataAttributes = $derived(
14
+ Object.fromEntries(
15
+ Object.entries(options).filter(([key]) => key.startsWith('data-sveltekit-'))
16
+ )
17
+ );
18
+ </script>
19
+
20
+ {#if href}
21
+ <!-- we can't use <a> directly here because Svelte confuses it with the
22
+ HTMLAElement which breaks the rendering -->
23
+ <svelte:element
24
+ this={'a'}
25
+ {href}
26
+ {target}
27
+ {rel}
28
+ {type}
29
+ {download}
30
+ {...dataAttributes}
31
+ aria-label="link"
32
+ xmlns="http://www.w3.org/2000/svg">
33
+ {@render children?.()}
34
+ </svelte:element>
35
+ {:else}
36
+ {@render children?.()}
37
+ {/if}
@@ -0,0 +1,15 @@
1
+ export default Anchor;
2
+ type Anchor = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Anchor: import("svelte").Component<{
7
+ datum?: Record<string, any>;
8
+ options?: Record<string, any>;
9
+ children: any;
10
+ }, {}, "">;
11
+ type $$ComponentProps = {
12
+ datum?: Record<string, any>;
13
+ options?: Record<string, any>;
14
+ children: any;
15
+ };
@@ -33,6 +33,7 @@
33
33
  dy: ConstantAccessor<number>;
34
34
  filter: ChannelAccessor;
35
35
  };
36
+ text: boolean;
36
37
  plot: PlotState;
37
38
  };
38
39
 
@@ -50,7 +51,8 @@
50
51
  height,
51
52
  options,
52
53
  plot,
53
- title
54
+ title,
55
+ text = true
54
56
  }: BaseAxisXProps = $props();
55
57
 
56
58
  function splitTick(tick: string | string[]) {
@@ -86,15 +88,17 @@
86
88
  })
87
89
  );
88
90
  const T = tickObjects.length;
89
- for (let i = 0; i < T; i++) {
90
- let j = i;
91
- // find the preceding tick that was not hidden
92
- do {
93
- j--;
94
- } while (j >= 0 && tickObjects[j].hidden);
95
- if (j >= 0) {
96
- const tickLabelSpace = Math.abs(tickObjects[i].x - tickObjects[j].x);
97
- tickObjects[i].hidden = tickLabelSpace < 15;
91
+ if (text) {
92
+ for (let i = 0; i < T; i++) {
93
+ let j = i;
94
+ // find the preceding tick that was not hidden
95
+ do {
96
+ j--;
97
+ } while (j >= 0 && tickObjects[j].hidden);
98
+ if (j >= 0) {
99
+ const tickLabelSpace = Math.abs(tickObjects[i].x - tickObjects[j].x);
100
+ tickObjects[i].hidden = tickLabelSpace < 15;
101
+ }
98
102
  }
99
103
  }
100
104
  return tickObjects;
@@ -102,6 +106,7 @@
102
106
 
103
107
  $effect(() => {
104
108
  untrack(() => [$autoMarginTop, $autoMarginBottom]);
109
+ if (!text) return;
105
110
  const outsideTextAnchor = anchor === 'top' ? 'end' : 'start';
106
111
  // measure tick label heights
107
112
  const maxLabelHeight =
@@ -144,26 +149,7 @@
144
149
  <g class="axis-x">
145
150
  {#each positionedTicks as tick, t (t)}
146
151
  {#if testFilter(tick.value, options) && !tick.hidden}
147
- {@const textLines = tick.text}
148
- {@const prevTextLines = t && positionedTicks[t - 1].text}
149
- {@const fontSize = resolveProp(tickFontSize, tick)}
150
152
  {@const tickClass_ = resolveProp(tickClass, tick.value)}
151
- {@const estLabelWidth = max(textLines.map((t) => t.length)) * fontSize * 0.2}
152
- {@const moveDown =
153
- (tickSize + tickPadding + (tickRotate !== 0 ? tickFontSize * 0.35 : 0)) *
154
- (anchor === 'bottom' ? 1 : -1)}
155
- {@const [textStyle, textClass] = resolveStyles(
156
- plot,
157
- tick,
158
- {
159
- fontVariant: isQuantitative ? 'tabular-nums' : 'normal',
160
- ...options,
161
- fontSize: tickFontSize,
162
- stroke: null
163
- },
164
- 'fill',
165
- { x: true }
166
- )}
167
153
  <g
168
154
  class="tick {tickClass_ || ''}"
169
155
  transform="translate({tick.x + tick.dx}, {tickY + tick.dy})"
@@ -182,31 +168,51 @@
182
168
  y2={anchor === 'bottom' ? tickSize : -tickSize} />
183
169
  {/if}
184
170
 
185
- <text
186
- bind:this={tickTextElements[t]}
187
- transform="translate(0, {moveDown}) rotate({tickRotate})"
188
- style={textStyle}
189
- class={textClass}
190
- x={0}
191
- y={0}
192
- dominant-baseline={tickRotate !== 0
193
- ? 'central'
194
- : anchor === 'bottom'
195
- ? 'hanging'
196
- : 'auto'}>
197
- {#if ticks.length > 0 || t === 0 || t === ticks.length - 1}
198
- {#if textLines.length === 1}
199
- {textLines[0]}
200
- {:else}
201
- {#each textLines as line, i (i)}
202
- <tspan x="0" dy={i ? 12 : 0}
203
- >{!prevTextLines || prevTextLines[i] !== line
204
- ? line
205
- : ''}</tspan>
206
- {/each}
171
+ {#if text}
172
+ {@const textLines = tick.text}
173
+ {@const prevTextLines = t && positionedTicks[t - 1].text}
174
+
175
+ {@const moveDown =
176
+ (tickSize + tickPadding + (tickRotate !== 0 ? tickFontSize * 0.35 : 0)) *
177
+ (anchor === 'bottom' ? 1 : -1)}
178
+ {@const [textStyle, textClass] = resolveStyles(
179
+ plot,
180
+ tick,
181
+ {
182
+ fontVariant: isQuantitative ? 'tabular-nums' : 'normal',
183
+ ...options,
184
+ fontSize: tickFontSize,
185
+ stroke: null
186
+ },
187
+ 'fill',
188
+ { x: true }
189
+ )}
190
+ <text
191
+ bind:this={tickTextElements[t]}
192
+ transform="translate(0, {moveDown}) rotate({tickRotate})"
193
+ style={textStyle}
194
+ class={textClass}
195
+ x={0}
196
+ y={0}
197
+ dominant-baseline={tickRotate !== 0
198
+ ? 'central'
199
+ : anchor === 'bottom'
200
+ ? 'hanging'
201
+ : 'auto'}>
202
+ {#if ticks.length > 0 || t === 0 || t === ticks.length - 1}
203
+ {#if textLines.length === 1}
204
+ {textLines[0]}
205
+ {:else}
206
+ {#each textLines as line, i (i)}
207
+ <tspan x="0" dy={i ? 12 : 0}
208
+ >{!prevTextLines || prevTextLines[i] !== line
209
+ ? line
210
+ : ''}</tspan>
211
+ {/each}
212
+ {/if}
207
213
  {/if}
208
- {/if}
209
- </text>
214
+ </text>
215
+ {/if}
210
216
  </g>
211
217
  {/if}
212
218
  {/each}
@@ -17,6 +17,7 @@ type BaseAxisXProps = {
17
17
  dy: ConstantAccessor<number>;
18
18
  filter: ChannelAccessor;
19
19
  };
20
+ text: boolean;
20
21
  plot: PlotState;
21
22
  };
22
23
  declare const BaseAxisX: import("svelte").Component<BaseAxisXProps, {}, "">;
@@ -29,6 +29,7 @@
29
29
  dy: ConstantAccessor<number>;
30
30
  };
31
31
  plot: PlotState;
32
+ text: boolean | null;
32
33
  };
33
34
 
34
35
  let {
@@ -46,7 +47,8 @@
46
47
  width,
47
48
  title,
48
49
  plot,
49
- options
50
+ options,
51
+ text = true
50
52
  }: BaseAxisYProps = $props();
51
53
 
52
54
  const LINE_ANCHOR = {
@@ -67,16 +69,18 @@
67
69
  element: null as SVGTextElement | null
68
70
  };
69
71
  });
70
- const T = tickObjects.length;
71
- for (let i = 0; i < T; i++) {
72
- let j = i;
73
- // find the preceding tick that was not hidden
74
- do {
75
- j--;
76
- } while (j >= 0 && tickObjects[j].hidden);
77
- if (j >= 0) {
78
- const tickLabelSpace = Math.abs(tickObjects[i].y - tickObjects[j].y);
79
- tickObjects[i].hidden = tickLabelSpace < 15;
72
+ if (text) {
73
+ const T = tickObjects.length;
74
+ for (let i = 0; i < T; i++) {
75
+ let j = i;
76
+ // find the preceding tick that was not hidden
77
+ do {
78
+ j--;
79
+ } while (j >= 0 && tickObjects[j].hidden);
80
+ if (j >= 0) {
81
+ const tickLabelSpace = Math.abs(tickObjects[i].y - tickObjects[j].y);
82
+ tickObjects[i].hidden = tickLabelSpace < 15;
83
+ }
80
84
  }
81
85
  }
82
86
  return tickObjects;
@@ -176,13 +180,15 @@
176
180
  class={tickLineClass}
177
181
  x2={anchor === 'left' ? -tickSize : tickSize} />
178
182
  {/if}
179
- <text
180
- bind:this={tickTexts[t]}
181
- class={[textClass, { 'is-left': anchor === 'left' }]}
182
- style={textStyle}
183
- x={(tickSize + tickPadding) * (anchor === 'left' ? -1 : 1)}
184
- dominant-baseline={LINE_ANCHOR[lineAnchor]}
185
- >{Array.isArray(tick.text) ? tick.text.join(' ') : tick.text}</text>
183
+ {#if text}
184
+ <text
185
+ bind:this={tickTexts[t]}
186
+ class={[textClass, { 'is-left': anchor === 'left' }]}
187
+ style={textStyle}
188
+ x={(tickSize + tickPadding) * (anchor === 'left' ? -1 : 1)}
189
+ dominant-baseline={LINE_ANCHOR[lineAnchor]}
190
+ >{Array.isArray(tick.text) ? tick.text.join(' ') : tick.text}</text>
191
+ {/if}
186
192
  </g>
187
193
  {/if}
188
194
  {/each}
@@ -17,6 +17,7 @@ type BaseAxisYProps = {
17
17
  dy: ConstantAccessor<number>;
18
18
  };
19
19
  plot: PlotState;
20
+ text: boolean | null;
20
21
  };
21
22
  declare const BaseAxisY: import("svelte").Component<BaseAxisYProps, {}, "">;
22
23
  type BaseAxisY = ReturnType<typeof BaseAxisY>;
@@ -1,44 +1,4 @@
1
- import { type MarkerShape } from './Marker.svelte';
2
- import type { BaseMarkProps, ConstantAccessor, DataRecord, Mark, PlotScales } from '../../types.js';
3
- type MarkerPathProps = BaseMarkProps & {
4
- /**
5
- * the datum associated with this path, usually the first
6
- * element of the data array group
7
- */
8
- datum: DataRecord;
9
- /**
10
- * the marker shape to use at the start of the path, defaults to
11
- * circle
12
- */
13
- markerStart?: boolean | MarkerShape;
14
- /**
15
- * the marker shape to use at the middle of the path, defaults to circle
16
- */
17
- markerMid?: boolean | MarkerShape;
18
- /**
19
- * the marker shape to use at the end of the path, defaults to circle
20
- */
21
- markerEnd?: boolean | MarkerShape;
22
- /**
23
- * shorthand for setting all markers
24
- */
25
- marker?: boolean | MarkerShape;
26
- /**
27
- * path string
28
- */
29
- d: string;
30
- style: string;
31
- startOffset: string;
32
- textStyle: string;
33
- textStyleClass?: string | null;
34
- text: string;
35
- transform: string;
36
- color: string;
37
- strokeWidth: ConstantAccessor<number>;
38
- mark: Mark<BaseMarkProps>;
39
- scales: PlotScales;
40
- };
41
1
  /** Helper component for paths with markers and optional text along the path. */
42
- declare const MarkerPath: import("svelte").Component<MarkerPathProps, {}, "">;
2
+ declare const MarkerPath: import("svelte").Component<any, {}, "">;
43
3
  type MarkerPath = ReturnType<typeof MarkerPath>;
44
4
  export default MarkerPath;
@@ -14,6 +14,7 @@ Helper component for rendering rectangular marks in SVG
14
14
  } from '../../types';
15
15
  import { addEventHandlers } from './events';
16
16
  import { getContext } from 'svelte';
17
+ import Anchor from './Anchor.svelte';
17
18
 
18
19
  let {
19
20
  datum,
@@ -101,33 +102,35 @@ Helper component for rendering rectangular marks in SVG
101
102
  );
102
103
  </script>
103
104
 
104
- {#if hasBorderRadius}
105
- <path
106
- transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
107
- d={roundedRect(
108
- 0,
109
- 0,
110
- width - insetLeft - insetRight,
111
- height - insetTop - insetBottom,
112
- borderRadius
113
- )}
114
- class={[styleClass, className]}
115
- {style}
116
- use:addEventHandlers={{
117
- getPlotState,
118
- options,
119
- datum: datum?.datum
120
- }} />
121
- {:else}
122
- <rect
123
- transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
124
- width={width - insetLeft - insetRight}
125
- height={height - insetTop - insetBottom}
126
- class={[styleClass, className]}
127
- {style}
128
- use:addEventHandlers={{
129
- getPlotState,
130
- options,
131
- datum: datum?.datum
132
- }} />
133
- {/if}
105
+ <Anchor {options} datum={datum?.datum}>
106
+ {#if hasBorderRadius}
107
+ <path
108
+ transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
109
+ d={roundedRect(
110
+ 0,
111
+ 0,
112
+ width - insetLeft - insetRight,
113
+ height - insetTop - insetBottom,
114
+ borderRadius
115
+ )}
116
+ class={[styleClass, className]}
117
+ {style}
118
+ use:addEventHandlers={{
119
+ getPlotState,
120
+ options,
121
+ datum: datum?.datum
122
+ }} />
123
+ {:else}
124
+ <rect
125
+ transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
126
+ width={width - insetLeft - insetRight}
127
+ height={height - insetTop - insetBottom}
128
+ class={[styleClass, className]}
129
+ {style}
130
+ use:addEventHandlers={{
131
+ getPlotState,
132
+ options,
133
+ datum: datum?.datum
134
+ }} />
135
+ {/if}
136
+ </Anchor>
@@ -123,7 +123,7 @@
123
123
  );
124
124
 
125
125
  let confBandGen = $derived(
126
- confidence !== false
126
+ confidence !== false && regression.predict
127
127
  ? confidenceInterval(
128
128
  data
129
129
  .map((d) => ({