columns.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { __assign, __extends, __rest } from "tslib";
  2. import { deepMix } from '@antv/util';
  3. import { DisplayObject, Group } from '../../shapes';
  4. import { deepAssign, select } from '../../util';
  5. var Columns = /** @class */ (function (_super) {
  6. __extends(Columns, _super);
  7. function Columns(_a) {
  8. var _this = this;
  9. var style = _a.style, rest = __rest(_a, ["style"]);
  10. _this = _super.call(this, deepMix({}, { type: 'column' }, __assign({ style: style }, rest))) || this;
  11. _this.columnsGroup = new Group({ name: 'columns' });
  12. _this.appendChild(_this.columnsGroup);
  13. _this.render();
  14. return _this;
  15. }
  16. Columns.prototype.render = function () {
  17. var columns = this.attributes.columns;
  18. select(this.columnsGroup)
  19. .selectAll('.column')
  20. .data(columns.flat())
  21. .join(function (enter) {
  22. return enter
  23. .append('rect')
  24. .attr('className', 'column')
  25. .each(function (style) {
  26. this.attr(style);
  27. });
  28. }, function (update) {
  29. return update.each(function (style) {
  30. this.attr(style);
  31. });
  32. }, function (exit) { return exit.remove(); });
  33. };
  34. Columns.prototype.update = function (attr) {
  35. this.attr(deepAssign({}, this.attributes, attr));
  36. this.render();
  37. };
  38. Columns.prototype.clear = function () {
  39. this.removeChildren();
  40. };
  41. return Columns;
  42. }(DisplayObject));
  43. export { Columns };
  44. //# sourceMappingURL=columns.js.map