@visactor/vchart
Version:
charts lib based @visactor/VGrammar
24 lines (20 loc) • 951 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.treemapLayout = void 0;
const vlayouts_1 = require("@visactor/vlayouts"), vutils_1 = require("@visactor/vutils"), hierarchy_1 = require("../../constant/hierarchy"), treemapLayout = (data, op) => {
const options = (0, vutils_1.isFunction)(op) ? op() : op, viewBox = options.getViewBox();
if (viewBox) {
const res = new vlayouts_1.TreemapLayout(options).layout(data, viewBox), nodes = [];
return (0, vlayouts_1.flattenNodes)(res, nodes, {
maxDepth: null == options ? void 0 : options.maxDepth
}), nodes.forEach((datum => {
datum && [ hierarchy_1.DEFAULT_HIERARCHY_ROOT, "name" ].forEach((key => {
datum[key] = datum.datum[datum.depth][options.nameField];
}));
})), nodes;
}
return [];
};
exports.treemapLayout = treemapLayout;
//# sourceMappingURL=treemap.js.map