layerchart 0.92.1 → 0.93.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.
- package/dist/components/BrushContext.svelte +476 -0
- package/dist/components/BrushContext.svelte.d.ts +73 -0
- package/dist/components/Chart.svelte +64 -47
- package/dist/components/Chart.svelte.d.ts +51 -12
- package/dist/components/charts/AreaChart.svelte +27 -22
- package/dist/components/charts/LineChart.svelte +23 -21
- package/dist/components/charts/PieChart.svelte.d.ts +45 -9
- package/dist/components/charts/ScatterChart.svelte +21 -24
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/tooltip/TooltipContext.svelte +7 -7
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +2 -2
- package/dist/utils/math.d.ts +2 -0
- package/dist/utils/math.js +9 -0
- package/package.json +1 -1
- package/dist/components/Brush.svelte +0 -436
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import GeoContext from './GeoContext.svelte';
|
|
10
10
|
import TooltipContext from './tooltip/TooltipContext.svelte';
|
|
11
11
|
import TransformContext from './TransformContext.svelte';
|
|
12
|
+
import BrushContext from './BrushContext.svelte';
|
|
12
13
|
|
|
13
14
|
import { accessor, type Accessor } from '../utils/common.js';
|
|
14
15
|
import { isScaleBand, type AnyScale, type DomainType } from '../utils/scales.js';
|
|
@@ -195,20 +196,26 @@
|
|
|
195
196
|
/** Props passed to GeoContext */
|
|
196
197
|
geo?: typeof geo;
|
|
197
198
|
|
|
199
|
+
/** Exposed via bind: to support `bind:geoProjection` for external access */
|
|
200
|
+
geoProjection?: typeof geoProjection;
|
|
201
|
+
|
|
198
202
|
/** Props passed to TooltipContext */
|
|
199
203
|
tooltip?: typeof tooltip;
|
|
200
204
|
|
|
205
|
+
/** Exposed via bind: to support `bind:tooltipContext` for external access (ex. `tooltipContext.data) */
|
|
206
|
+
tooltipContext?: typeof tooltipContext;
|
|
207
|
+
|
|
201
208
|
/** Props passed to TransformContext */
|
|
202
209
|
transform?: typeof transform;
|
|
203
210
|
|
|
204
211
|
/** Expose to support `bind:transformContext` for imperative control (`transformContext.translate(...)`) */
|
|
205
212
|
transformContext?: typeof transformContext;
|
|
206
213
|
|
|
207
|
-
/**
|
|
208
|
-
|
|
214
|
+
/** Props passed to BrushContext */
|
|
215
|
+
brush?: typeof brush;
|
|
209
216
|
|
|
210
|
-
/** Exposed via bind: to support `bind:
|
|
211
|
-
|
|
217
|
+
/** Exposed via bind: to support `bind:brushContext` for external access (ex. `brushContext.xDomain) */
|
|
218
|
+
brushContext?: typeof brushContext;
|
|
212
219
|
|
|
213
220
|
// ChartContext callback events
|
|
214
221
|
onresize?: typeof onresize;
|
|
@@ -278,19 +285,25 @@
|
|
|
278
285
|
/** Props passed to GeoContext */
|
|
279
286
|
export let geo: Partial<ComponentProps<GeoContext>> | undefined = undefined;
|
|
280
287
|
|
|
288
|
+
/** Expose bound geo projection context */
|
|
289
|
+
export let geoProjection: ComponentProps<GeoContext>['geo'] = undefined;
|
|
290
|
+
|
|
281
291
|
/** Props passed to TooltipContext */
|
|
282
292
|
export let tooltip: Partial<ComponentProps<TooltipContext>> | boolean | undefined = undefined;
|
|
283
293
|
|
|
294
|
+
/** Expose bound tooltip context */
|
|
295
|
+
export let tooltipContext: ComponentProps<TooltipContext>['tooltip'] = undefined;
|
|
296
|
+
|
|
284
297
|
/** Props passed to TransformContext */
|
|
285
298
|
export let transform: Partial<ComponentProps<TransformContext>> | undefined = undefined;
|
|
286
299
|
// @ts-expect-error will only be undefined until bind:transformContext runs
|
|
287
300
|
export let transformContext: TransformContext = undefined;
|
|
288
301
|
|
|
289
|
-
/**
|
|
290
|
-
export let
|
|
302
|
+
/** Props passed to BrushContext */
|
|
303
|
+
export let brush: Partial<ComponentProps<BrushContext>> | boolean | undefined = undefined;
|
|
291
304
|
|
|
292
|
-
/** Expose bound
|
|
293
|
-
export let
|
|
305
|
+
/** Expose bound brush context */
|
|
306
|
+
export let brushContext: ComponentProps<BrushContext>['brush'] = undefined;
|
|
294
307
|
|
|
295
308
|
export let onresize: ComponentProps<ChartContext<TData>>['onresize'] = undefined;
|
|
296
309
|
export let ondragstart: ComponentProps<TransformContext>['ondragstart'] = undefined;
|
|
@@ -419,45 +432,49 @@
|
|
|
419
432
|
{ondragend}
|
|
420
433
|
>
|
|
421
434
|
<GeoContext {...geo} bind:geo={geoProjection} let:projection>
|
|
422
|
-
{@const
|
|
423
|
-
<
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
435
|
+
{@const brushProps = typeof brush === 'object' ? brush : { disabled: !brush }}
|
|
436
|
+
<BrushContext {...brushProps} bind:brush={brushContext} let:brush>
|
|
437
|
+
{@const tooltipProps = typeof tooltip === 'object' ? tooltip : {}}
|
|
438
|
+
<TooltipContext {...tooltipProps} bind:tooltip={tooltipContext} let:tooltip>
|
|
439
|
+
<slot
|
|
440
|
+
{aspectRatio}
|
|
441
|
+
{containerHeight}
|
|
442
|
+
{containerWidth}
|
|
443
|
+
{height}
|
|
444
|
+
{width}
|
|
445
|
+
{element}
|
|
446
|
+
{projection}
|
|
447
|
+
transform={_transform}
|
|
448
|
+
{tooltip}
|
|
449
|
+
{brush}
|
|
450
|
+
{x}
|
|
451
|
+
{xScale}
|
|
452
|
+
{xGet}
|
|
453
|
+
{y}
|
|
454
|
+
{yScale}
|
|
455
|
+
{yGet}
|
|
456
|
+
{z}
|
|
457
|
+
{zScale}
|
|
458
|
+
{zGet}
|
|
459
|
+
{r}
|
|
460
|
+
{rScale}
|
|
461
|
+
{rGet}
|
|
462
|
+
{x1}
|
|
463
|
+
{x1Scale}
|
|
464
|
+
{x1Get}
|
|
465
|
+
{y1}
|
|
466
|
+
{y1Scale}
|
|
467
|
+
{y1Get}
|
|
468
|
+
{c}
|
|
469
|
+
{cScale}
|
|
470
|
+
{cGet}
|
|
471
|
+
{padding}
|
|
472
|
+
{data}
|
|
473
|
+
{flatData}
|
|
474
|
+
{config}
|
|
475
|
+
/>
|
|
476
|
+
</TooltipContext>
|
|
477
|
+
</BrushContext>
|
|
461
478
|
</GeoContext>
|
|
462
479
|
</TransformContext>
|
|
463
480
|
{/key}
|
|
@@ -182,6 +182,8 @@ declare class __sveltets_Render<TData> {
|
|
|
182
182
|
reflectY?: boolean | undefined;
|
|
183
183
|
geo?: import("svelte/store").Writable<import("d3-geo").GeoProjection>;
|
|
184
184
|
}> | undefined;
|
|
185
|
+
/** Exposed via bind: to support `bind:geoProjection` for external access */
|
|
186
|
+
geoProjection?: import("svelte/store").Writable<import("d3-geo").GeoProjection> | undefined;
|
|
185
187
|
/** Props passed to TooltipContext */
|
|
186
188
|
tooltip?: boolean | Partial<{
|
|
187
189
|
mode?: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
|
|
@@ -194,14 +196,23 @@ declare class __sveltets_Render<TData> {
|
|
|
194
196
|
data: any;
|
|
195
197
|
}) => any;
|
|
196
198
|
tooltip?: import("svelte/store").Writable<{
|
|
197
|
-
y: number;
|
|
198
199
|
x: number;
|
|
200
|
+
y: number;
|
|
199
201
|
data: any;
|
|
200
202
|
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
201
203
|
hide: () => void;
|
|
202
204
|
mode: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
|
|
203
205
|
}>;
|
|
204
206
|
}> | undefined;
|
|
207
|
+
/** Exposed via bind: to support `bind:tooltipContext` for external access (ex. `tooltipContext.data) */
|
|
208
|
+
tooltipContext?: import("svelte/store").Writable<{
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
data: any;
|
|
212
|
+
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
213
|
+
hide: () => void;
|
|
214
|
+
mode: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
|
|
215
|
+
}> | undefined;
|
|
205
216
|
/** Props passed to TransformContext */
|
|
206
217
|
transform?: Partial<{
|
|
207
218
|
mode?: "canvas" | "manual" | "none";
|
|
@@ -260,17 +271,44 @@ declare class __sveltets_Render<TData> {
|
|
|
260
271
|
}> | undefined;
|
|
261
272
|
/** Expose to support `bind:transformContext` for imperative control (`transformContext.translate(...)`) */
|
|
262
273
|
transformContext?: TransformContext;
|
|
263
|
-
/**
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
/** Props passed to BrushContext */
|
|
275
|
+
brush?: boolean | Partial<{
|
|
276
|
+
axis?: "x" | "y" | "both";
|
|
277
|
+
handleSize?: number;
|
|
278
|
+
resetOnEnd?: boolean;
|
|
279
|
+
xDomain?: DomainType;
|
|
280
|
+
yDomain?: DomainType;
|
|
281
|
+
mode?: "integrated" | "separated";
|
|
282
|
+
disabled?: boolean;
|
|
283
|
+
range?: Partial<import("svelte/elements").HTMLAttributes<HTMLDivElement>> | undefined;
|
|
284
|
+
handle?: Partial<import("svelte/elements").HTMLAttributes<HTMLDivElement>> | undefined;
|
|
285
|
+
classes?: {
|
|
286
|
+
root?: string;
|
|
287
|
+
frame?: string;
|
|
288
|
+
range?: string;
|
|
289
|
+
handle?: string;
|
|
290
|
+
labels?: string;
|
|
291
|
+
};
|
|
292
|
+
onchange?: (detail: {
|
|
293
|
+
xDomain?: DomainType;
|
|
294
|
+
yDomain?: DomainType;
|
|
295
|
+
}) => void;
|
|
296
|
+
onbrushstart?: (detail: {
|
|
297
|
+
xDomain?: DomainType;
|
|
298
|
+
yDomain?: DomainType;
|
|
299
|
+
}) => void;
|
|
300
|
+
onbrushend?: (detail: {
|
|
301
|
+
xDomain?: DomainType;
|
|
302
|
+
yDomain?: DomainType;
|
|
303
|
+
}) => void;
|
|
304
|
+
onreset?: (detail: {
|
|
305
|
+
xDomain?: DomainType;
|
|
306
|
+
yDomain?: DomainType;
|
|
307
|
+
}) => void;
|
|
308
|
+
brush?: import("svelte/store").Writable<import("./BrushContext.svelte").BrushContextValue>;
|
|
273
309
|
}> | undefined;
|
|
310
|
+
/** Exposed via bind: to support `bind:brushContext` for external access (ex. `brushContext.xDomain) */
|
|
311
|
+
brushContext?: import("svelte/store").Writable<import("./BrushContext.svelte").BrushContextValue> | undefined;
|
|
274
312
|
onresize?: ((e: import("./ChartContext.svelte").ChartResizeDetail) => void) | undefined;
|
|
275
313
|
ondragstart?: (() => void) | undefined;
|
|
276
314
|
ondragend?: (() => void) | undefined;
|
|
@@ -315,13 +353,14 @@ declare class __sveltets_Render<TData> {
|
|
|
315
353
|
reset: () => void;
|
|
316
354
|
};
|
|
317
355
|
tooltip: {
|
|
318
|
-
y: number;
|
|
319
356
|
x: number;
|
|
357
|
+
y: number;
|
|
320
358
|
data: any;
|
|
321
359
|
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
322
360
|
hide: () => void;
|
|
323
361
|
mode: "manual" | "bisect-x" | "bisect-y" | "band" | "bisect-band" | "bounds" | "voronoi" | "quadtree";
|
|
324
362
|
};
|
|
363
|
+
brush: import("./BrushContext.svelte").BrushContextValue;
|
|
325
364
|
x: Function;
|
|
326
365
|
xScale: any;
|
|
327
366
|
xGet: any;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import Area from '../Area.svelte';
|
|
11
11
|
import Axis from '../Axis.svelte';
|
|
12
|
-
import
|
|
12
|
+
import BrushContext from '../BrushContext.svelte';
|
|
13
13
|
import Canvas from '../layout/Canvas.svelte';
|
|
14
14
|
import Chart from '../Chart.svelte';
|
|
15
15
|
import ChartClipPath from '../ChartClipPath.svelte';
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
export let y: Accessor<TData> = undefined;
|
|
56
56
|
|
|
57
57
|
/** Set xDomain. Useful for external brush control */
|
|
58
|
-
export let xDomain: ComponentProps<typeof
|
|
58
|
+
export let xDomain: ComponentProps<typeof BrushContext>['xDomain'] = undefined;
|
|
59
59
|
|
|
60
60
|
/** Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
61
61
|
export let radial = false;
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
$: stackSeries = seriesLayout.startsWith('stack');
|
|
77
77
|
|
|
78
78
|
export let axis: ComponentProps<Axis> | 'x' | 'y' | boolean = true;
|
|
79
|
-
export let brush: ComponentProps<
|
|
79
|
+
export let brush: ComponentProps<BrushContext> | boolean = false;
|
|
80
80
|
export let grid: ComponentProps<Grid> | boolean = true;
|
|
81
81
|
export let labels: ComponentProps<Labels> | boolean = false;
|
|
82
82
|
export let legend: ComponentProps<Legend> | boolean = false;
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
|
|
98
98
|
export let props: {
|
|
99
99
|
area?: Partial<ComponentProps<Area>>;
|
|
100
|
-
brush?: Partial<ComponentProps<
|
|
100
|
+
brush?: Partial<ComponentProps<BrushContext>>;
|
|
101
101
|
grid?: Partial<ComponentProps<Grid>>;
|
|
102
102
|
highlight?: Partial<ComponentProps<Highlight>>;
|
|
103
103
|
labels?: Partial<ComponentProps<Labels>>;
|
|
@@ -185,7 +185,11 @@
|
|
|
185
185
|
...s.props,
|
|
186
186
|
class: cls(
|
|
187
187
|
'transition-opacity',
|
|
188
|
-
|
|
188
|
+
// Checking `visibleSeries.length > 1` fixes re-animated tweened areas on hover
|
|
189
|
+
visibleSeries.length > 1 &&
|
|
190
|
+
highlightSeriesKey &&
|
|
191
|
+
highlightSeriesKey !== s.key &&
|
|
192
|
+
'opacity-10',
|
|
189
193
|
props.area?.class,
|
|
190
194
|
s.props?.class
|
|
191
195
|
),
|
|
@@ -194,7 +198,10 @@
|
|
|
194
198
|
...lineProps,
|
|
195
199
|
class: cls(
|
|
196
200
|
'transition-opacity',
|
|
197
|
-
|
|
201
|
+
visibleSeries.length > 1 &&
|
|
202
|
+
highlightSeriesKey &&
|
|
203
|
+
highlightSeriesKey !== s.key &&
|
|
204
|
+
'opacity-10',
|
|
198
205
|
lineProps.class
|
|
199
206
|
),
|
|
200
207
|
},
|
|
@@ -255,6 +262,8 @@
|
|
|
255
262
|
);
|
|
256
263
|
});
|
|
257
264
|
|
|
265
|
+
$: brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush };
|
|
266
|
+
|
|
258
267
|
if (profile) {
|
|
259
268
|
console.time('AreaChart render');
|
|
260
269
|
onMount(() => {
|
|
@@ -286,6 +295,18 @@
|
|
|
286
295
|
...props.tooltip?.context,
|
|
287
296
|
...$$props.tooltip,
|
|
288
297
|
}}
|
|
298
|
+
brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
|
|
299
|
+
? {
|
|
300
|
+
axis: 'x',
|
|
301
|
+
resetOnEnd: true,
|
|
302
|
+
xDomain,
|
|
303
|
+
...brushProps,
|
|
304
|
+
onbrushend: (e) => {
|
|
305
|
+
xDomain = e.xDomain;
|
|
306
|
+
brushProps.onbrushend?.(e);
|
|
307
|
+
},
|
|
308
|
+
}
|
|
309
|
+
: false}
|
|
289
310
|
let:x
|
|
290
311
|
let:xScale
|
|
291
312
|
let:y
|
|
@@ -404,22 +425,6 @@
|
|
|
404
425
|
{/if}
|
|
405
426
|
</svelte:component>
|
|
406
427
|
|
|
407
|
-
{#if brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')}
|
|
408
|
-
<Svg>
|
|
409
|
-
{@const brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush }}
|
|
410
|
-
<Brush
|
|
411
|
-
axis="x"
|
|
412
|
-
resetOnEnd
|
|
413
|
-
{xDomain}
|
|
414
|
-
{...brushProps}
|
|
415
|
-
onbrushend={(e) => {
|
|
416
|
-
xDomain = e.xDomain;
|
|
417
|
-
brushProps.onbrushend?.(e);
|
|
418
|
-
}}
|
|
419
|
-
/>
|
|
420
|
-
</Svg>
|
|
421
|
-
{/if}
|
|
422
|
-
|
|
423
428
|
<slot name="legend" {...slotProps}>
|
|
424
429
|
{#if legend}
|
|
425
430
|
<Legend
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { selectionStore } from '@layerstack/svelte-stores';
|
|
7
7
|
|
|
8
8
|
import Axis from '../Axis.svelte';
|
|
9
|
-
import
|
|
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';
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
export let y: Accessor<TData> = undefined;
|
|
52
52
|
|
|
53
53
|
/** Set xDomain. Useful for external brush control */
|
|
54
|
-
export let xDomain: ComponentProps<typeof
|
|
54
|
+
export let xDomain: ComponentProps<typeof BrushContext>['xDomain'] = undefined;
|
|
55
55
|
|
|
56
56
|
/** Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
57
57
|
export let radial = false;
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
$: isDefaultSeries = series.length === 1 && series[0].key === 'default';
|
|
69
69
|
|
|
70
70
|
export let axis: ComponentProps<Axis> | 'x' | 'y' | boolean = true;
|
|
71
|
-
export let brush: ComponentProps<
|
|
71
|
+
export let brush: ComponentProps<BrushContext> | boolean = false;
|
|
72
72
|
export let grid: ComponentProps<Grid> | boolean = true;
|
|
73
73
|
export let labels: ComponentProps<Labels> | boolean = false;
|
|
74
74
|
export let legend: ComponentProps<Legend> | boolean = false;
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
) => void = () => {};
|
|
89
89
|
|
|
90
90
|
export let props: {
|
|
91
|
-
brush?: Partial<ComponentProps<
|
|
91
|
+
brush?: Partial<ComponentProps<BrushContext>>;
|
|
92
92
|
grid?: Partial<ComponentProps<Grid>>;
|
|
93
93
|
highlight?: Partial<ComponentProps<Highlight>>;
|
|
94
94
|
labels?: Partial<ComponentProps<Labels>>;
|
|
@@ -139,7 +139,11 @@
|
|
|
139
139
|
...s.props,
|
|
140
140
|
class: cls(
|
|
141
141
|
'transition-opacity',
|
|
142
|
-
|
|
142
|
+
// Checking `visibleSeries.length > 1` fixes re-animated tweened areas on hover
|
|
143
|
+
visibleSeries.length > 1 &&
|
|
144
|
+
highlightSeriesKey &&
|
|
145
|
+
highlightSeriesKey !== s.key &&
|
|
146
|
+
'opacity-10',
|
|
143
147
|
props.spline?.class,
|
|
144
148
|
s.props?.class
|
|
145
149
|
),
|
|
@@ -192,6 +196,8 @@
|
|
|
192
196
|
);
|
|
193
197
|
});
|
|
194
198
|
|
|
199
|
+
$: brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush };
|
|
200
|
+
|
|
195
201
|
if (profile) {
|
|
196
202
|
console.time('LineChart render');
|
|
197
203
|
onMount(() => {
|
|
@@ -220,6 +226,18 @@
|
|
|
220
226
|
...props.tooltip?.context,
|
|
221
227
|
...$$props.tooltip,
|
|
222
228
|
}}
|
|
229
|
+
brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
|
|
230
|
+
? {
|
|
231
|
+
axis: 'x',
|
|
232
|
+
resetOnEnd: true,
|
|
233
|
+
xDomain,
|
|
234
|
+
...brushProps,
|
|
235
|
+
onbrushend: (e) => {
|
|
236
|
+
xDomain = e.xDomain;
|
|
237
|
+
brushProps.onbrushend?.(e);
|
|
238
|
+
},
|
|
239
|
+
}
|
|
240
|
+
: false}
|
|
223
241
|
let:x
|
|
224
242
|
let:xScale
|
|
225
243
|
let:y
|
|
@@ -330,22 +348,6 @@
|
|
|
330
348
|
</slot>
|
|
331
349
|
</svelte:component>
|
|
332
350
|
|
|
333
|
-
{#if brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')}
|
|
334
|
-
<Svg>
|
|
335
|
-
{@const brushProps = { ...(typeof brush === 'object' ? brush : null), ...props.brush }}
|
|
336
|
-
<Brush
|
|
337
|
-
axis="x"
|
|
338
|
-
resetOnEnd
|
|
339
|
-
{xDomain}
|
|
340
|
-
{...brushProps}
|
|
341
|
-
onbrushend={(e) => {
|
|
342
|
-
xDomain = e.xDomain;
|
|
343
|
-
brushProps.onbrushend?.(e);
|
|
344
|
-
}}
|
|
345
|
-
/>
|
|
346
|
-
</Svg>
|
|
347
|
-
{/if}
|
|
348
|
-
|
|
349
351
|
<slot name="legend" {...slotProps}>
|
|
350
352
|
{#if legend}
|
|
351
353
|
<Legend
|
|
@@ -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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
|
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
|
|
47
|
+
export let xDomain: ComponentProps<typeof BrushContext>['xDomain'] = undefined;
|
|
48
48
|
/** Set yDomain. Useful for external brush control */
|
|
49
|
-
export let yDomain: ComponentProps<typeof
|
|
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<
|
|
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<
|
|
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,7 +6,6 @@ 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';
|
|
11
10
|
export { default as Calendar } from './Calendar.svelte';
|
|
12
11
|
export { default as Canvas } from './layout/Canvas.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -7,7 +7,6 @@ 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';
|
|
12
11
|
export { default as Calendar } from './Calendar.svelte';
|
|
13
12
|
export { default as Canvas } from './layout/Canvas.svelte';
|