@loidolt/theme-charts 0.7.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/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/components/BarChart.svelte +64 -0
- package/dist/components/BarChart.svelte.d.ts +14 -0
- package/dist/components/CandlestickChart.svelte +58 -0
- package/dist/components/CandlestickChart.svelte.d.ts +21 -0
- package/dist/components/Chart.svelte +282 -0
- package/dist/components/Chart.svelte.d.ts +73 -0
- package/dist/components/ChartDataTable.svelte +79 -0
- package/dist/components/ChartDataTable.svelte.d.ts +23 -0
- package/dist/components/FunnelChart.svelte +50 -0
- package/dist/components/FunnelChart.svelte.d.ts +18 -0
- package/dist/components/GaugeChart.svelte +54 -0
- package/dist/components/GaugeChart.svelte.d.ts +18 -0
- package/dist/components/HeatmapChart.svelte +51 -0
- package/dist/components/HeatmapChart.svelte.d.ts +14 -0
- package/dist/components/LineChart.svelte +66 -0
- package/dist/components/LineChart.svelte.d.ts +14 -0
- package/dist/components/PieChart.svelte +62 -0
- package/dist/components/PieChart.svelte.d.ts +18 -0
- package/dist/components/RadarChart.svelte +48 -0
- package/dist/components/RadarChart.svelte.d.ts +14 -0
- package/dist/components/SankeyChart.svelte +48 -0
- package/dist/components/SankeyChart.svelte.d.ts +18 -0
- package/dist/components/ScatterChart.svelte +61 -0
- package/dist/components/ScatterChart.svelte.d.ts +18 -0
- package/dist/components/TreemapChart.svelte +48 -0
- package/dist/components/TreemapChart.svelte.d.ts +17 -0
- package/dist/core/builders/category.d.ts +37 -0
- package/dist/core/builders/category.js +109 -0
- package/dist/core/builders/more.d.ts +119 -0
- package/dist/core/builders/more.js +530 -0
- package/dist/core/builders/slices.d.ts +36 -0
- package/dist/core/builders/slices.js +117 -0
- package/dist/core/describe.d.ts +27 -0
- package/dist/core/describe.js +69 -0
- package/dist/core/format.d.ts +15 -0
- package/dist/core/format.js +39 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.js +12 -0
- package/dist/core/theme.d.ts +30 -0
- package/dist/core/theme.js +137 -0
- package/dist/core/types.d.ts +98 -0
- package/dist/core/types.js +1 -0
- package/dist/core/validate.d.ts +4 -0
- package/dist/core/validate.js +10 -0
- package/dist/echarts/all.d.ts +3 -0
- package/dist/echarts/all.js +23 -0
- package/dist/echarts/bar.d.ts +3 -0
- package/dist/echarts/bar.js +2 -0
- package/dist/echarts/base.d.ts +3 -0
- package/dist/echarts/base.js +13 -0
- package/dist/echarts/candlestick.d.ts +3 -0
- package/dist/echarts/candlestick.js +3 -0
- package/dist/echarts/funnel.d.ts +3 -0
- package/dist/echarts/funnel.js +2 -0
- package/dist/echarts/gauge.d.ts +3 -0
- package/dist/echarts/gauge.js +2 -0
- package/dist/echarts/heatmap.d.ts +3 -0
- package/dist/echarts/heatmap.js +3 -0
- package/dist/echarts/line.d.ts +3 -0
- package/dist/echarts/line.js +2 -0
- package/dist/echarts/pie.d.ts +3 -0
- package/dist/echarts/pie.js +2 -0
- package/dist/echarts/radar.d.ts +3 -0
- package/dist/echarts/radar.js +3 -0
- package/dist/echarts/sankey.d.ts +3 -0
- package/dist/echarts/sankey.js +2 -0
- package/dist/echarts/scatter.d.ts +3 -0
- package/dist/echarts/scatter.js +2 -0
- package/dist/echarts/treemap.d.ts +3 -0
- package/dist/echarts/treemap.js +2 -0
- package/dist/echarts.d.ts +22 -0
- package/dist/echarts.js +24 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/package.json +67 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { Table, cx } from '@loidolt/theme-svelte';
|
|
4
|
+
import { formatNumber, type FormatOptions } from '../core/format.js';
|
|
5
|
+
import type { ChartCell, ChartTable } from '../core/types.js';
|
|
6
|
+
|
|
7
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
/** The rows and columns, as the chart builders' `…Table()` helpers return them. */
|
|
9
|
+
table: ChartTable;
|
|
10
|
+
/** Names the table, usually the chart's title. */
|
|
11
|
+
caption: string;
|
|
12
|
+
/**
|
|
13
|
+
* Present the table to assistive tech only. A chart's default: the picture is for the eye,
|
|
14
|
+
* the table for everyone else, and neither gets in the other's way.
|
|
15
|
+
*/
|
|
16
|
+
visuallyHidden?: boolean;
|
|
17
|
+
/** How numbers are written. */
|
|
18
|
+
valueFormat?: FormatOptions;
|
|
19
|
+
/** Written in empty cells. */
|
|
20
|
+
emptyCell?: string;
|
|
21
|
+
class?: string;
|
|
22
|
+
ref?: HTMLDivElement | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
table,
|
|
27
|
+
caption,
|
|
28
|
+
visuallyHidden = false,
|
|
29
|
+
valueFormat,
|
|
30
|
+
emptyCell = '—',
|
|
31
|
+
class: className,
|
|
32
|
+
ref = $bindable(null),
|
|
33
|
+
...rest
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const cell = (value: ChartCell) =>
|
|
37
|
+
value == null
|
|
38
|
+
? emptyCell
|
|
39
|
+
: typeof value === 'number'
|
|
40
|
+
? formatNumber(value, valueFormat)
|
|
41
|
+
: value;
|
|
42
|
+
const align = (value: ChartCell) => (typeof value === 'number' ? 'end' : undefined);
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
{#snippet contents()}
|
|
46
|
+
<thead>
|
|
47
|
+
<tr>
|
|
48
|
+
{#each table.columns as column, index (index)}
|
|
49
|
+
<th scope="col">{column}</th>
|
|
50
|
+
{/each}
|
|
51
|
+
</tr>
|
|
52
|
+
</thead>
|
|
53
|
+
<tbody>
|
|
54
|
+
{#each table.rows as row, rowIndex (rowIndex)}
|
|
55
|
+
<tr>
|
|
56
|
+
{#each row as value, index (index)}
|
|
57
|
+
{#if index === 0}
|
|
58
|
+
<th scope="row" data-align={align(value)}>{cell(value)}</th>
|
|
59
|
+
{:else}
|
|
60
|
+
<td data-align={align(value)}>{cell(value)}</td>
|
|
61
|
+
{/if}
|
|
62
|
+
{/each}
|
|
63
|
+
</tr>
|
|
64
|
+
{/each}
|
|
65
|
+
</tbody>
|
|
66
|
+
{/snippet}
|
|
67
|
+
|
|
68
|
+
<div bind:this={ref} class={cx('ldt-chart-table', className)} {...rest}>
|
|
69
|
+
{#if visuallyHidden}
|
|
70
|
+
<!-- Not the scrolling `Table`: a focusable region nobody can see would trap sighted
|
|
71
|
+
keyboard users on an invisible stop. -->
|
|
72
|
+
<table class="ldt-sr-only">
|
|
73
|
+
<caption>{caption}</caption>
|
|
74
|
+
{@render contents()}
|
|
75
|
+
</table>
|
|
76
|
+
{:else}
|
|
77
|
+
<Table {caption}>{@render contents()}</Table>
|
|
78
|
+
{/if}
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import { type FormatOptions } from '../core/format.js';
|
|
3
|
+
import type { ChartTable } from '../core/types.js';
|
|
4
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/** The rows and columns, as the chart builders' `…Table()` helpers return them. */
|
|
6
|
+
table: ChartTable;
|
|
7
|
+
/** Names the table, usually the chart's title. */
|
|
8
|
+
caption: string;
|
|
9
|
+
/**
|
|
10
|
+
* Present the table to assistive tech only. A chart's default: the picture is for the eye,
|
|
11
|
+
* the table for everyone else, and neither gets in the other's way.
|
|
12
|
+
*/
|
|
13
|
+
visuallyHidden?: boolean;
|
|
14
|
+
/** How numbers are written. */
|
|
15
|
+
valueFormat?: FormatOptions;
|
|
16
|
+
/** Written in empty cells. */
|
|
17
|
+
emptyCell?: string;
|
|
18
|
+
class?: string;
|
|
19
|
+
ref?: HTMLDivElement | null;
|
|
20
|
+
}
|
|
21
|
+
declare const ChartDataTable: import("svelte").Component<Props, {}, "ref">;
|
|
22
|
+
type ChartDataTable = ReturnType<typeof ChartDataTable>;
|
|
23
|
+
export default ChartDataTable;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildFunnelOption,
|
|
5
|
+
describeFunnel,
|
|
6
|
+
sliceTable,
|
|
7
|
+
type FunnelOptions,
|
|
8
|
+
} from '../core/builders/slices.js';
|
|
9
|
+
import type { SliceDatum } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, FunnelOptions {
|
|
15
|
+
/** The stages, in order. */
|
|
16
|
+
data: SliceDatum[];
|
|
17
|
+
/** Headings of the data table columns. */
|
|
18
|
+
tableLabels?: { nameLabel?: string; valueLabel?: string; shareLabel?: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
sort,
|
|
24
|
+
orientation,
|
|
25
|
+
showLabels,
|
|
26
|
+
showTooltip,
|
|
27
|
+
valueFormat,
|
|
28
|
+
tableLabels = {},
|
|
29
|
+
description,
|
|
30
|
+
empty,
|
|
31
|
+
instance = $bindable(null),
|
|
32
|
+
ref = $bindable(null),
|
|
33
|
+
...rest
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const options = $derived({ sort, orientation, showLabels, showTooltip, valueFormat });
|
|
37
|
+
const extensions = () => import('../echarts/funnel.js').then((module) => module.default);
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<Chart
|
|
41
|
+
bind:instance
|
|
42
|
+
bind:ref
|
|
43
|
+
option={(colors) => buildFunnelOption(data, options, colors)}
|
|
44
|
+
table={sliceTable(data, tableLabels)}
|
|
45
|
+
description={description ?? describeFunnel(data, valueFormat)}
|
|
46
|
+
empty={empty ?? data.length === 0}
|
|
47
|
+
{extensions}
|
|
48
|
+
tableFormat={valueFormat}
|
|
49
|
+
{...rest}
|
|
50
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type FunnelOptions } from '../core/builders/slices.js';
|
|
3
|
+
import type { SliceDatum } from '../core/types.js';
|
|
4
|
+
import Chart from './Chart.svelte';
|
|
5
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
6
|
+
interface Props extends ChartProps, FunnelOptions {
|
|
7
|
+
/** The stages, in order. */
|
|
8
|
+
data: SliceDatum[];
|
|
9
|
+
/** Headings of the data table columns. */
|
|
10
|
+
tableLabels?: {
|
|
11
|
+
nameLabel?: string;
|
|
12
|
+
valueLabel?: string;
|
|
13
|
+
shareLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare const FunnelChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
17
|
+
type FunnelChart = ReturnType<typeof FunnelChart>;
|
|
18
|
+
export default FunnelChart;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildGaugeOption,
|
|
5
|
+
describeGauge,
|
|
6
|
+
gaugeTable,
|
|
7
|
+
type GaugeOptions,
|
|
8
|
+
type GaugeData,
|
|
9
|
+
} from '../core/builders/more.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, GaugeOptions {
|
|
15
|
+
/** The reading, and the scale it sits on (0–100 unless given). */
|
|
16
|
+
data: GaugeData;
|
|
17
|
+
/** Headings of the data table columns. */
|
|
18
|
+
tableLabels?: {
|
|
19
|
+
readingLabel?: string;
|
|
20
|
+
valueLabel?: string;
|
|
21
|
+
minLabel?: string;
|
|
22
|
+
maxLabel?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
data,
|
|
28
|
+
splitNumber,
|
|
29
|
+
showProgress,
|
|
30
|
+
valueFormat,
|
|
31
|
+
label,
|
|
32
|
+
tableLabels = {},
|
|
33
|
+
description,
|
|
34
|
+
empty,
|
|
35
|
+
instance = $bindable(null),
|
|
36
|
+
ref = $bindable(null),
|
|
37
|
+
...rest
|
|
38
|
+
}: Props = $props();
|
|
39
|
+
|
|
40
|
+
const options = $derived({ splitNumber, showProgress, valueFormat, label });
|
|
41
|
+
const extensions = () => import('../echarts/gauge.js').then((module) => module.default);
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<Chart
|
|
45
|
+
bind:instance
|
|
46
|
+
bind:ref
|
|
47
|
+
option={(colors) => buildGaugeOption(data, options, colors)}
|
|
48
|
+
table={gaugeTable(data, tableLabels)}
|
|
49
|
+
description={description ?? describeGauge(data, valueFormat)}
|
|
50
|
+
{empty}
|
|
51
|
+
{extensions}
|
|
52
|
+
tableFormat={valueFormat}
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type GaugeOptions, type GaugeData } from '../core/builders/more.js';
|
|
3
|
+
import Chart from './Chart.svelte';
|
|
4
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
5
|
+
interface Props extends ChartProps, GaugeOptions {
|
|
6
|
+
/** The reading, and the scale it sits on (0–100 unless given). */
|
|
7
|
+
data: GaugeData;
|
|
8
|
+
/** Headings of the data table columns. */
|
|
9
|
+
tableLabels?: {
|
|
10
|
+
readingLabel?: string;
|
|
11
|
+
valueLabel?: string;
|
|
12
|
+
minLabel?: string;
|
|
13
|
+
maxLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare const GaugeChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
17
|
+
type GaugeChart = ReturnType<typeof GaugeChart>;
|
|
18
|
+
export default GaugeChart;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildHeatmapOption,
|
|
5
|
+
describeHeatmap,
|
|
6
|
+
heatmapTable,
|
|
7
|
+
type HeatmapOptions,
|
|
8
|
+
} from '../core/builders/more.js';
|
|
9
|
+
import type { HeatmapData } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, HeatmapOptions {
|
|
15
|
+
/** Column and row labels, and the value in each cell. */
|
|
16
|
+
data: HeatmapData;
|
|
17
|
+
/** Heading of the data table's first column, which holds the row labels. */
|
|
18
|
+
cornerLabel?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
showValues,
|
|
24
|
+
showTooltip,
|
|
25
|
+
showScale,
|
|
26
|
+
valueFormat,
|
|
27
|
+
min,
|
|
28
|
+
max,
|
|
29
|
+
cornerLabel = 'Row',
|
|
30
|
+
description,
|
|
31
|
+
empty,
|
|
32
|
+
instance = $bindable(null),
|
|
33
|
+
ref = $bindable(null),
|
|
34
|
+
...rest
|
|
35
|
+
}: Props = $props();
|
|
36
|
+
|
|
37
|
+
const options = $derived({ showValues, showTooltip, showScale, valueFormat, min, max });
|
|
38
|
+
const extensions = () => import('../echarts/heatmap.js').then((module) => module.default);
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<Chart
|
|
42
|
+
bind:instance
|
|
43
|
+
bind:ref
|
|
44
|
+
option={(colors) => buildHeatmapOption(data, options, colors)}
|
|
45
|
+
table={heatmapTable(data, cornerLabel)}
|
|
46
|
+
description={description ?? describeHeatmap(data, valueFormat)}
|
|
47
|
+
empty={empty ?? data.values.length === 0}
|
|
48
|
+
{extensions}
|
|
49
|
+
tableFormat={valueFormat}
|
|
50
|
+
{...rest}
|
|
51
|
+
/>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type HeatmapOptions } from '../core/builders/more.js';
|
|
3
|
+
import type { HeatmapData } from '../core/types.js';
|
|
4
|
+
import Chart from './Chart.svelte';
|
|
5
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
6
|
+
interface Props extends ChartProps, HeatmapOptions {
|
|
7
|
+
/** Column and row labels, and the value in each cell. */
|
|
8
|
+
data: HeatmapData;
|
|
9
|
+
/** Heading of the data table's first column, which holds the row labels. */
|
|
10
|
+
cornerLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const HeatmapChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
13
|
+
type HeatmapChart = ReturnType<typeof HeatmapChart>;
|
|
14
|
+
export default HeatmapChart;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildLineOption,
|
|
5
|
+
describeLine,
|
|
6
|
+
categoryTable,
|
|
7
|
+
type LineOptions,
|
|
8
|
+
} from '../core/builders/category.js';
|
|
9
|
+
import type { CategoryData } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, LineOptions {
|
|
15
|
+
/** Categories along the x axis and a series of values for each. */
|
|
16
|
+
data: CategoryData;
|
|
17
|
+
/** Heading of the first column in the data table. */
|
|
18
|
+
categoryLabel?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
area,
|
|
24
|
+
smooth,
|
|
25
|
+
stacked,
|
|
26
|
+
showPoints,
|
|
27
|
+
showLegend,
|
|
28
|
+
showTooltip,
|
|
29
|
+
showGrid,
|
|
30
|
+
valueFormat,
|
|
31
|
+
categoryAxisName,
|
|
32
|
+
valueAxisName,
|
|
33
|
+
categoryLabel = 'Category',
|
|
34
|
+
description,
|
|
35
|
+
empty,
|
|
36
|
+
instance = $bindable(null),
|
|
37
|
+
ref = $bindable(null),
|
|
38
|
+
...rest
|
|
39
|
+
}: Props = $props();
|
|
40
|
+
|
|
41
|
+
const options = $derived({
|
|
42
|
+
area,
|
|
43
|
+
smooth,
|
|
44
|
+
stacked,
|
|
45
|
+
showPoints,
|
|
46
|
+
showLegend,
|
|
47
|
+
showTooltip,
|
|
48
|
+
showGrid,
|
|
49
|
+
valueFormat,
|
|
50
|
+
categoryAxisName,
|
|
51
|
+
valueAxisName,
|
|
52
|
+
});
|
|
53
|
+
const extensions = () => import('../echarts/line.js').then((module) => module.default);
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<Chart
|
|
57
|
+
bind:instance
|
|
58
|
+
bind:ref
|
|
59
|
+
option={(colors) => buildLineOption(data, options, colors)}
|
|
60
|
+
table={categoryTable(data, categoryLabel)}
|
|
61
|
+
description={description ?? describeLine(data, valueFormat)}
|
|
62
|
+
empty={empty ?? (data.series.length === 0 || data.categories.length === 0)}
|
|
63
|
+
{extensions}
|
|
64
|
+
tableFormat={valueFormat}
|
|
65
|
+
{...rest}
|
|
66
|
+
/>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type LineOptions } from '../core/builders/category.js';
|
|
3
|
+
import type { CategoryData } from '../core/types.js';
|
|
4
|
+
import Chart from './Chart.svelte';
|
|
5
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
6
|
+
interface Props extends ChartProps, LineOptions {
|
|
7
|
+
/** Categories along the x axis and a series of values for each. */
|
|
8
|
+
data: CategoryData;
|
|
9
|
+
/** Heading of the first column in the data table. */
|
|
10
|
+
categoryLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const LineChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
13
|
+
type LineChart = ReturnType<typeof LineChart>;
|
|
14
|
+
export default LineChart;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildPieOption,
|
|
5
|
+
describePie,
|
|
6
|
+
sliceTable,
|
|
7
|
+
type PieOptions,
|
|
8
|
+
} from '../core/builders/slices.js';
|
|
9
|
+
import type { SliceDatum } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, PieOptions {
|
|
15
|
+
/** The parts of the whole, one slice each. */
|
|
16
|
+
data: SliceDatum[];
|
|
17
|
+
/** Headings of the data table columns. */
|
|
18
|
+
tableLabels?: { nameLabel?: string; valueLabel?: string; shareLabel?: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
innerRadius,
|
|
24
|
+
showLabels,
|
|
25
|
+
labelPosition,
|
|
26
|
+
showLegend,
|
|
27
|
+
showTooltip,
|
|
28
|
+
centerValue,
|
|
29
|
+
centerLabel,
|
|
30
|
+
valueFormat,
|
|
31
|
+
tableLabels = {},
|
|
32
|
+
description,
|
|
33
|
+
empty,
|
|
34
|
+
instance = $bindable(null),
|
|
35
|
+
ref = $bindable(null),
|
|
36
|
+
...rest
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
|
|
39
|
+
const options = $derived({
|
|
40
|
+
innerRadius,
|
|
41
|
+
showLabels,
|
|
42
|
+
labelPosition,
|
|
43
|
+
showLegend,
|
|
44
|
+
showTooltip,
|
|
45
|
+
centerValue,
|
|
46
|
+
centerLabel,
|
|
47
|
+
valueFormat,
|
|
48
|
+
});
|
|
49
|
+
const extensions = () => import('../echarts/pie.js').then((module) => module.default);
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Chart
|
|
53
|
+
bind:instance
|
|
54
|
+
bind:ref
|
|
55
|
+
option={(colors) => buildPieOption(data, options, colors)}
|
|
56
|
+
table={sliceTable(data, tableLabels)}
|
|
57
|
+
description={description ?? describePie(data, valueFormat)}
|
|
58
|
+
empty={empty ?? (data.length === 0 || data.every((slice) => slice.value === 0))}
|
|
59
|
+
{extensions}
|
|
60
|
+
tableFormat={valueFormat}
|
|
61
|
+
{...rest}
|
|
62
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type PieOptions } from '../core/builders/slices.js';
|
|
3
|
+
import type { SliceDatum } from '../core/types.js';
|
|
4
|
+
import Chart from './Chart.svelte';
|
|
5
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
6
|
+
interface Props extends ChartProps, PieOptions {
|
|
7
|
+
/** The parts of the whole, one slice each. */
|
|
8
|
+
data: SliceDatum[];
|
|
9
|
+
/** Headings of the data table columns. */
|
|
10
|
+
tableLabels?: {
|
|
11
|
+
nameLabel?: string;
|
|
12
|
+
valueLabel?: string;
|
|
13
|
+
shareLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare const PieChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
17
|
+
type PieChart = ReturnType<typeof PieChart>;
|
|
18
|
+
export default PieChart;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildRadarOption,
|
|
5
|
+
describeRadar,
|
|
6
|
+
radarTable,
|
|
7
|
+
type RadarOptions,
|
|
8
|
+
} from '../core/builders/more.js';
|
|
9
|
+
import type { RadarData } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, RadarOptions {
|
|
15
|
+
/** The spokes, and each series' value on every spoke. */
|
|
16
|
+
data: RadarData;
|
|
17
|
+
/** Heading of the first column in the data table. */
|
|
18
|
+
indicatorLabel?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
shape,
|
|
24
|
+
area,
|
|
25
|
+
showLegend,
|
|
26
|
+
showTooltip,
|
|
27
|
+
indicatorLabel = 'Measure',
|
|
28
|
+
description,
|
|
29
|
+
empty,
|
|
30
|
+
instance = $bindable(null),
|
|
31
|
+
ref = $bindable(null),
|
|
32
|
+
...rest
|
|
33
|
+
}: Props = $props();
|
|
34
|
+
|
|
35
|
+
const options = $derived({ shape, area, showLegend, showTooltip });
|
|
36
|
+
const extensions = () => import('../echarts/radar.js').then((module) => module.default);
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<Chart
|
|
40
|
+
bind:instance
|
|
41
|
+
bind:ref
|
|
42
|
+
option={(colors) => buildRadarOption(data, options, colors)}
|
|
43
|
+
table={radarTable(data, indicatorLabel)}
|
|
44
|
+
description={description ?? describeRadar(data)}
|
|
45
|
+
empty={empty ?? (data.series.length === 0 || data.indicators.length === 0)}
|
|
46
|
+
{extensions}
|
|
47
|
+
{...rest}
|
|
48
|
+
/>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type RadarOptions } from '../core/builders/more.js';
|
|
3
|
+
import type { RadarData } from '../core/types.js';
|
|
4
|
+
import Chart from './Chart.svelte';
|
|
5
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
6
|
+
interface Props extends ChartProps, RadarOptions {
|
|
7
|
+
/** The spokes, and each series' value on every spoke. */
|
|
8
|
+
data: RadarData;
|
|
9
|
+
/** Heading of the first column in the data table. */
|
|
10
|
+
indicatorLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const RadarChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
13
|
+
type RadarChart = ReturnType<typeof RadarChart>;
|
|
14
|
+
export default RadarChart;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildSankeyOption,
|
|
5
|
+
describeSankey,
|
|
6
|
+
sankeyTable,
|
|
7
|
+
type SankeyOptions,
|
|
8
|
+
} from '../core/builders/more.js';
|
|
9
|
+
import type { SankeyData } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, SankeyOptions {
|
|
15
|
+
/** Named nodes and the flows between them. */
|
|
16
|
+
data: SankeyData;
|
|
17
|
+
/** Headings of the data table columns. */
|
|
18
|
+
tableLabels?: { sourceLabel?: string; targetLabel?: string; valueLabel?: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
orientation,
|
|
24
|
+
showTooltip,
|
|
25
|
+
valueFormat,
|
|
26
|
+
tableLabels = {},
|
|
27
|
+
description,
|
|
28
|
+
empty,
|
|
29
|
+
instance = $bindable(null),
|
|
30
|
+
ref = $bindable(null),
|
|
31
|
+
...rest
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
|
|
34
|
+
const options = $derived({ orientation, showTooltip, valueFormat });
|
|
35
|
+
const extensions = () => import('../echarts/sankey.js').then((module) => module.default);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<Chart
|
|
39
|
+
bind:instance
|
|
40
|
+
bind:ref
|
|
41
|
+
option={(colors) => buildSankeyOption(data, options, colors)}
|
|
42
|
+
table={sankeyTable(data, tableLabels)}
|
|
43
|
+
description={description ?? describeSankey(data, valueFormat)}
|
|
44
|
+
empty={empty ?? data.links.length === 0}
|
|
45
|
+
{extensions}
|
|
46
|
+
tableFormat={valueFormat}
|
|
47
|
+
{...rest}
|
|
48
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { type SankeyOptions } from '../core/builders/more.js';
|
|
3
|
+
import type { SankeyData } from '../core/types.js';
|
|
4
|
+
import Chart from './Chart.svelte';
|
|
5
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
6
|
+
interface Props extends ChartProps, SankeyOptions {
|
|
7
|
+
/** Named nodes and the flows between them. */
|
|
8
|
+
data: SankeyData;
|
|
9
|
+
/** Headings of the data table columns. */
|
|
10
|
+
tableLabels?: {
|
|
11
|
+
sourceLabel?: string;
|
|
12
|
+
targetLabel?: string;
|
|
13
|
+
valueLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare const SankeyChart: import("svelte").Component<Props, {}, "ref" | "instance">;
|
|
17
|
+
type SankeyChart = ReturnType<typeof SankeyChart>;
|
|
18
|
+
export default SankeyChart;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
buildScatterOption,
|
|
5
|
+
describeScatter,
|
|
6
|
+
scatterTable,
|
|
7
|
+
type ScatterOptions,
|
|
8
|
+
} from '../core/builders/more.js';
|
|
9
|
+
import type { ScatterSeries } from '../core/types.js';
|
|
10
|
+
import Chart from './Chart.svelte';
|
|
11
|
+
|
|
12
|
+
type ChartProps = Omit<ComponentProps<typeof Chart>, 'option' | 'table' | 'extensions'>;
|
|
13
|
+
|
|
14
|
+
interface Props extends ChartProps, ScatterOptions {
|
|
15
|
+
/** One or more series of `[x, y]` points. */
|
|
16
|
+
data: ScatterSeries[];
|
|
17
|
+
/** Headings of the data table columns. */
|
|
18
|
+
tableLabels?: { seriesLabel?: string; xLabel?: string; yLabel?: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
showTrendLine,
|
|
24
|
+
symbolSize,
|
|
25
|
+
showLegend,
|
|
26
|
+
showTooltip,
|
|
27
|
+
xAxisName,
|
|
28
|
+
yAxisName,
|
|
29
|
+
xFormat,
|
|
30
|
+
yFormat,
|
|
31
|
+
tableLabels = {},
|
|
32
|
+
description,
|
|
33
|
+
empty,
|
|
34
|
+
instance = $bindable(null),
|
|
35
|
+
ref = $bindable(null),
|
|
36
|
+
...rest
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
|
|
39
|
+
const options = $derived({
|
|
40
|
+
showTrendLine,
|
|
41
|
+
symbolSize,
|
|
42
|
+
showLegend,
|
|
43
|
+
showTooltip,
|
|
44
|
+
xAxisName,
|
|
45
|
+
yAxisName,
|
|
46
|
+
xFormat,
|
|
47
|
+
yFormat,
|
|
48
|
+
});
|
|
49
|
+
const extensions = () => import('../echarts/scatter.js').then((module) => module.default);
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Chart
|
|
53
|
+
bind:instance
|
|
54
|
+
bind:ref
|
|
55
|
+
option={(colors) => buildScatterOption(data, options, colors)}
|
|
56
|
+
table={scatterTable(data, tableLabels)}
|
|
57
|
+
description={description ?? describeScatter(data)}
|
|
58
|
+
empty={empty ?? data.every((series) => series.data.length === 0)}
|
|
59
|
+
{extensions}
|
|
60
|
+
{...rest}
|
|
61
|
+
/>
|