layerchart 2.0.0-next.38 → 2.0.0-next.39
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 +15 -2
- package/dist/components/AnnotationPoint.svelte +13 -2
- package/dist/components/AnnotationRange.svelte +16 -2
- package/dist/components/Arc.svelte +3 -3
- package/dist/components/Area.svelte +10 -2
- package/dist/components/Axis.svelte +43 -26
- package/dist/components/Bar.svelte +6 -5
- package/dist/components/Bar.svelte.d.ts +2 -2
- package/dist/components/Bars.svelte +3 -3
- package/dist/components/Blur.svelte +2 -3
- package/dist/components/BrushContext.svelte +44 -44
- package/dist/components/Calendar.svelte +21 -4
- package/dist/components/Chart.svelte +1 -2
- package/dist/components/ChartClipPath.svelte +1 -1
- package/dist/components/Circle.svelte +44 -3
- package/dist/components/CircleClipPath.svelte +8 -1
- package/dist/components/ClipPath.svelte +1 -2
- package/dist/components/ColorRamp.svelte +1 -1
- package/dist/components/ComputedStyles.svelte +9 -2
- package/dist/components/Connector.svelte +1 -1
- package/dist/components/Ellipse.svelte +44 -3
- package/dist/components/Frame.svelte +1 -1
- package/dist/components/GeoCircle.svelte +1 -1
- package/dist/components/GeoEdgeFade.svelte +1 -1
- package/dist/components/GeoPath.svelte +18 -3
- package/dist/components/GeoPoint.svelte +3 -3
- package/dist/components/GeoSpline.svelte +1 -1
- package/dist/components/GeoTile.svelte +1 -1
- package/dist/components/Graticule.svelte +5 -5
- package/dist/components/Grid.svelte +57 -60
- package/dist/components/Group.svelte +11 -6
- package/dist/components/Highlight.svelte +46 -22
- package/dist/components/Highlight.svelte.d.ts +4 -0
- package/dist/components/Hull.svelte +11 -4
- package/dist/components/Labels.svelte +21 -11
- package/dist/components/Legend.svelte +133 -67
- package/dist/components/Legend.svelte.d.ts +7 -3
- package/dist/components/Line.svelte +40 -3
- package/dist/components/LinearGradient.svelte +35 -4
- package/dist/components/Link.svelte +1 -1
- package/dist/components/Marker.svelte +37 -26
- package/dist/components/MonthPath.svelte +14 -3
- package/dist/components/MotionPath.svelte +1 -1
- package/dist/components/Pattern.svelte +5 -5
- package/dist/components/Pie.svelte +1 -2
- package/dist/components/Points.svelte +1 -1
- package/dist/components/Polygon.svelte +27 -3
- package/dist/components/RadialGradient.svelte +3 -3
- package/dist/components/Rect.svelte +55 -5
- package/dist/components/Rect.svelte.d.ts +2 -2
- package/dist/components/RectClipPath.svelte +4 -3
- package/dist/components/RectClipPath.svelte.d.ts +2 -2
- package/dist/components/Rule.svelte +30 -23
- package/dist/components/Spline.svelte +29 -10
- package/dist/components/Text.svelte +59 -13
- package/dist/components/TileImage.svelte +19 -4
- package/dist/components/TransformContext.svelte +9 -3
- package/dist/components/TransformControls.svelte +72 -17
- package/dist/components/Voronoi.svelte +12 -13
- package/dist/components/charts/ArcChart.svelte +40 -69
- package/dist/components/charts/AreaChart.svelte +19 -42
- package/dist/components/charts/BarChart.svelte +7 -18
- package/dist/components/charts/DefaultTooltip.svelte +2 -2
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +1 -1
- package/dist/components/charts/LineChart.svelte +61 -66
- package/dist/components/charts/LineChart.svelte.d.ts +11 -5
- package/dist/components/charts/PieChart.svelte +41 -69
- package/dist/components/charts/ScatterChart.svelte +8 -19
- package/dist/components/charts/utils.svelte.d.ts +1 -19
- package/dist/components/charts/utils.svelte.js +7 -39
- package/dist/components/layout/Canvas.svelte +29 -20
- package/dist/components/layout/Html.svelte +15 -9
- package/dist/components/layout/Svg.svelte +19 -11
- package/dist/components/layout/WebGL.svelte +26 -6
- package/dist/components/layout/WebGL.svelte.d.ts +5 -2
- package/dist/components/tooltip/Tooltip.svelte +60 -29
- package/dist/components/tooltip/TooltipContext.svelte +73 -36
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +7 -0
- package/dist/components/tooltip/TooltipHeader.svelte +27 -14
- package/dist/components/tooltip/TooltipItem.svelte +41 -33
- package/dist/components/tooltip/TooltipList.svelte +12 -10
- package/dist/components/tooltip/TooltipSeparator.svelte +18 -10
- package/dist/states/series.svelte.d.ts +30 -0
- package/dist/states/series.svelte.js +54 -0
- package/dist/styles/daisyui-5.css +6 -0
- package/dist/styles/shadcn-svelte.css +11 -0
- package/dist/styles/skeleton-3.css +15 -0
- package/dist/utils/attributes.d.ts +3 -13
- package/dist/utils/attributes.js +4 -18
- package/dist/utils/common.d.ts +9 -0
- package/dist/utils/common.js +18 -1
- package/dist/utils/common.test.js +26 -1
- package/dist/utils/math.d.ts +17 -0
- package/dist/utils/math.js +17 -0
- package/dist/utils/types.d.ts +15 -2
- package/package.json +5 -1
|
@@ -149,7 +149,6 @@
|
|
|
149
149
|
|
|
150
150
|
<script lang="ts">
|
|
151
151
|
import { onMount, untrack, type Snippet } from 'svelte';
|
|
152
|
-
import { cls } from '@layerstack/tailwind';
|
|
153
152
|
import { Logger, localPoint } from '@layerstack/utils';
|
|
154
153
|
import { MediaQueryPresets } from '@layerstack/svelte-state';
|
|
155
154
|
|
|
@@ -166,7 +165,6 @@
|
|
|
166
165
|
} from 'svelte/elements';
|
|
167
166
|
import type { Without } from '../../utils/types.js';
|
|
168
167
|
import { getChartContext } from '../Chart.svelte';
|
|
169
|
-
import { layerClass } from '../../utils/attributes.js';
|
|
170
168
|
|
|
171
169
|
let {
|
|
172
170
|
ref: refProp = $bindable(),
|
|
@@ -453,12 +451,8 @@
|
|
|
453
451
|
<canvas
|
|
454
452
|
bind:this={ref}
|
|
455
453
|
style:z-index={zIndex}
|
|
456
|
-
class={
|
|
457
|
-
|
|
458
|
-
'absolute top-0 left-0 w-full h-full',
|
|
459
|
-
pointerEvents === false && 'pointer-events-none',
|
|
460
|
-
className
|
|
461
|
-
)}
|
|
454
|
+
class={['lc-layout-canvas', className]}
|
|
455
|
+
class:disablePointerEvents={pointerEvents === false}
|
|
462
456
|
onclick={(e) => {
|
|
463
457
|
const component = getPointerComponent(e);
|
|
464
458
|
component?.events?.click?.(e);
|
|
@@ -507,17 +501,32 @@
|
|
|
507
501
|
</canvas>
|
|
508
502
|
|
|
509
503
|
<!-- Hit canvas used for hidden context -->
|
|
510
|
-
<canvas
|
|
511
|
-
bind:this={hitCanvasElement}
|
|
512
|
-
class={cls(
|
|
513
|
-
layerClass('hit-canvas'),
|
|
514
|
-
'layerchart-hitcanvas',
|
|
515
|
-
'absolute top-0 left-0 w-full h-full',
|
|
516
|
-
'pointer-events-none', // events all handled by main canvas
|
|
517
|
-
// '[image-rendering:pixelated]', // https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
|
|
518
|
-
'border border-danger',
|
|
519
|
-
!debug && 'opacity-0'
|
|
520
|
-
)}
|
|
521
|
-
></canvas>
|
|
504
|
+
<canvas bind:this={hitCanvasElement} class="lc-hit-canvas" class:debug></canvas>
|
|
522
505
|
|
|
523
506
|
{@render children?.({ ref, canvasContext: context })}
|
|
507
|
+
|
|
508
|
+
<style>
|
|
509
|
+
@layer base {
|
|
510
|
+
:where(.lc-layout-canvas) {
|
|
511
|
+
position: absolute;
|
|
512
|
+
inset: 0;
|
|
513
|
+
|
|
514
|
+
&.disablePointerEvents {
|
|
515
|
+
pointer-events: none;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
:where(.lc-hit-canvas) {
|
|
520
|
+
position: absolute;
|
|
521
|
+
inset: 0;
|
|
522
|
+
pointer-events: none; /* events handled by main canvas */
|
|
523
|
+
image-rendering: pixelated; /* https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering */
|
|
524
|
+
|
|
525
|
+
opacity: 0;
|
|
526
|
+
&.debug {
|
|
527
|
+
border: 1px solid var(--color-danger, red);
|
|
528
|
+
opacity: 1;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
</style>
|
|
@@ -46,11 +46,9 @@
|
|
|
46
46
|
</script>
|
|
47
47
|
|
|
48
48
|
<script lang="ts">
|
|
49
|
-
import { cls } from '@layerstack/tailwind';
|
|
50
49
|
import { getTransformContext } from '../TransformContext.svelte';
|
|
51
50
|
|
|
52
51
|
import { getChartContext, setRenderContext } from '../Chart.svelte';
|
|
53
|
-
import { layerClass } from '../../utils/attributes.js';
|
|
54
52
|
|
|
55
53
|
let {
|
|
56
54
|
ref: refProp = $bindable(),
|
|
@@ -90,16 +88,11 @@
|
|
|
90
88
|
|
|
91
89
|
<div
|
|
92
90
|
bind:this={ref}
|
|
93
|
-
class={
|
|
94
|
-
|
|
95
|
-
'absolute top-0 left-0',
|
|
96
|
-
pointerEvents === false && 'pointer-events-none',
|
|
97
|
-
className
|
|
98
|
-
)}
|
|
91
|
+
class={['lc-layout-html', className]}
|
|
92
|
+
class:disablePointerEvents={pointerEvents === false}
|
|
99
93
|
style:transform
|
|
100
94
|
style:transform-origin="top left"
|
|
101
95
|
style:z-index={zIndex}
|
|
102
|
-
style:pointer-events={pointerEvents === false ? 'none' : null}
|
|
103
96
|
style:top="{ctx.padding.top}px"
|
|
104
97
|
style:bottom="{ctx.padding.bottom}px"
|
|
105
98
|
style:left="{ctx.padding.left}px"
|
|
@@ -112,3 +105,16 @@
|
|
|
112
105
|
>
|
|
113
106
|
{@render children?.({ ref })}
|
|
114
107
|
</div>
|
|
108
|
+
|
|
109
|
+
<style>
|
|
110
|
+
@layer base {
|
|
111
|
+
:where(.lc-layout-html) {
|
|
112
|
+
position: absolute;
|
|
113
|
+
inset: 0;
|
|
114
|
+
|
|
115
|
+
&.disablePointerEvents {
|
|
116
|
+
pointer-events: none;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -63,11 +63,9 @@
|
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
65
|
<script lang="ts">
|
|
66
|
-
import { cls } from '@layerstack/tailwind';
|
|
67
66
|
import { getTransformContext } from '../TransformContext.svelte';
|
|
68
67
|
|
|
69
68
|
import { getChartContext, setRenderContext } from '../Chart.svelte';
|
|
70
|
-
import { layerClass } from '../../utils/attributes.js';
|
|
71
69
|
|
|
72
70
|
let {
|
|
73
71
|
ref: refProp = $bindable(),
|
|
@@ -114,19 +112,15 @@
|
|
|
114
112
|
width={ctx.containerWidth}
|
|
115
113
|
height={ctx.containerHeight}
|
|
116
114
|
style:z-index={zIndex}
|
|
117
|
-
class={
|
|
118
|
-
|
|
119
|
-
'absolute top-0 left-0 overflow-visible',
|
|
120
|
-
pointerEvents === false && 'pointer-events-none',
|
|
121
|
-
className
|
|
122
|
-
)}
|
|
115
|
+
class={['lc-layout-svg', className]}
|
|
116
|
+
class:disablePointerEvents={pointerEvents === false}
|
|
123
117
|
role="figure"
|
|
124
118
|
{...restProps}
|
|
125
119
|
>
|
|
126
120
|
{#if typeof title === 'function'}
|
|
127
121
|
{@render title()}
|
|
128
122
|
{:else if title}
|
|
129
|
-
<title class=
|
|
123
|
+
<title class="lc-layout-svg-title">{title}</title>
|
|
130
124
|
{/if}
|
|
131
125
|
|
|
132
126
|
<defs>
|
|
@@ -135,11 +129,11 @@
|
|
|
135
129
|
|
|
136
130
|
<g
|
|
137
131
|
bind:this={innerRef}
|
|
138
|
-
class=
|
|
132
|
+
class="lc-layout-svg-g"
|
|
139
133
|
transform="translate({ctx.padding.left}, {ctx.padding.top})"
|
|
140
134
|
>
|
|
141
135
|
{#if transform}
|
|
142
|
-
<g {transform} class=
|
|
136
|
+
<g {transform} class="lc-layout-svg-g-transform">
|
|
143
137
|
{@render children?.({ ref })}
|
|
144
138
|
</g>
|
|
145
139
|
{:else}
|
|
@@ -147,3 +141,17 @@
|
|
|
147
141
|
{/if}
|
|
148
142
|
</g>
|
|
149
143
|
</svg>
|
|
144
|
+
|
|
145
|
+
<style>
|
|
146
|
+
@layer base {
|
|
147
|
+
:where(.lc-layout-svg) {
|
|
148
|
+
position: absolute;
|
|
149
|
+
inset: 0;
|
|
150
|
+
overflow: visible; /* match html and allow viewing outside of bounds (useful for axis that leak and general debugging)*/
|
|
151
|
+
|
|
152
|
+
&.disablePointerEvents {
|
|
153
|
+
pointer-events: none;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { Without } from '../../utils/types.js';
|
|
4
|
+
import type { HTMLCanvasAttributes } from 'svelte/elements';
|
|
5
|
+
|
|
6
|
+
export type WebGLPropsWithoutHTML = {
|
|
3
7
|
/**
|
|
4
8
|
* A reference to the `<canvas>` element.
|
|
5
9
|
*
|
|
@@ -44,6 +48,9 @@
|
|
|
44
48
|
>;
|
|
45
49
|
};
|
|
46
50
|
|
|
51
|
+
export type WebGLProps = WebGLPropsWithoutHTML &
|
|
52
|
+
Without<HTMLCanvasAttributes, WebGLPropsWithoutHTML>;
|
|
53
|
+
|
|
47
54
|
export type WebGLContextValue = {
|
|
48
55
|
gl: WebGLRenderingContext | null;
|
|
49
56
|
};
|
|
@@ -61,10 +68,9 @@
|
|
|
61
68
|
</script>
|
|
62
69
|
|
|
63
70
|
<script lang="ts">
|
|
64
|
-
import { onMount
|
|
71
|
+
import { onMount } from 'svelte';
|
|
65
72
|
import { getChartContext } from '../Chart.svelte';
|
|
66
73
|
import { Context } from 'runed';
|
|
67
|
-
import { extractLayerProps } from '../../utils/attributes.js';
|
|
68
74
|
|
|
69
75
|
let {
|
|
70
76
|
context = $bindable(),
|
|
@@ -73,6 +79,7 @@
|
|
|
73
79
|
fallback = '',
|
|
74
80
|
pointerEvents = true,
|
|
75
81
|
zIndex = 0,
|
|
82
|
+
class: className,
|
|
76
83
|
children,
|
|
77
84
|
...restProps
|
|
78
85
|
}: WebGLProps = $props();
|
|
@@ -116,14 +123,14 @@
|
|
|
116
123
|
|
|
117
124
|
<canvas
|
|
118
125
|
bind:this={ref}
|
|
126
|
+
class={['lc-layout-webgl', className]}
|
|
127
|
+
class:disablePointerEvents={pointerEvents === false}
|
|
119
128
|
style:z-index={zIndex}
|
|
120
|
-
style:pointer-events={pointerEvents === false ? 'none' : null}
|
|
121
129
|
style:top={ctx.padding.top + 'px'}
|
|
122
130
|
style:right={ctx.padding.right + 'px'}
|
|
123
131
|
style:bottom={ctx.padding.bottom + 'px'}
|
|
124
132
|
style:left={ctx.padding.left + 'px'}
|
|
125
|
-
|
|
126
|
-
{...extractLayerProps(restProps, 'layout-webgl')}
|
|
133
|
+
{...restProps}
|
|
127
134
|
>
|
|
128
135
|
{#if typeof fallback === 'function'}
|
|
129
136
|
{@render fallback()}
|
|
@@ -133,3 +140,16 @@
|
|
|
133
140
|
</canvas>
|
|
134
141
|
|
|
135
142
|
{@render children?.({ ref, webGLContext: context })}
|
|
143
|
+
|
|
144
|
+
<style>
|
|
145
|
+
@layer base {
|
|
146
|
+
:where(.lc-layout-webgl) {
|
|
147
|
+
position: absolute;
|
|
148
|
+
inset: 0;
|
|
149
|
+
|
|
150
|
+
&.disablePointerEvents {
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { Without } from '../../utils/types.js';
|
|
3
|
+
import type { HTMLCanvasAttributes } from 'svelte/elements';
|
|
4
|
+
export type WebGLPropsWithoutHTML = {
|
|
2
5
|
/**
|
|
3
6
|
* A reference to the `<canvas>` element.
|
|
4
7
|
*
|
|
@@ -39,12 +42,12 @@ export type WebGLProps = {
|
|
|
39
42
|
}
|
|
40
43
|
]>;
|
|
41
44
|
};
|
|
45
|
+
export type WebGLProps = WebGLPropsWithoutHTML & Without<HTMLCanvasAttributes, WebGLPropsWithoutHTML>;
|
|
42
46
|
export type WebGLContextValue = {
|
|
43
47
|
gl: WebGLRenderingContext | null;
|
|
44
48
|
};
|
|
45
49
|
export declare function setWebGLContext(context: WebGLContextValue): WebGLContextValue;
|
|
46
50
|
export declare function getWebGLContext(): WebGLContextValue;
|
|
47
|
-
import { type Snippet } from 'svelte';
|
|
48
51
|
declare const WebGl: import("svelte").Component<WebGLProps, {}, "ref" | "context">;
|
|
49
52
|
type WebGl = ReturnType<typeof WebGl>;
|
|
50
53
|
export default WebGl;
|
|
@@ -162,7 +162,6 @@
|
|
|
162
162
|
import { getTooltipContext } from './TooltipContext.svelte';
|
|
163
163
|
import { createMotion, type MotionProp } from '../../utils/motion.svelte.js';
|
|
164
164
|
import { untrack, type Snippet } from 'svelte';
|
|
165
|
-
import { layerClass } from '../../utils/attributes.js';
|
|
166
165
|
|
|
167
166
|
let {
|
|
168
167
|
anchor = 'top-left',
|
|
@@ -359,8 +358,8 @@
|
|
|
359
358
|
{#if tooltipCtx.data}
|
|
360
359
|
<div
|
|
361
360
|
{...props.root}
|
|
362
|
-
class={cls('
|
|
363
|
-
class:
|
|
361
|
+
class={cls('lc-tooltip-root', classes.root, props.root?.class)}
|
|
362
|
+
class:disablePointerEvents={pointerEvents === false}
|
|
364
363
|
style:top="{motionY.current}px"
|
|
365
364
|
style:left="{motionX.current}px"
|
|
366
365
|
transition:fade={{ duration: 100 }}
|
|
@@ -376,27 +375,11 @@
|
|
|
376
375
|
>
|
|
377
376
|
<div
|
|
378
377
|
{...props.container}
|
|
379
|
-
class={cls(
|
|
380
|
-
|
|
381
|
-
variant !== 'none' && ['text-sm py-1 px-2 h-full rounded-sm elevation-1'],
|
|
382
|
-
{
|
|
383
|
-
default: [
|
|
384
|
-
'bg-surface-100/90 dark:bg-surface-300/90 backdrop-filter backdrop-blur-[2px] text-surface-content',
|
|
385
|
-
'[&_.label]:text-surface-content/75',
|
|
386
|
-
],
|
|
387
|
-
invert: [
|
|
388
|
-
'bg-surface-content/90 backdrop-filter backdrop-blur-[2px] text-surface-100 border border-surface-content',
|
|
389
|
-
'[&_.label]:text-surface-100/50',
|
|
390
|
-
],
|
|
391
|
-
none: '',
|
|
392
|
-
}[variant],
|
|
393
|
-
classes.container,
|
|
394
|
-
props.container?.class,
|
|
395
|
-
className
|
|
396
|
-
)}
|
|
378
|
+
class={cls('lc-tooltip-container', classes.container, props.container?.class, className)}
|
|
379
|
+
data-variant={variant}
|
|
397
380
|
>
|
|
398
381
|
{#if children}
|
|
399
|
-
<div {...props.content} class={cls(
|
|
382
|
+
<div {...props.content} class={cls('lc-tooltip-content', classes.content)}>
|
|
400
383
|
{@render children({ data: tooltipCtx.data, payload: tooltipCtx.payload })}
|
|
401
384
|
</div>
|
|
402
385
|
{/if}
|
|
@@ -405,13 +388,61 @@
|
|
|
405
388
|
{/if}
|
|
406
389
|
|
|
407
390
|
<style>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
391
|
+
@layer component {
|
|
392
|
+
:where(.lc-tooltip-root) {
|
|
393
|
+
position: absolute;
|
|
394
|
+
z-index: 50;
|
|
395
|
+
user-select: none;
|
|
396
|
+
|
|
397
|
+
&.disablePointerEvents {
|
|
398
|
+
pointer-events: none;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
:where(.lc-tooltip-container) {
|
|
403
|
+
&:not([data-variant='none']) {
|
|
404
|
+
font-size: 0.875rem;
|
|
405
|
+
line-height: 1.25rem;
|
|
406
|
+
padding: 4px 8px;
|
|
407
|
+
height: 100%;
|
|
408
|
+
border-radius: 0.25rem; /* rounded-sm */
|
|
409
|
+
box-shadow: /* elevation-1 */
|
|
410
|
+
0px 2px 1px -1px hsl(0 0% 0% / 20%),
|
|
411
|
+
0px 1px 1px 0px hsl(0 0% 0% / 14%),
|
|
412
|
+
0px 1px 3px 0px hsl(0 0% 0% / 12%);
|
|
413
|
+
/* STYLE-TODO: vendor prefix (-webkit?) */
|
|
414
|
+
backdrop-filter: blur(2px);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
&[data-variant='default'] {
|
|
418
|
+
color: var(--color-surface-content, currentColor);
|
|
419
|
+
background-color: color-mix(
|
|
420
|
+
in oklab,
|
|
421
|
+
light-dark(var(--color-surface-100, white), var(--color-surface-300, black)) 90%,
|
|
422
|
+
transparent
|
|
423
|
+
);
|
|
413
424
|
|
|
414
|
-
|
|
415
|
-
|
|
425
|
+
:global(& .label) {
|
|
426
|
+
color: color-mix(in oklab, var(--color-surface-content, currentColor) 75%, transparent);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
&[data-variant='invert'] {
|
|
431
|
+
color: var(--color-surface-100, light-dark(white, black));
|
|
432
|
+
background-color: color-mix(
|
|
433
|
+
in oklab,
|
|
434
|
+
var(--color-surface-content, currentColor) 90%,
|
|
435
|
+
transparent
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
:global(& .label) {
|
|
439
|
+
color: color-mix(
|
|
440
|
+
in oklab,
|
|
441
|
+
var(--color-surface-100, light-dark(white, black)) 50%,
|
|
442
|
+
transparent
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
416
447
|
}
|
|
417
448
|
</style>
|
|
@@ -77,6 +77,14 @@
|
|
|
77
77
|
*/
|
|
78
78
|
locked?: boolean;
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Controls the touch event behavior on the tooltip container.
|
|
82
|
+
* By default uses `pan-y` to allow verticle scrolling but horizontal scrubbing.
|
|
83
|
+
* Use `none` to disable all touch events (useful for improved transform/geo charts interactions)
|
|
84
|
+
* @default 'pan-y'
|
|
85
|
+
*/
|
|
86
|
+
touchEvents?: 'none' | 'pan-x' | 'pan-y' | 'auto';
|
|
87
|
+
|
|
80
88
|
/**
|
|
81
89
|
* quadtree search or voronoi clip radius
|
|
82
90
|
* @default Infinity
|
|
@@ -144,7 +152,6 @@
|
|
|
144
152
|
getTooltipPayload,
|
|
145
153
|
type TooltipPayload,
|
|
146
154
|
} from './tooltipMetaContext.js';
|
|
147
|
-
import { layerClass } from '../../utils/attributes.js';
|
|
148
155
|
|
|
149
156
|
const ctx = getChartContext<any>();
|
|
150
157
|
const geoCtx = getGeoContext();
|
|
@@ -155,6 +162,7 @@
|
|
|
155
162
|
findTooltipData = 'closest',
|
|
156
163
|
hideDelay = 0,
|
|
157
164
|
locked = false,
|
|
165
|
+
touchEvents = 'pan-y',
|
|
158
166
|
mode = 'manual',
|
|
159
167
|
onclick = () => {},
|
|
160
168
|
radius = Infinity,
|
|
@@ -497,16 +505,16 @@
|
|
|
497
505
|
// full band width/height regardless of value
|
|
498
506
|
return {
|
|
499
507
|
x: x - xOffset,
|
|
500
|
-
y: min(ctx.yRange),
|
|
508
|
+
y: isScaleBand(ctx.yScale) ? y - yOffset : min(ctx.yRange),
|
|
501
509
|
width: ctx.xScale.step(),
|
|
502
|
-
height: fullHeight,
|
|
510
|
+
height: isScaleBand(ctx.yScale) ? ctx.yScale.step() : fullHeight,
|
|
503
511
|
data: d,
|
|
504
512
|
};
|
|
505
513
|
} else if (isScaleBand(ctx.yScale)) {
|
|
506
514
|
return {
|
|
507
|
-
x: min(ctx.xRange),
|
|
515
|
+
x: isScaleBand(ctx.xScale) ? x - xOffset : min(ctx.xRange),
|
|
508
516
|
y: y - yOffset,
|
|
509
|
-
width: fullWidth,
|
|
517
|
+
width: isScaleBand(ctx.xScale) ? ctx.xScale.step() : fullWidth,
|
|
510
518
|
height: ctx.yScale.step(),
|
|
511
519
|
data: d,
|
|
512
520
|
};
|
|
@@ -522,9 +530,9 @@
|
|
|
522
530
|
|
|
523
531
|
return {
|
|
524
532
|
x: x - xOffset,
|
|
525
|
-
y: min(ctx.yRange),
|
|
533
|
+
y: isScaleBand(ctx.yScale) ? y - yOffset : min(ctx.yRange),
|
|
526
534
|
width: (ctx.xScale(nextDataPoint) ?? 0) - (xValue ?? 0),
|
|
527
|
-
height: fullHeight,
|
|
535
|
+
height: isScaleBand(ctx.yScale) ? ctx.yScale.step() : fullHeight,
|
|
528
536
|
data: d,
|
|
529
537
|
};
|
|
530
538
|
} else if (isScaleTime(ctx.yScale)) {
|
|
@@ -538,9 +546,9 @@
|
|
|
538
546
|
: ctx.y(ctx.flatData[index + 1]);
|
|
539
547
|
|
|
540
548
|
return {
|
|
541
|
-
x: min(ctx.xRange),
|
|
549
|
+
x: isScaleBand(ctx.xScale) ? x - xOffset : min(ctx.xRange),
|
|
542
550
|
y: y - yOffset,
|
|
543
|
-
width: fullWidth,
|
|
551
|
+
width: isScaleBand(ctx.xScale) ? ctx.xScale.step() : fullWidth,
|
|
544
552
|
height: (ctx.yScale(nextDataPoint) ?? 0) - (yValue ?? 0),
|
|
545
553
|
data: d,
|
|
546
554
|
};
|
|
@@ -605,17 +613,12 @@
|
|
|
605
613
|
style:left="{ctx.padding.left}px"
|
|
606
614
|
style:width="{ctx.width}px"
|
|
607
615
|
style:height="{ctx.height}px"
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
ontouchstart={onPointerEnter}
|
|
615
|
-
onmousemove={onPointerMove}
|
|
616
|
-
ontouchmove={onPointerMove}
|
|
617
|
-
onmouseleave={onPointerLeave}
|
|
618
|
-
ontouchend={onPointerLeave}
|
|
616
|
+
style:--touch-action={touchEvents}
|
|
617
|
+
class="lc-tooltip-context"
|
|
618
|
+
class:debug={debug && triggerPointerEvents}
|
|
619
|
+
onpointerenter={onPointerEnter}
|
|
620
|
+
onpointermove={onPointerMove}
|
|
621
|
+
onpointerleave={onPointerLeave}
|
|
619
622
|
onclick={(e) => {
|
|
620
623
|
// Ignore clicks without data (triggered from Legend clicks, for example)
|
|
621
624
|
if (triggerPointerEvents && tooltipContext.data != null) {
|
|
@@ -627,7 +630,7 @@
|
|
|
627
630
|
>
|
|
628
631
|
<!-- Rendering slot within TooltipContext to allow pointer events to bubble up (ex. Brush) -->
|
|
629
632
|
<div
|
|
630
|
-
class=
|
|
633
|
+
class="lc-tooltip-context-container"
|
|
631
634
|
style:top="-{ctx.padding.top ?? 0}px"
|
|
632
635
|
style:left="-{ctx.padding.left ?? 0}px"
|
|
633
636
|
style:width="{ctx.containerWidth}px"
|
|
@@ -656,12 +659,12 @@
|
|
|
656
659
|
onclick={(e, { data }) => {
|
|
657
660
|
onclick(e, { data });
|
|
658
661
|
}}
|
|
659
|
-
classes={{ path: cls(debug && '
|
|
662
|
+
classes={{ path: cls('lc-tooltip-voronoi-path', debug && 'debug') }}
|
|
660
663
|
/>
|
|
661
664
|
</Svg>
|
|
662
665
|
{:else if mode === 'bounds' || mode === 'band'}
|
|
663
666
|
<Svg center={ctx.radial}>
|
|
664
|
-
<g class=
|
|
667
|
+
<g class="lc-tooltip-rects-g">
|
|
665
668
|
{#each rects as rect}
|
|
666
669
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
667
670
|
{#if ctx.radial}
|
|
@@ -670,10 +673,7 @@
|
|
|
670
673
|
outerRadius={rect.y + rect.height}
|
|
671
674
|
startAngle={rect.x}
|
|
672
675
|
endAngle={rect.x + rect.width}
|
|
673
|
-
class={cls(
|
|
674
|
-
layerClass('tooltip-rect'),
|
|
675
|
-
debug ? 'fill-danger/10 stroke-danger' : 'fill-transparent'
|
|
676
|
-
)}
|
|
676
|
+
class={cls('lc-tooltip-rect', debug && 'debug')}
|
|
677
677
|
onpointerenter={(e) => showTooltip(e, rect?.data)}
|
|
678
678
|
onpointermove={(e) => showTooltip(e, rect?.data)}
|
|
679
679
|
onpointerleave={() => hideTooltip()}
|
|
@@ -693,10 +693,7 @@
|
|
|
693
693
|
y={rect?.y}
|
|
694
694
|
width={rect?.width}
|
|
695
695
|
height={rect?.height}
|
|
696
|
-
class={cls(
|
|
697
|
-
layerClass('tooltip-rect'),
|
|
698
|
-
debug ? 'fill-danger/10 stroke-danger' : 'fill-transparent'
|
|
699
|
-
)}
|
|
696
|
+
class={cls('lc-tooltip-rect', debug && 'debug')}
|
|
700
697
|
onpointerenter={(e) => showTooltip(e, rect?.data)}
|
|
701
698
|
onpointermove={(e) => showTooltip(e, rect?.data)}
|
|
702
699
|
onpointerleave={() => hideTooltip()}
|
|
@@ -717,7 +714,7 @@
|
|
|
717
714
|
{:else if ['quadtree', 'quadtree-x', 'quadtree-y'].includes(mode) && debug}
|
|
718
715
|
<Svg pointerEvents={false}>
|
|
719
716
|
<ChartClipPath>
|
|
720
|
-
<g class=
|
|
717
|
+
<g class="lc-tooltip-quadtree-g">
|
|
721
718
|
{#if quadtree}
|
|
722
719
|
{#each quadtreeRects(quadtree, false) as rect}
|
|
723
720
|
<rect
|
|
@@ -725,10 +722,7 @@
|
|
|
725
722
|
y={rect.y}
|
|
726
723
|
width={rect.width}
|
|
727
724
|
height={rect.height}
|
|
728
|
-
class={cls(
|
|
729
|
-
layerClass('tooltip-quadtree-rect'),
|
|
730
|
-
debug ? 'fill-danger/10 stroke-danger' : 'fill-transparent'
|
|
731
|
-
)}
|
|
725
|
+
class={cls('lc-tooltip-quadtree-rect', debug && 'debug')}
|
|
732
726
|
/>
|
|
733
727
|
{/each}
|
|
734
728
|
{/if}
|
|
@@ -738,3 +732,46 @@
|
|
|
738
732
|
{/if}
|
|
739
733
|
</div>
|
|
740
734
|
</div>
|
|
735
|
+
|
|
736
|
+
<style>
|
|
737
|
+
@layer component {
|
|
738
|
+
:where(.lc-tooltip-context-container) {
|
|
739
|
+
position: absolute;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
:where(.lc-tooltip-context) {
|
|
743
|
+
position: absolute;
|
|
744
|
+
touch-action: var(--touch-action);
|
|
745
|
+
|
|
746
|
+
&.debug {
|
|
747
|
+
outline: 1px solid var(--color-danger);
|
|
748
|
+
background-color: color-mix(in oklab, var(--color-danger) 10%, transparent);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
:global(:where(.lc-tooltip-voronoi-path)) {
|
|
753
|
+
&.debug {
|
|
754
|
+
stroke: var(--color-danger);
|
|
755
|
+
fill: color-mix(in oklab, var(--color-danger) 10%, transparent);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
:where(.lc-tooltip-rect) {
|
|
760
|
+
fill: transparent;
|
|
761
|
+
|
|
762
|
+
&.debug {
|
|
763
|
+
stroke: var(--color-danger);
|
|
764
|
+
fill: color-mix(in oklab, var(--color-danger) 10%, transparent);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
:where(.lc-tooltip-quadtree-rect) {
|
|
769
|
+
fill: transparent;
|
|
770
|
+
|
|
771
|
+
&.debug {
|
|
772
|
+
stroke: var(--color-danger);
|
|
773
|
+
fill: color-mix(in oklab, var(--color-danger) 10%, transparent);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
</style>
|
|
@@ -35,6 +35,13 @@ type TooltipContextPropsWithoutHTML<T = any> = {
|
|
|
35
35
|
* @default false
|
|
36
36
|
*/
|
|
37
37
|
locked?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Controls the touch event behavior on the tooltip container.
|
|
40
|
+
* By default uses `pan-y` to allow verticle scrolling but horizontal scrubbing.
|
|
41
|
+
* Use `none` to disable all touch events (useful for improved transform/geo charts interactions)
|
|
42
|
+
* @default 'pan-y'
|
|
43
|
+
*/
|
|
44
|
+
touchEvents?: 'none' | 'pan-x' | 'pan-y' | 'auto';
|
|
38
45
|
/**
|
|
39
46
|
* quadtree search or voronoi clip radius
|
|
40
47
|
* @default Infinity
|