@lionad/cx-comps-tanstack-charts 0.1.0-alpha.14 → 0.1.0-alpha.16

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
@@ -785,7 +785,23 @@ function translatePolarGuide(spec) {
785
785
  "shape",
786
786
  "labels",
787
787
  "labelAngle",
788
- "labelOffset"
788
+ "labelOffset",
789
+ "id",
790
+ "className",
791
+ "labelClassName",
792
+ "stroke",
793
+ "strokeOpacity",
794
+ "strokeWidth",
795
+ "strokeDasharray",
796
+ "fill",
797
+ "fillOpacity",
798
+ "labelFill",
799
+ "labelFontSize",
800
+ "labelAnchor",
801
+ "labelBaseline",
802
+ "labelDx",
803
+ "labelDy",
804
+ "labelRotate"
789
805
  ]) if (spec[key] !== void 0) options[key] = spec[key];
790
806
  return factory(options);
791
807
  }
@@ -885,6 +901,15 @@ function hierarchyOptions(spec, idKey) {
885
901
  };
886
902
  throw new Error(`translateComposite: ${spec.type} 层级数据源必须声明 path 或 nodeId+parentId`);
887
903
  }
904
+ /**
905
+ * 层级布局节点的字段名通道(treemap/sunburst 的 color/z、tree 节点 dot 的 color/r):
906
+ * 库的 channelValues 在布局节点上平查 datum[field],而 flatHierarchyNodeContext 把源行
907
+ * 收纳在 data 下不展开——字段名物化为 data 取值 accessor,保持「字段名引用源数据」契约。
908
+ * sankey 不在此列:其 marks 回调 channel 按设计锁定布局行字段(key/width 等 canonical)。
909
+ */
910
+ function hierarchyFieldChannel(field) {
911
+ return (node) => node?.data?.[field];
912
+ }
888
913
  /** sankey:固化 marks 回调 = link(布局连线) + rect(布局节点),样式取自声明 */
889
914
  function translateSankey(spec, datasets) {
890
915
  const nodes = resolveMarkData(spec.nodes, datasets);
@@ -935,8 +960,8 @@ function translateSunburst(spec, datasets) {
935
960
  value: spec.value
936
961
  };
937
962
  if (spec.id !== void 0) options.id = spec.id;
938
- if (spec.color !== void 0) options.color = spec.color;
939
- if (spec.z !== void 0) options.z = spec.z;
963
+ if (spec.color !== void 0) options.color = hierarchyFieldChannel(spec.color);
964
+ if (spec.z !== void 0) options.z = hierarchyFieldChannel(spec.z);
940
965
  if (spec.visibleDepth !== void 0) options.visibleDepth = spec.visibleDepth;
941
966
  if (spec.ringPadding !== void 0) options.ringPadding = spec.ringPadding;
942
967
  for (const key of [
@@ -966,7 +991,7 @@ function translateTreemap(spec, datasets) {
966
991
  value: spec.value
967
992
  };
968
993
  if (spec.id !== void 0) options.id = spec.id;
969
- if (spec.color !== void 0) options.color = spec.color;
994
+ if (spec.color !== void 0) options.color = hierarchyFieldChannel(spec.color);
970
995
  if (spec.method !== void 0) options.method = spec.method;
971
996
  if (spec.ratio !== void 0) options.ratio = spec.ratio;
972
997
  if (spec.round !== void 0) options.round = spec.round;
@@ -1006,8 +1031,8 @@ function translateTree(spec, datasets) {
1006
1031
  x: "x",
1007
1032
  y: "y",
1008
1033
  key: "id",
1009
- r: spec.r ?? 4.5,
1010
- color: spec.color ?? void 0,
1034
+ r: typeof spec.r === "string" ? hierarchyFieldChannel(spec.r) : spec.r ?? 4.5,
1035
+ color: spec.color === void 0 ? void 0 : hierarchyFieldChannel(spec.color),
1011
1036
  strokeWidth: 1.5,
1012
1037
  ...nodeRScale !== void 0 ? { rScale: nodeRScale } : {}
1013
1038
  })];
@@ -1081,7 +1106,7 @@ const GEO_PROJECTION_FACTORIES = {
1081
1106
  equalEarth: geoEqualEarth,
1082
1107
  identity: geoIdentity
1083
1108
  };
1084
- /** geoShape:projection 名称枚举 → descriptor {type, fit, inset};fit:'data' 由库拟合数据本体 */
1109
+ /** geoShape:projection 名称枚举 → descriptor {type, fit, inset};fit:'data' 由库拟合数据本体,{data:'<name>'} 拟合另一命名数据集 */
1085
1110
  function translateGeoShape(spec, datasets) {
1086
1111
  const rows = resolveMarkData(spec.data, datasets);
1087
1112
  const projectionName = spec.projection ?? "mercator";
@@ -1089,7 +1114,10 @@ function translateGeoShape(spec, datasets) {
1089
1114
  if (!factory) throw new Error(`translateGeoShape: 未知投影 "${String(projectionName)}"`);
1090
1115
  const options = { projection: {
1091
1116
  type: factory,
1092
- fit: spec.fit ?? "data",
1117
+ fit: typeof spec.fit === "object" && spec.fit !== null ? {
1118
+ type: "FeatureCollection",
1119
+ features: resolveMarkData(spec.fit.data, datasets)
1120
+ } : spec.fit ?? "data",
1093
1121
  ...spec.inset !== void 0 ? { inset: spec.inset } : {}
1094
1122
  } };
1095
1123
  if (spec.id !== void 0) options.id = spec.id;
@@ -235,7 +235,9 @@ export interface CxChartMarkSpec {
235
235
  orientation?: 'left' | 'right' | 'top' | 'bottom';
236
236
  nodeSize?: [number, number];
237
237
  projection?: 'mercator' | 'orthographic' | 'naturalEarth1' | 'albersUsa' | 'equalEarth' | 'identity';
238
- fit?: 'data' | 'sphere';
238
+ fit?: 'data' | 'sphere' | {
239
+ data: string;
240
+ };
239
241
  by?: string;
240
242
  axes?: 'outer' | 'cell';
241
243
  minWidth?: number;
@@ -252,6 +254,22 @@ export interface CxChartPolarGuideSpec {
252
254
  labels?: boolean;
253
255
  labelAngle?: number;
254
256
  labelOffset?: number;
257
+ id?: string;
258
+ className?: string;
259
+ labelClassName?: string;
260
+ stroke?: string;
261
+ strokeOpacity?: number;
262
+ strokeWidth?: number;
263
+ strokeDasharray?: string;
264
+ fill?: string;
265
+ fillOpacity?: number;
266
+ labelFill?: string;
267
+ labelFontSize?: number;
268
+ labelAnchor?: 'start' | 'middle' | 'end';
269
+ labelBaseline?: 'auto' | 'middle' | 'hanging';
270
+ labelDx?: number;
271
+ labelDy?: number;
272
+ labelRotate?: number;
255
273
  }
256
274
  /**
257
275
  * forceGraph 力集声明式:库 ForceDescriptor 的 JSON 子集。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lionad/cx-comps-tanstack-charts",
3
- "version": "0.1.0-alpha.14",
3
+ "version": "0.1.0-alpha.16",
4
4
  "description": "cx material components wrapping TanStack Charts (@tanstack/charts/vue)",
5
5
  "keywords": [
6
6
  "charts",