layerchart 2.0.0-next.2 → 2.0.0-next.20
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/AnnotationLine.svelte +17 -29
- package/dist/components/AnnotationLine.svelte.d.ts +4 -2
- package/dist/components/AnnotationPoint.svelte +11 -13
- package/dist/components/AnnotationPoint.svelte.d.ts +4 -2
- package/dist/components/AnnotationRange.svelte +3 -3
- package/dist/components/Arc.svelte +2 -2
- package/dist/components/Axis.svelte +52 -24
- package/dist/components/Axis.svelte.d.ts +14 -3
- package/dist/components/Bar.svelte +7 -4
- package/dist/components/Bar.svelte.d.ts +4 -1
- package/dist/components/Bars.svelte +9 -6
- package/dist/components/Bars.svelte.d.ts +3 -3
- package/dist/components/Blur.svelte +20 -12
- package/dist/components/Blur.svelte.d.ts +2 -5
- package/dist/components/Calendar.svelte +10 -6
- package/dist/components/Calendar.svelte.d.ts +2 -1
- package/dist/components/Chart.svelte +2 -2
- package/dist/components/ClipPath.svelte +14 -9
- package/dist/components/Connector.svelte +2 -2
- package/dist/components/Connector.svelte.d.ts +1 -1
- package/dist/components/Ellipse.svelte +187 -0
- package/dist/components/Ellipse.svelte.d.ts +64 -0
- package/dist/components/ForceSimulation.svelte +168 -50
- package/dist/components/ForceSimulation.svelte.d.ts +80 -21
- package/dist/components/GeoEdgeFade.svelte +4 -3
- package/dist/components/GeoEdgeFade.svelte.d.ts +2 -2
- package/dist/components/GeoPath.svelte +12 -5
- package/dist/components/GeoPoint.svelte +1 -2
- package/dist/components/GeoSpline.svelte +4 -4
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/Graticule.svelte +3 -2
- package/dist/components/Grid.svelte +8 -7
- package/dist/components/Grid.svelte.d.ts +2 -1
- package/dist/components/Group.svelte +45 -5
- package/dist/components/Group.svelte.d.ts +32 -4
- package/dist/components/Highlight.svelte +1 -1
- package/dist/components/Hull.svelte +4 -4
- package/dist/components/Hull.svelte.d.ts +2 -2
- package/dist/components/Labels.svelte +6 -4
- package/dist/components/Labels.svelte.d.ts +2 -2
- package/dist/components/Legend.svelte +8 -5
- package/dist/components/Legend.svelte.d.ts +3 -3
- package/dist/components/MonthPath.svelte +14 -11
- package/dist/components/MonthPath.svelte.d.ts +4 -3
- package/dist/components/Polygon.svelte +285 -0
- package/dist/components/Polygon.svelte.d.ts +115 -0
- package/dist/components/RadialGradient.svelte +1 -3
- package/dist/components/Rule.svelte +3 -2
- package/dist/components/Spline.svelte +30 -18
- package/dist/components/Spline.svelte.d.ts +12 -4
- package/dist/components/Text.svelte +60 -48
- package/dist/components/Text.svelte.d.ts +6 -0
- package/dist/components/Treemap.svelte +63 -26
- package/dist/components/Treemap.svelte.d.ts +11 -11
- package/dist/components/Voronoi.svelte +55 -36
- package/dist/components/Voronoi.svelte.d.ts +5 -3
- package/dist/components/charts/ArcChart.svelte +2 -2
- package/dist/components/charts/AreaChart.svelte +9 -10
- package/dist/components/charts/BarChart.svelte +63 -53
- package/dist/components/charts/DefaultTooltip.svelte +1 -1
- package/dist/components/charts/LineChart.svelte +8 -5
- package/dist/components/charts/PieChart.svelte +2 -2
- package/dist/components/charts/ScatterChart.svelte +0 -2
- package/dist/components/charts/utils.svelte.d.ts +3 -3
- package/dist/components/charts/utils.svelte.js +7 -3
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/layout/Canvas.svelte +67 -49
- package/dist/components/layout/Canvas.svelte.d.ts +6 -0
- package/dist/components/layout/Layer.svelte +6 -4
- package/dist/components/layout/Layer.svelte.d.ts +6 -4
- package/dist/components/tooltip/Tooltip.svelte +14 -7
- package/dist/components/tooltip/TooltipContext.svelte +25 -8
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipHeader.svelte +5 -4
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipItem.svelte +5 -4
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipList.svelte +1 -1
- package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
- package/dist/docs/Blockquote.svelte +3 -1
- package/dist/docs/Blockquote.svelte.d.ts +4 -19
- package/dist/docs/Code.svelte +20 -12
- package/dist/docs/Code.svelte.d.ts +9 -23
- package/dist/docs/Header1.svelte +4 -2
- package/dist/docs/Header1.svelte.d.ts +4 -28
- package/dist/docs/Json.svelte +11 -3
- package/dist/docs/Json.svelte.d.ts +9 -21
- package/dist/docs/Layout.svelte +10 -7
- package/dist/docs/Layout.svelte.d.ts +4 -19
- package/dist/docs/Link.svelte +7 -3
- package/dist/docs/Link.svelte.d.ts +4 -38
- package/dist/docs/TilesetField.svelte +20 -19
- package/dist/docs/TilesetField.svelte.d.ts +5 -22
- package/dist/docs/ViewSourceButton.svelte +7 -4
- package/dist/docs/ViewSourceButton.svelte.d.ts +7 -21
- package/dist/utils/arcText.svelte.js +4 -4
- package/dist/utils/canvas.d.ts +77 -0
- package/dist/utils/canvas.js +105 -41
- package/dist/utils/genData.d.ts +14 -0
- package/dist/utils/genData.js +24 -6
- package/dist/utils/path.d.ts +10 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/scales.svelte.d.ts +3 -2
- package/dist/utils/scales.svelte.js +7 -3
- package/dist/utils/shape.d.ts +43 -0
- package/dist/utils/shape.js +59 -0
- package/dist/utils/string.d.ts +49 -0
- package/dist/utils/string.js +4 -2
- package/dist/utils/ticks.d.ts +4 -4
- package/dist/utils/ticks.js +106 -159
- package/dist/utils/ticks.test.js +6 -16
- package/dist/utils/treemap.d.ts +1 -1
- package/package.json +25 -22
- package/dist/utils/object.js +0 -2
|
@@ -64,6 +64,13 @@
|
|
|
64
64
|
*/
|
|
65
65
|
ignoreTransform?: boolean;
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Disable the hit canvas (useful when animations are playing)
|
|
69
|
+
*
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
disableHitCanvas?: boolean;
|
|
73
|
+
|
|
67
74
|
/**
|
|
68
75
|
* Show the hit canvas for debugging purposes.
|
|
69
76
|
*
|
|
@@ -144,13 +151,13 @@
|
|
|
144
151
|
import { onMount, untrack, type Snippet } from 'svelte';
|
|
145
152
|
import { cls } from '@layerstack/tailwind';
|
|
146
153
|
import { Logger, localPoint } from '@layerstack/utils';
|
|
147
|
-
import {
|
|
154
|
+
import { MediaQueryPresets } from '@layerstack/svelte-state';
|
|
148
155
|
|
|
149
156
|
import { setRenderContext } from '../Chart.svelte';
|
|
150
157
|
import { getTransformContext } from '../TransformContext.svelte';
|
|
151
158
|
import { getPixelColor, scaleCanvas, type ComputedStylesOptions } from '../../utils/canvas.js';
|
|
152
159
|
import { getColorStr, rgbColorGenerator } from '../../utils/color.js';
|
|
153
|
-
import { Context } from 'runed';
|
|
160
|
+
import { Context, useMutationObserver, watch } from 'runed';
|
|
154
161
|
import type {
|
|
155
162
|
HTMLCanvasAttributes,
|
|
156
163
|
MouseEventHandler,
|
|
@@ -171,6 +178,7 @@
|
|
|
171
178
|
fallback,
|
|
172
179
|
center = false,
|
|
173
180
|
ignoreTransform = false,
|
|
181
|
+
disableHitCanvas = false,
|
|
174
182
|
class: className,
|
|
175
183
|
children,
|
|
176
184
|
onclick,
|
|
@@ -256,6 +264,23 @@
|
|
|
256
264
|
* end HitCanvas
|
|
257
265
|
*/
|
|
258
266
|
|
|
267
|
+
// Invalidate/redraw if color scheme changes, either via browser `prefers-color-scheme` (including emulation) or by changing `<html class="dark">` or `<html data-theme="...">`
|
|
268
|
+
const { dark } = new MediaQueryPresets();
|
|
269
|
+
watch(
|
|
270
|
+
() => dark.current,
|
|
271
|
+
() => {
|
|
272
|
+
canvasContext.invalidate();
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
useMutationObserver(
|
|
276
|
+
() => document.documentElement,
|
|
277
|
+
() => canvasContext.invalidate(),
|
|
278
|
+
{
|
|
279
|
+
attributes: true,
|
|
280
|
+
attributeFilter: ['class', 'data-theme'],
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
|
|
259
284
|
onMount(() => {
|
|
260
285
|
context = ref?.getContext('2d', { willReadFrequently }) as CanvasRenderingContext2D;
|
|
261
286
|
|
|
@@ -263,22 +288,7 @@
|
|
|
263
288
|
willReadFrequently: false, // Explicitly set to `false` to resolve pixel artifacts between fill and stroke with the same color (issue #372)
|
|
264
289
|
}) as CanvasRenderingContext2D;
|
|
265
290
|
|
|
266
|
-
// Invalidate/redraw if color scheme changes, either via browser `prefers-color-scheme` (including emulation) or by changing `<html class="dark">` or `<html data-theme="...">`
|
|
267
|
-
darkColorScheme.subscribe(() => {
|
|
268
|
-
canvasContext.invalidate();
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
const observer = new MutationObserver(() => {
|
|
272
|
-
canvasContext.invalidate();
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
observer.observe(document.documentElement, {
|
|
276
|
-
attributes: true,
|
|
277
|
-
attributeFilter: ['class', 'data-theme'],
|
|
278
|
-
});
|
|
279
|
-
|
|
280
291
|
return () => {
|
|
281
|
-
observer.disconnect();
|
|
282
292
|
if (frameId) {
|
|
283
293
|
cancelAnimationFrame(frameId);
|
|
284
294
|
}
|
|
@@ -336,45 +346,53 @@
|
|
|
336
346
|
context.restore();
|
|
337
347
|
}
|
|
338
348
|
|
|
339
|
-
|
|
349
|
+
/*
|
|
350
|
+
* Sync hit canvas with main canvas
|
|
351
|
+
*/
|
|
340
352
|
if (hitCanvasContext) {
|
|
341
|
-
// scale hit canvas to match main canvas
|
|
342
|
-
scaleCanvas(hitCanvasContext, ctx.containerWidth, ctx.containerHeight);
|
|
343
|
-
hitCanvasContext.clearRect(0, 0, ctx.containerWidth, ctx.containerHeight);
|
|
344
|
-
|
|
345
|
-
// reset and sync transform to the state after retainState components
|
|
346
|
-
hitCanvasContext.resetTransform();
|
|
347
|
-
hitCanvasContext.setTransform(mainTransformAfterRetain);
|
|
348
|
-
|
|
349
|
-
// reset color generator
|
|
350
|
-
colorGenerator = rgbColorGenerator();
|
|
351
|
-
|
|
352
353
|
const inactiveMoving = !activeCanvas && transformCtx.moving;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
354
|
+
if (disableHitCanvas || transformCtx.dragging || inactiveMoving) {
|
|
355
|
+
// Skip rendering hit canvas
|
|
356
|
+
hitCanvasContext.clearRect(0, 0, ctx.containerWidth, ctx.containerHeight);
|
|
357
|
+
} else {
|
|
358
|
+
// scale hit canvas to match main canvas
|
|
359
|
+
scaleCanvas(hitCanvasContext, ctx.containerWidth, ctx.containerHeight);
|
|
360
|
+
hitCanvasContext.clearRect(0, 0, ctx.containerWidth, ctx.containerHeight);
|
|
361
|
+
|
|
362
|
+
// reset and sync transform to the state after retainState components
|
|
363
|
+
hitCanvasContext.resetTransform();
|
|
364
|
+
hitCanvasContext.setTransform(mainTransformAfterRetain);
|
|
365
|
+
|
|
366
|
+
// reset color generator
|
|
367
|
+
colorGenerator = rgbColorGenerator();
|
|
368
|
+
|
|
369
|
+
// render retainState components on hit canvas (e.g., Group)
|
|
370
|
+
for (const c of retainStateComponents) {
|
|
371
|
+
const componentHasEvents =
|
|
372
|
+
c.events && Object.values(c.events).filter((d) => d).length > 0;
|
|
373
|
+
|
|
374
|
+
if (componentHasEvents) {
|
|
375
|
+
// since the transform was already applied via setTransform, skip rendering
|
|
376
|
+
// the retainState component's transform again; proceed to its children
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
362
379
|
}
|
|
363
|
-
}
|
|
364
380
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
381
|
+
// render non-retainState components on hit canvas
|
|
382
|
+
for (const c of nonRetainStateComponents) {
|
|
383
|
+
const componentHasEvents =
|
|
384
|
+
c.events && Object.values(c.events).filter((d) => d).length > 0;
|
|
368
385
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
386
|
+
if (componentHasEvents) {
|
|
387
|
+
const color = getColorStr(colorGenerator.next().value);
|
|
388
|
+
const styleOverrides = { styles: { fill: color, stroke: color, _fillOpacity: 0.1 } };
|
|
372
389
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
390
|
+
hitCanvasContext.save();
|
|
391
|
+
c.render(hitCanvasContext, styleOverrides);
|
|
392
|
+
hitCanvasContext.restore();
|
|
376
393
|
|
|
377
|
-
|
|
394
|
+
componentByColor.set(color, c);
|
|
395
|
+
}
|
|
378
396
|
}
|
|
379
397
|
}
|
|
380
398
|
}
|
|
@@ -55,6 +55,12 @@ export type CanvasPropsWithoutHTML = {
|
|
|
55
55
|
* @default false
|
|
56
56
|
*/
|
|
57
57
|
ignoreTransform?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Disable the hit canvas (useful when animations are playing)
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
disableHitCanvas?: boolean;
|
|
58
64
|
/**
|
|
59
65
|
* Show the hit canvas for debugging purposes.
|
|
60
66
|
*
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
export type CanvasLayerProps = {
|
|
5
5
|
type: 'canvas';
|
|
6
|
-
} & Omit<ComponentProps<typeof Canvas>, 'type'>;
|
|
6
|
+
} & Omit<ComponentProps<typeof Canvas>, 'type' | 'onpointermove'>;
|
|
7
7
|
|
|
8
8
|
export type HtmlLayerProps = {
|
|
9
9
|
type: 'html';
|
|
10
|
-
} & Omit<ComponentProps<typeof Html>, 'type'>;
|
|
10
|
+
} & Omit<ComponentProps<typeof Html>, 'type' | 'onpointermove'>;
|
|
11
11
|
|
|
12
12
|
export type SvgLayerProps = {
|
|
13
13
|
type: 'svg';
|
|
14
|
-
} & Omit<ComponentProps<typeof Svg>, 'type'>;
|
|
14
|
+
} & Omit<ComponentProps<typeof Svg>, 'type' | 'onpointermove'>;
|
|
15
15
|
|
|
16
|
-
export type LayerProps = CanvasLayerProps | HtmlLayerProps | SvgLayerProps
|
|
16
|
+
export type LayerProps = (CanvasLayerProps | HtmlLayerProps | SvgLayerProps) & {
|
|
17
|
+
onpointermove?: (e: PointerEvent) => void;
|
|
18
|
+
};
|
|
17
19
|
</script>
|
|
18
20
|
|
|
19
21
|
<script lang="ts">
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { ComponentProps } from 'svelte';
|
|
2
2
|
export type CanvasLayerProps = {
|
|
3
3
|
type: 'canvas';
|
|
4
|
-
} & Omit<ComponentProps<typeof Canvas>, 'type'>;
|
|
4
|
+
} & Omit<ComponentProps<typeof Canvas>, 'type' | 'onpointermove'>;
|
|
5
5
|
export type HtmlLayerProps = {
|
|
6
6
|
type: 'html';
|
|
7
|
-
} & Omit<ComponentProps<typeof Html>, 'type'>;
|
|
7
|
+
} & Omit<ComponentProps<typeof Html>, 'type' | 'onpointermove'>;
|
|
8
8
|
export type SvgLayerProps = {
|
|
9
9
|
type: 'svg';
|
|
10
|
-
} & Omit<ComponentProps<typeof Svg>, 'type'>;
|
|
11
|
-
export type LayerProps = CanvasLayerProps | HtmlLayerProps | SvgLayerProps
|
|
10
|
+
} & Omit<ComponentProps<typeof Svg>, 'type' | 'onpointermove'>;
|
|
11
|
+
export type LayerProps = (CanvasLayerProps | HtmlLayerProps | SvgLayerProps) & {
|
|
12
|
+
onpointermove?: (e: PointerEvent) => void;
|
|
13
|
+
};
|
|
12
14
|
import Canvas from './Canvas.svelte';
|
|
13
15
|
import Html from './Html.svelte';
|
|
14
16
|
import Svg from './Svg.svelte';
|
|
@@ -359,13 +359,8 @@
|
|
|
359
359
|
{#if tooltipCtx.data}
|
|
360
360
|
<div
|
|
361
361
|
{...props.root}
|
|
362
|
-
class={cls(
|
|
363
|
-
|
|
364
|
-
'absolute z-50 select-none',
|
|
365
|
-
!pointerEvents && 'pointer-events-none',
|
|
366
|
-
classes.root,
|
|
367
|
-
props.root?.class
|
|
368
|
-
)}
|
|
362
|
+
class={cls('root', layerClass('tooltip-root'), classes.root, props.root?.class)}
|
|
363
|
+
class:pointer-events-none={!pointerEvents}
|
|
369
364
|
style:top="{motionY.current}px"
|
|
370
365
|
style:left="{motionX.current}px"
|
|
371
366
|
transition:fade={{ duration: 100 }}
|
|
@@ -408,3 +403,15 @@
|
|
|
408
403
|
</div>
|
|
409
404
|
</div>
|
|
410
405
|
{/if}
|
|
406
|
+
|
|
407
|
+
<style>
|
|
408
|
+
.root {
|
|
409
|
+
position: absolute;
|
|
410
|
+
z-index: 50;
|
|
411
|
+
user-select: none;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.pointer-events-none {
|
|
415
|
+
pointer-events: none;
|
|
416
|
+
}
|
|
417
|
+
</style>
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
locked?: boolean;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* quadtree search radius
|
|
75
|
+
* quadtree search or voronoi clip radius
|
|
76
76
|
* @default Infinity
|
|
77
77
|
*/
|
|
78
78
|
radius?: number;
|
|
@@ -116,11 +116,14 @@
|
|
|
116
116
|
</script>
|
|
117
117
|
|
|
118
118
|
<script lang="ts" generics="TData = any">
|
|
119
|
+
import type { Snippet } from 'svelte';
|
|
119
120
|
import { bisector, max, min } from 'd3-array';
|
|
120
121
|
import { quadtree as d3Quadtree, type Quadtree } from 'd3-quadtree';
|
|
121
122
|
import { sortFunc, localPoint } from '@layerstack/utils';
|
|
122
123
|
import { cls } from '@layerstack/tailwind';
|
|
123
124
|
|
|
125
|
+
import { getChartContext } from '../Chart.svelte';
|
|
126
|
+
import { getGeoContext } from '../GeoContext.svelte';
|
|
124
127
|
import Svg from './../layout/Svg.svelte';
|
|
125
128
|
import Arc from '../Arc.svelte';
|
|
126
129
|
import ChartClipPath from './../ChartClipPath.svelte';
|
|
@@ -130,8 +133,6 @@
|
|
|
130
133
|
import { cartesianToPolar } from '../../utils/math.js';
|
|
131
134
|
import { quadtreeRects } from '../../utils/quadtree.js';
|
|
132
135
|
import { raise } from '../../utils/chart.js';
|
|
133
|
-
import { getChartContext } from '../Chart.svelte';
|
|
134
|
-
import type { Snippet } from 'svelte';
|
|
135
136
|
import {
|
|
136
137
|
getTooltipMetaContext,
|
|
137
138
|
getTooltipPayload,
|
|
@@ -140,6 +141,7 @@
|
|
|
140
141
|
import { layerClass } from '../../utils/attributes.js';
|
|
141
142
|
|
|
142
143
|
const ctx = getChartContext<any>();
|
|
144
|
+
const geoCtx = getGeoContext();
|
|
143
145
|
|
|
144
146
|
let {
|
|
145
147
|
ref: refProp = $bindable(),
|
|
@@ -357,7 +359,11 @@
|
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
case 'quadtree': {
|
|
360
|
-
tooltipData = quadtree?.find(
|
|
362
|
+
tooltipData = quadtree?.find(
|
|
363
|
+
point.x - ctx.padding.left,
|
|
364
|
+
point.y - ctx.padding.top,
|
|
365
|
+
radius
|
|
366
|
+
);
|
|
361
367
|
break;
|
|
362
368
|
}
|
|
363
369
|
}
|
|
@@ -402,11 +408,14 @@
|
|
|
402
408
|
const quadtree: Quadtree<[number, number]> | undefined = $derived.by(() => {
|
|
403
409
|
if (mode === 'quadtree') {
|
|
404
410
|
return d3Quadtree()
|
|
405
|
-
.extent([
|
|
406
|
-
[0, 0],
|
|
407
|
-
[ctx.width, ctx.height],
|
|
408
|
-
])
|
|
409
411
|
.x((d) => {
|
|
412
|
+
if (geoCtx.projection) {
|
|
413
|
+
const lat = ctx.x(d);
|
|
414
|
+
const long = ctx.y(d);
|
|
415
|
+
const geoValue = geoCtx.projection([lat, long]) ?? [0, 0];
|
|
416
|
+
return geoValue[0];
|
|
417
|
+
}
|
|
418
|
+
|
|
410
419
|
const value = ctx.xGet(d);
|
|
411
420
|
|
|
412
421
|
if (Array.isArray(value)) {
|
|
@@ -420,6 +429,13 @@
|
|
|
420
429
|
}
|
|
421
430
|
})
|
|
422
431
|
.y((d) => {
|
|
432
|
+
if (geoCtx.projection) {
|
|
433
|
+
const lat = ctx.x(d);
|
|
434
|
+
const long = ctx.y(d);
|
|
435
|
+
const geoValue = geoCtx.projection([lat, long]) ?? [0, 0];
|
|
436
|
+
return geoValue[1];
|
|
437
|
+
}
|
|
438
|
+
|
|
423
439
|
const value = ctx.yGet(d);
|
|
424
440
|
|
|
425
441
|
if (Array.isArray(value)) {
|
|
@@ -546,6 +562,7 @@
|
|
|
546
562
|
{#if mode === 'voronoi'}
|
|
547
563
|
<Svg>
|
|
548
564
|
<Voronoi
|
|
565
|
+
r={radius}
|
|
549
566
|
onpointerenter={(e, { data }) => {
|
|
550
567
|
showTooltip(e, data);
|
|
551
568
|
}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import type
|
|
4
|
+
import { asAny, type Without } from '../../utils/types.js';
|
|
5
5
|
|
|
6
6
|
export type TooltipHeaderPropsWithoutHTML = {
|
|
7
7
|
/**
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
/**
|
|
14
14
|
* The format to use when displaying the value.
|
|
15
15
|
*/
|
|
16
|
-
format?: FormatType;
|
|
16
|
+
format?: FormatType | FormatConfig;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The color to use for the color dot.
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
</script>
|
|
55
55
|
|
|
56
56
|
<script lang="ts">
|
|
57
|
-
import { format as formatUtil, type FormatType } from '@layerstack/utils';
|
|
57
|
+
import { format as formatUtil, type FormatType, type FormatConfig } from '@layerstack/utils';
|
|
58
58
|
import { cls } from '@layerstack/tailwind';
|
|
59
59
|
import { layerClass } from '../../utils/attributes.js';
|
|
60
60
|
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
{#if children}
|
|
115
115
|
{@render children?.()}
|
|
116
116
|
{:else}
|
|
117
|
-
|
|
117
|
+
<!-- @ts-expect-error - improve types -->
|
|
118
|
+
{format ? formatUtil(value, asAny(format)) : value}
|
|
118
119
|
{/if}
|
|
119
120
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type Without } from '../../utils/types.js';
|
|
4
4
|
export type TooltipHeaderPropsWithoutHTML = {
|
|
5
5
|
/**
|
|
6
6
|
* The value to display in the tooltip header when the `children`
|
|
@@ -10,7 +10,7 @@ export type TooltipHeaderPropsWithoutHTML = {
|
|
|
10
10
|
/**
|
|
11
11
|
* The format to use when displaying the value.
|
|
12
12
|
*/
|
|
13
|
-
format?: FormatType;
|
|
13
|
+
format?: FormatType | FormatConfig;
|
|
14
14
|
/**
|
|
15
15
|
* The color to use for the color dot.
|
|
16
16
|
*/
|
|
@@ -40,7 +40,7 @@ export type TooltipHeaderPropsWithoutHTML = {
|
|
|
40
40
|
children?: Snippet;
|
|
41
41
|
};
|
|
42
42
|
export type TooltipHeaderProps = TooltipHeaderPropsWithoutHTML & Without<HTMLAttributes<HTMLElement>, TooltipHeaderPropsWithoutHTML>;
|
|
43
|
-
import { type FormatType } from '@layerstack/utils';
|
|
43
|
+
import { type FormatType, type FormatConfig } from '@layerstack/utils';
|
|
44
44
|
declare const TooltipHeader: import("svelte").Component<TooltipHeaderProps, {}, "ref" | "colorRef">;
|
|
45
45
|
type TooltipHeader = ReturnType<typeof TooltipHeader>;
|
|
46
46
|
export default TooltipHeader;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type
|
|
3
|
+
import { asAny, type Without } from '../../utils/types.js';
|
|
4
4
|
|
|
5
5
|
export type TooltipItemPropsWithoutHTML = {
|
|
6
6
|
/**
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* Format to use when displaying the value.
|
|
18
18
|
*/
|
|
19
|
-
format?: FormatType;
|
|
19
|
+
format?: FormatType | FormatConfig;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Alignment of the value.
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
</script>
|
|
76
76
|
|
|
77
77
|
<script lang="ts">
|
|
78
|
-
import { format as formatUtil, type FormatType } from '@layerstack/utils';
|
|
78
|
+
import { format as formatUtil, type FormatType, type FormatConfig } from '@layerstack/utils';
|
|
79
79
|
import { cls } from '@layerstack/tailwind';
|
|
80
80
|
import type { Snippet } from 'svelte';
|
|
81
81
|
import { layerClass } from '../../utils/attributes.js';
|
|
@@ -189,7 +189,8 @@
|
|
|
189
189
|
{#if children}
|
|
190
190
|
{@render children()}
|
|
191
191
|
{:else}
|
|
192
|
-
|
|
192
|
+
<!-- @ts-expect-error - improve types -->
|
|
193
|
+
{format ? formatUtil(value, asAny(format)) : value}
|
|
193
194
|
{/if}
|
|
194
195
|
</div>
|
|
195
196
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
-
import type
|
|
2
|
+
import { type Without } from '../../utils/types.js';
|
|
3
3
|
export type TooltipItemPropsWithoutHTML = {
|
|
4
4
|
/**
|
|
5
5
|
* The label to display in the tooltip item.
|
|
@@ -13,7 +13,7 @@ export type TooltipItemPropsWithoutHTML = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Format to use when displaying the value.
|
|
15
15
|
*/
|
|
16
|
-
format?: FormatType;
|
|
16
|
+
format?: FormatType | FormatConfig;
|
|
17
17
|
/**
|
|
18
18
|
* Alignment of the value.
|
|
19
19
|
*
|
|
@@ -59,7 +59,7 @@ export type TooltipItemPropsWithoutHTML = {
|
|
|
59
59
|
colorRef?: HTMLElement;
|
|
60
60
|
};
|
|
61
61
|
export type TooltipItemProps = TooltipItemPropsWithoutHTML & Without<HTMLAttributes<HTMLElement>, TooltipItemPropsWithoutHTML>;
|
|
62
|
-
import { type FormatType } from '@layerstack/utils';
|
|
62
|
+
import { type FormatType, type FormatConfig } from '@layerstack/utils';
|
|
63
63
|
import type { Snippet } from 'svelte';
|
|
64
64
|
declare const TooltipItem: import("svelte").Component<TooltipItemProps, {}, "ref" | "colorRef" | "labelRef" | "valueRef">;
|
|
65
65
|
type TooltipItem = ReturnType<typeof TooltipItem>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Accessor } from '../../utils/common.js';
|
|
2
2
|
import type { SeriesData } from '../charts/index.js';
|
|
3
3
|
import type { ChartContextValue } from '../Chart.svelte';
|
|
4
|
-
import { type FormatType } from '@layerstack/utils';
|
|
4
|
+
import { type FormatType, type FormatConfig } from '@layerstack/utils';
|
|
5
5
|
export type SimplifiedChartType = 'bar' | 'area' | 'line' | 'pie' | 'scatter';
|
|
6
6
|
export type BarTooltipMetaContextValue = {
|
|
7
7
|
type: 'bar';
|
|
@@ -52,7 +52,7 @@ export type TooltipPayload = {
|
|
|
52
52
|
chartType?: SimplifiedChartType;
|
|
53
53
|
payload: any;
|
|
54
54
|
rawSeriesData?: SeriesData<any, any>;
|
|
55
|
-
formatter?: FormatType;
|
|
55
|
+
formatter?: FormatType | FormatConfig;
|
|
56
56
|
};
|
|
57
57
|
type BasePayloadHandlerProps = {
|
|
58
58
|
ctx: ChartContextValue;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { mdiInformation } from '@mdi/js';
|
|
3
3
|
import { Icon } from 'svelte-ux';
|
|
4
4
|
import { cls } from '@layerstack/tailwind';
|
|
5
|
+
|
|
6
|
+
const { children } = $props();
|
|
5
7
|
</script>
|
|
6
8
|
|
|
7
9
|
<div
|
|
@@ -11,5 +13,5 @@
|
|
|
11
13
|
)}
|
|
12
14
|
>
|
|
13
15
|
<Icon data={mdiInformation} class="text-primary" />
|
|
14
|
-
|
|
16
|
+
{@render children()}
|
|
15
17
|
</div>
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(internal: unknown, props: {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Blockquote: $$__sveltets_2_IsomorphicComponent<any, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {
|
|
17
|
-
default: {};
|
|
18
|
-
}, {}, string>;
|
|
19
|
-
type Blockquote = InstanceType<typeof Blockquote>;
|
|
1
|
+
declare const Blockquote: import("svelte").Component<{
|
|
2
|
+
children: any;
|
|
3
|
+
}, {}, "">;
|
|
4
|
+
type Blockquote = ReturnType<typeof Blockquote>;
|
|
20
5
|
export default Blockquote;
|
package/dist/docs/Code.svelte
CHANGED
|
@@ -4,20 +4,28 @@
|
|
|
4
4
|
import { CopyButton } from 'svelte-ux';
|
|
5
5
|
import { cls } from '@layerstack/tailwind';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const {
|
|
8
|
+
source = null,
|
|
9
|
+
language = 'svelte',
|
|
10
|
+
highlightedSource = source
|
|
11
|
+
? Prism.highlight(source, Prism.languages[language] ?? Prism.languages.text, language)
|
|
12
|
+
: '',
|
|
13
|
+
classes = {},
|
|
14
|
+
class: className,
|
|
15
|
+
}: {
|
|
16
|
+
source: string | null;
|
|
17
|
+
language?: string;
|
|
18
|
+
highlightedSource?: string;
|
|
19
|
+
classes?: {
|
|
20
|
+
root?: string;
|
|
21
|
+
pre?: string;
|
|
22
|
+
code?: string;
|
|
23
|
+
};
|
|
24
|
+
class?: string;
|
|
25
|
+
} = $props();
|
|
18
26
|
</script>
|
|
19
27
|
|
|
20
|
-
<div class={cls('Code', 'rounded-sm', classes.root,
|
|
28
|
+
<div class={cls('Code', 'rounded-sm', classes.root, className)}>
|
|
21
29
|
{#if source}
|
|
22
30
|
<div class="relative">
|
|
23
31
|
<pre
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import 'prism-svelte';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
declare const Code: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
source?: string | null | undefined;
|
|
18
|
-
language?: string | undefined;
|
|
19
|
-
highlightedSource?: string | undefined;
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
source: string | null;
|
|
4
|
+
language?: string;
|
|
5
|
+
highlightedSource?: string;
|
|
20
6
|
classes?: {
|
|
21
7
|
root?: string;
|
|
22
8
|
pre?: string;
|
|
23
9
|
code?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type Code =
|
|
10
|
+
};
|
|
11
|
+
class?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const Code: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type Code = ReturnType<typeof Code>;
|
|
29
15
|
export default Code;
|
package/dist/docs/Header1.svelte
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { SectionDivider } from 'svelte-ux';
|
|
3
|
+
|
|
4
|
+
let { children, ...restProps } = $props();
|
|
3
5
|
</script>
|
|
4
6
|
|
|
5
7
|
<!--
|
|
@@ -9,6 +11,6 @@
|
|
|
9
11
|
- Maybe possible to set/get props from markdown/mdsvex
|
|
10
12
|
- Example: `#API { id: 'api' }
|
|
11
13
|
-->
|
|
12
|
-
<SectionDivider {
|
|
13
|
-
|
|
14
|
+
<SectionDivider {...restProps}>
|
|
15
|
+
{@render children()}
|
|
14
16
|
</SectionDivider>
|