@tetacom/svg-charts 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.browserslistrc +16 -0
  2. package/README.md +24 -0
  3. package/dist/README.md +24 -0
  4. package/dist/chart/base/series-base.component.d.ts +22 -0
  5. package/dist/chart/chart/chart.component.d.ts +29 -0
  6. package/dist/chart/chart-container/chart-container.component.d.ts +42 -0
  7. package/dist/chart/chart-container/gridlines/gridlines.component.d.ts +23 -0
  8. package/dist/chart/chart-container/plotband/plotband.component.d.ts +33 -0
  9. package/dist/chart/chart-container/plotline/plotline.component.d.ts +30 -0
  10. package/dist/chart/chart-container/series/bar/bar-series.component.d.ts +25 -0
  11. package/dist/chart/chart-container/series/line/line-series.component.d.ts +28 -0
  12. package/dist/chart/chart-container/series-host/series-host.component.d.ts +20 -0
  13. package/dist/chart/chart-container/tooltip/tooltip.component.d.ts +29 -0
  14. package/dist/chart/chart-container/x-axis/x-axis.component.d.ts +23 -0
  15. package/dist/chart/chart-container/y-axis/y-axis.component.d.ts +24 -0
  16. package/dist/chart/chart.module.d.ts +22 -0
  17. package/dist/chart/core/axis/axis.d.ts +54 -0
  18. package/dist/chart/core/axis/builders/axis-size-builder.d.ts +8 -0
  19. package/dist/chart/core/axis/builders/extremes-builder.d.ts +7 -0
  20. package/dist/chart/core/axis/builders/public-api.d.ts +2 -0
  21. package/dist/chart/core/utils/generate-ticks.d.ts +1 -0
  22. package/dist/chart/core/utils/get-text-width.d.ts +1 -0
  23. package/dist/chart/core/utils/public-api.d.ts +2 -0
  24. package/dist/chart/directives/brushable.directive.d.ts +17 -0
  25. package/dist/chart/directives/zoomable.directive.d.ts +20 -0
  26. package/dist/chart/legend/legend.component.d.ts +14 -0
  27. package/dist/chart/model/axis-options.d.ts +17 -0
  28. package/dist/chart/model/base-point.d.ts +9 -0
  29. package/dist/chart/model/chart-bounds.d.ts +12 -0
  30. package/dist/chart/model/enum/axis-orientation.d.ts +4 -0
  31. package/dist/chart/model/enum/axis-type.d.ts +7 -0
  32. package/dist/chart/model/enum/brush-type.d.ts +5 -0
  33. package/dist/chart/model/enum/drag-point-type.d.ts +5 -0
  34. package/dist/chart/model/enum/series-type.d.ts +4 -0
  35. package/dist/chart/model/enum/tooltip-tracking.d.ts +4 -0
  36. package/dist/chart/model/enum/zoom-type.d.ts +5 -0
  37. package/dist/chart/model/i-broadcast-message.d.ts +5 -0
  38. package/dist/chart/model/i-builder.d.ts +3 -0
  39. package/dist/chart/model/i-chart-config.d.ts +32 -0
  40. package/dist/chart/model/i-chart-event.d.ts +4 -0
  41. package/dist/chart/model/i-display-tooltip.d.ts +6 -0
  42. package/dist/chart/model/i-point-move.d.ts +6 -0
  43. package/dist/chart/model/marker-options.d.ts +7 -0
  44. package/dist/chart/model/plotband.d.ts +31 -0
  45. package/dist/chart/model/plotline.d.ts +19 -0
  46. package/dist/chart/model/series.d.ts +17 -0
  47. package/dist/chart/model/svg-attributes.d.ts +14 -0
  48. package/dist/chart/model/tooltip-options.d.ts +8 -0
  49. package/dist/chart/service/axes.service.d.ts +11 -0
  50. package/dist/chart/service/broadcast.service.d.ts +11 -0
  51. package/dist/chart/service/brush.service.d.ts +17 -0
  52. package/dist/chart/service/chart.service.d.ts +38 -0
  53. package/dist/chart/service/scale.service.d.ts +14 -0
  54. package/dist/chart/service/zoom.service.d.ts +25 -0
  55. package/dist/esm2020/chart/base/series-base.component.mjs +34 -0
  56. package/dist/esm2020/chart/chart/chart.component.mjs +73 -0
  57. package/dist/esm2020/chart/chart-container/chart-container.component.mjs +151 -0
  58. package/dist/esm2020/chart/chart-container/gridlines/gridlines.component.mjs +41 -0
  59. package/dist/esm2020/chart/chart-container/plotband/plotband.component.mjs +139 -0
  60. package/dist/esm2020/chart/chart-container/plotline/plotline.component.mjs +79 -0
  61. package/dist/esm2020/chart/chart-container/series/bar/bar-series.component.mjs +48 -0
  62. package/dist/esm2020/chart/chart-container/series/line/line-series.component.mjs +148 -0
  63. package/dist/esm2020/chart/chart-container/series-host/series-host.component.mjs +59 -0
  64. package/dist/esm2020/chart/chart-container/tooltip/tooltip.component.mjs +81 -0
  65. package/dist/esm2020/chart/chart-container/x-axis/x-axis.component.mjs +56 -0
  66. package/dist/esm2020/chart/chart-container/y-axis/y-axis.component.mjs +63 -0
  67. package/dist/esm2020/chart/chart.module.mjs +62 -0
  68. package/dist/esm2020/chart/core/axis/axis.mjs +96 -0
  69. package/dist/esm2020/chart/core/axis/builders/axis-size-builder.mjs +24 -0
  70. package/dist/esm2020/chart/core/axis/builders/extremes-builder.mjs +32 -0
  71. package/dist/esm2020/chart/core/axis/builders/public-api.mjs +3 -0
  72. package/dist/esm2020/chart/core/utils/generate-ticks.mjs +11 -0
  73. package/dist/esm2020/chart/core/utils/get-text-width.mjs +6 -0
  74. package/dist/esm2020/chart/core/utils/public-api.mjs +3 -0
  75. package/dist/esm2020/chart/directives/brushable.directive.mjs +28 -0
  76. package/dist/esm2020/chart/directives/zoomable.directive.mjs +37 -0
  77. package/dist/esm2020/chart/legend/legend.component.mjs +30 -0
  78. package/dist/esm2020/chart/model/axis-options.mjs +2 -0
  79. package/dist/esm2020/chart/model/base-point.mjs +2 -0
  80. package/dist/esm2020/chart/model/chart-bounds.mjs +13 -0
  81. package/dist/esm2020/chart/model/enum/axis-orientation.mjs +6 -0
  82. package/dist/esm2020/chart/model/enum/axis-type.mjs +9 -0
  83. package/dist/esm2020/chart/model/enum/brush-type.mjs +7 -0
  84. package/dist/esm2020/chart/model/enum/drag-point-type.mjs +7 -0
  85. package/dist/esm2020/chart/model/enum/series-type.mjs +6 -0
  86. package/dist/esm2020/chart/model/enum/tooltip-tracking.mjs +6 -0
  87. package/dist/esm2020/chart/model/enum/zoom-type.mjs +7 -0
  88. package/dist/esm2020/chart/model/i-broadcast-message.mjs +2 -0
  89. package/dist/esm2020/chart/model/i-builder.mjs +2 -0
  90. package/dist/esm2020/chart/model/i-chart-config.mjs +2 -0
  91. package/dist/esm2020/chart/model/i-chart-event.mjs +2 -0
  92. package/dist/esm2020/chart/model/i-display-tooltip.mjs +2 -0
  93. package/dist/esm2020/chart/model/i-point-move.mjs +2 -0
  94. package/dist/esm2020/chart/model/marker-options.mjs +2 -0
  95. package/dist/esm2020/chart/model/plotband.mjs +16 -0
  96. package/dist/esm2020/chart/model/plotline.mjs +12 -0
  97. package/dist/esm2020/chart/model/series.mjs +2 -0
  98. package/dist/esm2020/chart/model/svg-attributes.mjs +2 -0
  99. package/dist/esm2020/chart/model/tooltip-options.mjs +2 -0
  100. package/dist/esm2020/chart/service/axes.service.mjs +29 -0
  101. package/dist/esm2020/chart/service/broadcast.service.mjs +25 -0
  102. package/dist/esm2020/chart/service/brush.service.mjs +67 -0
  103. package/dist/esm2020/chart/service/chart.service.mjs +76 -0
  104. package/dist/esm2020/chart/service/scale.service.mjs +64 -0
  105. package/dist/esm2020/chart/service/zoom.service.mjs +117 -0
  106. package/dist/esm2020/public-api.mjs +7 -0
  107. package/dist/esm2020/tetacom-svg-charts.mjs +5 -0
  108. package/dist/fesm2015/tetacom-svg-charts.mjs +1589 -0
  109. package/dist/fesm2015/tetacom-svg-charts.mjs.map +1 -0
  110. package/dist/fesm2020/tetacom-svg-charts.mjs +1575 -0
  111. package/dist/fesm2020/tetacom-svg-charts.mjs.map +1 -0
  112. package/dist/package.json +35 -0
  113. package/dist/public-api.d.ts +3 -0
  114. package/dist/tetacom-svg-charts.d.ts +5 -0
  115. package/karma.conf.js +44 -0
  116. package/ng-package.json +7 -0
  117. package/package.json +15 -0
  118. package/src/chart/Chart.stories.ts +397 -0
  119. package/src/chart/base/series-base.component.ts +41 -0
  120. package/src/chart/chart/chart.component.html +5 -0
  121. package/src/chart/chart/chart.component.scss +6 -0
  122. package/src/chart/chart/chart.component.spec.ts +25 -0
  123. package/src/chart/chart/chart.component.ts +97 -0
  124. package/src/chart/chart-container/chart-container.component.html +78 -0
  125. package/src/chart/chart-container/chart-container.component.scss +15 -0
  126. package/src/chart/chart-container/chart-container.component.spec.ts +25 -0
  127. package/src/chart/chart-container/chart-container.component.ts +242 -0
  128. package/src/chart/chart-container/gridlines/gridlines.component.html +7 -0
  129. package/src/chart/chart-container/gridlines/gridlines.component.scss +8 -0
  130. package/src/chart/chart-container/gridlines/gridlines.component.spec.ts +25 -0
  131. package/src/chart/chart-container/gridlines/gridlines.component.ts +55 -0
  132. package/src/chart/chart-container/plotband/plotband.component.html +58 -0
  133. package/src/chart/chart-container/plotband/plotband.component.scss +13 -0
  134. package/src/chart/chart-container/plotband/plotband.component.spec.ts +25 -0
  135. package/src/chart/chart-container/plotband/plotband.component.ts +206 -0
  136. package/src/chart/chart-container/plotline/plotline.component.html +22 -0
  137. package/src/chart/chart-container/plotline/plotline.component.scss +6 -0
  138. package/src/chart/chart-container/plotline/plotline.component.spec.ts +25 -0
  139. package/src/chart/chart-container/plotline/plotline.component.ts +113 -0
  140. package/src/chart/chart-container/series/bar/bar-series.component.html +3 -0
  141. package/src/chart/chart-container/series/bar/bar-series.component.scss +0 -0
  142. package/src/chart/chart-container/series/bar/bar-series.component.ts +71 -0
  143. package/src/chart/chart-container/series/line/line-series.component.html +38 -0
  144. package/src/chart/chart-container/series/line/line-series.component.scss +9 -0
  145. package/src/chart/chart-container/series/line/line-series.component.spec.ts +25 -0
  146. package/src/chart/chart-container/series/line/line-series.component.ts +245 -0
  147. package/src/chart/chart-container/series-host/series-host.component.ts +80 -0
  148. package/src/chart/chart-container/tooltip/tooltip.component.html +14 -0
  149. package/src/chart/chart-container/tooltip/tooltip.component.scss +7 -0
  150. package/src/chart/chart-container/tooltip/tooltip.component.spec.ts +25 -0
  151. package/src/chart/chart-container/tooltip/tooltip.component.ts +134 -0
  152. package/src/chart/chart-container/x-axis/x-axis.component.html +1 -0
  153. package/src/chart/chart-container/x-axis/x-axis.component.scss +3 -0
  154. package/src/chart/chart-container/x-axis/x-axis.component.spec.ts +25 -0
  155. package/src/chart/chart-container/x-axis/x-axis.component.ts +80 -0
  156. package/src/chart/chart-container/y-axis/y-axis.component.html +4 -0
  157. package/src/chart/chart-container/y-axis/y-axis.component.scss +13 -0
  158. package/src/chart/chart-container/y-axis/y-axis.component.spec.ts +25 -0
  159. package/src/chart/chart-container/y-axis/y-axis.component.ts +90 -0
  160. package/src/chart/chart.module.ts +40 -0
  161. package/src/chart/core/axis/axis.ts +132 -0
  162. package/src/chart/core/axis/builders/axis-size-builder.ts +37 -0
  163. package/src/chart/core/axis/builders/extremes-builder.ts +45 -0
  164. package/src/chart/core/axis/builders/public-api.ts +2 -0
  165. package/src/chart/core/utils/generate-ticks.ts +14 -0
  166. package/src/chart/core/utils/get-text-width.ts +10 -0
  167. package/src/chart/core/utils/public-api.ts +2 -0
  168. package/src/chart/default/default-chart-config.ts +12 -0
  169. package/src/chart/directives/brushable.directive.ts +30 -0
  170. package/src/chart/directives/zoomable.directive.ts +31 -0
  171. package/src/chart/legend/legend.component.html +6 -0
  172. package/src/chart/legend/legend.component.scss +20 -0
  173. package/src/chart/legend/legend.component.spec.ts +25 -0
  174. package/src/chart/legend/legend.component.ts +35 -0
  175. package/src/chart/model/axis-options.ts +18 -0
  176. package/src/chart/model/base-point.ts +10 -0
  177. package/src/chart/model/chart-bounds.ts +18 -0
  178. package/src/chart/model/enum/axis-orientation.ts +4 -0
  179. package/src/chart/model/enum/axis-type.ts +7 -0
  180. package/src/chart/model/enum/brush-type.ts +5 -0
  181. package/src/chart/model/enum/drag-point-type.ts +5 -0
  182. package/src/chart/model/enum/public-api.ts +7 -0
  183. package/src/chart/model/enum/series-type.ts +4 -0
  184. package/src/chart/model/enum/tooltip-tracking.ts +4 -0
  185. package/src/chart/model/enum/zoom-type.ts +5 -0
  186. package/src/chart/model/i-broadcast-message.ts +5 -0
  187. package/src/chart/model/i-builder.ts +3 -0
  188. package/src/chart/model/i-chart-config.ts +33 -0
  189. package/src/chart/model/i-chart-event.ts +4 -0
  190. package/src/chart/model/i-display-tooltip.ts +7 -0
  191. package/src/chart/model/i-drag-event.ts +5 -0
  192. package/src/chart/model/i-point-move.ts +7 -0
  193. package/src/chart/model/marker-options.ts +8 -0
  194. package/src/chart/model/plotband.ts +45 -0
  195. package/src/chart/model/plotline.ts +29 -0
  196. package/src/chart/model/public-api.ts +0 -0
  197. package/src/chart/model/series.ts +18 -0
  198. package/src/chart/model/svg-attributes.ts +14 -0
  199. package/src/chart/model/tooltip-options.ts +37 -0
  200. package/src/chart/service/axes.service.spec.ts +16 -0
  201. package/src/chart/service/axes.service.ts +27 -0
  202. package/src/chart/service/broadcast.service.spec.ts +16 -0
  203. package/src/chart/service/broadcast.service.ts +24 -0
  204. package/src/chart/service/brush.service.spec.ts +16 -0
  205. package/src/chart/service/brush.service.ts +87 -0
  206. package/src/chart/service/chart.service.spec.ts +16 -0
  207. package/src/chart/service/chart.service.ts +100 -0
  208. package/src/chart/service/scale.service.spec.ts +16 -0
  209. package/src/chart/service/scale.service.ts +74 -0
  210. package/src/chart/service/zoom.service.spec.ts +16 -0
  211. package/src/chart/service/zoom.service.ts +153 -0
  212. package/src/public-api.ts +7 -0
  213. package/src/test.ts +27 -0
  214. package/tsconfig.lib.json +15 -0
  215. package/tsconfig.lib.prod.json +10 -0
  216. package/tsconfig.spec.json +17 -0
@@ -0,0 +1,1589 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component, Input, ChangeDetectionStrategy, ViewChild, ChangeDetectorRef, Directive, HostBinding, EventEmitter, Output, NgModule } from '@angular/core';
3
+ import * as i4 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { Subject, map, filter, merge, of, tap, takeWhile } from 'rxjs';
6
+ import * as d3 from 'd3';
7
+ import { zoomIdentity } from 'd3';
8
+ import { maxIndex } from 'd3-array';
9
+ import { throttleTime } from 'rxjs/operators';
10
+ import * as i3 from '@angular/platform-browser';
11
+
12
+ var AxisOrientation;
13
+ (function (AxisOrientation) {
14
+ AxisOrientation[AxisOrientation["x"] = 0] = "x";
15
+ AxisOrientation[AxisOrientation["y"] = 1] = "y";
16
+ })(AxisOrientation || (AxisOrientation = {}));
17
+
18
+ const getTextWidth = (inputText, backupRatio = 0.5, fontSize = 11) => {
19
+ let text = inputText !== null && inputText !== void 0 ? inputText : '';
20
+ text = text.toString();
21
+ return fontSize * backupRatio * text.length;
22
+ };
23
+
24
+ function generateTicks(extremes) {
25
+ const [min, max] = extremes;
26
+ const tickCount = 10;
27
+ const tickStep = (max - min) / tickCount;
28
+ const ticks = d3
29
+ .range(min, max + tickStep, tickStep)
30
+ .filter((step) => step <= max);
31
+ return ticks;
32
+ }
33
+
34
+ class AxisSizeBuilder {
35
+ constructor() {
36
+ this.titlePadding = 8;
37
+ this.basePadding = 16;
38
+ this.backupRatio = 0.58;
39
+ }
40
+ build(settings) {
41
+ let finalPadding = this.basePadding;
42
+ if (settings.orientation === AxisOrientation.y) {
43
+ const formatter = settings.defaultFormatter();
44
+ finalPadding += settings.options.title ? this.titlePadding : 0;
45
+ const maxElementLengthIndex = maxIndex(settings.tickValues, (_) => formatter(_).length);
46
+ finalPadding += getTextWidth(formatter(settings.tickValues[maxElementLengthIndex]), this.backupRatio);
47
+ }
48
+ if (settings.orientation === AxisOrientation.x) {
49
+ finalPadding += finalPadding + 20;
50
+ }
51
+ return finalPadding;
52
+ }
53
+ }
54
+
55
+ class ExtremesBuilder {
56
+ constructor() {
57
+ this.extentAccessorMap = new Map()
58
+ .set(AxisOrientation.x, (_) => _.x)
59
+ .set(AxisOrientation.y, (_) => _.y);
60
+ this.extremes = [0, 0];
61
+ }
62
+ build(settings) {
63
+ const options = settings.options;
64
+ const hasMin = (options === null || options === void 0 ? void 0 : options.min) != null;
65
+ const hasMax = (options === null || options === void 0 ? void 0 : options.max) != null;
66
+ if (!hasMin || !hasMax) {
67
+ const linkedSeries = settings.linkedSeries();
68
+ const data = linkedSeries.reduce((acc, current) => {
69
+ return acc.concat(current.data);
70
+ }, []);
71
+ const accessor = this.extentAccessorMap.get(settings.orientation);
72
+ // add negative axis!
73
+ this.extremes = d3.extent(data, accessor);
74
+ }
75
+ if (hasMin) {
76
+ this.extremes[0] = options === null || options === void 0 ? void 0 : options.min;
77
+ }
78
+ if (hasMax) {
79
+ this.extremes[1] = options === null || options === void 0 ? void 0 : options.max;
80
+ }
81
+ return this.extremes;
82
+ }
83
+ }
84
+
85
+ var AxisType;
86
+ (function (AxisType) {
87
+ AxisType[AxisType["number"] = 0] = "number";
88
+ AxisType[AxisType["time"] = 1] = "time";
89
+ AxisType[AxisType["category"] = 2] = "category";
90
+ AxisType[AxisType["log"] = 3] = "log";
91
+ AxisType[AxisType["pow"] = 4] = "pow";
92
+ })(AxisType || (AxisType = {}));
93
+
94
+ class Axis {
95
+ constructor(config) {
96
+ this._extremes = [0, 0];
97
+ this.defaultFormatters = new Map()
98
+ .set(AxisType.number, d3.format(',.2f'))
99
+ .set(AxisType.time, d3.timeFormat('%B %d, %Y'))
100
+ .set(AxisType.log, d3.format(',.2f'));
101
+ this.chartConfig = config;
102
+ }
103
+ /**
104
+ * Factory for creating x,y axes
105
+ * @param {AxisOrientation} orientation
106
+ * Axis type
107
+ * @param {IChartConfig} config
108
+ * Chart config
109
+ * @param {number} index
110
+ * Index axis
111
+ * @return {Axis}
112
+ * New generated axis
113
+ */
114
+ static createAxis(orientation, config, index) {
115
+ const axis = new Axis(config);
116
+ axis.setLocate(orientation);
117
+ axis.setIndex(index);
118
+ axis.setExtremes();
119
+ axis.setTicksValues();
120
+ axis.setSelfSize();
121
+ return axis;
122
+ }
123
+ /**
124
+ *
125
+ * @param {orientation} orientation
126
+ * Set locate axis x or y
127
+ */
128
+ setLocate(orientation) {
129
+ this._orientation = orientation;
130
+ }
131
+ /**
132
+ *
133
+ * @param {number | string} index
134
+ * Index axis
135
+ */
136
+ setIndex(index) {
137
+ this._index = index;
138
+ }
139
+ /**
140
+ * @return {Array<Series<BasePoint>>}
141
+ * Linked series
142
+ */
143
+ linkedSeries() {
144
+ var _a;
145
+ const linkedFilter = (serie) => serie[this._orientation === AxisOrientation.y ? 'yAxisIndex' : 'xAxisIndex'] === this._index;
146
+ return (_a = this.chartConfig) === null || _a === void 0 ? void 0 : _a.series.filter(linkedFilter);
147
+ }
148
+ setExtremes() {
149
+ const builder = new ExtremesBuilder();
150
+ this._extremes = builder.build(this);
151
+ this._extremes = d3.nice(this._extremes[0], this._extremes[1], 10);
152
+ }
153
+ setSelfSize() {
154
+ const builder = new AxisSizeBuilder();
155
+ this._selfSize = builder.build(this);
156
+ }
157
+ setTicksValues() {
158
+ const ticks = generateTicks(this._extremes);
159
+ this._ticksValues = ticks;
160
+ }
161
+ get extremes() {
162
+ return this._extremes;
163
+ }
164
+ get orientation() {
165
+ return this._orientation;
166
+ }
167
+ get selfSize() {
168
+ return this._selfSize;
169
+ }
170
+ get tickValues() {
171
+ return this._ticksValues;
172
+ }
173
+ get index() {
174
+ return this._index;
175
+ }
176
+ get options() {
177
+ return this.orientation === AxisOrientation.x
178
+ ? this.chartConfig.xAxis[this.index]
179
+ : this.chartConfig.yAxis[this.index];
180
+ }
181
+ defaultFormatter() {
182
+ return this.defaultFormatters.get(this.options.type);
183
+ }
184
+ }
185
+
186
+ class AxesService {
187
+ constructor() {
188
+ this.yAxis = new Map();
189
+ this.xAxis = new Map();
190
+ }
191
+ init(config) {
192
+ config === null || config === void 0 ? void 0 : config.yAxis.forEach((_, index) => {
193
+ const axis = Axis.createAxis(AxisOrientation.y, config, index);
194
+ this.yAxis.set(index, axis);
195
+ });
196
+ config === null || config === void 0 ? void 0 : config.xAxis.forEach((_, index) => {
197
+ const axis = Axis.createAxis(AxisOrientation.x, config, index);
198
+ this.xAxis.set(index, axis);
199
+ });
200
+ }
201
+ }
202
+ AxesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AxesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
203
+ AxesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AxesService, providedIn: 'root' });
204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AxesService, decorators: [{
205
+ type: Injectable,
206
+ args: [{
207
+ providedIn: 'root',
208
+ }]
209
+ }], ctorParameters: function () { return []; } });
210
+
211
+ class ScaleService {
212
+ constructor(axesService) {
213
+ this.axesService = axesService;
214
+ this.yScales = new Map();
215
+ this.xScales = new Map();
216
+ this.scaleMapping = new Map()
217
+ .set(AxisType.number, d3.scaleLinear)
218
+ .set(AxisType.time, d3.scaleTime)
219
+ .set(AxisType.category, d3.scaleOrdinal)
220
+ .set(AxisType.log, d3.scaleLog);
221
+ }
222
+ createScales(size, config) {
223
+ this.yScales.clear();
224
+ this.xScales.clear();
225
+ const topBound = [...this.axesService.xAxis.values()]
226
+ .filter((_) => { var _a, _b; return ((_a = _.options) === null || _a === void 0 ? void 0 : _a.visible) && ((_b = _.options) === null || _b === void 0 ? void 0 : _b.opposite); })
227
+ .reduce((acc, cur) => acc + cur.selfSize, 0);
228
+ const bottomBound = [...this.axesService.xAxis.values()]
229
+ .filter((_) => { var _a, _b; return ((_a = _.options) === null || _a === void 0 ? void 0 : _a.visible) && ((_b = _.options) === null || _b === void 0 ? void 0 : _b.opposite) !== true; })
230
+ .reduce((acc, cur) => acc + cur.selfSize, 0);
231
+ const leftBound = [...this.axesService.yAxis.values()]
232
+ .filter((_) => { var _a; return ((_a = _.options) === null || _a === void 0 ? void 0 : _a.visible) && _.options.opposite !== true; })
233
+ .reduce((acc, cur) => acc + cur.selfSize, 0);
234
+ const rightBound = [...this.axesService.yAxis.values()]
235
+ .filter((_) => { var _a; return ((_a = _.options) === null || _a === void 0 ? void 0 : _a.visible) && _.options.opposite; })
236
+ .reduce((acc, cur) => acc + cur.selfSize, 0);
237
+ this.axesService.yAxis.forEach((axis) => {
238
+ const scale = this.getScale(axis).range([
239
+ 0,
240
+ size.height - topBound - bottomBound,
241
+ ]);
242
+ this.yScales.set(axis.index, scale);
243
+ });
244
+ this.axesService.xAxis.forEach((axis) => {
245
+ const scale = this.getScale(axis).range([
246
+ 0,
247
+ size.width - leftBound - rightBound,
248
+ ]);
249
+ this.xScales.set(axis.index, scale);
250
+ });
251
+ }
252
+ getScale(axis) {
253
+ var _a;
254
+ return this.scaleMapping
255
+ .get((_a = axis.options) === null || _a === void 0 ? void 0 : _a.type)()
256
+ .domain(axis.orientation === AxisOrientation.y
257
+ ? [...axis.extremes].reverse()
258
+ : axis.extremes);
259
+ }
260
+ }
261
+ ScaleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ScaleService, deps: [{ token: AxesService }], target: i0.ɵɵFactoryTarget.Injectable });
262
+ ScaleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ScaleService, providedIn: 'root' });
263
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ScaleService, decorators: [{
264
+ type: Injectable,
265
+ args: [{
266
+ providedIn: 'root',
267
+ }]
268
+ }], ctorParameters: function () { return [{ type: AxesService }]; } });
269
+
270
+ class ChartService {
271
+ constructor(axesService, scaleService) {
272
+ this.axesService = axesService;
273
+ this.scaleService = scaleService;
274
+ this.size$ = new Subject();
275
+ this.pointerMove$ = new Subject();
276
+ this.tooltips$ = new Subject();
277
+ this.plotbandMove$ = new Subject();
278
+ this.plotlineMove$ = new Subject();
279
+ this.pointMove$ = new Subject();
280
+ this.size = this.size$.asObservable();
281
+ this.pointerMove = this.pointerMove$.asObservable();
282
+ this.tooltips = this.tooltips$.asObservable();
283
+ this.plotbandMove = this.plotbandMove$.asObservable();
284
+ this.plotlineMove = this.plotlineMove$.asObservable();
285
+ this.pointMove = this.pointMove$.asObservable();
286
+ this.size
287
+ .pipe(map((size) => {
288
+ this.scaleService.createScales(size, this._config);
289
+ }))
290
+ .subscribe();
291
+ }
292
+ init(config) {
293
+ var _a, _b;
294
+ this._config = config;
295
+ if (config.inverted) {
296
+ this._config.series = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.map((serie) => {
297
+ var _a;
298
+ return Object.assign(Object.assign({}, serie), { data: (_a = serie === null || serie === void 0 ? void 0 : serie.data) === null || _a === void 0 ? void 0 : _a.map((point) => {
299
+ return Object.assign(Object.assign({}, point), { x: point === null || point === void 0 ? void 0 : point.y, y: point === null || point === void 0 ? void 0 : point.x });
300
+ }) });
301
+ });
302
+ }
303
+ this.axesService.init(this._config);
304
+ }
305
+ setSize(size) {
306
+ this.size$.next(size);
307
+ }
308
+ setPointerMove(event) {
309
+ this.pointerMove$.next({ event });
310
+ }
311
+ setTooltip(tooltip) {
312
+ this.tooltips$.next(tooltip);
313
+ }
314
+ emitPlotband(event) {
315
+ this.plotbandMove$.next(event);
316
+ }
317
+ emitPlotline(event) {
318
+ this.plotlineMove$.next(event);
319
+ }
320
+ emitPoint(event) {
321
+ this.pointMove$.next(event);
322
+ }
323
+ get config() {
324
+ return this._config;
325
+ }
326
+ }
327
+ ChartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartService, deps: [{ token: AxesService }, { token: ScaleService }], target: i0.ɵɵFactoryTarget.Injectable });
328
+ ChartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartService, providedIn: 'root' });
329
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartService, decorators: [{
330
+ type: Injectable,
331
+ args: [{
332
+ providedIn: 'root',
333
+ }]
334
+ }], ctorParameters: function () { return [{ type: AxesService }, { type: ScaleService }]; } });
335
+
336
+ var ZoomType;
337
+ (function (ZoomType) {
338
+ ZoomType[ZoomType["x"] = 0] = "x";
339
+ ZoomType[ZoomType["y"] = 1] = "y";
340
+ ZoomType[ZoomType["xy"] = 2] = "xy";
341
+ })(ZoomType || (ZoomType = {}));
342
+
343
+ var BrushType;
344
+ (function (BrushType) {
345
+ BrushType[BrushType["x"] = 0] = "x";
346
+ BrushType[BrushType["y"] = 1] = "y";
347
+ BrushType[BrushType["xy"] = 2] = "xy";
348
+ })(BrushType || (BrushType = {}));
349
+
350
+ class BroadcastService {
351
+ constructor() {
352
+ this.emitter = new Subject();
353
+ }
354
+ broadcast(value) {
355
+ this.emitter.next(value);
356
+ }
357
+ subscribeToChannel(channel) {
358
+ return this.emitter
359
+ .asObservable()
360
+ .pipe(filter((msg) => channel && msg.channel === channel));
361
+ }
362
+ }
363
+ BroadcastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BroadcastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
364
+ BroadcastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BroadcastService, providedIn: 'root' });
365
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BroadcastService, decorators: [{
366
+ type: Injectable,
367
+ args: [{
368
+ providedIn: 'root',
369
+ }]
370
+ }], ctorParameters: function () { return []; } });
371
+
372
+ class ZoomService {
373
+ constructor(scaleService, broadcastService, chartService) {
374
+ this.scaleService = scaleService;
375
+ this.broadcastService = broadcastService;
376
+ this.chartService = chartService;
377
+ this.zoomed$ = new Subject();
378
+ this.x = new Map();
379
+ this.y = new Map();
380
+ this.initialZoom = zoomIdentity;
381
+ this.zoomed = this.zoomed$.asObservable();
382
+ merge(of(1), this.chartService.size)
383
+ .pipe(map((_) => {
384
+ this.x = new Map(this.scaleService.xScales);
385
+ this.y = new Map(this.scaleService.yScales);
386
+ if (this.svg) {
387
+ const currentTransform = d3.zoomTransform(this.svg.node());
388
+ this.setZoom(currentTransform);
389
+ }
390
+ }))
391
+ .subscribe();
392
+ }
393
+ applyZoom(svgElement, config, size) {
394
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
395
+ (_a = this.broadcastSubscribtion) === null || _a === void 0 ? void 0 : _a.unsubscribe();
396
+ this.svg = d3.select(svgElement.nativeElement);
397
+ const zoomType = (_b = config === null || config === void 0 ? void 0 : config.zoom) === null || _b === void 0 ? void 0 : _b.type;
398
+ const enable = (_c = config === null || config === void 0 ? void 0 : config.zoom) === null || _c === void 0 ? void 0 : _c.enable;
399
+ const zoomed = (event) => {
400
+ var _a, _b, _c, _d;
401
+ const { transform } = event;
402
+ if (zoomType === ZoomType.x || zoomType === ZoomType.xy) {
403
+ for (let [index, scale] of this.x.entries()) {
404
+ this.scaleService.xScales.set(index, transform.rescaleX(scale));
405
+ }
406
+ }
407
+ if (zoomType === ZoomType.y || zoomType === ZoomType.xy) {
408
+ for (let [index, scale] of this.y.entries()) {
409
+ this.scaleService.yScales.set(index, transform.rescaleY(scale));
410
+ }
411
+ }
412
+ if (enable) {
413
+ this.zoomed$.next({ event });
414
+ if (event.sourceEvent) {
415
+ this.broadcastService.broadcast({
416
+ channel: (_a = config === null || config === void 0 ? void 0 : config.zoom) === null || _a === void 0 ? void 0 : _a.syncChannel,
417
+ message: event,
418
+ domain: this.scaleService[((_b = config === null || config === void 0 ? void 0 : config.zoom) === null || _b === void 0 ? void 0 : _b.type) === ZoomType.x ? 'xScales' : 'yScales']
419
+ .get((_d = (_c = config.brush) === null || _c === void 0 ? void 0 : _c.axisIndex) !== null && _d !== void 0 ? _d : 0)
420
+ .domain(),
421
+ });
422
+ }
423
+ }
424
+ };
425
+ if (enable) {
426
+ this.zoom = d3
427
+ .zoom()
428
+ .scaleExtent([1, Infinity])
429
+ .extent([
430
+ [0, 0],
431
+ [size.width, size.height],
432
+ ]);
433
+ this.zoom.on('start zoom end', zoomed);
434
+ this.svg.call(this.zoom);
435
+ this.svg.call(this.zoom.transform, this.initialZoom);
436
+ const sc = ((_d = config === null || config === void 0 ? void 0 : config.zoom) === null || _d === void 0 ? void 0 : _d.type) === ZoomType.x
437
+ ? this.x.get((_f = (_e = config.brush) === null || _e === void 0 ? void 0 : _e.axisIndex) !== null && _f !== void 0 ? _f : 0)
438
+ : this.y.get((_h = (_g = config.brush) === null || _g === void 0 ? void 0 : _g.axisIndex) !== null && _h !== void 0 ? _h : 0);
439
+ this.broadcastSubscribtion = this.broadcastService
440
+ .subscribeToChannel((_j = config === null || config === void 0 ? void 0 : config.zoom) === null || _j === void 0 ? void 0 : _j.syncChannel)
441
+ .pipe(map((_) => {
442
+ const currentTransform = d3.zoomTransform(this.svg.node());
443
+ const { message } = _;
444
+ if (currentTransform !== (message === null || message === void 0 ? void 0 : message.transform)) {
445
+ if (message.selection) {
446
+ const s = message.selection;
447
+ const domain = sc.domain();
448
+ const scale = (domain[1] - domain[0]) / (s[1] - s[0]);
449
+ let transform = zoomIdentity.scale(scale);
450
+ if ((message === null || message === void 0 ? void 0 : message.brushType) === BrushType.x) {
451
+ transform = transform.translate(-sc(s[0]), 0);
452
+ }
453
+ if ((message === null || message === void 0 ? void 0 : message.brushType) === BrushType.y) {
454
+ transform = transform.translate(0, -sc(s[0]));
455
+ }
456
+ this.setZoom(transform);
457
+ return;
458
+ }
459
+ this.setZoom(message === null || message === void 0 ? void 0 : message.transform);
460
+ }
461
+ }))
462
+ .subscribe();
463
+ }
464
+ }
465
+ setZoom(transform) {
466
+ var _a;
467
+ // requestAnimationFrame(() => {
468
+ //
469
+ // });
470
+ (_a = this.svg) === null || _a === void 0 ? void 0 : _a.call(this.zoom.transform, transform);
471
+ }
472
+ }
473
+ ZoomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ZoomService, deps: [{ token: ScaleService }, { token: BroadcastService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Injectable });
474
+ ZoomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ZoomService, providedIn: 'root' });
475
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ZoomService, decorators: [{
476
+ type: Injectable,
477
+ args: [{
478
+ providedIn: 'root',
479
+ }]
480
+ }], ctorParameters: function () { return [{ type: ScaleService }, { type: BroadcastService }, { type: ChartService }]; } });
481
+
482
+ class BrushService {
483
+ constructor(broadcastService, scaleService) {
484
+ this.broadcastService = broadcastService;
485
+ this.scaleService = scaleService;
486
+ this.brushMap = new Map()
487
+ .set(BrushType.x, d3.brushX())
488
+ .set(BrushType.y, d3.brushY());
489
+ this.scaleMap = new Map()
490
+ .set(BrushType.x, 'xScales')
491
+ .set(BrushType.y, 'yScales');
492
+ }
493
+ applyBrush(svgElement, config, size) {
494
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
495
+ (_a = this.broadcastSubscribtion) === null || _a === void 0 ? void 0 : _a.unsubscribe();
496
+ if ((_b = config.brush) === null || _b === void 0 ? void 0 : _b.enable) {
497
+ const s = this.scaleService[this.scaleMap.get((_d = (_c = config === null || config === void 0 ? void 0 : config.brush) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : BrushType.x)].get((_f = (_e = config === null || config === void 0 ? void 0 : config.brush) === null || _e === void 0 ? void 0 : _e.axisIndex) !== null && _f !== void 0 ? _f : 0);
498
+ const brush = this.brushMap.get((_h = (_g = config === null || config === void 0 ? void 0 : config.brush) === null || _g === void 0 ? void 0 : _g.type) !== null && _h !== void 0 ? _h : BrushType.x);
499
+ const container = d3.select(svgElement.nativeElement);
500
+ const brushBehavior = brush.on('start brush end', (_) => {
501
+ var _a, _b, _c;
502
+ if (_.sourceEvent) {
503
+ const [from, to] = _.selection;
504
+ if (to - from < 5) {
505
+ container.call(brush.move, [from, to]);
506
+ return;
507
+ }
508
+ this.broadcastService.broadcast({
509
+ channel: (_a = config === null || config === void 0 ? void 0 : config.zoom) === null || _a === void 0 ? void 0 : _a.syncChannel,
510
+ message: Object.assign(Object.assign({}, _), { selection: [s.invert(from), s.invert(to)], brushType: (_c = (_b = config === null || config === void 0 ? void 0 : config.brush) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : BrushType.x }),
511
+ });
512
+ }
513
+ });
514
+ container.call(brushBehavior);
515
+ setTimeout(() => {
516
+ container.call(brush.move, s.domain().map(s), {});
517
+ });
518
+ this.broadcastSubscribtion = this.broadcastService
519
+ .subscribeToChannel((_j = config === null || config === void 0 ? void 0 : config.zoom) === null || _j === void 0 ? void 0 : _j.syncChannel)
520
+ .pipe(map((_) => {
521
+ var _a, _b, _c, _d, _e;
522
+ if ((_a = _.message) === null || _a === void 0 ? void 0 : _a.transform) {
523
+ const s = this.scaleService[this.scaleMap.get((_c = (_b = config === null || config === void 0 ? void 0 : config.brush) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : BrushType.x)].get((_e = (_d = config === null || config === void 0 ? void 0 : config.brush) === null || _d === void 0 ? void 0 : _d.axisIndex) !== null && _e !== void 0 ? _e : 0);
524
+ const domain = _.domain;
525
+ container.call(brush.move, [s(domain[0]), s(domain[1])]);
526
+ }
527
+ }))
528
+ .subscribe();
529
+ }
530
+ }
531
+ }
532
+ BrushService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BrushService, deps: [{ token: BroadcastService }, { token: ScaleService }], target: i0.ɵɵFactoryTarget.Injectable });
533
+ BrushService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BrushService, providedIn: 'root' });
534
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BrushService, decorators: [{
535
+ type: Injectable,
536
+ args: [{
537
+ providedIn: 'root',
538
+ }]
539
+ }], ctorParameters: function () { return [{ type: BroadcastService }, { type: ScaleService }]; } });
540
+
541
+ class ChartBounds {
542
+ constructor(options) {
543
+ this.top = 0;
544
+ this.right = 30;
545
+ this.bottom = 0;
546
+ this.left = 0;
547
+ this.top = (options === null || options === void 0 ? void 0 : options.top) || this.top;
548
+ this.right = (options === null || options === void 0 ? void 0 : options.right) || this.right;
549
+ this.bottom = (options === null || options === void 0 ? void 0 : options.bottom) || this.bottom;
550
+ this.left = (options === null || options === void 0 ? void 0 : options.left) || this.left;
551
+ }
552
+ }
553
+
554
+ class TooltipComponent {
555
+ constructor(svc, cdr, zoomService, sanitizer) {
556
+ this.svc = svc;
557
+ this.cdr = cdr;
558
+ this.zoomService = zoomService;
559
+ this.sanitizer = sanitizer;
560
+ this.tooltips = [];
561
+ this.alive = true;
562
+ }
563
+ ngOnInit() {
564
+ var _a, _b;
565
+ this.display = merge(this.svc.pointerMove, this.zoomService.zoomed).pipe(map(({ event }) => {
566
+ const opacity = (event === null || event === void 0 ? void 0 : event.type) === 'mousemove' ? 1 : 0;
567
+ return opacity;
568
+ }), tap(() => {
569
+ requestAnimationFrame(() => {
570
+ this.cdr.detectChanges();
571
+ });
572
+ }));
573
+ this.position = this.svc.pointerMove.pipe(filter(({ event }) => event), map((_) => {
574
+ return this.getPoisition(_);
575
+ }), tap((_) => this.cdr.detectChanges()));
576
+ const transformHtml = (html) => {
577
+ return this.sanitizer.bypassSecurityTrustHtml(html);
578
+ };
579
+ const defaultFormatter = (tooltips) => {
580
+ let html = '';
581
+ tooltips.forEach((_) => {
582
+ var _a, _b, _c;
583
+ const indicatorStyle = `display:block; width: 10px; height: 2px; background-color: ${(_a = _ === null || _ === void 0 ? void 0 : _.series) === null || _a === void 0 ? void 0 : _a.color}`;
584
+ html += `<div class="display-flex align-center"><span class="margin-right-1" style="${indicatorStyle}"></span>
585
+ <span class="font-title-3">${_.series.name}
586
+ <span class="font-body-3">x: ${(_b = _.point.x) === null || _b === void 0 ? void 0 : _b.toFixed(2)} y: ${(_c = _.point.y) === null || _c === void 0 ? void 0 : _c.toFixed(2)}</span></span></div>`;
587
+ });
588
+ return transformHtml(html);
589
+ };
590
+ const formatter = (_b = (_a = this.svc.config) === null || _a === void 0 ? void 0 : _a.tooltip) === null || _b === void 0 ? void 0 : _b.format;
591
+ this.displayTooltips = merge(this.svc.pointerMove.pipe(tap((_) => (this.tooltips = []))), this.svc.tooltips).pipe(takeWhile((_) => this.alive), filter((_) => !_['event']), map((tooltip) => {
592
+ if (tooltip) {
593
+ this.tooltips.push(tooltip);
594
+ }
595
+ const formatted = formatter
596
+ ? formatter(this.tooltips)
597
+ : defaultFormatter(this.tooltips);
598
+ return formatted;
599
+ }));
600
+ }
601
+ getPoisition({ event }) {
602
+ const centerX = this.size.width / 2;
603
+ const centerY = this.size.height / 2;
604
+ const padding = { x: 10, y: 10 };
605
+ const scene = {
606
+ left: event.pageX > centerX ? 'initial' : `${event.pageX + padding.x}px`,
607
+ top: event.pageY > centerY ? 'initial' : `${event.pageY + padding.y}px`,
608
+ bottom: event.pageY > centerY
609
+ ? `${window.innerHeight - event.pageY}px`
610
+ : 'initial',
611
+ right: event.pageX > centerX
612
+ ? `${window.innerWidth - event.pageX + padding.x}px`
613
+ : 'initial',
614
+ };
615
+ return scene;
616
+ }
617
+ ngOnDestroy() {
618
+ this.alive = false;
619
+ }
620
+ }
621
+ TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: TooltipComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ZoomService }, { token: i3.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
622
+ TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: TooltipComponent, selector: "teta-tooltip", inputs: { size: "size" }, ngImport: i0, template: "<ng-container *ngIf=\"position | async as p\">\n\n <div class=\"chart-tooltip color-text-90 bg-background-50 shadow-2 padding-2 border-radius-1\"\n [style.position]=\"'fixed'\"\n [style.opacity]=\"display | async\"\n style=\"pointer-events: none;\"\n [style.left]=\"p.left\"\n [style.top]=\"p.top\"\n [style.bottom]=\"p.bottom\"\n [style.right]=\"p.right\"\n [innerHTML]=\"displayTooltips | async\">\n </div>\n</ng-container>\n\n", styles: [":host{position:absolute}.chart-tooltip{transition:all .1s ease}\n"], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i4.AsyncPipe } });
623
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: TooltipComponent, decorators: [{
624
+ type: Component,
625
+ args: [{ selector: 'teta-tooltip', template: "<ng-container *ngIf=\"position | async as p\">\n\n <div class=\"chart-tooltip color-text-90 bg-background-50 shadow-2 padding-2 border-radius-1\"\n [style.position]=\"'fixed'\"\n [style.opacity]=\"display | async\"\n style=\"pointer-events: none;\"\n [style.left]=\"p.left\"\n [style.top]=\"p.top\"\n [style.bottom]=\"p.bottom\"\n [style.right]=\"p.right\"\n [innerHTML]=\"displayTooltips | async\">\n </div>\n</ng-container>\n\n", styles: [":host{position:absolute}.chart-tooltip{transition:all .1s ease}\n"] }]
626
+ }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ZoomService }, { type: i3.DomSanitizer }]; }, propDecorators: { size: [{
627
+ type: Input
628
+ }] } });
629
+
630
+ class YAxisComponent {
631
+ constructor(scaleService, chartService, cdr, zoomService) {
632
+ this.scaleService = scaleService;
633
+ this.chartService = chartService;
634
+ this.cdr = cdr;
635
+ this.zoomService = zoomService;
636
+ this._alive = true;
637
+ merge(this.zoomService.zoomed, this.chartService.size)
638
+ .pipe(takeWhile(() => this._alive), tap((_) => {
639
+ this.draw();
640
+ this.cdr.markForCheck();
641
+ }))
642
+ .subscribe();
643
+ }
644
+ ngOnInit() { }
645
+ ngOnDestroy() {
646
+ this._alive = false;
647
+ }
648
+ ngAfterViewInit() {
649
+ this.draw();
650
+ }
651
+ getLabelTransform() {
652
+ return `translate(${this.axis.options.opposite
653
+ ? this.axis.selfSize - 24
654
+ : -this.axis.selfSize + 24}, ${this.size.height / 2}) rotate(${this.axis.options.opposite ? '90' : '-90'})`;
655
+ }
656
+ draw() {
657
+ var _a, _b;
658
+ const scale = this.scaleService.yScales.get(this.axis.index);
659
+ const axis = this.axis.options.opposite
660
+ ? d3
661
+ .axisRight(scale)
662
+ // .tickValues(this.axis.tickValues)
663
+ .tickFormat((_a = this.axis.options.tickFormat) !== null && _a !== void 0 ? _a : this.axis.defaultFormatter())
664
+ : d3
665
+ .axisLeft(scale)
666
+ // .tickValues(this.axis.tickValues)
667
+ .tickFormat((_b = this.axis.options.tickFormat) !== null && _b !== void 0 ? _b : this.axis.defaultFormatter());
668
+ d3.select(this.node.nativeElement)
669
+ .call(axis)
670
+ .call((_) => _.select('.domain').remove());
671
+ }
672
+ }
673
+ YAxisComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: YAxisComponent, deps: [{ token: ScaleService }, { token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ZoomService }], target: i0.ɵɵFactoryTarget.Component });
674
+ YAxisComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: YAxisComponent, selector: "[teta-y-axis]", inputs: { axis: "axis", size: "size" }, viewQueries: [{ propertyName: "node", first: true, predicate: ["svg"], descendants: true }], ngImport: i0, template: "<svg:g #svg></svg:g>\n<svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text dy=\"-8px\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n</svg:g>\n", styles: [":host{shape-rendering:crispEdges}::ng-deep .tick text{fill:var(--color-text-70)}::ng-deep .tick line{stroke:var(--color-text-20)}:host .label-axis{fill:var(--color-text-70)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: YAxisComponent, decorators: [{
676
+ type: Component,
677
+ args: [{ selector: '[teta-y-axis]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:g #svg></svg:g>\n<svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text dy=\"-8px\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n</svg:g>\n", styles: [":host{shape-rendering:crispEdges}::ng-deep .tick text{fill:var(--color-text-70)}::ng-deep .tick line{stroke:var(--color-text-20)}:host .label-axis{fill:var(--color-text-70)}\n"] }]
678
+ }], ctorParameters: function () { return [{ type: ScaleService }, { type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ZoomService }]; }, propDecorators: { axis: [{
679
+ type: Input
680
+ }], size: [{
681
+ type: Input
682
+ }], node: [{
683
+ type: ViewChild,
684
+ args: ['svg']
685
+ }] } });
686
+
687
+ class XAxisComponent {
688
+ constructor(scaleService, chartService, cdr, zoomService) {
689
+ this.scaleService = scaleService;
690
+ this.chartService = chartService;
691
+ this.cdr = cdr;
692
+ this.zoomService = zoomService;
693
+ this._alive = true;
694
+ merge(this.zoomService.zoomed, this.chartService.size)
695
+ .pipe(takeWhile(() => this._alive), tap((_) => {
696
+ this.draw();
697
+ this.cdr.detectChanges();
698
+ }))
699
+ .subscribe();
700
+ }
701
+ ngOnInit() { }
702
+ ngOnDestroy() {
703
+ this._alive = false;
704
+ }
705
+ ngAfterViewInit() {
706
+ this.draw();
707
+ }
708
+ draw() {
709
+ var _a, _b;
710
+ const scale = this.scaleService.xScales.get(this.axis.index);
711
+ const axis = this.axis.options.opposite
712
+ ? d3
713
+ .axisTop(scale)
714
+ .tickFormat((_a = this.axis.options.tickFormat) !== null && _a !== void 0 ? _a : this.axis.defaultFormatter())
715
+ : d3
716
+ .axisBottom(scale)
717
+ .tickFormat((_b = this.axis.options.tickFormat) !== null && _b !== void 0 ? _b : this.axis.defaultFormatter());
718
+ d3.select(this.node.nativeElement)
719
+ .call(axis)
720
+ .call((_) => _.select('.domain').remove());
721
+ }
722
+ }
723
+ XAxisComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: XAxisComponent, deps: [{ token: ScaleService }, { token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ZoomService }], target: i0.ɵɵFactoryTarget.Component });
724
+ XAxisComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: XAxisComponent, selector: "[teta-x-axis]", inputs: { axis: "axis", size: "size" }, viewQueries: [{ propertyName: "node", first: true, predicate: ["svg"], descendants: true }], ngImport: i0, template: "<svg:g #svg></svg:g>\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: XAxisComponent, decorators: [{
726
+ type: Component,
727
+ args: [{ selector: '[teta-x-axis]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:g #svg></svg:g>\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"] }]
728
+ }], ctorParameters: function () { return [{ type: ScaleService }, { type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ZoomService }]; }, propDecorators: { axis: [{
729
+ type: Input
730
+ }], size: [{
731
+ type: Input
732
+ }], node: [{
733
+ type: ViewChild,
734
+ args: ['svg']
735
+ }] } });
736
+
737
+ class GridlinesComponent {
738
+ constructor(scaleService, axesService, chartService, zoomService, cdr) {
739
+ this.scaleService = scaleService;
740
+ this.axesService = axesService;
741
+ this.chartService = chartService;
742
+ this.zoomService = zoomService;
743
+ this.cdr = cdr;
744
+ merge(this.chartService.size, this.zoomService.zoomed)
745
+ .pipe(tap(() => {
746
+ this.draw();
747
+ this.cdr.detectChanges();
748
+ }))
749
+ .subscribe();
750
+ }
751
+ draw() {
752
+ this.y = this.scaleService.yScales.get(0);
753
+ this.x = this.scaleService.xScales.get(0);
754
+ this.tickYValues = this.y.ticks();
755
+ this.tickXValues = this.x.ticks();
756
+ }
757
+ ngOnInit() {
758
+ this.draw();
759
+ }
760
+ }
761
+ GridlinesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GridlinesComponent, deps: [{ token: ScaleService }, { token: AxesService }, { token: ChartService }, { token: ZoomService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
762
+ GridlinesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: GridlinesComponent, selector: "[teta-gridlines]", inputs: { size: "size" }, ngImport: i0, template: "<ng-container *ngFor=\"let tick of tickYValues\">\n <svg:line [attr.x1]=\"0\" stroke=\"red\" [attr.y1]=\"y(tick)\" [attr.x2]=\"size?.width\" [attr.y2]=\"y(tick)\"></svg:line>\n</ng-container>\n\n<ng-container *ngFor=\"let tick of tickXValues\">\n <svg:line [attr.x1]=\"x(tick)\" stroke=\"red\" [attr.y1]=\"0\" [attr.x2]=\"x(tick)\" [attr.y2]=\"size?.height\"></svg:line>\n</ng-container>\n", styles: [":host{shape-rendering:crispEdges}:host line{stroke-dasharray:1,4;stroke:var(--color-text-20)}\n"], directives: [{ type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GridlinesComponent, decorators: [{
764
+ type: Component,
765
+ args: [{ selector: '[teta-gridlines]', template: "<ng-container *ngFor=\"let tick of tickYValues\">\n <svg:line [attr.x1]=\"0\" stroke=\"red\" [attr.y1]=\"y(tick)\" [attr.x2]=\"size?.width\" [attr.y2]=\"y(tick)\"></svg:line>\n</ng-container>\n\n<ng-container *ngFor=\"let tick of tickXValues\">\n <svg:line [attr.x1]=\"x(tick)\" stroke=\"red\" [attr.y1]=\"0\" [attr.x2]=\"x(tick)\" [attr.y2]=\"size?.height\"></svg:line>\n</ng-container>\n", styles: [":host{shape-rendering:crispEdges}:host line{stroke-dasharray:1,4;stroke:var(--color-text-20)}\n"] }]
766
+ }], ctorParameters: function () { return [{ type: ScaleService }, { type: AxesService }, { type: ChartService }, { type: ZoomService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { size: [{
767
+ type: Input
768
+ }] } });
769
+
770
+ class PlotlineComponent {
771
+ constructor(cdr, zoomService, scaleService, chartService, element) {
772
+ this.cdr = cdr;
773
+ this.zoomService = zoomService;
774
+ this.scaleService = scaleService;
775
+ this.chartService = chartService;
776
+ this.element = element;
777
+ this.orientation = AxisOrientation;
778
+ this.zoomService.zoomed.subscribe(() => {
779
+ this.scale = this.scaleService[this.axis.orientation === AxisOrientation.x ? 'xScales' : 'yScales'].get(this.axis.index);
780
+ this.cdr.detectChanges();
781
+ });
782
+ }
783
+ ngOnInit() {
784
+ this.scale = this.scaleService[this.axis.orientation === AxisOrientation.x ? 'xScales' : 'yScales'].get(this.axis.index);
785
+ this.domain = this.scale.domain();
786
+ const plotlineElement = d3
787
+ .select(this.element.nativeElement)
788
+ .select('.plotline');
789
+ const grabElement = d3
790
+ .select(this.element.nativeElement)
791
+ .selectAll('.grabber');
792
+ const drag = d3
793
+ .drag()
794
+ .subject(() => {
795
+ if (this.axis.orientation === AxisOrientation.y) {
796
+ return { y: plotlineElement.attr('y1') };
797
+ }
798
+ if (this.axis.orientation === AxisOrientation.x) {
799
+ return { x: plotlineElement.attr('x1') };
800
+ }
801
+ })
802
+ .on('start drag end', (event, d) => {
803
+ d.value = this.scale.invert(event[AxisOrientation[this.axis.orientation]]);
804
+ this.emit({
805
+ event,
806
+ target: d,
807
+ });
808
+ this.cdr.detectChanges();
809
+ });
810
+ plotlineElement.datum(this.plotline);
811
+ grabElement.datum(this.plotline);
812
+ if (this.plotline.draggable) {
813
+ grabElement.call(drag);
814
+ }
815
+ }
816
+ emit(event) {
817
+ this.chartService.emitPlotline(event);
818
+ }
819
+ get value() {
820
+ return this.scale(this.plotline.value);
821
+ }
822
+ get height() {
823
+ return this.size.height;
824
+ }
825
+ get width() {
826
+ return this.size.width;
827
+ }
828
+ }
829
+ PlotlineComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: PlotlineComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: ZoomService }, { token: ScaleService }, { token: ChartService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
830
+ PlotlineComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: PlotlineComponent, selector: "[teta-plot-line]", inputs: { plotline: "plotline", size: "size", axis: "axis" }, ngImport: i0, template: "<svg:line class=\"plotline\"\n [attr.stroke]=\"plotline.style?.stroke || 'red'\"\n [attr.stroke-width]=\"plotline.style?.strokeWidth || 4\"\n [attr.stroke-dasharray]=\"plotline.style?.strokeDasharray\"\n [attr.x1]=\"axis.orientation === orientation.x ? value : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? value : width\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : value\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : value\">\n</svg:line>\n\n<svg:line class=\"grabber\"\n\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [attr.stroke]=\"'red'\"\n [attr.stroke-width]=\"8\"\n opacity=\"0\"\n [attr.x1]=\"axis.orientation === orientation.x ? value : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? value : width\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : value\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : value\">\n</svg:line>\n", styles: [":host .x-grabber{cursor:col-resize}:host .y-grabber{cursor:row-resize}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
831
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: PlotlineComponent, decorators: [{
832
+ type: Component,
833
+ args: [{ selector: '[teta-plot-line]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:line class=\"plotline\"\n [attr.stroke]=\"plotline.style?.stroke || 'red'\"\n [attr.stroke-width]=\"plotline.style?.strokeWidth || 4\"\n [attr.stroke-dasharray]=\"plotline.style?.strokeDasharray\"\n [attr.x1]=\"axis.orientation === orientation.x ? value : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? value : width\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : value\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : value\">\n</svg:line>\n\n<svg:line class=\"grabber\"\n\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [attr.stroke]=\"'red'\"\n [attr.stroke-width]=\"8\"\n opacity=\"0\"\n [attr.x1]=\"axis.orientation === orientation.x ? value : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? value : width\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : value\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : value\">\n</svg:line>\n", styles: [":host .x-grabber{cursor:col-resize}:host .y-grabber{cursor:row-resize}\n"] }]
834
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: ZoomService }, { type: ScaleService }, { type: ChartService }, { type: i0.ElementRef }]; }, propDecorators: { plotline: [{
835
+ type: Input
836
+ }], size: [{
837
+ type: Input
838
+ }], axis: [{
839
+ type: Input
840
+ }] } });
841
+
842
+ class PlotbandComponent {
843
+ constructor(scaleService, zoomService, chartService, cdr, element) {
844
+ this.scaleService = scaleService;
845
+ this.zoomService = zoomService;
846
+ this.chartService = chartService;
847
+ this.cdr = cdr;
848
+ this.element = element;
849
+ this.orientation = AxisOrientation;
850
+ this.zoomService.zoomed.subscribe(() => {
851
+ this.scale = this.scaleService[this.axis.orientation === AxisOrientation.x ? 'xScales' : 'yScales'].get(this.axis.index);
852
+ this.cdr.detectChanges();
853
+ });
854
+ }
855
+ emit(event) {
856
+ this.chartService.emitPlotband(event);
857
+ }
858
+ ngOnInit() {
859
+ this.scale = this.scaleService[this.axis.orientation === AxisOrientation.x ? 'xScales' : 'yScales'].get(this.axis.index);
860
+ this.domain = this.scale.domain();
861
+ const plotbandElement = d3
862
+ .select(this.element.nativeElement)
863
+ .select('.plotband');
864
+ const grabElements = d3
865
+ .select(this.element.nativeElement)
866
+ .selectAll('.grabber');
867
+ const drag = d3
868
+ .drag()
869
+ .subject(() => {
870
+ if (this.axis.orientation === AxisOrientation.x) {
871
+ return { x: plotbandElement.attr('x') };
872
+ }
873
+ if (this.axis.orientation === AxisOrientation.y) {
874
+ return { y: plotbandElement.attr('y') };
875
+ }
876
+ })
877
+ .on('start drag end', (event, d) => {
878
+ requestAnimationFrame(() => {
879
+ let bandSize = parseFloat(plotbandElement.attr(this.axis.orientation === AxisOrientation.x ? 'width' : 'height'));
880
+ d.to = this.scale.invert(event[AxisOrientation[this.axis.orientation]] +
881
+ (this.axis.orientation === AxisOrientation.x ? bandSize : 0));
882
+ d.from = this.scale.invert(event[AxisOrientation[this.axis.orientation]] +
883
+ (this.axis.orientation === AxisOrientation.y ? bandSize : 0));
884
+ this.emit({
885
+ event,
886
+ target: d,
887
+ });
888
+ this.cdr.detectChanges();
889
+ });
890
+ });
891
+ let grabberKey;
892
+ const resize = d3
893
+ .drag()
894
+ .on('start drag end', (event, d) => {
895
+ requestAnimationFrame(() => {
896
+ var _a, _b, _c, _d;
897
+ if ((event === null || event === void 0 ? void 0 : event.type) === 'start') {
898
+ const { grabber } = (_b = (_a = event === null || event === void 0 ? void 0 : event.sourceEvent) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.dataset;
899
+ grabberKey = grabber;
900
+ }
901
+ const min = Math.min(...this.domain);
902
+ const max = Math.max(...this.domain);
903
+ const minValue = (_c = d.min) !== null && _c !== void 0 ? _c : min;
904
+ const maxValue = (_d = d.max) !== null && _d !== void 0 ? _d : max;
905
+ d[grabberKey] = this.scale.invert(event[AxisOrientation[this.axis.orientation]]);
906
+ if (grabberKey === 'from') {
907
+ const borderMin = d.from <= minValue;
908
+ if (d.from >= d.to) {
909
+ d.from = d.to;
910
+ }
911
+ if (borderMin) {
912
+ d.from = minValue;
913
+ }
914
+ }
915
+ if (grabberKey === 'to') {
916
+ const borderMax = d.to >= maxValue;
917
+ if (borderMax) {
918
+ d.to = maxValue;
919
+ }
920
+ if (d.to <= d.from) {
921
+ d.to = d.from;
922
+ }
923
+ }
924
+ this.emit({
925
+ event,
926
+ target: d,
927
+ });
928
+ this.cdr.detectChanges();
929
+ });
930
+ });
931
+ plotbandElement.datum(this.plotband);
932
+ grabElements.datum(this.plotband);
933
+ if (this.plotband.draggable) {
934
+ plotbandElement.call(drag);
935
+ }
936
+ if (this.plotband.resizable) {
937
+ grabElements.call(resize);
938
+ }
939
+ }
940
+ get bandSize() {
941
+ return Math.abs(this.scale(this.plotband.to) - this.scale(this.plotband.from));
942
+ }
943
+ get height() {
944
+ return this.size.height;
945
+ }
946
+ get width() {
947
+ return this.size.width;
948
+ }
949
+ get from() {
950
+ return this.scale(this.plotband.from);
951
+ }
952
+ get to() {
953
+ return this.scale(this.plotband.to);
954
+ }
955
+ getFill(d) {
956
+ var _a, _b, _c, _d;
957
+ if ((_b = (_a = d.style) === null || _a === void 0 ? void 0 : _a.plotband) === null || _b === void 0 ? void 0 : _b.patternImage) {
958
+ return `url(#${(_c = d.style.plotband) === null || _c === void 0 ? void 0 : _c.patternImage})`;
959
+ }
960
+ return (_d = d.style.plotband) === null || _d === void 0 ? void 0 : _d.fill;
961
+ }
962
+ }
963
+ PlotbandComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: PlotbandComponent, deps: [{ token: ScaleService }, { token: ZoomService }, { token: ChartService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
964
+ PlotbandComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: PlotbandComponent, selector: "[teta-plot-band]", inputs: { plotband: "plotband", axis: "axis", size: "size" }, ngImport: i0, template: "<svg:rect class=\"plotband\"\n [attr.fill]=\"getFill(plotband)\"\n [attr.opacity]=\"plotband.style?.plotband?.opacity\"\n [attr.height]=\"axis.orientation === orientation.x ? height : bandSize\"\n [attr.width]=\"axis.orientation === orientation.x ? bandSize : width\"\n [attr.y]=\"axis.orientation === orientation.y ? to : null\"\n [attr.x]=\"axis.orientation === orientation.x ? from : null\">\n</svg:rect>\n\n<svg:line class=\"display-grabber\"\n [attr.stroke]=\"plotband.style?.grabbers?.stroke || 'red'\"\n [attr.stroke-width]=\"plotband.style?.grabbers?.strokeWidth || 4\"\n [attr.stroke-dasharray]=\"plotband.style?.grabbers?.strokeDasharray\"\n [attr.x1]=\"axis.orientation === orientation.x ? from : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? from : width\"\n [attr.data-grabber]=\"'from'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : from\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : from\">\n</svg:line>\n\n<svg:line class=\"display-grabber\"\n [attr.stroke]=\"plotband.style?.grabbers?.stroke || 'red'\"\n [attr.stroke-width]=\"plotband.style?.grabbers?.strokeWidth || 4\"\n [attr.stroke-dasharray]=\"plotband.style?.grabbers?.strokeDasharray\"\n [attr.x1]=\"axis.orientation === orientation.x ? to : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? to : width\"\n [attr.data-grabber]=\"'to'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : to\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : to\">\n</svg:line>\n\n<svg:line class=\"grabber\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [attr.stroke]=\"'red'\"\n [attr.stroke-width]=\"8\"\n opacity=\"0\"\n [attr.x1]=\"axis.orientation === orientation.x ? from : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? from : width\"\n [attr.data-grabber]=\"'from'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : from\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : from\">\n</svg:line>\n\n<svg:line class=\"grabber\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [attr.stroke]=\"'red'\"\n [attr.stroke-width]=\"8\"\n opacity=\"0\"\n [attr.x1]=\"axis.orientation === orientation.x ? to : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? to : width\"\n [attr.data-grabber]=\"'to'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : to\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : to\">\n</svg:line>\n\n\n", styles: [":host rect:hover{cursor:grab}:host rect:active{cursor:grabbing}:host .x-grabber{cursor:col-resize}:host .y-grabber{cursor:row-resize}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
965
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: PlotbandComponent, decorators: [{
966
+ type: Component,
967
+ args: [{ selector: '[teta-plot-band]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:rect class=\"plotband\"\n [attr.fill]=\"getFill(plotband)\"\n [attr.opacity]=\"plotband.style?.plotband?.opacity\"\n [attr.height]=\"axis.orientation === orientation.x ? height : bandSize\"\n [attr.width]=\"axis.orientation === orientation.x ? bandSize : width\"\n [attr.y]=\"axis.orientation === orientation.y ? to : null\"\n [attr.x]=\"axis.orientation === orientation.x ? from : null\">\n</svg:rect>\n\n<svg:line class=\"display-grabber\"\n [attr.stroke]=\"plotband.style?.grabbers?.stroke || 'red'\"\n [attr.stroke-width]=\"plotband.style?.grabbers?.strokeWidth || 4\"\n [attr.stroke-dasharray]=\"plotband.style?.grabbers?.strokeDasharray\"\n [attr.x1]=\"axis.orientation === orientation.x ? from : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? from : width\"\n [attr.data-grabber]=\"'from'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : from\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : from\">\n</svg:line>\n\n<svg:line class=\"display-grabber\"\n [attr.stroke]=\"plotband.style?.grabbers?.stroke || 'red'\"\n [attr.stroke-width]=\"plotband.style?.grabbers?.strokeWidth || 4\"\n [attr.stroke-dasharray]=\"plotband.style?.grabbers?.strokeDasharray\"\n [attr.x1]=\"axis.orientation === orientation.x ? to : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? to : width\"\n [attr.data-grabber]=\"'to'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : to\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : to\">\n</svg:line>\n\n<svg:line class=\"grabber\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [attr.stroke]=\"'red'\"\n [attr.stroke-width]=\"8\"\n opacity=\"0\"\n [attr.x1]=\"axis.orientation === orientation.x ? from : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? from : width\"\n [attr.data-grabber]=\"'from'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : from\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : from\">\n</svg:line>\n\n<svg:line class=\"grabber\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [attr.stroke]=\"'red'\"\n [attr.stroke-width]=\"8\"\n opacity=\"0\"\n [attr.x1]=\"axis.orientation === orientation.x ? to : 0\"\n [attr.x2]=\"axis.orientation === orientation.x ? to : width\"\n [attr.data-grabber]=\"'to'\"\n [attr.y1]=\"axis.orientation === orientation.x ? 0 : to\"\n [attr.y2]=\"axis.orientation === orientation.x ? height : to\">\n</svg:line>\n\n\n", styles: [":host rect:hover{cursor:grab}:host rect:active{cursor:grabbing}:host .x-grabber{cursor:col-resize}:host .y-grabber{cursor:row-resize}\n"] }]
968
+ }], ctorParameters: function () { return [{ type: ScaleService }, { type: ZoomService }, { type: ChartService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { plotband: [{
969
+ type: Input
970
+ }], axis: [{
971
+ type: Input
972
+ }], size: [{
973
+ type: Input
974
+ }] } });
975
+
976
+ class SeriesBaseComponent {
977
+ constructor(svc, cdr, scaleService, zoomService, element) {
978
+ this.svc = svc;
979
+ this.cdr = cdr;
980
+ this.scaleService = scaleService;
981
+ this.zoomService = zoomService;
982
+ this.element = element;
983
+ this.zoomService.zoomed
984
+ .pipe(tap((_) => {
985
+ this.cdr.detectChanges();
986
+ }))
987
+ .subscribe();
988
+ }
989
+ ngOnInit() { }
990
+ }
991
+ SeriesBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SeriesBaseComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
992
+ SeriesBaseComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: SeriesBaseComponent, selector: "ng-component", inputs: { series: "series", size: "size" }, ngImport: i0, template: '', isInline: true });
993
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SeriesBaseComponent, decorators: [{
994
+ type: Component,
995
+ args: [{
996
+ template: '',
997
+ }]
998
+ }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; }, propDecorators: { series: [{
999
+ type: Input
1000
+ }], size: [{
1001
+ type: Input
1002
+ }] } });
1003
+
1004
+ var TooltipTracking;
1005
+ (function (TooltipTracking) {
1006
+ TooltipTracking[TooltipTracking["x"] = 0] = "x";
1007
+ TooltipTracking[TooltipTracking["y"] = 1] = "y";
1008
+ })(TooltipTracking || (TooltipTracking = {}));
1009
+
1010
+ var DragPointType;
1011
+ (function (DragPointType) {
1012
+ DragPointType[DragPointType["x"] = 0] = "x";
1013
+ DragPointType[DragPointType["y"] = 1] = "y";
1014
+ DragPointType[DragPointType["xy"] = 2] = "xy";
1015
+ })(DragPointType || (DragPointType = {}));
1016
+
1017
+ class LineSeriesComponent extends SeriesBaseComponent {
1018
+ constructor(svc, cdr, scaleService, zoomService, element) {
1019
+ super(svc, cdr, scaleService, zoomService, element);
1020
+ this.svc = svc;
1021
+ this.cdr = cdr;
1022
+ this.scaleService = scaleService;
1023
+ this.zoomService = zoomService;
1024
+ this.element = element;
1025
+ }
1026
+ ngOnInit() {
1027
+ this.display = this.zoomService.zoomed.pipe(map(({ event }) => {
1028
+ return (event === null || event === void 0 ? void 0 : event.type) === 'end' ? 1 : 0;
1029
+ }));
1030
+ this.transform = this.svc.pointerMove.pipe(filter(({ event }) => event), map(({ event }) => {
1031
+ return this.getTransform(event);
1032
+ }), tap((_) => this.cdr.detectChanges()));
1033
+ }
1034
+ ngAfterViewInit() {
1035
+ var _a;
1036
+ const drag = (node, event, d) => {
1037
+ var _a, _b, _c, _d;
1038
+ if (((_a = d.marker) === null || _a === void 0 ? void 0 : _a.dragType) === DragPointType.x ||
1039
+ ((_b = d.marker) === null || _b === void 0 ? void 0 : _b.dragType) === DragPointType.xy) {
1040
+ d.x = this.x.invert(event.x);
1041
+ }
1042
+ if (((_c = d.marker) === null || _c === void 0 ? void 0 : _c.dragType) === DragPointType.y ||
1043
+ ((_d = d.marker) === null || _d === void 0 ? void 0 : _d.dragType) === DragPointType.xy) {
1044
+ d.y = this.y.invert(event.y);
1045
+ }
1046
+ this.svc.emitPoint({
1047
+ target: {
1048
+ series: this.series,
1049
+ point: d,
1050
+ },
1051
+ event,
1052
+ });
1053
+ this.cdr.detectChanges();
1054
+ };
1055
+ const dragMarkers = d3
1056
+ .drag()
1057
+ .subject(function (event, d) {
1058
+ const node = d3.select(this);
1059
+ return { x: node.attr('cx'), y: node.attr('cy') };
1060
+ })
1061
+ .on('start drag end', function (event, d) {
1062
+ const node = d3.select(this);
1063
+ drag(node, event, d);
1064
+ });
1065
+ const draggableMarkers = (_a = this.series.data) === null || _a === void 0 ? void 0 : _a.filter((_) => { var _a; return (_ === null || _ === void 0 ? void 0 : _.marker) && ((_a = _ === null || _ === void 0 ? void 0 : _.marker) === null || _a === void 0 ? void 0 : _a.draggable); });
1066
+ const element = d3
1067
+ .select(this.element.nativeElement)
1068
+ .selectAll('.draggable-marker')
1069
+ .data(draggableMarkers);
1070
+ element.call(dragMarkers);
1071
+ this.svgElement = d3
1072
+ .select(this.element.nativeElement)
1073
+ .select('.line')
1074
+ .node();
1075
+ }
1076
+ getPath() {
1077
+ this.x = this.scaleService.xScales.get(this.series.xAxisIndex);
1078
+ this.y = this.scaleService.yScales.get(this.series.yAxisIndex);
1079
+ const line = d3
1080
+ .line()
1081
+ .defined((point) => point.x !== null || point.y !== null)
1082
+ .x((point) => this.x(point.x))
1083
+ .y((point) => this.y(point.y));
1084
+ const path = line(this.series.data);
1085
+ return path;
1086
+ }
1087
+ getMarkers() {
1088
+ var _a;
1089
+ return (_a = this.series.data) === null || _a === void 0 ? void 0 : _a.filter((_) => _ === null || _ === void 0 ? void 0 : _.marker);
1090
+ }
1091
+ getTransform(event) {
1092
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1093
+ const mouse = d3.pointer(event);
1094
+ const foundX = this.scaleService.xScales.get(this.series.xAxisIndex);
1095
+ const foundY = this.scaleService.yScales.get(this.series.yAxisIndex);
1096
+ const tooltipTracking = (_b = (_a = this.svc.config) === null || _a === void 0 ? void 0 : _a.tooltip) === null || _b === void 0 ? void 0 : _b.tracking;
1097
+ const lineIntersection = (p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) => {
1098
+ const rV = {};
1099
+ let s1_x, s1_y, s2_x, s2_y;
1100
+ s1_x = p1_x - p0_x;
1101
+ s1_y = p1_y - p0_y;
1102
+ s2_x = p3_x - p2_x;
1103
+ s2_y = p3_y - p2_y;
1104
+ let s, t;
1105
+ s =
1106
+ (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) /
1107
+ (-s2_x * s1_y + s1_x * s2_y);
1108
+ t =
1109
+ (s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) /
1110
+ (-s2_x * s1_y + s1_x * s2_y);
1111
+ if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
1112
+ // Collision detected
1113
+ rV.x = p0_x + t * s1_x;
1114
+ rV.y = p0_y + t * s1_y;
1115
+ }
1116
+ return rV;
1117
+ };
1118
+ if (tooltipTracking === TooltipTracking.x) {
1119
+ const bisect = d3.bisector((_) => _.x).right;
1120
+ const x0 = foundX.invert(mouse[0]);
1121
+ const rightId = bisect(this.series.data, x0);
1122
+ const range = foundY.range();
1123
+ const intersect = lineIntersection(mouse[0], range[0], mouse[0], range[1], foundX((_c = this.series.data[rightId - 1]) === null || _c === void 0 ? void 0 : _c.x), foundY((_d = this.series.data[rightId - 1]) === null || _d === void 0 ? void 0 : _d.y), foundX((_e = this.series.data[rightId]) === null || _e === void 0 ? void 0 : _e.x), foundY((_f = this.series.data[rightId]) === null || _f === void 0 ? void 0 : _f.y));
1124
+ console.log(intersect);
1125
+ this.svc.setTooltip({
1126
+ point: { x: foundX.invert(intersect.x), y: foundY.invert(intersect.y) },
1127
+ series: this.series,
1128
+ });
1129
+ return {
1130
+ x: intersect.x,
1131
+ y: intersect.y,
1132
+ };
1133
+ }
1134
+ if (tooltipTracking === TooltipTracking.y) {
1135
+ const bisect = d3.bisector((_) => _.y).right;
1136
+ const y0 = foundY.invert(mouse[1]);
1137
+ const rightId = bisect(this.series.data, y0);
1138
+ const range = foundX.range();
1139
+ const intersect = lineIntersection(range[0], mouse[1], range[1], mouse[1], foundX((_g = this.series.data[rightId - 1]) === null || _g === void 0 ? void 0 : _g.x), foundY((_h = this.series.data[rightId - 1]) === null || _h === void 0 ? void 0 : _h.y), foundX((_j = this.series.data[rightId]) === null || _j === void 0 ? void 0 : _j.x), foundY((_k = this.series.data[rightId]) === null || _k === void 0 ? void 0 : _k.y));
1140
+ this.svc.setTooltip({
1141
+ point: { x: foundX.invert(intersect.x), y: foundY.invert(intersect.y) },
1142
+ series: this.series,
1143
+ });
1144
+ return {
1145
+ x: intersect.x,
1146
+ y: intersect.y,
1147
+ };
1148
+ }
1149
+ }
1150
+ }
1151
+ LineSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: LineSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1152
+ LineSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: LineSeriesComponent, selector: "svg:svg[teta-line-series]", usesInheritance: true, ngImport: i0, template: "<svg:path\n class=\"line\"\n [attr.d]=\"getPath()\"\n [attr.stroke]=\"series.color\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n fill=\"none\">\n</svg:path>\n\n<ng-container *ngIf=\"transform | async as t\">\n <svg:circle\n r=\"3\"\n [attr.fill]=\"series.color\"\n [attr.transform]=\"'translate('+ t.x +', '+ t.y +')'\"\n [attr.opacity]=\"display | async\">\n </svg:circle>\n</ng-container>\n\n<ng-container *ngIf=\"getMarkers() as markers\">\n\n <svg:circle\n class=\"marker\"\n *ngFor=\"let point of markers\"\n [class.draggable-marker]=\"point?.marker?.draggable\"\n [attr.r]=\"point.marker.style?.radius ?? 5\"\n [attr.fill]=\"point.marker.style?.fill ?? 'transparent'\"\n [attr.stroke]=\"point.marker.style?.stroke ?? 'none'\"\n [attr.stroke-width]=\"point.marker.style?.strokeWidth\"\n [attr.stroke-dasharray]=\"point.marker.style?.strokeDasharray\"\n [attr.cx]=\"x(point.x)\"\n [attr.cy]=\"y(point.y)\"\n >\n </svg:circle>\n\n\n</ng-container>\n\n\n\n", styles: [".draggable-marker{cursor:move}.active{stroke-opacity:.5}.marker-grab{opacity:0}\n"], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i4.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1153
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: LineSeriesComponent, decorators: [{
1154
+ type: Component,
1155
+ args: [{ selector: 'svg:svg[teta-line-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:path\n class=\"line\"\n [attr.d]=\"getPath()\"\n [attr.stroke]=\"series.color\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n fill=\"none\">\n</svg:path>\n\n<ng-container *ngIf=\"transform | async as t\">\n <svg:circle\n r=\"3\"\n [attr.fill]=\"series.color\"\n [attr.transform]=\"'translate('+ t.x +', '+ t.y +')'\"\n [attr.opacity]=\"display | async\">\n </svg:circle>\n</ng-container>\n\n<ng-container *ngIf=\"getMarkers() as markers\">\n\n <svg:circle\n class=\"marker\"\n *ngFor=\"let point of markers\"\n [class.draggable-marker]=\"point?.marker?.draggable\"\n [attr.r]=\"point.marker.style?.radius ?? 5\"\n [attr.fill]=\"point.marker.style?.fill ?? 'transparent'\"\n [attr.stroke]=\"point.marker.style?.stroke ?? 'none'\"\n [attr.stroke-width]=\"point.marker.style?.strokeWidth\"\n [attr.stroke-dasharray]=\"point.marker.style?.strokeDasharray\"\n [attr.cx]=\"x(point.x)\"\n [attr.cy]=\"y(point.y)\"\n >\n </svg:circle>\n\n\n</ng-container>\n\n\n\n", styles: [".draggable-marker{cursor:move}.active{stroke-opacity:.5}.marker-grab{opacity:0}\n"] }]
1156
+ }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1157
+
1158
+ class BarSeriesComponent extends SeriesBaseComponent {
1159
+ constructor(svc, cdr, scaleService, zoomService, element) {
1160
+ super(svc, cdr, scaleService, zoomService, element);
1161
+ this.svc = svc;
1162
+ this.cdr = cdr;
1163
+ this.scaleService = scaleService;
1164
+ this.zoomService = zoomService;
1165
+ this.element = element;
1166
+ }
1167
+ ngOnInit() {
1168
+ var _a;
1169
+ const x = this.scaleService.xScales.get(this.series.xAxisIndex);
1170
+ const y = this.scaleService.yScales.get(this.series.yAxisIndex);
1171
+ const domain = (_a = this.series.data) === null || _a === void 0 ? void 0 : _a.map((_) => _.x);
1172
+ const range = [x(domain[0]), x(domain[(domain === null || domain === void 0 ? void 0 : domain.length) - 1])];
1173
+ this.scaleBand = d3.scaleBand().domain(domain).range(range);
1174
+ this.y = y;
1175
+ }
1176
+ width() {
1177
+ return this.scaleBand.bandwidth();
1178
+ }
1179
+ height(point) {
1180
+ return Math.abs(this.y(0) - this.y(point.y));
1181
+ }
1182
+ getX(point) {
1183
+ return this.scaleBand(point.x);
1184
+ }
1185
+ getY(point) {
1186
+ return this.y(point.y);
1187
+ }
1188
+ ngOnChanges(changes) {
1189
+ console.log(changes);
1190
+ }
1191
+ }
1192
+ BarSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BarSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1193
+ BarSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: BarSeriesComponent, selector: "svg:svg[teta-bar-series]", usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<svg:rect *ngFor=\"let point of series.data\" [attr.y]=\"getY(point)\" [attr.x]=\"getX(point)\" [attr.width]=\"width()\"\n [attr.height]=\"height(point)\"\n [attr.fill]=\"point.color\"></svg:rect>\n", styles: [""], directives: [{ type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1194
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BarSeriesComponent, decorators: [{
1195
+ type: Component,
1196
+ args: [{ selector: 'svg:svg[teta-bar-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:rect *ngFor=\"let point of series.data\" [attr.y]=\"getY(point)\" [attr.x]=\"getX(point)\" [attr.width]=\"width()\"\n [attr.height]=\"height(point)\"\n [attr.fill]=\"point.color\"></svg:rect>\n", styles: [""] }]
1197
+ }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1198
+
1199
+ var SeriesType;
1200
+ (function (SeriesType) {
1201
+ SeriesType[SeriesType["line"] = 0] = "line";
1202
+ SeriesType[SeriesType["bar"] = 1] = "bar";
1203
+ })(SeriesType || (SeriesType = {}));
1204
+
1205
+ class SeriesHostComponent {
1206
+ constructor(viewContainerRef, chartService) {
1207
+ this.viewContainerRef = viewContainerRef;
1208
+ this.chartService = chartService;
1209
+ this.defaultSeriesTypeMapping = new Map()
1210
+ .set(SeriesType.line, LineSeriesComponent)
1211
+ .set(SeriesType.bar, BarSeriesComponent);
1212
+ this._init = false;
1213
+ this.chartService.size
1214
+ .pipe(throttleTime(100, null, { trailing: true }), tap(() => {
1215
+ var _a;
1216
+ (_a = this._componentRef) === null || _a === void 0 ? void 0 : _a.injector.get(ChangeDetectorRef).detectChanges();
1217
+ }))
1218
+ .subscribe();
1219
+ }
1220
+ ngOnInit() {
1221
+ if (!SeriesBaseComponent.isPrototypeOf(this.series.component)) {
1222
+ this.series.component =
1223
+ this.defaultSeriesTypeMapping.get(this.series.type) ||
1224
+ LineSeriesComponent;
1225
+ }
1226
+ this._componentRef = this.viewContainerRef.createComponent(this.series.component);
1227
+ this._componentRef.instance.series = this.series;
1228
+ this._componentRef.instance.size = this.size;
1229
+ this._init = true;
1230
+ }
1231
+ ngOnDestroy() { }
1232
+ ngOnChanges(changes) {
1233
+ if (this._init && changes.hasOwnProperty('series')) {
1234
+ this._componentRef.instance.series = this.series;
1235
+ this._componentRef.instance.size = this.size;
1236
+ this._componentRef.injector.get(ChangeDetectorRef).markForCheck();
1237
+ this._componentRef.injector.get(ChangeDetectorRef).detectChanges();
1238
+ }
1239
+ }
1240
+ }
1241
+ SeriesHostComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SeriesHostComponent, deps: [{ token: i0.ViewContainerRef }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Component });
1242
+ SeriesHostComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: SeriesHostComponent, selector: "[teta-series-host]", inputs: { series: "series", size: "size" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1243
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SeriesHostComponent, decorators: [{
1244
+ type: Component,
1245
+ args: [{
1246
+ selector: '[teta-series-host]',
1247
+ template: '',
1248
+ changeDetection: ChangeDetectionStrategy.OnPush,
1249
+ }]
1250
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: ChartService }]; }, propDecorators: { series: [{
1251
+ type: Input
1252
+ }], size: [{
1253
+ type: Input
1254
+ }] } });
1255
+
1256
+ class BrushableDirective {
1257
+ constructor(brushService, chartService, element) {
1258
+ this.brushService = brushService;
1259
+ this.chartService = chartService;
1260
+ this.element = element;
1261
+ }
1262
+ ngOnInit() { }
1263
+ ngAfterViewInit() {
1264
+ this.brushService.applyBrush(this.element, this.config, this.size);
1265
+ }
1266
+ }
1267
+ BrushableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BrushableDirective, deps: [{ token: BrushService }, { token: ChartService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1268
+ BrushableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.1", type: BrushableDirective, selector: "svg:svg[tetaBrushable]", inputs: { config: "config", size: "size" }, ngImport: i0 });
1269
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BrushableDirective, decorators: [{
1270
+ type: Directive,
1271
+ args: [{
1272
+ selector: 'svg:svg[tetaBrushable]',
1273
+ }]
1274
+ }], ctorParameters: function () { return [{ type: BrushService }, { type: ChartService }, { type: i0.ElementRef }]; }, propDecorators: { config: [{
1275
+ type: Input
1276
+ }], size: [{
1277
+ type: Input
1278
+ }] } });
1279
+
1280
+ class ZoomableDirective {
1281
+ constructor(element, svc, chartService) {
1282
+ this.element = element;
1283
+ this.svc = svc;
1284
+ this.chartService = chartService;
1285
+ this.zoomable = false;
1286
+ }
1287
+ ngOnInit() {
1288
+ var _a, _b, _c, _d;
1289
+ if (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.zoom) === null || _b === void 0 ? void 0 : _b.enable) || ((_d = (_c = this.axis) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.zoom)) {
1290
+ this.zoomable = true;
1291
+ this.svc.applyZoom(this.element, this.chartService.config, this.size);
1292
+ }
1293
+ }
1294
+ ngAfterViewInit() { }
1295
+ }
1296
+ ZoomableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ZoomableDirective, deps: [{ token: i0.ElementRef }, { token: ZoomService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Directive });
1297
+ ZoomableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.1", type: ZoomableDirective, selector: "[tetaZoomable]", inputs: { config: "config", axis: "axis", size: "size" }, host: { properties: { "class.zoomable": "this.zoomable" } }, ngImport: i0 });
1298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ZoomableDirective, decorators: [{
1299
+ type: Directive,
1300
+ args: [{
1301
+ selector: '[tetaZoomable]',
1302
+ }]
1303
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ZoomService }, { type: ChartService }]; }, propDecorators: { config: [{
1304
+ type: Input
1305
+ }], axis: [{
1306
+ type: Input
1307
+ }], size: [{
1308
+ type: Input
1309
+ }], zoomable: [{
1310
+ type: HostBinding,
1311
+ args: ['class.zoomable']
1312
+ }] } });
1313
+
1314
+ class ChartContainerComponent {
1315
+ constructor(_svc, _cdr, _elementRef, _axesService) {
1316
+ this._svc = _svc;
1317
+ this._cdr = _cdr;
1318
+ this._elementRef = _elementRef;
1319
+ this._axesService = _axesService;
1320
+ this.filterPositionMap = new Map()
1321
+ .set(true, (axis) => (_) => _.options.opposite && _.options.visible && axis.index <= _.index)
1322
+ .set(false, (axis) => (_) => _.options.opposite !== true &&
1323
+ _.options.visible &&
1324
+ _.index <= axis.index);
1325
+ this.sumSize = (acc, curr) => acc + curr.selfSize;
1326
+ this.size = this._svc.size.pipe(throttleTime(100, undefined, { trailing: true }), tap(() => {
1327
+ setTimeout(() => {
1328
+ this._cdr.detectChanges();
1329
+ });
1330
+ }));
1331
+ this.yAxes = this._axesService.yAxis;
1332
+ this.xAxes = this._axesService.xAxis;
1333
+ this.uniqId = (Date.now() + Math.random()).toString(36);
1334
+ }
1335
+ ngOnInit() {
1336
+ this._observer = new ResizeObserver((entries) => {
1337
+ this._svc.setSize(entries[0].contentRect);
1338
+ });
1339
+ this._observer.observe(this._elementRef.nativeElement);
1340
+ this._svc.init(this.config);
1341
+ }
1342
+ oppositeFilter(axis) {
1343
+ return (_) => _.options.opposite && _.options.visible && axis.index <= _.index;
1344
+ }
1345
+ nonOppositeFilter(axis) {
1346
+ return (_) => _.options.opposite !== true && _.options.visible && _.index <= axis.index;
1347
+ }
1348
+ getVisibleRect(size) {
1349
+ const yAxesArray = [...this.yAxes.values()];
1350
+ const xAxesArray = [...this.xAxes.values()];
1351
+ const left = yAxesArray
1352
+ .filter((_) => _.options.opposite !== true && _.options.visible)
1353
+ .reduce(this.sumSize, 0);
1354
+ const right = yAxesArray
1355
+ .filter((_) => _.options.opposite && _.options.visible)
1356
+ .reduce(this.sumSize, 0);
1357
+ const bottom = xAxesArray
1358
+ .filter((_) => _.options.opposite !== true && _.options.visible)
1359
+ .reduce(this.sumSize, 0);
1360
+ const top = xAxesArray
1361
+ .filter((_) => _.options.opposite && _.options.visible)
1362
+ .reduce(this.sumSize, 0);
1363
+ const rect = {
1364
+ left,
1365
+ top,
1366
+ width: size.width - left - right + 1,
1367
+ height: size.height - top - bottom + 1,
1368
+ };
1369
+ return rect;
1370
+ }
1371
+ getYAxisTranslate(axis, size) {
1372
+ const yAxesArray = [...this.yAxes.values()];
1373
+ const translateOpposite = yAxesArray
1374
+ .filter(this.nonOppositeFilter(axis))
1375
+ .reduce(this.sumSize, 0);
1376
+ const translateNonOpposite = yAxesArray
1377
+ .filter(this.oppositeFilter(axis))
1378
+ .reduce(this.sumSize, 0);
1379
+ return `translate(${axis.options.opposite
1380
+ ? size.width - translateNonOpposite
1381
+ : translateOpposite}, 0)`;
1382
+ }
1383
+ getXAxisTranslate(axis, size) {
1384
+ const xAxesArray = [...this.xAxes.values()];
1385
+ const translateNonOpposite = xAxesArray
1386
+ .filter(this.nonOppositeFilter(axis))
1387
+ .reduce(this.sumSize, 0);
1388
+ const translateOpposite = xAxesArray
1389
+ .filter(this.oppositeFilter(axis))
1390
+ .reduce(this.sumSize, 0);
1391
+ return `translate(0, ${axis.options.opposite
1392
+ ? translateOpposite
1393
+ : size.height - translateNonOpposite})`;
1394
+ }
1395
+ getTranslate(axis, size) {
1396
+ const xAxesArray = [...this.xAxes.values()];
1397
+ const yAxesArray = [...this.yAxes.values()];
1398
+ const oppositeFilter = this.filterPositionMap.get(true);
1399
+ const nonOppositeFilter = this.filterPositionMap.get(false);
1400
+ const oppositeOffsetY = yAxesArray.filter(oppositeFilter(axis));
1401
+ const nonOppositeOffsetY = yAxesArray.filter(nonOppositeFilter(axis));
1402
+ const oppositeOffsetX = xAxesArray.filter(oppositeFilter(axis));
1403
+ const nonOppositeOffsetX = xAxesArray.filter(nonOppositeFilter(axis));
1404
+ const oppositeTranslateY = oppositeOffsetY.reduce((acc, curr) => acc + curr.selfSize, 0);
1405
+ const nonOppisteTranslateY = nonOppositeOffsetY.reduce((acc, curr) => acc + curr.selfSize, 0);
1406
+ const oppositeTranslateX = oppositeOffsetX.reduce((acc, curr) => acc + curr.selfSize, 0);
1407
+ const nonOppisteTranslateX = nonOppositeOffsetX.reduce((acc, curr) => acc + curr.selfSize, 0);
1408
+ const left = yAxesArray
1409
+ .filter((_) => _.options.visible && _.options.opposite !== true)
1410
+ .reduce((acc, curr) => acc + curr.selfSize, 0);
1411
+ const top = xAxesArray
1412
+ .filter((_) => _.options.visible && _.options.opposite === true)
1413
+ .reduce((acc, curr) => acc + curr.selfSize, 0);
1414
+ if (axis.orientation === AxisOrientation.x) {
1415
+ return `translate(${left}, ${axis.options.opposite
1416
+ ? oppositeTranslateX
1417
+ : size.height - nonOppisteTranslateX})`;
1418
+ }
1419
+ if (axis.orientation === AxisOrientation.y) {
1420
+ return `translate(${axis.options.opposite
1421
+ ? size.width - oppositeTranslateY
1422
+ : nonOppisteTranslateY}, ${top})`;
1423
+ }
1424
+ return 'translate(0, 0)';
1425
+ }
1426
+ mouseMove(event) {
1427
+ this._svc.setPointerMove(event);
1428
+ }
1429
+ mouseLeave(event) {
1430
+ this._svc.setPointerMove(event);
1431
+ }
1432
+ id() {
1433
+ return this.uniqId;
1434
+ }
1435
+ ngAfterContentChecked() { }
1436
+ ngAfterViewChecked() { }
1437
+ ngOnChanges(changes) { }
1438
+ }
1439
+ ChartContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartContainerComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: AxesService }], target: i0.ɵɵFactoryTarget.Component });
1440
+ ChartContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ChartContainerComponent, selector: "teta-chart-container", inputs: { config: "config" }, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"size | async as s\">\n <teta-tooltip [size]=\"s\"></teta-tooltip>\n <svg\n [tetaZoomable]\n [tetaBrushable]\n [size]=\"s\"\n [config]=\"config\"\n [attr.width]=\"s.width\"\n [attr.height]=\"s.height\"\n [attr.viewBox]=\"'0 0 '+s.width+' '+s.height\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousemove)=\"mouseMove($event)\">\n <ng-container *ngIf=\"getVisibleRect(s) as rect\">\n <defs>\n <clipPath [attr.id]=\"'visible-window-' + id()\">\n <rect [attr.x]=\"rect.left\" [attr.y]=\"rect.top\" [attr.width]=\"rect.width\" [attr.height]=\"rect.height\"></rect>\n </clipPath>\n </defs>\n\n <g class=\"y-axis-container\">\n <g *ngFor=\"let item of yAxes | keyvalue\"\n teta-y-axis\n [axis]=\"item.value\"\n [size]=\"s\"\n [attr.transform]=\"getTranslate(item.value, s)\"></g>\n </g>\n <g class=\"x-axis-container\">\n <g *ngFor=\"let item of xAxes | keyvalue\"\n teta-x-axis\n\n [axis]=\"item.value\"\n [size]=\"s\"\n [attr.transform]=\"getTranslate(item.value, s)\"></g>\n </g>\n <g [attr.clip-path]=\"'url(#visible-window-'+ id() +')'\">\n <g [attr.transform]=\"'translate('+ rect.left +', '+ rect.top +')'\">\n <g class=\"gridlines\" teta-gridlines [size]=\"s\"></g>\n\n <g class=\"x-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of config.xAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotline of axis.plotlines\" [plotline]=\"plotline\" [size]=\"s\"\n [axis]=\"xAxes.get(i)\"></g>\n </ng-container>\n </g>\n\n <g class=\"y-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of config.yAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotline of axis.plotlines\" [plotline]=\"plotline\" [size]=\"s\"\n [axis]=\"yAxes.get(i)\"></g>\n </ng-container>\n </g>\n\n <g class=\"x-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of config.xAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotband of axis.plotbands\" [plotband]=\"plotband\" [size]=\"s\"\n [axis]=\"xAxes.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"y-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of config.yAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotband of axis.plotbands\" [plotband]=\"plotband\" [size]=\"s\"\n [axis]=\"yAxes.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"series-tooltip-line-marker\"></g>\n <g class=\"series-container\">\n <g teta-series-host\n *ngFor=\"let series of config.series\"\n [series]=\"series\"\n [size]=\"s\"></g>\n </g>\n </g>\n </g>\n </ng-container>\n </svg>\n\n\n</ng-container>\n", styles: [":host{display:flex;flex-direction:column;flex-grow:1;min-width:0;min-height:0}:host .zoomable:hover{cursor:grab}:host .zoomable:active{cursor:grabbing}\n"], components: [{ type: TooltipComponent, selector: "teta-tooltip", inputs: ["size"] }, { type: YAxisComponent, selector: "[teta-y-axis]", inputs: ["axis", "size"] }, { type: XAxisComponent, selector: "[teta-x-axis]", inputs: ["axis", "size"] }, { type: GridlinesComponent, selector: "[teta-gridlines]", inputs: ["size"] }, { type: PlotlineComponent, selector: "[teta-plot-line]", inputs: ["plotline", "size", "axis"] }, { type: PlotbandComponent, selector: "[teta-plot-band]", inputs: ["plotband", "axis", "size"] }, { type: SeriesHostComponent, selector: "[teta-series-host]", inputs: ["series", "size"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: BrushableDirective, selector: "svg:svg[tetaBrushable]", inputs: ["config", "size"] }, { type: ZoomableDirective, selector: "[tetaZoomable]", inputs: ["config", "axis", "size"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i4.AsyncPipe, "keyvalue": i4.KeyValuePipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1441
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartContainerComponent, decorators: [{
1442
+ type: Component,
1443
+ args: [{ selector: 'teta-chart-container', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"size | async as s\">\n <teta-tooltip [size]=\"s\"></teta-tooltip>\n <svg\n [tetaZoomable]\n [tetaBrushable]\n [size]=\"s\"\n [config]=\"config\"\n [attr.width]=\"s.width\"\n [attr.height]=\"s.height\"\n [attr.viewBox]=\"'0 0 '+s.width+' '+s.height\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousemove)=\"mouseMove($event)\">\n <ng-container *ngIf=\"getVisibleRect(s) as rect\">\n <defs>\n <clipPath [attr.id]=\"'visible-window-' + id()\">\n <rect [attr.x]=\"rect.left\" [attr.y]=\"rect.top\" [attr.width]=\"rect.width\" [attr.height]=\"rect.height\"></rect>\n </clipPath>\n </defs>\n\n <g class=\"y-axis-container\">\n <g *ngFor=\"let item of yAxes | keyvalue\"\n teta-y-axis\n [axis]=\"item.value\"\n [size]=\"s\"\n [attr.transform]=\"getTranslate(item.value, s)\"></g>\n </g>\n <g class=\"x-axis-container\">\n <g *ngFor=\"let item of xAxes | keyvalue\"\n teta-x-axis\n\n [axis]=\"item.value\"\n [size]=\"s\"\n [attr.transform]=\"getTranslate(item.value, s)\"></g>\n </g>\n <g [attr.clip-path]=\"'url(#visible-window-'+ id() +')'\">\n <g [attr.transform]=\"'translate('+ rect.left +', '+ rect.top +')'\">\n <g class=\"gridlines\" teta-gridlines [size]=\"s\"></g>\n\n <g class=\"x-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of config.xAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotline of axis.plotlines\" [plotline]=\"plotline\" [size]=\"s\"\n [axis]=\"xAxes.get(i)\"></g>\n </ng-container>\n </g>\n\n <g class=\"y-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of config.yAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotline of axis.plotlines\" [plotline]=\"plotline\" [size]=\"s\"\n [axis]=\"yAxes.get(i)\"></g>\n </ng-container>\n </g>\n\n <g class=\"x-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of config.xAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotband of axis.plotbands\" [plotband]=\"plotband\" [size]=\"s\"\n [axis]=\"xAxes.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"y-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of config.yAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotband of axis.plotbands\" [plotband]=\"plotband\" [size]=\"s\"\n [axis]=\"yAxes.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"series-tooltip-line-marker\"></g>\n <g class=\"series-container\">\n <g teta-series-host\n *ngFor=\"let series of config.series\"\n [series]=\"series\"\n [size]=\"s\"></g>\n </g>\n </g>\n </g>\n </ng-container>\n </svg>\n\n\n</ng-container>\n", styles: [":host{display:flex;flex-direction:column;flex-grow:1;min-width:0;min-height:0}:host .zoomable:hover{cursor:grab}:host .zoomable:active{cursor:grabbing}\n"] }]
1444
+ }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: AxesService }]; }, propDecorators: { config: [{
1445
+ type: Input
1446
+ }] } });
1447
+
1448
+ class LegendComponent {
1449
+ constructor() {
1450
+ this.sizeMapping = new Map()
1451
+ .set(SeriesType.line, 2)
1452
+ .set(SeriesType.bar, 12);
1453
+ this.classLegend = true;
1454
+ }
1455
+ ngOnInit() {
1456
+ var _a;
1457
+ this.series = (_a = this.series) === null || _a === void 0 ? void 0 : _a.filter((_) => _.showInLegend !== false);
1458
+ }
1459
+ getHeight(serie) {
1460
+ return this.sizeMapping.get(serie.type);
1461
+ }
1462
+ }
1463
+ LegendComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: LegendComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1464
+ LegendComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: LegendComponent, selector: "teta-legend", inputs: { series: "series" }, host: { properties: { "class.padding-bottom-4": "this.classLegend" } }, ngImport: i0, template: "<div *ngFor=\"let serie of series\">\n <div class=\"legend-item\">\n <div class=\"legend-icon-form\" [style.height.px]=\"getHeight(serie)\" [style.background-color]=\"serie.color\"></div>\n <div class=\"legend-label\">{{ serie.name }}</div>\n </div>\n</div>\n", styles: [":host{display:flex;grid-gap:8px;flex-wrap:wrap;align-items:center;justify-content:space-evenly}:host .legend-item{display:flex;align-items:center}:host .legend-icon-form{width:12px}:host .legend-label{margin-left:5px}\n"], directives: [{ type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1465
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: LegendComponent, decorators: [{
1466
+ type: Component,
1467
+ args: [{ selector: 'teta-legend', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div *ngFor=\"let serie of series\">\n <div class=\"legend-item\">\n <div class=\"legend-icon-form\" [style.height.px]=\"getHeight(serie)\" [style.background-color]=\"serie.color\"></div>\n <div class=\"legend-label\">{{ serie.name }}</div>\n </div>\n</div>\n", styles: [":host{display:flex;grid-gap:8px;flex-wrap:wrap;align-items:center;justify-content:space-evenly}:host .legend-item{display:flex;align-items:center}:host .legend-icon-form{width:12px}:host .legend-label{margin-left:5px}\n"] }]
1468
+ }], ctorParameters: function () { return []; }, propDecorators: { series: [{
1469
+ type: Input
1470
+ }], classLegend: [{
1471
+ type: HostBinding,
1472
+ args: ['class.padding-bottom-4']
1473
+ }] } });
1474
+
1475
+ class ChartComponent {
1476
+ constructor(svc, zoomService) {
1477
+ this.svc = svc;
1478
+ this.zoomService = zoomService;
1479
+ this.plotBandsMove = new EventEmitter();
1480
+ this.plotLinesMove = new EventEmitter();
1481
+ this.pointMove = new EventEmitter();
1482
+ }
1483
+ set config(config) {
1484
+ this._config = Object.assign({
1485
+ bounds: new ChartBounds(),
1486
+ }, config);
1487
+ }
1488
+ get config() {
1489
+ return this._config;
1490
+ }
1491
+ ngOnChanges(changes) { }
1492
+ ngOnInit() {
1493
+ this.svc.plotbandMove.subscribe((_) => {
1494
+ this.plotBandsMove.emit(_);
1495
+ });
1496
+ this.svc.plotlineMove.subscribe((_) => {
1497
+ this.plotLinesMove.emit(_);
1498
+ });
1499
+ this.svc.pointMove.subscribe((_) => {
1500
+ this.pointMove.emit(_);
1501
+ });
1502
+ }
1503
+ ngAfterViewInit() { }
1504
+ ngOnDestroy() {
1505
+ var _a;
1506
+ (_a = this.zoomService.broadcastSubscribtion) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1507
+ }
1508
+ }
1509
+ ChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartComponent, deps: [{ token: ChartService }, { token: ZoomService }], target: i0.ɵɵFactoryTarget.Component });
1510
+ ChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ChartComponent, selector: "teta-chart", inputs: { config: "config" }, outputs: { plotBandsMove: "plotBandsMove", plotLinesMove: "plotLinesMove", pointMove: "pointMove" }, providers: [
1511
+ ChartService,
1512
+ ZoomService,
1513
+ ScaleService,
1514
+ AxesService,
1515
+ BrushService,
1516
+ ], usesOnChanges: true, ngImport: i0, template: "<div class=\"column column_auto\">\n <teta-chart-container class=\"chart-container\" [config]=\"config\"></teta-chart-container>\n</div>\n\n<teta-legend *ngIf=\"config.legend?.enable === true\" [series]=\"config.series\"></teta-legend>\n", styles: [":host{display:flex;flex-direction:column;height:100%;width:100%}\n"], components: [{ type: ChartContainerComponent, selector: "teta-chart-container", inputs: ["config"] }, { type: LegendComponent, selector: "teta-legend", inputs: ["series"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1517
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartComponent, decorators: [{
1518
+ type: Component,
1519
+ args: [{ selector: 'teta-chart', providers: [
1520
+ ChartService,
1521
+ ZoomService,
1522
+ ScaleService,
1523
+ AxesService,
1524
+ BrushService,
1525
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"column column_auto\">\n <teta-chart-container class=\"chart-container\" [config]=\"config\"></teta-chart-container>\n</div>\n\n<teta-legend *ngIf=\"config.legend?.enable === true\" [series]=\"config.series\"></teta-legend>\n", styles: [":host{display:flex;flex-direction:column;height:100%;width:100%}\n"] }]
1526
+ }], ctorParameters: function () { return [{ type: ChartService }, { type: ZoomService }]; }, propDecorators: { plotBandsMove: [{
1527
+ type: Output
1528
+ }], plotLinesMove: [{
1529
+ type: Output
1530
+ }], pointMove: [{
1531
+ type: Output
1532
+ }], config: [{
1533
+ type: Input
1534
+ }] } });
1535
+
1536
+ class ChartModule {
1537
+ }
1538
+ ChartModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1539
+ ChartModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartModule, declarations: [ChartComponent,
1540
+ SeriesHostComponent,
1541
+ ChartContainerComponent,
1542
+ LegendComponent,
1543
+ SeriesBaseComponent,
1544
+ LineSeriesComponent,
1545
+ GridlinesComponent,
1546
+ XAxisComponent,
1547
+ YAxisComponent,
1548
+ PlotlineComponent,
1549
+ PlotbandComponent,
1550
+ BarSeriesComponent,
1551
+ TooltipComponent,
1552
+ ZoomableDirective,
1553
+ BrushableDirective], imports: [CommonModule], exports: [ChartComponent] });
1554
+ ChartModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartModule, imports: [[CommonModule]] });
1555
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ChartModule, decorators: [{
1556
+ type: NgModule,
1557
+ args: [{
1558
+ declarations: [
1559
+ ChartComponent,
1560
+ SeriesHostComponent,
1561
+ ChartContainerComponent,
1562
+ LegendComponent,
1563
+ SeriesBaseComponent,
1564
+ LineSeriesComponent,
1565
+ GridlinesComponent,
1566
+ XAxisComponent,
1567
+ YAxisComponent,
1568
+ PlotlineComponent,
1569
+ PlotbandComponent,
1570
+ BarSeriesComponent,
1571
+ TooltipComponent,
1572
+ ZoomableDirective,
1573
+ BrushableDirective,
1574
+ ],
1575
+ exports: [ChartComponent],
1576
+ imports: [CommonModule],
1577
+ }]
1578
+ }] });
1579
+
1580
+ /*
1581
+ * Public API Surface of chart
1582
+ */
1583
+
1584
+ /**
1585
+ * Generated bundle index. Do not edit.
1586
+ */
1587
+
1588
+ export { ChartComponent, ChartModule, ChartService };
1589
+ //# sourceMappingURL=tetacom-svg-charts.mjs.map