| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { hide, show } from '../../utils/style';
- import { Node } from '../node';
- export class CompositionNode extends Node {
- /**
- * Change current node data and its children data.
- */
- changeData(data) {
- var _a;
- const chart = this.getRoot();
- if (!chart)
- return;
- this.attr('data', data);
- if ((_a = this.children) === null || _a === void 0 ? void 0 : _a.length) {
- this.children.forEach((child) => {
- child.attr('data', data);
- });
- }
- return chart === null || chart === void 0 ? void 0 : chart.render();
- }
- /**
- * Get view instance by key.
- */
- getView() {
- const chart = this.getRoot();
- const { views } = chart.getContext();
- if (!(views === null || views === void 0 ? void 0 : views.length))
- return undefined;
- return views.find((view) => view.key === this._key);
- }
- getScale() {
- var _a;
- return (_a = this.getView()) === null || _a === void 0 ? void 0 : _a.scale;
- }
- getScaleByChannel(channel) {
- const scale = this.getScale();
- if (scale)
- return scale[channel];
- return;
- }
- getCoordinate() {
- var _a;
- return (_a = this.getView()) === null || _a === void 0 ? void 0 : _a.coordinate;
- }
- getTheme() {
- var _a;
- return (_a = this.getView()) === null || _a === void 0 ? void 0 : _a.theme;
- }
- getGroup() {
- const key = this._key;
- if (!key)
- return undefined;
- const chart = this.getRoot();
- const chartGroup = chart.getContext().canvas.getRoot();
- return chartGroup.getElementById(key);
- }
- /**
- * Show the view.
- */
- show() {
- const group = this.getGroup();
- if (!group)
- return;
- !group.isVisible() && show(group);
- }
- /**
- * Hide the view.
- */
- hide() {
- const group = this.getGroup();
- if (!group)
- return;
- group.isVisible() && hide(group);
- }
- }
- //# sourceMappingURL=base.js.map
|