1 | /**
|
2 | * Module, defining base Axis Renderer.
|
3 | */
|
4 | import { __extends } from "tslib";
|
5 | /**
|
6 | * ============================================================================
|
7 | * IMPORTS
|
8 | * ============================================================================
|
9 | * @hidden
|
10 | */
|
11 | import { Container } from "../../core/Container";
|
12 | import { MutableValueDisposer } from "../../core/utils/Disposer";
|
13 | import { AxisDataItem } from "./Axis";
|
14 | import { AxisLine } from "./AxisLine";
|
15 | import { AxisFill } from "./AxisFill";
|
16 | import { Grid } from "./Grid";
|
17 | import { AxisLabel } from "./AxisLabel";
|
18 | import { AxisTick } from "./AxisTick";
|
19 | import { ListTemplate, ListDisposer } from "../../core/utils/List";
|
20 | import { registry } from "../../core/Registry";
|
21 | import { percent } from "../../core/utils/Percent";
|
22 | import * as $math from "../../core/utils/Math";
|
23 | import * as $type from "../../core/utils/Type";
|
24 | /**
|
25 | * ============================================================================
|
26 | * MAIN CLASS
|
27 | * ============================================================================
|
28 | * @hidden
|
29 | */
|
30 | /**
|
31 | * A base class for all axis renderers.
|
32 | *
|
33 | * @see {@link IAxisRendererEvents} for a list of available events
|
34 | * @see {@link IAxisRendererAdapters} for a list of available Adapters
|
35 | */
|
36 | var AxisRenderer = /** @class */ (function (_super) {
|
37 | __extends(AxisRenderer, _super);
|
38 | /**
|
39 | * Constructor.
|
40 | *
|
41 | * @param axis Related axis
|
42 | */
|
43 | function AxisRenderer() {
|
44 | var _this =
|
45 | // Init
|
46 | _super.call(this) || this;
|
47 | /**
|
48 | * A related chart.
|
49 | */
|
50 | _this._chart = new MutableValueDisposer();
|
51 | _this.className = "AxisRenderer";
|
52 | // Set defaults
|
53 | _this.minGridDistance = 50;
|
54 | _this.inside = false;
|
55 | _this.inversed = false;
|
56 | _this.tooltipLocation = 0.5;
|
57 | _this.fullWidthTooltip = false;
|
58 | _this.cellStartLocation = 0;
|
59 | _this.cellEndLocation = 1;
|
60 | _this.minLabelPosition = 0;
|
61 | _this.maxLabelPosition = 1;
|
62 | _this.shouldClone = false;
|
63 | var gridContainer = _this.createChild(Container);
|
64 | gridContainer.shouldClone = false;
|
65 | gridContainer.layout = "none";
|
66 | // gridContainer.isMeasured = false;
|
67 | gridContainer.virtualParent = _this;
|
68 | gridContainer.width = percent(100);
|
69 | gridContainer.height = percent(100);
|
70 | _this.gridContainer = gridContainer;
|
71 | // not good without this
|
72 | gridContainer.events.on("maxsizechanged", function () {
|
73 | if (_this.inited) {
|
74 | _this.invalidateAxisItems();
|
75 | }
|
76 | }, _this, false);
|
77 | var breakContainer = _this.createChild(Container);
|
78 | breakContainer.shouldClone = false;
|
79 | breakContainer.isMeasured = false;
|
80 | breakContainer.layout = "none";
|
81 | breakContainer.width = percent(100);
|
82 | breakContainer.height = percent(100);
|
83 | _this.breakContainer = breakContainer;
|
84 | var bulletsContainer = _this.createChild(Container);
|
85 | bulletsContainer.shouldClone = false;
|
86 | bulletsContainer.isMeasured = false;
|
87 | bulletsContainer.layout = "none";
|
88 | bulletsContainer.width = percent(100);
|
89 | bulletsContainer.height = percent(100);
|
90 | _this.bulletsContainer = bulletsContainer;
|
91 | _this.line = _this.createChild(AxisLine);
|
92 | _this.line.shouldClone = false;
|
93 | _this.line.strokeOpacity = 0;
|
94 | var baseGrid = _this.createChild(Grid);
|
95 | baseGrid.shouldClone = false;
|
96 | _this.baseGrid = baseGrid;
|
97 | // Make elements disposable
|
98 | var disposers = _this._disposers;
|
99 | disposers.push(baseGrid);
|
100 | disposers.push(_this.line);
|
101 | disposers.push(gridContainer);
|
102 | disposers.push(breakContainer);
|
103 | disposers.push(bulletsContainer);
|
104 | disposers.push(_this._chart);
|
105 | _this.ticks.template.disabled = true;
|
106 | _this.axisFills.template.disabled = true;
|
107 | _this.axisFills.template.interactionsEnabled = false;
|
108 | // Apply theme
|
109 | _this.applyTheme();
|
110 | return _this;
|
111 | }
|
112 | Object.defineProperty(AxisRenderer.prototype, "axis", {
|
113 | /**
|
114 | * Axis of a renderer
|
115 | * @return axis Axis
|
116 | */
|
117 | get: function () {
|
118 | return this._axis;
|
119 | },
|
120 | /**
|
121 | * Axis of a renderer
|
122 | * @param axis Axis
|
123 | */
|
124 | set: function (axis) {
|
125 | this.setAxis(axis);
|
126 | },
|
127 | enumerable: true,
|
128 | configurable: true
|
129 | });
|
130 | /**
|
131 | * @ignore
|
132 | */
|
133 | AxisRenderer.prototype.setAxis = function (axis) {
|
134 | this._axis = axis;
|
135 | this.baseGrid.parent = axis;
|
136 | this.line.parent = axis;
|
137 | this.gridContainer.bind("opacity", axis);
|
138 | };
|
139 | /**
|
140 | * Called when rendered is attached to an Axis, as well as a property of
|
141 | * Axis that might affect the appearance is updated.
|
142 | *
|
143 | * E.g. `axis.opposite`, `axis.inside`, etc.
|
144 | *
|
145 | * This method is called **before** draw, so that any related setting
|
146 | * changed in this method can be changed.
|
147 | *
|
148 | * @todo Description (review)
|
149 | * @ignore Exclude from docs
|
150 | */
|
151 | AxisRenderer.prototype.processRenderer = function () {
|
152 | this.events.on("sizechanged", this.updateTooltip, this, false);
|
153 | this.events.on("positionchanged", this.updateTooltip, this, false);
|
154 | this.labels.template.inside = this.inside;
|
155 | this.ticks.template.inside = this.inside;
|
156 | };
|
157 | /**
|
158 | * Updates Axis' tooltip.
|
159 | *
|
160 | * @todo Description (review)
|
161 | * @ignore Exclude from docs
|
162 | */
|
163 | AxisRenderer.prototype.updateTooltip = function () {
|
164 | // This is a placeholder method for extending classes to override.
|
165 | };
|
166 | Object.defineProperty(AxisRenderer.prototype, "axisLength", {
|
167 | /**
|
168 | * Returns actual length of the Axis, in pixels.
|
169 | *
|
170 | * @return Length (px)
|
171 | */
|
172 | get: function () {
|
173 | // This is a placeholder method for extending classes to override.
|
174 | return 0;
|
175 | },
|
176 | enumerable: true,
|
177 | configurable: true
|
178 | });
|
179 | /**
|
180 | * Re-positions an element to new coordinates.
|
181 | *
|
182 | * @ignore Exclude from docs
|
183 | * @param item A target element
|
184 | * @param point New coordinates
|
185 | */
|
186 | AxisRenderer.prototype.positionItem = function (item, point) {
|
187 | if (item) {
|
188 | item.moveTo(point);
|
189 | }
|
190 | };
|
191 | /**
|
192 | * Converts relative position on axis to point coordinates.
|
193 | *
|
194 | * @param position Position (0-1)
|
195 | * @return Point
|
196 | */
|
197 | AxisRenderer.prototype.positionToPoint = function (position, position2) {
|
198 | // This is a placeholder method for extending classes to override.
|
199 | return { x: 0, y: 0 };
|
200 | };
|
201 | /**
|
202 | * Converts relative position on axis to angle.
|
203 | *
|
204 | * @ignore Exclude from docs
|
205 | * @todo Description (review / units)
|
206 | * @param position Position (0-1)
|
207 | * @return Angle
|
208 | */
|
209 | AxisRenderer.prototype.positionToAngle = function (position) {
|
210 | // This is a placeholder method for extending classes to override.
|
211 | return 0;
|
212 | };
|
213 | /**
|
214 | * Converts relative position (0-1) on axis to a pixel coordinate.
|
215 | *
|
216 | * @param position Position (0-1)
|
217 | * @return Coordinate (px)
|
218 | */
|
219 | AxisRenderer.prototype.positionToCoordinate = function (position) {
|
220 | var coordinate;
|
221 | var axis = this.axis;
|
222 | var axisFullLength = axis.axisFullLength;
|
223 | if (axis.renderer.inversed) {
|
224 | coordinate = (axis.end - position) * axisFullLength;
|
225 | }
|
226 | else {
|
227 | coordinate = (position - axis.start) * axisFullLength;
|
228 | }
|
229 | return coordinate;
|
230 | };
|
231 | AxisRenderer.prototype.updateGridContainer = function () {
|
232 | };
|
233 | AxisRenderer.prototype.getHeight = function () {
|
234 | var gridContainer = this.gridContainer;
|
235 | if (gridContainer.parent) {
|
236 | return gridContainer.parent.pixelHeight;
|
237 | }
|
238 | return this.gridContainer.pixelHeight || 0;
|
239 | };
|
240 | AxisRenderer.prototype.getWidth = function () {
|
241 | var gridContainer = this.gridContainer;
|
242 | if (gridContainer.parent) {
|
243 | return gridContainer.parent.pixelWidth;
|
244 | }
|
245 | return this.gridContainer.pixelWidth || 0;
|
246 | };
|
247 | /**
|
248 | * Converts a coordinate in pixels to a relative position. (0-1)
|
249 | *
|
250 | * @param coordinate Coordinate (px)
|
251 | * @param coordinate2 Coordinate of a second axis, only needed for complex axes systems, like timeline (px)
|
252 | * @return Position (0-1)
|
253 | */
|
254 | AxisRenderer.prototype.coordinateToPosition = function (coordinate, coordinate2) {
|
255 | var position;
|
256 | var axis = this.axis;
|
257 | var axisFullLength = axis.axisFullLength;
|
258 | if (axis.renderer.inversed) {
|
259 | position = axis.end - coordinate / axisFullLength;
|
260 | }
|
261 | else {
|
262 | position = coordinate / axisFullLength + axis.start;
|
263 | }
|
264 | return $math.round(position, 5);
|
265 | };
|
266 | /**
|
267 | * Converts a point at specific coordinates to a relative position (0-1)
|
268 | * on the axis.
|
269 | *
|
270 | * @ignore Exclude from docs
|
271 | * @param point Point
|
272 | * @return Position (0-1)
|
273 | */
|
274 | AxisRenderer.prototype.pointToPosition = function (point) {
|
275 | // This is a placeholder method for extending classes to override.
|
276 | return 0;
|
277 | };
|
278 | /**
|
279 | * [getPositionRangePath description]
|
280 | *
|
281 | * @ignore Exclude from docs
|
282 | * @todo Description
|
283 | * @param startPosition Starting position
|
284 | * @param endPosition End position
|
285 | * @return SVG path
|
286 | */
|
287 | AxisRenderer.prototype.getPositionRangePath = function (startPosition, endPosition) {
|
288 | return "";
|
289 | };
|
290 | /**
|
291 | * Invalidates all axis data items, effectively causing them re-evaluated.
|
292 | *
|
293 | * @ignore Exclude from docs
|
294 | * @todo Description (review)
|
295 | */
|
296 | AxisRenderer.prototype.invalidateAxisItems = function () {
|
297 | var axis = this.axis;
|
298 | if (axis) {
|
299 | axis.invalidateDataItems();
|
300 | }
|
301 | };
|
302 | /**
|
303 | * Updates and positions a grid element.
|
304 | *
|
305 | * @ignore Exclude from docs
|
306 | * @param grid Grid element
|
307 | * @param position Starting position
|
308 | * @param endPosition End position
|
309 | */
|
310 | AxisRenderer.prototype.updateGridElement = function (grid, position, endPosition) {
|
311 | // This is a placeholder method for extending classes to override.
|
312 | };
|
313 | /**
|
314 | * Updates and positions a tick element.
|
315 | *
|
316 | * @ignore Exclude from docs
|
317 | * @param tick Tick element
|
318 | * @param position Starting position
|
319 | * @param endPosition End position
|
320 | */
|
321 | AxisRenderer.prototype.updateTickElement = function (tick, position, endPosition) {
|
322 | // This is a placeholder method for extending classes to override.
|
323 | };
|
324 | /**
|
325 | * Updates and positions axis bullet.
|
326 | *
|
327 | * @ignore Exclude from docs
|
328 | * @param bullet AxisBullet element
|
329 | * @param position Starting position
|
330 | * @param endPosition End position
|
331 | */
|
332 | AxisRenderer.prototype.updateBullet = function (bullet, position, endPosition) {
|
333 | // This is a placeholder method for extending classes to override.
|
334 | };
|
335 | /**
|
336 | * Updates and positions a label element.
|
337 | *
|
338 | * @ignore Exclude from docs
|
339 | * @param label Label element
|
340 | * @param position Starting position
|
341 | * @param endPosition Ending position
|
342 | */
|
343 | AxisRenderer.prototype.updateLabelElement = function (label, position, endPosition, location) {
|
344 | // This is a placeholder method for extending classes to override.
|
345 | };
|
346 | /**
|
347 | * Updates and positions the axis fill element.
|
348 | *
|
349 | * @ignore Exclude from docs
|
350 | * @param fill Fill element
|
351 | * @param position Starting position
|
352 | * @param endPosition Ending position
|
353 | */
|
354 | AxisRenderer.prototype.updateFillElement = function (fill, position, endPosition) {
|
355 | fill.startPosition = position;
|
356 | fill.endPosition = endPosition;
|
357 | };
|
358 | /**
|
359 | * Updates and positions the axis line element.
|
360 | *
|
361 | * @ignore Exclude from docs
|
362 | */
|
363 | AxisRenderer.prototype.updateAxisLine = function () {
|
364 | // This is a placeholder method for extending classes to override.
|
365 | };
|
366 | /**
|
367 | * Updates and positions the base grid element.
|
368 | *
|
369 | * @ignore Exclude from docs
|
370 | */
|
371 | AxisRenderer.prototype.updateBaseGridElement = function () {
|
372 | // This is a placeholder method for extending classes to override.
|
373 | };
|
374 | /**
|
375 | * Updates and positions an axis break element.
|
376 | *
|
377 | * @ignore Exclude from docs
|
378 | * @param axisBreak Break element
|
379 | */
|
380 | AxisRenderer.prototype.updateBreakElement = function (axisBreak) {
|
381 | this.positionItem(axisBreak.startLine, axisBreak.startPoint);
|
382 | this.toggleVisibility(axisBreak.startLine, axisBreak.startPosition, 0, 1);
|
383 | this.positionItem(axisBreak.endLine, axisBreak.endPoint);
|
384 | this.toggleVisibility(axisBreak.endLine, axisBreak.endPosition, 0, 1);
|
385 | };
|
386 | Object.defineProperty(AxisRenderer.prototype, "minGridDistance", {
|
387 | /**
|
388 | * @return Min distance (px)
|
389 | */
|
390 | get: function () {
|
391 | return this.getPropertyValue("minGridDistance");
|
392 | },
|
393 | /**
|
394 | * Minimum distance in pixels between grid elements.
|
395 | *
|
396 | * Use it to control density of the grid/labels on the axis.element.
|
397 | *
|
398 | * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/#Setting_the_density_of_the_the_grid_labels} for more info
|
399 | * @param value Min distance (px)
|
400 | */
|
401 | set: function (value) {
|
402 | if (this.setPropertyValue("minGridDistance", value)) {
|
403 | if (this.axis) {
|
404 | this.axis.invalidateDataItems();
|
405 | }
|
406 | }
|
407 | },
|
408 | enumerable: true,
|
409 | configurable: true
|
410 | });
|
411 | Object.defineProperty(AxisRenderer.prototype, "chart", {
|
412 | /**
|
413 | * @ignore Exclude from docs
|
414 | * @return Chart
|
415 | */
|
416 | get: function () {
|
417 | return this._chart.get();
|
418 | },
|
419 | /**
|
420 | * A chart, associated with the Axis.
|
421 | *
|
422 | * @ignore Exclude from docs
|
423 | * @param value Chart
|
424 | */
|
425 | set: function (value) {
|
426 | this._chart.set(value, null);
|
427 | },
|
428 | enumerable: true,
|
429 | configurable: true
|
430 | });
|
431 | /**
|
432 | * Toggles visibility of an element, based on its current position and
|
433 | * min/max position settings.
|
434 | *
|
435 | * E.g. labels based on `minLabelPosition` and `maxLabelPosition`.
|
436 | *
|
437 | * @ignore Exclude from docs
|
438 | * @param sprite An element to toggle
|
439 | * @param position Elements current position
|
440 | * @param minPosition Min position setting
|
441 | * @param maxPosition Max position setting
|
442 | */
|
443 | AxisRenderer.prototype.toggleVisibility = function (sprite, position, minPosition, maxPosition) {
|
444 | var axis = this.axis;
|
445 | var dataItem = sprite.dataItem;
|
446 | if (dataItem && dataItem instanceof AxisDataItem) {
|
447 | if ($type.isNumber(dataItem.minPosition)) {
|
448 | minPosition = dataItem.minPosition;
|
449 | }
|
450 | if ($type.isNumber(dataItem.maxPosition)) {
|
451 | maxPosition = dataItem.maxPosition;
|
452 | }
|
453 | }
|
454 | var updatedStart = axis.start + (axis.end - axis.start) * (minPosition - 0.0001);
|
455 | var updatedEnd = axis.start + (axis.end - axis.start) * (maxPosition + 0.0001);
|
456 | if (!sprite.disabled) {
|
457 | if (position < updatedStart || position > updatedEnd) {
|
458 | sprite.__disabled = true;
|
459 | }
|
460 | else {
|
461 | sprite.__disabled = false;
|
462 | }
|
463 | }
|
464 | };
|
465 | /**
|
466 | * Creates visual elements for and axis break.
|
467 | *
|
468 | * @ignore Exclude from docs
|
469 | * @param axisBreak Axis break
|
470 | */
|
471 | AxisRenderer.prototype.createBreakSprites = function (axisBreak) {
|
472 | // This is a placeholder method for extending classes to override.
|
473 | };
|
474 | Object.defineProperty(AxisRenderer.prototype, "axisFills", {
|
475 | /**
|
476 | * A list of Axis' Fill elements.
|
477 | *
|
478 | * Those are fill elements that cover the space between every second set
|
479 | * of grid lines, and can be configured to create striped charts.
|
480 | *
|
481 | * Please note that these are disabled by default. To enable them, set
|
482 | * template to true.
|
483 | *
|
484 | * ```TypeScript
|
485 | * categoryAxis.renderer.axisFills.template.disabled = false;
|
486 | * ```
|
487 | * ```JavaScript
|
488 | * categoryAxis.renderer.axisFills.template.disabled = false;
|
489 | * ```
|
490 | * ```JSON
|
491 | * {
|
492 | * // ...
|
493 | * "xAxes": [{
|
494 | * // ...
|
495 | * "renderer": {
|
496 | * "axisFills": {
|
497 | * "disabled": false
|
498 | * }
|
499 | * }
|
500 | * }]
|
501 | * }
|
502 | * ```
|
503 | *
|
504 | * @see {@link https://www.amcharts.com/docs/v4/tutorials/alternated-axis-fills/} this tutorial for more info.
|
505 | * @return Fill elements
|
506 | */
|
507 | get: function () {
|
508 | if (!this._axisFills) {
|
509 | var fill = this.createFill(this.axis);
|
510 | this._axisFills = new ListTemplate(fill);
|
511 | fill.applyOnClones = true;
|
512 | fill.events.on("enabled", this.invalidateAxisItems, this, false);
|
513 | this._disposers.push(new ListDisposer(this._axisFills));
|
514 | this._disposers.push(this._axisFills.template);
|
515 | }
|
516 | return this._axisFills;
|
517 | },
|
518 | enumerable: true,
|
519 | configurable: true
|
520 | });
|
521 | /**
|
522 | * Returns a new fill element, suitable for this Axis Renderer type.
|
523 | *
|
524 | * @return Fill element
|
525 | */
|
526 | AxisRenderer.prototype.createFill = function (axis) {
|
527 | return new AxisFill(axis);
|
528 | };
|
529 | Object.defineProperty(AxisRenderer.prototype, "grid", {
|
530 | /**
|
531 | * A list of Axis' Grid elements.
|
532 | *
|
533 | * @return Grid elements
|
534 | */
|
535 | get: function () {
|
536 | if (!this._grid) {
|
537 | var grid = this.createGrid();
|
538 | this._grid = new ListTemplate(grid);
|
539 | grid.applyOnClones = true;
|
540 | grid.events.on("enabled", this.invalidateAxisItems, this, false);
|
541 | this._disposers.push(new ListDisposer(this._grid));
|
542 | this._disposers.push(this._grid.template);
|
543 | }
|
544 | return this._grid;
|
545 | },
|
546 | enumerable: true,
|
547 | configurable: true
|
548 | });
|
549 | /**
|
550 | * Returns a new grid element, suitable for this Axis Renderer type.
|
551 | *
|
552 | * @return Grid element
|
553 | */
|
554 | AxisRenderer.prototype.createGrid = function () {
|
555 | return new Grid();
|
556 | };
|
557 | Object.defineProperty(AxisRenderer.prototype, "ticks", {
|
558 | /**
|
559 | * A list of Axis' Tick elements.
|
560 | *
|
561 | * Please note that these are disabled by default. To enable ticks, you'll
|
562 | * need to set `disabled` and `strokeOpacity` properties of the tick template.
|
563 | *
|
564 | * ```TypeScript
|
565 | * categoryAxis.renderer.ticks.template.disabled = false;
|
566 | * categoryAxis.renderer.ticks.template.strokeOpacity = 0.5;
|
567 | * ```
|
568 | * ```JavaScript
|
569 | * categoryAxis.renderer.ticks.template.disabled = false;
|
570 | * categoryAxis.renderer.ticks.template.strokeOpacity = 0.5;
|
571 | * ```
|
572 | * ```JSON
|
573 | * {
|
574 | * // ...
|
575 | * "xAxes": [{
|
576 | * // ...
|
577 | * "renderer": {
|
578 | * "ticks": {
|
579 | * "disabled": false,
|
580 | * "strokeOpacity": 0.5
|
581 | * }
|
582 | * }
|
583 | * }]
|
584 | * }
|
585 | * ```
|
586 | *
|
587 | * @return Tick elements
|
588 | */
|
589 | get: function () {
|
590 | if (!this._ticks) {
|
591 | var tick = this.createTick();
|
592 | tick.applyOnClones = true;
|
593 | tick.isMeasured = false;
|
594 | tick.events.on("enabled", this.invalidateAxisItems, this, false);
|
595 | this._ticks = new ListTemplate(tick);
|
596 | this._disposers.push(new ListDisposer(this._ticks));
|
597 | this._disposers.push(this._ticks.template);
|
598 | }
|
599 | return this._ticks;
|
600 | },
|
601 | enumerable: true,
|
602 | configurable: true
|
603 | });
|
604 | /**
|
605 | * Returns a new tick element, suitable for this Axis Renderer type.
|
606 | *
|
607 | * @return Tick element
|
608 | */
|
609 | AxisRenderer.prototype.createTick = function () {
|
610 | return new AxisTick();
|
611 | };
|
612 | Object.defineProperty(AxisRenderer.prototype, "labels", {
|
613 | /**
|
614 | * A list of Axis' Label elements.
|
615 | *
|
616 | * @return Label elements
|
617 | */
|
618 | get: function () {
|
619 | if (!this._labels) {
|
620 | var label = this.createLabel();
|
621 | this._labels = new ListTemplate(label);
|
622 | label.applyOnClones = true;
|
623 | label.events.on("enabled", this.invalidateAxisItems, this, false);
|
624 | this._disposers.push(new ListDisposer(this._labels));
|
625 | this._disposers.push(this._labels.template);
|
626 | }
|
627 | return this._labels;
|
628 | },
|
629 | enumerable: true,
|
630 | configurable: true
|
631 | });
|
632 | /**
|
633 | * Returns a new label element, suitable for this Axis Renderer type.
|
634 | *
|
635 | * @return Label element
|
636 | */
|
637 | AxisRenderer.prototype.createLabel = function () {
|
638 | return new AxisLabel();
|
639 | };
|
640 | Object.defineProperty(AxisRenderer.prototype, "inside", {
|
641 | /**
|
642 | * @return Labels inside?
|
643 | */
|
644 | get: function () {
|
645 | return this.getPropertyValue("inside");
|
646 | },
|
647 | /**
|
648 | * Indicates whether Axis' labels and ticks should be drawn inside Plot area.
|
649 | *
|
650 | * Does not work with all renderers, like AxisRendererRadial.
|
651 | *
|
652 | * @param value Labels inside?
|
653 | */
|
654 | set: function (value) {
|
655 | if (this.setPropertyValue("inside", value)) {
|
656 | if (this.axis) {
|
657 | this.axis.invalidate();
|
658 | }
|
659 | }
|
660 | if (value) {
|
661 | this.width = 0;
|
662 | this.height = 0;
|
663 | }
|
664 | else {
|
665 | this.width = undefined;
|
666 | this.height = undefined;
|
667 | }
|
668 | },
|
669 | enumerable: true,
|
670 | configurable: true
|
671 | });
|
672 | Object.defineProperty(AxisRenderer.prototype, "opposite", {
|
673 | /**
|
674 | * @return Draw axis on opposite side?
|
675 | */
|
676 | get: function () {
|
677 | return this.getPropertyValue("opposite");
|
678 | },
|
679 | /**
|
680 | * Indicates whether Axis should be drawn on the opposite side of the plot
|
681 | * area than it would normally be drawn based on chart's settings.
|
682 | *
|
683 | * Does not work with all renderers, like [[AxisRendererRadial]] and
|
684 | * [[AxisRenderer Circular].
|
685 | *
|
686 | * @param value Draw axis on opposite side?
|
687 | */
|
688 | set: function (value) {
|
689 | this.setPropertyValue("opposite", value);
|
690 | },
|
691 | enumerable: true,
|
692 | configurable: true
|
693 | });
|
694 | Object.defineProperty(AxisRenderer.prototype, "fullWidthTooltip", {
|
695 | /**
|
696 | * @return Full width tooltip?
|
697 | */
|
698 | get: function () {
|
699 | return this.getPropertyValue("fullWidthTooltip");
|
700 | },
|
701 | /**
|
702 | * Indicates if Axis tooltip should take the whole width of the axis cell.
|
703 | * (between two grid lines)
|
704 | *
|
705 | * NOTE: this setting is ignored on circular axis types.
|
706 | *
|
707 | * @param value Full width tooltip?
|
708 | */
|
709 | set: function (value) {
|
710 | this.setPropertyValue("fullWidthTooltip", value);
|
711 | },
|
712 | enumerable: true,
|
713 | configurable: true
|
714 | });
|
715 | Object.defineProperty(AxisRenderer.prototype, "tooltipLocation", {
|
716 | /**
|
717 | * @return Tooltip location
|
718 | */
|
719 | get: function () {
|
720 | return this.getPropertyValue("tooltipLocation");
|
721 | },
|
722 | /**
|
723 | * Location within axis cell to show tooltip on. (0-1)
|
724 | *
|
725 | * 0 - show at the start
|
726 | * 0.5 - show right in the middle
|
727 | * 1 - show at the end
|
728 | *
|
729 | * @param value Tooltip location
|
730 | */
|
731 | set: function (value) {
|
732 | this.setPropertyValue("tooltipLocation", value);
|
733 | },
|
734 | enumerable: true,
|
735 | configurable: true
|
736 | });
|
737 | Object.defineProperty(AxisRenderer.prototype, "tooltipLocation2", {
|
738 | /**
|
739 | * @return Tooltip location
|
740 | */
|
741 | get: function () {
|
742 | return this.getPropertyValue("tooltipLocation2");
|
743 | },
|
744 | /**
|
745 | * Location within secondary axis cell to show tooltip on. (0-1)
|
746 | *
|
747 | * 0 - show at the start
|
748 | * 0.5 - show right in the middle
|
749 | * 1 - show at the end
|
750 | *
|
751 | * @param value Tooltip location
|
752 | */
|
753 | set: function (value) {
|
754 | this.setPropertyValue("tooltipLocation2", value);
|
755 | },
|
756 | enumerable: true,
|
757 | configurable: true
|
758 | });
|
759 | Object.defineProperty(AxisRenderer.prototype, "cellStartLocation", {
|
760 | /**
|
761 | * @return Cell start (0-1)
|
762 | */
|
763 | get: function () {
|
764 | return this.getPropertyValue("cellStartLocation");
|
765 | },
|
766 | /**
|
767 | * Location for the cell start.
|
768 | *
|
769 | * Normally a "cell" is the whole available width in a category.
|
770 | *
|
771 | * If there are several clustered column-like series available, the whole
|
772 | * space is divided between each clustered column, or column stacks.
|
773 | *
|
774 | * `cellStartLocation` identifies where, within available space, the actual
|
775 | * cell starts.
|
776 | *
|
777 | * This, together with column series' `width` will affect actual width of
|
778 | * columns, and thus gaps between them.
|
779 | *
|
780 | * This will affect category-like axes only, like [[DateAxis]], or
|
781 | * [[CategoryAxis]].
|
782 | *
|
783 | * This is used to limit a space occupied by series like column.
|
784 | *
|
785 | * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.
|
786 | * @param value Cell start (0-1)
|
787 | */
|
788 | set: function (value) {
|
789 | if (this.setPropertyValue("cellStartLocation", value)) {
|
790 | if (this.axis) {
|
791 | this.axis.invalidateSeries();
|
792 | }
|
793 | }
|
794 | },
|
795 | enumerable: true,
|
796 | configurable: true
|
797 | });
|
798 | Object.defineProperty(AxisRenderer.prototype, "cellEndLocation", {
|
799 | /**
|
800 | * @return Cell end (0-1)
|
801 | */
|
802 | get: function () {
|
803 | return this.getPropertyValue("cellEndLocation");
|
804 | },
|
805 | /**
|
806 | * Location for the cell end.
|
807 | *
|
808 | * Normally a "cell" is the whole available width in a category.
|
809 | *
|
810 | * If there are several clustered column-like series available, the whole
|
811 | * space is divided between each clustered column, or column stacks.
|
812 | *
|
813 | * `cellEndLocation` identifies where, within available space, the actual
|
814 | * cell ends.
|
815 | *
|
816 | * This, together with column series' `width` will affect actual width of
|
817 | * columns, and thus gaps between them.
|
818 | *
|
819 | * This will affect category-like axes only, like [[DateAxis]], or
|
820 | * [[CategoryAxis]].
|
821 | *
|
822 | * This is used to limit a space occupied by series like column.
|
823 | *
|
824 | * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.
|
825 | * @param value Cell end (0-1)
|
826 | */
|
827 | set: function (value) {
|
828 | if (this.setPropertyValue("cellEndLocation", value)) {
|
829 | if (this.axis) {
|
830 | this.axis.invalidateSeries();
|
831 | }
|
832 | }
|
833 | },
|
834 | enumerable: true,
|
835 | configurable: true
|
836 | });
|
837 | Object.defineProperty(AxisRenderer.prototype, "inversed", {
|
838 | /**
|
839 | * @return Flip axis?
|
840 | */
|
841 | get: function () {
|
842 | return this.getPropertyValue("inversed");
|
843 | },
|
844 | /**
|
845 | * Indicates if the scale of the axis should be flipped.
|
846 | *
|
847 | * @param value Flip axis?
|
848 | */
|
849 | set: function (value) {
|
850 | this.setPropertyValue("inversed", value);
|
851 | },
|
852 | enumerable: true,
|
853 | configurable: true
|
854 | });
|
855 | Object.defineProperty(AxisRenderer.prototype, "minLabelPosition", {
|
856 | /**
|
857 | * @return Min label position (0-1)
|
858 | */
|
859 | get: function () {
|
860 | return this.getPropertyValue("minLabelPosition");
|
861 | },
|
862 | /**
|
863 | * Minimum position along the Axis, for labels.
|
864 | *
|
865 | * Labels, which have their position closer to the start of the Axis, will be
|
866 | * automatically hidden.
|
867 | *
|
868 | * E.g., setting this to 0.05 (5% of total axis length) would hide labels,
|
869 | * that would otherwise be drawn very near start of the Axis.
|
870 | *
|
871 | * This is especially usefull with `inside = true`, or if the chart hasn't
|
872 | * got any extra margins.
|
873 | *
|
874 | * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.
|
875 | * @param value Min label position (0-1)
|
876 | */
|
877 | set: function (value) {
|
878 | this.setPropertyValue("minLabelPosition", value, true);
|
879 | },
|
880 | enumerable: true,
|
881 | configurable: true
|
882 | });
|
883 | Object.defineProperty(AxisRenderer.prototype, "maxLabelPosition", {
|
884 | /**
|
885 | * @return Max label position (0-1)
|
886 | */
|
887 | get: function () {
|
888 | return this.getPropertyValue("maxLabelPosition");
|
889 | },
|
890 | /**
|
891 | * Maximum position along the Axis, for labels.
|
892 | *
|
893 | * Labels, which have their position closer to the and of the Axis, will be
|
894 | * automatically hidden.
|
895 | *
|
896 | * E.g., setting this to 0.95 (95% of total axis length) would hide labels,
|
897 | * that would otherwise be drawn very near end of the Axis.
|
898 | *
|
899 | * This is especially usefull with `inside = true`, or if the chart hasn't
|
900 | * got any extra margins.
|
901 | *
|
902 | * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.
|
903 | * @param value Max label position (0-1)
|
904 | */
|
905 | set: function (value) {
|
906 | this.setPropertyValue("maxLabelPosition", value, true);
|
907 | },
|
908 | enumerable: true,
|
909 | configurable: true
|
910 | });
|
911 | /**
|
912 | * Copies all settings and related items from another object of the same
|
913 | * type.
|
914 | *
|
915 | * @param source Source object
|
916 | */
|
917 | AxisRenderer.prototype.copyFrom = function (source) {
|
918 | _super.prototype.copyFrom.call(this, source);
|
919 | this.grid.template.copyFrom(source.grid.template);
|
920 | this.ticks.template.copyFrom(source.ticks.template);
|
921 | this.labels.template.copyFrom(source.labels.template);
|
922 | this.axisFills.template.copyFrom(source.axisFills.template);
|
923 | this.line.copyFrom(source.line);
|
924 | this.baseGrid.copyFrom(source.baseGrid);
|
925 | };
|
926 | /**
|
927 | * @ignore
|
928 | */
|
929 | AxisRenderer.prototype.toAxisPosition = function (value) {
|
930 | return value;
|
931 | };
|
932 | /**
|
933 | * Sets `visibility` property:
|
934 | *
|
935 | * * `true` - visible
|
936 | * * `false` - hidden
|
937 | *
|
938 | * @param value true - visible, false - hidden
|
939 | * @return Current visibility
|
940 | */
|
941 | AxisRenderer.prototype.setVisibility = function (value) {
|
942 | _super.prototype.setVisibility.call(this, value);
|
943 | this.bulletsContainer.visible = value;
|
944 | };
|
945 | return AxisRenderer;
|
946 | }(Container));
|
947 | export { AxisRenderer };
|
948 | /**
|
949 | * Register class in system, so that it can be instantiated using its name from
|
950 | * anywhere.
|
951 | *
|
952 | * @ignore
|
953 | */
|
954 | registry.registeredClasses["AxisRenderer"] = AxisRenderer;
|
955 | //# sourceMappingURL=AxisRenderer.js.map |
\ | No newline at end of file |