UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

19 lines (16 loc) 673 B
import { flattenNodes, TreemapLayout } from "@visactor/vlayouts"; import { DEFAULT_HIERARCHY_ROOT } from "../../constant/hierarchy"; export const treemapLayout = (data, op) => { if (op.getViewBox()) { const res = new TreemapLayout(op).layout(data, op.getViewBox()), nodes = []; return flattenNodes(res, nodes, { maxDepth: null == op ? void 0 : op.maxDepth }), nodes.forEach(((datum, i) => { datum && [ DEFAULT_HIERARCHY_ROOT, "name" ].forEach((key => { datum[key] = datum.datum[datum.depth][op.nameField]; })); })), nodes; } return []; }; //# sourceMappingURL=treemap.js.map