@visactor/vmind
Version:
<div align="center"> <a href="https://github.com/VisActor#gh-light-mode-only" target="_blank"> <img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/logo_500_200_light.svg"/> </a> <a href="https://githu
53 lines (46 loc) • 1.49 kB
JavaScript
import { isValidDataTable } from "../../../../utils/dataTable";
import { color, discreteLegend } from "./common";
export const sankeyData = context => {
const {dataTable: dataTable, cell: cell, spec: spec} = context, {source: source, target: target} = cell, linkData = isValidDataTable(dataTable) ? dataTable : [], nodeData = [ ...new Set([ ...linkData.map((item => item[source])), ...linkData.map((item => item[target])) ]) ].map((node => ({
name: node
})));
return spec.data = {
id: "data",
values: [ {
nodes: nodeData,
links: linkData
} ]
}, {
spec: spec
};
};
export const sankeyField = context => {
const {cell: cell, spec: spec} = context;
return spec.sourceField = cell.source, spec.targetField = cell.target, spec.valueField = cell.value,
spec.categoryField = "name", spec.nodeKey = datum => datum.name, {
spec: spec
};
};
export const sankeyLink = context => {
const {spec: spec} = context;
return spec.link = {
style: {},
state: {
hover: {},
blur: {}
}
}, {
spec: spec
};
};
export const sankeyLabel = context => {
const {spec: spec} = context;
return spec.label = {
visible: !0,
style: {}
}, {
spec: spec
};
};
export const pipelineSankey = [ sankeyData, color, sankeyField, sankeyLink, sankeyLabel, discreteLegend ];
//# sourceMappingURL=sankey.js.map