layerchart 2.0.0-next.44 → 2.0.0-next.45
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/LICENSE +1 -1
- package/dist/components/AnnotationLine.svelte +1 -1
- package/dist/components/AnnotationPoint.svelte +1 -1
- package/dist/components/AnnotationRange.svelte +16 -15
- package/dist/components/Arc.svelte +10 -10
- package/dist/components/Arc.svelte.d.ts +4 -4
- package/dist/components/Arc.svelte.test.d.ts +1 -0
- package/dist/components/Arc.svelte.test.js +868 -0
- package/dist/components/Area.svelte +9 -7
- package/dist/components/Axis.svelte +2 -1
- package/dist/components/Axis.svelte.d.ts +1 -0
- package/dist/components/Bar.svelte +3 -3
- package/dist/components/Bars.svelte +1 -1
- package/dist/components/Blur.svelte +3 -3
- package/dist/components/Bounds.svelte +1 -1
- package/dist/components/BrushContext.svelte +1 -1
- package/dist/components/Calendar.svelte +2 -2
- package/dist/components/Calendar.svelte.d.ts +1 -1
- package/dist/components/Chart.svelte +63 -137
- package/dist/components/Chart.svelte.d.ts +23 -88
- package/dist/components/ChartClipPath.svelte +1 -1
- package/dist/components/Circle.svelte +17 -8
- package/dist/components/Circle.svelte.d.ts +3 -0
- package/dist/components/ClipPath.svelte +4 -4
- package/dist/components/Connector.svelte +4 -4
- package/dist/components/Connector.svelte.d.ts +3 -3
- package/dist/components/Ellipse.svelte +7 -7
- package/dist/components/Frame.svelte +1 -1
- package/dist/components/GeoContext.svelte +4 -20
- package/dist/components/GeoContext.svelte.d.ts +2 -6
- package/dist/components/GeoEdgeFade.svelte +1 -1
- package/dist/components/GeoPath.svelte +42 -107
- package/dist/components/GeoPath.svelte.d.ts +5 -4
- package/dist/components/GeoPoint.svelte +5 -5
- package/dist/components/GeoSpline.svelte +2 -14
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/GeoTile.svelte +7 -6
- package/dist/components/GeoVisible.svelte +1 -1
- package/dist/components/Graticule.svelte +4 -7
- package/dist/components/Graticule.svelte.d.ts +2 -1
- package/dist/components/Grid.svelte +1 -1
- package/dist/components/Group.svelte +8 -8
- package/dist/components/Highlight.svelte +18 -16
- package/dist/components/Hull.svelte +2 -2
- package/dist/components/Labels.svelte +1 -1
- package/dist/components/Legend.svelte +1 -1
- package/dist/components/Line.svelte +9 -7
- package/dist/components/LinearGradient.svelte +8 -7
- package/dist/components/MonthPath.svelte +5 -11
- package/dist/components/MonthPath.svelte.d.ts +2 -2
- package/dist/components/Pack.svelte +4 -6
- package/dist/components/Pack.svelte.d.ts +2 -4
- package/dist/components/Partition.svelte +4 -3
- package/dist/components/Partition.svelte.d.ts +2 -1
- package/dist/components/Path.svelte +344 -0
- package/dist/components/Path.svelte.d.ts +72 -0
- package/dist/components/Pattern.svelte +6 -6
- package/dist/components/Pie.svelte +2 -2
- package/dist/components/Pie.svelte.d.ts +1 -1
- package/dist/components/Point.svelte +1 -1
- package/dist/components/Points.svelte +1 -1
- package/dist/components/Polygon.svelte +8 -6
- package/dist/components/RadialGradient.svelte +7 -7
- package/dist/components/Rect.svelte +32 -10
- package/dist/components/Rect.svelte.d.ts +4 -1
- package/dist/components/Rule.svelte +1 -1
- package/dist/components/Sankey.svelte +1 -1
- package/dist/components/Spline.svelte +13 -337
- package/dist/components/Spline.svelte.d.ts +10 -73
- package/dist/components/Text.svelte +9 -7
- package/dist/components/Threshold.svelte +3 -3
- package/dist/components/TransformContext.svelte +10 -143
- package/dist/components/TransformControls.svelte +2 -2
- package/dist/components/TransformControls.svelte.d.ts +1 -1
- package/dist/components/Tree.svelte +4 -3
- package/dist/components/Tree.svelte.d.ts +2 -1
- package/dist/components/Treemap.svelte +4 -3
- package/dist/components/Treemap.svelte.d.ts +2 -1
- package/dist/components/Voronoi.svelte +5 -5
- package/dist/components/charts/ArcChart.svelte +14 -6
- package/dist/components/charts/ArcChart.svelte.d.ts +1 -1
- package/dist/components/charts/AreaChart.svelte +12 -6
- package/dist/components/charts/BarChart.svelte +12 -6
- package/dist/components/charts/DefaultTooltip.svelte +1 -1
- package/dist/components/charts/LineChart.svelte +12 -6
- package/dist/components/charts/PieChart.svelte +14 -6
- package/dist/components/charts/PieChart.svelte.d.ts +1 -1
- package/dist/components/charts/ScatterChart.svelte +11 -9
- package/dist/components/charts/types.d.ts +7 -6
- package/dist/components/index.d.ts +14 -12
- package/dist/components/index.js +14 -12
- package/dist/components/{layout → layers}/Canvas.svelte +13 -60
- package/dist/components/{layout → layers}/Canvas.svelte.d.ts +2 -32
- package/dist/components/{layout → layers}/Html.svelte +18 -3
- package/dist/components/{layout → layers}/Html.svelte.d.ts +7 -0
- package/dist/components/layers/Layer.svelte +85 -0
- package/dist/components/{layout → layers}/Layer.svelte.d.ts +7 -3
- package/dist/components/{layout → layers}/Svg.svelte +18 -3
- package/dist/components/{layout → layers}/Svg.svelte.d.ts +7 -0
- package/dist/components/{layout → layers}/WebGL.svelte +1 -1
- package/dist/components/{layout → layers}/WebGL.svelte.d.ts +3 -3
- package/dist/components/tests/TestHarness.svelte +76 -0
- package/dist/components/tests/TestHarness.svelte.d.ts +19 -0
- package/dist/components/tooltip/Tooltip.svelte +3 -3
- package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContext.svelte +13 -45
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +2 -14
- package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
- package/dist/components/tooltip/tooltipMetaContext.js +2 -2
- package/dist/contexts/canvas.d.ts +33 -0
- package/dist/contexts/canvas.js +14 -0
- package/dist/contexts/chart.d.ts +84 -0
- package/dist/contexts/chart.js +10 -0
- package/dist/contexts/geo.d.ts +6 -0
- package/dist/contexts/geo.js +12 -0
- package/dist/contexts/index.d.ts +6 -0
- package/dist/contexts/index.js +6 -0
- package/dist/contexts/layer.d.ts +3 -0
- package/dist/contexts/layer.js +8 -0
- package/dist/contexts/settings.d.ts +4 -0
- package/dist/contexts/settings.js +10 -0
- package/dist/contexts/tooltip.d.ts +15 -0
- package/dist/contexts/tooltip.js +8 -0
- package/dist/contexts/transform.d.ts +95 -0
- package/dist/contexts/transform.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/states/settings.svelte.d.ts +12 -0
- package/dist/states/settings.svelte.js +10 -0
- package/dist/states/transform.svelte.d.ts +9 -0
- package/dist/states/transform.svelte.js +31 -0
- package/dist/utils/arcText.svelte.d.ts +1 -1
- package/dist/utils/canvas.d.ts +7 -3
- package/dist/utils/canvas.js +78 -11
- package/dist/utils/common.d.ts +8 -1
- package/dist/utils/common.js +9 -10
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/motion.svelte.js +0 -1
- package/dist/utils/rect.svelte.d.ts +1 -1
- package/dist/utils/rect.svelte.js +17 -9
- package/dist/utils/string.d.ts +3 -1
- package/package.json +32 -54
- package/README.md +0 -41
- package/dist/components/layout/Layer.svelte +0 -41
- package/dist/docs/Blockquote.svelte +0 -17
- package/dist/docs/Blockquote.svelte.d.ts +0 -5
- package/dist/docs/Code.svelte +0 -80
- package/dist/docs/Code.svelte.d.ts +0 -14
- package/dist/docs/ConnectorSweepMenuField.svelte +0 -17
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +0 -7
- package/dist/docs/ConnectorTypeMenuField.svelte +0 -17
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +0 -7
- package/dist/docs/CurveMenuField.svelte +0 -44
- package/dist/docs/CurveMenuField.svelte.d.ts +0 -9
- package/dist/docs/GeoDebug.svelte +0 -60
- package/dist/docs/GeoDebug.svelte.d.ts +0 -4
- package/dist/docs/Header1.svelte +0 -16
- package/dist/docs/Header1.svelte.d.ts +0 -5
- package/dist/docs/Json.svelte +0 -36
- package/dist/docs/Json.svelte.d.ts +0 -10
- package/dist/docs/Layout.svelte +0 -21
- package/dist/docs/Layout.svelte.d.ts +0 -8
- package/dist/docs/Link.svelte +0 -9
- package/dist/docs/Link.svelte.d.ts +0 -5
- package/dist/docs/PathDataMenuField.svelte +0 -78
- package/dist/docs/PathDataMenuField.svelte.d.ts +0 -9
- package/dist/docs/Preview.svelte +0 -104
- package/dist/docs/Preview.svelte.d.ts +0 -13
- package/dist/docs/TilesetField.svelte +0 -136
- package/dist/docs/TilesetField.svelte.d.ts +0 -6
- package/dist/docs/TransformDebug.svelte +0 -22
- package/dist/docs/TransformDebug.svelte.d.ts +0 -20
- package/dist/docs/ViewSourceButton.svelte +0 -53
- package/dist/docs/ViewSourceButton.svelte.d.ts +0 -11
- /package/dist/{utils → contexts}/legendPayload.d.ts +0 -0
- /package/dist/{utils → contexts}/legendPayload.js +0 -0
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
export type GraticulePropsWithoutHTML = {
|
|
7
7
|
lines?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
|
|
8
8
|
outline?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
|
|
9
|
-
|
|
9
|
+
stepX?: number;
|
|
10
|
+
stepY?: number;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export type GraticuleProps = GraticulePropsWithoutHTML &
|
|
@@ -18,13 +19,9 @@
|
|
|
18
19
|
import { extractLayerProps } from '../utils/attributes.js';
|
|
19
20
|
import Group from './Group.svelte';
|
|
20
21
|
|
|
21
|
-
let { lines, outline,
|
|
22
|
+
let { lines, outline, stepX = 10, stepY = 10, ...restProps }: GraticuleProps = $props();
|
|
22
23
|
|
|
23
|
-
const graticule = geoGraticule();
|
|
24
|
-
|
|
25
|
-
$effect(() => {
|
|
26
|
-
graticule.step(step);
|
|
27
|
-
});
|
|
24
|
+
const graticule = $derived(geoGraticule().step([stepX, stepY]));
|
|
28
25
|
</script>
|
|
29
26
|
|
|
30
27
|
<Group class="lc-graticule-g">
|
|
@@ -4,7 +4,8 @@ import GeoPath, { type GeoPathProps } from './GeoPath.svelte';
|
|
|
4
4
|
export type GraticulePropsWithoutHTML = {
|
|
5
5
|
lines?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
|
|
6
6
|
outline?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
|
|
7
|
-
|
|
7
|
+
stepX?: number;
|
|
8
|
+
stepY?: number;
|
|
8
9
|
};
|
|
9
10
|
export type GraticuleProps = GraticulePropsWithoutHTML & Without<GeoPathProps, Omit<GraticulePropsWithoutHTML, 'ref'>>;
|
|
10
11
|
declare const Graticule: import("svelte").Component<GraticuleProps, {}, "">;
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
import Line from './Line.svelte';
|
|
98
98
|
import Rule from './Rule.svelte';
|
|
99
99
|
import Spline from './Spline.svelte';
|
|
100
|
-
import { getChartContext } from '
|
|
100
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
101
101
|
import { extractLayerProps } from '../utils/attributes.js';
|
|
102
102
|
import { autoTickVals, type TicksConfig } from '../utils/ticks.js';
|
|
103
103
|
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
import { fade } from 'svelte/transition';
|
|
84
84
|
import { cubicIn } from 'svelte/easing';
|
|
85
85
|
|
|
86
|
-
import {
|
|
87
|
-
import { registerCanvasComponent } from './
|
|
86
|
+
import { getLayerContext } from '../contexts/layer.js';
|
|
87
|
+
import { registerCanvasComponent } from './layers/Canvas.svelte';
|
|
88
88
|
|
|
89
|
-
import { getChartContext } from '
|
|
89
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
90
90
|
|
|
91
91
|
const ctx = getChartContext();
|
|
92
92
|
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
const
|
|
137
|
+
const layerCtx = getLayerContext();
|
|
138
138
|
|
|
139
|
-
if (
|
|
139
|
+
if (layerCtx === 'canvas') {
|
|
140
140
|
registerCanvasComponent({
|
|
141
141
|
name: 'Group',
|
|
142
142
|
render: (ctx) => {
|
|
@@ -170,9 +170,9 @@
|
|
|
170
170
|
};
|
|
171
171
|
</script>
|
|
172
172
|
|
|
173
|
-
{#if
|
|
173
|
+
{#if layerCtx === 'canvas'}
|
|
174
174
|
{@render children?.()}
|
|
175
|
-
{:else if
|
|
175
|
+
{:else if layerCtx === 'svg'}
|
|
176
176
|
<g
|
|
177
177
|
style:transform
|
|
178
178
|
class={['lc-group-g', className]}
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
>
|
|
185
185
|
{@render children?.()}
|
|
186
186
|
</g>
|
|
187
|
-
{:else if
|
|
187
|
+
{:else if layerCtx === 'html'}
|
|
188
188
|
<div
|
|
189
189
|
bind:this={ref}
|
|
190
190
|
style:transform
|
|
@@ -122,8 +122,8 @@
|
|
|
122
122
|
|
|
123
123
|
import { isScaleBand, isScaleTime } from '../utils/scales.svelte.js';
|
|
124
124
|
import { asAny } from '../utils/types.js';
|
|
125
|
-
import { getChartContext } from '
|
|
126
|
-
import { getTooltipContext } from '
|
|
125
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
126
|
+
import { getTooltipContext } from '../contexts/tooltip.js';
|
|
127
127
|
import { extractLayerProps } from '../utils/attributes.js';
|
|
128
128
|
import type { MotionProp } from '../utils/motion.svelte.js';
|
|
129
129
|
import Arc from './Arc.svelte';
|
|
@@ -261,27 +261,28 @@
|
|
|
261
261
|
// x area
|
|
262
262
|
if (Array.isArray(xCoord)) {
|
|
263
263
|
// `x` accessor with multiple properties (ex. `x={['start', 'end']})`)
|
|
264
|
+
tmpArea.x = min(xCoord);
|
|
264
265
|
tmpArea.width = max(xCoord) - min(xCoord); // Use first/last values for width
|
|
265
266
|
} else if (isScaleBand(ctx.xScale)) {
|
|
267
|
+
tmpArea.x = xCoord - (ctx.xScale.padding() * ctx.xScale.step()) / 2;
|
|
266
268
|
tmpArea.width = ctx.xScale.step();
|
|
267
269
|
} else if (ctx.xInterval) {
|
|
268
270
|
// x-axis time scale with interval
|
|
269
271
|
const start = ctx.xInterval.floor(xValue);
|
|
270
272
|
const end = ctx.xInterval.offset(start);
|
|
271
|
-
|
|
273
|
+
const xStart = ctx.xScale(start);
|
|
274
|
+
const xEnd = ctx.xScale(end);
|
|
275
|
+
tmpArea.x = Math.min(xStart, xEnd);
|
|
276
|
+
tmpArea.width = Math.abs(xEnd - xStart);
|
|
272
277
|
} else {
|
|
273
278
|
// Find width to next data point
|
|
274
279
|
const index = ctx.flatData.findIndex((d) => Number(x(d)) === Number(x(highlightData)));
|
|
275
280
|
const isLastPoint = index + 1 === ctx.flatData.length;
|
|
276
281
|
const nextDataPoint = isLastPoint ? max(ctx.xDomain) : x(ctx.flatData[index + 1]);
|
|
282
|
+
tmpArea.x = xCoord;
|
|
277
283
|
tmpArea.width = (ctx.xScale(nextDataPoint) ?? 0) - (xCoord ?? 0);
|
|
278
284
|
}
|
|
279
285
|
|
|
280
|
-
// If array, use left-most value for top left of rect
|
|
281
|
-
tmpArea.x =
|
|
282
|
-
(Array.isArray(xCoord) ? min(xCoord) : xCoord) -
|
|
283
|
-
(isScaleBand(ctx.xScale) ? (ctx.xScale.padding() * ctx.xScale.step()) / 2 : 0);
|
|
284
|
-
|
|
285
286
|
if (axis === 'x') {
|
|
286
287
|
tmpArea.y = min(ctx.yRange) as unknown as number;
|
|
287
288
|
tmpArea.height = (max(ctx.yRange) - min(ctx.yRange)) as unknown as number;
|
|
@@ -292,27 +293,28 @@
|
|
|
292
293
|
// y area
|
|
293
294
|
if (Array.isArray(yCoord)) {
|
|
294
295
|
// `y` accessor with multiple properties (ex. `y={['start', 'end']})`)
|
|
295
|
-
tmpArea.
|
|
296
|
+
tmpArea.y = min(yCoord);
|
|
297
|
+
tmpArea.height = max(yCoord) - min(yCoord); // Use first/last values for height
|
|
296
298
|
} else if (isScaleBand(ctx.yScale)) {
|
|
299
|
+
tmpArea.y = yCoord - (ctx.yScale.padding() * ctx.yScale.step()) / 2;
|
|
297
300
|
tmpArea.height = ctx.yScale.step();
|
|
298
301
|
} else if (ctx.yInterval) {
|
|
299
302
|
// y-axis time scale with interval
|
|
300
303
|
const start = ctx.yInterval.floor(yValue);
|
|
301
304
|
const end = ctx.yInterval.offset(start);
|
|
302
|
-
|
|
305
|
+
const yStart = ctx.yScale(start);
|
|
306
|
+
const yEnd = ctx.yScale(end);
|
|
307
|
+
tmpArea.y = Math.min(yStart, yEnd);
|
|
308
|
+
tmpArea.height = Math.abs(yEnd - yStart);
|
|
303
309
|
} else {
|
|
304
|
-
// Find
|
|
310
|
+
// Find height to next data point
|
|
305
311
|
const index = ctx.flatData.findIndex((d) => Number(y(d)) === Number(y(highlightData)));
|
|
306
312
|
const isLastPoint = index + 1 === ctx.flatData.length;
|
|
307
313
|
const nextDataPoint = isLastPoint ? max(ctx.yDomain) : y(ctx.flatData[index + 1]);
|
|
314
|
+
tmpArea.y = yCoord;
|
|
308
315
|
tmpArea.height = (ctx.yScale(nextDataPoint) ?? 0) - (yCoord ?? 0);
|
|
309
316
|
}
|
|
310
317
|
|
|
311
|
-
// If array, use left-most value for top left of rect
|
|
312
|
-
tmpArea.y =
|
|
313
|
-
(Array.isArray(yCoord) ? min(yCoord) : yCoord) -
|
|
314
|
-
(isScaleBand(ctx.yScale) ? (ctx.yScale.padding() * ctx.yScale.step()) / 2 : 0);
|
|
315
|
-
|
|
316
318
|
if (axis === 'y') {
|
|
317
319
|
tmpArea.width = max(ctx.xRange) as unknown as number;
|
|
318
320
|
}
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
import GeoPath from './GeoPath.svelte';
|
|
64
64
|
import Group, { type GroupProps } from './Group.svelte';
|
|
65
65
|
import Spline from './Spline.svelte';
|
|
66
|
-
import { getChartContext } from '
|
|
67
|
-
import { getGeoContext } from '
|
|
66
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
67
|
+
import { getGeoContext } from '../contexts/geo.js';
|
|
68
68
|
|
|
69
69
|
let {
|
|
70
70
|
data,
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
import { cls } from '@layerstack/tailwind';
|
|
73
73
|
|
|
74
74
|
import { isScaleBand } from '../utils/scales.svelte.js';
|
|
75
|
-
import { getChartContext } from '
|
|
75
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
76
76
|
import Group from './Group.svelte';
|
|
77
77
|
import { extractLayerProps } from '../utils/attributes.js';
|
|
78
78
|
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
import ColorRamp from './ColorRamp.svelte';
|
|
121
121
|
import { cls } from '@layerstack/tailwind';
|
|
122
122
|
import type { AnyScale } from '../utils/scales.svelte.js';
|
|
123
|
-
import { getChartContext } from '
|
|
123
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
124
124
|
import { extractLayerProps } from '../utils/attributes.js';
|
|
125
125
|
import { resolveMaybeFn } from '../utils/common.js';
|
|
126
126
|
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
|
|
93
93
|
<script lang="ts">
|
|
94
94
|
import { cls } from '@layerstack/tailwind';
|
|
95
|
-
import { merge } from '
|
|
95
|
+
import { merge } from '@layerstack/utils';
|
|
96
96
|
|
|
97
|
-
import { registerCanvasComponent } from './
|
|
98
|
-
import {
|
|
97
|
+
import { registerCanvasComponent } from './layers/Canvas.svelte';
|
|
98
|
+
import { getLayerContext } from '../contexts/layer.js';
|
|
99
99
|
|
|
100
100
|
import { createKey } from '../utils/key.svelte.js';
|
|
101
101
|
import { createId } from '../utils/createId.js';
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
const motionX2 = createMotion(initialX2, () => x2, motion);
|
|
135
135
|
const motionY2 = createMotion(initialY2, () => y2, motion);
|
|
136
136
|
|
|
137
|
-
const
|
|
137
|
+
const layerCtx = getLayerContext();
|
|
138
138
|
|
|
139
139
|
function render(
|
|
140
140
|
ctx: CanvasRenderingContext2D,
|
|
@@ -149,6 +149,7 @@
|
|
|
149
149
|
: {
|
|
150
150
|
styles: { fill, stroke, strokeWidth, opacity },
|
|
151
151
|
classes: cls('lc-line', className),
|
|
152
|
+
style: restProps.style as string | undefined,
|
|
152
153
|
}
|
|
153
154
|
);
|
|
154
155
|
}
|
|
@@ -156,7 +157,7 @@
|
|
|
156
157
|
const fillKey = createKey(() => fill);
|
|
157
158
|
const strokeKey = createKey(() => stroke);
|
|
158
159
|
|
|
159
|
-
if (
|
|
160
|
+
if (layerCtx === 'canvas') {
|
|
160
161
|
registerCanvasComponent({
|
|
161
162
|
name: 'Line',
|
|
162
163
|
render,
|
|
@@ -176,12 +177,13 @@
|
|
|
176
177
|
strokeWidth,
|
|
177
178
|
opacity,
|
|
178
179
|
className,
|
|
180
|
+
restProps.style,
|
|
179
181
|
],
|
|
180
182
|
});
|
|
181
183
|
}
|
|
182
184
|
</script>
|
|
183
185
|
|
|
184
|
-
{#if
|
|
186
|
+
{#if layerCtx === 'svg'}
|
|
185
187
|
<line
|
|
186
188
|
x1={motionX1.current}
|
|
187
189
|
y1={motionY1.current}
|
|
@@ -201,7 +203,7 @@
|
|
|
201
203
|
<MarkerWrapper id={markerStartId} marker={markerStart ?? marker} />
|
|
202
204
|
<MarkerWrapper id={markerMidId} marker={markerMid ?? marker} />
|
|
203
205
|
<MarkerWrapper id={markerEndId} marker={markerEnd ?? marker} />
|
|
204
|
-
{:else if
|
|
206
|
+
{:else if layerCtx === 'html'}
|
|
205
207
|
{@const { angle, length } = pointsToAngleAndLength(
|
|
206
208
|
{ x: motionX1.current, y: motionY1.current },
|
|
207
209
|
{ x: motionX2.current, y: motionY2.current }
|
|
@@ -76,8 +76,9 @@
|
|
|
76
76
|
</script>
|
|
77
77
|
|
|
78
78
|
<script lang="ts">
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
79
|
+
import { getLayerContext } from '../contexts/layer.js';
|
|
80
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
81
|
+
import { registerCanvasComponent } from './layers/Canvas.svelte';
|
|
81
82
|
import { createLinearGradient, getComputedStyles } from '../utils/canvas.js';
|
|
82
83
|
import { parsePercent } from '../utils/math.js';
|
|
83
84
|
import { createId } from '../utils/createId.js';
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
const ctx = getChartContext();
|
|
112
|
-
const
|
|
113
|
+
const layerCtx = getLayerContext();
|
|
113
114
|
|
|
114
115
|
let canvasGradient = $state<CanvasGradient>();
|
|
115
116
|
|
|
@@ -173,7 +174,7 @@
|
|
|
173
174
|
canvasGradient = gradient;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
if (
|
|
177
|
+
if (layerCtx === 'canvas') {
|
|
177
178
|
registerCanvasComponent({
|
|
178
179
|
name: 'Gradient',
|
|
179
180
|
render,
|
|
@@ -182,13 +183,13 @@
|
|
|
182
183
|
}
|
|
183
184
|
</script>
|
|
184
185
|
|
|
185
|
-
{#if
|
|
186
|
+
{#if layerCtx === 'canvas'}
|
|
186
187
|
<!--
|
|
187
188
|
TODO: we can probably pass the context to coerce this type so we don't need a bunch
|
|
188
189
|
of predicates to check if the gradient is a CanvasGradient or not...
|
|
189
190
|
-->
|
|
190
191
|
{@render children?.({ id, gradient: asAny(canvasGradient) })}
|
|
191
|
-
{:else if
|
|
192
|
+
{:else if layerCtx === 'svg'}
|
|
192
193
|
<defs>
|
|
193
194
|
<linearGradient
|
|
194
195
|
bind:this={ref}
|
|
@@ -224,6 +225,6 @@
|
|
|
224
225
|
</defs>
|
|
225
226
|
|
|
226
227
|
{@render children?.({ id, gradient: `url(#${id})` })}
|
|
227
|
-
{:else if
|
|
228
|
+
{:else if layerCtx === 'html'}
|
|
228
229
|
{@render children?.({ id, gradient: createCSSGradient() })}
|
|
229
230
|
{/if}
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type MonthPathProps = MonthPathPropsWithoutHTML &
|
|
32
|
-
// we omit the
|
|
33
|
-
// passing them through to `<
|
|
34
|
-
Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML &
|
|
32
|
+
// we omit the path props to avoid conflicts with attribute names since we are
|
|
33
|
+
// passing them through to `<Path />`
|
|
34
|
+
Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & PathPropsWithoutHTML>;
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
<script lang="ts">
|
|
38
38
|
import { timeWeek } from 'd3-time';
|
|
39
39
|
import { cls } from '@layerstack/tailwind';
|
|
40
40
|
import { endOfInterval } from '@layerstack/utils';
|
|
41
|
-
import
|
|
41
|
+
import Path, { type PathPropsWithoutHTML } from './Path.svelte';
|
|
42
42
|
|
|
43
43
|
let {
|
|
44
44
|
date,
|
|
@@ -76,13 +76,7 @@
|
|
|
76
76
|
`);
|
|
77
77
|
</script>
|
|
78
78
|
|
|
79
|
-
<
|
|
80
|
-
bind:pathRef
|
|
81
|
-
{pathData}
|
|
82
|
-
fill="none"
|
|
83
|
-
class={cls('lc-month-path', className)}
|
|
84
|
-
{...restProps}
|
|
85
|
-
/>
|
|
79
|
+
<Path bind:pathRef {pathData} fill="none" class={cls('lc-month-path', className)} {...restProps} />
|
|
86
80
|
|
|
87
81
|
<style>
|
|
88
82
|
@layer components {
|
|
@@ -22,8 +22,8 @@ export type MonthPathPropsWithoutHTML = {
|
|
|
22
22
|
*/
|
|
23
23
|
pathRef?: SVGPathElement;
|
|
24
24
|
};
|
|
25
|
-
export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML &
|
|
26
|
-
import { type
|
|
25
|
+
export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & PathPropsWithoutHTML>;
|
|
26
|
+
import { type PathPropsWithoutHTML } from './Path.svelte';
|
|
27
27
|
declare const MonthPath: import("svelte").Component<MonthPathProps, {}, "pathRef">;
|
|
28
28
|
type MonthPath = ReturnType<typeof MonthPath>;
|
|
29
29
|
export default MonthPath;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
|
|
5
5
|
export type PackProps<T> = {
|
|
6
|
+
/** d3 hierarchy node */
|
|
7
|
+
hierarchy: HierarchyNode<T>;
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* The size of the pack layout.
|
|
8
11
|
*/
|
|
@@ -15,11 +18,6 @@
|
|
|
15
18
|
*/
|
|
16
19
|
padding?: number;
|
|
17
20
|
|
|
18
|
-
/**
|
|
19
|
-
* The hierarchy data to be packed.
|
|
20
|
-
*/
|
|
21
|
-
hierarchy: HierarchyNode<T>;
|
|
22
|
-
|
|
23
21
|
/**
|
|
24
22
|
* A bindable reference to the computed packed nodes.
|
|
25
23
|
*
|
|
@@ -32,7 +30,7 @@
|
|
|
32
30
|
</script>
|
|
33
31
|
|
|
34
32
|
<script lang="ts" generics="T">
|
|
35
|
-
import { getChartContext } from '
|
|
33
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
36
34
|
|
|
37
35
|
const ctx = getChartContext();
|
|
38
36
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type HierarchyCircularNode, type HierarchyNode } from 'd3-hierarchy';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
export type PackProps<T> = {
|
|
4
|
+
/** d3 hierarchy node */
|
|
5
|
+
hierarchy: HierarchyNode<T>;
|
|
4
6
|
/**
|
|
5
7
|
* The size of the pack layout.
|
|
6
8
|
*/
|
|
@@ -11,10 +13,6 @@ export type PackProps<T> = {
|
|
|
11
13
|
* @see https://github.com/d3/d3-hierarchy#pack_padding
|
|
12
14
|
*/
|
|
13
15
|
padding?: number;
|
|
14
|
-
/**
|
|
15
|
-
* The hierarchy data to be packed.
|
|
16
|
-
*/
|
|
17
|
-
hierarchy: HierarchyNode<T>;
|
|
18
16
|
/**
|
|
19
17
|
* A bindable reference to the computed packed nodes.
|
|
20
18
|
*
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
import type { Snippet } from 'svelte';
|
|
8
8
|
|
|
9
9
|
export type PartitionProps<T> = {
|
|
10
|
+
/** d3 hierarchy node */
|
|
11
|
+
hierarchy: HierarchyNode<T>;
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* The orientation of the partition layout.
|
|
12
15
|
*
|
|
@@ -31,8 +34,6 @@
|
|
|
31
34
|
*/
|
|
32
35
|
round?: boolean;
|
|
33
36
|
|
|
34
|
-
hierarchy: HierarchyNode<T>;
|
|
35
|
-
|
|
36
37
|
/**
|
|
37
38
|
* A bindable reference to the descendants of the partition layout.
|
|
38
39
|
*
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
</script>
|
|
46
47
|
|
|
47
48
|
<script lang="ts" generics="T">
|
|
48
|
-
import { getChartContext } from '
|
|
49
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
49
50
|
|
|
50
51
|
let {
|
|
51
52
|
size,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type HierarchyNode, type HierarchyRectangularNode } from 'd3-hierarchy';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
export type PartitionProps<T> = {
|
|
4
|
+
/** d3 hierarchy node */
|
|
5
|
+
hierarchy: HierarchyNode<T>;
|
|
4
6
|
/**
|
|
5
7
|
* The orientation of the partition layout.
|
|
6
8
|
*
|
|
@@ -21,7 +23,6 @@ export type PartitionProps<T> = {
|
|
|
21
23
|
* see: https://github.com/d3/d3-hierarchy#tree_nodeSize
|
|
22
24
|
*/
|
|
23
25
|
round?: boolean;
|
|
24
|
-
hierarchy: HierarchyNode<T>;
|
|
25
26
|
/**
|
|
26
27
|
* A bindable reference to the descendants of the partition layout.
|
|
27
28
|
*
|