UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

66 lines (63 loc) • 1.77 kB
/** * DevExtreme (esm/__internal/viz/tree_map/node.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { extend as _extend } from "../../core/utils/m_extend"; const updateTile = [updateLeaf, updateGroup]; class Node { isNode() { return !!(this.nodes && this.level < this.ctx.maxLevel) } isActive() { const { ctx: ctx } = this; return this.level >= ctx.minLevel && this.level <= ctx.maxLevel } updateStyles() { const isNode = Number(this.isNode()); this.state = this._buildState(this.ctx.settings[isNode].state, !isNode && this.color && { fill: this.color }) } _buildState(state, extra) { const base = _extend({}, state); return extra ? _extend(base, extra) : base } updateLabelStyle() { const settings = this.ctx.settings[Number(this.isNode())]; this.labelState = settings.labelState; this.labelParams = settings.labelParams } _getState() { return this.state } applyState() { updateTile[Number(this.isNode())](this.tile, this._getState()) } } _extend(Node.prototype, { value: 0 }); function updateLeaf(content, attrs) { content.smartAttr(attrs) } function updateGroup(content, attrs) { content.outer.attr({ stroke: attrs.stroke, "stroke-width": attrs["stroke-width"], "stroke-opacity": attrs["stroke-opacity"] }); content.inner.smartAttr({ fill: attrs.fill, opacity: attrs.opacity, hatching: attrs.hatching }) } export default Node;