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

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.
Files changed (2) hide show
  1. package/dist/index.mjs +14 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -885,6 +885,15 @@ function hierarchyOptions(spec, idKey) {
885
885
  };
886
886
  throw new Error(`translateComposite: ${spec.type} 层级数据源必须声明 path 或 nodeId+parentId`);
887
887
  }
888
+ /**
889
+ * 层级布局节点的字段名通道(treemap/sunburst 的 color/z、tree 节点 dot 的 color/r):
890
+ * 库的 channelValues 在布局节点上平查 datum[field],而 flatHierarchyNodeContext 把源行
891
+ * 收纳在 data 下不展开——字段名物化为 data 取值 accessor,保持「字段名引用源数据」契约。
892
+ * sankey 不在此列:其 marks 回调 channel 按设计锁定布局行字段(key/width 等 canonical)。
893
+ */
894
+ function hierarchyFieldChannel(field) {
895
+ return (node) => node?.data?.[field];
896
+ }
888
897
  /** sankey:固化 marks 回调 = link(布局连线) + rect(布局节点),样式取自声明 */
889
898
  function translateSankey(spec, datasets) {
890
899
  const nodes = resolveMarkData(spec.nodes, datasets);
@@ -935,8 +944,8 @@ function translateSunburst(spec, datasets) {
935
944
  value: spec.value
936
945
  };
937
946
  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;
947
+ if (spec.color !== void 0) options.color = hierarchyFieldChannel(spec.color);
948
+ if (spec.z !== void 0) options.z = hierarchyFieldChannel(spec.z);
940
949
  if (spec.visibleDepth !== void 0) options.visibleDepth = spec.visibleDepth;
941
950
  if (spec.ringPadding !== void 0) options.ringPadding = spec.ringPadding;
942
951
  for (const key of [
@@ -966,7 +975,7 @@ function translateTreemap(spec, datasets) {
966
975
  value: spec.value
967
976
  };
968
977
  if (spec.id !== void 0) options.id = spec.id;
969
- if (spec.color !== void 0) options.color = spec.color;
978
+ if (spec.color !== void 0) options.color = hierarchyFieldChannel(spec.color);
970
979
  if (spec.method !== void 0) options.method = spec.method;
971
980
  if (spec.ratio !== void 0) options.ratio = spec.ratio;
972
981
  if (spec.round !== void 0) options.round = spec.round;
@@ -1006,8 +1015,8 @@ function translateTree(spec, datasets) {
1006
1015
  x: "x",
1007
1016
  y: "y",
1008
1017
  key: "id",
1009
- r: spec.r ?? 4.5,
1010
- color: spec.color ?? void 0,
1018
+ r: typeof spec.r === "string" ? hierarchyFieldChannel(spec.r) : spec.r ?? 4.5,
1019
+ color: spec.color === void 0 ? void 0 : hierarchyFieldChannel(spec.color),
1011
1020
  strokeWidth: 1.5,
1012
1021
  ...nodeRScale !== void 0 ? { rScale: nodeRScale } : {}
1013
1022
  })];
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.15",
4
4
  "description": "cx material components wrapping TanStack Charts (@tanstack/charts/vue)",
5
5
  "keywords": [
6
6
  "charts",