layerchart 0.51.2 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Axis.svelte +4 -3
- package/dist/components/Axis.svelte.d.ts +17 -12
- package/dist/components/Labels.svelte +2 -2
- package/dist/components/Legend.svelte +61 -36
- package/dist/components/Legend.svelte.d.ts +4 -0
- package/dist/components/Points.svelte +3 -0
- package/dist/components/Points.svelte.d.ts +10 -16
- package/dist/components/Rule.svelte +60 -19
- package/dist/components/charts/AreaChart.svelte +40 -8
- package/dist/components/charts/AreaChart.svelte.d.ts +62 -31
- package/dist/components/charts/BarChart.svelte +42 -9
- package/dist/components/charts/BarChart.svelte.d.ts +63 -24
- package/dist/components/charts/LineChart.svelte +27 -6
- package/dist/components/charts/LineChart.svelte.d.ts +62 -31
- package/dist/components/charts/PieChart.svelte +16 -0
- package/dist/components/charts/PieChart.svelte.d.ts +30 -4
- package/dist/components/charts/ScatterChart.svelte +26 -5
- package/dist/components/charts/ScatterChart.svelte.d.ts +53 -20
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script generics="TData">import {} from 'svelte';
|
|
2
|
-
import { scaleBand, scaleLinear } from 'd3-scale';
|
|
3
|
-
import { stack } from 'd3-shape';
|
|
2
|
+
import { scaleBand, scaleOrdinal, scaleLinear } from 'd3-scale';
|
|
3
|
+
import { stack, stackOffsetDiverging, stackOffsetExpand, stackOffsetNone } from 'd3-shape';
|
|
4
4
|
import { sum } from 'd3-array';
|
|
5
5
|
import { format } from '@layerstack/utils';
|
|
6
6
|
import Axis from '../Axis.svelte';
|
|
@@ -8,6 +8,8 @@ import Bars from '../Bars.svelte';
|
|
|
8
8
|
import Chart from '../Chart.svelte';
|
|
9
9
|
import Highlight from '../Highlight.svelte';
|
|
10
10
|
import Labels from '../Labels.svelte';
|
|
11
|
+
import Legend from '../Legend.svelte';
|
|
12
|
+
import Rule from '../Rule.svelte';
|
|
11
13
|
import Svg from '../layout/Svg.svelte';
|
|
12
14
|
import * as Tooltip from '../tooltip/index.js';
|
|
13
15
|
import { accessor, chartDataArray } from '../../utils/common.js';
|
|
@@ -25,10 +27,12 @@ export let series = [
|
|
|
25
27
|
];
|
|
26
28
|
/** Determine how to layout series. Overlap (default), stack, or group side by side */
|
|
27
29
|
export let seriesLayout = 'overlap';
|
|
28
|
-
$: stackSeries = seriesLayout
|
|
30
|
+
$: stackSeries = seriesLayout.startsWith('stack');
|
|
29
31
|
$: groupSeries = seriesLayout === 'group';
|
|
30
32
|
export let axis = true;
|
|
33
|
+
export let rule = true;
|
|
31
34
|
export let labels = false;
|
|
35
|
+
export let legend = false;
|
|
32
36
|
/** Padding between primary x or y bands/bars, applied to scaleBand().padding() */
|
|
33
37
|
export let bandPadding = 0.4;
|
|
34
38
|
/** Padding between group/series items when using 'seriesLayout="group"', applied to scaleBand().padding() */
|
|
@@ -64,7 +68,19 @@ $: allSeriesData = series
|
|
|
64
68
|
$: chartData = (allSeriesData.length ? allSeriesData : chartDataArray(data));
|
|
65
69
|
$: if (stackSeries) {
|
|
66
70
|
const seriesKeys = series.map((s) => s.key);
|
|
67
|
-
const stackData = stack().keys(seriesKeys)(chartDataArray(data));
|
|
71
|
+
// const stackData = stack().keys(seriesKeys)(chartDataArray(data)) as any[];
|
|
72
|
+
const offset = seriesLayout === 'stackExpand'
|
|
73
|
+
? stackOffsetExpand
|
|
74
|
+
: seriesLayout === 'stackDiverging'
|
|
75
|
+
? stackOffsetDiverging
|
|
76
|
+
: stackOffsetNone;
|
|
77
|
+
const stackData = stack()
|
|
78
|
+
.keys(seriesKeys)
|
|
79
|
+
.value((d, key) => {
|
|
80
|
+
const s = series.find((d) => d.key === key);
|
|
81
|
+
return accessor(s.value ?? s.key)(d);
|
|
82
|
+
})
|
|
83
|
+
.offset(offset)(chartDataArray(data));
|
|
68
84
|
chartData = chartData.map((d, i) => {
|
|
69
85
|
return {
|
|
70
86
|
...d,
|
|
@@ -78,7 +94,7 @@ $: if (stackSeries) {
|
|
|
78
94
|
data={chartData}
|
|
79
95
|
x={x ??
|
|
80
96
|
(stackSeries
|
|
81
|
-
? (d) => series.
|
|
97
|
+
? (d) => series.flatMap((s, i) => d.stackData[i])
|
|
82
98
|
: series.map((s) => s.value ?? s.key))}
|
|
83
99
|
{xScale}
|
|
84
100
|
{xBaseline}
|
|
@@ -88,7 +104,7 @@ $: if (stackSeries) {
|
|
|
88
104
|
{x1Range}
|
|
89
105
|
y={y ??
|
|
90
106
|
(stackSeries
|
|
91
|
-
? (d) => series.
|
|
107
|
+
? (d) => series.flatMap((s, i) => d.stackData[i])
|
|
92
108
|
: series.map((s) => s.value ?? s.key))}
|
|
93
109
|
{yScale}
|
|
94
110
|
{yBaseline}
|
|
@@ -100,7 +116,7 @@ $: if (stackSeries) {
|
|
|
100
116
|
? undefined
|
|
101
117
|
: {
|
|
102
118
|
left: axis === true || axis === 'y' ? 16 : 0,
|
|
103
|
-
bottom: axis === true || axis === 'x' ? 16 : 0,
|
|
119
|
+
bottom: (axis === true || axis === 'x' ? 16 : 0) + (legend === true ? 32 : 0),
|
|
104
120
|
}}
|
|
105
121
|
tooltip={{ mode: 'band' }}
|
|
106
122
|
{...$$restProps}
|
|
@@ -122,7 +138,6 @@ $: if (stackSeries) {
|
|
|
122
138
|
<Axis
|
|
123
139
|
placement="left"
|
|
124
140
|
grid={isVertical}
|
|
125
|
-
rule
|
|
126
141
|
format={(value) => format(value, undefined, { variant: 'short' })}
|
|
127
142
|
{...typeof axis === 'object' ? axis : null}
|
|
128
143
|
{...props.yAxis}
|
|
@@ -133,12 +148,15 @@ $: if (stackSeries) {
|
|
|
133
148
|
<Axis
|
|
134
149
|
placement="bottom"
|
|
135
150
|
grid={!isVertical}
|
|
136
|
-
rule
|
|
137
151
|
format={(value) => format(value, undefined, { variant: 'short' })}
|
|
138
152
|
{...typeof axis === 'object' ? axis : null}
|
|
139
153
|
{...props.xAxis}
|
|
140
154
|
/>
|
|
141
155
|
{/if}
|
|
156
|
+
|
|
157
|
+
{#if rule}
|
|
158
|
+
<Rule x={0} y={0} {...typeof rule === 'object' ? rule : null} {...props.rule} />
|
|
159
|
+
{/if}
|
|
142
160
|
{/if}
|
|
143
161
|
</slot>
|
|
144
162
|
|
|
@@ -180,6 +198,21 @@ $: if (stackSeries) {
|
|
|
180
198
|
{/if}
|
|
181
199
|
</Svg>
|
|
182
200
|
|
|
201
|
+
<slot name="legend" {...slotProps}>
|
|
202
|
+
{#if legend}
|
|
203
|
+
<Legend
|
|
204
|
+
scale={scaleOrdinal(
|
|
205
|
+
series.map((s) => s.key),
|
|
206
|
+
series.map((s) => s.color)
|
|
207
|
+
)}
|
|
208
|
+
placement="bottom"
|
|
209
|
+
variant="swatches"
|
|
210
|
+
{...props.legend}
|
|
211
|
+
{...typeof legend === 'object' ? legend : null}
|
|
212
|
+
/>
|
|
213
|
+
{/if}
|
|
214
|
+
</slot>
|
|
215
|
+
|
|
183
216
|
<slot name="tooltip" {...slotProps}>
|
|
184
217
|
<Tooltip.Root let:data>
|
|
185
218
|
<Tooltip.Header>{format(isVertical ? x(data) : y(data))}</Tooltip.Header>
|
|
@@ -4,6 +4,8 @@ import Axis from '../Axis.svelte';
|
|
|
4
4
|
import Bars from '../Bars.svelte';
|
|
5
5
|
import Highlight from '../Highlight.svelte';
|
|
6
6
|
import Labels from '../Labels.svelte';
|
|
7
|
+
import Legend from '../Legend.svelte';
|
|
8
|
+
import Rule from '../Rule.svelte';
|
|
7
9
|
import { type Accessor } from '../../utils/common.js';
|
|
8
10
|
declare class __sveltets_Render<TData> {
|
|
9
11
|
props(): {
|
|
@@ -177,48 +179,84 @@ declare class __sveltets_Render<TData> {
|
|
|
177
179
|
}> | undefined;
|
|
178
180
|
transformContext?: import("..").TransformContext;
|
|
179
181
|
} & {
|
|
180
|
-
series?: {
|
|
181
|
-
key: string;
|
|
182
|
-
label?: string;
|
|
183
|
-
value?: Accessor<TData>;
|
|
184
|
-
/** Provider series data, else uses chart data (with value/key accessor) */
|
|
185
|
-
data?: TData[] | undefined;
|
|
186
|
-
color?: string;
|
|
187
|
-
props?: Partial<ComponentProps<Bars>>;
|
|
188
|
-
}[] | undefined;
|
|
189
|
-
seriesLayout?: "overlap" | "stack" | "group";
|
|
190
|
-
labels?: boolean | {
|
|
191
|
-
[x: string]: any;
|
|
192
|
-
placement?: ("inside" | "outside" | "center") | undefined;
|
|
193
|
-
offset?: number | undefined;
|
|
194
|
-
format?: import("@layerstack/utils").FormatType | undefined;
|
|
195
|
-
};
|
|
196
182
|
axis?: boolean | "x" | "y" | {
|
|
183
|
+
[x: string]: any;
|
|
197
184
|
placement: "top" | "bottom" | "left" | "right" | "angle" | "radius";
|
|
198
|
-
label?: string;
|
|
199
|
-
labelPlacement?: "start" | "middle" | "end";
|
|
185
|
+
label?: string | undefined;
|
|
186
|
+
labelPlacement?: ("start" | "middle" | "end") | undefined;
|
|
200
187
|
labelProps?: Partial<ComponentProps<import("..").Text>> | undefined;
|
|
201
|
-
rule?: boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style"
|
|
202
|
-
grid?: boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style"
|
|
188
|
+
rule?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
189
|
+
grid?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
203
190
|
ticks?: number | any[] | ((scale: import("../../utils/scales").AnyScale) => any) | null | undefined;
|
|
204
|
-
tickLength?: number;
|
|
191
|
+
tickLength?: number | undefined;
|
|
205
192
|
format?: import("@layerstack/utils").FormatType | undefined;
|
|
206
193
|
tickLabelProps?: Partial<ComponentProps<import("..").Text>> | undefined;
|
|
207
194
|
spring?: boolean | Parameters<typeof import("svelte/motion").spring>[1];
|
|
208
195
|
tweened?: boolean | Parameters<typeof import("svelte/motion").tweened>[1];
|
|
209
|
-
transitionIn?: typeof import("svelte/transition").fade | (() => {});
|
|
210
|
-
transitionInParams?: import("svelte-ux").TransitionParams;
|
|
196
|
+
transitionIn?: (typeof import("svelte/transition").fade | (() => {})) | undefined;
|
|
197
|
+
transitionInParams?: import("svelte-ux").TransitionParams | undefined;
|
|
211
198
|
scale?: any;
|
|
199
|
+
classes?: {
|
|
200
|
+
root?: string;
|
|
201
|
+
label?: string;
|
|
202
|
+
} | undefined;
|
|
212
203
|
};
|
|
213
|
-
orientation?: "horizontal" | "vertical";
|
|
214
204
|
bandPadding?: number;
|
|
205
|
+
groupPadding?: number;
|
|
206
|
+
labels?: boolean | {
|
|
207
|
+
[x: string]: any;
|
|
208
|
+
placement?: ("inside" | "outside" | "center") | undefined;
|
|
209
|
+
offset?: number | undefined;
|
|
210
|
+
format?: import("@layerstack/utils").FormatType | undefined;
|
|
211
|
+
};
|
|
212
|
+
legend?: boolean | {
|
|
213
|
+
[x: string]: any;
|
|
214
|
+
scale?: any;
|
|
215
|
+
title?: string | undefined;
|
|
216
|
+
width?: number | undefined;
|
|
217
|
+
height?: number | undefined;
|
|
218
|
+
ticks?: number | undefined;
|
|
219
|
+
tickFormat?: import("@layerstack/utils").FormatType | undefined;
|
|
220
|
+
tickValues?: any[] | undefined;
|
|
221
|
+
tickFontSize?: number | undefined;
|
|
222
|
+
tickLength?: number | undefined;
|
|
223
|
+
placement?: ("left" | "right" | "center" | "bottom" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
224
|
+
orientation?: ("horizontal" | "vertical") | undefined;
|
|
225
|
+
variant?: ("ramp" | "swatches") | undefined;
|
|
226
|
+
classes?: {
|
|
227
|
+
root?: string;
|
|
228
|
+
title?: string;
|
|
229
|
+
label?: string;
|
|
230
|
+
tick?: string;
|
|
231
|
+
swatches?: string;
|
|
232
|
+
swatch?: string;
|
|
233
|
+
} | undefined;
|
|
234
|
+
};
|
|
235
|
+
orientation?: "horizontal" | "vertical";
|
|
215
236
|
props?: {
|
|
216
237
|
xAxis?: Partial<ComponentProps<Axis>>;
|
|
217
238
|
yAxis?: Partial<ComponentProps<Axis>>;
|
|
239
|
+
rule?: Partial<ComponentProps<Rule>>;
|
|
218
240
|
bars?: Partial<ComponentProps<Bars>>;
|
|
241
|
+
legend?: Partial<ComponentProps<Legend>>;
|
|
219
242
|
highlight?: Partial<ComponentProps<Highlight>>;
|
|
220
243
|
labels?: Partial<ComponentProps<Labels>>;
|
|
221
244
|
} | undefined;
|
|
245
|
+
rule?: boolean | {
|
|
246
|
+
[x: string]: any;
|
|
247
|
+
x?: (number | Date | boolean | "left" | "right") | undefined;
|
|
248
|
+
y?: (number | Date | boolean | "top" | "bottom") | undefined;
|
|
249
|
+
};
|
|
250
|
+
series?: {
|
|
251
|
+
key: string;
|
|
252
|
+
label?: string;
|
|
253
|
+
value?: Accessor<TData>;
|
|
254
|
+
/** Provider series data, else uses chart data (with value/key accessor) */
|
|
255
|
+
data?: TData[] | undefined;
|
|
256
|
+
color?: string;
|
|
257
|
+
props?: Partial<ComponentProps<Bars>>;
|
|
258
|
+
}[] | undefined;
|
|
259
|
+
seriesLayout?: "overlap" | "stack" | "stackExpand" | "stackDiverging" | "group";
|
|
222
260
|
};
|
|
223
261
|
events(): {} & {
|
|
224
262
|
[evt: string]: CustomEvent<any>;
|
|
@@ -230,6 +268,7 @@ declare class __sveltets_Render<TData> {
|
|
|
230
268
|
marks: any;
|
|
231
269
|
'above-marks': any;
|
|
232
270
|
highlight: any;
|
|
271
|
+
legend: any;
|
|
233
272
|
tooltip: any;
|
|
234
273
|
};
|
|
235
274
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
<script generics="TData">import
|
|
2
|
-
import {} from '
|
|
3
|
-
import { scaleLinear, scaleTime } from 'd3-scale';
|
|
1
|
+
<script generics="TData">import {} from 'svelte';
|
|
2
|
+
import { scaleLinear, scaleOrdinal, scaleTime } from 'd3-scale';
|
|
4
3
|
import { format } from '@layerstack/utils';
|
|
5
4
|
import Axis from '../Axis.svelte';
|
|
6
5
|
import Chart from '../Chart.svelte';
|
|
7
6
|
import Highlight from '../Highlight.svelte';
|
|
8
7
|
import Labels from '../Labels.svelte';
|
|
8
|
+
import Legend from '../Legend.svelte';
|
|
9
|
+
import Points from '../Points.svelte';
|
|
10
|
+
import Rule from '../Rule.svelte';
|
|
9
11
|
import Spline from '../Spline.svelte';
|
|
10
12
|
import Svg from '../layout/Svg.svelte';
|
|
11
13
|
import * as Tooltip from '../tooltip/index.js';
|
|
@@ -17,7 +19,9 @@ export let y = undefined;
|
|
|
17
19
|
export let radial = false;
|
|
18
20
|
export let series = [{ key: 'default', value: y, color: 'hsl(var(--color-primary))' }];
|
|
19
21
|
export let axis = true;
|
|
22
|
+
export let rule = true;
|
|
20
23
|
export let labels = false;
|
|
24
|
+
export let legend = false;
|
|
21
25
|
export let points = false;
|
|
22
26
|
export let props = {};
|
|
23
27
|
$: allSeriesData = series
|
|
@@ -40,7 +44,7 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
40
44
|
? undefined
|
|
41
45
|
: {
|
|
42
46
|
left: axis === true || axis === 'y' ? 16 : 0,
|
|
43
|
-
bottom: axis === true || axis === 'x' ? 16 : 0,
|
|
47
|
+
bottom: (axis === true || axis === 'x' ? 16 : 0) + (legend === true ? 32 : 0),
|
|
44
48
|
}}
|
|
45
49
|
tooltip={{ mode: 'bisect-x' }}
|
|
46
50
|
{...$$restProps}
|
|
@@ -62,7 +66,6 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
62
66
|
<Axis
|
|
63
67
|
placement={radial ? 'radius' : 'left'}
|
|
64
68
|
grid
|
|
65
|
-
rule
|
|
66
69
|
format={(value) => format(value, undefined, { variant: 'short' })}
|
|
67
70
|
{...typeof axis === 'object' ? axis : null}
|
|
68
71
|
{...props.yAxis}
|
|
@@ -73,12 +76,15 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
73
76
|
<Axis
|
|
74
77
|
placement={radial ? 'angle' : 'bottom'}
|
|
75
78
|
grid={radial}
|
|
76
|
-
rule
|
|
77
79
|
format={(value) => format(value, undefined, { variant: 'short' })}
|
|
78
80
|
{...typeof axis === 'object' ? axis : null}
|
|
79
81
|
{...props.xAxis}
|
|
80
82
|
/>
|
|
81
83
|
{/if}
|
|
84
|
+
|
|
85
|
+
{#if rule}
|
|
86
|
+
<Rule x={0} y={0} {...typeof rule === 'object' ? rule : null} {...props.rule} />
|
|
87
|
+
{/if}
|
|
82
88
|
{/if}
|
|
83
89
|
</slot>
|
|
84
90
|
|
|
@@ -128,6 +134,21 @@ $: xScale = accessor(x)(chartData[0]) instanceof Date ? scaleTime() : scaleLinea
|
|
|
128
134
|
</slot>
|
|
129
135
|
</Svg>
|
|
130
136
|
|
|
137
|
+
<slot name="legend" {...slotProps}>
|
|
138
|
+
{#if legend}
|
|
139
|
+
<Legend
|
|
140
|
+
scale={scaleOrdinal(
|
|
141
|
+
series.map((s) => s.key),
|
|
142
|
+
series.map((s) => s.color)
|
|
143
|
+
)}
|
|
144
|
+
placement="bottom"
|
|
145
|
+
variant="swatches"
|
|
146
|
+
{...props.legend}
|
|
147
|
+
{...typeof legend === 'object' ? legend : null}
|
|
148
|
+
/>
|
|
149
|
+
{/if}
|
|
150
|
+
</slot>
|
|
151
|
+
|
|
131
152
|
<slot name="tooltip" {...slotProps}>
|
|
132
153
|
<Tooltip.Root let:data>
|
|
133
154
|
<Tooltip.Header>{format(x(data))}</Tooltip.Header>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import Points from '../Points.svelte';
|
|
3
2
|
import { type ComponentProps } from 'svelte';
|
|
4
3
|
import Axis from '../Axis.svelte';
|
|
5
4
|
import Highlight from '../Highlight.svelte';
|
|
6
5
|
import Labels from '../Labels.svelte';
|
|
6
|
+
import Legend from '../Legend.svelte';
|
|
7
|
+
import Points from '../Points.svelte';
|
|
8
|
+
import Rule from '../Rule.svelte';
|
|
7
9
|
import Spline from '../Spline.svelte';
|
|
8
10
|
import { type Accessor } from '../../utils/common.js';
|
|
9
11
|
declare class __sveltets_Render<TData> {
|
|
@@ -178,37 +180,56 @@ declare class __sveltets_Render<TData> {
|
|
|
178
180
|
}> | undefined;
|
|
179
181
|
transformContext?: import("..").TransformContext;
|
|
180
182
|
} & {
|
|
181
|
-
series?: {
|
|
182
|
-
key: string | number;
|
|
183
|
-
label?: string;
|
|
184
|
-
value?: Accessor<TData>;
|
|
185
|
-
/** Provider series data, else uses chart data (with value/key accessor) */
|
|
186
|
-
data?: TData[] | undefined;
|
|
187
|
-
color?: string;
|
|
188
|
-
props?: Partial<ComponentProps<Spline>>;
|
|
189
|
-
}[] | undefined;
|
|
190
|
-
labels?: boolean | {
|
|
191
|
-
[x: string]: any;
|
|
192
|
-
placement?: ("inside" | "outside" | "center") | undefined;
|
|
193
|
-
offset?: number | undefined;
|
|
194
|
-
format?: import("@layerstack/utils").FormatType | undefined;
|
|
195
|
-
};
|
|
196
183
|
axis?: boolean | "x" | "y" | {
|
|
184
|
+
[x: string]: any;
|
|
197
185
|
placement: "top" | "bottom" | "left" | "right" | "angle" | "radius";
|
|
198
|
-
label?: string;
|
|
199
|
-
labelPlacement?: "start" | "middle" | "end";
|
|
186
|
+
label?: string | undefined;
|
|
187
|
+
labelPlacement?: ("start" | "middle" | "end") | undefined;
|
|
200
188
|
labelProps?: Partial<ComponentProps<import("..").Text>> | undefined;
|
|
201
|
-
rule?: boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style"
|
|
202
|
-
grid?: boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style"
|
|
189
|
+
rule?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
190
|
+
grid?: (boolean | Pick<import("svelte/elements").SVGAttributes<SVGElement>, "class" | "style">) | undefined;
|
|
203
191
|
ticks?: number | any[] | ((scale: import("../../utils/scales").AnyScale) => any) | null | undefined;
|
|
204
|
-
tickLength?: number;
|
|
192
|
+
tickLength?: number | undefined;
|
|
205
193
|
format?: import("@layerstack/utils").FormatType | undefined;
|
|
206
194
|
tickLabelProps?: Partial<ComponentProps<import("..").Text>> | undefined;
|
|
207
195
|
spring?: boolean | Parameters<typeof import("svelte/motion").spring>[1];
|
|
208
196
|
tweened?: boolean | Parameters<typeof import("svelte/motion").tweened>[1];
|
|
209
|
-
transitionIn?: typeof import("svelte/transition").fade | (() => {});
|
|
210
|
-
transitionInParams?: import("svelte-ux").TransitionParams;
|
|
197
|
+
transitionIn?: (typeof import("svelte/transition").fade | (() => {})) | undefined;
|
|
198
|
+
transitionInParams?: import("svelte-ux").TransitionParams | undefined;
|
|
199
|
+
scale?: any;
|
|
200
|
+
classes?: {
|
|
201
|
+
root?: string;
|
|
202
|
+
label?: string;
|
|
203
|
+
} | undefined;
|
|
204
|
+
};
|
|
205
|
+
labels?: boolean | {
|
|
206
|
+
[x: string]: any;
|
|
207
|
+
placement?: ("inside" | "outside" | "center") | undefined;
|
|
208
|
+
offset?: number | undefined;
|
|
209
|
+
format?: import("@layerstack/utils").FormatType | undefined;
|
|
210
|
+
};
|
|
211
|
+
legend?: boolean | {
|
|
212
|
+
[x: string]: any;
|
|
211
213
|
scale?: any;
|
|
214
|
+
title?: string | undefined;
|
|
215
|
+
width?: number | undefined;
|
|
216
|
+
height?: number | undefined;
|
|
217
|
+
ticks?: number | undefined;
|
|
218
|
+
tickFormat?: import("@layerstack/utils").FormatType | undefined;
|
|
219
|
+
tickValues?: any[] | undefined;
|
|
220
|
+
tickFontSize?: number | undefined;
|
|
221
|
+
tickLength?: number | undefined;
|
|
222
|
+
placement?: ("left" | "right" | "center" | "bottom" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
223
|
+
orientation?: ("horizontal" | "vertical") | undefined;
|
|
224
|
+
variant?: ("ramp" | "swatches") | undefined;
|
|
225
|
+
classes?: {
|
|
226
|
+
root?: string;
|
|
227
|
+
title?: string;
|
|
228
|
+
label?: string;
|
|
229
|
+
tick?: string;
|
|
230
|
+
swatches?: string;
|
|
231
|
+
swatch?: string;
|
|
232
|
+
} | undefined;
|
|
212
233
|
};
|
|
213
234
|
points?: boolean | {
|
|
214
235
|
[x: string]: any;
|
|
@@ -220,24 +241,33 @@ declare class __sveltets_Render<TData> {
|
|
|
220
241
|
fill?: string | undefined;
|
|
221
242
|
stroke?: string | undefined;
|
|
222
243
|
strokeWidth?: number | string | undefined;
|
|
223
|
-
render?: ((ctx: CanvasRenderingContext2D, points:
|
|
224
|
-
x: number;
|
|
225
|
-
y: number;
|
|
226
|
-
r: number;
|
|
227
|
-
xValue: any;
|
|
228
|
-
yValue: any;
|
|
229
|
-
data: any;
|
|
230
|
-
}[]) => any) | undefined;
|
|
244
|
+
render?: ((ctx: CanvasRenderingContext2D, points: import("../Points.svelte").Point[]) => any) | undefined;
|
|
231
245
|
class?: string | undefined;
|
|
232
246
|
};
|
|
233
247
|
props?: {
|
|
234
248
|
xAxis?: Partial<ComponentProps<Axis>>;
|
|
235
249
|
yAxis?: Partial<ComponentProps<Axis>>;
|
|
250
|
+
rule?: Partial<ComponentProps<Rule>>;
|
|
236
251
|
spline?: Partial<ComponentProps<Spline>>;
|
|
252
|
+
legend?: Partial<ComponentProps<Legend>>;
|
|
237
253
|
highlight?: Partial<ComponentProps<Highlight>>;
|
|
238
254
|
labels?: Partial<ComponentProps<Labels>>;
|
|
239
255
|
points?: Partial<ComponentProps<Points>>;
|
|
240
256
|
} | undefined;
|
|
257
|
+
rule?: boolean | {
|
|
258
|
+
[x: string]: any;
|
|
259
|
+
x?: (number | Date | boolean | "left" | "right") | undefined;
|
|
260
|
+
y?: (number | Date | boolean | "top" | "bottom") | undefined;
|
|
261
|
+
};
|
|
262
|
+
series?: {
|
|
263
|
+
key: string | number;
|
|
264
|
+
label?: string;
|
|
265
|
+
value?: Accessor<TData>;
|
|
266
|
+
/** Provider series data, else uses chart data (with value/key accessor) */
|
|
267
|
+
data?: TData[] | undefined;
|
|
268
|
+
color?: string;
|
|
269
|
+
props?: Partial<ComponentProps<Spline>>;
|
|
270
|
+
}[] | undefined;
|
|
241
271
|
};
|
|
242
272
|
events(): {} & {
|
|
243
273
|
[evt: string]: CustomEvent<any>;
|
|
@@ -249,6 +279,7 @@ declare class __sveltets_Render<TData> {
|
|
|
249
279
|
marks: any;
|
|
250
280
|
'above-marks': any;
|
|
251
281
|
highlight: any;
|
|
282
|
+
legend: any;
|
|
252
283
|
tooltip: any;
|
|
253
284
|
};
|
|
254
285
|
}
|
|
@@ -4,6 +4,7 @@ import { format } from '@layerstack/utils';
|
|
|
4
4
|
import Arc from '../Arc.svelte';
|
|
5
5
|
import Chart from '../Chart.svelte';
|
|
6
6
|
import Group from '../Group.svelte';
|
|
7
|
+
import Legend from '../Legend.svelte';
|
|
7
8
|
import Pie from '../Pie.svelte';
|
|
8
9
|
import Svg from '../layout/Svg.svelte';
|
|
9
10
|
import * as Tooltip from '../tooltip/index.js';
|
|
@@ -18,6 +19,7 @@ $: valueAccessor = accessor(value);
|
|
|
18
19
|
/** Maximum possible value, useful when `data` is single item */
|
|
19
20
|
export let maxValue = undefined;
|
|
20
21
|
export let series = [{ key: 'default', value: value /*, color: 'hsl(var(--color-primary))'*/ }];
|
|
22
|
+
export let legend = false;
|
|
21
23
|
/**
|
|
22
24
|
* Range [min,max] in degrees. See also startAngle/endAngle
|
|
23
25
|
*/
|
|
@@ -59,6 +61,7 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
59
61
|
'hsl(var(--color-warning))',
|
|
60
62
|
'hsl(var(--color-danger))',
|
|
61
63
|
]}
|
|
64
|
+
padding={{ bottom: legend === true ? 32 : 0 }}
|
|
62
65
|
{...$$restProps}
|
|
63
66
|
let:x
|
|
64
67
|
let:xScale
|
|
@@ -95,6 +98,7 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
95
98
|
{tooltip}
|
|
96
99
|
data={d}
|
|
97
100
|
{...props.arc}
|
|
101
|
+
{...s.props}
|
|
98
102
|
/>
|
|
99
103
|
{:else}
|
|
100
104
|
<Pie
|
|
@@ -119,6 +123,7 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
119
123
|
data={arc.data}
|
|
120
124
|
{tooltip}
|
|
121
125
|
{...props.arc}
|
|
126
|
+
{...s.props}
|
|
122
127
|
/>
|
|
123
128
|
{/each}
|
|
124
129
|
</Pie>
|
|
@@ -130,6 +135,17 @@ $: seriesColors = series.map((s) => s.color).filter((d) => d != null);
|
|
|
130
135
|
<slot name="above-marks" {...slotProps} />
|
|
131
136
|
</Svg>
|
|
132
137
|
|
|
138
|
+
<slot name="legend" {...slotProps}>
|
|
139
|
+
{#if legend}
|
|
140
|
+
<Legend
|
|
141
|
+
placement="bottom"
|
|
142
|
+
variant="swatches"
|
|
143
|
+
{...props.legend}
|
|
144
|
+
{...typeof legend === 'object' ? legend : null}
|
|
145
|
+
/>
|
|
146
|
+
{/if}
|
|
147
|
+
</slot>
|
|
148
|
+
|
|
133
149
|
<slot name="tooltip" {...slotProps}>
|
|
134
150
|
<Tooltip.Root let:data>
|
|
135
151
|
<Tooltip.List>
|
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
import { type ComponentProps } from 'svelte';
|
|
3
3
|
import Arc from '../Arc.svelte';
|
|
4
4
|
import Group from '../Group.svelte';
|
|
5
|
+
import Legend from '../Legend.svelte';
|
|
5
6
|
import Pie from '../Pie.svelte';
|
|
6
7
|
import { type Accessor } from '../../utils/common.js';
|
|
7
8
|
declare class __sveltets_Render<TData> {
|
|
@@ -176,19 +177,42 @@ declare class __sveltets_Render<TData> {
|
|
|
176
177
|
}> | undefined;
|
|
177
178
|
transformContext?: import("..").TransformContext;
|
|
178
179
|
} & {
|
|
180
|
+
cornerRadius?: number;
|
|
181
|
+
innerRadius?: number | undefined;
|
|
179
182
|
label?: Accessor<TData>;
|
|
180
|
-
|
|
183
|
+
legend?: boolean | {
|
|
184
|
+
[x: string]: any;
|
|
185
|
+
scale?: any;
|
|
186
|
+
title?: string | undefined;
|
|
187
|
+
width?: number | undefined;
|
|
188
|
+
height?: number | undefined;
|
|
189
|
+
ticks?: number | undefined;
|
|
190
|
+
tickFormat?: import("@layerstack/utils").FormatType | undefined;
|
|
191
|
+
tickValues?: any[] | undefined;
|
|
192
|
+
tickFontSize?: number | undefined;
|
|
193
|
+
tickLength?: number | undefined;
|
|
194
|
+
placement?: ("left" | "right" | "center" | "bottom" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
195
|
+
orientation?: ("horizontal" | "vertical") | undefined;
|
|
196
|
+
variant?: ("ramp" | "swatches") | undefined;
|
|
197
|
+
classes?: {
|
|
198
|
+
root?: string;
|
|
199
|
+
title?: string;
|
|
200
|
+
label?: string;
|
|
201
|
+
tick?: string;
|
|
202
|
+
swatches?: string;
|
|
203
|
+
swatch?: string;
|
|
204
|
+
} | undefined;
|
|
205
|
+
};
|
|
181
206
|
maxValue?: number | undefined;
|
|
182
|
-
range?: number[];
|
|
183
|
-
innerRadius?: number | undefined;
|
|
184
207
|
outerRadius?: number | undefined;
|
|
185
|
-
cornerRadius?: number;
|
|
186
208
|
padAngle?: number;
|
|
187
209
|
props?: {
|
|
188
210
|
pie?: Partial<ComponentProps<Pie>>;
|
|
189
211
|
group?: Partial<ComponentProps<Group>>;
|
|
190
212
|
arc?: Partial<ComponentProps<Arc>>;
|
|
213
|
+
legend?: Partial<ComponentProps<Legend>>;
|
|
191
214
|
} | undefined;
|
|
215
|
+
range?: number[];
|
|
192
216
|
series?: {
|
|
193
217
|
key: string | number;
|
|
194
218
|
label?: string;
|
|
@@ -200,6 +224,7 @@ declare class __sveltets_Render<TData> {
|
|
|
200
224
|
color?: string;
|
|
201
225
|
props?: Partial<ComponentProps<Arc>>;
|
|
202
226
|
}[] | undefined;
|
|
227
|
+
value?: Accessor<TData>;
|
|
203
228
|
};
|
|
204
229
|
events(): {} & {
|
|
205
230
|
[evt: string]: CustomEvent<any>;
|
|
@@ -209,6 +234,7 @@ declare class __sveltets_Render<TData> {
|
|
|
209
234
|
'below-marks': any;
|
|
210
235
|
marks: any;
|
|
211
236
|
'above-marks': any;
|
|
237
|
+
legend: any;
|
|
212
238
|
tooltip: any;
|
|
213
239
|
};
|
|
214
240
|
}
|