@lionad/cx-comps-tanstack-charts 0.1.0-alpha.6 → 0.1.0-alpha.8
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/area/index.d.ts +26 -0
- package/dist/area/src/index.vue.d.ts +3 -0
- package/dist/bar/index.d.ts +26 -0
- package/dist/bar/src/index.vue.d.ts +3 -0
- package/dist/chart/index.d.ts +26 -0
- package/dist/chart/src/index.vue.d.ts +3 -0
- package/dist/dot/index.d.ts +26 -0
- package/dist/dot/src/index.vue.d.ts +3 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.mjs +17 -10
- package/dist/line/index.d.ts +26 -0
- package/dist/line/src/index.vue.d.ts +3 -0
- package/dist/pie/index.d.ts +26 -0
- package/dist/pie/src/index.vue.d.ts +3 -0
- package/dist/shared/chart-skeleton.vue.d.ts +8 -0
- package/dist/shared/curve-options.d.ts +9 -0
- package/dist/shared/streaming.d.ts +5 -0
- package/dist/shared/translate/axis.d.ts +9 -0
- package/dist/shared/translate/composite.d.ts +13 -0
- package/dist/shared/translate/curve.d.ts +18 -0
- package/dist/shared/translate/definition.d.ts +7 -0
- package/dist/shared/translate/index.d.ts +15 -0
- package/dist/shared/translate/mark.d.ts +14 -0
- package/dist/shared/translate/polar.d.ts +19 -0
- package/dist/shared/translate/scale.d.ts +8 -0
- package/dist/shared/translate/transforms.d.ts +11 -0
- package/dist/shared/translate/types.d.ts +469 -0
- package/dist/shared/use-chart-props.d.ts +32 -0
- package/dist/shared/use-pie-chart.d.ts +20 -0
- package/dist/shared/use-preset-chart.d.ts +25 -0
- package/dist/stream-triggers.d.ts +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
2
|
+
name: string;
|
|
3
|
+
getName?: (opts: {
|
|
4
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
5
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => string;
|
|
8
|
+
icon: string;
|
|
9
|
+
description: string;
|
|
10
|
+
key: string;
|
|
11
|
+
aliasKeys?: string | string[];
|
|
12
|
+
component: import("vue").Component;
|
|
13
|
+
headless?: boolean;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
16
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
17
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
18
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
19
|
+
url?: string;
|
|
20
|
+
umdExportsName?: string;
|
|
21
|
+
type?: "umd" | "esm" | "local";
|
|
22
|
+
rules?: {
|
|
23
|
+
edit: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
2
|
+
name: string;
|
|
3
|
+
getName?: (opts: {
|
|
4
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
5
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => string;
|
|
8
|
+
icon: string;
|
|
9
|
+
description: string;
|
|
10
|
+
key: string;
|
|
11
|
+
aliasKeys?: string | string[];
|
|
12
|
+
component: import("vue").Component;
|
|
13
|
+
headless?: boolean;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
16
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
17
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
18
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
19
|
+
url?: string;
|
|
20
|
+
umdExportsName?: string;
|
|
21
|
+
type?: "umd" | "esm" | "local";
|
|
22
|
+
rules?: {
|
|
23
|
+
edit: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
2
|
+
name: string;
|
|
3
|
+
getName?: (opts: {
|
|
4
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
5
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => string;
|
|
8
|
+
icon: string;
|
|
9
|
+
description: string;
|
|
10
|
+
key: string;
|
|
11
|
+
aliasKeys?: string | string[];
|
|
12
|
+
component: import("vue").Component;
|
|
13
|
+
headless?: boolean;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
16
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
17
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
18
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
19
|
+
url?: string;
|
|
20
|
+
umdExportsName?: string;
|
|
21
|
+
type?: "umd" | "esm" | "local";
|
|
22
|
+
rules?: {
|
|
23
|
+
edit: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
2
|
+
name: string;
|
|
3
|
+
getName?: (opts: {
|
|
4
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
5
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => string;
|
|
8
|
+
icon: string;
|
|
9
|
+
description: string;
|
|
10
|
+
key: string;
|
|
11
|
+
aliasKeys?: string | string[];
|
|
12
|
+
component: import("vue").Component;
|
|
13
|
+
headless?: boolean;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
16
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
17
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
18
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
19
|
+
url?: string;
|
|
20
|
+
umdExportsName?: string;
|
|
21
|
+
type?: "umd" | "esm" | "local";
|
|
22
|
+
rules?: {
|
|
23
|
+
edit: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CxMaterialBundle } from '@lionad/cx-definition';
|
|
2
|
+
export { default as CxTanstackChartsChart } from './chart';
|
|
3
|
+
export { default as CxTanstackChartsLine } from './line';
|
|
4
|
+
export { default as CxTanstackChartsBar } from './bar';
|
|
5
|
+
export { default as CxTanstackChartsArea } from './area';
|
|
6
|
+
export { default as CxTanstackChartsDot } from './dot';
|
|
7
|
+
export { default as CxTanstackChartsPie } from './pie';
|
|
8
|
+
export * from './shared/translate';
|
|
9
|
+
export { TANSTACK_CHARTS_STREAM_TRIGGERS, createTanstackChartsTriggerRegistry, mainArrayOf, } from './stream-triggers';
|
|
10
|
+
/** TanStack Charts 物料数组:通用 chart + 笛卡尔预设(line/bar/area/dot)+ 饼图 */
|
|
11
|
+
export declare const CxTanstackCharts: (import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
12
|
+
name: string;
|
|
13
|
+
getName?: (opts: {
|
|
14
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
15
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
}) => string;
|
|
18
|
+
icon: string;
|
|
19
|
+
description: string;
|
|
20
|
+
key: string;
|
|
21
|
+
aliasKeys?: string | string[];
|
|
22
|
+
component: import("vue").Component;
|
|
23
|
+
headless?: boolean;
|
|
24
|
+
async?: boolean;
|
|
25
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
26
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
27
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
28
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
29
|
+
url?: string;
|
|
30
|
+
umdExportsName?: string;
|
|
31
|
+
type?: "umd" | "esm" | "local";
|
|
32
|
+
rules?: {
|
|
33
|
+
edit: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
}>>)[];
|
|
36
|
+
/** TanStack Charts 物料 bundle:自描述单元,供装配方(cx-nuxt 等)按 bundle 装配 */
|
|
37
|
+
export declare const CxTanstackChartsBundle: CxMaterialBundle;
|
package/dist/index.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import { treemap } from "@tanstack/charts/hierarchy/treemap";
|
|
|
24
24
|
import { forceLayout } from "@tanstack/charts/network/force";
|
|
25
25
|
import { sankeyDiagram } from "@tanstack/charts/network/sankey";
|
|
26
26
|
import { geoAlbersUsa, geoEqualEarth, geoIdentity, geoMercator, geoNaturalEarth1, geoOrthographic } from "d3-geo";
|
|
27
|
+
import { tooltip } from "@tanstack/charts/tooltip";
|
|
27
28
|
import { compileTrigger, createTriggerRegistry } from "@lionad/cx-stream";
|
|
28
29
|
//#region src/shared/chart-skeleton.vue
|
|
29
30
|
const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
@@ -1145,10 +1146,15 @@ function translateLegend(legend) {
|
|
|
1145
1146
|
if (width !== void 0) items.width = width;
|
|
1146
1147
|
return colorLegend(items);
|
|
1147
1148
|
}
|
|
1148
|
-
/**
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1149
|
+
/**
|
|
1150
|
+
* tooltip 声明:false→关闭;true→默认 DOM extension;对象→extension + 标量子集。
|
|
1151
|
+
* 库层没有「缺省开启」——resolveTooltipInput 对 undefined 返回 null 即关闭,
|
|
1152
|
+
* 开启必须显式挂 extension(裸 extension 或 { use, ...options } 两形态);
|
|
1153
|
+
* 裸 options 对象会在 mount 时抛 TypeError(input.use 为 undefined)。
|
|
1154
|
+
*/
|
|
1155
|
+
function translateTooltip(tooltip$1) {
|
|
1156
|
+
if (tooltip$1 === false) return false;
|
|
1157
|
+
if (tooltip$1 === true) return tooltip;
|
|
1152
1158
|
const options = {};
|
|
1153
1159
|
for (const key of [
|
|
1154
1160
|
"placement",
|
|
@@ -1158,8 +1164,11 @@ function translateTooltip(tooltip) {
|
|
|
1158
1164
|
"anchor",
|
|
1159
1165
|
"sort",
|
|
1160
1166
|
"items"
|
|
1161
|
-
]) if (tooltip[key] !== void 0) options[key] = tooltip[key];
|
|
1162
|
-
return
|
|
1167
|
+
]) if (tooltip$1[key] !== void 0) options[key] = tooltip$1[key];
|
|
1168
|
+
return {
|
|
1169
|
+
use: tooltip,
|
|
1170
|
+
...options
|
|
1171
|
+
};
|
|
1163
1172
|
}
|
|
1164
1173
|
/**
|
|
1165
1174
|
* 时间轴 channel 纠偏:utc/time scale 要求 channel 值为 Date 实例,而 JSON spec 只能
|
|
@@ -1276,10 +1285,8 @@ function buildDefinition(spec, datasets, rowsOverride) {
|
|
|
1276
1285
|
if (spec.keyboard !== void 0) definition.keyboard = spec.keyboard;
|
|
1277
1286
|
if (spec.focusRing !== void 0) definition.focusRing = spec.focusRing;
|
|
1278
1287
|
if (spec.focus !== void 0) definition.focus = spec.focus;
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
if (tooltip !== void 0) definition.tooltip = tooltip;
|
|
1282
|
-
}
|
|
1288
|
+
const tooltip$2 = spec.tooltip === void 0 ? tooltip : translateTooltip(spec.tooltip);
|
|
1289
|
+
if (tooltip$2 !== void 0) definition.tooltip = tooltip$2;
|
|
1283
1290
|
return definition;
|
|
1284
1291
|
}
|
|
1285
1292
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
2
|
+
name: string;
|
|
3
|
+
getName?: (opts: {
|
|
4
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
5
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => string;
|
|
8
|
+
icon: string;
|
|
9
|
+
description: string;
|
|
10
|
+
key: string;
|
|
11
|
+
aliasKeys?: string | string[];
|
|
12
|
+
component: import("vue").Component;
|
|
13
|
+
headless?: boolean;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
16
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
17
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
18
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
19
|
+
url?: string;
|
|
20
|
+
umdExportsName?: string;
|
|
21
|
+
type?: "umd" | "esm" | "local";
|
|
22
|
+
rules?: {
|
|
23
|
+
edit: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").Component & import("@lionad/cx-definition").NormalizeKey<Required<{
|
|
2
|
+
name: string;
|
|
3
|
+
getName?: (opts: {
|
|
4
|
+
cx: import("@lionad/cx-definition").CxLoaderInstance;
|
|
5
|
+
comp: import("@lionad/cx-definition").CxComponentRuntime;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => string;
|
|
8
|
+
icon: string;
|
|
9
|
+
description: string;
|
|
10
|
+
key: string;
|
|
11
|
+
aliasKeys?: string | string[];
|
|
12
|
+
component: import("vue").Component;
|
|
13
|
+
headless?: boolean;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
props?: import("@lionad/cx-definition").CxComponentMetaProps;
|
|
16
|
+
emits?: import("@lionad/cx-definition").CxComponentMetaEmits;
|
|
17
|
+
exposes?: import("@lionad/cx-definition").CxComponentMetaExposes;
|
|
18
|
+
slots?: import("@lionad/cx-definition").CxComponentMetaSlots;
|
|
19
|
+
url?: string;
|
|
20
|
+
umdExportsName?: string;
|
|
21
|
+
type?: "umd" | "esm" | "local";
|
|
22
|
+
rules?: {
|
|
23
|
+
edit: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
height?: number;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
5
|
+
height: number;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChartAxisOptions } from '@tanstack/charts';
|
|
2
|
+
import type { CxChartAxisSpec } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* axis 声明式 → ChartAxisOptions;scale 缺省按轴位回退(x→point、y→linear)。
|
|
5
|
+
* undefined(含流式中间态:definition 开容器后 x/y 字段尚未传到)注入缺省 axis——
|
|
6
|
+
* 库对「mark 物化 channel 但 axis 无 scale 配置」抛错,缺席不等于无轴。
|
|
7
|
+
* null 原样保留(polar 等 scale 值为 never 的 definition 显式无轴)。
|
|
8
|
+
*/
|
|
9
|
+
export declare function translateAxis(spec: CxChartAxisSpec | null | undefined, fallbackKind: 'point' | 'linear'): ChartAxisOptions | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChartMark } from '@tanstack/charts';
|
|
2
|
+
import type { CxChartDatasets, CxChartMarkSpec, CxChartSpec } from './types';
|
|
3
|
+
/** 复合 type 守卫(definition 组装层据此分流;sunburst 虽属 polar 族约定,分发仍走此处) */
|
|
4
|
+
export declare const COMPOSITE_TYPES: ReadonlySet<string>;
|
|
5
|
+
/**
|
|
6
|
+
* 复合 mark 分发。tree/forceGraph 展开为多 mark;forceGraph 额外回传轴域推导结果。
|
|
7
|
+
* translateChild 仅 facet 需要。
|
|
8
|
+
*/
|
|
9
|
+
export declare function translateCompositeMark(spec: CxChartMarkSpec, datasets: CxChartDatasets | undefined, translateChild: (spec: CxChartSpec, rows: readonly unknown[]) => unknown): {
|
|
10
|
+
marks: ChartMark<unknown, any, any>[];
|
|
11
|
+
xDomain?: [number, number];
|
|
12
|
+
yDomain?: [number, number];
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChartCurve } from '@tanstack/charts';
|
|
2
|
+
import type { AreaXCurve } from '@tanstack/charts/area-x';
|
|
3
|
+
import type { CurveFactory } from 'd3-shape';
|
|
4
|
+
import type { CxChartCurveName } from './types';
|
|
5
|
+
/** curve 枚举白名单:预设物料组装 spec 前的运行时校验(JSON 输入不受 TS 约束) */
|
|
6
|
+
export declare const CX_CHART_CURVE_NAMES: CxChartCurveName[];
|
|
7
|
+
/** curve 枚举 → ChartCurve(line+area 函数对);未知枚举显式抛错(JSON 输入不受 TS 约束,运行时防御) */
|
|
8
|
+
export declare function translateCurve(name: CxChartCurveName): ChartCurve;
|
|
9
|
+
/**
|
|
10
|
+
* curve 枚举 → AreaXCurve:violinY 等水平展开面积 mark 的专用包装
|
|
11
|
+
* (ViolinYCurve = AreaXCurve,d3Curve 产物不提供 areaX 生成器)。
|
|
12
|
+
*/
|
|
13
|
+
export declare function translateAreaXCurve(name: CxChartCurveName): AreaXCurve;
|
|
14
|
+
/**
|
|
15
|
+
* curve 枚举 → 原生 d3 CurveFactory:polar radial 系(radialLine/radialArea)
|
|
16
|
+
* 的 curve 参数直接消费 d3 工厂而非 ChartCurve 包装(库签名实证 CurveFactory)。
|
|
17
|
+
*/
|
|
18
|
+
export declare function translateRadialCurve(name: CxChartCurveName): CurveFactory;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DomChartDefinition } from '@tanstack/charts';
|
|
2
|
+
import type { CxChartDatasets, CxChartSpec } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 声明式 spec → DomChartDefinition(物料渲染入口)。
|
|
5
|
+
* datasets:命名数据集表(数据顶层化契约),marks 内字符串引用在此解析。
|
|
6
|
+
*/
|
|
7
|
+
export declare function translateChartSpec(spec: CxChartSpec, datasets?: CxChartDatasets): DomChartDefinition;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 声明式 JSON → TanStack Charts 运行时定义的翻译层(桶文件)。
|
|
3
|
+
* 模块分工:types(声明式契约)/ curve / scale / axis / mark(基础+spatial)/
|
|
4
|
+
* transforms(数据预处理管道)/ polar(极坐标族)/ composite(七类命名复合)/
|
|
5
|
+
* definition(translateChartSpec 组装入口)。
|
|
6
|
+
*/
|
|
7
|
+
export type { CxChartAxisSpec, CxChartCurveName, CxChartDatasets, CxChartForceSpec, CxChartLayoutSpec, CxChartMarkSpec, CxChartMarkType, CxChartPolarGuideSpec, CxChartReduce, CxChartScaleSpec, CxChartSpec, CxChartTransformOutputs, CxChartTransformSpec, } from './types';
|
|
8
|
+
export { CX_CHART_CURVE_NAMES, translateCurve } from './curve';
|
|
9
|
+
export { translateScale } from './scale';
|
|
10
|
+
export { translateAxis } from './axis';
|
|
11
|
+
export { resolveMarkData, translateMark } from './mark';
|
|
12
|
+
export { applyTransforms, translateOutputs, translateReduce, translateTransform } from './transforms';
|
|
13
|
+
export { POLAR_FAMILY_TYPES, translatePie, translatePolar } from './polar';
|
|
14
|
+
export { COMPOSITE_TYPES, translateCompositeMark } from './composite';
|
|
15
|
+
export { translateChartSpec } from './definition';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ChartMark } from '@tanstack/charts';
|
|
2
|
+
import type { CxChartDatasets, CxChartMarkSpec } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* mark data 解析:字符串 → datasets 查表;数组原样透传。
|
|
5
|
+
* 未命中一律回退空数组——流式中间态(definition 先闭合、数据集在途;多数据集
|
|
6
|
+
* 部分到达)与 LLM 笔误在运行时不可区分,渲染层容错优先(与「渲染链路不过 zod,
|
|
7
|
+
* fallback 从简」契约一致);笔误显式化归生成期校验(spec 渲染断言门)。
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveMarkData(data: readonly unknown[] | string | undefined, datasets: CxChartDatasets | undefined): readonly unknown[];
|
|
10
|
+
/**
|
|
11
|
+
* 单 mark 声明式 → ChartMark;多余样式键对 mark 工厂无害(按名读取)。
|
|
12
|
+
* polar/pie/sankey 等容器与复合 type 不在此处(polar.ts / composite.ts 分支处理)。
|
|
13
|
+
*/
|
|
14
|
+
export declare function translateMark(spec: CxChartMarkSpec, datasets?: CxChartDatasets): ChartMark<unknown, any, any>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ChartMark } from '@tanstack/charts';
|
|
2
|
+
import type { CxChartDatasets, CxChartMarkSpec } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* polar 容器:{ type:'polar', marks:[radialXxx...], angleAxis, radiusAxis, radiusRatio,
|
|
5
|
+
* startAngle, endAngle, inset, polarGuides } → polar({...})。
|
|
6
|
+
* extraMarks:调用方预组装的 PolarMark(sunburst 等自包含层级 mark 不走 radial 直译)。
|
|
7
|
+
*/
|
|
8
|
+
export declare function translatePolar(spec: CxChartMarkSpec, datasets: CxChartDatasets | undefined, extraMarks?: readonly unknown[]): ChartMark<unknown, any, any>;
|
|
9
|
+
/**
|
|
10
|
+
* pie 命名复合:{ type:'pie', data, value, key, color, innerRadiusRatio, ... } →
|
|
11
|
+
* pie() 角度分配预处理 + polar(radialArc) 一体展开(donut = innerRadiusRatio > 0)。
|
|
12
|
+
* startAngle/endAngle/padAngle 并入 transform options(transform 侧字段名 gapAngle;
|
|
13
|
+
* 容器层同名字段只作用于 angle scale 映射,radialArc 直接读 datum 弧度——
|
|
14
|
+
* 不传 transform 则声明静默失效)。返回 polar 容器 mark,definition 层按 polar 族
|
|
15
|
+
* 约定处理无轴(见 definition.ts)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function translatePie(spec: CxChartMarkSpec, datasets: CxChartDatasets | undefined): ChartMark<unknown, any, any>;
|
|
18
|
+
/** polar 族 type 判定(definition 组装层据此应用无轴约定) */
|
|
19
|
+
export declare const POLAR_FAMILY_TYPES: ReadonlySet<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CxChartScaleSpec } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* scale 声明式 → ChartScaleInput。
|
|
4
|
+
* 无 domain 时返回工厂形态(库从 marks channel 推断 domain);
|
|
5
|
+
* 有 domain 时返回实例(保留配置,库不再推断)。
|
|
6
|
+
* 时间系(utc/time)domain 为 ISO 8601 字符串,翻译为 Date 实例(JSON 不可表达 Date)。
|
|
7
|
+
*/
|
|
8
|
+
export declare function translateScale(spec: CxChartScaleSpec): unknown;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CxChartDatasets, CxChartReduce, CxChartTransformOutputs, CxChartTransformSpec } from './types';
|
|
2
|
+
/** reduce 声明式 → 库归约器;字符串枚举 count/sum/mean/min/max 原样透传,其余映射函数引用 */
|
|
3
|
+
export declare function translateReduce(reduce: CxChartReduce): unknown;
|
|
4
|
+
export declare function translateOutputs(outputs: CxChartTransformOutputs): Record<string, unknown>;
|
|
5
|
+
/** 单步 transform → 行数组;源数据经 data 名查 datasets 表(缺省 rows,未命中回退空数组) */
|
|
6
|
+
export declare function translateTransform(spec: CxChartTransformSpec, datasets: CxChartDatasets): readonly unknown[];
|
|
7
|
+
/**
|
|
8
|
+
* 执行 transforms 管道:产物以 name 注册进 datasets 副本(不污染调用方表;
|
|
9
|
+
* 源数据集引用未命中时回退空数组——与 resolveMarkData 同一容错语义)。
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyTransforms(transforms: readonly CxChartTransformSpec[], datasets: CxChartDatasets): CxChartDatasets;
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import type { ChartTheme } from '@tanstack/charts';
|
|
2
|
+
/**
|
|
3
|
+
* 声明式 JSON 类型:物料 data 的投影形态。
|
|
4
|
+
*
|
|
5
|
+
* Why 存在:defineChart 的 definition 含三类不可 JSON 化值——scale(函数工厂/实例)、
|
|
6
|
+
* curve(ChartCurve 函数对)、回调(format/accessor/tooltip content)。cx 物料 data 必须
|
|
7
|
+
* 纯 JSON,本模块把声明式描述(kind 枚举、curve 枚举、字段名 channel、标量子集)约束为
|
|
8
|
+
* 可 JSON 化形态,由翻译层编译为运行时实例。channel 仅支持字段名字符串:低代码与
|
|
9
|
+
* LLM 生成场景不要求 accessor 函数(accessor 逻辑经数据预置烘焙降级)。
|
|
10
|
+
*/
|
|
11
|
+
export type CxChartCurveName = 'linear' | 'linearClosed' | 'monotoneX' | 'step' | 'stepAfter' | 'stepBefore' | 'basis' | 'natural' | 'catmullRom';
|
|
12
|
+
/**
|
|
13
|
+
* scale 声明式枚举。时间系(utc/time)domain 用 ISO 8601 字符串表达
|
|
14
|
+
* (Date 实例 JSON 不可表达,翻译层负责 new Date 转换)。
|
|
15
|
+
*/
|
|
16
|
+
export type CxChartScaleSpec = {
|
|
17
|
+
kind: 'linear';
|
|
18
|
+
domain?: [number, number];
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'utc' | 'time';
|
|
21
|
+
domain?: [string, string];
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'log' | 'sqrt' | 'symlog';
|
|
24
|
+
domain?: [number, number];
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'pow';
|
|
27
|
+
exponent?: number;
|
|
28
|
+
domain?: [number, number];
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'point';
|
|
31
|
+
domain?: string[];
|
|
32
|
+
padding?: number;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'band';
|
|
35
|
+
domain?: string[];
|
|
36
|
+
padding?: number;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'ordinal';
|
|
39
|
+
domain?: string[];
|
|
40
|
+
};
|
|
41
|
+
export interface CxChartAxisSpec {
|
|
42
|
+
scale?: CxChartScaleSpec;
|
|
43
|
+
nice?: boolean | number;
|
|
44
|
+
reverse?: boolean;
|
|
45
|
+
grid?: boolean;
|
|
46
|
+
axis?: false | {
|
|
47
|
+
label?: string;
|
|
48
|
+
ticks?: {
|
|
49
|
+
count?: number;
|
|
50
|
+
size?: number;
|
|
51
|
+
padding?: number;
|
|
52
|
+
values?: (number | string)[];
|
|
53
|
+
};
|
|
54
|
+
tickLabels?: false | {
|
|
55
|
+
rotate?: number;
|
|
56
|
+
fontSize?: number;
|
|
57
|
+
dx?: number;
|
|
58
|
+
dy?: number;
|
|
59
|
+
anchor?: 'start' | 'middle' | 'end';
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* mark layout 声明式(stack/group/dodge 挂 mark.layout 字段;
|
|
65
|
+
* group 的 scale 函数形态不可 JSON,仅暴露 padding)。
|
|
66
|
+
*/
|
|
67
|
+
export type CxChartLayoutSpec = {
|
|
68
|
+
kind: 'stack';
|
|
69
|
+
order?: 'input' | 'ascending' | 'descending' | 'inside-out' | string[];
|
|
70
|
+
offset?: 'diverging' | 'normalize' | 'center' | 'wiggle';
|
|
71
|
+
reverse?: boolean;
|
|
72
|
+
anchor?: {
|
|
73
|
+
series: string;
|
|
74
|
+
fraction?: number;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'group';
|
|
78
|
+
padding?: number;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'dodgeX';
|
|
81
|
+
anchor?: 'left' | 'middle' | 'right';
|
|
82
|
+
padding?: number;
|
|
83
|
+
} | {
|
|
84
|
+
kind: 'dodgeY';
|
|
85
|
+
anchor?: 'bottom' | 'middle' | 'top';
|
|
86
|
+
padding?: number;
|
|
87
|
+
};
|
|
88
|
+
export type CxChartMarkType = 'lineY' | 'lineX' | 'areaY' | 'areaX' | 'barY' | 'barX' | 'ruleY' | 'ruleX' | 'dot' | 'text' | 'tickX' | 'tickY' | 'bandY' | 'bandX' | 'rect' | 'cell' | 'link' | 'arrow' | 'vector' | 'hexagon' | 'frame' | 'boxY' | 'boxX' | 'violinY' | 'violinX' | 'ridgelineY' | 'ridgelineX' | 'waffleY' | 'waffleX' | 'differenceY' | 'differenceX' | 'linearRegressionY' | 'linearRegressionX' | 'voronoi' | 'hexbin' | 'contour' | 'delaunayLink' | 'density' | 'polar' | 'pie' | 'radialArc' | 'radialBarRadius' | 'radialBarAngle' | 'radialLine' | 'radialArea' | 'radialDot' | 'radialText' | 'radialRule' | 'sankey' | 'sunburst' | 'treemap' | 'tree' | 'forceGraph' | 'geoShape' | 'facet';
|
|
89
|
+
/**
|
|
90
|
+
* 单 mark 声明式。平铺契约(LLM 友好):专有标量字段全部可选、按名透传,
|
|
91
|
+
* 不适用的字段被对应工厂忽略;channel 只接受字段名字符串(弹性 channel
|
|
92
|
+
* angle/radius/width/height/length/rotate/r 另接受数值常量)。
|
|
93
|
+
*/
|
|
94
|
+
export interface CxChartMarkSpec {
|
|
95
|
+
type: CxChartMarkType;
|
|
96
|
+
/**
|
|
97
|
+
* 行数组(内嵌,常量数组亦可)或命名数据集字符串引用。
|
|
98
|
+
* 字符串引用由 translateChartSpec 的 datasets 表解析——GenUI 契约是数据顶层化
|
|
99
|
+
* (data.rows 与 definition 平级),marks 内以 "rows" 引用;未命中一律回退空数组
|
|
100
|
+
* (流式中间态与笔误运行时不可区分,渲染层容错优先,笔误显式化归生成期校验门)。
|
|
101
|
+
*/
|
|
102
|
+
data?: readonly unknown[] | string;
|
|
103
|
+
id?: string;
|
|
104
|
+
x?: string;
|
|
105
|
+
y?: string;
|
|
106
|
+
x1?: string;
|
|
107
|
+
y1?: string;
|
|
108
|
+
x2?: string;
|
|
109
|
+
y2?: string;
|
|
110
|
+
z?: string;
|
|
111
|
+
color?: string;
|
|
112
|
+
key?: string;
|
|
113
|
+
text?: string;
|
|
114
|
+
r?: string | number;
|
|
115
|
+
angle?: string | number;
|
|
116
|
+
radius?: string | number;
|
|
117
|
+
width?: string | number;
|
|
118
|
+
height?: string | number;
|
|
119
|
+
length?: string | number;
|
|
120
|
+
rotate?: string | number;
|
|
121
|
+
stroke?: string;
|
|
122
|
+
strokeWidth?: number;
|
|
123
|
+
strokeOpacity?: number;
|
|
124
|
+
strokeDasharray?: string;
|
|
125
|
+
fill?: string;
|
|
126
|
+
fillOpacity?: number;
|
|
127
|
+
fontSize?: number;
|
|
128
|
+
fontWeight?: number;
|
|
129
|
+
dx?: number;
|
|
130
|
+
dy?: number;
|
|
131
|
+
points?: boolean;
|
|
132
|
+
opacity?: number;
|
|
133
|
+
curve?: CxChartCurveName;
|
|
134
|
+
layout?: CxChartLayoutSpec;
|
|
135
|
+
span?: number;
|
|
136
|
+
overlap?: number;
|
|
137
|
+
unit?: number;
|
|
138
|
+
round?: boolean;
|
|
139
|
+
gap?: number;
|
|
140
|
+
columns?: number;
|
|
141
|
+
headLength?: number;
|
|
142
|
+
headAngle?: number;
|
|
143
|
+
lineCap?: 'butt' | 'round' | 'square';
|
|
144
|
+
anchor?: 'start' | 'middle' | 'end';
|
|
145
|
+
ci?: number;
|
|
146
|
+
samples?: number;
|
|
147
|
+
positiveFill?: string;
|
|
148
|
+
negativeFill?: string;
|
|
149
|
+
positiveFillOpacity?: number;
|
|
150
|
+
negativeFillOpacity?: number;
|
|
151
|
+
comparisonStroke?: string;
|
|
152
|
+
cornerRadius?: number;
|
|
153
|
+
padAngle?: number;
|
|
154
|
+
radiusOffset?: number;
|
|
155
|
+
/** radial 系径向起止(radialRule 引导线/指针、radialBarRadius/radialArea 内径端):字段名或数值常量 */
|
|
156
|
+
radius1?: string | number;
|
|
157
|
+
radius2?: string | number;
|
|
158
|
+
/** radialBarAngle 弧段角度起止(显式堆叠弧段):字段名或数值常量 */
|
|
159
|
+
angle1?: string | number;
|
|
160
|
+
angle2?: string | number;
|
|
161
|
+
baseline?: 'auto' | 'middle' | 'hanging';
|
|
162
|
+
inset?: number;
|
|
163
|
+
/** hexbin 相邻 bin 中心水平像素距 */
|
|
164
|
+
binWidth?: number;
|
|
165
|
+
/** hexbin 聚合输出(reduce 枚举同 transforms) */
|
|
166
|
+
outputs?: CxChartTransformOutputs;
|
|
167
|
+
/** contour 等值线层数或精确层级(标量网格字段复用通用 value channel);density 同字段表达密度层级 */
|
|
168
|
+
thresholds?: number | number[];
|
|
169
|
+
/** contour 线性插值平滑(缺省 true) */
|
|
170
|
+
smooth?: boolean;
|
|
171
|
+
/** density 高斯核带宽(CSS 像素,库缺省 20) */
|
|
172
|
+
bandwidth?: number;
|
|
173
|
+
/** density 密度网格单元尺寸(CSS 像素,库缺省 4) */
|
|
174
|
+
cellSize?: number;
|
|
175
|
+
marks?: CxChartMarkSpec[];
|
|
176
|
+
radiusRatio?: number;
|
|
177
|
+
startAngle?: number;
|
|
178
|
+
endAngle?: number;
|
|
179
|
+
angleAxis?: CxChartAxisSpec;
|
|
180
|
+
radiusAxis?: CxChartAxisSpec;
|
|
181
|
+
polarGuides?: CxChartPolarGuideSpec[];
|
|
182
|
+
innerRadiusRatio?: number;
|
|
183
|
+
outerRadiusRatio?: number;
|
|
184
|
+
value?: string;
|
|
185
|
+
path?: string;
|
|
186
|
+
delimiter?: string;
|
|
187
|
+
nodeId?: string;
|
|
188
|
+
parentId?: string;
|
|
189
|
+
nodes?: string;
|
|
190
|
+
links?: string;
|
|
191
|
+
nodeKey?: string;
|
|
192
|
+
source?: string;
|
|
193
|
+
target?: string;
|
|
194
|
+
/** sankey 稳定连线标识字段 */
|
|
195
|
+
linkKey?: string;
|
|
196
|
+
/** forceGraph 仿真参数与力集(缺省固化常规四力:link/manyBody/center/collide) */
|
|
197
|
+
domainPadding?: number;
|
|
198
|
+
forces?: CxChartForceSpec[];
|
|
199
|
+
align?: 'left' | 'right' | 'center' | 'justify';
|
|
200
|
+
nodeWidth?: number;
|
|
201
|
+
nodePadding?: number;
|
|
202
|
+
iterations?: number;
|
|
203
|
+
method?: 'squarify' | 'binary' | 'dice' | 'slice' | 'slice-dice';
|
|
204
|
+
ratio?: number;
|
|
205
|
+
paddingInner?: number;
|
|
206
|
+
paddingOuter?: number;
|
|
207
|
+
/** treemap 叶子标签字段名(string);facet 分组标签开关(boolean)——按 mark type 分别消费 */
|
|
208
|
+
label?: string | boolean;
|
|
209
|
+
labelPadding?: number;
|
|
210
|
+
labelFontSize?: number;
|
|
211
|
+
labelFontWeight?: number;
|
|
212
|
+
orientation?: 'left' | 'right' | 'top' | 'bottom';
|
|
213
|
+
nodeSize?: [number, number];
|
|
214
|
+
projection?: 'mercator' | 'orthographic' | 'naturalEarth1' | 'albersUsa' | 'equalEarth' | 'identity';
|
|
215
|
+
fit?: 'data' | 'sphere';
|
|
216
|
+
by?: string;
|
|
217
|
+
axes?: 'outer' | 'cell';
|
|
218
|
+
minWidth?: number;
|
|
219
|
+
chart?: CxChartSpec;
|
|
220
|
+
visibleDepth?: number;
|
|
221
|
+
ringPadding?: number;
|
|
222
|
+
}
|
|
223
|
+
/** polar guides(radialGrid/angleGrid)声明式 */
|
|
224
|
+
export interface CxChartPolarGuideSpec {
|
|
225
|
+
kind: 'radialGrid' | 'angleGrid';
|
|
226
|
+
values?: (number | string)[];
|
|
227
|
+
ticks?: number;
|
|
228
|
+
shape?: 'circle' | 'polygon';
|
|
229
|
+
labels?: boolean;
|
|
230
|
+
labelAngle?: number;
|
|
231
|
+
labelOffset?: number;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* forceGraph 力集声明式:库 ForceDescriptor 的 JSON 子集。
|
|
235
|
+
* 数值参数接受字段名字符串(库 ForceNumericValue 支持 TransformValue);
|
|
236
|
+
* custom 工厂形态不可 JSON,不收录。
|
|
237
|
+
*/
|
|
238
|
+
export type CxChartForceSpec = {
|
|
239
|
+
type: 'link';
|
|
240
|
+
distance?: number | string;
|
|
241
|
+
strength?: number | string;
|
|
242
|
+
} | {
|
|
243
|
+
type: 'manyBody';
|
|
244
|
+
strength?: number | string;
|
|
245
|
+
} | {
|
|
246
|
+
type: 'center';
|
|
247
|
+
x?: number;
|
|
248
|
+
y?: number;
|
|
249
|
+
} | {
|
|
250
|
+
type: 'collide';
|
|
251
|
+
radius?: number | string;
|
|
252
|
+
strength?: number;
|
|
253
|
+
} | {
|
|
254
|
+
type: 'x';
|
|
255
|
+
x?: number | string;
|
|
256
|
+
strength?: number | string;
|
|
257
|
+
} | {
|
|
258
|
+
type: 'y';
|
|
259
|
+
y?: number | string;
|
|
260
|
+
strength?: number | string;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* reduce 枚举(outputs 归约器):字符串枚举全可 JSON;
|
|
264
|
+
* quantile 带参数用对象形态 { quantile: 0.25 }。
|
|
265
|
+
*/
|
|
266
|
+
export type CxChartReduce = 'count' | 'sum' | 'mean' | 'min' | 'max' | 'median' | 'first' | 'last' | 'variance' | 'deviation' | 'delta' | 'ratio' | {
|
|
267
|
+
quantile: number;
|
|
268
|
+
};
|
|
269
|
+
export interface CxChartTransformOutputs {
|
|
270
|
+
[name: string]: {
|
|
271
|
+
value?: string;
|
|
272
|
+
reduce: CxChartReduce;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* 数据预处理管道:spec 顶层 transforms 数组,按序执行,
|
|
277
|
+
* 每步产物以 name 注册进数据集表(marks/transforms 后续步骤可字符串引用)。
|
|
278
|
+
* data 缺省引用 'rows'。binTime 系不收录(interval 对象 JSON 不可表达——时间分箱由
|
|
279
|
+
* 数据预置聚合降级)。
|
|
280
|
+
*/
|
|
281
|
+
export type CxChartTransformSpec = {
|
|
282
|
+
name: string;
|
|
283
|
+
kind: 'groupBy';
|
|
284
|
+
data?: string;
|
|
285
|
+
by: string | Record<string, string>;
|
|
286
|
+
outputs: CxChartTransformOutputs;
|
|
287
|
+
} | {
|
|
288
|
+
name: string;
|
|
289
|
+
kind: 'binX' | 'binY';
|
|
290
|
+
data?: string;
|
|
291
|
+
value: string;
|
|
292
|
+
by?: string | Record<string, string>;
|
|
293
|
+
thresholds?: number | number[];
|
|
294
|
+
domain?: [number, number];
|
|
295
|
+
outputs?: CxChartTransformOutputs;
|
|
296
|
+
} | {
|
|
297
|
+
name: string;
|
|
298
|
+
kind: 'binXY';
|
|
299
|
+
data?: string;
|
|
300
|
+
x: string;
|
|
301
|
+
y: string;
|
|
302
|
+
by?: string | Record<string, string>;
|
|
303
|
+
xThresholds?: number | number[];
|
|
304
|
+
yThresholds?: number | number[];
|
|
305
|
+
xDomain?: [number, number];
|
|
306
|
+
yDomain?: [number, number];
|
|
307
|
+
outputs?: CxChartTransformOutputs;
|
|
308
|
+
} | {
|
|
309
|
+
name: string;
|
|
310
|
+
kind: 'rollingWindow';
|
|
311
|
+
data?: string;
|
|
312
|
+
size: number;
|
|
313
|
+
by?: string | Record<string, string>;
|
|
314
|
+
anchor?: 'start' | 'middle' | 'end';
|
|
315
|
+
partial?: boolean;
|
|
316
|
+
outputs: CxChartTransformOutputs;
|
|
317
|
+
orderBy?: string;
|
|
318
|
+
order?: 'ascending' | 'descending';
|
|
319
|
+
} | {
|
|
320
|
+
name: string;
|
|
321
|
+
kind: 'normalize';
|
|
322
|
+
data?: string;
|
|
323
|
+
value: string;
|
|
324
|
+
by?: string | Record<string, string>;
|
|
325
|
+
as?: string;
|
|
326
|
+
basis?: 'sum' | 'max' | 'extent' | 'first' | 'last';
|
|
327
|
+
} | {
|
|
328
|
+
name: string;
|
|
329
|
+
kind: 'cumulative';
|
|
330
|
+
data?: string;
|
|
331
|
+
by?: string | Record<string, string>;
|
|
332
|
+
outputs: CxChartTransformOutputs;
|
|
333
|
+
orderBy?: string;
|
|
334
|
+
order?: 'ascending' | 'descending';
|
|
335
|
+
} | {
|
|
336
|
+
name: string;
|
|
337
|
+
kind: 'fold';
|
|
338
|
+
data?: string;
|
|
339
|
+
fields: string[];
|
|
340
|
+
as?: {
|
|
341
|
+
key: string;
|
|
342
|
+
value: string;
|
|
343
|
+
};
|
|
344
|
+
} | {
|
|
345
|
+
name: string;
|
|
346
|
+
kind: 'rank';
|
|
347
|
+
data?: string;
|
|
348
|
+
value: string;
|
|
349
|
+
by?: string | Record<string, string>;
|
|
350
|
+
order?: 'ascending' | 'descending';
|
|
351
|
+
ties?: 'competition' | 'dense' | 'ordinal';
|
|
352
|
+
as?: string;
|
|
353
|
+
} | {
|
|
354
|
+
name: string;
|
|
355
|
+
kind: 'select';
|
|
356
|
+
data?: string;
|
|
357
|
+
by?: string | Record<string, string>;
|
|
358
|
+
value?: string;
|
|
359
|
+
select: 'first' | 'last' | 'min' | 'max';
|
|
360
|
+
} | {
|
|
361
|
+
name: string;
|
|
362
|
+
kind: 'stackRowsY' | 'stackRowsX';
|
|
363
|
+
data?: string;
|
|
364
|
+
x: string;
|
|
365
|
+
y: string;
|
|
366
|
+
z?: string;
|
|
367
|
+
order?: 'input' | 'ascending' | 'descending' | 'inside-out' | string[];
|
|
368
|
+
offset?: 'diverging' | 'normalize' | 'center' | 'wiggle';
|
|
369
|
+
reverse?: boolean;
|
|
370
|
+
anchor?: {
|
|
371
|
+
series: string;
|
|
372
|
+
fraction?: number;
|
|
373
|
+
};
|
|
374
|
+
} | {
|
|
375
|
+
name: string;
|
|
376
|
+
kind: 'waterfall';
|
|
377
|
+
data?: string;
|
|
378
|
+
value: string;
|
|
379
|
+
by?: string | Record<string, string>;
|
|
380
|
+
total?: boolean;
|
|
381
|
+
orderBy?: string;
|
|
382
|
+
order?: 'ascending' | 'descending';
|
|
383
|
+
} | {
|
|
384
|
+
name: string;
|
|
385
|
+
kind: 'mosaicY' | 'mosaicX';
|
|
386
|
+
data?: string;
|
|
387
|
+
x: string;
|
|
388
|
+
y: string;
|
|
389
|
+
value: string;
|
|
390
|
+
xOrder?: (string | number)[];
|
|
391
|
+
yOrder?: (string | number)[];
|
|
392
|
+
} | {
|
|
393
|
+
name: string;
|
|
394
|
+
kind: 'linearRegressionRowsY' | 'linearRegressionRowsX';
|
|
395
|
+
data?: string;
|
|
396
|
+
x: string;
|
|
397
|
+
y: string;
|
|
398
|
+
z?: string;
|
|
399
|
+
ci?: number;
|
|
400
|
+
samples?: number;
|
|
401
|
+
} | {
|
|
402
|
+
name: string;
|
|
403
|
+
kind: 'boxRows';
|
|
404
|
+
data?: string;
|
|
405
|
+
category: string;
|
|
406
|
+
value: string;
|
|
407
|
+
} | {
|
|
408
|
+
name: string;
|
|
409
|
+
kind: 'pie';
|
|
410
|
+
data?: string;
|
|
411
|
+
value: string;
|
|
412
|
+
/** CX 统一 padAngle 命名(transform 侧字段为 gapAngle,翻译层映射) */
|
|
413
|
+
padAngle?: number;
|
|
414
|
+
startAngle?: number;
|
|
415
|
+
endAngle?: number;
|
|
416
|
+
};
|
|
417
|
+
/** 命名数据集表:物料 data 顶层除 definition 外的数组字段(GenUI 契约 rows/nodes/links) */
|
|
418
|
+
export type CxChartDatasets = Record<string, readonly unknown[] | undefined>;
|
|
419
|
+
export interface CxChartSpec {
|
|
420
|
+
marks: CxChartMarkSpec[];
|
|
421
|
+
x?: CxChartAxisSpec | null;
|
|
422
|
+
y?: CxChartAxisSpec | null;
|
|
423
|
+
theme?: Partial<ChartTheme>;
|
|
424
|
+
margin?: number | {
|
|
425
|
+
top?: number;
|
|
426
|
+
right?: number;
|
|
427
|
+
bottom?: number;
|
|
428
|
+
left?: number;
|
|
429
|
+
};
|
|
430
|
+
guides?: boolean;
|
|
431
|
+
clip?: boolean;
|
|
432
|
+
/** 数据预处理管道(顶层声明,marks 之前执行;产物注册进 datasets 表) */
|
|
433
|
+
transforms?: CxChartTransformSpec[];
|
|
434
|
+
/** color scale 声明式(domain/range 直可 JSON;legend 为图例声明) */
|
|
435
|
+
color?: {
|
|
436
|
+
domain?: (string | number)[];
|
|
437
|
+
range?: string[];
|
|
438
|
+
legend?: true | {
|
|
439
|
+
kind?: 'color' | 'gradient';
|
|
440
|
+
label?: string;
|
|
441
|
+
placement?: 'top' | 'bottom';
|
|
442
|
+
itemWidth?: number;
|
|
443
|
+
steps?: number;
|
|
444
|
+
width?: number;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
tooltip?: boolean | {
|
|
448
|
+
placement?: 'auto' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left' | 'top-left' | ('top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left' | 'top-left')[];
|
|
449
|
+
offset?: number;
|
|
450
|
+
sticky?: boolean;
|
|
451
|
+
visibility?: 'focus' | 'pinned';
|
|
452
|
+
anchor?: 'point' | 'pointer' | 'group-center' | {
|
|
453
|
+
x?: 'point' | 'pointer' | 'value' | 'group-center' | 'plot-left' | 'plot-center' | 'plot-right';
|
|
454
|
+
y?: 'point' | 'pointer' | 'value' | 'group-center' | 'plot-top' | 'plot-center' | 'plot-bottom';
|
|
455
|
+
};
|
|
456
|
+
sort?: 'visual' | 'color-domain' | 'focus';
|
|
457
|
+
items?: ('x' | 'y' | 'group' | {
|
|
458
|
+
channel: 'x' | 'y' | 'group';
|
|
459
|
+
label?: string;
|
|
460
|
+
} | {
|
|
461
|
+
field: string;
|
|
462
|
+
label?: string;
|
|
463
|
+
})[];
|
|
464
|
+
};
|
|
465
|
+
pointer?: boolean;
|
|
466
|
+
keyboard?: boolean;
|
|
467
|
+
focusRing?: boolean;
|
|
468
|
+
focus?: 'nearest' | 'nearest-x' | 'nearest-y' | 'group-x' | 'group-y';
|
|
469
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { CxChartDatasets, CxChartSpec } from './translate';
|
|
3
|
+
export interface CxChartHostPartition {
|
|
4
|
+
/** <Chart> 宿主 props(标量白名单 + class/style) */
|
|
5
|
+
hostProps: ComputedRef<Record<string, unknown>>;
|
|
6
|
+
/** Chart 必填 ariaLabel,独立绑定(v-bind 对象无法向模板类型检查证明 required 键在场) */
|
|
7
|
+
ariaLabel: ComputedRef<string>;
|
|
8
|
+
}
|
|
9
|
+
export interface CxChartPropsPartition extends CxChartHostPartition {
|
|
10
|
+
/** 物料 JSON definition(声明式 spec,待翻译层组装) */
|
|
11
|
+
spec: ComputedRef<CxChartSpec>;
|
|
12
|
+
/** 命名数据集表(rows/nodes/links 白名单分馏;marks 字符串引用在此解析) */
|
|
13
|
+
datasets: ComputedRef<CxChartDatasets>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 分馏 <Chart> 宿主 props:标量白名单 + class/style + ariaLabel 回退。
|
|
17
|
+
*
|
|
18
|
+
* 剥离 cx 内部键(comp 运行时节点、data-* 编辑标记、_ 前缀编辑器键),与 vtu/EP 桥接同形。
|
|
19
|
+
* class/style 保留进 hostProps(cx 编辑器样式类落到 Chart 根宿主 div)。
|
|
20
|
+
* ariaLabel 是 Chart 必填 prop,缺省回退物料中文名;它与 hostProps 分开返回,
|
|
21
|
+
* 由包装层显式绑定,否则模板类型检查把 v-bind 的 Record 当作 required 键缺席。
|
|
22
|
+
* 预设物料与通用 chart 共用本函数——差异只在 spec 来源(definition 键 vs 通道组装)。
|
|
23
|
+
*/
|
|
24
|
+
export declare function useChartHostProps(attrs: Record<string, unknown>): CxChartHostPartition;
|
|
25
|
+
/**
|
|
26
|
+
* 通用 chart 物料的分馏:definition 键 → spec,外加宿主 props。
|
|
27
|
+
*
|
|
28
|
+
* definition 键从透传集中分馏——Chart 组件的 definition prop 只接受运行时产物,
|
|
29
|
+
* 物料侧的 JSON spec 须经翻译层组装后由包装层显式绑定,不能随 v-bind 原样透传。
|
|
30
|
+
* 返回独立 computed 而非整体 ref:包装层分别绑定,避免解构丢响应性。
|
|
31
|
+
*/
|
|
32
|
+
export declare function useChartProps(attrs: Record<string, unknown>): CxChartPropsPartition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DomChartDefinition } from '@tanstack/charts';
|
|
2
|
+
import type { ComputedRef } from 'vue';
|
|
3
|
+
import type { CxChartHostPartition } from './use-chart-props';
|
|
4
|
+
export interface CxPieChartPartition extends CxChartHostPartition {
|
|
5
|
+
/** pie 变换 + polar(radialArc) 组装的运行时 definition */
|
|
6
|
+
definition: ComputedRef<DomChartDefinition>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 饼图物料的 definition 组装:扁平通道 props(data/name/value/innerRadiusRatio)
|
|
10
|
+
* → pie() 角度分配 → polar(radialArc) 扇区弧。
|
|
11
|
+
*
|
|
12
|
+
* 与笛卡尔预设的翻译层路径不同:pie 涉及运行时函数(pie 变换、innerRadius 比例函数),
|
|
13
|
+
* 属 JSON 不可表达值的物料侧桥接,故在物料内直接组装、不经 CxChartSpec 声明式投影。
|
|
14
|
+
*
|
|
15
|
+
* 鲁棒性(JSON 输入不受 TS 约束):
|
|
16
|
+
* - 负值/非数值行在 pie 前过滤——pie 对负值显式抛 TypeError,不过滤会炸整棵渲染树;
|
|
17
|
+
* - innerRadiusRatio 钳制 [0, 0.95]——1.0 完全空心渲染不可见,属无效配置而非有效极端;
|
|
18
|
+
* - name/value 字段缺席回退 'name'/'value'(与笛卡尔预设的回退策略同形)。
|
|
19
|
+
*/
|
|
20
|
+
export declare function usePieChart(attrs: Record<string, unknown>): CxPieChartPartition;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { CxChartHostPartition } from './use-chart-props';
|
|
3
|
+
import type { CxChartMarkType, CxChartScaleSpec, CxChartSpec } from './translate';
|
|
4
|
+
export interface CxPresetChartOptions {
|
|
5
|
+
/** 预设 mark 类型(lineY/barY/areaY/dot 等笛卡尔单通道 mark) */
|
|
6
|
+
markType: CxChartMarkType;
|
|
7
|
+
/** x 轴 scale kind(序列类用 point/band,数值散点用 linear) */
|
|
8
|
+
xScale: CxChartScaleSpec['kind'];
|
|
9
|
+
/** 是否消费 curve 通道(line/area 支持,bar/dot 忽略) */
|
|
10
|
+
withCurve?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CxPresetChartPartition extends CxChartHostPartition {
|
|
13
|
+
/** 由通道 props(data/x/y/curve)组装的声明式 spec */
|
|
14
|
+
spec: ComputedRef<CxChartSpec>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 预设物料的 spec 组装:把扁平通道 props(data 行数组 + x/y 字段名 + curve 枚举)
|
|
18
|
+
* 投影为单 mark 的 CxChartSpec,与通用 chart 物料共用翻译层与宿主 props 分馏。
|
|
19
|
+
*
|
|
20
|
+
* 通道缺席回退固定字段名(x→'x'、y→'y')而非省略:translateMark 对非字符串 channel
|
|
21
|
+
* 显式抛错,流式中间态/编辑器清空场景下回退保证规格恒可翻译;data 缺席回退空数组
|
|
22
|
+
* (mark 渲染为空而非抛错)。meta.props 的 initial 三元组(data 行键/x 值/y 值)
|
|
23
|
+
* 必须自洽——initial 不参与运行时校验,漂移无任何报错(vtu 既有教训)。
|
|
24
|
+
*/
|
|
25
|
+
export declare function usePresetChart(attrs: Record<string, unknown>, options: CxPresetChartOptions): CxPresetChartPartition;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CxSpec, StreamTriggerConfig, TriggerRegistry } from '@lionad/cx-stream';
|
|
2
|
+
export declare const TANSTACK_CHARTS_STREAM_TRIGGERS: StreamTriggerConfig[];
|
|
3
|
+
/** 装配 TanStack Charts 物料的 trigger 注册表(size 恒 6) */
|
|
4
|
+
export declare function createTanstackChartsTriggerRegistry(): TriggerRegistry<CxSpec>;
|
|
5
|
+
/** 增量节点的主数组(回放计数展示用);非数组增长型物料或数组缺席时返回 null */
|
|
6
|
+
export declare function mainArrayOf(node: {
|
|
7
|
+
key: string;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
}): unknown[] | null;
|