1 | /**
|
2 | * A module defining functionality for axis grid elements.
|
3 | */
|
4 | import { __extends } from "tslib";
|
5 | /**
|
6 | * ============================================================================
|
7 | * IMPORTS
|
8 | * ============================================================================
|
9 | * @hidden
|
10 | */
|
11 | import { Sprite } from "../../core/Sprite";
|
12 | import { registry } from "../../core/Registry";
|
13 | import { color } from "../../core/utils/Color";
|
14 | import { InterfaceColorSet } from "../../core/utils/InterfaceColorSet";
|
15 | import { defaultRules, ResponsiveBreakpoints } from "../../core/utils/Responsive";
|
16 | /**
|
17 | * ============================================================================
|
18 | * MAIN CLASS
|
19 | * ============================================================================
|
20 | * @hidden
|
21 | */
|
22 | /**
|
23 | * Displays an axis grid line.
|
24 | *
|
25 | * @see {@link IGridEvents} for a list of available events
|
26 | * @see {@link IGridAdapters} for a list of available Adapters
|
27 | * @todo Review: container is better, as we'll be able to attach something to the grid, also with 3d charts we might need some additional elements
|
28 | * @important
|
29 | */
|
30 | var Grid = /** @class */ (function (_super) {
|
31 | __extends(Grid, _super);
|
32 | /**
|
33 | * Constructor
|
34 | */
|
35 | function Grid() {
|
36 | var _this = _super.call(this) || this;
|
37 | _this.className = "Grid";
|
38 | _this.element = _this.paper.add("path");
|
39 | _this.location = 0.5;
|
40 | _this.isMeasured = false;
|
41 | _this.above = false;
|
42 | var interfaceColors = new InterfaceColorSet();
|
43 | _this.stroke = interfaceColors.getFor("grid");
|
44 | _this.pixelPerfect = true;
|
45 | _this.strokeOpacity = 0.15;
|
46 | _this.fill = color(); // "none";
|
47 | _this.applyTheme();
|
48 | return _this;
|
49 | }
|
50 | Object.defineProperty(Grid.prototype, "location", {
|
51 | /**
|
52 | * @return Location (0-1)
|
53 | */
|
54 | get: function () {
|
55 | return this.getPropertyValue("location");
|
56 | },
|
57 | /**
|
58 | * Location within axis cell to place grid line on.
|
59 | *
|
60 | * * 0 - start
|
61 | * * 0.5 - middle
|
62 | * * 1 - end
|
63 | *
|
64 | * @param value Location (0-1)
|
65 | */
|
66 | set: function (value) {
|
67 | this.setPropertyValue("location", value, true);
|
68 | },
|
69 | enumerable: true,
|
70 | configurable: true
|
71 | });
|
72 | Object.defineProperty(Grid.prototype, "above", {
|
73 | /**
|
74 | * @return Draw above series?
|
75 | */
|
76 | get: function () {
|
77 | return this.getPropertyValue("above");
|
78 | },
|
79 | /**
|
80 | * Normally fill goes below series. Set this to `true` to go above.
|
81 | *
|
82 | * @default false
|
83 | * @since 4.5.9
|
84 | * @param value Draw above series?
|
85 | */
|
86 | set: function (value) {
|
87 | this.setPropertyValue("above", value, true);
|
88 | },
|
89 | enumerable: true,
|
90 | configurable: true
|
91 | });
|
92 | /**
|
93 | * @ignore
|
94 | */
|
95 | Grid.prototype.setDisabled = function (value) {
|
96 | var changed = _super.prototype.setDisabled.call(this, value);
|
97 | if (this.axis) {
|
98 | this.axis.invalidateDataItems();
|
99 | }
|
100 | return changed;
|
101 | };
|
102 | return Grid;
|
103 | }(Sprite));
|
104 | export { Grid };
|
105 | /**
|
106 | * Register class in system, so that it can be instantiated using its name from
|
107 | * anywhere.
|
108 | *
|
109 | * @ignore
|
110 | */
|
111 | registry.registeredClasses["Grid"] = Grid;
|
112 | /**
|
113 | * Add default responsive rules
|
114 | */
|
115 | /**
|
116 | * Disable grid on smaller charts
|
117 | */
|
118 | defaultRules.push({
|
119 | relevant: ResponsiveBreakpoints.maybeXS,
|
120 | state: function (target, stateId) {
|
121 | if (target instanceof Grid) {
|
122 | var state = target.states.create(stateId);
|
123 | state.properties.disabled = true;
|
124 | return state;
|
125 | }
|
126 | return null;
|
127 | }
|
128 | });
|
129 | //# sourceMappingURL=Grid.js.map |
\ | No newline at end of file |