@lionad/cx-comps-tanstack-charts 0.1.0-alpha.29 → 0.1.0-alpha.31
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/index.mjs
CHANGED
|
@@ -404,9 +404,9 @@ function translateAxis(spec, fallbackKind) {
|
|
|
404
404
|
//#region src/shared/translate/geometry.ts
|
|
405
405
|
/**
|
|
406
406
|
* 占位几何检测:LLM 在数据集缺席时可能产出 geometry 为占位字符串的示意 spec
|
|
407
|
-
* (如 "…(命名数据集)…"
|
|
408
|
-
*
|
|
409
|
-
*
|
|
407
|
+
* (如 "…(命名数据集)…"),或只引用不提供数据集(resolveMarkData 回退空数组)。
|
|
408
|
+
* 翻译层与渲染层对这些形态容错回退,占位字符串则被库静默忽略——都渲染为空壳
|
|
409
|
+
* svg 且无任何反馈。本模块提供「渲染必然空壳」的判定与翻译期警告,让空壳显式化。
|
|
410
410
|
*
|
|
411
411
|
* 流式安全性:占位字符串只可能出现在完整闭合的 JSON 中(流式截断停在字符层,
|
|
412
412
|
* 截断帧不可解析即不会产出 spec),检测不存在流式中间态误报面。
|
|
@@ -428,16 +428,31 @@ function isPlaceholderGeometryDataset(rows) {
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
431
|
+
* 组件层空态判定:整图渲染必然空壳时为 true。
|
|
432
|
+
*
|
|
433
|
+
* 判定范围收敛在纯 geoShape 图(全部 marks 均为 geoShape):geoShape 无独立于数据
|
|
434
|
+
* 的渲染力(数据不可用即零图元),而其余 mark 类型总有独立形状;复合图只要存在
|
|
435
|
+
* 一个非 geoShape mark 或一个可用 geo 数据集就返回 false,防「部分可渲染却整体
|
|
436
|
+
* 空态」的误杀。覆盖三种不可用形态:
|
|
437
|
+
* - 命名数据集占位(geometry 占位字符串/全 null)
|
|
438
|
+
* - 命名数据集缺失(只引用不提供,resolveMarkData 回退空数组)
|
|
439
|
+
* - mark 内联 data 数组本身占位(不占命名数据集表的形态)
|
|
433
440
|
*/
|
|
434
|
-
function
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
441
|
+
function isPlaceholderChartRender(spec, datasets) {
|
|
442
|
+
const marks = spec?.marks;
|
|
443
|
+
if (!marks?.length) return false;
|
|
444
|
+
if (marks.some((mark) => mark.type !== "geoShape")) return false;
|
|
445
|
+
return marks.every((mark) => {
|
|
446
|
+
const rows = typeof mark.data === "string" ? datasets?.[mark.data] : mark.data;
|
|
447
|
+
if (rows === void 0 || rows === null) return true;
|
|
448
|
+
if (!Array.isArray(rows)) return false;
|
|
449
|
+
if (rows.length === 0) return true;
|
|
450
|
+
return isPlaceholderGeometryDataset(rows);
|
|
451
|
+
});
|
|
438
452
|
}
|
|
439
|
-
/**
|
|
440
|
-
const
|
|
453
|
+
/** 翻译期警告去重:数组引用(占位)与数据集名(缺失)各自只警告一次 */
|
|
454
|
+
const warnedRows = /* @__PURE__ */ new WeakSet();
|
|
455
|
+
const warnedMissing = /* @__PURE__ */ new Set();
|
|
441
456
|
/**
|
|
442
457
|
* 翻译期占位几何警告:数据集整体占位时 console.warn 指出空壳根因与修复方向。
|
|
443
458
|
* 只挂在 geoShape(占位字符串的高发地——示意 spec 的外部轮廓数据集);普通 mark
|
|
@@ -445,10 +460,20 @@ const warned = /* @__PURE__ */ new WeakSet();
|
|
|
445
460
|
* (新引用)视为新数据集重新警告。
|
|
446
461
|
*/
|
|
447
462
|
function warnPlaceholderGeometry(rows, datasetName, markType) {
|
|
448
|
-
if (!isPlaceholderGeometryDataset(rows) ||
|
|
449
|
-
|
|
463
|
+
if (!isPlaceholderGeometryDataset(rows) || warnedRows.has(rows)) return;
|
|
464
|
+
warnedRows.add(rows);
|
|
450
465
|
console.warn(`[cx-charts] ${markType} 数据集${datasetName ? ` "${datasetName}"` : ""} 的 geometry 全部缺失或为占位字符串,渲染为空壳——须以真实 GeoJSON 数据集整体替换示意占位(技能侧见「数据供给」表)。`);
|
|
451
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* 翻译期数据集缺失警告:geoShape 按名引用了数据集表中不存在的键——与占位字符串
|
|
469
|
+
* 同为「渲染空壳无反馈」的事故形态,区别只在根因(未提供 vs 提供了占位)。
|
|
470
|
+
* 按名去重(缺失数据集无内容引用可作 WeakSet 键),命名数据集到达后不再命中。
|
|
471
|
+
*/
|
|
472
|
+
function warnMissingGeometryDataset(datasetName, markType) {
|
|
473
|
+
if (warnedMissing.has(datasetName)) return;
|
|
474
|
+
warnedMissing.add(datasetName);
|
|
475
|
+
console.warn(`[cx-charts] ${markType} 引用的数据集 "${datasetName}" 不存在,渲染为空壳——数据集须随物料 data 顶层提供(GenUI 数据顶层化契约)。`);
|
|
476
|
+
}
|
|
452
477
|
//#endregion
|
|
453
478
|
//#region src/shared/translate/transforms.ts
|
|
454
479
|
/**
|
|
@@ -1282,7 +1307,9 @@ const GEO_PROJECTION_FACTORIES = {
|
|
|
1282
1307
|
/** geoShape:projection 名称枚举 → descriptor {type, fit, inset};fit:'data' 由库拟合数据本体,{data:'<name>'} 拟合另一命名数据集 */
|
|
1283
1308
|
function translateGeoShape(spec, datasets) {
|
|
1284
1309
|
const rows = resolveMarkData(spec.data, datasets);
|
|
1285
|
-
|
|
1310
|
+
const datasetName = typeof spec.data === "string" ? spec.data : void 0;
|
|
1311
|
+
if (datasetName && rows.length === 0 && !datasets?.[datasetName]) warnMissingGeometryDataset(datasetName, "geoShape");
|
|
1312
|
+
else warnPlaceholderGeometry(rows, datasetName, "geoShape");
|
|
1286
1313
|
const projectionName = spec.projection ?? "mercator";
|
|
1287
1314
|
if (typeof projectionName === "object") throw new Error("translateGeoShape: projection {$by} 仅允许出现在 facet chart 子模板内");
|
|
1288
1315
|
const factory = GEO_PROJECTION_FACTORIES[projectionName];
|
|
@@ -1732,7 +1759,8 @@ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
|
1732
1759
|
const { spec, datasets, hostProps, ariaLabel } = useChartProps(attrs);
|
|
1733
1760
|
const definition = computed(() => translateChartSpec(spec.value, datasets.value));
|
|
1734
1761
|
const isStreaming = computed(() => streamingFields(attrs).includes("definition"));
|
|
1735
|
-
const
|
|
1762
|
+
const hasStreamingFields = computed(() => streamingFields(attrs).length > 0);
|
|
1763
|
+
const hasPlaceholderGeometry = computed(() => !hasStreamingFields.value && isPlaceholderChartRender(spec.value, datasets.value));
|
|
1736
1764
|
const skeletonHeight = computed(() => {
|
|
1737
1765
|
const h = Number(attrs.height);
|
|
1738
1766
|
return Number.isFinite(h) && h > 0 ? h : 320;
|
|
@@ -2556,4 +2584,4 @@ const CxTanstackChartsBundle = {
|
|
|
2556
2584
|
materials: [...CxTanstackCharts]
|
|
2557
2585
|
};
|
|
2558
2586
|
//#endregion
|
|
2559
|
-
export { COMPOSITE_TYPES, CX_CHART_CURVE_NAMES, CxTanstackCharts, area_default as CxTanstackChartsArea, bar_default as CxTanstackChartsBar, CxTanstackChartsBundle, chart_default as CxTanstackChartsChart, dot_default as CxTanstackChartsDot, line_default as CxTanstackChartsLine, pie_default as CxTanstackChartsPie, POLAR_FAMILY_TYPES, TANSTACK_CHARTS_STREAM_TRIGGERS, applyTransforms, createTanstackChartsTriggerRegistry,
|
|
2587
|
+
export { COMPOSITE_TYPES, CX_CHART_CURVE_NAMES, CxTanstackCharts, area_default as CxTanstackChartsArea, bar_default as CxTanstackChartsBar, CxTanstackChartsBundle, chart_default as CxTanstackChartsChart, dot_default as CxTanstackChartsDot, line_default as CxTanstackChartsLine, pie_default as CxTanstackChartsPie, POLAR_FAMILY_TYPES, TANSTACK_CHARTS_STREAM_TRIGGERS, applyTransforms, createTanstackChartsTriggerRegistry, isPlaceholderChartRender, isPlaceholderGeometryDataset, mainArrayOf, resolveMarkData, resolveRScaleOption, translateAxis, translateChartSpec, translateCompositeMark, translateCurve, translateMark, translateOutputs, translatePie, translatePolar, translateReduce, translateScale, translateTransform, warnMissingGeometryDataset, warnPlaceholderGeometry };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CxChartDatasets } from './types';
|
|
1
|
+
import type { CxChartDatasets, CxChartSpec } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* 单数据集整体不可渲染判定:Feature 数组且全部条目几何缺失或为占位字符串。
|
|
4
4
|
* 混合场景(部分真实几何)不算——部分数据仍可渲染,整体空态会误杀;
|
|
@@ -6,10 +6,17 @@ import type { CxChartDatasets } from './types';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isPlaceholderGeometryDataset(rows: readonly unknown[]): boolean;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* 组件层空态判定:整图渲染必然空壳时为 true。
|
|
10
|
+
*
|
|
11
|
+
* 判定范围收敛在纯 geoShape 图(全部 marks 均为 geoShape):geoShape 无独立于数据
|
|
12
|
+
* 的渲染力(数据不可用即零图元),而其余 mark 类型总有独立形状;复合图只要存在
|
|
13
|
+
* 一个非 geoShape mark 或一个可用 geo 数据集就返回 false,防「部分可渲染却整体
|
|
14
|
+
* 空态」的误杀。覆盖三种不可用形态:
|
|
15
|
+
* - 命名数据集占位(geometry 占位字符串/全 null)
|
|
16
|
+
* - 命名数据集缺失(只引用不提供,resolveMarkData 回退空数组)
|
|
17
|
+
* - mark 内联 data 数组本身占位(不占命名数据集表的形态)
|
|
11
18
|
*/
|
|
12
|
-
export declare function
|
|
19
|
+
export declare function isPlaceholderChartRender(spec: CxChartSpec | undefined, datasets: CxChartDatasets | undefined): boolean;
|
|
13
20
|
/**
|
|
14
21
|
* 翻译期占位几何警告:数据集整体占位时 console.warn 指出空壳根因与修复方向。
|
|
15
22
|
* 只挂在 geoShape(占位字符串的高发地——示意 spec 的外部轮廓数据集);普通 mark
|
|
@@ -17,3 +24,9 @@ export declare function hasOnlyPlaceholderGeometry(datasets: CxChartDatasets): b
|
|
|
17
24
|
* (新引用)视为新数据集重新警告。
|
|
18
25
|
*/
|
|
19
26
|
export declare function warnPlaceholderGeometry(rows: readonly unknown[], datasetName: string | undefined, markType: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* 翻译期数据集缺失警告:geoShape 按名引用了数据集表中不存在的键——与占位字符串
|
|
29
|
+
* 同为「渲染空壳无反馈」的事故形态,区别只在根因(未提供 vs 提供了占位)。
|
|
30
|
+
* 按名去重(缺失数据集无内容引用可作 WeakSet 键),命名数据集到达后不再命中。
|
|
31
|
+
*/
|
|
32
|
+
export declare function warnMissingGeometryDataset(datasetName: string, markType: string): void;
|
|
@@ -8,7 +8,7 @@ export type { CxChartAxisSpec, CxChartCurveName, CxChartDatasets, CxChartForceSp
|
|
|
8
8
|
export { CX_CHART_CURVE_NAMES, translateCurve } from './curve';
|
|
9
9
|
export { translateScale } from './scale';
|
|
10
10
|
export { translateAxis } from './axis';
|
|
11
|
-
export {
|
|
11
|
+
export { isPlaceholderChartRender, isPlaceholderGeometryDataset, warnMissingGeometryDataset, warnPlaceholderGeometry, } from './geometry';
|
|
12
12
|
export { resolveMarkData, resolveRScaleOption, translateMark } from './mark';
|
|
13
13
|
export { applyTransforms, translateOutputs, translateReduce, translateTransform } from './transforms';
|
|
14
14
|
export { POLAR_FAMILY_TYPES, translatePie, translatePolar } from './polar';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionad/cx-comps-tanstack-charts",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.31",
|
|
4
4
|
"description": "cx material components wrapping TanStack Charts (@tanstack/charts/vue)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"charts",
|
|
@@ -34,14 +34,10 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "vp pack && vue-tsc -p tsconfig.build.json",
|
|
39
|
-
"typecheck": "vue-tsgo --tsdk ../../node_modules/.pnpm/typescript@7.0.2/node_modules/typescript --noEmit"
|
|
40
|
-
},
|
|
41
37
|
"dependencies": {
|
|
42
|
-
"@lionad/cx-definition": "
|
|
43
|
-
"@lionad/cx-stream": "
|
|
44
|
-
"@lionad/cx-vue": "
|
|
38
|
+
"@lionad/cx-definition": "0.1.0-alpha.10",
|
|
39
|
+
"@lionad/cx-stream": "0.1.0-alpha.14",
|
|
40
|
+
"@lionad/cx-vue": "0.1.0-alpha.11",
|
|
45
41
|
"d3-geo": "^3.1.1",
|
|
46
42
|
"d3-scale": "^4.0.2",
|
|
47
43
|
"d3-shape": "^3.2.0"
|
|
@@ -60,5 +56,9 @@
|
|
|
60
56
|
"@tanstack/charts": "^0.14.0",
|
|
61
57
|
"@vueuse/core": "^13.0.0 || ^14.0.0",
|
|
62
58
|
"vue": "^3.5.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "vp pack && vue-tsc -p tsconfig.build.json",
|
|
62
|
+
"typecheck": "vue-tsgo --tsdk ../../node_modules/.pnpm/typescript@7.0.2/node_modules/typescript --noEmit"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|