1 | import { __extends } from "tslib";
|
2 | /**
|
3 | * ============================================================================
|
4 | * IMPORTS
|
5 | * ============================================================================
|
6 | * @hidden
|
7 | */
|
8 | import { Sprite } from "../../core/Sprite";
|
9 | import { registry } from "../../core/Registry";
|
10 | import { InterfaceColorSet } from "../../core/utils/InterfaceColorSet";
|
11 | import * as $type from "../../core/utils/Type";
|
12 | /**
|
13 | * ============================================================================
|
14 | * MAIN CLASS
|
15 | * ============================================================================
|
16 | * @hidden
|
17 | */
|
18 | /**
|
19 | * AxisFill is a base class used to defines fill shapes for various
|
20 | * type-specific Axes.
|
21 | *
|
22 | * Axis fills are used to add fills to specific ranges of those axes.
|
23 | *
|
24 | * @see {@link IAxisFillEvents} for a list of available events
|
25 | * @see {@link IAxisFillAdapters} for a list of available Adapters
|
26 | * @important
|
27 | */
|
28 | var AxisFill = /** @class */ (function (_super) {
|
29 | __extends(AxisFill, _super);
|
30 | /**
|
31 | * Constructor.
|
32 | *
|
33 | * @param axis Axis
|
34 | */
|
35 | function AxisFill(axis) {
|
36 | var _this = _super.call(this) || this;
|
37 | _this.axis = axis;
|
38 | _this.element = _this.paper.add("path");
|
39 | _this.className = "AxisFill";
|
40 | _this.isMeasured = false;
|
41 | _this.location = 0;
|
42 | _this.above = false;
|
43 | var interfaceColors = new InterfaceColorSet();
|
44 | _this.fill = interfaceColors.getFor("alternativeBackground");
|
45 | _this.fillOpacity = 0;
|
46 | _this.applyTheme();
|
47 | return _this;
|
48 | }
|
49 | /**
|
50 | * @ignore
|
51 | */
|
52 | AxisFill.prototype.setDisabled = function (value) {
|
53 | var changed = _super.prototype.setDisabled.call(this, value);
|
54 | if (this.axis) {
|
55 | this.axis.invalidateDataItems();
|
56 | }
|
57 | return changed;
|
58 | };
|
59 | /**
|
60 | * Draws the fill element.
|
61 | *
|
62 | * @ignore Exclude from docs
|
63 | */
|
64 | AxisFill.prototype.draw = function () {
|
65 | _super.prototype.draw.call(this);
|
66 | if (this.__disabled || this.disabled) {
|
67 | return;
|
68 | }
|
69 | if (this.axis && $type.isNumber(this.startPosition) && $type.isNumber(this.endPosition)) {
|
70 | this.fillPath = this.axis.getPositionRangePath(this.startPosition, this.endPosition);
|
71 | this.path = this.fillPath;
|
72 | if (this.isMeasured) {
|
73 | this.measure();
|
74 | }
|
75 | }
|
76 | };
|
77 | Object.defineProperty(AxisFill.prototype, "startPosition", {
|
78 | /**
|
79 | * @return Start position
|
80 | */
|
81 | get: function () {
|
82 | return this.getPropertyValue("startPosition");
|
83 | },
|
84 | /**
|
85 | * An actual starting position of the fill.
|
86 | *
|
87 | * @param value Starting position
|
88 | */
|
89 | set: function (value) {
|
90 | this.setPropertyValue("startPosition", value);
|
91 | this.invalidate(); // this is needed as relative position might not change when zooming
|
92 | },
|
93 | enumerable: true,
|
94 | configurable: true
|
95 | });
|
96 | Object.defineProperty(AxisFill.prototype, "endPosition", {
|
97 | /**
|
98 | * @return End position
|
99 | */
|
100 | get: function () {
|
101 | return this.getPropertyValue("endPosition");
|
102 | },
|
103 | /**
|
104 | * An actual end position of the fill.
|
105 | *
|
106 | * @param value End position
|
107 | */
|
108 | set: function (value) {
|
109 | this.setPropertyValue("endPosition", value);
|
110 | this.invalidate(); // this is needed as relative position might not change when zooming
|
111 | },
|
112 | enumerable: true,
|
113 | configurable: true
|
114 | });
|
115 | Object.defineProperty(AxisFill.prototype, "location", {
|
116 | /**
|
117 | * @return Location (0-1)
|
118 | */
|
119 | get: function () {
|
120 | return this.getPropertyValue("location");
|
121 | },
|
122 | /**
|
123 | * Relative location of the fill. (0-1)
|
124 | *
|
125 | * @param value Location (0-1)
|
126 | */
|
127 | set: function (value) {
|
128 | this.setPropertyValue("location", value, true);
|
129 | },
|
130 | enumerable: true,
|
131 | configurable: true
|
132 | });
|
133 | /**
|
134 | * @ignore
|
135 | */
|
136 | AxisFill.prototype.setPath = function (value) {
|
137 | if (this.setPropertyValue("path", value)) {
|
138 | this.element.attr({ "d": value });
|
139 | return true;
|
140 | }
|
141 | return false;
|
142 | };
|
143 | Object.defineProperty(AxisFill.prototype, "above", {
|
144 | /**
|
145 | * @return Draw above series?
|
146 | */
|
147 | get: function () {
|
148 | return this.getPropertyValue("above");
|
149 | },
|
150 | /**
|
151 | * Normally fill goes below series. Set this to `true` to go above.
|
152 | *
|
153 | * @default false
|
154 | * @since 4.5.9
|
155 | * @param value Draw above series?
|
156 | */
|
157 | set: function (value) {
|
158 | this.setPropertyValue("above", value, true);
|
159 | },
|
160 | enumerable: true,
|
161 | configurable: true
|
162 | });
|
163 | return AxisFill;
|
164 | }(Sprite));
|
165 | export { AxisFill };
|
166 | /**
|
167 | * Register class in system, so that it can be instantiated using its name from
|
168 | * anywhere.
|
169 | *
|
170 | * @ignore
|
171 | */
|
172 | registry.registeredClasses["AxisFill"] = AxisFill;
|
173 | //# sourceMappingURL=AxisFill.js.map |
\ | No newline at end of file |