svelteplot 0.5.0-pr-233.1 → 0.5.0-pr-237.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.
@@ -207,6 +207,7 @@
207
207
  const yDomainCount = $derived(
208
208
  isOneDimensional && explicitScales.has('x') ? 1 : preScales.y.domain.length
209
209
  );
210
+
210
211
  // compute the (automatic) height based on various factors:
211
212
  // - if the plot used a projection and the projection requires an aspect ratio,
212
213
  // we use it, but adjust for the facet counts
@@ -215,34 +216,34 @@
215
216
  // - for one-dimensional scales using the x scale we set a fixed height
216
217
  // - for y band-scales we use the number of items in the y domain
217
218
  const height = $derived(
218
- maybeNumber(plotOptions.height) === null || plotOptions.height === 'auto'
219
- ? Math.round(
220
- preScales.projection && preScales.projection.aspectRatio
221
- ? ((plotWidth * preScales.projection.aspectRatio) / xFacetCount) *
222
- yFacetCount +
219
+ typeof plotOptions.height === 'function'
220
+ ? plotOptions.height(plotWidth)
221
+ : maybeNumber(plotOptions.height) === null || plotOptions.height === 'auto'
222
+ ? Math.round(
223
+ preScales.projection && preScales.projection.aspectRatio
224
+ ? ((plotWidth * preScales.projection.aspectRatio) / xFacetCount) *
225
+ yFacetCount +
226
+ plotOptions.marginTop +
227
+ plotOptions.marginBottom
228
+ : plotOptions.aspectRatio
229
+ ? heightFromAspect(
230
+ preScales.x,
231
+ preScales.y,
232
+ plotOptions.aspectRatio,
233
+ plotWidth,
234
+ plotOptions.marginTop,
235
+ plotOptions.marginBottom
236
+ )
237
+ : ((isOneDimensional && explicitScales.has('x')) || !explicitMarks.length
238
+ ? yFacetCount * DEFAULTS.bandScaleHeight
239
+ : preScales.y.type === 'band'
240
+ ? yFacetCount * yDomainCount * DEFAULTS.bandScaleHeight
241
+ : preScales.y.type === 'point'
242
+ ? yFacetCount * yDomainCount * DEFAULTS.pointScaleHeight
243
+ : DEFAULTS.height) +
223
244
  plotOptions.marginTop +
224
245
  plotOptions.marginBottom
225
- : plotOptions.aspectRatio
226
- ? heightFromAspect(
227
- preScales.x,
228
- preScales.y,
229
- plotOptions.aspectRatio,
230
- plotWidth,
231
- plotOptions.marginTop,
232
- plotOptions.marginBottom
233
- )
234
- : ((isOneDimensional && explicitScales.has('x')) || !explicitMarks.length
235
- ? yFacetCount * DEFAULTS.bandScaleHeight
236
- : preScales.y.type === 'band'
237
- ? yFacetCount * yDomainCount * DEFAULTS.bandScaleHeight
238
- : preScales.y.type === 'point'
239
- ? yFacetCount * yDomainCount * DEFAULTS.pointScaleHeight
240
- : DEFAULTS.height) +
241
- plotOptions.marginTop +
242
- plotOptions.marginBottom
243
- )
244
- : typeof plotOptions.height === 'function'
245
- ? plotOptions.height(plotWidth)
246
+ )
246
247
  : maybeNumber(plotOptions.height)
247
248
  );
248
249
 
@@ -1,6 +1,5 @@
1
1
  import type { ChannelName, Channels, RawValue } from '../types/index.js';
2
2
  import type { Snippet } from 'svelte';
3
- import type { TransitionConfig } from 'svelte/transition';
4
3
  /**
5
4
  * Returns first argument that is not null or undefined
6
5
  */
@@ -17,4 +16,3 @@ export declare function parseInset(inset: number | string, width: number): numbe
17
16
  export declare function omit<T extends {}, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
18
17
  export declare function identity<T>(x: T): T;
19
18
  export declare const GEOJSON_PREFER_STROKE: Set<string>;
20
- export declare function noTransition(node: Element): TransitionConfig;
@@ -61,14 +61,3 @@ export function identity(x) {
61
61
  return x;
62
62
  }
63
63
  export const GEOJSON_PREFER_STROKE = new Set(['MultiLineString', 'LineString']);
64
- export function noTransition(node) {
65
- node.dispatchEvent(new CustomEvent('introstart'));
66
- node.dispatchEvent(new CustomEvent('introend'));
67
- node.dispatchEvent(new CustomEvent('outrostart'));
68
- node.dispatchEvent(new CustomEvent('outroend'));
69
- return {
70
- duration: 0,
71
- delay: 0,
72
- css: () => ''
73
- };
74
- }
@@ -18,7 +18,6 @@
18
18
  import { autoTicks } from '../helpers/autoTicks.js';
19
19
  import { resolveScaledStyles } from '../helpers/resolve.js';
20
20
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
21
- import { identity, noTransition } from '../helpers';
22
21
 
23
22
  interface AxisXMarkProps
24
23
  extends Omit<
@@ -64,8 +63,6 @@
64
63
  textAnchor: 'auto',
65
64
  opacity: 0.8,
66
65
  anchor: 'bottom',
67
- tIn: [noTransition, {}],
68
- tOut: [noTransition, {}],
69
66
  ...getPlotDefaults().axis,
70
67
  ...getPlotDefaults().axisX
71
68
  };
@@ -239,9 +236,7 @@
239
236
  scaleFn={plot.scales.x.fn}
240
237
  scaleType={plot.scales.x.type}
241
238
  tickFormat={useTickFormat}
242
- title={useTitle}
243
- tIn={DEFAULTS.tIn}
244
- tOut={DEFAULTS.tOut} />
239
+ title={useTitle} />
245
240
  {/if}
246
241
  </Mark>
247
242
 
@@ -17,7 +17,6 @@
17
17
  import { autoTicks } from '../helpers/autoTicks.js';
18
18
  import { resolveScaledStyles } from '../helpers/resolve.js';
19
19
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
20
- import { noTransition } from '../helpers';
21
20
 
22
21
  interface AxisYMarkProps
23
22
  extends Omit<
@@ -62,8 +61,6 @@
62
61
  opacity: 0.8,
63
62
  anchor: 'left',
64
63
  textAnchor: 'auto',
65
- tIn: [noTransition, {}],
66
- tOut: [noTransition, {}],
67
64
  ...getPlotDefaults().axis,
68
65
  ...getPlotDefaults().axisY
69
66
  };
@@ -228,9 +225,7 @@
228
225
  scaleType={plot.scales.y.type}
229
226
  tickFormat={useTickFormat}
230
227
  title={useTitle}
231
- width={plot.facetWidth}
232
- tIn={DEFAULTS.tIn}
233
- tOut={DEFAULTS.tOut} />
228
+ width={plot.facetWidth} />
234
229
  {/if}
235
230
  </Mark>
236
231
 
@@ -19,7 +19,7 @@
19
19
  } from '../types/index.js';
20
20
  import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
21
21
  import { autoTicks } from '../helpers/autoTicks.js';
22
- import { noTransition, testFilter } from '../helpers/index.js';
22
+ import { testFilter } from '../helpers/index.js';
23
23
  import { RAW_VALUE } from '../transforms/recordize.js';
24
24
  import isDataRecord from '../helpers/isDataRecord';
25
25
  import { INDEX } from '../constants';
@@ -28,8 +28,6 @@
28
28
  let markProps: GridXMarkProps = $props();
29
29
 
30
30
  const DEFAULTS = {
31
- tIn: [noTransition, {}],
32
- tOut: [noTransition, {}],
33
31
  ...getPlotDefaults().grid,
34
32
  ...getPlotDefaults().gridX
35
33
  };
@@ -67,9 +65,6 @@
67
65
  isDataRecord(d) ? { ...d, [INDEX]: i } : { [RAW_VALUE]: d, [INDEX]: i }
68
66
  ) as DataRecord[]
69
67
  );
70
-
71
- const tInF = $derived(DEFAULTS.tIn?.[0] ?? noTransition);
72
- const tOutF = $derived(DEFAULTS.tOut?.[0] ?? noTransition);
73
68
  </script>
74
69
 
75
70
  <Mark
@@ -80,7 +75,7 @@
80
75
  {automatic}>
81
76
  {#snippet children({ usedScales })}
82
77
  <g class="grid-x">
83
- {#each ticks as tick (tick[RAW_VALUE])}
78
+ {#each ticks as tick, t (t)}
84
79
  {#if testFilter(tick, options)}
85
80
  {@const x =
86
81
  plot.scales.x.fn(tick[RAW_VALUE]) +
@@ -104,8 +99,6 @@
104
99
  true
105
100
  )}
106
101
  <line
107
- in:tInF|global={{ ...(DEFAULTS.tIn?.[1] ?? {}) }}
108
- out:tOutF|global={{ ...(DEFAULTS.tOut?.[1] ?? {}) }}
109
102
  class={styleClass}
110
103
  transform="translate({x + dx},{dy})"
111
104
  {style}
@@ -13,16 +13,13 @@
13
13
  import type { PlotContext, BaseMarkProps, RawValue, ChannelAccessor } from '../types/index.js';
14
14
  import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
15
15
  import { autoTicks } from '../helpers/autoTicks.js';
16
- import { noTransition, testFilter } from '../helpers/index.js';
16
+ import { testFilter } from '../helpers/index.js';
17
17
  import { RAW_VALUE } from '../transforms/recordize.js';
18
18
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
19
- import { uniqBy } from 'es-toolkit';
20
19
 
21
20
  let markProps: GridYMarkProps = $props();
22
21
 
23
22
  const DEFAULTS = {
24
- tIn: [noTransition, {}],
25
- tOut: [noTransition, {}],
26
23
  ...getPlotDefaults().grid,
27
24
  ...getPlotDefaults().gridY
28
25
  };
@@ -57,9 +54,6 @@
57
54
  autoTickCount
58
55
  )
59
56
  );
60
-
61
- const tInF = $derived(DEFAULTS.tIn?.[0] ?? noTransition);
62
- const tOutF = $derived(DEFAULTS.tOut?.[0] ?? noTransition);
63
57
  </script>
64
58
 
65
59
  <Mark
@@ -70,7 +64,7 @@
70
64
  {automatic}>
71
65
  {#snippet children({ usedScales })}
72
66
  <g class="grid-y">
73
- {#each ticks as tick (tick)}
67
+ {#each ticks as tick, t (t)}
74
68
  {#if testFilter(tick, options)}
75
69
  {@const y =
76
70
  plot.scales.y.fn(tick) +
@@ -94,8 +88,6 @@
94
88
  true
95
89
  )}
96
90
  <line
97
- in:tInF|global={{ ...(DEFAULTS.tIn?.[1] ?? {}) }}
98
- out:tOutF|global={{ ...(DEFAULTS.tOut?.[1] ?? {}) }}
99
91
  {style}
100
92
  class={styleClass}
101
93
  transform="translate({dx},{y + dy})"
@@ -216,7 +216,7 @@
216
216
  markerEnd={args.markerEnd}
217
217
  marker={args.marker}
218
218
  strokeWidth={args.strokeWidth}
219
- datum={lineData[0]}
219
+ datum={lineData[0].datum}
220
220
  d={pathString}
221
221
  dInv={text ? linePath(lineData.toReversed()) : null}
222
222
  color={lineData[0].stroke || 'currentColor'}
@@ -225,7 +225,7 @@
225
225
  text={text ? resolveProp(text, lineData[0]) : null}
226
226
  startOffset={resolveProp(
227
227
  args.textStartOffset,
228
- lineData[0],
228
+ lineData[0].datum,
229
229
  '50%'
230
230
  )}
231
231
  {textStyle}
@@ -10,13 +10,11 @@
10
10
  PlotState,
11
11
  RawValue,
12
12
  ScaledDataRecord,
13
- ScaleType,
14
- TransitionArgs,
15
- TransitionFunction
13
+ ScaleType
16
14
  } from '../../types/index.js';
17
15
  import { resolveProp, resolveStyles } from '../../helpers/resolve.js';
18
16
  import { max } from 'd3-array';
19
- import { noTransition, randomId, testFilter } from '../../helpers/index.js';
17
+ import { randomId, testFilter } from '../../helpers/index.js';
20
18
  import { INDEX } from '../../constants';
21
19
  import { RAW_VALUE } from '../../transforms/recordize';
22
20
 
@@ -41,8 +39,6 @@
41
39
  };
42
40
  text: boolean;
43
41
  plot: PlotState;
44
- tIn?: [TransitionFunction?, TransitionArgs?];
45
- tOut?: [TransitionFunction?, TransitionArgs?];
46
42
  };
47
43
 
48
44
  let {
@@ -60,9 +56,7 @@
60
56
  options,
61
57
  plot,
62
58
  title,
63
- text = true,
64
- tIn = [],
65
- tOut = []
59
+ text = true
66
60
  }: BaseAxisXProps = $props();
67
61
 
68
62
  function splitTick(tick: string | string[]) {
@@ -155,9 +149,6 @@
155
149
  if ($autoMarginTop.has(id)) $autoMarginTop.delete(id);
156
150
  };
157
151
  });
158
-
159
- const tInF = $derived(tIn?.[0] ?? noTransition);
160
- const tOutF = $derived(tOut?.[0] ?? noTransition);
161
152
  </script>
162
153
 
163
154
  <g class="axis-x">
@@ -166,8 +157,6 @@
166
157
  {@const tickClass_ = resolveProp(tickClass, tick)}
167
158
  {@const tickFontSize_ = +resolveProp(tickFontSize, tick, 10)}
168
159
  <g
169
- in:tInF|global={{ ...(tIn?.[1] ?? {}) }}
170
- out:tOutF|global={{ ...(tOut?.[1] ?? {}) }}
171
160
  class="tick {tickClass_ || ''}"
172
161
  transform="translate({tick.x + tick.dx}, {tickY + tick.dy})"
173
162
  text-anchor={tickRotate < 0 ? 'end' : tickRotate > 0 ? 'start' : 'middle'}>
@@ -1,4 +1,4 @@
1
- import type { ChannelAccessor, ConstantAccessor, PlotState, RawValue, ScaleType, TransitionArgs, TransitionFunction } from '../../types/index.js';
1
+ import type { ChannelAccessor, ConstantAccessor, PlotState, RawValue, ScaleType } from '../../types/index.js';
2
2
  type BaseAxisXProps = {
3
3
  scaleFn: (d: RawValue) => number;
4
4
  scaleType: ScaleType;
@@ -20,8 +20,6 @@ type BaseAxisXProps = {
20
20
  };
21
21
  text: boolean;
22
22
  plot: PlotState;
23
- tIn?: [TransitionFunction?, TransitionArgs?];
24
- tOut?: [TransitionFunction?, TransitionArgs?];
25
23
  };
26
24
  declare const BaseAxisX: import("svelte").Component<BaseAxisXProps, {}, "">;
27
25
  type BaseAxisX = ReturnType<typeof BaseAxisX>;
@@ -1,16 +1,16 @@
1
1
  <script lang="ts">
2
2
  import { getContext, untrack } from 'svelte';
3
- import { identity, noTransition, randomId, testFilter } from '../../helpers/index.js';
3
+ import { randomId, testFilter } from '../../helpers/index.js';
4
4
  import { resolveProp, resolveStyles } from '../../helpers/resolve.js';
5
5
  import { max } from 'd3-array';
6
6
  import type {
7
7
  AutoMarginStores,
8
8
  ConstantAccessor,
9
+ DataRecord,
9
10
  PlotState,
10
11
  RawValue,
11
- ScaleType,
12
- TransitionArgs,
13
- TransitionFunction
12
+ ScaledDataRecord,
13
+ ScaleType
14
14
  } from '../../types/index.js';
15
15
  import { RAW_VALUE } from '../../transforms/recordize';
16
16
  import { INDEX } from '../../constants';
@@ -36,8 +36,6 @@
36
36
  };
37
37
  plot: PlotState;
38
38
  text: boolean | null;
39
- tIn?: [TransitionFunction?, TransitionArgs?];
40
- tOut?: [TransitionFunction?, TransitionArgs?];
41
39
  };
42
40
 
43
41
  let {
@@ -56,9 +54,7 @@
56
54
  title,
57
55
  plot,
58
56
  options,
59
- text = true,
60
- tIn = [],
61
- tOut = []
57
+ text = true
62
58
  }: BaseAxisYProps = $props();
63
59
 
64
60
  const LINE_ANCHOR = {
@@ -155,9 +151,6 @@
155
151
  if ($autoMarginTop.has(id)) $autoMarginTop.delete(id);
156
152
  };
157
153
  });
158
-
159
- const tInF = $derived(tIn?.[0] ?? noTransition);
160
- const tOutF = $derived(tOut?.[0] ?? noTransition);
161
154
  </script>
162
155
 
163
156
  <g class="axis-y">
@@ -178,8 +171,6 @@
178
171
  true
179
172
  )}
180
173
  <g
181
- in:tInF|global={{ ...(tIn?.[1] ?? {}) }}
182
- out:tOutF|global={{ ...(tOut?.[1] ?? {}) }}
183
174
  class="tick {tickClass_ || ''}"
184
175
  transform="translate({tick.dx +
185
176
  marginLeft +
@@ -1,4 +1,4 @@
1
- import type { ConstantAccessor, PlotState, RawValue, ScaleType, TransitionArgs, TransitionFunction } from '../../types/index.js';
1
+ import type { ConstantAccessor, PlotState, RawValue, ScaleType } from '../../types/index.js';
2
2
  type BaseAxisYProps = {
3
3
  scaleFn: (d: RawValue) => number;
4
4
  scaleType: ScaleType;
@@ -20,8 +20,6 @@ type BaseAxisYProps = {
20
20
  };
21
21
  plot: PlotState;
22
22
  text: boolean | null;
23
- tIn?: [TransitionFunction?, TransitionArgs?];
24
- tOut?: [TransitionFunction?, TransitionArgs?];
25
23
  };
26
24
  declare const BaseAxisY: import("svelte").Component<BaseAxisYProps, {}, "">;
27
25
  type BaseAxisY = ReturnType<typeof BaseAxisY>;
@@ -4,7 +4,6 @@ import type { MarkerShape } from '../marks/helpers/Marker.svelte';
4
4
  import type { Channels, ScaledChannelName } from './channel.js';
5
5
  import type { RawValue } from './data.js';
6
6
  import type { BaseMarkProps } from './mark.js';
7
- import type { TransitionConfig } from 'svelte/transition';
8
7
  export type GenericMarkOptions = Record<string | symbol, any>;
9
8
  export type CurveName = 'basis' | 'basis-closed' | 'basis-open' | 'bundle' | 'bump-x' | 'bump-y' | 'cardinal' | 'cardinal-closed' | 'cardinal-open' | 'catmull-rom' | 'catmull-rom-closed' | 'catmull-rom-open' | 'linear' | 'linear-closed' | 'monotone-x' | 'monotone-y' | 'natural' | 'step' | 'step-after' | 'step-before';
10
9
  export type MarkerOptions = {
@@ -50,12 +49,6 @@ export type MapIndexObject = {
50
49
  export type MapMethod = 'cumsum' | 'rank' | 'quantile' | ((I: number[], S: number[]) => number[]) | MapIndexObject;
51
50
  export type MapOptions = Partial<Record<ScaledChannelName, MapMethod>>;
52
51
  export type UsedScales = Record<ScaledChannelName, boolean>;
53
- export type TransitionFunction = (node: Element, params: any) => TransitionConfig;
54
- export type TransitionArgs = {
55
- delay?: number;
56
- duration?: number;
57
- easing?: (t: number) => number;
58
- };
59
52
  export * from './channel';
60
53
  export * from './colorScheme';
61
54
  export * from './data';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.5.0-pr-233.1",
3
+ "version": "0.5.0-pr-237.0",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",
@@ -57,7 +57,7 @@
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.44.0",
60
+ "@sveltejs/kit": "^2.47.3",
61
61
  "@sveltejs/package": "^2.5.4",
62
62
  "@sveltejs/vite-plugin-svelte": "5.1.1",
63
63
  "@sveltepress/theme-default": "^6.0.4",
@@ -79,34 +79,34 @@
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.45.0",
83
- "@typescript-eslint/parser": "^8.45.0",
82
+ "@typescript-eslint/eslint-plugin": "^8.46.2",
83
+ "@typescript-eslint/parser": "^8.46.2",
84
84
  "csstype": "^3.1.3",
85
85
  "d3-dsv": "^3.0.1",
86
86
  "d3-fetch": "^3.0.1",
87
87
  "d3-force": "^3.0.0",
88
- "eslint": "^9.37.0",
88
+ "eslint": "^9.38.0",
89
89
  "eslint-config-prettier": "^10.1.8",
90
- "eslint-plugin-svelte": "3.12.4",
90
+ "eslint-plugin-svelte": "3.12.5",
91
91
  "jsdom": "^26.1.0",
92
92
  "prettier": "^3.6.2",
93
93
  "prettier-plugin-svelte": "^3.4.0",
94
- "puppeteer": "^24.23.0",
94
+ "puppeteer": "^24.26.1",
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
98
  "sass": "^1.93.2",
99
- "svelte-check": "^4.3.2",
100
- "svelte-eslint-parser": "1.3.3",
101
- "svelte-highlight": "^7.8.4",
99
+ "svelte-check": "^4.3.3",
100
+ "svelte-eslint-parser": "1.4.0",
101
+ "svelte-highlight": "^7.9.0",
102
102
  "svg-path-parser": "^1.1.0",
103
103
  "topojson-client": "^3.1.0",
104
104
  "ts-essentials": "^10.1.1",
105
105
  "tslib": "^2.8.1",
106
- "typedoc": "^0.28.13",
106
+ "typedoc": "^0.28.14",
107
107
  "typedoc-plugin-markdown": "^4.9.0",
108
108
  "typescript": "^5.9.3",
109
- "vite": "^6.3.6",
109
+ "vite": "^6.4.1",
110
110
  "vitest": "^3.2.4",
111
111
  "vitest-matchmedia-mock": "^2.0.3",
112
112
  "yoctocolors": "^2.1.2"
@@ -126,10 +126,10 @@
126
126
  "d3-scale-chromatic": "^3.1.0",
127
127
  "d3-shape": "^3.2.0",
128
128
  "d3-time": "^3.1.0",
129
- "es-toolkit": "^1.39.10",
129
+ "es-toolkit": "^1.41.0",
130
130
  "fast-equals": "^5.3.2",
131
131
  "interval-tree-1d": "^1.0.4",
132
132
  "merge-deep": "^3.0.3",
133
- "svelte": "5.39.8"
133
+ "svelte": "5.41.3"
134
134
  }
135
135
  }