@lionad/cx-comps-tanstack-charts 0.1.0-alpha.18 → 0.1.0-alpha.19
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 +37 -20
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { Chart } from "@tanstack/charts/vue";
|
|
|
4
4
|
import { useCxBEM } from "@lionad/cx-vue";
|
|
5
5
|
import { areaX, areaY, arrow, bandX, bandY, barX, barY, binX, binXY, binY, boxRows, boxX, boxY, cell, colorGradientLegend, colorLegend, cumulative, d3Curve, defaultChartTheme, defineChart, delta, deviation, differenceX, differenceY, dodgeX, dodgeY, dot, first, fold, frame, group, groupBy, hexagon, last, lineX, lineY, linearRegressionRowsX, linearRegressionRowsY, linearRegressionX, linearRegressionY, link, median, mosaicX, mosaicY, normalize, quantile, rank, ratio, rect, ridgelineX, ridgelineY, rollingWindow, ruleX, ruleY, select, stack, stackRowsX, stackRowsY, text, tickX, tickY, variance, vector, violinX, violinY, waffleX, waffleY, waterfall } from "@tanstack/charts";
|
|
6
6
|
import { d3AreaXCurve } from "@tanstack/charts/d3/area-x";
|
|
7
|
-
import { curveBasis, curveCatmullRom, curveLinear, curveLinearClosed, curveMonotoneX, curveNatural, curveStep, curveStepAfter, curveStepBefore } from "d3-shape";
|
|
7
|
+
import { curveBasis, curveBumpX, curveCatmullRom, curveLinear, curveLinearClosed, curveMonotoneX, curveNatural, curveStep, curveStepAfter, curveStepBefore } from "d3-shape";
|
|
8
8
|
import { scaleLinear } from "@tanstack/charts/scales/linear";
|
|
9
9
|
import { scaleOrdinal } from "@tanstack/charts/scales/ordinal";
|
|
10
10
|
import { scalePoint } from "@tanstack/charts/scales/point";
|
|
@@ -910,6 +910,18 @@ function hierarchyOptions(spec, idKey) {
|
|
|
910
910
|
function hierarchyFieldChannel(field) {
|
|
911
911
|
return (node) => node?.data?.[field];
|
|
912
912
|
}
|
|
913
|
+
/**
|
|
914
|
+
* sankey 布局行顶层只有 canonical 字段(key/width/坐标),原 datum 收纳在 .data 下;
|
|
915
|
+
* 声明式样式字段名(如 stroke:"色调"、color:"id")须穿透到原 datum 解析,
|
|
916
|
+
* 否则 channel 按顶层查表得 undefined 而静默退回默认样式。
|
|
917
|
+
*/
|
|
918
|
+
function sankeyDatumField(field) {
|
|
919
|
+
return (row) => {
|
|
920
|
+
const record = row;
|
|
921
|
+
if (record.data != null && field in record.data) return record.data[field];
|
|
922
|
+
return record[field];
|
|
923
|
+
};
|
|
924
|
+
}
|
|
913
925
|
/** sankey:固化 marks 回调 = link(布局连线) + rect(布局节点),样式取自声明 */
|
|
914
926
|
function translateSankey(spec, datasets) {
|
|
915
927
|
const nodes = resolveMarkData(spec.nodes, datasets);
|
|
@@ -922,25 +934,30 @@ function translateSankey(spec, datasets) {
|
|
|
922
934
|
source: spec.source,
|
|
923
935
|
target: spec.target,
|
|
924
936
|
value: spec.value,
|
|
925
|
-
marks: (context) =>
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
937
|
+
marks: (context) => {
|
|
938
|
+
const strokeField = typeof spec.stroke === "string" && context.links.some((l) => l?.data?.[spec.stroke] !== void 0) ? spec.stroke : null;
|
|
939
|
+
return [looseLink(context.links, {
|
|
940
|
+
x1: "x1",
|
|
941
|
+
y1: "y1",
|
|
942
|
+
x2: "x2",
|
|
943
|
+
y2: "y2",
|
|
944
|
+
key: "key",
|
|
945
|
+
strokeWidth: (row) => Math.max(1, Number(row.width) || 1),
|
|
946
|
+
lineCap: "butt",
|
|
947
|
+
curve: d3Curve(curveBumpX),
|
|
948
|
+
color: strokeField ? sankeyDatumField(strokeField) : void 0,
|
|
949
|
+
stroke: strokeField ? void 0 : spec.stroke ?? void 0,
|
|
950
|
+
strokeOpacity: spec.strokeOpacity ?? .55
|
|
951
|
+
}), looseRect(context.nodes, {
|
|
952
|
+
x1: "x0",
|
|
953
|
+
x2: "x1",
|
|
954
|
+
y1: "y0",
|
|
955
|
+
y2: "y1",
|
|
956
|
+
key: "key",
|
|
957
|
+
color: typeof spec.color === "string" ? sankeyDatumField(spec.color) : spec.color ?? "key",
|
|
958
|
+
fillOpacity: spec.fillOpacity ?? void 0
|
|
959
|
+
})];
|
|
960
|
+
}
|
|
944
961
|
};
|
|
945
962
|
if (spec.id !== void 0) options.id = spec.id;
|
|
946
963
|
if (spec.align !== void 0) options.align = spec.align;
|