svelteplot 0.5.3-pr-255.0 → 0.5.3-pr-255.2

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 (41) hide show
  1. package/dist/Mark.svelte +6 -0
  2. package/dist/Plot.svelte +12 -2
  3. package/dist/constants.d.ts +1 -1
  4. package/dist/core/FacetAxes.svelte +2 -2
  5. package/dist/core/Plot.svelte +7 -11
  6. package/dist/helpers/colors.d.ts +8 -11
  7. package/dist/helpers/facets.d.ts +1 -1
  8. package/dist/helpers/getBaseStyles.d.ts +2 -4
  9. package/dist/helpers/index.d.ts +1 -1
  10. package/dist/helpers/reduce.d.ts +1 -1
  11. package/dist/helpers/removeIdenticalLines.js +3 -2
  12. package/dist/helpers/scales.d.ts +5 -5
  13. package/dist/helpers/symbols.d.ts +2 -2
  14. package/dist/helpers/time.d.ts +3 -3
  15. package/dist/helpers/typeChecks.d.ts +4 -4
  16. package/dist/helpers/wordwrap.d.ts +14 -0
  17. package/dist/helpers/wordwrap.js +129 -0
  18. package/dist/marks/AxisX.svelte +2 -1
  19. package/dist/marks/AxisX.svelte.d.ts +1 -0
  20. package/dist/marks/Brush.svelte +44 -4
  21. package/dist/marks/CustomMark.svelte +9 -3
  22. package/dist/marks/Image.svelte +76 -0
  23. package/dist/marks/Image.svelte.d.ts +19 -0
  24. package/dist/marks/Text.svelte.d.ts +1 -1
  25. package/dist/marks/WaffleX.svelte +28 -4
  26. package/dist/marks/WaffleY.svelte +35 -8
  27. package/dist/marks/helpers/Anchor.svelte +16 -2
  28. package/dist/marks/helpers/Anchor.svelte.d.ts +28 -14
  29. package/dist/marks/helpers/BaseAxisX.svelte +31 -3
  30. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +2 -0
  31. package/dist/marks/helpers/waffle.d.ts +17 -2
  32. package/dist/marks/helpers/waffle.js +0 -1
  33. package/dist/marks/index.d.ts +2 -1
  34. package/dist/marks/index.js +2 -1
  35. package/dist/transforms/centroid.d.ts +1 -4
  36. package/dist/transforms/group.js +11 -5
  37. package/dist/transforms/recordize.d.ts +3 -3
  38. package/dist/transforms/sort.d.ts +2 -2
  39. package/dist/types/plot.d.ts +10 -6
  40. package/dist/types/scale.d.ts +8 -0
  41. package/package.json +14 -14
@@ -76,7 +76,7 @@ declare class __sveltets_Render<Datum extends DataRecord> {
76
76
  * the font size of the text
77
77
  */
78
78
  fontFamily?: ConstantAccessor<CSS.Property.FontFamily, Datum>;
79
- fontSize?: ConstantAccessor<number | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | (string & {}) | "small" | "medium" | "large" | "x-large" | "x-small" | "xx-large" | "xx-small" | "xxx-large" | "larger" | "smaller", Datum>;
79
+ fontSize?: ConstantAccessor<number | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | (string & {}) | "small" | "math" | "large" | "medium" | "x-large" | "x-small" | "xx-large" | "xx-small" | "xxx-large" | "larger" | "smaller", Datum>;
80
80
  fontWeight?: ConstantAccessor<CSS.Property.FontWeight, Datum>;
81
81
  fontStyle?: ConstantAccessor<CSS.Property.FontStyle, Datum>;
82
82
  fontVariant?: ConstantAccessor<CSS.Property.FontVariant, Datum>;
@@ -7,7 +7,8 @@
7
7
  DataRecord,
8
8
  BaseMarkProps,
9
9
  ChannelAccessor,
10
- LinkableMarkProps
10
+ LinkableMarkProps,
11
+ BorderRadius
11
12
  } from '../types';
12
13
  import { wafflePolygon, type WaffleOptions } from './helpers/waffle';
13
14
  import { getPlotDefaults } from '../hooks/plotDefaults';
@@ -15,11 +16,13 @@
15
16
  import type { StackOptions } from '../transforms/stack';
16
17
  import Mark from '../Mark.svelte';
17
18
  import { getContext } from 'svelte';
19
+ import { resolveProp, resolveStyles } from '../helpers/resolve';
20
+ import { roundedRect } from '../helpers/roundedRect';
18
21
 
19
22
  interface WaffleXMarkProps
20
23
  extends BaseMarkProps<Datum>,
21
24
  LinkableMarkProps<Datum>,
22
- WaffleOptions {
25
+ WaffleOptions<Datum> {
23
26
  data?: Datum[];
24
27
  /**
25
28
  * bound to a quantitative scale
@@ -52,6 +55,7 @@
52
55
  data = [{} as Datum],
53
56
  class: className = null,
54
57
  stack,
58
+ symbol = null,
55
59
  unit,
56
60
  ...options
57
61
  }: WaffleXMarkProps = $derived({ ...DEFAULTS, ...markProps });
@@ -79,10 +83,30 @@
79
83
  {#snippet children({ mark, usedScales, scaledData })}
80
84
  {@const wafflePoly = wafflePolygon('x', args, plot.scales)}
81
85
  {#each scaledData as d, i (i)}
86
+ {@const borderRadius = resolveProp(args.borderRadius, d?.datum, 0) as BorderRadius}
87
+ {@const hasBorderRadius =
88
+ (typeof borderRadius === 'number' && borderRadius > 0) ||
89
+ (typeof borderRadius === 'object' &&
90
+ Math.max(
91
+ borderRadius.topRight ?? 0,
92
+ borderRadius.bottomRight ?? 0,
93
+ borderRadius.topLeft ?? 0,
94
+ borderRadius.bottomLeft ?? 0
95
+ ) > 0)}
96
+ {@const [style, styleClass] = resolveStyles(plot, d, options, 'fill', usedScales)}
82
97
  {@const { pattern, rect, path } = wafflePoly(d)}
83
- <g>
98
+ <g class={['waffle-x', className]}>
84
99
  <pattern {...pattern}>
85
- <rect {...rect} fill="currentColor" />
100
+ {#if symbol}
101
+ {@render symbol(rect)}
102
+ {:else if hasBorderRadius}
103
+ <path
104
+ d={roundedRect(rect.x, rect.y, rect.width, rect.height, borderRadius)}
105
+ {style}
106
+ class={styleClass} />
107
+ {:else}
108
+ <rect {style} class={styleClass} {...rect} />
109
+ {/if}
86
110
  </pattern>
87
111
  <path {...path} />
88
112
  </g>
@@ -8,18 +8,22 @@
8
8
  ChannelAccessor,
9
9
  BaseMarkProps,
10
10
  LinkableMarkProps,
11
- PlotContext
11
+ PlotContext,
12
+ BorderRadius
12
13
  } from '../types';
13
14
  import { wafflePolygon, type WaffleOptions } from './helpers/waffle';
14
15
  import { getPlotDefaults } from '../hooks/plotDefaults';
15
16
  import { getContext } from 'svelte';
16
17
  import { intervalY, recordizeY, sort, stackY } from '../transforms';
17
18
  import Mark from '../Mark.svelte';
19
+ import { resolveProp, resolveStyles } from '../helpers/resolve';
20
+ import { roundedRect } from '../helpers/roundedRect';
21
+ import GroupMultiple from './helpers/GroupMultiple.svelte';
18
22
 
19
23
  interface WaffleYMarkProps
20
24
  extends BaseMarkProps<Datum>,
21
25
  LinkableMarkProps<Datum>,
22
- WaffleOptions {
26
+ WaffleOptions<Datum> {
23
27
  data?: Datum[];
24
28
  /**
25
29
  * bound to a babd scale
@@ -37,11 +41,9 @@
37
41
  * bound to a quantitative scale
38
42
  */
39
43
  y2?: ChannelAccessor<Datum>;
40
- stack?: StackOptions;
41
44
  }
42
45
 
43
46
  const DEFAULTS = {
44
- fill: 'currentColor',
45
47
  ...getPlotDefaults().waffle,
46
48
  ...getPlotDefaults().waffleY
47
49
  };
@@ -52,6 +54,7 @@
52
54
  data = [{} as Datum],
53
55
  class: className = null,
54
56
  stack,
57
+ symbol = null,
55
58
  ...options
56
59
  }: WaffleYMarkProps = $derived({ ...DEFAULTS, ...markProps });
57
60
 
@@ -68,8 +71,6 @@
68
71
  stack
69
72
  )
70
73
  );
71
-
72
- $inspect({ args, options });
73
74
  </script>
74
75
 
75
76
  <Mark
@@ -80,10 +81,36 @@
80
81
  {#snippet children({ mark, usedScales, scaledData })}
81
82
  {@const wafflePoly = wafflePolygon('y', args, plot.scales)}
82
83
  {#each scaledData as d, i (i)}
84
+ {@const [style, styleClass] = resolveStyles(
85
+ plot,
86
+ d,
87
+ args,
88
+ args.stroke && !args.fill ? 'stroke' : 'fill',
89
+ usedScales
90
+ )}
91
+ {@const borderRadius = resolveProp(args.borderRadius, d?.datum, 0) as BorderRadius}
92
+ {@const hasBorderRadius =
93
+ (typeof borderRadius === 'number' && borderRadius > 0) ||
94
+ (typeof borderRadius === 'object' &&
95
+ Math.max(
96
+ borderRadius.topRight ?? 0,
97
+ borderRadius.bottomRight ?? 0,
98
+ borderRadius.topLeft ?? 0,
99
+ borderRadius.bottomLeft ?? 0
100
+ ) > 0)}
83
101
  {@const { pattern, rect, path } = wafflePoly(d)}
84
- <g>
102
+ <g class={['waffle-y', className]}>
85
103
  <pattern {...pattern}>
86
- <rect {...rect} fill="currentColor" />
104
+ {#if symbol}
105
+ {@render symbol({ ...rect, style, styleClass, datum: d.datum })}
106
+ {:else if hasBorderRadius}
107
+ <path
108
+ d={roundedRect(rect.x, rect.y, rect.width, rect.height, borderRadius)}
109
+ {style}
110
+ class={styleClass} />
111
+ {:else}
112
+ <rect {style} class={styleClass} {...rect} />
113
+ {/if}
87
114
  </pattern>
88
115
  <path {...path} />
89
116
  </g>
@@ -1,7 +1,21 @@
1
- <script>
1
+ <script lang="ts" generics="Datum extends Record<string, any>">
2
2
  import { resolveProp } from '../../helpers/resolve.js';
3
+ import type { ConstantAccessor } from '../../types';
3
4
 
4
- let { datum = {}, options = {}, children } = $props();
5
+ interface AnchorProps {
6
+ datum?: Datum;
7
+ options?: {
8
+ href?: ConstantAccessor<string, Datum>;
9
+ target?: ConstantAccessor<string, Datum>;
10
+ rel?: ConstantAccessor<string, Datum>;
11
+ type?: ConstantAccessor<string, Datum>;
12
+ download?: ConstantAccessor<string, Datum>;
13
+ [key: string]: any;
14
+ };
15
+ children?: () => any;
16
+ }
17
+
18
+ let { datum = {}, options = {}, children }: AnchorProps = $props();
5
19
 
6
20
  const href = $derived(resolveProp(options.href, datum, null));
7
21
  const target = $derived(resolveProp(options.target, datum, null));
@@ -1,15 +1,29 @@
1
+ import type { ConstantAccessor } from '../../types';
2
+ declare class __sveltets_Render<Datum extends Record<string, any>> {
3
+ props(): {
4
+ datum?: Datum | undefined;
5
+ options?: {
6
+ [key: string]: any;
7
+ href?: ConstantAccessor<string, Datum_1>;
8
+ target?: ConstantAccessor<string, Datum_1>;
9
+ rel?: ConstantAccessor<string, Datum_1>;
10
+ type?: ConstantAccessor<string, Datum_1>;
11
+ download?: ConstantAccessor<string, Datum_1>;
12
+ } | undefined;
13
+ children?: (() => any) | undefined;
14
+ };
15
+ events(): {};
16
+ slots(): {};
17
+ bindings(): "";
18
+ exports(): {};
19
+ }
20
+ interface $$IsomorphicComponent {
21
+ new <Datum extends Record<string, any>>(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']>> & {
22
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
23
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
24
+ <Datum extends Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
25
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
26
+ }
27
+ declare const Anchor: $$IsomorphicComponent;
28
+ type Anchor<Datum extends Record<string, any>> = InstanceType<typeof Anchor<Datum>>;
1
29
  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
- };
@@ -17,6 +17,7 @@
17
17
  import { randomId, testFilter } from '../../helpers/index.js';
18
18
  import { INDEX } from '../../constants';
19
19
  import { RAW_VALUE } from '../../transforms/recordize';
20
+ import wordwrap from '../../helpers/wordwrap';
20
21
 
21
22
  type BaseAxisXProps = {
22
23
  scaleFn: (d: RawValue) => number;
@@ -35,7 +36,9 @@
35
36
  dx: ConstantAccessor<number>;
36
37
  dy: ConstantAccessor<number>;
37
38
  filter: ChannelAccessor;
39
+ wordwrap: boolean;
38
40
  textAnchor: ConstantAccessor<'start' | 'middle' | 'end'> | 'auto';
41
+ removeDuplicateTicks: boolean;
39
42
  };
40
43
  text: boolean;
41
44
  plot: PlotState;
@@ -59,8 +62,21 @@
59
62
  text = true
60
63
  }: BaseAxisXProps = $props();
61
64
 
65
+ const isBandScale = $derived(scaleType === 'band');
66
+ const bandWidth = $derived(isBandScale ? scaleFn.bandwidth() : 0);
67
+
62
68
  function splitTick(tick: string | string[]) {
63
- return Array.isArray(tick) ? tick : [tick];
69
+ return Array.isArray(tick)
70
+ ? tick
71
+ : typeof tick === 'string' && isBandScale && options.wordwrap !== false
72
+ ? wordwrap(
73
+ tick,
74
+ { maxLineWidth: bandWidth * 0.9 },
75
+ { minCharactersPerLine: 4 },
76
+ +resolveProp(tickFontSize, {}, 11),
77
+ false
78
+ )
79
+ : [tick];
64
80
  }
65
81
 
66
82
  let tickRotate = $derived(plot.options.x.tickRotate || 0);
@@ -72,7 +88,7 @@
72
88
  // generate id used for registering margins
73
89
  const id = randomId();
74
90
 
75
- const { autoMarginTop, autoMarginBottom } =
91
+ const { autoMarginTop, autoMarginBottom, autoMarginLeft, autoMarginRight } =
76
92
  getContext<AutoMarginStores>('svelteplot/autoMargins');
77
93
 
78
94
  let tickTextElements = $state([] as SVGTextElement[]);
@@ -109,6 +125,14 @@
109
125
  return tickObjects as ScaledDataRecord[];
110
126
  });
111
127
 
128
+ $effect(() => {
129
+ // just add some minimal horizontal margins for axis ticks
130
+ untrack(() => $autoMarginLeft);
131
+ untrack(() => $autoMarginRight);
132
+ $autoMarginLeft.set(id, 5);
133
+ $autoMarginRight.set(id, 5);
134
+ });
135
+
112
136
  $effect(() => {
113
137
  untrack(() => [$autoMarginTop, $autoMarginBottom]);
114
138
  if (!text) return;
@@ -147,6 +171,8 @@
147
171
  return () => {
148
172
  if ($autoMarginBottom.has(id)) $autoMarginBottom.delete(id);
149
173
  if ($autoMarginTop.has(id)) $autoMarginTop.delete(id);
174
+ if ($autoMarginLeft.has(id)) $autoMarginLeft.delete(id);
175
+ if ($autoMarginRight.has(id)) $autoMarginRight.delete(id);
150
176
  };
151
177
  });
152
178
  </script>
@@ -222,7 +248,9 @@
222
248
  {:else}
223
249
  {#each textLines as line, i (i)}
224
250
  <tspan x="0" dy={i ? 12 : 0}
225
- >{!prevTextLines || prevTextLines[i] !== line
251
+ >{!prevTextLines ||
252
+ prevTextLines[i] !== line ||
253
+ options.removeDuplicateTicks === false
226
254
  ? line
227
255
  : ''}</tspan>
228
256
  {/each}
@@ -16,7 +16,9 @@ type BaseAxisXProps = {
16
16
  dx: ConstantAccessor<number>;
17
17
  dy: ConstantAccessor<number>;
18
18
  filter: ChannelAccessor;
19
+ wordwrap: boolean;
19
20
  textAnchor: ConstantAccessor<'start' | 'middle' | 'end'> | 'auto';
21
+ removeDuplicateTicks: boolean;
20
22
  };
21
23
  text: boolean;
22
24
  plot: PlotState;
@@ -1,6 +1,8 @@
1
- import type { PlotScales, ScaledDataRecord } from '../../types';
1
+ import type { Snippet } from 'svelte';
2
+ import type { StackOptions } from '../../transforms/stack';
3
+ import type { BorderRadius, ConstantAccessor, PlotScales, ScaledDataRecord } from '../../types';
2
4
  type Point = [number, number];
3
- export type WaffleOptions = {
5
+ export type WaffleOptions<T> = {
4
6
  /**
5
7
  * the quantity represented by each square in the waffle chart, defaults to 1
6
8
  */
@@ -17,6 +19,19 @@ export type WaffleOptions = {
17
19
  * whether to round values to avoid partial cells; defaults to false
18
20
  */
19
21
  round?: boolean;
22
+ stack?: StackOptions;
23
+ borderRadius?: ConstantAccessor<BorderRadius, T>;
24
+ symbol?: Snippet<[
25
+ {
26
+ x: number;
27
+ y: number;
28
+ width: number;
29
+ height: number;
30
+ style: string | null;
31
+ styleClass: string | null;
32
+ datum: T;
33
+ }
34
+ ]>;
20
35
  };
21
36
  type WaffleProps = {
22
37
  pattern: {
@@ -66,7 +66,6 @@ export function wafflePolygon(y, options, scales) {
66
66
  const y2val = d.resolved[y2];
67
67
  const P = wafflePoints(round(y1val / unit), round(y2val / unit), multiple).map(transform);
68
68
  const c = P.pop();
69
- console.log({ c, P, xv, y1val, y2val });
70
69
  const id = getPatternId();
71
70
  const pos = [d[x] + tx + mx, y0];
72
71
  return {
@@ -27,12 +27,12 @@ export { default as Geo } from './Geo.svelte';
27
27
  export { default as Graticule } from './Graticule.svelte';
28
28
  export { default as GridX } from './GridX.svelte';
29
29
  export { default as GridY } from './GridY.svelte';
30
+ export { default as Image } from './Image.svelte';
30
31
  export { default as Line } from './Line.svelte';
31
32
  export { default as LineX } from './LineX.svelte';
32
33
  export { default as LineY } from './LineY.svelte';
33
34
  export { default as Link } from './Link.svelte';
34
35
  export { default as Pointer } from './Pointer.svelte';
35
- export { default as Vector } from './Vector.svelte';
36
36
  export { default as Rect } from './Rect.svelte';
37
37
  export { default as RectX } from './RectX.svelte';
38
38
  export { default as RectY } from './RectY.svelte';
@@ -45,6 +45,7 @@ export { default as Spike } from './Spike.svelte';
45
45
  export { default as Text } from './Text.svelte';
46
46
  export { default as TickX } from './TickX.svelte';
47
47
  export { default as TickY } from './TickY.svelte';
48
+ export { default as Vector } from './Vector.svelte';
48
49
  export { default as WaffleX } from './WaffleX.svelte';
49
50
  export { default as WaffleY } from './WaffleY.svelte';
50
51
  export { default as ColorLegend } from './ColorLegend.svelte';
@@ -27,12 +27,12 @@ export { default as Geo } from './Geo.svelte';
27
27
  export { default as Graticule } from './Graticule.svelte';
28
28
  export { default as GridX } from './GridX.svelte';
29
29
  export { default as GridY } from './GridY.svelte';
30
+ export { default as Image } from './Image.svelte';
30
31
  export { default as Line } from './Line.svelte';
31
32
  export { default as LineX } from './LineX.svelte';
32
33
  export { default as LineY } from './LineY.svelte';
33
34
  export { default as Link } from './Link.svelte';
34
35
  export { default as Pointer } from './Pointer.svelte';
35
- export { default as Vector } from './Vector.svelte';
36
36
  export { default as Rect } from './Rect.svelte';
37
37
  export { default as RectX } from './RectX.svelte';
38
38
  export { default as RectY } from './RectY.svelte';
@@ -45,6 +45,7 @@ export { default as Spike } from './Spike.svelte';
45
45
  export { default as Text } from './Text.svelte';
46
46
  export { default as TickX } from './TickX.svelte';
47
47
  export { default as TickY } from './TickY.svelte';
48
+ export { default as Vector } from './Vector.svelte';
48
49
  export { default as WaffleX } from './WaffleX.svelte';
49
50
  export { default as WaffleY } from './WaffleY.svelte';
50
51
  // HTML marks
@@ -1,8 +1,5 @@
1
1
  import type { DataRecord, TransformArg } from '../types/index.js';
2
- declare const CENTROID: unique symbol;
3
- type WithCentroid<T> = T & {
4
- [CENTROID]: [number, number];
5
- };
2
+ type WithCentroid<T> = T & {};
6
3
  export declare function geoCentroid<Datum extends DataRecord>({ data, ...options }: {
7
4
  data: Datum[];
8
5
  } & TransformArg<Datum>): TransformArg<WithCentroid<Datum>>;
@@ -1,5 +1,5 @@
1
1
  import { groupFacetsAndZ } from '../helpers/group.js';
2
- import { testFilter } from '../helpers/index.js';
2
+ import { isValid, testFilter } from '../helpers/index.js';
3
3
  import { reduceOutputs } from '../helpers/reduce.js';
4
4
  import { resolveChannel } from '../helpers/resolve.js';
5
5
  import { groups as d3Groups } from 'd3-array';
@@ -58,8 +58,12 @@ export function groupY(input, options = {}) {
58
58
  export function groupZ(input, options = {}) {
59
59
  return groupXYZ('z', input, options);
60
60
  }
61
+ const groupDimRaw = Symbol('groupDimRaw');
61
62
  function groupXYZ(dim, { data, ...channels }, options = {}) {
62
- if ((dim === 'z' ? channels.z || channels.fill || channels.stroke : channels[dim]) == null)
63
+ // console.log({ dim, data, channels, options });
64
+ if ((dim === 'z'
65
+ ? channels.z || channels.fill || channels.stroke || channels.fx || channels.fy
66
+ : channels[dim]) == null)
63
67
  throw new Error('you must provide a channel to group on ' + dim);
64
68
  const propName = options[`${dim}PropName`] != null
65
69
  ? options[`${dim}PropName`]
@@ -70,9 +74,11 @@ function groupXYZ(dim, { data, ...channels }, options = {}) {
70
74
  // group by x or y
71
75
  const groups = dim === 'z'
72
76
  ? [[null, data]]
73
- : d3Groups(data.filter((d) => testFilter(d, channels)), (d) => {
74
- const v = resolveChannel(dim, d, channels);
75
- return interval ? interval.round(v) : v;
77
+ : d3Groups(data
78
+ .filter((d) => testFilter(d, channels))
79
+ .map((d) => ({ ...d, [groupDimRaw]: resolveChannel(dim, d, channels) }))
80
+ .filter((d) => isValid(d[groupDimRaw])), (d) => {
81
+ return interval ? interval.floor(d[groupDimRaw]) : d[groupDimRaw];
76
82
  });
77
83
  const newData = [];
78
84
  let newChannels = omit({ ...channels }, 'filter');
@@ -1,7 +1,7 @@
1
1
  import type { TransformArgsRow, TransformArgsRecord } from '../types/index.js';
2
- export declare const X: unique symbol;
3
- export declare const Y: unique symbol;
4
- export declare const RAW_VALUE: unique symbol;
2
+ export declare const X: any;
3
+ export declare const Y: any;
4
+ export declare const RAW_VALUE: any;
5
5
  export declare function indexData<T extends object>(data: T[]): (T & {})[];
6
6
  export declare function recordizeX<T>({ data, ...channels }: TransformArgsRow<T>, { withIndex }?: {
7
7
  withIndex: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { DataRow, TransformArg } from '../types/index.js';
2
- export declare const SORT_KEY: unique symbol;
3
- export declare const IS_SORTED: unique symbol;
2
+ export declare const SORT_KEY: any;
3
+ export declare const IS_SORTED: any;
4
4
  export declare function sort<T>({ data, ...channels }: TransformArg<T>, options?: {
5
5
  reverse?: boolean;
6
6
  }): any;
@@ -1,9 +1,9 @@
1
1
  import type { ComponentProps } from 'svelte';
2
2
  import type { ColorScheme } from './colorScheme.js';
3
3
  import type { GeoProjection } from 'd3-geo';
4
- import type { ChannelAccessor, ChannelName, ColorScaleOptions, DataRecord, LegendScaleOptions, PlotScales, ScaleOptions, XScaleOptions, YScaleOptions } from './index.js';
4
+ import type { ChannelAccessor, ChannelName, ColorScaleOptions, DataRecord, LegendScaleOptions, PlotScales, RawValue, ScaleOptions, XScaleOptions, YScaleOptions } from './index.js';
5
5
  import type { Snippet } from 'svelte';
6
- import type { Area, AreaX, AreaY, Arrow, AxisX, AxisY, BarX, BarY, BoxX, BoxY, Brush, BrushX, BrushY, Cell, DifferenceY, Dot, Frame, Geo, Graticule, GridX, GridY, Line, Link, Pointer, Rect, RectX, RectY, RuleX, RuleY, Sphere, Spike, Text, TickX, TickY, Vector } from '../marks/index.js';
6
+ import type { Area, AreaX, AreaY, Arrow, AxisX, AxisY, BarX, BarY, BoxX, BoxY, Brush, BrushX, BrushY, Cell, DifferenceY, Dot, Frame, Geo, Graticule, GridX, GridY, Image, Line, Link, Pointer, Rect, RectX, RectY, RuleX, RuleY, Sphere, Spike, Text, TickX, TickY, Vector } from '../marks/index.js';
7
7
  import type WaffleX from '../marks/WaffleX.svelte';
8
8
  import type WaffleY from '../marks/WaffleY.svelte';
9
9
  export type PlotState = {
@@ -232,6 +232,10 @@ export type PlotDefaults = {
232
232
  gridY: Partial<Omit<ComponentProps<typeof GridY>, IgnoreDefaults> & {
233
233
  implicit: boolean;
234
234
  }>;
235
+ /**
236
+ * default props for image marks
237
+ */
238
+ image: Partial<Omit<ComponentProps<typeof Image>, IgnoreDefaults>>;
235
239
  /**
236
240
  * default props for line marks
237
241
  */
@@ -419,11 +423,11 @@ export type PlotOptions = {
419
423
  /**
420
424
  * Options for the shared x scale.
421
425
  */
422
- x: Partial<XScaleOptions>;
426
+ x: Partial<XScaleOptions> | false | RawValue[];
423
427
  /**
424
428
  * Options for the shared y scale
425
429
  */
426
- y: Partial<YScaleOptions>;
430
+ y: Partial<YScaleOptions> | false | RawValue[];
427
431
  /**
428
432
  * Options for the shared radius scale
429
433
  */
@@ -432,8 +436,8 @@ export type PlotOptions = {
432
436
  opacity: Partial<ScaleOptions>;
433
437
  symbol: Partial<LegendScaleOptions>;
434
438
  length: Partial<ScaleOptions>;
435
- fx: Partial<ScaleOptions>;
436
- fy: Partial<ScaleOptions>;
439
+ fx: Partial<XScaleOptions> | false | RawValue[];
440
+ fy: Partial<YScaleOptions> | false | RawValue[];
437
441
  children: Snippet<[
438
442
  {
439
443
  width: number;
@@ -106,6 +106,14 @@ export type XScaleOptions = ScaleOptions & {
106
106
  tickRotate: number;
107
107
  labelAnchor: 'auto' | 'left' | 'center' | 'right';
108
108
  tickFormat: false | Intl.NumberFormatOptions | ((d: RawValue) => string);
109
+ /**
110
+ * Enable word wrapping for axis tick labels, default true
111
+ */
112
+ wordWrap: boolean;
113
+ /**
114
+ * Remove duplicate ticks from axis, default true
115
+ */
116
+ removeDuplicateTicks: boolean;
109
117
  };
110
118
  export type YScaleOptions = ScaleOptions & {
111
119
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.5.3-pr-255.0",
3
+ "version": "0.5.3-pr-255.2",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",
@@ -57,13 +57,13 @@
57
57
  "@sveltejs/adapter-auto": "^6.1.1",
58
58
  "@sveltejs/adapter-static": "^3.0.10",
59
59
  "@sveltejs/eslint-config": "^8.3.4",
60
- "@sveltejs/kit": "^2.47.3",
60
+ "@sveltejs/kit": "^2.48.5",
61
61
  "@sveltejs/package": "^2.5.4",
62
62
  "@sveltejs/vite-plugin-svelte": "5.1.1",
63
63
  "@sveltepress/theme-default": "^6.0.4",
64
64
  "@sveltepress/twoslash": "^1.2.2",
65
65
  "@sveltepress/vite": "^1.2.2",
66
- "@testing-library/svelte": "^5.2.8",
66
+ "@testing-library/svelte": "^5.2.9",
67
67
  "@testing-library/user-event": "^14.6.1",
68
68
  "@types/d3-array": "^3.2.2",
69
69
  "@types/d3-color": "^3.1.3",
@@ -79,24 +79,24 @@
79
79
  "@types/geojson": "^7946.0.16",
80
80
  "@types/topojson": "^3.2.6",
81
81
  "@types/topojson-client": "^3.1.5",
82
- "@typescript-eslint/eslint-plugin": "^8.46.2",
83
- "@typescript-eslint/parser": "^8.46.2",
84
- "csstype": "^3.1.3",
82
+ "@typescript-eslint/eslint-plugin": "^8.46.4",
83
+ "@typescript-eslint/parser": "^8.46.4",
84
+ "csstype": "^3.2.0",
85
85
  "d3-dsv": "^3.0.1",
86
86
  "d3-fetch": "^3.0.1",
87
87
  "d3-force": "^3.0.0",
88
- "eslint": "^9.38.0",
88
+ "eslint": "^9.39.1",
89
89
  "eslint-config-prettier": "^10.1.8",
90
- "eslint-plugin-svelte": "3.12.5",
90
+ "eslint-plugin-svelte": "3.13.0",
91
91
  "jsdom": "^26.1.0",
92
92
  "prettier": "^3.6.2",
93
93
  "prettier-plugin-svelte": "^3.4.0",
94
- "puppeteer": "^24.26.1",
94
+ "puppeteer": "^24.30.0",
95
95
  "remark-code-extra": "^1.0.1",
96
96
  "remark-code-frontmatter": "^1.0.0",
97
97
  "resize-observer-polyfill": "^1.5.1",
98
- "sass": "^1.93.2",
99
- "svelte-check": "^4.3.3",
98
+ "sass": "^1.94.0",
99
+ "svelte-check": "^4.3.4",
100
100
  "svelte-eslint-parser": "1.4.0",
101
101
  "svelte-highlight": "^7.9.0",
102
102
  "svg-path-parser": "^1.1.0",
@@ -107,7 +107,7 @@
107
107
  "typedoc-plugin-markdown": "^4.9.0",
108
108
  "typescript": "^5.9.3",
109
109
  "vite": "^6.4.1",
110
- "vitest": "^3.2.4",
110
+ "vitest": "^4.0.9",
111
111
  "vitest-matchmedia-mock": "^2.0.3",
112
112
  "yoctocolors": "^2.1.2"
113
113
  },
@@ -127,9 +127,9 @@
127
127
  "d3-shape": "^3.2.0",
128
128
  "d3-time": "^3.1.0",
129
129
  "es-toolkit": "^1.41.0",
130
- "fast-equals": "^5.3.2",
130
+ "fast-equals": "^5.3.3",
131
131
  "interval-tree-1d": "^1.0.4",
132
132
  "merge-deep": "^3.0.3",
133
- "svelte": "5.43.0"
133
+ "svelte": "5"
134
134
  }
135
135
  }