svelteplot 0.10.3-pr-484.0 → 0.10.3-pr-485.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.
@@ -60,8 +60,8 @@
60
60
  import Mark from '../Mark.svelte';
61
61
  import MarkerPath from './helpers/MarkerPath.svelte';
62
62
  import { replaceChannels } from '../transforms/rename.js';
63
- import { line, type CurveFactory } from 'd3-shape';
64
- import callWithProps from '../helpers/callWithProps.js';
63
+ import { line, type CurveFactory, type Line as D3Line } from 'd3-shape';
64
+ import type { MarkerShape } from './helpers/Marker.svelte';
65
65
  import { maybeCurve } from '../helpers/curves.js';
66
66
  import { geoPath } from 'd3-geo';
67
67
  import { pick } from 'es-toolkit';
@@ -93,9 +93,9 @@
93
93
  const args = $derived(
94
94
  replaceChannels(
95
95
  sort({
96
- data: indexData(data),
96
+ data: indexData(data as object[]) as DataRecord[],
97
97
  stroke: 'currentColor',
98
- ...options
98
+ ...(options as BaseMarkProps<DataRecord>)
99
99
  }),
100
100
  { y: ['y1', 'y2'], x: ['x1', 'x2'] }
101
101
  )
@@ -103,42 +103,44 @@
103
103
 
104
104
  const sphericalLine = $derived(plot.scales.projection && curve === 'auto');
105
105
 
106
- const linePath: (d: ScaledDataRecord, reversed: boolean) => string = $derived.by(() => {
107
- const fn = callWithProps(line, [], {
108
- curve: maybeCurve(
109
- curve === 'auto' ? 'linear' : curve,
110
- bend === true ? 0.6 : bend === false ? 0 : (bend ?? tension)
111
- ),
112
- x: (d) => d[0],
113
- y: (d) => d[1]
114
- });
106
+ const linePath: (d: ScaledDataRecord, reversed?: boolean) => string | null = $derived.by(() => {
107
+ const fn: D3Line<[number, number]> = line<[number, number]>()
108
+ .curve(
109
+ maybeCurve(
110
+ curve === 'auto' ? 'linear' : curve,
111
+ bend === true ? 0.6 : bend === false ? 0 : (bend ?? tension ?? 0)
112
+ )
113
+ )
114
+ .x((d) => d[0])
115
+ .y((d) => d[1]);
115
116
 
116
117
  return (d: ScaledDataRecord, reversed = false) =>
117
118
  fn(
118
119
  reversed
119
120
  ? [
120
- [d.x2, d.y2],
121
- [d.x1, d.y1]
121
+ [d.x2 as number, d.y2 as number],
122
+ [d.x1 as number, d.y1 as number]
122
123
  ]
123
124
  : [
124
- [d.x1, d.y1],
125
- [d.x2, d.y2]
125
+ [d.x1 as number, d.y1 as number],
126
+ [d.x2 as number, d.y2 as number]
126
127
  ]
127
128
  );
128
129
  });
129
130
 
130
- const sphericalLinePath: (d: ScaledDataRecord, reversed: boolean) => string = $derived.by(
131
- () => {
131
+ const sphericalLinePath: (d: ScaledDataRecord, reversed?: boolean) => string | null =
132
+ $derived.by(() => {
132
133
  const fn = sphereLine(plot.scales.projection);
133
134
  return (d: ScaledDataRecord, reversed = false) => {
134
135
  const x1 = resolveChannel('x1', d.datum, args);
135
136
  const y1 = resolveChannel('y1', d.datum, args);
136
137
  const x2 = resolveChannel('x2', d.datum, args);
137
138
  const y2 = resolveChannel('y2', d.datum, args);
138
- return reversed ? fn(x2, y2, x1, y1) : fn(x1, y1, x2, y2);
139
+ return reversed
140
+ ? fn(x2 as number, y2 as number, x1 as number, y1 as number)
141
+ : fn(x1 as number, y1 as number, x2 as number, y2 as number);
139
142
  };
140
- }
141
- );
143
+ });
142
144
  // sphericalLine
143
145
  // ?
144
146
 
@@ -146,7 +148,7 @@
146
148
  // :
147
149
  // );
148
150
 
149
- function sphereLine(projection) {
151
+ function sphereLine(projection: any) {
150
152
  const path = geoPath(projection);
151
153
  return (x1: number, y1: number, x2: number, y2: number) => {
152
154
  return path({
@@ -181,10 +183,10 @@
181
183
  d,
182
184
  {
183
185
  textAnchor: 'middle',
184
- ...pick(args, ['fontSize', 'fontWeight', 'fontStyle', 'textAnchor']),
185
- fill: args.textFill || args.stroke,
186
- stroke: args.textStroke,
187
- strokeWidth: args.textStrokeWidth
186
+ ...pick(args, ['fontSize', 'fontWeight', 'fontStyle']),
187
+ fill: options.textFill || args.stroke,
188
+ stroke: options.textStroke,
189
+ strokeWidth: options.textStrokeWidth
188
190
  },
189
191
  'fill',
190
192
  usedScales
@@ -192,21 +194,27 @@
192
194
 
193
195
  <MarkerPath
194
196
  mark={{ ...mark, options: args }}
197
+ transform=""
195
198
  scales={plot.scales}
196
- markerStart={args.markerStart}
197
- markerEnd={args.markerEnd}
198
- marker={args.marker}
199
- markerScale={args.markerScale}
200
- class={styleClass}
201
- strokeWidth={args.strokeWidth}
202
- datum={d.datum}
203
- color={d.stroke}
204
- d={sphericalLine ? sphericalLinePath(d) : linePath(d)}
205
- dInv={sphericalLine ? sphericalLinePath(d, true) : linePath(d, true)}
206
- {style}
207
- text={text ? resolveProp(text, d.datum) : null}
208
- startOffset={resolveProp(args.textStartOffset, d.datum, '50%')}
209
- {textStyle}
199
+ markerStart={options.markerStart as boolean | MarkerShape | undefined}
200
+ markerEnd={options.markerEnd as boolean | MarkerShape | undefined}
201
+ marker={options.marker as boolean | MarkerShape | undefined}
202
+ markerScale={options.markerScale}
203
+ class={styleClass ?? undefined}
204
+ strokeWidth={options.strokeWidth as ConstantAccessor<number>}
205
+ datum={d.datum as DataRecord}
206
+ color={d.stroke ?? 'currentColor'}
207
+ d={(sphericalLine ? sphericalLinePath(d) : linePath(d)) ?? ''}
208
+ dInv={(sphericalLine ? sphericalLinePath(d, true) : linePath(d, true)) ??
209
+ undefined}
210
+ style={style ?? ''}
211
+ text={text ? ((resolveProp(text, d.datum as Datum) as string) ?? '') : ''}
212
+ startOffset={(resolveProp(
213
+ options.textStartOffset,
214
+ d.datum as Datum,
215
+ '50%'
216
+ ) as string) ?? '50%'}
217
+ textStyle={textStyle ?? ''}
210
218
  {textStyleClass} />
211
219
  {/if}
212
220
  {/each}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.10.3-pr-484.0",
3
+ "version": "0.10.3-pr-485.0",
4
4
  "description": "A Svelte-native data visualization framework based on the layered grammar of graphics principles.",
5
5
  "keywords": [
6
6
  "svelte",