svelteplot 0.1.3-next.8 → 0.1.3-next.9

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.
package/dist/Mark.svelte CHANGED
@@ -78,8 +78,6 @@
78
78
  }
79
79
  }
80
80
 
81
-
82
-
83
81
  const mark = new Mark(type);
84
82
 
85
83
  $effect(() => {
@@ -128,24 +126,26 @@
128
126
  const testFacet = $derived(getTestFacet());
129
127
 
130
128
  const resolvedData: ResolvedDataRecord[] = $derived(
131
- data.map((d,i) => ({...d, [INDEX]: i})).flatMap((row) => {
132
- const channels = options as Record<ChannelName, ChannelAccessor>;
133
- if (!testFacet(row, channels) || !testFilter(row, channels)) return [];
134
- const out: ResolvedDataRecord = {
135
- datum: row
136
- };
137
- for (const [channel] of Object.entries(CHANNEL_SCALE) as [
138
- ScaledChannelName,
139
- ScaleName
140
- ][]) {
141
- // check if the mark has defined an accessor for this channel
142
- if (options?.[channel] !== undefined && out[channel] === undefined) {
143
- // resolve value
144
- out[channel] = resolveChannel(channel, row, options);
129
+ data
130
+ .map((d, i) => ({ ...d, [INDEX]: i }))
131
+ .flatMap((row) => {
132
+ const channels = options as Record<ChannelName, ChannelAccessor>;
133
+ if (!testFacet(row, channels) || !testFilter(row, channels)) return [];
134
+ const out: ResolvedDataRecord = {
135
+ datum: row
136
+ };
137
+ for (const [channel] of Object.entries(CHANNEL_SCALE) as [
138
+ ScaledChannelName,
139
+ ScaleName
140
+ ][]) {
141
+ // check if the mark has defined an accessor for this channel
142
+ if (options?.[channel] !== undefined && out[channel] === undefined) {
143
+ // resolve value
144
+ out[channel] = resolveChannel(channel, row, options);
145
+ }
145
146
  }
146
- }
147
- return [out];
148
- })
147
+ return [out];
148
+ })
149
149
  );
150
150
 
151
151
  let prevResolvedData: ResolvedDataRecord[] = [];
@@ -158,7 +158,6 @@
158
158
  }
159
159
  });
160
160
 
161
-
162
161
  function isDifferent(array1: ResolvedDataRecord[], array2: ResolvedDataRecord[]) {
163
162
  if (array1.length !== array2.length) return true;
164
163
  for (let i = 0; i < array1.length; i++) {
@@ -156,7 +156,7 @@
156
156
  explicitDomains,
157
157
  hasProjection: !!initialOpts.projection,
158
158
  margins: initialOpts.margins,
159
- inset: initialOpts.inset,
159
+ inset: initialOpts.inset
160
160
  })
161
161
  );
162
162
 
@@ -175,7 +175,9 @@
175
175
 
176
176
  const hasProjection = $derived(!!preScales.projection);
177
177
 
178
- const plotWidth = $derived((fixedWidth || width) - plotOptions.marginLeft - plotOptions.marginRight);
178
+ const plotWidth = $derived(
179
+ (fixedWidth || width) - plotOptions.marginLeft - plotOptions.marginRight
180
+ );
179
181
 
180
182
  // the facet and y domain counts are used for computing the automatic height
181
183
  const xFacetCount = $derived(Math.max(1, preScales.fx.domain.length));
@@ -47,7 +47,7 @@
47
47
  )
48
48
  );
49
49
 
50
- $inspect({args})
50
+ $inspect({ args });
51
51
  </script>
52
52
 
53
53
  <Mark
@@ -14,10 +14,17 @@
14
14
  let { automatic, class: className = null, ...options }: FrameMarkProps = $props();
15
15
 
16
16
  const { getPlotState } = getContext<PlotContext>('svelteplot');
17
- let plot = $derived(getPlotState());
17
+ const plot = $derived(getPlotState());
18
18
 
19
- let dx = $derived(resolveProp(options.dx, null, 0));
20
- let dy = $derived(resolveProp(options.dy, null, 0));
19
+ const dx = $derived(resolveProp(options.dx, null, 0));
20
+ const dy = $derived(resolveProp(options.dy, null, 0));
21
+
22
+ const {
23
+ insetLeft = options.inset || 0,
24
+ insetTop = options.inset || 0,
25
+ insetRight = options.inset || 0,
26
+ insetBottom = options.inset || 0
27
+ } = $derived(options);
21
28
  </script>
22
29
 
23
30
  <Mark type="frame" {automatic}>
@@ -25,12 +32,12 @@
25
32
  class={['frame', className]}
26
33
  transform={dx || dy ? `translate(${dx},${dy})` : null}
27
34
  style={resolveScaledStyles({}, options, {}, plot, 'stroke')}
28
- x={plot.options.marginLeft}
29
- y={plot.options.marginTop}
35
+ x={plot.options.marginLeft + +insetLeft}
36
+ y={plot.options.marginTop + +insetTop}
30
37
  rx={resolveProp(options.rx, null, null)}
31
38
  ry={resolveProp(options.ry, null, null)}
32
- width={plot.facetWidth}
33
- height={plot.facetHeight}
39
+ width={plot.facetWidth - (insetLeft || 0) - (insetRight || 0)}
40
+ height={plot.facetHeight - (insetBottom || 0) - (insetTop || 0)}
34
41
  use:addEventHandlers={{ getPlotState, options: options, datum: {} }} />
35
42
  </Mark>
36
43
 
@@ -156,7 +156,7 @@
156
156
  )}
157
157
 
158
158
  <MarkerPath
159
- mark={{...mark, options: args}}
159
+ mark={{ ...mark, options: args }}
160
160
  scales={plot.scales}
161
161
  markerStart={args.markerStart}
162
162
  markerEnd={args.markerEnd}
@@ -131,8 +131,13 @@
131
131
  {@const [style, styleClass] = resolveStyles(
132
132
  plot,
133
133
  { ...d, __tspanIndex: 0 },
134
- { fontSize: 12, fontWeight: 500, strokeWidth: 1.6,
135
- textAnchor: isLeft ? 'start' : isRight ? 'end' : 'middle', ...args },
134
+ {
135
+ fontSize: 12,
136
+ fontWeight: 500,
137
+ strokeWidth: 1.6,
138
+ textAnchor: isLeft ? 'start' : isRight ? 'end' : 'middle',
139
+ ...args
140
+ },
136
141
  'fill',
137
142
  usedScales
138
143
  )}
@@ -156,8 +161,11 @@
156
161
  fontSize
157
162
  )
158
163
  ]})"
159
- >{#each textLines as line, l}<tspan x="0" dy={l ? fontSize : 0} class={styleClass} {style}
160
- >{line}</tspan
164
+ >{#each textLines as line, l}<tspan
165
+ x="0"
166
+ dy={l ? fontSize : 0}
167
+ class={styleClass}
168
+ {style}>{line}</tspan
161
169
  >{/each}{#if title}<title>{title}</title>{/if}</text>
162
170
  {:else}
163
171
  <!-- singleline text-->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.1.3-next.8",
3
+ "version": "0.1.3-next.9",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",