layerchart 0.81.0 → 0.81.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.
@@ -31,6 +31,12 @@
31
31
 
32
32
  export let labels: ComponentProps<Text> | boolean = false;
33
33
 
34
+ /** Mode of operation
35
+ * `integrated`: use with single chart
36
+ * `separated`: use with separate (typically smaller) chart and state can be managed externally (sync with other charts, etc). Show active selection when domain does not equal original
37
+ */
38
+ export let mode: 'integrated' | 'separated' = 'integrated';
39
+
34
40
  // Capture original domains for reset()
35
41
  const originalXDomain = $xScale.domain() as [number, number];
36
42
  const originalYDomain = $yScale.domain() as [number, number];
@@ -212,12 +218,15 @@
212
218
  $: rangeWidth = axis === 'both' || axis === 'x' ? right - left : $width;
213
219
  $: rangeHeight = axis === 'both' || axis === 'y' ? bottom - top : $height;
214
220
 
215
- // Set reactively to handle cases where xDomain/yDomain are set externally (ex. `bind:xDomain`)
216
- $: isActive =
217
- xDomain?.[0]?.valueOf() !== originalXDomain[0]?.valueOf() ||
218
- xDomain?.[1]?.valueOf() !== originalXDomain[1]?.valueOf() ||
219
- yDomain?.[0]?.valueOf() !== originalYDomain[0]?.valueOf() ||
220
- yDomain?.[1]?.valueOf() !== originalYDomain[1]?.valueOf();
221
+ let isActive = false;
222
+ $: if (mode === 'separated') {
223
+ // Set reactively to handle cases where xDomain/yDomain are set externally (ex. `bind:xDomain`)
224
+ isActive =
225
+ xDomain?.[0]?.valueOf() !== originalXDomain[0]?.valueOf() ||
226
+ xDomain?.[1]?.valueOf() !== originalXDomain[1]?.valueOf() ||
227
+ yDomain?.[0]?.valueOf() !== originalYDomain[0]?.valueOf() ||
228
+ yDomain?.[1]?.valueOf() !== originalYDomain[1]?.valueOf();
229
+ }
221
230
  </script>
222
231
 
223
232
  <g class={cls('Brush select-none', classes.root, $$props.class)}>
@@ -13,6 +13,7 @@ declare const __propDef: {
13
13
  xDomain?: DomainType | undefined;
14
14
  yDomain?: DomainType | undefined;
15
15
  labels?: (ComponentProps<Text> | boolean) | undefined;
16
+ mode?: "integrated" | "separated" | undefined;
16
17
  range?: SVGAttributes<SVGRectElement> | undefined;
17
18
  handle?: SVGAttributes<SVGRectElement> | undefined;
18
19
  format?: FormatType | undefined;
@@ -75,7 +75,7 @@
75
75
  $: stackSeries = seriesLayout.startsWith('stack');
76
76
 
77
77
  export let axis: ComponentProps<Axis> | 'x' | 'y' | boolean = true;
78
- export let brush: ({ mode: 'integrated' } & ComponentProps<Brush>) | false = false;
78
+ export let brush: ComponentProps<Brush> | boolean = false;
79
79
  export let grid: ComponentProps<Grid> | boolean = true;
80
80
  export let labels: ComponentProps<Labels> | boolean = false;
81
81
  export let legend: ComponentProps<Legend> | boolean = false;
@@ -396,7 +396,7 @@
396
396
  {/if}
397
397
  </svelte:component>
398
398
 
399
- {#if brush && brush.mode === 'integrated'}
399
+ {#if brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')}
400
400
  <Svg>
401
401
  {@const brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush }}
402
402
  <Brush
@@ -67,7 +67,7 @@
67
67
  $: isDefaultSeries = series.length === 1 && series[0].key === 'default';
68
68
 
69
69
  export let axis: ComponentProps<Axis> | 'x' | 'y' | boolean = true;
70
- export let brush: ({ mode: 'integrated' } & ComponentProps<Brush>) | false = false;
70
+ export let brush: ComponentProps<Brush> | boolean = false;
71
71
  export let grid: ComponentProps<Grid> | boolean = true;
72
72
  export let labels: ComponentProps<Labels> | boolean = false;
73
73
  export let legend: ComponentProps<Legend> | boolean = false;
@@ -322,7 +322,7 @@
322
322
  </slot>
323
323
  </svelte:component>
324
324
 
325
- {#if brush && brush.mode === 'integrated'}
325
+ {#if brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')}
326
326
  <Svg>
327
327
  {@const brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush }}
328
328
  <Brush
@@ -58,7 +58,7 @@
58
58
  $: isDefaultSeries = series.length === 1 && series[0].key === 'default';
59
59
 
60
60
  export let axis: ComponentProps<Axis> | 'x' | 'y' | boolean = true;
61
- export let brush: ({ mode: 'integrated' } & ComponentProps<Brush>) | false = false;
61
+ export let brush: ComponentProps<Brush> | boolean = false;
62
62
  export let grid: ComponentProps<Grid> | boolean = true;
63
63
  export let labels: ComponentProps<Labels> | boolean = false;
64
64
  export let legend: ComponentProps<Legend> | boolean = false;
@@ -270,7 +270,7 @@
270
270
  </svelte:component>
271
271
 
272
272
  <!-- TODO: Determine how to coordinate with `tooltip={{ mode: 'voronoi' }} -->
273
- {#if brush && brush.mode === 'integrated'}
273
+ {#if brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')}
274
274
  <Svg>
275
275
  {@const brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush }}
276
276
  <Brush
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "0.81.0",
7
+ "version": "0.81.1",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.27.12",
10
10
  "@mdi/js": "^7.4.47",