1 | /**
|
2 | * A module which defines functionality related to Category Axis Break.
|
3 | */
|
4 | import { __extends } from "tslib";
|
5 | /**
|
6 | * ============================================================================
|
7 | * IMPORTS
|
8 | * ============================================================================
|
9 | * @hidden
|
10 | */
|
11 | import { AxisBreak } from "./AxisBreak";
|
12 | import { registry } from "../../core/Registry";
|
13 | /**
|
14 | * ============================================================================
|
15 | * MAIN CLASS
|
16 | * ============================================================================
|
17 | * @hidden
|
18 | */
|
19 | /**
|
20 | * Base class to define "breaks" in axes
|
21 | * @see {@link ICategoryAxisBreakEvents} for a list of available events
|
22 | * @see {@link ICategoryAxisBreakAdapters} for a list of available Adapters
|
23 | */
|
24 | var CategoryAxisBreak = /** @class */ (function (_super) {
|
25 | __extends(CategoryAxisBreak, _super);
|
26 | /**
|
27 | * Constructor
|
28 | */
|
29 | function CategoryAxisBreak() {
|
30 | var _this = _super.call(this) || this;
|
31 | _this.className = "CategoryAxisBreak";
|
32 | _this.properties.startLocation = 0.5;
|
33 | _this.properties.endLocation = 0.5;
|
34 | _this.applyTheme();
|
35 | return _this;
|
36 | }
|
37 | Object.defineProperty(CategoryAxisBreak.prototype, "startPosition", {
|
38 | /**
|
39 | * Pixel position of the break's start.
|
40 | *
|
41 | * @return Position (px)
|
42 | * @readonly
|
43 | */
|
44 | get: function () {
|
45 | if (this.axis) {
|
46 | return this.axis.indexToPosition(this.adjustedStartValue, this.startLocation);
|
47 | }
|
48 | },
|
49 | enumerable: true,
|
50 | configurable: true
|
51 | });
|
52 | Object.defineProperty(CategoryAxisBreak.prototype, "endPosition", {
|
53 | /**
|
54 | * Pixel position of the break's end.
|
55 | *
|
56 | * @return Position (px)
|
57 | * @readonly
|
58 | */
|
59 | get: function () {
|
60 | if (this.axis) {
|
61 | return this.axis.indexToPosition(this.adjustedEndValue, this.endLocation);
|
62 | }
|
63 | },
|
64 | enumerable: true,
|
65 | configurable: true
|
66 | });
|
67 | Object.defineProperty(CategoryAxisBreak.prototype, "startCategory", {
|
68 | /**
|
69 | * @return Start category
|
70 | */
|
71 | get: function () {
|
72 | return this.getPropertyValue("startCategory");
|
73 | },
|
74 | /**
|
75 | * A category break starts on.
|
76 | *
|
77 | * @param value Start category
|
78 | */
|
79 | set: function (value) {
|
80 | if (this.setPropertyValue("startCategory", value)) {
|
81 | if (this.axis) {
|
82 | this.axis.invalidateDataItems();
|
83 | this.axis.invalidateSeries();
|
84 | }
|
85 | }
|
86 | },
|
87 | enumerable: true,
|
88 | configurable: true
|
89 | });
|
90 | Object.defineProperty(CategoryAxisBreak.prototype, "endCategory", {
|
91 | /**
|
92 | * @return End category
|
93 | */
|
94 | get: function () {
|
95 | return this.getPropertyValue("endCategory");
|
96 | },
|
97 | /**
|
98 | * A category break ends on.
|
99 | *
|
100 | * @param value End category
|
101 | */
|
102 | set: function (value) {
|
103 | if (this.setPropertyValue("endCategory", value)) {
|
104 | if (this.axis) {
|
105 | this.axis.invalidateDataItems();
|
106 | this.axis.invalidateSeries();
|
107 | }
|
108 | }
|
109 | },
|
110 | enumerable: true,
|
111 | configurable: true
|
112 | });
|
113 | Object.defineProperty(CategoryAxisBreak.prototype, "startValue", {
|
114 | /**
|
115 | * @return Value
|
116 | */
|
117 | get: function () {
|
118 | var category = this.getPropertyValue("startCategory");
|
119 | if (category) {
|
120 | return this.axis.categoryToIndex(category);
|
121 | }
|
122 | else {
|
123 | return this.getPropertyValue("startValue");
|
124 | }
|
125 | },
|
126 | /**
|
127 | * An index of start category.
|
128 | *
|
129 | * @param value Value
|
130 | */
|
131 | set: function (value) {
|
132 | if (this.setPropertyValue("startValue", value)) {
|
133 | if (this.axis) {
|
134 | this.axis.invalidateDataItems();
|
135 | this.axis.invalidateSeries();
|
136 | }
|
137 | }
|
138 | },
|
139 | enumerable: true,
|
140 | configurable: true
|
141 | });
|
142 | Object.defineProperty(CategoryAxisBreak.prototype, "endValue", {
|
143 | /**
|
144 | * @return Value
|
145 | */
|
146 | get: function () {
|
147 | var category = this.getPropertyValue("endCategory");
|
148 | if (category) {
|
149 | return this.axis.categoryToIndex(category);
|
150 | }
|
151 | else {
|
152 | return this.getPropertyValue("endValue");
|
153 | }
|
154 | },
|
155 | /**
|
156 | * An index of end category or a end value.
|
157 | *
|
158 | * @param value Value
|
159 | */
|
160 | set: function (value) {
|
161 | if (this.setPropertyValue("endValue", value)) {
|
162 | if (this.axis) {
|
163 | this.axis.invalidateDataItems();
|
164 | this.axis.invalidateSeries();
|
165 | }
|
166 | }
|
167 | },
|
168 | enumerable: true,
|
169 | configurable: true
|
170 | });
|
171 | Object.defineProperty(CategoryAxisBreak.prototype, "startLocation", {
|
172 | /**
|
173 | * @return Break start location
|
174 | */
|
175 | get: function () {
|
176 | return this.getPropertyValue("startLocation");
|
177 | },
|
178 | /**
|
179 | * Indicates where within starting category break should begin.
|
180 | *
|
181 | * Values range from `0` (start) to `1` (end), with default being `0.5` (middle).
|
182 | *
|
183 | * E.g. if you want to a break to fully encompass start and end categories,
|
184 | * you should set `startLocation = 0` and `endLocation = 1`.
|
185 | *
|
186 | * @since 4.9.17
|
187 | * @default 0.5
|
188 | * @param value Break start location
|
189 | */
|
190 | set: function (value) {
|
191 | if (this.setPropertyValue("startLocation", value)) {
|
192 | if (this.axis) {
|
193 | this.axis.invalidateDataItems();
|
194 | this.axis.invalidateSeries();
|
195 | }
|
196 | }
|
197 | },
|
198 | enumerable: true,
|
199 | configurable: true
|
200 | });
|
201 | Object.defineProperty(CategoryAxisBreak.prototype, "endLocation", {
|
202 | /**
|
203 | * @return Break end location
|
204 | */
|
205 | get: function () {
|
206 | return this.getPropertyValue("endLocation");
|
207 | },
|
208 | /**
|
209 | * Indicates where within ending category break should end.
|
210 | *
|
211 | * Values range from `0` (start) to `1` (end), with default being `0.5` (middle).
|
212 | *
|
213 | * E.g. if you want to a break to fully encompass start and end categories,
|
214 | * you should set `startLocation = 0` and `endLocation = 1`.
|
215 | *
|
216 | * @since 4.9.17
|
217 | * @default 0.5
|
218 | * @param value Break end location
|
219 | */
|
220 | set: function (value) {
|
221 | if (this.setPropertyValue("endLocation", value)) {
|
222 | if (this.axis) {
|
223 | this.axis.invalidateDataItems();
|
224 | this.axis.invalidateSeries();
|
225 | }
|
226 | }
|
227 | },
|
228 | enumerable: true,
|
229 | configurable: true
|
230 | });
|
231 | return CategoryAxisBreak;
|
232 | }(AxisBreak));
|
233 | export { CategoryAxisBreak };
|
234 | /**
|
235 | * Register class in system, so that it can be instantiated using its name from
|
236 | * anywhere.
|
237 | *
|
238 | * @ignore
|
239 | */
|
240 | registry.registeredClasses["CategoryAxisBreak"] = CategoryAxisBreak;
|
241 | //# sourceMappingURL=CategoryAxisBreak.js.map |
\ | No newline at end of file |