node.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * DevExtreme (viz/tree_map/node.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var _extend = require("../../core/utils/extend").extend;
  11. function Node() {}
  12. _extend(Node.prototype, {
  13. value: 0,
  14. isNode: function() {
  15. return !!(this.nodes && this.level < this.ctx.maxLevel)
  16. },
  17. isActive: function() {
  18. var ctx = this.ctx;
  19. return this.level >= ctx.minLevel && this.level <= ctx.maxLevel
  20. },
  21. updateStyles: function() {
  22. var that = this;
  23. var isNode = Number(that.isNode());
  24. that.state = that._buildState(that.ctx.settings[isNode].state, !isNode && that.color && {
  25. fill: that.color
  26. })
  27. },
  28. _buildState: function(state, extra) {
  29. var base = _extend({}, state);
  30. return extra ? _extend(base, extra) : base
  31. },
  32. updateLabelStyle: function() {
  33. var settings = this.ctx.settings[Number(this.isNode())];
  34. this.labelState = settings.labelState;
  35. this.labelParams = settings.labelParams
  36. },
  37. _getState: function() {
  38. return this.state
  39. },
  40. applyState: function() {
  41. updateTile[Number(this.isNode())](this.tile, this._getState())
  42. }
  43. });
  44. var updateTile = [updateLeaf, updateGroup];
  45. function updateLeaf(content, attrs) {
  46. content.smartAttr(attrs)
  47. }
  48. function updateGroup(content, attrs) {
  49. content.outer.attr({
  50. stroke: attrs.stroke,
  51. "stroke-width": attrs["stroke-width"],
  52. "stroke-opacity": attrs["stroke-opacity"]
  53. });
  54. content.inner.smartAttr({
  55. fill: attrs.fill,
  56. opacity: attrs.opacity,
  57. hatching: attrs.hatching
  58. })
  59. }
  60. module.exports = Node;