layerchart 0.53.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Arc.svelte +170 -144
- package/dist/components/Area.svelte +96 -67
- package/dist/components/Area.svelte.d.ts +1 -0
- package/dist/components/Axis.svelte +241 -234
- package/dist/components/Axis.svelte.d.ts +2 -1
- package/dist/components/Bar.svelte +72 -45
- package/dist/components/Bars.svelte +46 -34
- package/dist/components/Bars.svelte.d.ts +1 -0
- package/dist/components/Blur.svelte +5 -3
- package/dist/components/Bounds.svelte +37 -21
- package/dist/components/Brush.svelte +181 -110
- package/dist/components/Calendar.svelte +51 -38
- package/dist/components/Chart.svelte +296 -73
- package/dist/components/Chart.svelte.d.ts +42 -25
- package/dist/components/ChartClipPath.svelte +8 -5
- package/dist/components/ChartContext.svelte +243 -93
- package/dist/components/ChartContext.svelte.d.ts +15 -23
- package/dist/components/Circle.svelte +25 -16
- package/dist/components/CircleClipPath.svelte +16 -10
- package/dist/components/ClipPath.svelte +11 -7
- package/dist/components/ColorRamp.svelte +12 -10
- package/dist/components/ForceSimulation.svelte +185 -116
- package/dist/components/Frame.svelte +10 -6
- package/dist/components/GeoCircle.svelte +15 -9
- package/dist/components/GeoContext.svelte +109 -62
- package/dist/components/GeoEdgeFade.svelte +20 -14
- package/dist/components/GeoPath.svelte +107 -69
- package/dist/components/GeoPoint.svelte +32 -18
- package/dist/components/GeoSpline.svelte +30 -22
- package/dist/components/GeoTile.svelte +40 -30
- package/dist/components/GeoVisible.svelte +10 -7
- package/dist/components/Graticule.svelte +14 -8
- package/dist/components/Grid.svelte +178 -0
- package/dist/components/Grid.svelte.d.ts +35 -0
- package/dist/components/Group.svelte +43 -31
- package/dist/components/Highlight.svelte +284 -243
- package/dist/components/HitCanvas.svelte +75 -42
- package/dist/components/Hull.svelte +40 -20
- package/dist/components/Labels.svelte +84 -63
- package/dist/components/Labels.svelte.d.ts +2 -0
- package/dist/components/Legend.svelte +106 -75
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/Line.svelte +29 -19
- package/dist/components/LinearGradient.svelte +21 -15
- package/dist/components/Link.svelte +44 -22
- package/dist/components/MonthPath.svelte +23 -16
- package/dist/components/MotionPath.svelte +34 -25
- package/dist/components/Pack.svelte +21 -14
- package/dist/components/Partition.svelte +35 -20
- package/dist/components/Pattern.svelte +8 -6
- package/dist/components/Pie.svelte +76 -57
- package/dist/components/Point.svelte +11 -7
- package/dist/components/Points.svelte +178 -143
- package/dist/components/RadialGradient.svelte +25 -18
- package/dist/components/Rect.svelte +33 -19
- package/dist/components/RectClipPath.svelte +16 -11
- package/dist/components/Rule.svelte +66 -42
- package/dist/components/Rule.svelte.d.ts +2 -0
- package/dist/components/Sankey.svelte +55 -30
- package/dist/components/Spline.svelte +118 -96
- package/dist/components/Text.svelte +137 -104
- package/dist/components/Threshold.svelte +18 -7
- package/dist/components/TileImage.svelte +56 -50
- package/dist/components/TransformContext.svelte +238 -136
- package/dist/components/TransformControls.svelte +57 -29
- package/dist/components/TransformControls.svelte.d.ts +1 -1
- package/dist/components/Tree.svelte +33 -23
- package/dist/components/Treemap.svelte +69 -41
- package/dist/components/Voronoi.svelte +55 -28
- package/dist/components/charts/AreaChart.svelte +162 -87
- package/dist/components/charts/AreaChart.svelte.d.ts +41 -3
- package/dist/components/charts/BarChart.svelte +207 -108
- package/dist/components/charts/BarChart.svelte.d.ts +41 -3
- package/dist/components/charts/LineChart.svelte +119 -47
- package/dist/components/charts/LineChart.svelte.d.ts +41 -3
- package/dist/components/charts/PieChart.svelte +117 -53
- package/dist/components/charts/PieChart.svelte.d.ts +17 -2
- package/dist/components/charts/ScatterChart.svelte +92 -42
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/layout/Canvas.svelte +63 -43
- package/dist/components/layout/Html.svelte +28 -18
- package/dist/components/layout/Svg.svelte +47 -32
- package/dist/components/tooltip/Tooltip.svelte +143 -82
- package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContext.svelte +315 -248
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +7 -0
- package/dist/components/tooltip/TooltipHeader.svelte +9 -3
- package/dist/components/tooltip/TooltipItem.svelte +17 -9
- package/dist/components/tooltip/TooltipList.svelte +2 -1
- package/dist/components/tooltip/TooltipSeparator.svelte +3 -2
- package/dist/docs/Blockquote.svelte +4 -3
- package/dist/docs/Code.svelte +15 -8
- package/dist/docs/CurveMenuField.svelte +17 -12
- package/dist/docs/GeoDebug.svelte +13 -9
- package/dist/docs/Header1.svelte +2 -1
- package/dist/docs/Json.svelte +6 -4
- package/dist/docs/Layout.svelte +6 -6
- package/dist/docs/PathDataMenuField.svelte +52 -44
- package/dist/docs/Preview.svelte +48 -29
- package/dist/docs/TilesetField.svelte +80 -62
- package/dist/docs/TransformDebug.svelte +8 -5
- package/dist/docs/ViewSourceButton.svelte +13 -9
- package/dist/stores/motionStore.d.ts +1 -1
- package/dist/utils/scales.d.ts +4 -4
- package/package.json +29 -30
|
@@ -1,35 +1,93 @@
|
|
|
1
|
-
<script generics="TData">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
<script lang="ts" generics="TData">
|
|
2
|
+
import { type ComponentProps } from 'svelte';
|
|
3
|
+
import { scaleLinear, scaleOrdinal, scaleTime } from 'd3-scale';
|
|
4
|
+
import { format } from '@layerstack/utils';
|
|
5
|
+
|
|
6
|
+
import Axis from '../Axis.svelte';
|
|
7
|
+
import Chart from '../Chart.svelte';
|
|
8
|
+
import Grid from '../Grid.svelte';
|
|
9
|
+
import Highlight from '../Highlight.svelte';
|
|
10
|
+
import Labels from '../Labels.svelte';
|
|
11
|
+
import Legend from '../Legend.svelte';
|
|
12
|
+
import Points from '../Points.svelte';
|
|
13
|
+
import Rule from '../Rule.svelte';
|
|
14
|
+
import Spline from '../Spline.svelte';
|
|
15
|
+
import Svg from '../layout/Svg.svelte';
|
|
16
|
+
import * as Tooltip from '../tooltip/index.js';
|
|
17
|
+
|
|
18
|
+
import { accessor, chartDataArray, type Accessor } from '../../utils/common.js';
|
|
19
|
+
|
|
20
|
+
interface $$Props extends ComponentProps<Chart<TData>> {
|
|
21
|
+
axis?: typeof axis;
|
|
22
|
+
grid?: typeof grid;
|
|
23
|
+
labels?: typeof labels;
|
|
24
|
+
legend?: typeof legend;
|
|
25
|
+
points?: typeof points;
|
|
26
|
+
props?: typeof props;
|
|
27
|
+
rule?: typeof rule;
|
|
28
|
+
series?: typeof series;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export let data: $$Props['data'] = [];
|
|
32
|
+
export let x: Accessor<TData> = undefined;
|
|
33
|
+
export let y: Accessor<TData> = undefined;
|
|
34
|
+
|
|
35
|
+
/** 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 */
|
|
36
|
+
export let radial = false;
|
|
37
|
+
|
|
38
|
+
export let series: {
|
|
39
|
+
key: string | number;
|
|
40
|
+
label?: string;
|
|
41
|
+
value?: Accessor<TData>;
|
|
42
|
+
/** Provider series data, else uses chart data (with value/key accessor) */
|
|
43
|
+
data?: TData[];
|
|
44
|
+
color?: string;
|
|
45
|
+
props?: Partial<ComponentProps<Spline>>;
|
|
46
|
+
}[] = [{ key: 'default', value: y, color: 'hsl(var(--color-primary))' }];
|
|
47
|
+
$: isDefaultSeries = series.length === 1 && series[0].key === 'default';
|
|
48
|
+
|
|
49
|
+
export let axis: ComponentProps<Axis> | 'x' | 'y' | boolean = true;
|
|
50
|
+
export let rule: ComponentProps<Rule> | boolean = true;
|
|
51
|
+
export let grid: ComponentProps<Grid> | boolean = true;
|
|
52
|
+
export let labels: ComponentProps<Labels> | boolean = false;
|
|
53
|
+
export let legend: ComponentProps<Legend> | boolean = false;
|
|
54
|
+
export let points: ComponentProps<Points> | boolean = false;
|
|
55
|
+
|
|
56
|
+
export let props: {
|
|
57
|
+
xAxis?: Partial<ComponentProps<Axis>>;
|
|
58
|
+
yAxis?: Partial<ComponentProps<Axis>>;
|
|
59
|
+
grid?: Partial<ComponentProps<Grid>>;
|
|
60
|
+
rule?: Partial<ComponentProps<Rule>>;
|
|
61
|
+
spline?: Partial<ComponentProps<Spline>>;
|
|
62
|
+
legend?: Partial<ComponentProps<Legend>>;
|
|
63
|
+
highlight?: Partial<ComponentProps<Highlight>>;
|
|
64
|
+
labels?: Partial<ComponentProps<Labels>>;
|
|
65
|
+
points?: Partial<ComponentProps<Points>>;
|
|
66
|
+
} = {};
|
|
67
|
+
|
|
68
|
+
$: allSeriesData = series
|
|
28
69
|
.flatMap((s) => s.data?.map((d) => ({ seriesKey: s.key, ...d })))
|
|
29
|
-
.filter((d) => d)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
70
|
+
.filter((d) => d) as Array<TData & { stackData?: any }>;
|
|
71
|
+
|
|
72
|
+
$: chartData = (allSeriesData.length ? allSeriesData : chartDataArray(data)) as Array<
|
|
73
|
+
TData & { stackData?: any }
|
|
74
|
+
>;
|
|
75
|
+
|
|
76
|
+
// Default xScale based on first data's `x` value
|
|
77
|
+
$: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinear();
|
|
78
|
+
|
|
79
|
+
function getSplineProps(s: (typeof series)[number], i: number) {
|
|
80
|
+
const splineProps: ComponentProps<Spline> = {
|
|
81
|
+
data: s.data,
|
|
82
|
+
y: s.value ?? (s.data ? undefined : s.key),
|
|
83
|
+
class: 'stroke-2',
|
|
84
|
+
stroke: s.color,
|
|
85
|
+
...props.spline,
|
|
86
|
+
...s.props,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return splineProps;
|
|
90
|
+
}
|
|
33
91
|
</script>
|
|
34
92
|
|
|
35
93
|
<Chart
|
|
@@ -52,20 +110,40 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
52
110
|
let:xScale
|
|
53
111
|
let:y
|
|
54
112
|
let:yScale
|
|
113
|
+
let:c
|
|
114
|
+
let:cScale
|
|
55
115
|
let:width
|
|
56
116
|
let:height
|
|
57
117
|
let:padding
|
|
58
118
|
let:tooltip
|
|
59
119
|
>
|
|
60
|
-
{@const slotProps = {
|
|
120
|
+
{@const slotProps = {
|
|
121
|
+
x,
|
|
122
|
+
xScale,
|
|
123
|
+
y,
|
|
124
|
+
yScale,
|
|
125
|
+
c,
|
|
126
|
+
cScale,
|
|
127
|
+
width,
|
|
128
|
+
height,
|
|
129
|
+
padding,
|
|
130
|
+
tooltip,
|
|
131
|
+
series,
|
|
132
|
+
getSplineProps,
|
|
133
|
+
}}
|
|
61
134
|
<slot {...slotProps}>
|
|
62
135
|
<Svg center={radial}>
|
|
136
|
+
<slot name="grid" {...slotProps}>
|
|
137
|
+
{#if grid}
|
|
138
|
+
<Grid x={radial} y {...typeof grid === 'object' ? grid : null} {...props.grid} />
|
|
139
|
+
{/if}
|
|
140
|
+
</slot>
|
|
141
|
+
|
|
63
142
|
<slot name="axis" {...slotProps}>
|
|
64
143
|
{#if axis}
|
|
65
144
|
{#if axis !== 'x'}
|
|
66
145
|
<Axis
|
|
67
146
|
placement={radial ? 'radius' : 'left'}
|
|
68
|
-
grid
|
|
69
147
|
format={(value) => format(value, undefined, { variant: 'short' })}
|
|
70
148
|
{...typeof axis === 'object' ? axis : null}
|
|
71
149
|
{...props.yAxis}
|
|
@@ -75,7 +153,6 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
75
153
|
{#if axis !== 'y'}
|
|
76
154
|
<Axis
|
|
77
155
|
placement={radial ? 'angle' : 'bottom'}
|
|
78
|
-
grid={radial}
|
|
79
156
|
format={(value) => format(value, undefined, { variant: 'short' })}
|
|
80
157
|
{...typeof axis === 'object' ? axis : null}
|
|
81
158
|
{...props.xAxis}
|
|
@@ -91,15 +168,8 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
91
168
|
<slot name="below-marks" {...slotProps} />
|
|
92
169
|
|
|
93
170
|
<slot name="marks" {...slotProps}>
|
|
94
|
-
{#each series as s}
|
|
95
|
-
<Spline
|
|
96
|
-
data={s.data}
|
|
97
|
-
y={s.value ?? (s.data ? undefined : s.key)}
|
|
98
|
-
class="stroke-2"
|
|
99
|
-
stroke={s.color}
|
|
100
|
-
{...props.spline}
|
|
101
|
-
{...s.props}
|
|
102
|
-
/>
|
|
171
|
+
{#each series as s, i}
|
|
172
|
+
<Spline {...getSplineProps(s, i)} />
|
|
103
173
|
{/each}
|
|
104
174
|
</slot>
|
|
105
175
|
|
|
@@ -137,10 +207,12 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
137
207
|
<slot name="legend" {...slotProps}>
|
|
138
208
|
{#if legend}
|
|
139
209
|
<Legend
|
|
140
|
-
scale={
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
210
|
+
scale={isDefaultSeries
|
|
211
|
+
? undefined
|
|
212
|
+
: scaleOrdinal(
|
|
213
|
+
series.map((s) => s.label ?? s.key),
|
|
214
|
+
series.map((s) => s.color)
|
|
215
|
+
)}
|
|
144
216
|
placement="bottom"
|
|
145
217
|
variant="swatches"
|
|
146
218
|
{...props.legend}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import { type ComponentProps } from 'svelte';
|
|
3
3
|
import Axis from '../Axis.svelte';
|
|
4
|
+
import Grid from '../Grid.svelte';
|
|
4
5
|
import Highlight from '../Highlight.svelte';
|
|
5
6
|
import Labels from '../Labels.svelte';
|
|
6
7
|
import Legend from '../Legend.svelte';
|
|
@@ -76,7 +77,7 @@ declare class __sveltets_Render<TData> {
|
|
|
76
77
|
width: number;
|
|
77
78
|
height: number;
|
|
78
79
|
}) => number[] | string[]) | undefined;
|
|
79
|
-
cRange?: string[];
|
|
80
|
+
cRange?: string[] | readonly string[];
|
|
80
81
|
xReverse?: boolean;
|
|
81
82
|
yReverse?: boolean;
|
|
82
83
|
zReverse?: boolean;
|
|
@@ -131,6 +132,13 @@ declare class __sveltets_Render<TData> {
|
|
|
131
132
|
onClick?: ({ data }: {
|
|
132
133
|
data: any;
|
|
133
134
|
}) => any;
|
|
135
|
+
tooltip?: import("svelte/store").Writable<{
|
|
136
|
+
y: number;
|
|
137
|
+
x: number;
|
|
138
|
+
data: any;
|
|
139
|
+
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
140
|
+
hide: () => void;
|
|
141
|
+
}>;
|
|
134
142
|
}> | undefined;
|
|
135
143
|
transform?: Partial<{
|
|
136
144
|
mode?: "canvas" | "manual" | "none";
|
|
@@ -179,6 +187,14 @@ declare class __sveltets_Render<TData> {
|
|
|
179
187
|
setScale?: (value: number, options?: import("../../stores/motionStore").MotionOptions) => void;
|
|
180
188
|
}> | undefined;
|
|
181
189
|
transformContext?: import("..").TransformContext;
|
|
190
|
+
geoProjection?: import("svelte/store").Writable<import("d3-geo").GeoProjection> | undefined;
|
|
191
|
+
tooltipContext?: import("svelte/store").Writable<{
|
|
192
|
+
y: number;
|
|
193
|
+
x: number;
|
|
194
|
+
data: any;
|
|
195
|
+
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
196
|
+
hide: () => void;
|
|
197
|
+
}> | undefined;
|
|
182
198
|
} & {
|
|
183
199
|
axis?: boolean | "x" | "y" | {
|
|
184
200
|
[x: string]: any;
|
|
@@ -186,7 +202,7 @@ declare class __sveltets_Render<TData> {
|
|
|
186
202
|
label?: string | undefined;
|
|
187
203
|
labelPlacement?: ("start" | "middle" | "end") | undefined;
|
|
188
204
|
labelProps?: Partial<ComponentProps<import("..").Text>> | undefined;
|
|
189
|
-
rule?: (boolean |
|
|
205
|
+
rule?: (boolean | Partial<ComponentProps<Rule>>) | undefined;
|
|
190
206
|
grid?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
191
207
|
ticks?: number | any[] | ((scale: import("../../utils/scales").AnyScale) => any) | null | undefined;
|
|
192
208
|
tickLength?: number | undefined;
|
|
@@ -202,8 +218,26 @@ declare class __sveltets_Render<TData> {
|
|
|
202
218
|
label?: string;
|
|
203
219
|
} | undefined;
|
|
204
220
|
};
|
|
221
|
+
grid?: boolean | {
|
|
222
|
+
[x: string]: any;
|
|
223
|
+
x?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
224
|
+
y?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
225
|
+
xTicks?: number | any[] | ((scale: import("../../utils/scales").AnyScale) => any) | null | undefined;
|
|
226
|
+
yTicks?: number | any[] | ((scale: import("../../utils/scales").AnyScale) => any) | null | undefined;
|
|
227
|
+
bandAlign?: ("center" | "between") | undefined;
|
|
228
|
+
radialY?: ("circle" | "linear") | undefined;
|
|
229
|
+
spring?: boolean | Parameters<typeof import("svelte/motion").spring>[1];
|
|
230
|
+
tweened?: boolean | Parameters<typeof import("svelte/motion").tweened>[1];
|
|
231
|
+
transitionIn?: (typeof import("svelte/transition").fade | (() => {})) | undefined;
|
|
232
|
+
transitionInParams?: import("svelte-ux").TransitionParams | undefined;
|
|
233
|
+
classes?: {
|
|
234
|
+
root?: string;
|
|
235
|
+
line?: string;
|
|
236
|
+
} | undefined;
|
|
237
|
+
};
|
|
205
238
|
labels?: boolean | {
|
|
206
239
|
[x: string]: any;
|
|
240
|
+
value?: Accessor;
|
|
207
241
|
placement?: ("inside" | "outside" | "center") | undefined;
|
|
208
242
|
offset?: number | undefined;
|
|
209
243
|
format?: import("@layerstack/utils").FormatType | undefined;
|
|
@@ -219,7 +253,7 @@ declare class __sveltets_Render<TData> {
|
|
|
219
253
|
tickValues?: any[] | undefined;
|
|
220
254
|
tickFontSize?: number | undefined;
|
|
221
255
|
tickLength?: number | undefined;
|
|
222
|
-
placement?: ("
|
|
256
|
+
placement?: ("center" | "left" | "right" | "bottom" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
223
257
|
orientation?: ("horizontal" | "vertical") | undefined;
|
|
224
258
|
variant?: ("ramp" | "swatches") | undefined;
|
|
225
259
|
classes?: {
|
|
@@ -247,6 +281,7 @@ declare class __sveltets_Render<TData> {
|
|
|
247
281
|
props?: {
|
|
248
282
|
xAxis?: Partial<ComponentProps<Axis>>;
|
|
249
283
|
yAxis?: Partial<ComponentProps<Axis>>;
|
|
284
|
+
grid?: Partial<ComponentProps<Grid>>;
|
|
250
285
|
rule?: Partial<ComponentProps<Rule>>;
|
|
251
286
|
spline?: Partial<ComponentProps<Spline>>;
|
|
252
287
|
legend?: Partial<ComponentProps<Legend>>;
|
|
@@ -257,7 +292,9 @@ declare class __sveltets_Render<TData> {
|
|
|
257
292
|
rule?: boolean | {
|
|
258
293
|
[x: string]: any;
|
|
259
294
|
x?: (number | Date | boolean | "left" | "right") | undefined;
|
|
295
|
+
xOffset?: number | undefined;
|
|
260
296
|
y?: (number | Date | boolean | "top" | "bottom") | undefined;
|
|
297
|
+
yOffset?: number | undefined;
|
|
261
298
|
};
|
|
262
299
|
series?: {
|
|
263
300
|
key: string | number;
|
|
@@ -274,6 +311,7 @@ declare class __sveltets_Render<TData> {
|
|
|
274
311
|
};
|
|
275
312
|
slots(): {
|
|
276
313
|
default: any;
|
|
314
|
+
grid: any;
|
|
277
315
|
axis: any;
|
|
278
316
|
'below-marks': any;
|
|
279
317
|
marks: any;
|
|
@@ -1,52 +1,102 @@
|
|
|
1
|
-
<script generics="TData">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export let
|
|
45
|
-
$:
|
|
1
|
+
<script lang="ts" generics="TData">
|
|
2
|
+
import { type ComponentProps } from 'svelte';
|
|
3
|
+
import { sum } from 'd3-array';
|
|
4
|
+
import { format } from '@layerstack/utils';
|
|
5
|
+
|
|
6
|
+
import Arc from '../Arc.svelte';
|
|
7
|
+
import Chart from '../Chart.svelte';
|
|
8
|
+
import Group from '../Group.svelte';
|
|
9
|
+
import Legend from '../Legend.svelte';
|
|
10
|
+
import Pie from '../Pie.svelte';
|
|
11
|
+
import Svg from '../layout/Svg.svelte';
|
|
12
|
+
import * as Tooltip from '../tooltip/index.js';
|
|
13
|
+
|
|
14
|
+
import { accessor, chartDataArray, type Accessor } from '../../utils/common.js';
|
|
15
|
+
|
|
16
|
+
type ChartProps = ComponentProps<Chart<TData>>;
|
|
17
|
+
|
|
18
|
+
interface $$Props extends ChartProps {
|
|
19
|
+
cornerRadius?: typeof cornerRadius;
|
|
20
|
+
innerRadius?: typeof innerRadius;
|
|
21
|
+
key?: typeof key;
|
|
22
|
+
label?: typeof label;
|
|
23
|
+
legend?: typeof legend;
|
|
24
|
+
maxValue?: typeof maxValue;
|
|
25
|
+
outerRadius?: typeof outerRadius;
|
|
26
|
+
padAngle?: typeof padAngle;
|
|
27
|
+
props?: typeof props;
|
|
28
|
+
range?: typeof range;
|
|
29
|
+
series?: typeof series;
|
|
30
|
+
value?: typeof label;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export let data: ChartProps['data'] = [];
|
|
34
|
+
|
|
35
|
+
/** Key accessor */
|
|
36
|
+
export let key: Accessor<TData> = 'key';
|
|
37
|
+
$: keyAccessor = accessor(key);
|
|
38
|
+
|
|
39
|
+
/** Label accessor */
|
|
40
|
+
export let label: Accessor<TData> = 'label';
|
|
41
|
+
$: labelAccessor = accessor(label);
|
|
42
|
+
|
|
43
|
+
/** Value accessor */
|
|
44
|
+
export let value: Accessor<TData> = 'value';
|
|
45
|
+
$: valueAccessor = accessor(value);
|
|
46
|
+
|
|
47
|
+
/** Maximum possible value, useful when `data` is single item */
|
|
48
|
+
export let maxValue: number | undefined = undefined;
|
|
49
|
+
|
|
50
|
+
export let series: {
|
|
51
|
+
key: string | number;
|
|
52
|
+
label?: string;
|
|
53
|
+
value?: Accessor<TData>;
|
|
54
|
+
/** Provider series data, else uses chart data (with value/key accessor) */
|
|
55
|
+
data?: TData[];
|
|
56
|
+
/** Maximum possible value, useful when `data` is single item */
|
|
57
|
+
maxValue?: number;
|
|
58
|
+
color?: string;
|
|
59
|
+
props?: Partial<ComponentProps<Arc>>;
|
|
60
|
+
}[] = [{ key: 'default', value: value /*, color: 'hsl(var(--color-primary))'*/ }];
|
|
61
|
+
|
|
62
|
+
export let legend: ComponentProps<Legend> | boolean = false;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Range [min,max] in degrees. See also startAngle/endAngle
|
|
66
|
+
*/
|
|
67
|
+
export let range = [0, 360];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Define innerRadius.
|
|
71
|
+
* value >= 1: discrete value
|
|
72
|
+
* value > 0: percent of `outerRadius`
|
|
73
|
+
* value < 0: offset of `outerRadius`
|
|
74
|
+
* default: yRange min
|
|
75
|
+
*/
|
|
76
|
+
export let innerRadius: number | undefined = undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Define outerRadius. Defaults to yRange max/2 (ie. chart height / 2)
|
|
80
|
+
*/
|
|
81
|
+
export let outerRadius: number | undefined = undefined;
|
|
82
|
+
|
|
83
|
+
export let cornerRadius = 0;
|
|
84
|
+
export let padAngle = 0;
|
|
85
|
+
|
|
86
|
+
export let props: {
|
|
87
|
+
pie?: Partial<ComponentProps<Pie>>;
|
|
88
|
+
group?: Partial<ComponentProps<Group>>;
|
|
89
|
+
arc?: Partial<ComponentProps<Arc>>;
|
|
90
|
+
legend?: Partial<ComponentProps<Legend>>;
|
|
91
|
+
} = {};
|
|
92
|
+
|
|
93
|
+
$: allSeriesData = series
|
|
46
94
|
.flatMap((s) => s.data?.map((d) => ({ seriesKey: s.key, ...d })))
|
|
47
|
-
.filter((d) => d)
|
|
48
|
-
|
|
49
|
-
$:
|
|
95
|
+
.filter((d) => d) as Array<TData>;
|
|
96
|
+
|
|
97
|
+
$: chartData = (allSeriesData.length ? allSeriesData : chartDataArray(data)) as Array<TData>;
|
|
98
|
+
|
|
99
|
+
$: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
50
100
|
</script>
|
|
51
101
|
|
|
52
102
|
<Chart
|
|
@@ -77,7 +127,21 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
77
127
|
let:padding
|
|
78
128
|
let:tooltip
|
|
79
129
|
>
|
|
80
|
-
{@const slotProps = {
|
|
130
|
+
{@const slotProps = {
|
|
131
|
+
key,
|
|
132
|
+
label,
|
|
133
|
+
value,
|
|
134
|
+
x,
|
|
135
|
+
xScale,
|
|
136
|
+
y,
|
|
137
|
+
yScale,
|
|
138
|
+
c,
|
|
139
|
+
cScale,
|
|
140
|
+
width,
|
|
141
|
+
height,
|
|
142
|
+
padding,
|
|
143
|
+
tooltip,
|
|
144
|
+
}}
|
|
81
145
|
<slot {...slotProps}>
|
|
82
146
|
<Svg center>
|
|
83
147
|
<slot name="below-marks" {...slotProps} />
|
|
@@ -96,8 +160,8 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
96
160
|
outerRadius={(outerRadius ?? 0) < 0 ? i * (outerRadius ?? 0) : outerRadius}
|
|
97
161
|
{cornerRadius}
|
|
98
162
|
{padAngle}
|
|
99
|
-
fill={s.color ?? cScale(c(d))}
|
|
100
|
-
track={{ fill: s.color ?? cScale(c(d)), 'fill-opacity': 0.1 }}
|
|
163
|
+
fill={s.color ?? cScale?.(c(d))}
|
|
164
|
+
track={{ fill: s.color ?? cScale?.(c(d)), 'fill-opacity': 0.1 }}
|
|
101
165
|
{tooltip}
|
|
102
166
|
data={d}
|
|
103
167
|
{...props.arc}
|
|
@@ -122,7 +186,7 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
122
186
|
{innerRadius}
|
|
123
187
|
{cornerRadius}
|
|
124
188
|
{padAngle}
|
|
125
|
-
fill={cScale(c(arc.data))}
|
|
189
|
+
fill={cScale?.(c(arc.data))}
|
|
126
190
|
data={arc.data}
|
|
127
191
|
{tooltip}
|
|
128
192
|
{...props.arc}
|
|
@@ -159,7 +223,7 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
159
223
|
<Tooltip.Item
|
|
160
224
|
label={labelAccessor(data) || keyAccessor(data)}
|
|
161
225
|
value={valueAccessor(data)}
|
|
162
|
-
color={cScale(c(data))}
|
|
226
|
+
color={cScale?.(c(data))}
|
|
163
227
|
{format}
|
|
164
228
|
/>
|
|
165
229
|
</Tooltip.List>
|
|
@@ -73,7 +73,7 @@ declare class __sveltets_Render<TData> {
|
|
|
73
73
|
width: number;
|
|
74
74
|
height: number;
|
|
75
75
|
}) => number[] | string[]) | undefined;
|
|
76
|
-
cRange?: string[];
|
|
76
|
+
cRange?: string[] | readonly string[];
|
|
77
77
|
xReverse?: boolean;
|
|
78
78
|
yReverse?: boolean;
|
|
79
79
|
zReverse?: boolean;
|
|
@@ -128,6 +128,13 @@ declare class __sveltets_Render<TData> {
|
|
|
128
128
|
onClick?: ({ data }: {
|
|
129
129
|
data: any;
|
|
130
130
|
}) => any;
|
|
131
|
+
tooltip?: import("svelte/store").Writable<{
|
|
132
|
+
y: number;
|
|
133
|
+
x: number;
|
|
134
|
+
data: any;
|
|
135
|
+
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
136
|
+
hide: () => void;
|
|
137
|
+
}>;
|
|
131
138
|
}> | undefined;
|
|
132
139
|
transform?: Partial<{
|
|
133
140
|
mode?: "canvas" | "manual" | "none";
|
|
@@ -176,6 +183,14 @@ declare class __sveltets_Render<TData> {
|
|
|
176
183
|
setScale?: (value: number, options?: import("../../stores/motionStore").MotionOptions) => void;
|
|
177
184
|
}> | undefined;
|
|
178
185
|
transformContext?: import("..").TransformContext;
|
|
186
|
+
geoProjection?: import("svelte/store").Writable<import("d3-geo").GeoProjection> | undefined;
|
|
187
|
+
tooltipContext?: import("svelte/store").Writable<{
|
|
188
|
+
y: number;
|
|
189
|
+
x: number;
|
|
190
|
+
data: any;
|
|
191
|
+
show: (e: PointerEvent, tooltipData?: any) => void;
|
|
192
|
+
hide: () => void;
|
|
193
|
+
}> | undefined;
|
|
179
194
|
} & {
|
|
180
195
|
cornerRadius?: number;
|
|
181
196
|
innerRadius?: number | undefined;
|
|
@@ -192,7 +207,7 @@ declare class __sveltets_Render<TData> {
|
|
|
192
207
|
tickValues?: any[] | undefined;
|
|
193
208
|
tickFontSize?: number | undefined;
|
|
194
209
|
tickLength?: number | undefined;
|
|
195
|
-
placement?: ("
|
|
210
|
+
placement?: ("center" | "left" | "right" | "bottom" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
196
211
|
orientation?: ("horizontal" | "vertical") | undefined;
|
|
197
212
|
variant?: ("ramp" | "swatches") | undefined;
|
|
198
213
|
classes?: {
|