1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | exports.CompositionNode = void 0;
|
10 | const style_1 = require("../utils/style");
|
11 | const node_1 = require("./node");
|
12 | const define_1 = require("./define");
|
13 | const props_1 = require("./props");
|
14 | let CompositionNode = class CompositionNode extends node_1.Node {
|
15 | |
16 |
|
17 |
|
18 | changeData(data) {
|
19 | var _a;
|
20 | const chart = this.getRoot();
|
21 | if (!chart)
|
22 | return;
|
23 | this.attr('data', data);
|
24 | if ((_a = this.children) === null || _a === void 0 ? void 0 : _a.length) {
|
25 | this.children.forEach((child) => {
|
26 | child.attr('data', data);
|
27 | });
|
28 | }
|
29 | return chart === null || chart === void 0 ? void 0 : chart.render();
|
30 | }
|
31 | |
32 |
|
33 |
|
34 | getView() {
|
35 | const chart = this.getRoot();
|
36 | const { views } = chart.getContext();
|
37 | if (!(views === null || views === void 0 ? void 0 : views.length))
|
38 | return undefined;
|
39 | return views.find((view) => view.key === this._key);
|
40 | }
|
41 | getScale() {
|
42 | var _a;
|
43 | return (_a = this.getView()) === null || _a === void 0 ? void 0 : _a.scale;
|
44 | }
|
45 | getScaleByChannel(channel) {
|
46 | const scale = this.getScale();
|
47 | if (scale)
|
48 | return scale[channel];
|
49 | return;
|
50 | }
|
51 | getCoordinate() {
|
52 | var _a;
|
53 | return (_a = this.getView()) === null || _a === void 0 ? void 0 : _a.coordinate;
|
54 | }
|
55 | getTheme() {
|
56 | var _a;
|
57 | return (_a = this.getView()) === null || _a === void 0 ? void 0 : _a.theme;
|
58 | }
|
59 | getGroup() {
|
60 | const key = this._key;
|
61 | if (!key)
|
62 | return undefined;
|
63 | const chart = this.getRoot();
|
64 | const chartGroup = chart.getContext().canvas.getRoot();
|
65 | return chartGroup.getElementById(key);
|
66 | }
|
67 | |
68 |
|
69 |
|
70 | show() {
|
71 | const group = this.getGroup();
|
72 | if (!group)
|
73 | return;
|
74 | !group.isVisible() && (0, style_1.show)(group);
|
75 | }
|
76 | |
77 |
|
78 |
|
79 | hide() {
|
80 | const group = this.getGroup();
|
81 | if (!group)
|
82 | return;
|
83 | group.isVisible() && (0, style_1.hide)(group);
|
84 | }
|
85 | };
|
86 | CompositionNode = __decorate([
|
87 | (0, define_1.defineProps)(props_1.compositionProps)
|
88 | ], CompositionNode);
|
89 | exports.CompositionNode = CompositionNode;
|
90 |
|
\ | No newline at end of file |