layerchart 0.92.1 → 0.93.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.
@@ -120,6 +120,7 @@ declare class __sveltets_Render<TData> {
120
120
  reflectY?: boolean | undefined;
121
121
  geo?: import("svelte/store").Writable<import("d3-geo").GeoProjection>;
122
122
  }> | undefined;
123
+ geoProjection?: import("svelte/store").Writable<import("d3-geo").GeoProjection> | undefined;
123
124
  tooltip?: boolean | Partial<{
124
125
  mode?: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
125
126
  findTooltipData?: "closest" | "left" | "right";
@@ -131,14 +132,22 @@ declare class __sveltets_Render<TData> {
131
132
  data: any;
132
133
  }) => any;
133
134
  tooltip?: import("svelte/store").Writable<{
134
- y: number;
135
135
  x: number;
136
+ y: number;
136
137
  data: any;
137
138
  show: (e: PointerEvent, tooltipData?: any) => void;
138
139
  hide: () => void;
139
140
  mode: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
140
141
  }>;
141
142
  }> | undefined;
143
+ tooltipContext?: import("svelte/store").Writable<{
144
+ x: number;
145
+ y: number;
146
+ data: any;
147
+ show: (e: PointerEvent, tooltipData?: any) => void;
148
+ hide: () => void;
149
+ mode: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
150
+ }> | undefined;
142
151
  transform?: Partial<{
143
152
  mode?: "canvas" | "manual" | "none";
144
153
  translateOnScale?: boolean;
@@ -195,15 +204,42 @@ declare class __sveltets_Render<TData> {
195
204
  setScale?: (value: number, options?: import("../../stores/motionStore").MotionOptions) => void;
196
205
  }> | undefined;
197
206
  transformContext?: import("..").TransformContext;
198
- geoProjection?: import("svelte/store").Writable<import("d3-geo").GeoProjection> | undefined;
199
- tooltipContext?: import("svelte/store").Writable<{
200
- y: number;
201
- x: number;
202
- data: any;
203
- show: (e: PointerEvent, tooltipData?: any) => void;
204
- hide: () => void;
205
- mode: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
207
+ brush?: boolean | Partial<{
208
+ axis?: "x" | "y" | "both";
209
+ handleSize?: number;
210
+ resetOnEnd?: boolean;
211
+ xDomain?: import("../../utils/scales").DomainType;
212
+ yDomain?: import("../../utils/scales").DomainType;
213
+ mode?: "integrated" | "separated";
214
+ disabled?: boolean;
215
+ range?: Partial<import("svelte/elements").HTMLAttributes<HTMLDivElement>> | undefined;
216
+ handle?: Partial<import("svelte/elements").HTMLAttributes<HTMLDivElement>> | undefined;
217
+ classes?: {
218
+ root?: string;
219
+ frame?: string;
220
+ range?: string;
221
+ handle?: string;
222
+ labels?: string;
223
+ };
224
+ onchange?: (detail: {
225
+ xDomain?: import("../../utils/scales").DomainType;
226
+ yDomain?: import("../../utils/scales").DomainType;
227
+ }) => void;
228
+ onbrushstart?: (detail: {
229
+ xDomain?: import("../../utils/scales").DomainType;
230
+ yDomain?: import("../../utils/scales").DomainType;
231
+ }) => void;
232
+ onbrushend?: (detail: {
233
+ xDomain?: import("../../utils/scales").DomainType;
234
+ yDomain?: import("../../utils/scales").DomainType;
235
+ }) => void;
236
+ onreset?: (detail: {
237
+ xDomain?: import("../../utils/scales").DomainType;
238
+ yDomain?: import("../../utils/scales").DomainType;
239
+ }) => void;
240
+ brush?: import("svelte/store").Writable<import("../BrushContext.svelte").BrushContextValue>;
206
241
  }> | undefined;
242
+ brushContext?: import("svelte/store").Writable<import("../BrushContext.svelte").BrushContextValue> | undefined;
207
243
  onresize?: ((e: import("../ChartContext.svelte").ChartResizeDetail) => void) | undefined;
208
244
  ondragstart?: (() => void) | undefined;
209
245
  ondragend?: (() => void) | undefined;
@@ -6,7 +6,7 @@
6
6
  import { selectionStore } from '@layerstack/svelte-stores';
7
7
 
8
8
  import Axis from '../Axis.svelte';
9
- import Brush from '../Brush.svelte';
9
+ import BrushContext from '../BrushContext.svelte';
10
10
  import Canvas from '../layout/Canvas.svelte';
11
11
  import Chart from '../Chart.svelte';
12
12
  import ChartClipPath from '../ChartClipPath.svelte';
@@ -44,9 +44,9 @@
44
44
  export let y: Accessor<TData> = undefined;
45
45
 
46
46
  /** Set xDomain. Useful for external brush control */
47
- export let xDomain: ComponentProps<typeof Brush>['xDomain'] = undefined;
47
+ export let xDomain: ComponentProps<typeof BrushContext>['xDomain'] = undefined;
48
48
  /** Set yDomain. Useful for external brush control */
49
- export let yDomain: ComponentProps<typeof Brush>['yDomain'] = undefined;
49
+ export let yDomain: ComponentProps<typeof BrushContext>['yDomain'] = undefined;
50
50
 
51
51
  export let series: {
52
52
  key: string;
@@ -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: ComponentProps<Brush> | boolean = false;
61
+ export let brush: ComponentProps<BrushContext> | 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;
@@ -68,7 +68,7 @@
68
68
  export let ontooltipclick: (e: MouseEvent, detail: { data: any }) => void = () => {};
69
69
 
70
70
  export let props: {
71
- brush?: Partial<ComponentProps<Brush>>;
71
+ brush?: Partial<ComponentProps<BrushContext>>;
72
72
  debug?: typeof debug;
73
73
  grid?: Partial<ComponentProps<Grid>>;
74
74
  highlight?: Partial<ComponentProps<Highlight>>;
@@ -157,6 +157,8 @@
157
157
  );
158
158
  });
159
159
 
160
+ $: brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush };
161
+
160
162
  if (profile) {
161
163
  console.time('ScatterChart render');
162
164
  onMount(() => {
@@ -185,6 +187,20 @@
185
187
  ...props.tooltip?.context,
186
188
  ...$$props.tooltip,
187
189
  }}
190
+ brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
191
+ ? {
192
+ axis: 'both',
193
+ resetOnEnd: true,
194
+ xDomain,
195
+ yDomain,
196
+ ...brushProps,
197
+ onbrushend: (e) => {
198
+ xDomain = e.xDomain;
199
+ yDomain = e.yDomain;
200
+ brushProps.onbrushend?.(e);
201
+ },
202
+ }
203
+ : false}
188
204
  let:x
189
205
  let:xScale
190
206
  let:y
@@ -275,25 +291,6 @@
275
291
  {/if}
276
292
  </svelte:component>
277
293
 
278
- <!-- TODO: Determine how to coordinate with `tooltip={{ mode: 'voronoi' }} -->
279
- {#if brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')}
280
- <Svg>
281
- {@const brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush }}
282
- <Brush
283
- axis="both"
284
- resetOnEnd
285
- {xDomain}
286
- {yDomain}
287
- {...brushProps}
288
- onbrushend={(e) => {
289
- xDomain = e.xDomain;
290
- yDomain = e.yDomain;
291
- brushProps.onbrushend?.(e);
292
- }}
293
- />
294
- </Svg>
295
- {/if}
296
-
297
294
  <slot name="legend" {...slotProps}>
298
295
  {#if legend}
299
296
  <Legend
@@ -6,8 +6,8 @@ export { default as Axis } from './Axis.svelte';
6
6
  export { default as Bar } from './Bar.svelte';
7
7
  export { default as Bars } from './Bars.svelte';
8
8
  export { default as Blur } from './Blur.svelte';
9
- export { default as Brush } from './Brush.svelte';
10
9
  export { default as Bounds } from './Bounds.svelte';
10
+ export { default as BrushContext } from './BrushContext.svelte';
11
11
  export { default as Calendar } from './Calendar.svelte';
12
12
  export { default as Canvas } from './layout/Canvas.svelte';
13
13
  export { default as Chart } from './Chart.svelte';
@@ -7,8 +7,8 @@ export { default as Axis } from './Axis.svelte';
7
7
  export { default as Bar } from './Bar.svelte';
8
8
  export { default as Bars } from './Bars.svelte';
9
9
  export { default as Blur } from './Blur.svelte';
10
- export { default as Brush } from './Brush.svelte';
11
10
  export { default as Bounds } from './Bounds.svelte';
11
+ export { default as BrushContext } from './BrushContext.svelte';
12
12
  export { default as Calendar } from './Calendar.svelte';
13
13
  export { default as Canvas } from './layout/Canvas.svelte';
14
14
  export { default as Chart } from './Chart.svelte';
@@ -115,8 +115,8 @@
115
115
 
116
116
  /** Exposed to allow binding in Chart */
117
117
  export let tooltip = writable({
118
- y: 0,
119
118
  x: 0,
119
+ y: 0,
120
120
  data: null as any,
121
121
  show: showTooltip,
122
122
  hide: hideTooltip,
@@ -393,12 +393,12 @@
393
393
  <!-- svelte-ignore a11y-click-events-have-key-events -->
394
394
  <!-- svelte-ignore a11y-no-static-element-interactions -->
395
395
  <div
396
- style:width="{$width}px"
397
- style:height="{$height}px"
398
396
  style:top="{$padding.top}px"
399
397
  style:left="{$padding.left}px"
398
+ style:width="{$width}px"
399
+ style:height="{$height}px"
400
400
  class={cls(
401
- 'tooltip-trigger absolute touch-none',
401
+ 'TooltipContext absolute touch-none',
402
402
  debug && triggerPointerEvents && 'bg-danger/10 outline outline-danger'
403
403
  )}
404
404
  on:pointerenter={triggerPointerEvents ? showTooltip : undefined}
@@ -410,13 +410,13 @@
410
410
  }
411
411
  }}
412
412
  >
413
- <!-- Rendering slot within tooltip-trigger allows pointer events to bubble up (ex. Brush) -->
413
+ <!-- Rendering slot within TooltipContext to allow pointer events to bubble up (ex. Brush) -->
414
414
  <div
415
415
  class="absolute"
416
- style:width="{$containerWidth}px"
417
- style:height="{$containerHeight}px"
418
416
  style:top="-{$padding.top ?? 0}px"
419
417
  style:left="-{$padding.left ?? 0}px"
418
+ style:width="{$containerWidth}px"
419
+ style:height="{$containerHeight}px"
420
420
  >
421
421
  <slot tooltip={$tooltip} />
422
422
 
@@ -30,8 +30,8 @@ declare const __propDef: {
30
30
  data: any;
31
31
  }) => any;
32
32
  /** Exposed to allow binding in Chart */ tooltip?: import("svelte/store").Writable<{
33
- y: number;
34
33
  x: number;
34
+ y: number;
35
35
  data: any;
36
36
  show: (e: PointerEvent, tooltipData?: any) => void;
37
37
  hide: () => void;
@@ -44,8 +44,8 @@ declare const __propDef: {
44
44
  slots: {
45
45
  default: {
46
46
  tooltip: {
47
- y: number;
48
47
  x: number;
48
+ y: number;
49
49
  data: any;
50
50
  show: (e: PointerEvent, tooltipData?: any) => void;
51
51
  hide: () => void;
@@ -29,3 +29,5 @@ export declare function celsiusToFahrenheit(temperature: number): number;
29
29
  export declare function fahrenheitToCelsius(temperature: number): number;
30
30
  /** Parse percent string (`50%`) to decimal (`0.5`) */
31
31
  export declare function parsePercent(percent: string | number): number;
32
+ /** Add second value while maintaining `Date` or `number` type */
33
+ export declare function add(value1: Date | number, value2: number): number | Date;
@@ -55,3 +55,12 @@ export function parsePercent(percent) {
55
55
  return Number(percent.replace('%', '')) / 100;
56
56
  }
57
57
  }
58
+ /** Add second value while maintaining `Date` or `number` type */
59
+ export function add(value1, value2) {
60
+ if (value1 instanceof Date) {
61
+ return new Date(value1.getTime() + value2);
62
+ }
63
+ else {
64
+ return value1 + value2;
65
+ }
66
+ }
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.92.1",
7
+ "version": "0.93.1",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.27.12",
10
10
  "@mdi/js": "^7.4.47",