@tetacom/svg-charts 1.4.21 → 1.4.22

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 (137) hide show
  1. package/chart/base/series-base.component.d.ts +1 -1
  2. package/chart/chart/chart.component.d.ts +1 -1
  3. package/chart/chart-container/annotation/annotation.component.d.ts +1 -1
  4. package/chart/chart-container/chart-container.component.d.ts +1 -1
  5. package/chart/chart-container/crosshair/crosshair.component.d.ts +1 -1
  6. package/chart/chart-container/gridlines/gridlines.component.d.ts +1 -1
  7. package/chart/chart-container/plotband/plot-band.component.d.ts +1 -1
  8. package/chart/chart-container/plotline/plotline.component.d.ts +1 -1
  9. package/chart/chart-container/series/area-series/area-series.component.d.ts +1 -1
  10. package/chart/chart-container/series/bar/bar-series.component.d.ts +1 -1
  11. package/chart/chart-container/series/block-area-series/block-area-series.component.d.ts +1 -1
  12. package/chart/chart-container/series/block-series/block-series.component.d.ts +1 -1
  13. package/chart/chart-container/series/line/line-series.component.d.ts +1 -1
  14. package/chart/chart-container/series/linear-series-base.d.ts +1 -1
  15. package/chart/chart-container/series/scatter-series/scatter-series.component.d.ts +1 -1
  16. package/chart/chart-container/series-host/series-host.component.d.ts +1 -1
  17. package/chart/chart-container/tooltip/tooltip.component.d.ts +1 -1
  18. package/chart/chart-container/x-axis/x-axis.component.d.ts +1 -1
  19. package/chart/chart-container/y-axis/y-axis.component.d.ts +1 -1
  20. package/chart/directives/brushable.directive.d.ts +1 -1
  21. package/chart/directives/draggable-point.directive.d.ts +1 -1
  22. package/chart/directives/zoomable.directive.d.ts +1 -1
  23. package/chart/legend/legend.component.d.ts +1 -1
  24. package/chart/model/i-broadcast-message.d.ts +2 -2
  25. package/chart/stories/bandseries/bandseries.component.d.ts +1 -1
  26. package/esm2022/chart/base/series-base.component.mjs +50 -0
  27. package/esm2022/chart/chart/chart.component.mjs +175 -0
  28. package/esm2022/chart/chart-container/annotation/annotation.component.mjs +108 -0
  29. package/esm2022/chart/chart-container/chart-container.component.mjs +194 -0
  30. package/esm2022/chart/chart-container/crosshair/crosshair.component.mjs +39 -0
  31. package/esm2022/chart/chart-container/gridlines/gridlines.component.mjs +45 -0
  32. package/esm2022/chart/chart-container/plotband/plot-band.component.mjs +174 -0
  33. package/esm2022/chart/chart-container/plotline/plotline.component.mjs +98 -0
  34. package/esm2022/chart/chart-container/series/area-series/area-series.component.mjs +74 -0
  35. package/esm2022/chart/chart-container/series/bar/bar-series.component.mjs +68 -0
  36. package/esm2022/chart/chart-container/series/block-area-series/block-area-series.component.mjs +69 -0
  37. package/esm2022/chart/chart-container/series/block-series/block-series.component.mjs +69 -0
  38. package/{esm2020 → esm2022}/chart/chart-container/series/line/line-series.component.mjs +37 -30
  39. package/esm2022/chart/chart-container/series/linear-series-base.mjs +210 -0
  40. package/esm2022/chart/chart-container/series/scatter-series/scatter-series.component.mjs +53 -0
  41. package/esm2022/chart/chart-container/series-host/series-host.component.mjs +50 -0
  42. package/{esm2020 → esm2022}/chart/chart-container/tooltip/tooltip.component.mjs +18 -5
  43. package/esm2022/chart/chart-container/x-axis/x-axis.component.mjs +54 -0
  44. package/esm2022/chart/chart-container/y-axis/y-axis.component.mjs +40 -0
  45. package/{esm2020 → esm2022}/chart/chart.module.mjs +36 -36
  46. package/esm2022/chart/core/axis/axis.mjs +135 -0
  47. package/esm2022/chart/core/axis/builders/axis-size-builder.mjs +31 -0
  48. package/esm2022/chart/core/axis/builders/extremes-builder.mjs +33 -0
  49. package/esm2022/chart/directives/brushable.directive.mjs +162 -0
  50. package/esm2022/chart/directives/draggable-point.directive.mjs +147 -0
  51. package/esm2022/chart/directives/zoomable.directive.mjs +263 -0
  52. package/esm2022/chart/legend/legend.component.mjs +38 -0
  53. package/{esm2020 → esm2022}/chart/model/chart-bounds.mjs +5 -5
  54. package/esm2022/chart/model/i-broadcast-message.mjs +27 -0
  55. package/esm2022/chart/model/plot-band.mjs +28 -0
  56. package/esm2022/chart/model/plot-line.mjs +21 -0
  57. package/esm2022/chart/service/broadcast.service.mjs +24 -0
  58. package/esm2022/chart/service/brush.service.mjs +22 -0
  59. package/esm2022/chart/service/chart.service.mjs +244 -0
  60. package/esm2022/chart/service/scale.service.mjs +206 -0
  61. package/esm2022/chart/service/zoom.service.mjs +85 -0
  62. package/esm2022/chart/stories/bandseries/bandseries.component.mjs +36 -0
  63. package/{fesm2020 → fesm2022}/tetacom-svg-charts.mjs +583 -337
  64. package/{fesm2020 → fesm2022}/tetacom-svg-charts.mjs.map +1 -1
  65. package/package.json +8 -14
  66. package/esm2020/chart/base/series-base.component.mjs +0 -42
  67. package/esm2020/chart/chart/chart.component.mjs +0 -172
  68. package/esm2020/chart/chart-container/annotation/annotation.component.mjs +0 -99
  69. package/esm2020/chart/chart-container/chart-container.component.mjs +0 -182
  70. package/esm2020/chart/chart-container/crosshair/crosshair.component.mjs +0 -34
  71. package/esm2020/chart/chart-container/gridlines/gridlines.component.mjs +0 -37
  72. package/esm2020/chart/chart-container/plotband/plot-band.component.mjs +0 -163
  73. package/esm2020/chart/chart-container/plotline/plotline.component.mjs +0 -87
  74. package/esm2020/chart/chart-container/series/area-series/area-series.component.mjs +0 -67
  75. package/esm2020/chart/chart-container/series/bar/bar-series.component.mjs +0 -59
  76. package/esm2020/chart/chart-container/series/block-area-series/block-area-series.component.mjs +0 -60
  77. package/esm2020/chart/chart-container/series/block-series/block-series.component.mjs +0 -60
  78. package/esm2020/chart/chart-container/series/linear-series-base.mjs +0 -198
  79. package/esm2020/chart/chart-container/series/scatter-series/scatter-series.component.mjs +0 -43
  80. package/esm2020/chart/chart-container/series-host/series-host.component.mjs +0 -46
  81. package/esm2020/chart/chart-container/x-axis/x-axis.component.mjs +0 -48
  82. package/esm2020/chart/chart-container/y-axis/y-axis.component.mjs +0 -36
  83. package/esm2020/chart/core/axis/axis.mjs +0 -128
  84. package/esm2020/chart/core/axis/builders/axis-size-builder.mjs +0 -33
  85. package/esm2020/chart/core/axis/builders/extremes-builder.mjs +0 -35
  86. package/esm2020/chart/directives/brushable.directive.mjs +0 -153
  87. package/esm2020/chart/directives/draggable-point.directive.mjs +0 -141
  88. package/esm2020/chart/directives/zoomable.directive.mjs +0 -254
  89. package/esm2020/chart/legend/legend.component.mjs +0 -36
  90. package/esm2020/chart/model/i-broadcast-message.mjs +0 -18
  91. package/esm2020/chart/model/plot-band.mjs +0 -17
  92. package/esm2020/chart/model/plot-line.mjs +0 -13
  93. package/esm2020/chart/service/broadcast.service.mjs +0 -23
  94. package/esm2020/chart/service/brush.service.mjs +0 -21
  95. package/esm2020/chart/service/chart.service.mjs +0 -229
  96. package/esm2020/chart/service/scale.service.mjs +0 -203
  97. package/esm2020/chart/service/zoom.service.mjs +0 -80
  98. package/esm2020/chart/stories/bandseries/bandseries.component.mjs +0 -29
  99. package/fesm2015/tetacom-svg-charts.mjs +0 -3095
  100. package/fesm2015/tetacom-svg-charts.mjs.map +0 -1
  101. /package/{esm2020 → esm2022}/chart/chart-container/series/public-api.mjs +0 -0
  102. /package/{esm2020 → esm2022}/chart/core/axis/builders/public-api.mjs +0 -0
  103. /package/{esm2020 → esm2022}/chart/core/utils/generate-ticks.mjs +0 -0
  104. /package/{esm2020 → esm2022}/chart/core/utils/get-text-width.mjs +0 -0
  105. /package/{esm2020 → esm2022}/chart/core/utils/public-api.mjs +0 -0
  106. /package/{esm2020 → esm2022}/chart/default/default-axis-config.mjs +0 -0
  107. /package/{esm2020 → esm2022}/chart/default/default-chart-config.mjs +0 -0
  108. /package/{esm2020 → esm2022}/chart/default/default-series-config.mjs +0 -0
  109. /package/{esm2020 → esm2022}/chart/default/defaultSeriesTypeMapping.mjs +0 -0
  110. /package/{esm2020 → esm2022}/chart/model/annotation.mjs +0 -0
  111. /package/{esm2020 → esm2022}/chart/model/axis-options.mjs +0 -0
  112. /package/{esm2020 → esm2022}/chart/model/base-point.mjs +0 -0
  113. /package/{esm2020 → esm2022}/chart/model/enum/axis-orientation.mjs +0 -0
  114. /package/{esm2020 → esm2022}/chart/model/enum/brush-type.mjs +0 -0
  115. /package/{esm2020 → esm2022}/chart/model/enum/clip-points-direction.mjs +0 -0
  116. /package/{esm2020 → esm2022}/chart/model/enum/drag-point-type.mjs +0 -0
  117. /package/{esm2020 → esm2022}/chart/model/enum/fill-type.mjs +0 -0
  118. /package/{esm2020 → esm2022}/chart/model/enum/public-api.mjs +0 -0
  119. /package/{esm2020 → esm2022}/chart/model/enum/scale-type.mjs +0 -0
  120. /package/{esm2020 → esm2022}/chart/model/enum/series-type.mjs +0 -0
  121. /package/{esm2020 → esm2022}/chart/model/enum/tooltip-tracking.mjs +0 -0
  122. /package/{esm2020 → esm2022}/chart/model/enum/zoom-behavior-type.mjs +0 -0
  123. /package/{esm2020 → esm2022}/chart/model/enum/zoom-type.mjs +0 -0
  124. /package/{esm2020 → esm2022}/chart/model/i-builder.mjs +0 -0
  125. /package/{esm2020 → esm2022}/chart/model/i-chart-config.mjs +0 -0
  126. /package/{esm2020 → esm2022}/chart/model/i-chart-event.mjs +0 -0
  127. /package/{esm2020 → esm2022}/chart/model/i-display-tooltip.mjs +0 -0
  128. /package/{esm2020 → esm2022}/chart/model/i-point-move.mjs +0 -0
  129. /package/{esm2020 → esm2022}/chart/model/i-scales-map.mjs +0 -0
  130. /package/{esm2020 → esm2022}/chart/model/marker-options.mjs +0 -0
  131. /package/{esm2020 → esm2022}/chart/model/public-api.mjs +0 -0
  132. /package/{esm2020 → esm2022}/chart/model/series.mjs +0 -0
  133. /package/{esm2020 → esm2022}/chart/model/svg-attributes.mjs +0 -0
  134. /package/{esm2020 → esm2022}/chart/model/tooltip-options.mjs +0 -0
  135. /package/{esm2020 → esm2022}/chart/service/public-api.mjs +0 -0
  136. /package/{esm2020 → esm2022}/public-api.mjs +0 -0
  137. /package/{esm2020 → esm2022}/tetacom-svg-charts.mjs +0 -0
@@ -1,3095 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, Component, Input, EventEmitter, Directive, Output, HostListener, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, ViewChild, HostBinding, NgModule } from '@angular/core';
3
- import * as i4 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
5
- import { __awaiter } from 'tslib';
6
- import { BehaviorSubject, Subject, of, withLatestFrom, map, shareReplay, filter, lastValueFrom, take, ReplaySubject, combineLatest, tap, takeWhile, observeOn, animationFrameScheduler } from 'rxjs';
7
- import * as d3 from 'd3';
8
- import { zoomIdentity } from 'd3';
9
- import { maxIndex } from 'd3-array';
10
- import * as i5 from '@tetacom/ng-components';
11
- import { PositionUtil, Align, VerticalAlign, tetaZoneFull, LetModule } from '@tetacom/ng-components';
12
- import * as i3 from '@angular/platform-browser';
13
-
14
- var ZoomType;
15
- (function (ZoomType) {
16
- ZoomType[ZoomType["x"] = 0] = "x";
17
- ZoomType[ZoomType["y"] = 1] = "y";
18
- ZoomType[ZoomType["xy"] = 2] = "xy";
19
- })(ZoomType || (ZoomType = {}));
20
-
21
- class ChartBounds {
22
- constructor(options) {
23
- this.top = 0;
24
- this.right = 0;
25
- this.bottom = 0;
26
- this.left = 0;
27
- this.top = (options === null || options === void 0 ? void 0 : options.top) || 0;
28
- this.right = (options === null || options === void 0 ? void 0 : options.right) || 0;
29
- this.bottom = (options === null || options === void 0 ? void 0 : options.bottom) || 0;
30
- this.left = (options === null || options === void 0 ? void 0 : options.left) || 0;
31
- }
32
- }
33
-
34
- var TooltipTracking;
35
- (function (TooltipTracking) {
36
- TooltipTracking[TooltipTracking["x"] = 0] = "x";
37
- TooltipTracking[TooltipTracking["y"] = 1] = "y";
38
- })(TooltipTracking || (TooltipTracking = {}));
39
-
40
- var ZoomBehaviorType;
41
- (function (ZoomBehaviorType) {
42
- ZoomBehaviorType[ZoomBehaviorType["move"] = 0] = "move";
43
- ZoomBehaviorType[ZoomBehaviorType["wheel"] = 1] = "wheel";
44
- })(ZoomBehaviorType || (ZoomBehaviorType = {}));
45
-
46
- const defaultChartConfig = () => ({
47
- name: null,
48
- zoom: {
49
- enable: true,
50
- type: ZoomType.x,
51
- syncType: ZoomType.xy,
52
- zoomBehavior: ZoomBehaviorType.move
53
- },
54
- bounds: new ChartBounds({
55
- bottom: 12,
56
- left: 12,
57
- top: 12,
58
- right: 12
59
- }),
60
- legend: {
61
- enable: true,
62
- },
63
- tooltip: {
64
- enable: true,
65
- showMarkers: true,
66
- tracking: TooltipTracking.x,
67
- showCrosshair: false,
68
- padding: {
69
- x: 16,
70
- y: 16
71
- }
72
- },
73
- xAxis: [],
74
- yAxis: [],
75
- series: [],
76
- gridLines: {
77
- enable: true
78
- }
79
- });
80
-
81
- var ScaleType;
82
- (function (ScaleType) {
83
- ScaleType[ScaleType["linear"] = 0] = "linear";
84
- ScaleType[ScaleType["log"] = 1] = "log";
85
- ScaleType[ScaleType["symlog"] = 2] = "symlog";
86
- ScaleType[ScaleType["pow"] = 3] = "pow";
87
- ScaleType[ScaleType["sqrt"] = 4] = "sqrt";
88
- ScaleType[ScaleType["time"] = 5] = "time";
89
- ScaleType[ScaleType["band"] = 6] = "band";
90
- })(ScaleType || (ScaleType = {}));
91
-
92
- const defaultAxisConfig = {
93
- visible: true,
94
- zoom: true,
95
- scaleType: {
96
- type: ScaleType.linear,
97
- },
98
- niceTicks: false,
99
- };
100
-
101
- var SeriesType;
102
- (function (SeriesType) {
103
- SeriesType[SeriesType["line"] = 0] = "line";
104
- SeriesType[SeriesType["bar"] = 1] = "bar";
105
- SeriesType[SeriesType["area"] = 2] = "area";
106
- SeriesType[SeriesType["scatter"] = 3] = "scatter";
107
- SeriesType[SeriesType["block"] = 4] = "block";
108
- SeriesType[SeriesType["blockArea"] = 5] = "blockArea";
109
- })(SeriesType || (SeriesType = {}));
110
-
111
- var FillType;
112
- (function (FillType) {
113
- FillType[FillType["default"] = 0] = "default";
114
- FillType[FillType["gradient"] = 1] = "gradient";
115
- })(FillType || (FillType = {}));
116
- var FillDirection;
117
- (function (FillDirection) {
118
- FillDirection[FillDirection["x"] = 0] = "x";
119
- FillDirection[FillDirection["y"] = 1] = "y";
120
- })(FillDirection || (FillDirection = {}));
121
-
122
- var ClipPointsDirection;
123
- (function (ClipPointsDirection) {
124
- ClipPointsDirection[ClipPointsDirection["x"] = 0] = "x";
125
- ClipPointsDirection[ClipPointsDirection["y"] = 1] = "y";
126
- ClipPointsDirection[ClipPointsDirection["none"] = 2] = "none";
127
- })(ClipPointsDirection || (ClipPointsDirection = {}));
128
-
129
- const defaultSeriesConfig = () => ({
130
- data: [],
131
- type: SeriesType.line,
132
- xAxisIndex: 0,
133
- yAxisIndex: 0,
134
- fillType: FillType.default,
135
- color: 'coral',
136
- visible: true,
137
- clipPointsDirection: ClipPointsDirection.x
138
- });
139
-
140
- class ChartService {
141
- constructor() {
142
- this.config$ = new BehaviorSubject(defaultChartConfig());
143
- this.size$ = new BehaviorSubject(null);
144
- this.pointerMove$ = new Subject();
145
- this.tooltips$ = new BehaviorSubject(new Map());
146
- this.plotBandEvent$ = new Subject();
147
- this.plotLineMove$ = new Subject();
148
- this.pointMove$ = new Subject();
149
- this.chartClick$ = new Subject();
150
- this.chartContextMenu$ = new Subject();
151
- this.annotationEvent$ = new Subject();
152
- this.annotationMove$ = new Subject();
153
- this.id = of((Date.now() + Math.random()).toString(36));
154
- this.config = this.config$.asObservable().pipe(withLatestFrom(this.id), map(this.setDefaults), map(this.setPreparationData), map(this.restoreLocalStorage), shareReplay({
155
- bufferSize: 1,
156
- refCount: true,
157
- }));
158
- this.size = this.size$.asObservable().pipe(filter((size) => size != null));
159
- this.pointerMove = this.pointerMove$.asObservable();
160
- this.tooltips = this.tooltips$.asObservable();
161
- this.plotBandEvent = this.plotBandEvent$.asObservable();
162
- this.plotLineMove = this.plotLineMove$.asObservable();
163
- this.pointMove = this.pointMove$.asObservable();
164
- this.chartClick = this.chartClick$.asObservable();
165
- this.chartContextMenu = this.chartContextMenu$.asObservable();
166
- this.annotationClick = this.annotationEvent$
167
- .asObservable()
168
- .pipe(filter((_) => { var _a; return ((_a = _ === null || _ === void 0 ? void 0 : _.event) === null || _a === void 0 ? void 0 : _a.type) === 'click'; }));
169
- this.annotationContextMenu = this.annotationEvent$
170
- .asObservable()
171
- .pipe(filter((_) => { var _a; return ((_a = _ === null || _ === void 0 ? void 0 : _.event) === null || _a === void 0 ? void 0 : _a.type) === 'contextmenu'; }));
172
- this.annotationMove = this.annotationMove$.asObservable();
173
- this.plotBandClick = this.plotBandEvent$
174
- .asObservable()
175
- .pipe(filter((_) => { var _a; return ((_a = _ === null || _ === void 0 ? void 0 : _.event) === null || _a === void 0 ? void 0 : _a.type) === 'click'; }));
176
- this.plotBandContextMenu = this.plotBandEvent$
177
- .asObservable()
178
- .pipe(filter((_) => { var _a; return ((_a = _ === null || _ === void 0 ? void 0 : _.event) === null || _a === void 0 ? void 0 : _a.type) === 'contextmenu'; }));
179
- // this.zoomInstance = this.zoomInstance$.asObservable();
180
- // this.brushInstance = this.brushInstance$.asObservable();
181
- }
182
- setConfig(config) {
183
- this.clearTooltips();
184
- this.config$.next(config);
185
- }
186
- setSize(size) {
187
- this.size$.next(size);
188
- }
189
- setPointerMove(event) {
190
- this.pointerMove$.next(event);
191
- }
192
- setTooltip(tooltip) {
193
- const currentTooltips = this.tooltips$.value;
194
- if (!tooltip.point) {
195
- currentTooltips.delete(tooltip.series);
196
- }
197
- else {
198
- currentTooltips.set(tooltip.series, tooltip);
199
- }
200
- this.tooltips$.next(new Map(currentTooltips));
201
- }
202
- clearTooltips() {
203
- this.tooltips$.next(new Map());
204
- }
205
- toggleVisibilitySeries(seriesIndex, visible) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- if ((seriesIndex === null || seriesIndex === void 0 ? void 0 : seriesIndex.length) === 0) {
208
- return;
209
- }
210
- const currentConfig = yield lastValueFrom(this.config.pipe(take(1)));
211
- seriesIndex.forEach((serieIndex) => {
212
- const currentSerieIndex = currentConfig.series.findIndex((_) => _.id === serieIndex);
213
- if (currentSerieIndex === -1) {
214
- return;
215
- }
216
- currentConfig.series[currentSerieIndex].visible = visible !== undefined ? visible : !currentConfig.series[currentSerieIndex].visible;
217
- const seriesLinkCount = currentConfig.series.filter((_) => _.yAxisIndex === currentConfig.series[currentSerieIndex].yAxisIndex && _.visible === true).length;
218
- currentConfig.yAxis[currentConfig.series[currentSerieIndex].yAxisIndex].visible = seriesLinkCount !== 0;
219
- });
220
- try {
221
- this.saveCookie(currentConfig);
222
- }
223
- finally {
224
- this.config$.next(currentConfig);
225
- }
226
- });
227
- }
228
- emitMoveAnnotation(event) {
229
- this.annotationMove$.next(event);
230
- }
231
- emitAnnotation(event) {
232
- this.annotationEvent$.next(event);
233
- }
234
- emitPlotband(event) {
235
- this.plotBandEvent$.next(event);
236
- }
237
- emitPlotline(event) {
238
- this.plotLineMove$.next(event);
239
- }
240
- emitPoint(event) {
241
- this.pointMove$.next(event);
242
- }
243
- emitChartClick(event) {
244
- this.chartClick$.next(event);
245
- }
246
- emitChartContextMenu(event) {
247
- this.chartContextMenu$.next(event);
248
- }
249
- // public emitZoomInstance(event: ZoomService) {
250
- // this.zoomInstance$.next(event);
251
- // }
252
- //
253
- // public emitZoomInstance(event: ZoomService) {
254
- // this.zoomInstance$.next(event);
255
- // }
256
- saveCookie(config) {
257
- var _a;
258
- if (!config.name)
259
- return;
260
- const hiddenSeries = (_a = config.series) === null || _a === void 0 ? void 0 : _a.filter((_) => !_.visible).map((_) => _.id);
261
- localStorage.setItem(`${config.name}_${ChartService._hiddenSeriesPostfix}`, JSON.stringify(hiddenSeries));
262
- }
263
- restoreLocalStorage(config) {
264
- if (!config.name)
265
- return config;
266
- const hiddenSeries = localStorage.getItem(`${config.name}_${ChartService._hiddenSeriesPostfix}`);
267
- if (hiddenSeries) {
268
- const json = JSON.parse(hiddenSeries);
269
- config.series = config.series.map((serie, index) => {
270
- serie.visible = !json.includes(serie.id);
271
- const currentSerieIndex = config.series.findIndex((_) => _.id === serie.id);
272
- if (currentSerieIndex !== -1) {
273
- const seriesLinkCount = config.series.filter((_) => _.yAxisIndex === config.series[currentSerieIndex].yAxisIndex && _.visible === true).length;
274
- config.yAxis[config.series[currentSerieIndex].yAxisIndex].visible = seriesLinkCount !== 0;
275
- }
276
- return serie;
277
- });
278
- return config;
279
- }
280
- return config;
281
- }
282
- setDefaults(data) {
283
- var _a, _b, _c, _d, _e, _f, _g;
284
- let [config, id] = data;
285
- const defaultConfig = (defaultConfig) => {
286
- return (source) => {
287
- return Object.assign({}, defaultConfig, source);
288
- };
289
- };
290
- config = Object.assign({}, defaultChartConfig(), config);
291
- config.id = (_a = config.id) !== null && _a !== void 0 ? _a : id;
292
- config.xAxis = config.xAxis.map(defaultConfig(defaultAxisConfig));
293
- config.yAxis = config.yAxis.map(defaultConfig(defaultAxisConfig));
294
- config.series = config.series.map(defaultConfig(defaultSeriesConfig()));
295
- config.series = config.series.map((_, index) => {
296
- var _a, _b;
297
- return Object.assign(Object.assign({}, _), { data: (_a = _.data) !== null && _a !== void 0 ? _a : [], id: (_b = _.id) !== null && _b !== void 0 ? _b : index });
298
- });
299
- const oppositeYCount = (_b = config.yAxis) === null || _b === void 0 ? void 0 : _b.filter((_) => _.opposite);
300
- const oppositeXCount = (_c = config.xAxis) === null || _c === void 0 ? void 0 : _c.filter((_) => _.opposite);
301
- const nonOppositeYCount = (_d = config.yAxis) === null || _d === void 0 ? void 0 : _d.filter((_) => !_.opposite);
302
- const nonOppositeXCount = (_e = config.xAxis) === null || _e === void 0 ? void 0 : _e.filter((_) => !_.opposite);
303
- if ((nonOppositeXCount === null || nonOppositeXCount === void 0 ? void 0 : nonOppositeXCount.length) > 1) {
304
- config.bounds.bottom = 0;
305
- }
306
- if ((oppositeXCount === null || oppositeXCount === void 0 ? void 0 : oppositeXCount.length) > 1) {
307
- config.bounds.top = 0;
308
- }
309
- if ((nonOppositeYCount === null || nonOppositeYCount === void 0 ? void 0 : nonOppositeYCount.length) > 1) {
310
- config.bounds.left = 0;
311
- }
312
- if ((oppositeYCount === null || oppositeYCount === void 0 ? void 0 : oppositeYCount.length) > 1) {
313
- config.bounds.right = 0;
314
- }
315
- config.tooltip = Object.assign({}, defaultChartConfig().tooltip, config.tooltip);
316
- config.zoom = Object.assign({}, defaultChartConfig().zoom, config.zoom);
317
- config.zoom.syncChannel = (_g = (_f = config.zoom) === null || _f === void 0 ? void 0 : _f.syncChannel) !== null && _g !== void 0 ? _g : id;
318
- return config;
319
- }
320
- setPreparationData(config) {
321
- var _a, _b;
322
- if (config.inverted) {
323
- const xAxes = [...config.xAxis];
324
- const yAxes = [...config.yAxis];
325
- config.xAxis = yAxes;
326
- config.yAxis = xAxes;
327
- config.series = (_a = config.series) === null || _a === void 0 ? void 0 : _a.map((serie) => {
328
- var _a;
329
- const x = serie.xAxisIndex;
330
- const y = serie.yAxisIndex;
331
- serie.xAxisIndex = y;
332
- serie.yAxisIndex = x;
333
- return Object.assign(Object.assign({}, serie), { clipPointsDirection: ClipPointsDirection.y, data: (_a = serie === null || serie === void 0 ? void 0 : serie.data) === null || _a === void 0 ? void 0 : _a.map((point) => {
334
- 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, x1: point === null || point === void 0 ? void 0 : point.y1, y1: point === null || point === void 0 ? void 0 : point.x1 });
335
- }) });
336
- });
337
- }
338
- if ((_b = config === null || config === void 0 ? void 0 : config.brush) === null || _b === void 0 ? void 0 : _b.enable) {
339
- config.yAxis = config.yAxis.map((_) => (Object.assign(Object.assign({}, _), { zoom: false })));
340
- config.xAxis = config.xAxis.map((_) => (Object.assign(Object.assign({}, _), { zoom: false })));
341
- }
342
- return config;
343
- }
344
- }
345
- ChartService._hiddenSeriesPostfix = 'hidden_series';
346
- ChartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
347
- ChartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartService, providedIn: 'root' });
348
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartService, decorators: [{
349
- type: Injectable,
350
- args: [{
351
- providedIn: 'root',
352
- }]
353
- }], ctorParameters: function () { return []; } });
354
-
355
- var AxisOrientation;
356
- (function (AxisOrientation) {
357
- AxisOrientation[AxisOrientation["x"] = 0] = "x";
358
- AxisOrientation[AxisOrientation["y"] = 1] = "y";
359
- })(AxisOrientation || (AxisOrientation = {}));
360
-
361
- class BroadcastService {
362
- constructor() {
363
- this.zoomEmitter = new ReplaySubject(1);
364
- }
365
- broadcastZoom(value) {
366
- this.zoomEmitter.next(value);
367
- }
368
- subscribeToZoom(channel) {
369
- return this.zoomEmitter.asObservable().pipe(filter((msg) => channel && msg.channel === channel));
370
- }
371
- }
372
- BroadcastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BroadcastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
373
- BroadcastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BroadcastService, providedIn: 'root' });
374
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BroadcastService, decorators: [{
375
- type: Injectable,
376
- args: [{
377
- providedIn: 'root',
378
- }]
379
- }], ctorParameters: function () { return []; } });
380
-
381
- class ZoomService {
382
- constructor(_broadcast, _chart) {
383
- this._broadcast = _broadcast;
384
- this._chart = _chart;
385
- this.zoomed$ = new BehaviorSubject(null);
386
- this.zoomed = this.zoomed$.asObservable().pipe(shareReplay({
387
- bufferSize: 1,
388
- refCount: true
389
- }));
390
- }
391
- fireZoom(zoom) {
392
- this.zoomed$.next(zoom);
393
- }
394
- broadcastZoom(zoom) {
395
- var _a;
396
- if ((_a = this.broadcastChannel) === null || _a === void 0 ? void 0 : _a.length) {
397
- this._broadcast.broadcastZoom({
398
- channel: this.broadcastChannel,
399
- message: zoom
400
- });
401
- }
402
- }
403
- setBroadcastChannel(channel) {
404
- var _a, _b;
405
- if (this.broadcastSub) {
406
- (_a = this.broadcastSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
407
- }
408
- this.broadcastChannel = channel;
409
- if ((_b = this.broadcastChannel) === null || _b === void 0 ? void 0 : _b.length) {
410
- this.broadcastSub = combineLatest([this._broadcast.subscribeToZoom(this.broadcastChannel), this._chart.config])
411
- .pipe(filter(([zoom, config]) => {
412
- var _a;
413
- return ((_a = zoom.message) === null || _a === void 0 ? void 0 : _a.chartId) !== config.id && (config.zoom.syncType === ZoomType.xy ||
414
- (zoom.message.axis.orientation === AxisOrientation.y && config.zoom.syncType === ZoomType.y) ||
415
- (zoom.message.axis.orientation === AxisOrientation.x && config.zoom.syncType === ZoomType.x));
416
- }))
417
- .subscribe(([zoom, config]) => {
418
- this.fireZoom(zoom.message);
419
- });
420
- }
421
- }
422
- getD3Transform(targetDomain, originalDomain, scale, orientation, inverted) {
423
- const zoomScale = Math.abs(scale(originalDomain[1]) - scale(originalDomain[0])) / Math.abs(scale(targetDomain[1]) - scale(targetDomain[0]));
424
- let transform = zoomIdentity.scale(zoomScale);
425
- if (orientation === AxisOrientation.x) {
426
- if (!!inverted) {
427
- transform = transform.translate(-scale(Math.max(...targetDomain)), 0);
428
- }
429
- else {
430
- transform = transform.translate(-scale(Math.min(...targetDomain)), 0);
431
- }
432
- }
433
- if (orientation === AxisOrientation.y) {
434
- if (!!inverted) {
435
- transform = transform.translate(0, -scale(Math.min(...targetDomain)));
436
- }
437
- else {
438
- transform = transform.translate(0, -scale(Math.max(...targetDomain)));
439
- }
440
- }
441
- return transform;
442
- }
443
- ngOnDestroy() {
444
- var _a;
445
- (_a = this.broadcastSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
446
- }
447
- }
448
- ZoomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, deps: [{ token: BroadcastService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Injectable });
449
- ZoomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, providedIn: 'root' });
450
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, decorators: [{
451
- type: Injectable,
452
- args: [{
453
- providedIn: 'root',
454
- }]
455
- }], ctorParameters: function () { return [{ type: BroadcastService }, { type: ChartService }]; } });
456
-
457
- const getTextWidth = (inputText, backupRatio = 0.5, fontSize = 10) => {
458
- let text = inputText !== null && inputText !== void 0 ? inputText : '';
459
- text = text.toString();
460
- return fontSize * backupRatio * text.length;
461
- };
462
-
463
- function generateTicks(extremes, count = 10) {
464
- const [min, max] = extremes;
465
- const tickStep = (max - min) / count;
466
- const ticks = d3
467
- .range(min, max + tickStep, tickStep)
468
- .filter((step) => step <= max);
469
- return ticks;
470
- }
471
-
472
- class AxisSizeBuilder {
473
- constructor() {
474
- this.titlePadding = 11;
475
- this.basePadding = 16;
476
- this.backupRatio = 0.58;
477
- }
478
- build(settings) {
479
- let finalPadding = this.basePadding;
480
- if (settings.orientation === AxisOrientation.y) {
481
- const formatter = settings.options.tickFormat || settings.defaultFormatter();
482
- finalPadding += settings.options.title ? this.titlePadding : 0;
483
- const scale = settings.defaultScale()();
484
- scale.domain(settings.extremes);
485
- if (settings.options.scaleType.type === ScaleType.band) {
486
- scale.ticks = (ticks) => {
487
- return scale.domain();
488
- };
489
- }
490
- const ticks = scale.ticks(20);
491
- const maxElementLengthIndex = maxIndex(ticks, (_) => formatter(_).length);
492
- finalPadding += getTextWidth(formatter(ticks[maxElementLengthIndex]), this.backupRatio);
493
- }
494
- if (settings.orientation === AxisOrientation.x) {
495
- finalPadding += finalPadding + 20;
496
- }
497
- return finalPadding;
498
- }
499
- }
500
-
501
- class ExtremesBuilder {
502
- constructor() {
503
- this.extentAccessorMap = new Map()
504
- .set(AxisOrientation.x, (_) => _.x)
505
- .set(AxisOrientation.y, (_) => _.y);
506
- this.extremes = [0, 0];
507
- }
508
- build(settings) {
509
- const options = settings.options;
510
- const hasMin = (options === null || options === void 0 ? void 0 : options.min) != null;
511
- const hasMax = (options === null || options === void 0 ? void 0 : options.max) != null;
512
- if (!hasMin || !hasMax) {
513
- const linkedSeries = settings.linkedSeries();
514
- const data = linkedSeries.reduce((acc, current) => {
515
- return acc.concat(current.data);
516
- }, []);
517
- const accessor = this.extentAccessorMap.get(settings.orientation);
518
- this.extremes = data.length > 1 ? d3.extent(data, accessor) : [0, 0];
519
- if (settings.options.scaleType.type === ScaleType.band) {
520
- this.extremes = data.map(accessor);
521
- }
522
- }
523
- if (hasMin) {
524
- this.extremes[0] = options === null || options === void 0 ? void 0 : options.min;
525
- }
526
- if (hasMax) {
527
- this.extremes[1] = options === null || options === void 0 ? void 0 : options.max;
528
- }
529
- return this.extremes;
530
- }
531
- }
532
-
533
- class Axis {
534
- constructor(config) {
535
- this._extremes = [0, 0];
536
- this._originDomain = [0, 0];
537
- this.defaultFormatters = new Map()
538
- .set(ScaleType.linear, d3.format(',.5~r'))
539
- .set(ScaleType.time, d3.timeFormat('%d.%m.%Y'))
540
- .set(ScaleType.log, d3.format('~s'))
541
- .set(ScaleType.symlog, d3.format('~s'))
542
- .set(ScaleType.pow, d3.format('~s'))
543
- .set(ScaleType.sqrt, d3.format('~s'))
544
- .set(ScaleType.band, (_) => { return _; });
545
- this.defaultScales = new Map()
546
- .set(ScaleType.linear, d3.scaleLinear)
547
- .set(ScaleType.log, d3.scaleLog)
548
- .set(ScaleType.symlog, d3.scaleSymlog)
549
- .set(ScaleType.pow, d3.scalePow)
550
- .set(ScaleType.sqrt, d3.scaleSqrt)
551
- .set(ScaleType.time, d3.scaleTime)
552
- .set(ScaleType.band, d3.scaleBand);
553
- this.chartConfig = config;
554
- }
555
- /**
556
- * Factory for creating x,y axes
557
- * @param {AxisOrientation} orientation
558
- * Axis type
559
- * @param {IChartConfig} config
560
- * Chart config
561
- * @param {number} index
562
- * New generated axis
563
- */
564
- static createAxis(orientation, config, index) {
565
- const axis = new Axis(config);
566
- axis.setLocate(orientation);
567
- axis.setIndex(index);
568
- axis.setOptions();
569
- axis.setExtremes();
570
- axis.setTicksValues();
571
- axis.setSelfSize();
572
- return axis;
573
- }
574
- /**
575
- *
576
- * @param {orientation} orientation
577
- * Set locate axis x or y
578
- */
579
- setLocate(orientation) {
580
- this._orientation = orientation;
581
- }
582
- /**
583
- *
584
- * @param {number} index
585
- * Index axis
586
- */
587
- setIndex(index) {
588
- this._index = index;
589
- }
590
- /**
591
- * @return {Array<Series<BasePoint>>}
592
- * Linked series
593
- */
594
- linkedSeries() {
595
- var _a;
596
- const linkedFilter = (serie) => serie[this._orientation === AxisOrientation.y ? 'yAxisIndex' : 'xAxisIndex'] === this._index;
597
- return (_a = this.chartConfig) === null || _a === void 0 ? void 0 : _a.series.filter(linkedFilter);
598
- }
599
- setExtremes() {
600
- const builder = new ExtremesBuilder();
601
- this._extremes = builder.build(this);
602
- }
603
- setOriginDomain(domain) {
604
- this._originDomain = domain;
605
- }
606
- setScale(scale) {
607
- this._scale = scale;
608
- if (this.options.scaleType.type === ScaleType.band) {
609
- this._scale.ticks = () => {
610
- return this._scale.domain();
611
- };
612
- }
613
- }
614
- setSelfSize() {
615
- this._selfSize = new AxisSizeBuilder().build(this);
616
- }
617
- setTicksValues() {
618
- //this._ticksValues = generateTicks(this._extremes);
619
- }
620
- setOptions() {
621
- const options = this.orientation === AxisOrientation.x
622
- ? this.chartConfig.xAxis[this.index]
623
- : this.chartConfig.yAxis[this.index];
624
- this._options = options;
625
- }
626
- get scale() {
627
- return this._scale;
628
- }
629
- get extremes() {
630
- return this._extremes;
631
- }
632
- get orientation() {
633
- return this._orientation;
634
- }
635
- get selfSize() {
636
- return this._selfSize;
637
- }
638
- get tickValues() {
639
- return this._ticksValues;
640
- }
641
- get index() {
642
- return this._index;
643
- }
644
- get options() {
645
- return this._options;
646
- }
647
- get originDomain() {
648
- return this._originDomain;
649
- }
650
- defaultFormatter() {
651
- return this.defaultFormatters.get(this.options.scaleType.type);
652
- }
653
- defaultScale() {
654
- return this.defaultScales.get(this.options.scaleType.type);
655
- }
656
- }
657
-
658
- class ZoomMessage {
659
- constructor(options) {
660
- this.eventType = options === null || options === void 0 ? void 0 : options.eventType;
661
- this.element = options === null || options === void 0 ? void 0 : options.element;
662
- this.axis = options === null || options === void 0 ? void 0 : options.axis;
663
- this.domain = options.domain;
664
- this.chartId = options === null || options === void 0 ? void 0 : options.chartId;
665
- this.style = options === null || options === void 0 ? void 0 : options.style;
666
- }
667
- }
668
- class BrushMessage {
669
- constructor(options) {
670
- this.chartId = options === null || options === void 0 ? void 0 : options.chartId;
671
- this.selection = options === null || options === void 0 ? void 0 : options.selection;
672
- this.mode = options === null || options === void 0 ? void 0 : options.mode;
673
- }
674
- }
675
-
676
- class ScaleService {
677
- constructor(chartService, zoomService) {
678
- this.chartService = chartService;
679
- this.zoomService = zoomService;
680
- this.transformCacheX = new Map();
681
- this.transformCacheY = new Map();
682
- this.scaleMapping = new Map()
683
- .set(ScaleType.linear, d3.scaleLinear)
684
- .set(ScaleType.time, d3.scaleTime)
685
- .set(ScaleType.log, d3.scaleLog)
686
- .set(ScaleType.symlog, d3.scaleSymlog)
687
- .set(ScaleType.pow, d3.scalePow)
688
- .set(ScaleType.sqrt, d3.scaleSqrt)
689
- .set(ScaleType.band, d3.scaleBand);
690
- this.scales = combineLatest([
691
- this.chartService.size,
692
- this.chartService.config,
693
- this.zoomService.zoomed,
694
- ]).pipe(map((data) => {
695
- var _a, _b, _c, _d;
696
- const [size, config, zoom] = data;
697
- const xAxisMap = new Map();
698
- const yAxisMap = new Map();
699
- config.yAxis.map((_, index) => {
700
- yAxisMap.set(index, Axis.createAxis(AxisOrientation.y, config, index));
701
- });
702
- config.xAxis.map((_, index) => {
703
- xAxisMap.set(index, Axis.createAxis(AxisOrientation.x, config, index));
704
- });
705
- // Generate x scales
706
- const left = Array.from(yAxisMap.values())
707
- .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); })
708
- .reduce((acc, cur) => acc + cur.selfSize, 0);
709
- const right = Array.from(yAxisMap.values())
710
- .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; })
711
- .reduce((acc, cur) => acc + cur.selfSize, 0);
712
- const finalWidth = (size.width || 0) - left - right;
713
- xAxisMap.forEach((axis) => {
714
- var _a, _b;
715
- let domain = axis.extremes;
716
- if (axis === null || axis === void 0 ? void 0 : axis.options.inverted) {
717
- domain = [...axis.extremes].reverse();
718
- }
719
- let scale = this.scaleMapping
720
- .get(axis.options.scaleType.type)()
721
- .domain(domain)
722
- .range([0, finalWidth - config.bounds.right]);
723
- if (axis.options.niceTicks) {
724
- scale.nice();
725
- }
726
- if (axis.options.scaleType.type === ScaleType.log) {
727
- scale.base(axis.options.scaleType.base);
728
- }
729
- if (axis.options.scaleType.type === ScaleType.band) {
730
- scale.paddingInner(0.1);
731
- scale.paddingOuter(0.1);
732
- scale.align(0.1);
733
- }
734
- axis.setScale(scale);
735
- axis.setOriginDomain(scale.domain());
736
- const hasCache = this.transformCacheX.has(axis.index);
737
- const shouldRestore = ((_a = zoom === null || zoom === void 0 ? void 0 : zoom.axis) === null || _a === void 0 ? void 0 : _a.orientation) !== AxisOrientation.x ||
738
- ((_b = zoom.axis) === null || _b === void 0 ? void 0 : _b.index) !== axis.index;
739
- if (hasCache && shouldRestore) {
740
- const restoredTransform = this.transformCacheX.get(axis.index);
741
- axis.setScale(restoredTransform.rescaleX(scale));
742
- }
743
- });
744
- if (zoom && zoom.domain) {
745
- if (((_a = zoom.axis) === null || _a === void 0 ? void 0 : _a.orientation) === AxisOrientation.x) {
746
- if (xAxisMap.has(zoom.axis.index)) {
747
- const x = xAxisMap.get(zoom.axis.index);
748
- const transform = this.zoomService.getD3Transform(zoom.domain, x.originDomain, x.scale, AxisOrientation.x, x.options.inverted);
749
- const rescaled = transform.rescaleX(x.scale.copy());
750
- x.setScale(rescaled);
751
- this.transformCacheX.set(x.index, transform);
752
- }
753
- }
754
- }
755
- // Generate y axis
756
- const top = Array.from(xAxisMap.values())
757
- .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); })
758
- .reduce((acc, cur) => acc + cur.selfSize, 0);
759
- const bottom = Array.from(xAxisMap.values())
760
- .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; })
761
- .reduce((acc, cur) => acc + cur.selfSize, 0);
762
- const finalHeight = (size.height || 0) -
763
- top -
764
- bottom -
765
- ((_b = config === null || config === void 0 ? void 0 : config.bounds) === null || _b === void 0 ? void 0 : _b.top) -
766
- ((_c = config.bounds) === null || _c === void 0 ? void 0 : _c.bottom);
767
- yAxisMap.forEach((axis) => {
768
- var _a, _b;
769
- let domain = axis.extremes;
770
- if (axis.orientation === AxisOrientation.y) {
771
- domain = [...axis.extremes].reverse();
772
- }
773
- if (axis === null || axis === void 0 ? void 0 : axis.options.inverted) {
774
- domain = domain.reverse();
775
- }
776
- const scale = this.scaleMapping
777
- .get(axis.options.scaleType.type)()
778
- .domain(domain)
779
- .range([config.bounds.top, finalHeight]);
780
- if (axis.options.niceTicks) {
781
- scale.nice();
782
- }
783
- if (axis.options.scaleType.type === ScaleType.log) {
784
- scale.base(axis.options.scaleType.base);
785
- }
786
- if (axis.options.scaleType.type === ScaleType.band) {
787
- scale.paddingInner(0.1);
788
- scale.paddingOuter(0.1);
789
- scale.align(0.1);
790
- }
791
- axis.setScale(scale);
792
- axis.setOriginDomain(scale.domain());
793
- const hasCache = this.transformCacheY.has(axis.index);
794
- const shouldRestore = ((_a = zoom === null || zoom === void 0 ? void 0 : zoom.axis) === null || _a === void 0 ? void 0 : _a.orientation) !== AxisOrientation.y ||
795
- ((_b = zoom.axis) === null || _b === void 0 ? void 0 : _b.index) !== axis.index;
796
- if (hasCache && shouldRestore) {
797
- const restoredTransform = this.transformCacheY.get(axis.index);
798
- axis.setScale(restoredTransform.rescaleY(scale));
799
- }
800
- });
801
- if (zoom && zoom.domain) {
802
- if (((_d = zoom.axis) === null || _d === void 0 ? void 0 : _d.orientation) === AxisOrientation.y) {
803
- if (yAxisMap.has(zoom.axis.index)) {
804
- const y = yAxisMap.get(zoom.axis.index);
805
- const transform = this.zoomService.getD3Transform(zoom.domain, y.originDomain, y.scale, AxisOrientation.y, y.options.inverted);
806
- const rescaled = transform.rescaleY(y.scale.copy());
807
- y.setScale(rescaled);
808
- this.transformCacheY.set(y.index, transform);
809
- }
810
- }
811
- }
812
- return {
813
- x: xAxisMap,
814
- y: yAxisMap
815
- };
816
- }), shareReplay({
817
- bufferSize: 1,
818
- refCount: true,
819
- }));
820
- }
821
- resetZoom() {
822
- this.chartService.config.pipe(take(1), withLatestFrom(this.scales)).subscribe(([config, scales]) => {
823
- config.xAxis.forEach((axis, index) => {
824
- var _a, _b;
825
- const scale = (_b = (_a = scales === null || scales === void 0 ? void 0 : scales.x) === null || _a === void 0 ? void 0 : _a.get(index)) === null || _b === void 0 ? void 0 : _b.originDomain;
826
- if (scale) {
827
- const msg = new ZoomMessage({
828
- eventType: "end",
829
- axis: {
830
- index,
831
- orientation: AxisOrientation.x
832
- },
833
- domain: scale,
834
- chartId: config.id
835
- });
836
- this.zoomService.fireZoom(msg);
837
- if (config.zoom.syncChannel && config.zoom.syncType === ZoomType.x) {
838
- this.zoomService.broadcastZoom(msg);
839
- }
840
- }
841
- });
842
- config.yAxis.forEach((axis, index) => {
843
- var _a, _b;
844
- const scale = (_b = (_a = scales === null || scales === void 0 ? void 0 : scales.y) === null || _a === void 0 ? void 0 : _a.get(index)) === null || _b === void 0 ? void 0 : _b.originDomain;
845
- if (scale) {
846
- const msg = new ZoomMessage({
847
- eventType: "end",
848
- axis: {
849
- index,
850
- orientation: AxisOrientation.y
851
- },
852
- domain: scale,
853
- chartId: config.id
854
- });
855
- this.zoomService.fireZoom(msg);
856
- if (config.zoom.syncChannel && config.zoom.syncType === ZoomType.y) {
857
- this.zoomService.broadcastZoom(msg);
858
- }
859
- }
860
- });
861
- });
862
- }
863
- }
864
- ScaleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ScaleService, deps: [{ token: ChartService }, { token: ZoomService }], target: i0.ɵɵFactoryTarget.Injectable });
865
- ScaleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ScaleService, providedIn: 'root' });
866
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ScaleService, decorators: [{
867
- type: Injectable,
868
- args: [{
869
- providedIn: 'root',
870
- }]
871
- }], ctorParameters: function () { return [{ type: ChartService }, { type: ZoomService }]; } });
872
-
873
- class BrushService {
874
- constructor() {
875
- this._brushDomain = new ReplaySubject(1);
876
- this.brushDomain = this._brushDomain.asObservable();
877
- }
878
- setBrush(brush) {
879
- this._brushDomain.next(brush);
880
- }
881
- }
882
- BrushService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BrushService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
883
- BrushService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BrushService, providedIn: 'root' });
884
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BrushService, decorators: [{
885
- type: Injectable,
886
- args: [{
887
- providedIn: 'root',
888
- }]
889
- }], ctorParameters: function () { return []; } });
890
-
891
- var BrushType;
892
- (function (BrushType) {
893
- BrushType[BrushType["x"] = 0] = "x";
894
- BrushType[BrushType["y"] = 1] = "y";
895
- BrushType[BrushType["xy"] = 2] = "xy";
896
- })(BrushType || (BrushType = {}));
897
-
898
- class SeriesBaseComponent {
899
- constructor(svc, cdr, scaleService, zoomService, element, zone) {
900
- this.svc = svc;
901
- this.cdr = cdr;
902
- this.scaleService = scaleService;
903
- this.zoomService = zoomService;
904
- this.element = element;
905
- this.zone = zone;
906
- }
907
- set config(config) {
908
- this._config = config;
909
- }
910
- get config() {
911
- return this._config;
912
- }
913
- set series(series) {
914
- this._series = series;
915
- }
916
- get series() {
917
- return this._series;
918
- }
919
- ngOnInit() {
920
- }
921
- }
922
- SeriesBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: SeriesBaseComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
923
- SeriesBaseComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: SeriesBaseComponent, selector: "ng-component", inputs: { config: "config", series: "series" }, ngImport: i0, template: '', isInline: true });
924
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: SeriesBaseComponent, decorators: [{
925
- type: Component,
926
- args: [{
927
- template: '',
928
- }]
929
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { config: [{
930
- type: Input
931
- }], series: [{
932
- type: Input
933
- }] } });
934
-
935
- class LinearSeriesBase extends SeriesBaseComponent {
936
- constructor(svc, cdr, scaleService, zoomService, element) {
937
- super(svc, cdr, scaleService, zoomService, element);
938
- this.svc = svc;
939
- this.cdr = cdr;
940
- this.scaleService = scaleService;
941
- this.zoomService = zoomService;
942
- this.element = element;
943
- this.defaultClipPointsMapping = new Map();
944
- this._update = new BehaviorSubject(null);
945
- }
946
- set series(series) {
947
- var _a;
948
- this.__series = series;
949
- this.markers = (_a = this.__series.data) === null || _a === void 0 ? void 0 : _a.filter((_) => (_ === null || _ === void 0 ? void 0 : _.marker) && (_ === null || _ === void 0 ? void 0 : _.x) !== undefined && (_ === null || _ === void 0 ? void 0 : _.y) !== undefined && (_ === null || _ === void 0 ? void 0 : _.x) !== null && (_ === null || _ === void 0 ? void 0 : _.y) !== null);
950
- }
951
- get series() {
952
- return this.__series;
953
- }
954
- ngOnInit() {
955
- const filterX = (min, max) => (point, idx, arr) => {
956
- const bigger = min > max ? min : max;
957
- const smaller = min > max ? max : min;
958
- return (point.x <= bigger ||
959
- point.x1 <= bigger ||
960
- (arr[idx - 1] && arr[idx - 1].x <= bigger) ||
961
- (arr[idx - 1] && arr[idx - 1].x1 <= bigger)) &&
962
- (point.x >= smaller ||
963
- point.x1 >= smaller ||
964
- (arr[idx + 1] && arr[idx + 1].x >= smaller) ||
965
- (arr[idx + 1] && arr[idx + 1].x1 >= smaller));
966
- };
967
- const filterY = (min, max) => (point, idx, arr) => {
968
- const bigger = min > max ? min : max;
969
- const smaller = min > max ? max : min;
970
- return (point.y <= bigger ||
971
- point.y1 <= bigger ||
972
- (arr[idx - 1] && arr[idx - 1].y <= bigger) ||
973
- (arr[idx - 1] && arr[idx - 1].y1 <= bigger)) &&
974
- (point.y >= smaller ||
975
- point.y1 >= smaller ||
976
- (arr[idx + 1] && arr[idx + 1].y >= smaller) ||
977
- (arr[idx + 1] && arr[idx + 1].y1 >= smaller));
978
- };
979
- this.defaultClipPointsMapping.set(ClipPointsDirection.x, filterX);
980
- this.defaultClipPointsMapping.set(ClipPointsDirection.y, filterY);
981
- this.transform = this.svc.pointerMove.pipe(withLatestFrom(this.scaleService.scales), map((data) => {
982
- const [event, { x, y }] = data;
983
- return this.getTransform(event, x.get(this.series.xAxisIndex).scale, y.get(this.series.yAxisIndex).scale);
984
- }), tap(() => setTimeout(() => this.cdr.detectChanges())));
985
- this.path = combineLatest([this.scaleService.scales, this._update]).pipe(map(([data]) => {
986
- var _a, _b;
987
- const { x, y } = data;
988
- this.x = (_a = x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale;
989
- this.y = (_b = y.get(this.series.yAxisIndex)) === null || _b === void 0 ? void 0 : _b.scale;
990
- if (!this.x || !this.y) {
991
- return '';
992
- }
993
- const filter = this.defaultClipPointsMapping.get(this.series.clipPointsDirection);
994
- const line = d3
995
- .line()
996
- .defined((point) => point.x !== null &&
997
- point.y !== null &&
998
- point.x !== undefined &&
999
- point.y !== undefined &&
1000
- !isNaN(point.x) &&
1001
- !isNaN(point.y))
1002
- .x((point) => this.x(point.x))
1003
- .y((point) => this.y(point.y));
1004
- let filteredData = this.series.data;
1005
- if (this.series.clipPointsDirection === ClipPointsDirection.x) {
1006
- let [min, max] = this.x.domain();
1007
- min = min instanceof Date ? min.getTime() : min;
1008
- max = max instanceof Date ? max.getTime() : max;
1009
- filteredData = filteredData === null || filteredData === void 0 ? void 0 : filteredData.filter(filter(min, max));
1010
- }
1011
- if (this.series.clipPointsDirection === ClipPointsDirection.y) {
1012
- let [min, max] = this.y.domain();
1013
- min = min instanceof Date ? min.getTime() : min;
1014
- max = max instanceof Date ? max.getTime() : max;
1015
- filteredData = filteredData === null || filteredData === void 0 ? void 0 : filteredData.filter(filter(min, max));
1016
- }
1017
- return line(filteredData);
1018
- }));
1019
- }
1020
- ngOnDestroy() {
1021
- this.svc.setTooltip({
1022
- point: null,
1023
- series: this.series,
1024
- });
1025
- }
1026
- ngAfterViewInit() {
1027
- }
1028
- getTransform(event, scaleX, scaleY) {
1029
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1030
- if (event.type === 'mouseleave') {
1031
- return null;
1032
- }
1033
- const mouse = [event === null || event === void 0 ? void 0 : event.offsetX, event === null || event === void 0 ? void 0 : event.offsetY];
1034
- const tooltipTracking = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.tooltip) === null || _b === void 0 ? void 0 : _b.tracking;
1035
- const lineIntersection = (p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) => {
1036
- const rV = {};
1037
- let s1_x, s1_y, s2_x, s2_y;
1038
- s1_x = p1_x - p0_x;
1039
- s1_y = p1_y - p0_y;
1040
- s2_x = p3_x - p2_x;
1041
- s2_y = p3_y - p2_y;
1042
- let s, t;
1043
- s =
1044
- (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) /
1045
- (-s2_x * s1_y + s1_x * s2_y);
1046
- t =
1047
- (s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) /
1048
- (-s2_x * s1_y + s1_x * s2_y);
1049
- if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
1050
- // Collision detected
1051
- rV.x = p0_x + t * s1_x;
1052
- rV.y = p0_y + t * s1_y;
1053
- }
1054
- return rV;
1055
- };
1056
- if (tooltipTracking === TooltipTracking.x) {
1057
- const bisect = d3.bisector((_) => _.x).right;
1058
- const pointer = mouse[0];
1059
- let x0 = scaleX.invert(pointer);
1060
- if (x0 instanceof Date) {
1061
- x0 = x0.getTime();
1062
- }
1063
- const rightId = bisect(this.series.data, x0);
1064
- const range = scaleY.range();
1065
- const intersect = lineIntersection(pointer, range[0], pointer, Number.MAX_SAFE_INTEGER, scaleX((_c = this.series.data[rightId - 1]) === null || _c === void 0 ? void 0 : _c.x), scaleY((_d = this.series.data[rightId - 1]) === null || _d === void 0 ? void 0 : _d.y), scaleX((_e = this.series.data[rightId]) === null || _e === void 0 ? void 0 : _e.x), scaleY((_f = this.series.data[rightId]) === null || _f === void 0 ? void 0 : _f.y));
1066
- const x = scaleX.invert(intersect.x);
1067
- const y = scaleY.invert(intersect.y);
1068
- if (x !== null && x !== undefined && !isNaN(x) && y !== null && y !== undefined && !isNaN(y)) {
1069
- this.svc.setTooltip({
1070
- point: { x: scaleX.invert(intersect.x), y: scaleY.invert(intersect.y) },
1071
- series: this.series,
1072
- });
1073
- }
1074
- else {
1075
- this.svc.setTooltip({
1076
- point: null,
1077
- series: this.series,
1078
- });
1079
- }
1080
- return {
1081
- x: intersect.x,
1082
- y: intersect.y,
1083
- };
1084
- }
1085
- if (tooltipTracking === TooltipTracking.y) {
1086
- const bisect = d3.bisector((_) => _.y).right;
1087
- let y0 = scaleY.invert(mouse[1]);
1088
- if (y0 instanceof Date) {
1089
- y0 = y0.getTime();
1090
- }
1091
- const rightId = bisect(this.series.data, y0);
1092
- const range = scaleX.range();
1093
- const intersect = lineIntersection(range[0], mouse[1], Number.MAX_SAFE_INTEGER, mouse[1], scaleX((_g = this.series.data[rightId - 1]) === null || _g === void 0 ? void 0 : _g.x), scaleY((_h = this.series.data[rightId - 1]) === null || _h === void 0 ? void 0 : _h.y), scaleX((_j = this.series.data[rightId]) === null || _j === void 0 ? void 0 : _j.x), scaleY((_k = this.series.data[rightId]) === null || _k === void 0 ? void 0 : _k.y));
1094
- const x = scaleX.invert(intersect.x);
1095
- const y = scaleY.invert(intersect.y);
1096
- if (x !== null && x !== undefined && !isNaN(x) && y !== null && y !== undefined && !isNaN(y)) {
1097
- this.svc.setTooltip({
1098
- point: { x: scaleX.invert(intersect.x), y: scaleY.invert(intersect.y) },
1099
- series: this.series,
1100
- });
1101
- }
1102
- else {
1103
- this.svc.setTooltip({
1104
- point: null,
1105
- series: this.series,
1106
- });
1107
- }
1108
- return {
1109
- x: intersect.x,
1110
- y: intersect.y,
1111
- };
1112
- }
1113
- }
1114
- }
1115
- LinearSeriesBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: LinearSeriesBase, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1116
- LinearSeriesBase.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: LinearSeriesBase, selector: "ng-component", inputs: { series: "series" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
1117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: LinearSeriesBase, decorators: [{
1118
- type: Component,
1119
- args: [{
1120
- template: '',
1121
- }]
1122
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; }, propDecorators: { series: [{
1123
- type: Input
1124
- }] } });
1125
-
1126
- var DragPointType;
1127
- (function (DragPointType) {
1128
- DragPointType[DragPointType["x"] = 0] = "x";
1129
- DragPointType[DragPointType["y"] = 1] = "y";
1130
- DragPointType[DragPointType["xy"] = 2] = "xy";
1131
- })(DragPointType || (DragPointType = {}));
1132
-
1133
- class DraggablePointDirective {
1134
- constructor(_elementRef) {
1135
- this._elementRef = _elementRef;
1136
- this.moveStart = new EventEmitter();
1137
- this.moveProcess = new EventEmitter();
1138
- this.moveEnd = new EventEmitter();
1139
- }
1140
- mouseDown(event) {
1141
- if (!this.tetaDraggablePoint) {
1142
- return;
1143
- }
1144
- event.stopPropagation();
1145
- event.preventDefault();
1146
- this.startPosition = {
1147
- x: event.x,
1148
- y: event.y
1149
- };
1150
- this.moveStart.emit(this.startPosition);
1151
- }
1152
- mouseUp(event) {
1153
- if (this.startPosition !== null && this.startPosition !== undefined) {
1154
- let deltaX = event.x - this.startPosition.x;
1155
- let deltaY = event.y - this.startPosition.y;
1156
- if (this.dragDirection === DragPointType.x) {
1157
- deltaY = 0;
1158
- }
1159
- if (this.dragDirection === DragPointType.y) {
1160
- deltaX = 0;
1161
- }
1162
- if (this.allowDrag && !this.allowDrag({
1163
- x: event.x,
1164
- y: event.y,
1165
- deltaX,
1166
- deltaY
1167
- })) {
1168
- this.startPosition = null;
1169
- return;
1170
- }
1171
- if (this.transformCache) {
1172
- this.transformCache.x = this.transformCache.x + deltaX;
1173
- this.transformCache.y = this.transformCache.y + deltaY;
1174
- }
1175
- else {
1176
- this.transformCache = {
1177
- x: deltaX,
1178
- y: deltaY
1179
- };
1180
- }
1181
- this.moveEnd.emit({
1182
- x: event.x,
1183
- y: event.y,
1184
- deltaX,
1185
- deltaY
1186
- });
1187
- }
1188
- this.startPosition = null;
1189
- }
1190
- mouseMove(event) {
1191
- if (this.startPosition) {
1192
- let deltaX = event.x - this.startPosition.x;
1193
- let deltaY = event.y - this.startPosition.y;
1194
- if (this.transformCache) {
1195
- deltaX = this.transformCache.x + deltaX;
1196
- deltaY = this.transformCache.y + deltaY;
1197
- }
1198
- if (this.allowDrag && !this.allowDrag({
1199
- x: event.x,
1200
- y: event.y,
1201
- deltaX,
1202
- deltaY
1203
- })) {
1204
- return;
1205
- }
1206
- if (this.dragDirection === DragPointType.x) {
1207
- deltaY = 0;
1208
- }
1209
- if (this.dragDirection === DragPointType.y) {
1210
- deltaX = 0;
1211
- }
1212
- this.setTransform(deltaX, deltaY);
1213
- event.stopPropagation();
1214
- event.preventDefault();
1215
- this.moveProcess.emit({
1216
- x: event.x,
1217
- y: event.y,
1218
- deltaX,
1219
- deltaY
1220
- });
1221
- }
1222
- }
1223
- setTransform(x, y) {
1224
- this._elementRef.nativeElement.style.transform = `translate(${x}px, ${y}px)`;
1225
- }
1226
- resetTransform() {
1227
- this.setTransform(0, 0);
1228
- this.transformCache = null;
1229
- }
1230
- }
1231
- DraggablePointDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: DraggablePointDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1232
- DraggablePointDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: DraggablePointDirective, selector: "[tetaDraggablePoint]", inputs: { tetaDraggablePoint: "tetaDraggablePoint", dragDirection: "dragDirection", allowDrag: "allowDrag" }, outputs: { moveStart: "moveStart", moveProcess: "moveProcess", moveEnd: "moveEnd" }, host: { listeners: { "mousedown": "mouseDown($event)", "touchstart": "mouseDown($event)", "window:mouseup": "mouseUp($event)", "window:touchend": "mouseUp($event)", "window:mousemove": "mouseMove($event)", "window:touchmove": "mouseMove($event)" } }, exportAs: ["tetaDraggablePoint"], ngImport: i0 });
1233
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: DraggablePointDirective, decorators: [{
1234
- type: Directive,
1235
- args: [{
1236
- selector: '[tetaDraggablePoint]',
1237
- exportAs: 'tetaDraggablePoint'
1238
- }]
1239
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { tetaDraggablePoint: [{
1240
- type: Input
1241
- }], dragDirection: [{
1242
- type: Input
1243
- }], allowDrag: [{
1244
- type: Input
1245
- }], moveStart: [{
1246
- type: Output
1247
- }], moveProcess: [{
1248
- type: Output
1249
- }], moveEnd: [{
1250
- type: Output
1251
- }], mouseDown: [{
1252
- type: HostListener,
1253
- args: ['mousedown', ['$event']]
1254
- }, {
1255
- type: HostListener,
1256
- args: ['touchstart', ['$event']]
1257
- }], mouseUp: [{
1258
- type: HostListener,
1259
- args: ['window:mouseup', ['$event']]
1260
- }, {
1261
- type: HostListener,
1262
- args: ['window:touchend', ['$event']]
1263
- }], mouseMove: [{
1264
- type: HostListener,
1265
- args: ['window:mousemove', ['$event']]
1266
- }, {
1267
- type: HostListener,
1268
- args: ['window:touchmove', ['$event']]
1269
- }] } });
1270
-
1271
- class LineSeriesComponent extends LinearSeriesBase {
1272
- constructor(svc, cdr, scaleService, zoomService, element) {
1273
- super(svc, cdr, scaleService, zoomService, element);
1274
- this.svc = svc;
1275
- this.cdr = cdr;
1276
- this.scaleService = scaleService;
1277
- this.zoomService = zoomService;
1278
- this.element = element;
1279
- this.allowDrag = (point) => {
1280
- return (newPoint) => {
1281
- if (point.marker.minX !== null && point.marker.minX !== undefined) {
1282
- if (this.x.invert(this.x(this.start.x) + newPoint.deltaX) < point.marker.minX) {
1283
- return false;
1284
- }
1285
- }
1286
- if (point.marker.maxX !== null && point.marker.maxX !== undefined) {
1287
- if (this.x.invert(this.x(this.start.x) + newPoint.deltaX) > point.marker.maxX) {
1288
- return false;
1289
- }
1290
- }
1291
- if (point.marker.minY !== null && point.marker.minY !== undefined) {
1292
- if (this.y.invert(this.y(this.start.y) + newPoint.deltaY) < point.marker.minY) {
1293
- return false;
1294
- }
1295
- }
1296
- if (point.marker.maxY !== null && point.marker.maxY !== undefined) {
1297
- if (this.y.invert(this.y(this.start.y) + newPoint.deltaY) > point.marker.maxY) {
1298
- return false;
1299
- }
1300
- }
1301
- return true;
1302
- };
1303
- };
1304
- }
1305
- moveStart(event, point) {
1306
- this.start = { x: point.x, y: point.y };
1307
- }
1308
- moveEnd(event, point) {
1309
- point.x = this.x.invert(this.x(this.start.x) + event.deltaX);
1310
- point.y = this.y.invert(this.y(this.start.y) + event.deltaY);
1311
- this._update.next();
1312
- const emitEvent = {
1313
- type: 'end',
1314
- sourceEvent: event
1315
- };
1316
- this.svc.emitPoint({
1317
- target: {
1318
- series: this.series,
1319
- point: point,
1320
- },
1321
- event: emitEvent,
1322
- });
1323
- }
1324
- moveProcess(event, point) {
1325
- point.x = this.x.invert(this.x(this.start.x) + event.deltaX);
1326
- point.y = this.y.invert(this.y(this.start.y) + event.deltaY);
1327
- this._update.next();
1328
- const emitEvent = {
1329
- type: 'drag',
1330
- sourceEvent: event
1331
- };
1332
- this.svc.emitPoint({
1333
- target: {
1334
- series: this.series,
1335
- point: point,
1336
- },
1337
- event: emitEvent,
1338
- });
1339
- }
1340
- startLabel(event, label) {
1341
- this.labelStart = { dx: label.dx, dy: label.dy };
1342
- }
1343
- moveLabel(event, label) {
1344
- label.dx = this.labelStart.dx + event.deltaX;
1345
- label.dy = this.labelStart.dy + event.deltaY;
1346
- }
1347
- }
1348
- LineSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: LineSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1349
- LineSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: LineSeriesComponent, selector: "svg:svg[teta-line-series]", usesInheritance: true, ngImport: i0, template: "<svg:path\n class=\"line\"\n [attr.d]=\"path | async\"\n [attr.stroke]=\"series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n fill=\"none\">\n</svg:path>\n<ng-container *ngIf=\"transform | async as t\">\n <svg:circle\n *ngIf=\"t?.x !=null && t?.y!=null\"\n r=\"3\"\n [attr.fill]=\"series.color\"\n [attr.transform]=\"'translate('+ t.x +', '+ t.y +')'\"\n >\n </svg:circle>\n</ng-container>\n<ng-container *ngIf=\"markers as draggablePoints\">\n <ng-container *ngIf=\"x && y\">\n <svg:g\n *ngFor=\"let point of draggablePoints\"\n [attr.transform]=\"'translate(' + x(point.x) + ',' + y(point.y) + ')'\">\n <svg:g [tetaDraggablePoint]=\"point.marker.draggable\"\n [dragDirection]=\"point.marker.dragType\"\n [allowDrag]=\"allowDrag(point)\"\n #dragPoint=\"tetaDraggablePoint\"\n (moveStart)=\"moveStart($event, point)\"\n (moveEnd)=\"moveEnd($event, point);dragPoint.resetTransform();\"\n (moveProcess)=\"moveProcess($event, point);dragPoint.resetTransform();\"\n [class.draggable-marker]=\"point?.marker?.draggable\">\n <svg:circle\n class=\"marker\"\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]=\"0\"\n [attr.cy]=\"0\">\n </svg:circle>\n <ng-container *ngIf=\"point.marker.label?.text\">\n <svg:line\n [attr.x1]=\"0\"\n [attr.y1]=\"0\"\n [attr.x2]=\"point.marker.label?.dx\"\n [attr.y2]=\"point.marker.label?.dy\"\n [attr.stroke]=\"point.marker.label?.style?.stroke ?? 'var(--color-text-90)'\"\n [attr.stroke-width]=\"point.marker.label?.style?.strokeWidth ?? 1\"\n [attr.stroke-dasharray]=\"point.marker.label?.style?.strokeDasharray ?? null\">\n </svg:line>\n <svg:foreignObject\n [tetaDraggablePoint]=\"point.marker.label?.draggable\"\n [dragDirection]=\"point.marker.label.dragType\"\n #labelPoint=\"tetaDraggablePoint\"\n (moveStart)=\"startLabel($event, point.marker.label)\"\n (moveProcess)=\"moveLabel($event, point.marker.label); labelPoint.resetTransform();\"\n (moveEnd)=\"labelPoint.resetTransform();\"\n [attr.width]=\"annotationNode?.offsetWidth ?? 0\"\n [attr.height]=\"annotationNode?.offsetHeight ?? 0\"\n [attr.x]=\"point.marker.label?.dx\"\n [attr.y]=\"point.marker.label?.dy\"\n class=\"position-absolute\">\n <div\n #annotationNode\n class=\"shadow-2 padding-2\"\n [style.color]=\"'var(--color-text-90)'\"\n [style.background-color]=\"'var(--color-background-50)'\"\n [style.cursor]=\"'move'\"\n style=\"border-radius: 2px; display: inline-block;\">\n {{point.marker.label?.text}}\n </div>\n </svg:foreignObject>\n </ng-container>\n </svg:g>\n </svg:g>\n </ng-container>\n\n</ng-container>\n\n\n\n", styles: [".draggable-marker{cursor:move}.active{stroke-opacity:.5}.marker-grab{opacity:0}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: DraggablePointDirective, selector: "[tetaDraggablePoint]", inputs: ["tetaDraggablePoint", "dragDirection", "allowDrag"], outputs: ["moveStart", "moveProcess", "moveEnd"], exportAs: ["tetaDraggablePoint"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1350
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: LineSeriesComponent, decorators: [{
1351
- type: Component,
1352
- args: [{ selector: 'svg:svg[teta-line-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:path\n class=\"line\"\n [attr.d]=\"path | async\"\n [attr.stroke]=\"series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n fill=\"none\">\n</svg:path>\n<ng-container *ngIf=\"transform | async as t\">\n <svg:circle\n *ngIf=\"t?.x !=null && t?.y!=null\"\n r=\"3\"\n [attr.fill]=\"series.color\"\n [attr.transform]=\"'translate('+ t.x +', '+ t.y +')'\"\n >\n </svg:circle>\n</ng-container>\n<ng-container *ngIf=\"markers as draggablePoints\">\n <ng-container *ngIf=\"x && y\">\n <svg:g\n *ngFor=\"let point of draggablePoints\"\n [attr.transform]=\"'translate(' + x(point.x) + ',' + y(point.y) + ')'\">\n <svg:g [tetaDraggablePoint]=\"point.marker.draggable\"\n [dragDirection]=\"point.marker.dragType\"\n [allowDrag]=\"allowDrag(point)\"\n #dragPoint=\"tetaDraggablePoint\"\n (moveStart)=\"moveStart($event, point)\"\n (moveEnd)=\"moveEnd($event, point);dragPoint.resetTransform();\"\n (moveProcess)=\"moveProcess($event, point);dragPoint.resetTransform();\"\n [class.draggable-marker]=\"point?.marker?.draggable\">\n <svg:circle\n class=\"marker\"\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]=\"0\"\n [attr.cy]=\"0\">\n </svg:circle>\n <ng-container *ngIf=\"point.marker.label?.text\">\n <svg:line\n [attr.x1]=\"0\"\n [attr.y1]=\"0\"\n [attr.x2]=\"point.marker.label?.dx\"\n [attr.y2]=\"point.marker.label?.dy\"\n [attr.stroke]=\"point.marker.label?.style?.stroke ?? 'var(--color-text-90)'\"\n [attr.stroke-width]=\"point.marker.label?.style?.strokeWidth ?? 1\"\n [attr.stroke-dasharray]=\"point.marker.label?.style?.strokeDasharray ?? null\">\n </svg:line>\n <svg:foreignObject\n [tetaDraggablePoint]=\"point.marker.label?.draggable\"\n [dragDirection]=\"point.marker.label.dragType\"\n #labelPoint=\"tetaDraggablePoint\"\n (moveStart)=\"startLabel($event, point.marker.label)\"\n (moveProcess)=\"moveLabel($event, point.marker.label); labelPoint.resetTransform();\"\n (moveEnd)=\"labelPoint.resetTransform();\"\n [attr.width]=\"annotationNode?.offsetWidth ?? 0\"\n [attr.height]=\"annotationNode?.offsetHeight ?? 0\"\n [attr.x]=\"point.marker.label?.dx\"\n [attr.y]=\"point.marker.label?.dy\"\n class=\"position-absolute\">\n <div\n #annotationNode\n class=\"shadow-2 padding-2\"\n [style.color]=\"'var(--color-text-90)'\"\n [style.background-color]=\"'var(--color-background-50)'\"\n [style.cursor]=\"'move'\"\n style=\"border-radius: 2px; display: inline-block;\">\n {{point.marker.label?.text}}\n </div>\n </svg:foreignObject>\n </ng-container>\n </svg:g>\n </svg:g>\n </ng-container>\n\n</ng-container>\n\n\n\n", styles: [".draggable-marker{cursor:move}.active{stroke-opacity:.5}.marker-grab{opacity:0}\n"] }]
1353
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1354
-
1355
- class BarSeriesComponent extends SeriesBaseComponent {
1356
- constructor(svc, cdr, scaleService, zoomService, element) {
1357
- super(svc, cdr, scaleService, zoomService, element);
1358
- this.svc = svc;
1359
- this.cdr = cdr;
1360
- this.scaleService = scaleService;
1361
- this.zoomService = zoomService;
1362
- this.element = element;
1363
- this.Math = Math;
1364
- }
1365
- ngOnInit() {
1366
- this.barSeriesCount = this.svc.config.pipe(map((_) => {
1367
- const count = _.series.filter((_) => _.type === SeriesType.bar && _.xAxisIndex === this.series.xAxisIndex);
1368
- return count.length;
1369
- }));
1370
- this.x1 = this.scaleService.scales.pipe(map((_) => {
1371
- var _a;
1372
- const x = (_a = _.x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale;
1373
- const range = x.range();
1374
- const domain = this.series.data.map((_) => _.x);
1375
- return d3
1376
- .scaleBand()
1377
- .range([0, range[1]])
1378
- .domain(domain)
1379
- .padding(0.1);
1380
- }));
1381
- this.x = this.scaleService.scales.pipe(map((_) => { var _a; return (_a = _.x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1382
- this.y = this.scaleService.scales.pipe(map((_) => { var _a; return (_a = _.y.get(this.series.yAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1383
- }
1384
- mouseenter(point) {
1385
- this.svc.setTooltip({
1386
- point: point,
1387
- series: this.series,
1388
- });
1389
- }
1390
- mouseleave(point) {
1391
- this.svc.setTooltip({
1392
- point: null,
1393
- series: this.series,
1394
- });
1395
- }
1396
- ngOnChanges(changes) { }
1397
- }
1398
- BarSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BarSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1399
- BarSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: BarSeriesComponent, selector: "svg:svg[teta-bar-series]", usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n x: x | async,\n x1: x1 | async,\n y: y | async,\n barSeriesCount: barSeriesCount | async\n} as data\">\n <ng-container *ngIf=\"data.x && data.y\">\n <ng-container *ngIf=\"data.barSeriesCount > 1\">\n <svg:rect\n *ngFor=\"let point of series.data\"\n (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\"\n [attr.x]=\"data.x(point.x) + (series.id * data.x1.bandwidth() / data.barSeriesCount)\"\n [attr.y]=\"point.y > 0 ? data.y(point.y) : data.y(0)\"\n [attr.width]=\"data.x1.bandwidth() / data.barSeriesCount\"\n [attr.height]=\"Math.abs(data.y(point.y) - data.y(0))\"\n [attr.fill]=\"series.color\"\n ></svg:rect>\n </ng-container>\n <ng-container *ngIf=\"data.barSeriesCount === 1\">\n <svg:rect\n *ngFor=\"let point of series.data\"\n (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"point.y > 0 ? data.y(point.y) : data.y(0)\"\n [attr.width]=\"data.x1.bandwidth()\"\n [attr.height]=\"Math.abs(data.y(point.y) - data.y(0))\"\n [attr.fill]=\"point.color ?? series.color\"\n ></svg:rect>\n </ng-container>\n </ng-container>\n</ng-container>\n\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1400
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BarSeriesComponent, decorators: [{
1401
- type: Component,
1402
- args: [{ selector: 'svg:svg[teta-bar-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n x: x | async,\n x1: x1 | async,\n y: y | async,\n barSeriesCount: barSeriesCount | async\n} as data\">\n <ng-container *ngIf=\"data.x && data.y\">\n <ng-container *ngIf=\"data.barSeriesCount > 1\">\n <svg:rect\n *ngFor=\"let point of series.data\"\n (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\"\n [attr.x]=\"data.x(point.x) + (series.id * data.x1.bandwidth() / data.barSeriesCount)\"\n [attr.y]=\"point.y > 0 ? data.y(point.y) : data.y(0)\"\n [attr.width]=\"data.x1.bandwidth() / data.barSeriesCount\"\n [attr.height]=\"Math.abs(data.y(point.y) - data.y(0))\"\n [attr.fill]=\"series.color\"\n ></svg:rect>\n </ng-container>\n <ng-container *ngIf=\"data.barSeriesCount === 1\">\n <svg:rect\n *ngFor=\"let point of series.data\"\n (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"point.y > 0 ? data.y(point.y) : data.y(0)\"\n [attr.width]=\"data.x1.bandwidth()\"\n [attr.height]=\"Math.abs(data.y(point.y) - data.y(0))\"\n [attr.fill]=\"point.color ?? series.color\"\n ></svg:rect>\n </ng-container>\n </ng-container>\n</ng-container>\n\n" }]
1403
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1404
-
1405
- class ScatterSeriesComponent extends SeriesBaseComponent {
1406
- constructor(svc, cdr, scaleService, zoomService, element) {
1407
- super(svc, cdr, scaleService, zoomService, element);
1408
- this.svc = svc;
1409
- this.cdr = cdr;
1410
- this.scaleService = scaleService;
1411
- this.zoomService = zoomService;
1412
- this.element = element;
1413
- }
1414
- ngOnInit() {
1415
- this.x = this.scaleService.scales.pipe(map(_ => { var _a; return (_a = _.x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1416
- this.y = this.scaleService.scales.pipe(map(_ => { var _a; return (_a = _.y.get(this.series.yAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1417
- }
1418
- ngAfterViewInit() {
1419
- }
1420
- mouseenter(point) {
1421
- this.svc.setTooltip({
1422
- point: point,
1423
- series: this.series,
1424
- });
1425
- }
1426
- mouseleave(point) {
1427
- this.svc.setTooltip({
1428
- point: null,
1429
- series: this.series,
1430
- });
1431
- }
1432
- }
1433
- ScatterSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ScatterSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1434
- ScatterSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: ScatterSeriesComponent, selector: "svg:svg[teta-scatter-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async\n} as scales\">\n <ng-container *ngIf=\"scales.x && scales.y\">\n <svg:circle\n class=\"line\"\n *ngFor=\"let point of series.data\"\n (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\"\n [attr.cx]=\"scales.x(point.x)\"\n [attr.cy]=\"scales.y(point.y)\"\n [attr.r]=\"series.style?.radius ?? 1\"\n [attr.stroke]=\"point.color ?? series.color\"\n [attr.fill]=\"point.color ?? series.color\"\n [attr.stroke-width]=\"series.style?.strokeWidth\">\n </svg:circle>\n </ng-container>\n</ng-container>\n\n\n\n", styles: [".draggable-marker{cursor:move}.active{stroke-opacity:.5}.marker-grab{opacity:0}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1435
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ScatterSeriesComponent, decorators: [{
1436
- type: Component,
1437
- args: [{ selector: 'svg:svg[teta-scatter-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async\n} as scales\">\n <ng-container *ngIf=\"scales.x && scales.y\">\n <svg:circle\n class=\"line\"\n *ngFor=\"let point of series.data\"\n (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\"\n [attr.cx]=\"scales.x(point.x)\"\n [attr.cy]=\"scales.y(point.y)\"\n [attr.r]=\"series.style?.radius ?? 1\"\n [attr.stroke]=\"point.color ?? series.color\"\n [attr.fill]=\"point.color ?? series.color\"\n [attr.stroke-width]=\"series.style?.strokeWidth\">\n </svg:circle>\n </ng-container>\n</ng-container>\n\n\n\n", styles: [".draggable-marker{cursor:move}.active{stroke-opacity:.5}.marker-grab{opacity:0}\n"] }]
1438
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1439
-
1440
- class BlockSeriesComponent extends SeriesBaseComponent {
1441
- constructor(svc, cdr, scaleService, zoomService, element) {
1442
- super(svc, cdr, scaleService, zoomService, element);
1443
- this.svc = svc;
1444
- this.cdr = cdr;
1445
- this.scaleService = scaleService;
1446
- this.zoomService = zoomService;
1447
- this.element = element;
1448
- this.fillType = FillType;
1449
- this.Math = Math;
1450
- this.id = (Date.now() + Math.random()).toString(36);
1451
- }
1452
- ngOnInit() {
1453
- this.x = this.scaleService.scales.pipe(map((_) => { var _a; return (_a = _.x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1454
- this.y = this.scaleService.scales.pipe(map((_) => { var _a; return (_a = _.y.get(this.series.yAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1455
- this.displayPoints = this.y.pipe(filter((y) => y), map((y) => {
1456
- return this.series.data.filter((point, index, arr) => {
1457
- var _a, _b, _c, _d;
1458
- const [min, max] = y.domain();
1459
- return (point.y >= min ||
1460
- point.y1 >= min ||
1461
- ((_a = arr[index + 1]) === null || _a === void 0 ? void 0 : _a.y) >= min ||
1462
- ((_b = arr[index + 1]) === null || _b === void 0 ? void 0 : _b.y1) >= min) &&
1463
- (point.y <= max ||
1464
- point.y1 <= max ||
1465
- ((_c = arr[index - 1]) === null || _c === void 0 ? void 0 : _c.y) <= max ||
1466
- ((_d = arr[index - 1]) === null || _d === void 0 ? void 0 : _d.y1) <= max);
1467
- });
1468
- }));
1469
- }
1470
- mouseenter(point) {
1471
- this.svc.setTooltip({
1472
- point: point,
1473
- series: this.series,
1474
- });
1475
- }
1476
- mouseleave(point) {
1477
- this.svc.setTooltip({
1478
- point: null,
1479
- series: this.series,
1480
- });
1481
- }
1482
- ngAfterViewInit() {
1483
- }
1484
- }
1485
- BlockSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BlockSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1486
- BlockSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: BlockSeriesComponent, selector: "svg:svg[teta-block-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngIf=\"data.x && data.y\">\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n x=\"0\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.style?.fill ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n width=\"100%\">\n </svg:rect>\n <svg:text *ngIf=\"point.text && data.y(point.y1) - data.y(point.y) > 8\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.style?.stroke ?? series.color\"></svg:line>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.style?.stroke ?? series.color\"></svg:line>\n </svg:g>\n </ng-container>\n\n </ng-container>\n</ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1487
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BlockSeriesComponent, decorators: [{
1488
- type: Component,
1489
- args: [{ selector: 'svg:svg[teta-block-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngIf=\"data.x && data.y\">\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n x=\"0\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.style?.fill ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n width=\"100%\">\n </svg:rect>\n <svg:text *ngIf=\"point.text && data.y(point.y1) - data.y(point.y) > 8\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.style?.stroke ?? series.color\"></svg:line>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.style?.stroke ?? series.color\"></svg:line>\n </svg:g>\n </ng-container>\n\n </ng-container>\n</ng-container>\n" }]
1490
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1491
-
1492
- class BlockAreaSeriesComponent extends SeriesBaseComponent {
1493
- constructor(svc, cdr, scaleService, zoomService, element) {
1494
- super(svc, cdr, scaleService, zoomService, element);
1495
- this.svc = svc;
1496
- this.cdr = cdr;
1497
- this.scaleService = scaleService;
1498
- this.zoomService = zoomService;
1499
- this.element = element;
1500
- this.fillType = FillType;
1501
- this.Math = Math;
1502
- this.id = (Date.now() + Math.random()).toString(36);
1503
- }
1504
- ngOnInit() {
1505
- this.x = this.scaleService.scales.pipe(map((_) => { var _a; return (_a = _.x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1506
- this.y = this.scaleService.scales.pipe(map((_) => { var _a; return (_a = _.y.get(this.series.yAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
1507
- this.displayPoints = this.y.pipe(filter((y) => y), map((y) => {
1508
- return this.series.data.filter((point, index, arr) => {
1509
- var _a, _b, _c, _d;
1510
- const [min, max] = y.domain();
1511
- return (point.y >= min ||
1512
- point.y1 >= min ||
1513
- ((_a = arr[index + 1]) === null || _a === void 0 ? void 0 : _a.y) >= min ||
1514
- ((_b = arr[index + 1]) === null || _b === void 0 ? void 0 : _b.y1) >= min) &&
1515
- (point.y <= max ||
1516
- point.y1 <= max ||
1517
- ((_c = arr[index - 1]) === null || _c === void 0 ? void 0 : _c.y) <= max ||
1518
- ((_d = arr[index - 1]) === null || _d === void 0 ? void 0 : _d.y1) <= max);
1519
- });
1520
- }));
1521
- }
1522
- ngAfterViewInit() {
1523
- }
1524
- mouseenter(point) {
1525
- this.svc.setTooltip({
1526
- point: point,
1527
- series: this.series,
1528
- });
1529
- }
1530
- mouseleave(point) {
1531
- this.svc.setTooltip({
1532
- point: null,
1533
- series: this.series,
1534
- });
1535
- }
1536
- }
1537
- BlockAreaSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BlockAreaSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1538
- BlockAreaSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: BlockAreaSeriesComponent, selector: "svg:svg[teta-block-area-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\"\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngIf=\"data.x && data.y\">\n\n\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n *ngIf=\"!!config.inverted\"\n [attr.x]=\"data.x(0) < data.x(point.x) ? data.x(0) : data.x(point.x)\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.width]=\"data.x(0) < data.x(point.x) ? data.x(point.x) - data.x(0) : data.x(0) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.style?.stroke ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.style?.fill ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:rect\n *ngIf=\"!config.inverted\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"data.y(0)\"\n [attr.height]=\"Math.abs(data.y(0) - data.y(point.y))\"\n [attr.width]=\"data.x(point.x1) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:text *ngIf=\"point.text\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\" [attr.stroke]=\"point.iconId ? 'var(&#45;&#45;color-text-10)' : point.color ?? series.color\"></svg:line>-->\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\" [attr.stroke]=\"point.iconId ? 'var(&#45;&#45;color-text-10)' : point.color ?? series.color\"></svg:line>-->\n\n </svg:g>\n </ng-container>\n\n </ng-container>\n</ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1539
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BlockAreaSeriesComponent, decorators: [{
1540
- type: Component,
1541
- args: [{ selector: 'svg:svg[teta-block-area-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\"\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.style?.fill ?? series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngIf=\"data.x && data.y\">\n\n\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n *ngIf=\"!!config.inverted\"\n [attr.x]=\"data.x(0) < data.x(point.x) ? data.x(0) : data.x(point.x)\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.width]=\"data.x(0) < data.x(point.x) ? data.x(point.x) - data.x(0) : data.x(0) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.style?.stroke ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.style?.fill ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:rect\n *ngIf=\"!config.inverted\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"data.y(0)\"\n [attr.height]=\"Math.abs(data.y(0) - data.y(point.y))\"\n [attr.width]=\"data.x(point.x1) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:text *ngIf=\"point.text\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\" [attr.stroke]=\"point.iconId ? 'var(&#45;&#45;color-text-10)' : point.color ?? series.color\"></svg:line>-->\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\" [attr.stroke]=\"point.iconId ? 'var(&#45;&#45;color-text-10)' : point.color ?? series.color\"></svg:line>-->\n\n </svg:g>\n </ng-container>\n\n </ng-container>\n</ng-container>\n" }]
1542
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1543
-
1544
- class AreaSeriesComponent extends LinearSeriesBase {
1545
- constructor(svc, cdr, scaleService, zoomService, element) {
1546
- super(svc, cdr, scaleService, zoomService, element);
1547
- this.svc = svc;
1548
- this.cdr = cdr;
1549
- this.scaleService = scaleService;
1550
- this.zoomService = zoomService;
1551
- this.element = element;
1552
- this.fillDirection = FillDirection;
1553
- this.fillType = FillType;
1554
- this.id = (Date.now() + Math.random()).toString(36);
1555
- }
1556
- ngOnInit() {
1557
- super.ngOnInit();
1558
- this.areaPath = this.scaleService.scales.pipe(map((data) => {
1559
- var _a, _b;
1560
- const { x, y } = data;
1561
- this.x = (_a = x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale;
1562
- this.y = (_b = y.get(this.series.yAxisIndex)) === null || _b === void 0 ? void 0 : _b.scale;
1563
- if (!this.x || !this.y) {
1564
- return '';
1565
- }
1566
- const area = d3
1567
- .area()
1568
- .defined((point) => point.x !== null &&
1569
- point.y !== null &&
1570
- !isNaN(point.x) &&
1571
- !isNaN(point.y));
1572
- area
1573
- .x1((_) => _.x1 !== null && _.x1 !== undefined ? this.x(_.x1) : this.x(0))
1574
- .x0((_) => this.x(_.x))
1575
- .y((_) => this.y(_.y));
1576
- const filter = this.defaultClipPointsMapping.get(this.series.clipPointsDirection);
1577
- let filteredData = this.series.data;
1578
- if (this.series.clipPointsDirection === ClipPointsDirection.x) {
1579
- let [min, max] = this.x.domain();
1580
- min = min instanceof Date ? min.getTime() : min;
1581
- max = max instanceof Date ? max.getTime() : max;
1582
- filteredData = filteredData === null || filteredData === void 0 ? void 0 : filteredData.filter(filter(min, max));
1583
- }
1584
- if (this.series.clipPointsDirection === ClipPointsDirection.y) {
1585
- let [min, max] = this.y.domain();
1586
- min = min instanceof Date ? min.getTime() : min;
1587
- max = max instanceof Date ? max.getTime() : max;
1588
- filteredData = filteredData === null || filteredData === void 0 ? void 0 : filteredData.filter(filter(min, max));
1589
- }
1590
- return area(filteredData);
1591
- }));
1592
- }
1593
- }
1594
- AreaSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: AreaSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1595
- AreaSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: AreaSeriesComponent, selector: "svg:svg[teta-area-series]", usesInheritance: true, ngImport: i0, template: "<svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted || series?.fillDirection === fillDirection.y ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted || series?.fillDirection === fillDirection.y ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.8\"></svg:stop>\n </svg:linearGradient>\n</svg:defs>\n<svg:path\n class=\"area\"\n [attr.d]=\"areaPath | async\"\n [attr.stroke-width]=\"0\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : series.style?.fill ?? series.color\">\n</svg:path>\n<svg:path\n class=\"area\"\n fill=\"none\"\n [attr.d]=\"path | async\"\n [attr.stroke]=\"series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\">\n</svg:path>\n<ng-container *ngIf=\"transform | async as t\">\n <svg:circle\n *ngIf=\"t?.x !=null && t?.y !=null\"\n r=\"3\"\n [attr.fill]=\"series.color\"\n [attr.transform]=\"'translate('+ t.x +', '+ t.y +')'\"\n >\n </svg:circle>\n</ng-container>\n<ng-container *ngIf=\"markers as draggablePoints\">\n <svg:circle\n class=\"marker\"\n *ngFor=\"let point of draggablePoints\"\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</ng-container>\n\n\n\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1596
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: AreaSeriesComponent, decorators: [{
1597
- type: Component,
1598
- args: [{ selector: 'svg:svg[teta-area-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted || series?.fillDirection === fillDirection.y ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted || series?.fillDirection === fillDirection.y ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.8\"></svg:stop>\n </svg:linearGradient>\n</svg:defs>\n<svg:path\n class=\"area\"\n [attr.d]=\"areaPath | async\"\n [attr.stroke-width]=\"0\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : series.style?.fill ?? series.color\">\n</svg:path>\n<svg:path\n class=\"area\"\n fill=\"none\"\n [attr.d]=\"path | async\"\n [attr.stroke]=\"series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\">\n</svg:path>\n<ng-container *ngIf=\"transform | async as t\">\n <svg:circle\n *ngIf=\"t?.x !=null && t?.y !=null\"\n r=\"3\"\n [attr.fill]=\"series.color\"\n [attr.transform]=\"'translate('+ t.x +', '+ t.y +')'\"\n >\n </svg:circle>\n</ng-container>\n<ng-container *ngIf=\"markers as draggablePoints\">\n <svg:circle\n class=\"marker\"\n *ngFor=\"let point of draggablePoints\"\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</ng-container>\n\n\n\n" }]
1599
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
1600
-
1601
- const defaultSeriesTypeMapping = new Map()
1602
- .set(SeriesType.line, LineSeriesComponent)
1603
- .set(SeriesType.bar, BarSeriesComponent)
1604
- .set(SeriesType.scatter, ScatterSeriesComponent)
1605
- .set(SeriesType.block, BlockSeriesComponent)
1606
- .set(SeriesType.area, AreaSeriesComponent)
1607
- .set(SeriesType.blockArea, BlockAreaSeriesComponent);
1608
-
1609
- class SeriesHostComponent {
1610
- constructor(viewContainerRef) {
1611
- this.viewContainerRef = viewContainerRef;
1612
- this._init = false;
1613
- }
1614
- ngOnInit() {
1615
- if (!SeriesBaseComponent.isPrototypeOf(this.series.component)) {
1616
- this.series.component =
1617
- defaultSeriesTypeMapping.get(this.series.type) || LineSeriesComponent;
1618
- }
1619
- this._componentRef = this.viewContainerRef.createComponent(this.series.component);
1620
- this._componentRef.instance.config = this.config;
1621
- this._componentRef.instance.series = this.series;
1622
- this._init = true;
1623
- }
1624
- ngOnDestroy() {
1625
- this._componentRef.destroy();
1626
- }
1627
- ngOnChanges(changes) {
1628
- if (this._init && (changes.hasOwnProperty('series') || changes.hasOwnProperty('config'))) {
1629
- this._componentRef.instance.config = this.config;
1630
- this._componentRef.instance.series = this.series;
1631
- this._componentRef.injector.get(ChangeDetectorRef).detectChanges();
1632
- }
1633
- }
1634
- }
1635
- SeriesHostComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: SeriesHostComponent, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
1636
- SeriesHostComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: SeriesHostComponent, selector: "[teta-series-host]", inputs: { config: "config", series: "series" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1637
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: SeriesHostComponent, decorators: [{
1638
- type: Component,
1639
- args: [{
1640
- selector: '[teta-series-host]',
1641
- template: '',
1642
- changeDetection: ChangeDetectionStrategy.OnPush,
1643
- }]
1644
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; }, propDecorators: { config: [{
1645
- type: Input
1646
- }], series: [{
1647
- type: Input
1648
- }] } });
1649
-
1650
- class GridlinesComponent {
1651
- constructor(svc, chartService) {
1652
- this.svc = svc;
1653
- this.chartService = chartService;
1654
- this.config = this.chartService.config;
1655
- this.tickYValues = this.svc.scales.pipe(withLatestFrom(this.config), map((_) => {
1656
- var _a, _b, _c, _d, _e;
1657
- const [scales, config] = _;
1658
- const ratio = this.size.height / 40;
1659
- return ((_b = (_a = config.gridLines) === null || _a === void 0 ? void 0 : _a.y) === null || _b === void 0 ? void 0 : _b.ticksCount) != null ? generateTicks(scales.y.get(0).scale.domain(), (_d = (_c = config.gridLines) === null || _c === void 0 ? void 0 : _c.y) === null || _d === void 0 ? void 0 : _d.ticksCount) : (_e = scales.y.get(0)) === null || _e === void 0 ? void 0 : _e.scale.ticks(ratio);
1660
- }));
1661
- this.tickXValues = this.svc.scales.pipe(withLatestFrom(this.config), map((_) => {
1662
- var _a, _b, _c, _d, _e;
1663
- const [scales, config] = _;
1664
- const ratio = this.size.width / 40;
1665
- return ((_b = (_a = config.gridLines) === null || _a === void 0 ? void 0 : _a.x) === null || _b === void 0 ? void 0 : _b.ticksCount) != null ? generateTicks(scales.x.get(0).originDomain, (_d = (_c = config.gridLines) === null || _c === void 0 ? void 0 : _c.x) === null || _d === void 0 ? void 0 : _d.ticksCount) : (_e = scales.x.get(0)) === null || _e === void 0 ? void 0 : _e.scale.ticks(ratio);
1666
- }));
1667
- this.y = this.svc.scales.pipe(map((_) => { var _a; return (_a = _.y.get(0)) === null || _a === void 0 ? void 0 : _a.scale; }));
1668
- this.x = this.svc.scales.pipe(map((_) => { var _a; return (_a = _.x.get(0)) === null || _a === void 0 ? void 0 : _a.scale; }));
1669
- }
1670
- ngAfterViewInit() {
1671
- }
1672
- }
1673
- GridlinesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: GridlinesComponent, deps: [{ token: ScaleService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Component });
1674
- GridlinesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: GridlinesComponent, selector: "[teta-gridlines]", inputs: { size: "size" }, ngImport: i0, template: "<ng-container *ngIf=\"{\n xValues: tickXValues | async,\n yValues: tickYValues | async,\n x: x | async,\n y: y | async,\n config: config | async\n} as data\">\n <ng-container *ngIf=\"data.y && data.config.gridLines?.showY !== false\">\n <ng-container *ngFor=\"let tick of data.yValues\">\n <svg:line [attr.x1]=\"0\"\n [attr.y1]=\"data.y(tick) || 1\"\n [attr.x2]=\"size?.width\"\n [attr.y2]=\"data.y(tick) || 1\"></svg:line>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"data.x && data.config.gridLines?.showX !== false\">\n <ng-container *ngFor=\"let tick of data.xValues\">\n <svg:line [attr.x1]=\"data.x(tick) || 1\"\n [attr.y1]=\"0\"\n [attr.x2]=\"data.x(tick) || 1\"\n [attr.y2]=\"size?.height\"></svg:line>\n </ng-container>\n </ng-container>\n\n</ng-container>\n\n\n", styles: [":host{shape-rendering:crispEdges}:host line{stroke:var(--color-text-5)}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1675
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: GridlinesComponent, decorators: [{
1676
- type: Component,
1677
- args: [{ selector: '[teta-gridlines]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n xValues: tickXValues | async,\n yValues: tickYValues | async,\n x: x | async,\n y: y | async,\n config: config | async\n} as data\">\n <ng-container *ngIf=\"data.y && data.config.gridLines?.showY !== false\">\n <ng-container *ngFor=\"let tick of data.yValues\">\n <svg:line [attr.x1]=\"0\"\n [attr.y1]=\"data.y(tick) || 1\"\n [attr.x2]=\"size?.width\"\n [attr.y2]=\"data.y(tick) || 1\"></svg:line>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"data.x && data.config.gridLines?.showX !== false\">\n <ng-container *ngFor=\"let tick of data.xValues\">\n <svg:line [attr.x1]=\"data.x(tick) || 1\"\n [attr.y1]=\"0\"\n [attr.x2]=\"data.x(tick) || 1\"\n [attr.y2]=\"size?.height\"></svg:line>\n </ng-container>\n </ng-container>\n\n</ng-container>\n\n\n", styles: [":host{shape-rendering:crispEdges}:host line{stroke:var(--color-text-5)}\n"] }]
1678
- }], ctorParameters: function () { return [{ type: ScaleService }, { type: ChartService }]; }, propDecorators: { size: [{
1679
- type: Input
1680
- }] } });
1681
-
1682
- class XAxisComponent {
1683
- constructor(scaleService, _svc) {
1684
- this.scaleService = scaleService;
1685
- this._svc = _svc;
1686
- this.update$ = new BehaviorSubject(null);
1687
- this._alive = true;
1688
- this.x = this.scaleService.scales.pipe(map((_) => {
1689
- var _a;
1690
- return (_a = _.x.get(this.axis.index)) === null || _a === void 0 ? void 0 : _a.scale;
1691
- }));
1692
- this.ticks = combineLatest([this.x, this.update$]).pipe(withLatestFrom(this._svc.size), map((_) => {
1693
- const [[x], size] = _;
1694
- const tickSize = x.ticks().map((_) => getTextWidth(this.axis.options.tickFormat ? this.axis.options.tickFormat(_) : this.axis.defaultFormatter()(_), 0.45, 11));
1695
- return x.ticks(size.width / parseInt(d3.max(tickSize), 10) / 5);
1696
- }));
1697
- }
1698
- getLabelTransform() {
1699
- return `translate(${this.size.width / 2}, ${this.axis.options.opposite ? -32 : 32})`;
1700
- }
1701
- ngOnInit() {
1702
- }
1703
- ngOnDestroy() {
1704
- this._alive = false;
1705
- }
1706
- ngOnChanges(changes) {
1707
- if (changes.hasOwnProperty('axis')) {
1708
- this.update$.next();
1709
- }
1710
- }
1711
- }
1712
- XAxisComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: XAxisComponent, deps: [{ token: ScaleService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Component });
1713
- XAxisComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: XAxisComponent, selector: "[teta-x-axis]", inputs: { axis: "axis", size: "size" }, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"{x: x | async, ticks: ticks | async} as data\">\n <svg:g text-anchor=\"middle\" *ngFor=\"let tick of data.ticks\" [attr.transform]=\"'translate('+ data.x(tick) +', 0)'\">\n <text fill=\"var(--color-text-70)\" [attr.dy]=\"axis.options.opposite ? '-0.71em' : '0.71em'\" [attr.y]=\"axis.options.opposite ? 0 : 9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.y2]=\"axis.options.opposite ? -6 : 6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text fill=\"var(--color-text-70)\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1714
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: XAxisComponent, decorators: [{
1715
- type: Component,
1716
- args: [{ selector: '[teta-x-axis]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{x: x | async, ticks: ticks | async} as data\">\n <svg:g text-anchor=\"middle\" *ngFor=\"let tick of data.ticks\" [attr.transform]=\"'translate('+ data.x(tick) +', 0)'\">\n <text fill=\"var(--color-text-70)\" [attr.dy]=\"axis.options.opposite ? '-0.71em' : '0.71em'\" [attr.y]=\"axis.options.opposite ? 0 : 9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.y2]=\"axis.options.opposite ? -6 : 6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text fill=\"var(--color-text-70)\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"] }]
1717
- }], ctorParameters: function () { return [{ type: ScaleService }, { type: ChartService }]; }, propDecorators: { axis: [{
1718
- type: Input
1719
- }], size: [{
1720
- type: Input
1721
- }] } });
1722
-
1723
- class YAxisComponent {
1724
- constructor(scaleService) {
1725
- this.scaleService = scaleService;
1726
- this._alive = true;
1727
- this.y = this.scaleService.scales.pipe(map((_) => {
1728
- var _a;
1729
- return (_a = _.y.get(this.axis.index)) === null || _a === void 0 ? void 0 : _a.scale;
1730
- }));
1731
- }
1732
- ngOnInit() { }
1733
- ngOnDestroy() {
1734
- this._alive = false;
1735
- }
1736
- ngAfterViewInit() {
1737
- }
1738
- getLabelTransform() {
1739
- return `translate(${this.axis.options.opposite
1740
- ? this.axis.selfSize
1741
- : -this.axis.selfSize}, ${this.size.height / 2}) rotate(-90)`;
1742
- }
1743
- }
1744
- YAxisComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: YAxisComponent, deps: [{ token: ScaleService }], target: i0.ɵɵFactoryTarget.Component });
1745
- YAxisComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: YAxisComponent, selector: "[teta-y-axis]", inputs: { axis: "axis", size: "size" }, ngImport: i0, template: "<ng-container *ngIf=\"y | async as scale\">\n <svg:g [attr.text-anchor]=\"axis.options.opposite ? 'start' : 'end'\" *ngFor=\"let tick of scale.ticks()\" [attr.transform]=\"'translate(0, '+ scale(tick) +')'\">\n <text fill=\"var(--color-text-70)\" dy=\"0.32em\" [attr.x]=\"axis.options.opposite ? 10 : -9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.x2]=\"axis.options.opposite ? 6 : -6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text [attr.dy]=\"axis.options.opposite ? '-4px' : '4px'\" text-anchor=\"middle\" [attr.dominant-baseline]=\"axis.options.opposite ? 'auto' : 'hanging'\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host{shape-rendering:crispEdges}:host .label-axis{fill:var(--color-text-70)}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1746
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: YAxisComponent, decorators: [{
1747
- type: Component,
1748
- args: [{ selector: '[teta-y-axis]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"y | async as scale\">\n <svg:g [attr.text-anchor]=\"axis.options.opposite ? 'start' : 'end'\" *ngFor=\"let tick of scale.ticks()\" [attr.transform]=\"'translate(0, '+ scale(tick) +')'\">\n <text fill=\"var(--color-text-70)\" dy=\"0.32em\" [attr.x]=\"axis.options.opposite ? 10 : -9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.x2]=\"axis.options.opposite ? 6 : -6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text [attr.dy]=\"axis.options.opposite ? '-4px' : '4px'\" text-anchor=\"middle\" [attr.dominant-baseline]=\"axis.options.opposite ? 'auto' : 'hanging'\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host{shape-rendering:crispEdges}:host .label-axis{fill:var(--color-text-70)}\n"] }]
1749
- }], ctorParameters: function () { return [{ type: ScaleService }]; }, propDecorators: { axis: [{
1750
- type: Input
1751
- }], size: [{
1752
- type: Input
1753
- }] } });
1754
-
1755
- class PlotlineComponent {
1756
- constructor(cdr, zoomService, scaleService, chartService, element) {
1757
- this.cdr = cdr;
1758
- this.zoomService = zoomService;
1759
- this.scaleService = scaleService;
1760
- this.chartService = chartService;
1761
- this.element = element;
1762
- this.orientation = AxisOrientation;
1763
- }
1764
- ngOnInit() {
1765
- this._domain = this.scale.domain();
1766
- const plotlineElement = d3
1767
- .select(this.element.nativeElement)
1768
- .select('.plotline');
1769
- const grabElement = d3
1770
- .select(this.element.nativeElement)
1771
- .selectAll('.grabber');
1772
- this.dragElements = d3
1773
- .drag()
1774
- .subject(() => {
1775
- if (this.axis.orientation === AxisOrientation.y) {
1776
- return { y: plotlineElement.attr('y1') };
1777
- }
1778
- if (this.axis.orientation === AxisOrientation.x) {
1779
- return { x: plotlineElement.attr('x1') };
1780
- }
1781
- });
1782
- const drag = this.dragElements
1783
- .on('start drag end', (event, d) => {
1784
- d.value = this.scale.invert(event[AxisOrientation[this.axis.orientation]]);
1785
- if (d.max !== null && d.max !== undefined && d.value >= d.max) {
1786
- d.value = d.max;
1787
- }
1788
- if (d.min !== null && d.min !== undefined && d.value <= d.min) {
1789
- d.value = d.min;
1790
- }
1791
- this.emit({
1792
- event,
1793
- target: d,
1794
- });
1795
- this.cdr.detectChanges();
1796
- });
1797
- plotlineElement.datum(this.plotLine);
1798
- grabElement.datum(this.plotLine);
1799
- if (this.plotLine.draggable) {
1800
- grabElement.call(drag);
1801
- }
1802
- }
1803
- ngOnDestroy() {
1804
- this.dragElements.on('start drag end', null);
1805
- }
1806
- emit(event) {
1807
- this.chartService.emitPlotline(event);
1808
- }
1809
- get value() {
1810
- return this.scale(this.plotLine.value);
1811
- }
1812
- get height() {
1813
- return this.size.height;
1814
- }
1815
- get width() {
1816
- return this.size.width;
1817
- }
1818
- }
1819
- PlotlineComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PlotlineComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: ZoomService }, { token: ScaleService }, { token: ChartService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1820
- PlotlineComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: PlotlineComponent, selector: "[teta-plot-line]", inputs: { plotLine: "plotLine", size: "size", axis: "axis", scale: "scale" }, 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\n<svg:text\n *ngIf=\"axis.orientation === orientation.x\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n class=\"label font-title-2 fill-text-70\"\n [attr.x]=\"value\"\n dy=\"-2em\"\n [attr.transform]=\"'rotate(-90, '+ value +',' + height / 2 + ')'\"\n [attr.y]=\"height / 2\">{{plotLine.label}}\n</svg:text>\n\n<svg:text\n *ngIf=\"axis.orientation === orientation.y\"\n text-anchor=\"middle\"\n class=\"label font-title-2 fill-text-70\"\n dominant-baseline=\"central\"\n [attr.x]=\"value\"\n [attr.y]=\"width / 2\">{{plotLine.label}}\n</svg:text>\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"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1821
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PlotlineComponent, decorators: [{
1822
- type: Component,
1823
- 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\n<svg:text\n *ngIf=\"axis.orientation === orientation.x\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n class=\"label font-title-2 fill-text-70\"\n [attr.x]=\"value\"\n dy=\"-2em\"\n [attr.transform]=\"'rotate(-90, '+ value +',' + height / 2 + ')'\"\n [attr.y]=\"height / 2\">{{plotLine.label}}\n</svg:text>\n\n<svg:text\n *ngIf=\"axis.orientation === orientation.y\"\n text-anchor=\"middle\"\n class=\"label font-title-2 fill-text-70\"\n dominant-baseline=\"central\"\n [attr.x]=\"value\"\n [attr.y]=\"width / 2\">{{plotLine.label}}\n</svg:text>\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"] }]
1824
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: ZoomService }, { type: ScaleService }, { type: ChartService }, { type: i0.ElementRef }]; }, propDecorators: { plotLine: [{
1825
- type: Input
1826
- }], size: [{
1827
- type: Input
1828
- }], axis: [{
1829
- type: Input
1830
- }], scale: [{
1831
- type: Input
1832
- }] } });
1833
-
1834
- class PlotBandComponent {
1835
- constructor(scaleService, zoomService, chartService, cdr, element) {
1836
- this.scaleService = scaleService;
1837
- this.zoomService = zoomService;
1838
- this.chartService = chartService;
1839
- this.cdr = cdr;
1840
- this.element = element;
1841
- this.orientation = AxisOrientation;
1842
- this.getTextPosition = () => {
1843
- let [min, max] = this.scale.domain();
1844
- min = min instanceof Date ? min.getTime() : min;
1845
- max = max instanceof Date ? max.getTime() : max;
1846
- const from = this.plotBand.from instanceof Date ? this.plotBand.from.getTime() : this.plotBand.from;
1847
- const to = this.plotBand.to instanceof Date ? this.plotBand.to.getTime() : this.plotBand.to;
1848
- const position = ((from <= min ? min : from) + (to >= max ? max : to)) / 2;
1849
- return this.scale(position);
1850
- };
1851
- }
1852
- click(event) {
1853
- this.emit({
1854
- target: this.plotBand,
1855
- event,
1856
- });
1857
- }
1858
- contextMenu(event) {
1859
- this.emit({
1860
- target: this.plotBand,
1861
- event,
1862
- });
1863
- }
1864
- emit(event) {
1865
- this.chartService.emitPlotband(event);
1866
- }
1867
- ngAfterViewInit() {
1868
- const plotbandElement = d3
1869
- .select(this.element.nativeElement)
1870
- .select('.plotband');
1871
- const grabElements = d3
1872
- .select(this.element.nativeElement)
1873
- .selectAll('.grabber');
1874
- this.dragElements = d3
1875
- .drag()
1876
- .subject(() => {
1877
- if (this.axis.orientation === AxisOrientation.x) {
1878
- return { x: plotbandElement.attr('x') };
1879
- }
1880
- if (this.axis.orientation === AxisOrientation.y) {
1881
- return { y: plotbandElement.attr('y') };
1882
- }
1883
- });
1884
- const drag = this.dragElements
1885
- .on('start drag end', (event, d) => {
1886
- let bandSize = parseFloat(plotbandElement.attr(this.axis.orientation === AxisOrientation.x ? 'width' : 'height'));
1887
- d.from = this.scale.invert(event[AxisOrientation[this.axis.orientation]]);
1888
- d.to = this.scale.invert(event[AxisOrientation[this.axis.orientation]] + bandSize);
1889
- this.emit({
1890
- event,
1891
- target: d,
1892
- });
1893
- this.cdr.detectChanges();
1894
- });
1895
- let grabberKey;
1896
- this.resizeElements = d3
1897
- .drag();
1898
- const resize = this.resizeElements
1899
- .on('start drag end', (event, d) => {
1900
- var _a, _b, _c, _d;
1901
- if ((event === null || event === void 0 ? void 0 : event.type) === 'start') {
1902
- 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;
1903
- grabberKey = grabber;
1904
- }
1905
- const min = Math.min(...this.scale.domain());
1906
- const max = Math.max(...this.scale.domain());
1907
- const minValue = (_c = d.min) !== null && _c !== void 0 ? _c : min;
1908
- const maxValue = (_d = d.max) !== null && _d !== void 0 ? _d : max;
1909
- d[grabberKey] = this.scale.invert(event[AxisOrientation[this.axis.orientation]]);
1910
- if (grabberKey === 'from') {
1911
- const borderMin = d.from <= minValue;
1912
- if (d.from >= d.to) {
1913
- d.from = d.to;
1914
- }
1915
- if (borderMin) {
1916
- d.from = minValue;
1917
- }
1918
- }
1919
- if (grabberKey === 'to') {
1920
- const borderMax = d.to >= maxValue;
1921
- if (borderMax) {
1922
- d.to = maxValue;
1923
- }
1924
- if (d.to <= d.from) {
1925
- d.to = d.from;
1926
- }
1927
- }
1928
- this.emit({
1929
- event,
1930
- target: d,
1931
- });
1932
- this.cdr.detectChanges();
1933
- });
1934
- plotbandElement.datum(this.plotBand);
1935
- grabElements.datum(this.plotBand);
1936
- if (this.plotBand.draggable) {
1937
- plotbandElement.call(drag);
1938
- }
1939
- if (this.plotBand.resizable) {
1940
- grabElements.call(resize);
1941
- }
1942
- }
1943
- ngOnDestroy() {
1944
- this.dragElements.on('start drag end', null);
1945
- this.resizeElements.on('start drag end', null);
1946
- }
1947
- get height() {
1948
- return this.size.height;
1949
- }
1950
- get width() {
1951
- return this.size.width;
1952
- }
1953
- get from() {
1954
- return this.scale(this.plotBand.from);
1955
- }
1956
- get to() {
1957
- return this.scale(this.plotBand.to);
1958
- }
1959
- get bandSize() {
1960
- return Math.abs(this.scale(this.plotBand.to) - this.scale(this.plotBand.from));
1961
- }
1962
- getFill(d) {
1963
- var _a, _b, _c, _d;
1964
- if ((_b = (_a = d.style) === null || _a === void 0 ? void 0 : _a.plotBand) === null || _b === void 0 ? void 0 : _b.patternImage) {
1965
- return `url(#${(_c = d.style.plotBand) === null || _c === void 0 ? void 0 : _c.patternImage})`;
1966
- }
1967
- return (_d = d.style.plotBand) === null || _d === void 0 ? void 0 : _d.fill;
1968
- }
1969
- }
1970
- PlotBandComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PlotBandComponent, deps: [{ token: ScaleService }, { token: ZoomService }, { token: ChartService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1971
- PlotBandComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: PlotBandComponent, selector: "[teta-plot-band]", inputs: { plotBand: "plotBand", axis: "axis", scale: "scale", size: "size" }, host: { listeners: { "click": "click($event)", "contextmenu": "contextMenu($event)" } }, ngImport: i0, template: "<svg:rect\n class=\"plotband\" xmlns:svg=\"http://www.w3.org/1999/html\"\n [class.draggable]=\"plotBand?.draggable === true\"\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 ? from : null\"\n [attr.x]=\"axis.orientation === orientation.x ? from : null\">\n</svg:rect>\n\n<svg:text\n *ngIf=\"axis.orientation === orientation.x\"\n text-anchor=\"middle\"\n dominant-baseline=\"middle\"\n class=\"label font-caption fill-text-90\"\n [attr.x]=\"getTextPosition()\"\n [attr.transform]=\"'rotate(-90, '+ getTextPosition() +',' + height / 2 + ')'\"\n [attr.y]=\"height / 2\">{{plotBand.label}}\n</svg:text>\n\n<svg:text\n *ngIf=\"axis.orientation === orientation.y\"\n text-anchor=\"middle\"\n class=\"label font-caption fill-text-90\"\n dominant-baseline=\"central\"\n [attr.x]=\"getTextPosition()\"\n [attr.y]=\"width / 2\">{{plotBand.label}}\n</svg:text>\n\n<svg:line class=\"display-grabber\"\n *ngIf=\"plotBand.showGrabbers && plotBand.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\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 *ngIf=\"plotBand.showGrabbers && plotBand.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\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 *ngIf=\"plotBand.resizable\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [class.resizeable]=\"plotBand?.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\n [attr.stroke-width]=\"8\"\n [style.transform]=\"axis.orientation === orientation.x ? 'translateX(2px)' : 'translateY(2px)'\"\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<svg:line class=\"grabber\"\n *ngIf=\"plotBand.resizable\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [class.resizeable]=\"plotBand?.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\n [attr.stroke-width]=\"8\"\n [style.transform]=\"axis.orientation === orientation.x ? 'translateX(-2px)' : 'translateY(-2px)'\"\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 .draggable rect:hover{cursor:grab}:host .draggable rect:active{cursor:grabbing}:host .x-grabber.resizeable{cursor:col-resize}:host .y-grabber.resizeable{cursor:row-resize}:host:hover .grabber{opacity:.1}.grabber{opacity:0}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1972
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PlotBandComponent, decorators: [{
1973
- type: Component,
1974
- args: [{ selector: '[teta-plot-band]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg:rect\n class=\"plotband\" xmlns:svg=\"http://www.w3.org/1999/html\"\n [class.draggable]=\"plotBand?.draggable === true\"\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 ? from : null\"\n [attr.x]=\"axis.orientation === orientation.x ? from : null\">\n</svg:rect>\n\n<svg:text\n *ngIf=\"axis.orientation === orientation.x\"\n text-anchor=\"middle\"\n dominant-baseline=\"middle\"\n class=\"label font-caption fill-text-90\"\n [attr.x]=\"getTextPosition()\"\n [attr.transform]=\"'rotate(-90, '+ getTextPosition() +',' + height / 2 + ')'\"\n [attr.y]=\"height / 2\">{{plotBand.label}}\n</svg:text>\n\n<svg:text\n *ngIf=\"axis.orientation === orientation.y\"\n text-anchor=\"middle\"\n class=\"label font-caption fill-text-90\"\n dominant-baseline=\"central\"\n [attr.x]=\"getTextPosition()\"\n [attr.y]=\"width / 2\">{{plotBand.label}}\n</svg:text>\n\n<svg:line class=\"display-grabber\"\n *ngIf=\"plotBand.showGrabbers && plotBand.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\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 *ngIf=\"plotBand.showGrabbers && plotBand.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\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 *ngIf=\"plotBand.resizable\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [class.resizeable]=\"plotBand?.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\n [attr.stroke-width]=\"8\"\n [style.transform]=\"axis.orientation === orientation.x ? 'translateX(2px)' : 'translateY(2px)'\"\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<svg:line class=\"grabber\"\n *ngIf=\"plotBand.resizable\"\n [class.x-grabber]=\"axis.orientation === orientation.x\"\n [class.y-grabber]=\"axis.orientation === orientation.y\"\n [class.resizeable]=\"plotBand?.resizable\"\n [attr.stroke]=\"plotBand.style?.grabbers?.stroke || 'var(--color-text-50)'\"\n [attr.stroke-width]=\"8\"\n [style.transform]=\"axis.orientation === orientation.x ? 'translateX(-2px)' : 'translateY(-2px)'\"\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 .draggable rect:hover{cursor:grab}:host .draggable rect:active{cursor:grabbing}:host .x-grabber.resizeable{cursor:col-resize}:host .y-grabber.resizeable{cursor:row-resize}:host:hover .grabber{opacity:.1}.grabber{opacity:0}\n"] }]
1975
- }], ctorParameters: function () { return [{ type: ScaleService }, { type: ZoomService }, { type: ChartService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { plotBand: [{
1976
- type: Input
1977
- }], axis: [{
1978
- type: Input
1979
- }], scale: [{
1980
- type: Input
1981
- }], size: [{
1982
- type: Input
1983
- }], click: [{
1984
- type: HostListener,
1985
- args: ['click', ['$event']]
1986
- }], contextMenu: [{
1987
- type: HostListener,
1988
- args: ['contextmenu', ['$event']]
1989
- }] } });
1990
-
1991
- class TooltipComponent {
1992
- constructor(svc, cdr, zoomService, sanitizer, _zone, _elementRef) {
1993
- this.svc = svc;
1994
- this.cdr = cdr;
1995
- this.zoomService = zoomService;
1996
- this.sanitizer = sanitizer;
1997
- this._zone = _zone;
1998
- this._elementRef = _elementRef;
1999
- this.tooltips = this.svc.tooltips.pipe(map((_) => [..._.values()]));
2000
- }
2001
- ngOnInit() {
2002
- var _a, _b;
2003
- this.display = this.svc.pointerMove.pipe(map((event) => {
2004
- return event.type === 'mousemove' ? 1 : 0;
2005
- }), tap(() => {
2006
- setTimeout(() => {
2007
- this.cdr.detectChanges();
2008
- });
2009
- }));
2010
- this.position = this.svc.pointerMove.pipe(filter((event) => !!event), map((_) => {
2011
- return this.getPosition(_);
2012
- }), tap(() => this.cdr.detectChanges()));
2013
- const transformHtml = (html) => {
2014
- return this.sanitizer.bypassSecurityTrustHtml(html);
2015
- };
2016
- const defaultFormatter = (tooltips) => {
2017
- let html = '';
2018
- const format = d3.timeFormat('%d.%m.%Y');
2019
- tooltips.forEach((_) => {
2020
- var _a, _b, _c;
2021
- 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}`;
2022
- html += `<div class="display-flex align-center"><span class="margin-right-1" style="${indicatorStyle}"></span>
2023
- <span class="font-title-3">${_.series.name}
2024
- <span class="font-body-3">
2025
- x: ${_.point.x instanceof Date ? format(_.point.x) : (_b = _.point.x) === null || _b === void 0 ? void 0 : _b.toFixed(2)}
2026
- y: ${_.point.y instanceof Date ? format(_.point.y) : (_c = _.point.y) === null || _c === void 0 ? void 0 : _c.toFixed(2)}
2027
- </span>
2028
- </span></div>`;
2029
- });
2030
- return transformHtml(html);
2031
- };
2032
- const formatter = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.tooltip) === null || _b === void 0 ? void 0 : _b.format;
2033
- this.displayTooltips = this.svc.tooltips.pipe(map((tooltips) => {
2034
- const tooltipList = [...tooltips.values()];
2035
- if ((tooltipList === null || tooltipList === void 0 ? void 0 : tooltipList.length) < 1) {
2036
- return '';
2037
- }
2038
- const formatted = formatter
2039
- ? transformHtml(formatter(tooltipList))
2040
- : defaultFormatter(tooltipList);
2041
- return formatted;
2042
- }));
2043
- }
2044
- getPosition(event) {
2045
- var _a, _b;
2046
- if (!this.tooltip) {
2047
- return null;
2048
- }
2049
- return PositionUtil.getPosition({
2050
- top: event.pageY,
2051
- bottom: event.pageY,
2052
- left: event.pageX,
2053
- right: event.pageX,
2054
- }, (_b = (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect(), Align.auto, VerticalAlign.top, 12);
2055
- }
2056
- format(input) {
2057
- if (input instanceof Date) {
2058
- const format = d3.timeFormat('%d.%m.%Y');
2059
- return format(input);
2060
- }
2061
- const format = d3.format(',.5~r');
2062
- return format(input);
2063
- }
2064
- }
2065
- TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: TooltipComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ZoomService }, { token: i3.DomSanitizer }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
2066
- TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: TooltipComponent, selector: "teta-tooltip", inputs: { size: "size", config: "config" }, viewQueries: [{ propertyName: "tooltip", first: true, predicate: ["tooltip"], descendants: true, read: ElementRef }], ngImport: i0, template: "<ng-container *tetaLet=\"position | async as p\">\n <ng-container *ngIf=\"tooltips | async as t\">\n <div class=\"chart-tooltip color-text-90 bg-background-50 shadow-2\"\n #tooltip\n [style.position]=\"'fixed'\"\n *ngIf=\"t.length > 0\"\n [style.opacity]=\"display | async\"\n [hidden]=\"!p\"\n style=\"pointer-events: none; min-width: 200px;\"\n [style.left.px]=\"p?.left\"\n [style.top.px]=\"p?.top\"\n [style.bottom.px]=\"p?.bottom\"\n [style.right.px]=\"p?.right\"\n >\n <ng-container *ngIf=\"config.tooltip?.template\">\n <ng-container *ngTemplateOutlet=\"config.tooltip.template; context: {$implicit: t}\"></ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"config.tooltip?.format; else default\">\n <div [innerHTML]=\"displayTooltips | async\"></div>\n </ng-container>\n\n <ng-template #default>\n <div *ngIf=\"!config.tooltip?.template\" class=\"padding-2 border-radius-1\">\n <ng-container *ngFor=\"let tooltip of t\">\n <div class=\"display-flex align-center\">\n <span class=\"display-block margin-right-1\" [style.width.px]=\"10\" [style.height.px]=\"2\"\n [style.background-color]=\"tooltip.series?.color\"></span>\n <span class=\"font-title-3\">\n {{ tooltip.series?.name }}\n <span class=\"font-body-3\">\n x: {{ format(tooltip.point?.x) }}\n y: {{ format(tooltip.point?.y) }}\n </span>\n </span>\n </div>\n </ng-container>\n </div>\n </ng-template>\n </div>\n </ng-container>\n</ng-container>\n\n\n\n", styles: [":host{position:absolute;z-index:2}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i5.LetDirective, selector: "[tetaLet]", inputs: ["tetaLet"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2067
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: TooltipComponent, decorators: [{
2068
- type: Component,
2069
- args: [{ selector: 'teta-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *tetaLet=\"position | async as p\">\n <ng-container *ngIf=\"tooltips | async as t\">\n <div class=\"chart-tooltip color-text-90 bg-background-50 shadow-2\"\n #tooltip\n [style.position]=\"'fixed'\"\n *ngIf=\"t.length > 0\"\n [style.opacity]=\"display | async\"\n [hidden]=\"!p\"\n style=\"pointer-events: none; min-width: 200px;\"\n [style.left.px]=\"p?.left\"\n [style.top.px]=\"p?.top\"\n [style.bottom.px]=\"p?.bottom\"\n [style.right.px]=\"p?.right\"\n >\n <ng-container *ngIf=\"config.tooltip?.template\">\n <ng-container *ngTemplateOutlet=\"config.tooltip.template; context: {$implicit: t}\"></ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"config.tooltip?.format; else default\">\n <div [innerHTML]=\"displayTooltips | async\"></div>\n </ng-container>\n\n <ng-template #default>\n <div *ngIf=\"!config.tooltip?.template\" class=\"padding-2 border-radius-1\">\n <ng-container *ngFor=\"let tooltip of t\">\n <div class=\"display-flex align-center\">\n <span class=\"display-block margin-right-1\" [style.width.px]=\"10\" [style.height.px]=\"2\"\n [style.background-color]=\"tooltip.series?.color\"></span>\n <span class=\"font-title-3\">\n {{ tooltip.series?.name }}\n <span class=\"font-body-3\">\n x: {{ format(tooltip.point?.x) }}\n y: {{ format(tooltip.point?.y) }}\n </span>\n </span>\n </div>\n </ng-container>\n </div>\n </ng-template>\n </div>\n </ng-container>\n</ng-container>\n\n\n\n", styles: [":host{position:absolute;z-index:2}\n"] }]
2070
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ZoomService }, { type: i3.DomSanitizer }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { size: [{
2071
- type: Input
2072
- }], config: [{
2073
- type: Input
2074
- }], tooltip: [{
2075
- type: ViewChild,
2076
- args: ['tooltip', { static: false, read: ElementRef }]
2077
- }] } });
2078
-
2079
- class ZoomableDirective {
2080
- constructor(elementRef, zoomService, chartService, zone) {
2081
- this.elementRef = elementRef;
2082
- this.zoomService = zoomService;
2083
- this.chartService = chartService;
2084
- this.zone = zone;
2085
- this.zoomable = false;
2086
- this.crosshair = false;
2087
- this.alive = true;
2088
- this.currentTransform = zoomIdentity;
2089
- this.zoomed = (event) => {
2090
- if (event.sourceEvent && (this.elementRef.nativeElement === event.sourceEvent.target || this.elementRef.nativeElement.contains(event.sourceEvent.target))) {
2091
- if (Object.keys(event.sourceEvent).length !== 0) {
2092
- const origin = this.axis.scale.copy().domain(this.axis.originDomain);
2093
- if (this.axis.options.scaleType.type === ScaleType.band) {
2094
- return;
2095
- }
2096
- const domain = this.axis.orientation === AxisOrientation.y
2097
- ? event.transform.rescaleY(origin).domain()
2098
- : event.transform.rescaleX(origin).domain();
2099
- if (domain[0] === null || domain[0] === undefined
2100
- || domain[1] === null || domain[1] === undefined
2101
- || Math.abs(domain[0] - domain[1]) < 0.000001) {
2102
- return;
2103
- }
2104
- const message = new ZoomMessage({
2105
- eventType: event.type,
2106
- axis: {
2107
- index: this.axis.index,
2108
- orientation: this.axis.orientation,
2109
- },
2110
- element: this.elementRef,
2111
- domain,
2112
- chartId: this.config.id
2113
- });
2114
- this.zoomService.fireZoom(message);
2115
- this.zoomService.broadcastZoom(message);
2116
- }
2117
- this.currentTransform = event.transform;
2118
- }
2119
- };
2120
- }
2121
- mouseenter() {
2122
- var _a, _b, _c, _d;
2123
- (_a = this.zoom) === null || _a === void 0 ? void 0 : _a.on('start zoom end', this.zoomed);
2124
- (_b = this._element) === null || _b === void 0 ? void 0 : _b.call(this.zoom).on('dblclick.zoom', null);
2125
- // Run wheel event listener
2126
- if (((_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.zoom) === null || _d === void 0 ? void 0 : _d.zoomBehavior) === ZoomBehaviorType.wheel) {
2127
- this.runWheelTranslate();
2128
- }
2129
- }
2130
- mouseleave() {
2131
- var _a, _b;
2132
- (_a = this.zoom) === null || _a === void 0 ? void 0 : _a.on('start zoom end', null);
2133
- (_b = this._element) === null || _b === void 0 ? void 0 : _b.on('wheel', null);
2134
- }
2135
- ngOnInit() {
2136
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2137
- if (((_b = (_a = this.axis) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.zoom) || ((_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.zoom) === null || _d === void 0 ? void 0 : _d.enable)) {
2138
- this.zoomable = ((_f = (_e = this.config) === null || _e === void 0 ? void 0 : _e.zoom) === null || _f === void 0 ? void 0 : _f.zoomBehavior) === ZoomBehaviorType.move && !((_h = (_g = this.config) === null || _g === void 0 ? void 0 : _g.tooltip) === null || _h === void 0 ? void 0 : _h.showCrosshair);
2139
- this.crosshair = (_k = (_j = this.config) === null || _j === void 0 ? void 0 : _j.tooltip) === null || _k === void 0 ? void 0 : _k.showCrosshair;
2140
- }
2141
- }
2142
- ngAfterViewInit() {
2143
- this.initZoomListeners();
2144
- this.initZoomSync();
2145
- }
2146
- ngOnDestroy() {
2147
- var _a, _b;
2148
- (_a = this.zoom) === null || _a === void 0 ? void 0 : _a.on('start zoom end', null);
2149
- (_b = this._element) === null || _b === void 0 ? void 0 : _b.on('wheel', null);
2150
- this.alive = false;
2151
- }
2152
- initZoomSync() {
2153
- this.zoomService.zoomed.pipe(takeWhile(() => this.alive)).subscribe((zoomed) => {
2154
- var _a, _b;
2155
- if (this._element && this.elementRef !== (zoomed === null || zoomed === void 0 ? void 0 : zoomed.element)
2156
- && ((_a = zoomed === null || zoomed === void 0 ? void 0 : zoomed.axis) === null || _a === void 0 ? void 0 : _a.index) === this.axis.index
2157
- && ((_b = zoomed === null || zoomed === void 0 ? void 0 : zoomed.axis) === null || _b === void 0 ? void 0 : _b.orientation) === this.axis.orientation) {
2158
- const scale = this.axis.scale.copy().domain(this.axis.originDomain);
2159
- let transform;
2160
- if (zoomed.domain === null) {
2161
- transform = zoomIdentity;
2162
- }
2163
- else {
2164
- transform =
2165
- this.zoomService.getD3Transform(zoomed.domain, this.axis.originDomain, scale, this.axis.orientation, this.axis.options.inverted);
2166
- }
2167
- this._element.call(this.zoom.transform, transform);
2168
- this.currentTransform = transform;
2169
- }
2170
- });
2171
- }
2172
- initZoomListeners() {
2173
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
2174
- const enable = (((_b = (_a = this.axis) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.zoom) && ((_c = this.axis) === null || _c === void 0 ? void 0 : _c.options.visible) !== false) ||
2175
- ((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.zoom) === null || _e === void 0 ? void 0 : _e.enable);
2176
- if (!enable) {
2177
- return;
2178
- }
2179
- this._element = d3.select(this.elementRef.nativeElement);
2180
- this.zoom = d3.zoom().extent([
2181
- [0, 0],
2182
- [this.size.width, this.size.height],
2183
- ]);
2184
- const min = ((_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.zoom) === null || _g === void 0 ? void 0 : _g.minTranslate) != null
2185
- ? this.axis.scale((_j = (_h = this.config) === null || _h === void 0 ? void 0 : _h.zoom) === null || _j === void 0 ? void 0 : _j.minTranslate)
2186
- : -Infinity;
2187
- const max = (((_l = (_k = this.config) === null || _k === void 0 ? void 0 : _k.zoom) === null || _l === void 0 ? void 0 : _l.maxTranslate) != null
2188
- ? this.axis.scale((_o = (_m = this.config) === null || _m === void 0 ? void 0 : _m.zoom) === null || _o === void 0 ? void 0 : _o.maxTranslate)
2189
- : Infinity);
2190
- if (this.axis.orientation === AxisOrientation.x && this.config.zoom.type === ZoomType.x) {
2191
- this.zoom.translateExtent([
2192
- [Math.min(min, max), -Infinity],
2193
- [Math.max(min, max), Infinity],
2194
- ]);
2195
- }
2196
- if (this.axis.orientation === AxisOrientation.y && this.config.zoom.type === ZoomType.y) {
2197
- this.zoom.translateExtent([
2198
- [-Infinity, Math.min(min, max)],
2199
- [Infinity, Math.max(min, max)],
2200
- ]);
2201
- }
2202
- if ((_p = this.config.zoom) === null || _p === void 0 ? void 0 : _p.wheelDelta) {
2203
- this.zoom.wheelDelta((_q = this.config.zoom) === null || _q === void 0 ? void 0 : _q.wheelDelta);
2204
- }
2205
- if ((_s = (_r = this.config) === null || _r === void 0 ? void 0 : _r.zoom) === null || _s === void 0 ? void 0 : _s.wheelFilter) {
2206
- this.zoom.filter((_u = (_t = this.config) === null || _t === void 0 ? void 0 : _t.zoom) === null || _u === void 0 ? void 0 : _u.wheelFilter);
2207
- }
2208
- if (this.axis.options.scaleType.type !== ScaleType.band) {
2209
- const extremes = this.axis.extremes;
2210
- const maxZoom = ((_v = this.config.zoom) === null || _v === void 0 ? void 0 : _v.max)
2211
- ? (extremes[1] - extremes[0]) /
2212
- ((_w = this.config.zoom) === null || _w === void 0 ? void 0 : _w.max)
2213
- : ((_x = this.config.zoom) === null || _x === void 0 ? void 0 : _x.limitZoomByData)
2214
- ? 1
2215
- : 0;
2216
- const minZoom = ((_y = this.config.zoom) === null || _y === void 0 ? void 0 : _y.min)
2217
- ? (extremes[1] - extremes[0]) /
2218
- ((_z = this.config.zoom) === null || _z === void 0 ? void 0 : _z.min)
2219
- : Infinity;
2220
- this.zoom.scaleExtent([maxZoom, minZoom]);
2221
- }
2222
- if (((_1 = (_0 = this.config) === null || _0 === void 0 ? void 0 : _0.zoom) === null || _1 === void 0 ? void 0 : _1.zoomBehavior) === ZoomBehaviorType.wheel) {
2223
- this.runWheelTranslate();
2224
- }
2225
- }
2226
- runWheelTranslate() {
2227
- var _a;
2228
- let type = 'start';
2229
- let wheeling;
2230
- // For touch events
2231
- this.zoom.on('start zoom end', this.zoomed);
2232
- (_a = this._element) === null || _a === void 0 ? void 0 : _a.call(this.zoom);
2233
- this.zoom
2234
- .filter((event) => {
2235
- return (event.ctrlKey && event.type === 'wheel') ||
2236
- Boolean(window.TouchEvent && event.type !== 'wheel');
2237
- })
2238
- .wheelDelta((event) => {
2239
- var _a;
2240
- const delta = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.zoom.type) === ZoomType.x
2241
- ? -event.deltaX
2242
- : -event.deltaY;
2243
- return delta * 0.002;
2244
- });
2245
- const emit = (type, event) => {
2246
- var _a, _b, _c, _d;
2247
- const origin = this.axis.scale.copy().domain(this.axis.originDomain);
2248
- let transform = zoomIdentity;
2249
- const delta = type === 'end'
2250
- ? 0
2251
- : this.axis.orientation === AxisOrientation.y
2252
- ? event.deltaY
2253
- : event.deltaX;
2254
- if (this.axis.orientation === AxisOrientation.y) {
2255
- transform = transform.translate(0, this.currentTransform.y - delta / 2);
2256
- }
2257
- if (this.axis.orientation === AxisOrientation.x) {
2258
- transform = transform.translate(this.currentTransform.x - delta / 2, 0);
2259
- }
2260
- transform = transform.scale(this.currentTransform.k);
2261
- let domain = this.axis.orientation === AxisOrientation.y
2262
- ? transform.rescaleY(origin).domain()
2263
- : transform.rescaleX(origin).domain();
2264
- const extent = ((_a = this.axis.options) === null || _a === void 0 ? void 0 : _a.inverted) ? domain : [...domain].reverse();
2265
- if (extent[0] <= ((_b = this.config.zoom) === null || _b === void 0 ? void 0 : _b.minTranslate)) {
2266
- return;
2267
- }
2268
- if (extent[1] >= ((_c = this.config.zoom) === null || _c === void 0 ? void 0 : _c.maxTranslate)) {
2269
- return;
2270
- }
2271
- const message = new ZoomMessage({
2272
- eventType: type,
2273
- element: this.elementRef,
2274
- axis: {
2275
- index: this.axis.index,
2276
- orientation: this.axis.orientation
2277
- },
2278
- domain,
2279
- chartId: this.config.id,
2280
- });
2281
- (_d = this._element) === null || _d === void 0 ? void 0 : _d.call(this.zoom.transform, transform);
2282
- this.zoomService.fireZoom(message);
2283
- this.zoomService.broadcastZoom(message);
2284
- this.currentTransform = transform;
2285
- };
2286
- this._element.on('wheel', (event) => {
2287
- event.preventDefault();
2288
- if (event.ctrlKey) {
2289
- return;
2290
- }
2291
- this.zone.runOutsideAngular(() => {
2292
- clearTimeout(wheeling);
2293
- emit(type, event);
2294
- type = 'zoom';
2295
- wheeling = setTimeout(() => {
2296
- emit('end', event);
2297
- type = 'start';
2298
- }, 50);
2299
- });
2300
- });
2301
- }
2302
- }
2303
- ZoomableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomableDirective, deps: [{ token: i0.ElementRef }, { token: ZoomService }, { token: ChartService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
2304
- ZoomableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: ZoomableDirective, selector: "[tetaZoomable]", inputs: { config: "config", axis: "axis", size: "size" }, host: { listeners: { "mouseenter": "mouseenter()", "mouseleave": "mouseleave()" }, properties: { "class.zoomable": "this.zoomable", "class.crosshair": "this.crosshair" } }, ngImport: i0 });
2305
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomableDirective, decorators: [{
2306
- type: Directive,
2307
- args: [{
2308
- selector: '[tetaZoomable]',
2309
- }]
2310
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ZoomService }, { type: ChartService }, { type: i0.NgZone }]; }, propDecorators: { config: [{
2311
- type: Input
2312
- }], axis: [{
2313
- type: Input
2314
- }], size: [{
2315
- type: Input
2316
- }], zoomable: [{
2317
- type: HostBinding,
2318
- args: ['class.zoomable']
2319
- }], crosshair: [{
2320
- type: HostBinding,
2321
- args: ['class.crosshair']
2322
- }], mouseenter: [{
2323
- type: HostListener,
2324
- args: ['mouseenter']
2325
- }], mouseleave: [{
2326
- type: HostListener,
2327
- args: ['mouseleave']
2328
- }] } });
2329
-
2330
- class BrushableDirective {
2331
- constructor(brushService, chartService, element, zone) {
2332
- this.brushService = brushService;
2333
- this.chartService = chartService;
2334
- this.element = element;
2335
- this.zone = zone;
2336
- this.brushMap = new Map()
2337
- .set(BrushType.x, d3.brushX())
2338
- .set(BrushType.y, d3.brushY());
2339
- this._alive = true;
2340
- this._container = d3.select(this.element.nativeElement);
2341
- }
2342
- ngOnInit() {
2343
- this.brushService.brushDomain.pipe(takeWhile(() => this._alive), filter((brush) => brush.chartId !== this.config.id)).subscribe((brush) => {
2344
- this._container.call(this.brush.move, [
2345
- Math.floor(brush.selection[0]),
2346
- Math.floor(brush.selection[1]),
2347
- ].map(this.axis.scale));
2348
- });
2349
- }
2350
- ngOnDestroy() {
2351
- this._alive = false;
2352
- }
2353
- ngAfterViewInit() {
2354
- var _a, _b, _c, _d, _e, _f;
2355
- if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.brush) === null || _b === void 0 ? void 0 : _b.enable) {
2356
- const brushMessage = new BrushMessage({
2357
- chartId: this.config.id,
2358
- selection: [(_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.brush) === null || _d === void 0 ? void 0 : _d.from, (_f = (_e = this.config) === null || _e === void 0 ? void 0 : _e.brush) === null || _f === void 0 ? void 0 : _f.to],
2359
- mode: 'init'
2360
- });
2361
- this.brushService.setBrush(brushMessage);
2362
- }
2363
- }
2364
- ngOnChanges(changes) {
2365
- var _a, _b;
2366
- if (changes.hasOwnProperty('config')) {
2367
- this.clearPreviousSelection();
2368
- }
2369
- if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.brush) === null || _b === void 0 ? void 0 : _b.enable) {
2370
- this.applyBrush(this.config, this.axis.scale);
2371
- }
2372
- }
2373
- applyBrush(config, brushScale) {
2374
- var _a, _b, _c, _d;
2375
- (_a = this.brush) === null || _a === void 0 ? void 0 : _a.on('start brush end', null);
2376
- if ((_b = config.brush) === null || _b === void 0 ? void 0 : _b.enable) {
2377
- this.brush = this.brushMap.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);
2378
- this.brush.on('start brush end', (_) => {
2379
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
2380
- if (_.sourceEvent) {
2381
- if (!_.selection)
2382
- return;
2383
- const [from, to] = _.selection;
2384
- if (to - from === 0) {
2385
- const selection = (_b = (_a = this.selection) === null || _a === void 0 ? void 0 : _a.map(brushScale)) !== null && _b !== void 0 ? _b : [(_c = config.brush) === null || _c === void 0 ? void 0 : _c.from, (_d = config.brush) === null || _d === void 0 ? void 0 : _d.to].map(brushScale);
2386
- const halfBrushHeight = (selection[1] - selection[0]) / 2;
2387
- const invertedSelection = [
2388
- from - halfBrushHeight,
2389
- to + halfBrushHeight,
2390
- ].map(brushScale.invert);
2391
- if (invertedSelection[1] - invertedSelection[0] >
2392
- ((_e = config.brush) === null || _e === void 0 ? void 0 : _e.max)) {
2393
- this._container.call(this.brush.move, [
2394
- Math.floor(invertedSelection[0]),
2395
- Math.floor(invertedSelection[0] + ((_f = config.brush) === null || _f === void 0 ? void 0 : _f.max)),
2396
- ].map(brushScale));
2397
- return;
2398
- }
2399
- if (invertedSelection[1] - invertedSelection[0] <
2400
- ((_g = config.brush) === null || _g === void 0 ? void 0 : _g.min)) {
2401
- this._container.call(this.brush.move, [
2402
- Math.floor(invertedSelection[0]),
2403
- Math.ceil(invertedSelection[0] + ((_h = config.brush) === null || _h === void 0 ? void 0 : _h.min)),
2404
- ].map(brushScale));
2405
- return;
2406
- }
2407
- this._container.call(this.brush.move, [
2408
- from - halfBrushHeight,
2409
- to + halfBrushHeight,
2410
- ]);
2411
- return;
2412
- }
2413
- if (brushScale.invert(to) - brushScale.invert(from) >
2414
- ((_j = config.brush) === null || _j === void 0 ? void 0 : _j.max)) {
2415
- this._container.call(this.brush.move, this.selection
2416
- ? [
2417
- this.selection[0],
2418
- this.selection[0] + ((_k = config.brush) === null || _k === void 0 ? void 0 : _k.max),
2419
- ].map(brushScale)
2420
- : [(_l = config.brush) === null || _l === void 0 ? void 0 : _l.from, (_m = config.brush) === null || _m === void 0 ? void 0 : _m.to].map(brushScale));
2421
- return;
2422
- }
2423
- if (brushScale.invert(to) - brushScale.invert(from) <
2424
- ((_o = config.brush) === null || _o === void 0 ? void 0 : _o.min)) {
2425
- this._container.call(this.brush.move, this.selection
2426
- ? [
2427
- this.selection[0],
2428
- this.selection[0] + ((_p = config.brush) === null || _p === void 0 ? void 0 : _p.min),
2429
- ].map(brushScale)
2430
- : [(_q = config.brush) === null || _q === void 0 ? void 0 : _q.from, (_r = config.brush) === null || _r === void 0 ? void 0 : _r.to].map(brushScale));
2431
- return;
2432
- }
2433
- if (_.sourceEvent instanceof MouseEvent) {
2434
- this.selection = _.selection.map(brushScale.invert);
2435
- }
2436
- const brushMessage = new BrushMessage({
2437
- chartId: this.config.id,
2438
- selection: [brushScale.invert(from), brushScale.invert(to)],
2439
- mode: _.mode
2440
- });
2441
- this.brushService.setBrush(brushMessage);
2442
- }
2443
- });
2444
- this.zone.runOutsideAngular(() => {
2445
- setTimeout(() => {
2446
- var _a, _b;
2447
- this._container.call(this.brush);
2448
- let domain = brushScale.domain();
2449
- if ((_a = config === null || config === void 0 ? void 0 : config.brush) === null || _a === void 0 ? void 0 : _a.from) {
2450
- domain[0] = config.brush.from;
2451
- }
2452
- if ((_b = config === null || config === void 0 ? void 0 : config.brush) === null || _b === void 0 ? void 0 : _b.to) {
2453
- domain[1] = config.brush.to;
2454
- }
2455
- this._container.call(this.brush.move, this.selection
2456
- ? this.selection.map(brushScale)
2457
- : domain.map(brushScale), {});
2458
- }, 0);
2459
- });
2460
- }
2461
- }
2462
- clearPreviousSelection() {
2463
- this.selection = null;
2464
- }
2465
- }
2466
- BrushableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BrushableDirective, deps: [{ token: BrushService }, { token: ChartService }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
2467
- BrushableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: BrushableDirective, selector: "[tetaBrushable]", inputs: { config: "config", axis: "axis" }, usesOnChanges: true, ngImport: i0 });
2468
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BrushableDirective, decorators: [{
2469
- type: Directive,
2470
- args: [{
2471
- selector: '[tetaBrushable]',
2472
- }]
2473
- }], ctorParameters: function () { return [{ type: BrushService }, { type: ChartService }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { config: [{
2474
- type: Input
2475
- }], axis: [{
2476
- type: Input
2477
- }] } });
2478
-
2479
- class AnnotationComponent {
2480
- constructor(scaleService, cdr, chartService) {
2481
- this.scaleService = scaleService;
2482
- this.cdr = cdr;
2483
- this.chartService = chartService;
2484
- this.x = this.scaleService.scales.pipe(map((_) => { var _a, _b; return (_b = _.x.get((_a = this.annotation.xAxisIndex) !== null && _a !== void 0 ? _a : 0)) === null || _b === void 0 ? void 0 : _b.scale; }));
2485
- this.y = this.scaleService.scales.pipe(map((_) => { var _a, _b; return (_b = _.y.get((_a = this.annotation.yAxisIndex) !== null && _a !== void 0 ? _a : 0)) === null || _b === void 0 ? void 0 : _b.scale; }));
2486
- this.drag = d3.drag();
2487
- }
2488
- set annotation(annotation) {
2489
- this._annotation = annotation;
2490
- }
2491
- get annotation() {
2492
- return this._annotation;
2493
- }
2494
- set node(node) {
2495
- this._node = node;
2496
- this.init();
2497
- this.cdr.detectChanges();
2498
- }
2499
- get node() {
2500
- return this._node;
2501
- }
2502
- click(event) {
2503
- this.chartService.emitAnnotation({
2504
- event,
2505
- target: this.annotation
2506
- });
2507
- }
2508
- contextMenu(event) {
2509
- this.chartService.emitAnnotation({
2510
- event,
2511
- target: this.annotation
2512
- });
2513
- }
2514
- ngOnDestroy() {
2515
- this.drag.on('drag end', null);
2516
- }
2517
- init() {
2518
- d3.select(this.node.nativeElement).datum(this.annotation);
2519
- const offsetPx = 10;
2520
- const nodeRect = this.node.nativeElement.getBoundingClientRect();
2521
- if (this.annotation.draggable) {
2522
- this.drag.on('drag end', (event, d) => __awaiter(this, void 0, void 0, function* () {
2523
- const x = yield lastValueFrom(this.x.pipe(take(1)));
2524
- const y = yield lastValueFrom(this.y.pipe(take(1)));
2525
- d.dx += event.dx;
2526
- d.dy += event.dy;
2527
- // x constraint
2528
- if ((d.dx + x(d.point.x) - offsetPx) <= 0) {
2529
- d.dx = -x(d.point.x) + offsetPx;
2530
- }
2531
- if (d.dx + x(d.point.x) + nodeRect.width - offsetPx >= this.visibleRect.width) {
2532
- d.dx = this.visibleRect.width - x(d.point.x) - nodeRect.width + offsetPx;
2533
- }
2534
- // y constraint
2535
- if ((d.dy + y(d.point.y) - offsetPx) <= 0) {
2536
- d.dy = -y(d.point.y) + offsetPx;
2537
- }
2538
- if (d.dy + y(d.point.y) + nodeRect.height - offsetPx >= this.visibleRect.height) {
2539
- d.dy = Math.abs(y(d.point.y) - this.visibleRect.height) - nodeRect.height + offsetPx;
2540
- }
2541
- this.cdr.detectChanges();
2542
- this.chartService.emitMoveAnnotation({
2543
- event,
2544
- target: d
2545
- });
2546
- }));
2547
- d3.select(this.node.nativeElement).call(this.drag);
2548
- }
2549
- }
2550
- }
2551
- AnnotationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: AnnotationComponent, deps: [{ token: ScaleService }, { token: i0.ChangeDetectorRef }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Component });
2552
- AnnotationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: AnnotationComponent, selector: "[teta-annotation]", inputs: { visibleRect: "visibleRect", annotation: "annotation" }, host: { listeners: { "click": "click($event)", "contextmenu": "contextMenu($event)" } }, viewQueries: [{ propertyName: "node", first: true, predicate: ["annotationNode"], descendants: true }], ngImport: i0, template: "<ng-container *ngIf=\"{\n x: x | async,\n y: y | async\n } as data\">\n <ng-container *ngIf=\"data.x && data.y\">\n\n\n <svg:circle\n [attr.r]=\"annotation.style?.radius ?? 5\"\n [attr.cx]=\"data.x(annotation.point.x)\"\n [attr.fill]=\"annotation?.style?.fill ?? 'var(--color-text-90)'\"\n [attr.cy]=\"data.y(annotation.point.y)\">\n </svg:circle>\n <svg:line\n [attr.x1]=\"data.x(annotation.point.x)\"\n [attr.y1]=\"data.y(annotation.point.y)\"\n [attr.x2]=\"data.x(annotation.point.x) + (annotation.dx ?? 0)\"\n [attr.y2]=\"data.y(annotation.point.y) + (annotation.dy ?? 0)\"\n [attr.stroke]=\"annotation.style?.stroke ?? 'var(--color-text-90)'\"\n [attr.stroke-width]=\"annotation.style?.strokeWidth ?? 1\"\n [attr.stroke-dasharray]=\"annotation.style?.strokeDasharray ?? null\"\n >\n </svg:line>\n <svg:foreignObject\n class=\"position-absolute\"\n [attr.width]=\"node?.nativeElement.offsetWidth ?? 0\"\n [attr.height]=\"node?.nativeElement.offsetHeight ?? 0\"\n [attr.x]=\"data.x(annotation.point.x) + (annotation.dx ?? 0) - 10\"\n [attr.y]=\"data.y(annotation.point.y) + (annotation.dy ?? 0) - 10\">\n <div\n #annotationNode\n [style.background-color]=\"annotation.style?.fill ?? 'var(--color-text-90)'\"\n [style.cursor]=\"annotation?.draggable ? 'move' : 'default'\"\n [className]=\"'padding-h-2 ' + annotation.className ?? ''\"\n style=\"border-radius: 2px; display: inline-block;\">\n <ng-container *ngIf=\"annotation.template;else default\">\n <ng-container *ngTemplateOutlet=\"annotation.template;context: {$implicit: annotation}\"></ng-container>\n </ng-container>\n </div>\n </svg:foreignObject>\n </ng-container>\n</ng-container>\n<ng-template #default>\n {{ annotation.note?.label}}\n</ng-template>\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2553
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: AnnotationComponent, decorators: [{
2554
- type: Component,
2555
- args: [{ selector: '[teta-annotation]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n x: x | async,\n y: y | async\n } as data\">\n <ng-container *ngIf=\"data.x && data.y\">\n\n\n <svg:circle\n [attr.r]=\"annotation.style?.radius ?? 5\"\n [attr.cx]=\"data.x(annotation.point.x)\"\n [attr.fill]=\"annotation?.style?.fill ?? 'var(--color-text-90)'\"\n [attr.cy]=\"data.y(annotation.point.y)\">\n </svg:circle>\n <svg:line\n [attr.x1]=\"data.x(annotation.point.x)\"\n [attr.y1]=\"data.y(annotation.point.y)\"\n [attr.x2]=\"data.x(annotation.point.x) + (annotation.dx ?? 0)\"\n [attr.y2]=\"data.y(annotation.point.y) + (annotation.dy ?? 0)\"\n [attr.stroke]=\"annotation.style?.stroke ?? 'var(--color-text-90)'\"\n [attr.stroke-width]=\"annotation.style?.strokeWidth ?? 1\"\n [attr.stroke-dasharray]=\"annotation.style?.strokeDasharray ?? null\"\n >\n </svg:line>\n <svg:foreignObject\n class=\"position-absolute\"\n [attr.width]=\"node?.nativeElement.offsetWidth ?? 0\"\n [attr.height]=\"node?.nativeElement.offsetHeight ?? 0\"\n [attr.x]=\"data.x(annotation.point.x) + (annotation.dx ?? 0) - 10\"\n [attr.y]=\"data.y(annotation.point.y) + (annotation.dy ?? 0) - 10\">\n <div\n #annotationNode\n [style.background-color]=\"annotation.style?.fill ?? 'var(--color-text-90)'\"\n [style.cursor]=\"annotation?.draggable ? 'move' : 'default'\"\n [className]=\"'padding-h-2 ' + annotation.className ?? ''\"\n style=\"border-radius: 2px; display: inline-block;\">\n <ng-container *ngIf=\"annotation.template;else default\">\n <ng-container *ngTemplateOutlet=\"annotation.template;context: {$implicit: annotation}\"></ng-container>\n </ng-container>\n </div>\n </svg:foreignObject>\n </ng-container>\n</ng-container>\n<ng-template #default>\n {{ annotation.note?.label}}\n</ng-template>\n" }]
2556
- }], ctorParameters: function () { return [{ type: ScaleService }, { type: i0.ChangeDetectorRef }, { type: ChartService }]; }, propDecorators: { visibleRect: [{
2557
- type: Input
2558
- }], annotation: [{
2559
- type: Input
2560
- }], node: [{
2561
- type: ViewChild,
2562
- args: ['annotationNode', { static: false }]
2563
- }], click: [{
2564
- type: HostListener,
2565
- args: ['click', ['$event']]
2566
- }], contextMenu: [{
2567
- type: HostListener,
2568
- args: ['contextmenu', ['$event']]
2569
- }] } });
2570
-
2571
- class CrosshairComponent {
2572
- constructor(scaleService, chartService, cdr) {
2573
- this.scaleService = scaleService;
2574
- this.chartService = chartService;
2575
- this.cdr = cdr;
2576
- }
2577
- ngOnInit() {
2578
- this.transform = this.chartService.pointerMove.pipe(map((event) => {
2579
- return {
2580
- x: event.type === 'mouseleave' ? -9999 : event.offsetX,
2581
- y: event.type === 'mouseleave' ? -9999 : event.offsetY
2582
- };
2583
- }), tap(() => {
2584
- setTimeout(() => {
2585
- this.cdr.detectChanges();
2586
- });
2587
- }));
2588
- }
2589
- }
2590
- CrosshairComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: CrosshairComponent, deps: [{ token: ScaleService }, { token: ChartService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2591
- CrosshairComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: CrosshairComponent, selector: "[teta-crosshair]", inputs: { size: "size" }, ngImport: i0, template: "<ng-container *ngIf=\"transform | async as t\">\n <svg:line [attr.x1]=\"t.x\" y1=\"0\" [attr.x2]=\"t.x\" [attr.y2]=\"size.height\" stroke=\"var(--color-text-90)\" stroke-width=\"0.5\"></svg:line>\n <svg:line x1=\"0\" [attr.y1]=\"t.y\" [attr.x2]=\"size.width\" [attr.y2]=\"t.y\" stroke=\"var(--color-text-90)\" stroke-width=\"0.5\"></svg:line>\n</ng-container>\n", styles: [":host{shape-rendering:crispEdges;pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] });
2592
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: CrosshairComponent, decorators: [{
2593
- type: Component,
2594
- args: [{ selector: '[teta-crosshair]', template: "<ng-container *ngIf=\"transform | async as t\">\n <svg:line [attr.x1]=\"t.x\" y1=\"0\" [attr.x2]=\"t.x\" [attr.y2]=\"size.height\" stroke=\"var(--color-text-90)\" stroke-width=\"0.5\"></svg:line>\n <svg:line x1=\"0\" [attr.y1]=\"t.y\" [attr.x2]=\"size.width\" [attr.y2]=\"t.y\" stroke=\"var(--color-text-90)\" stroke-width=\"0.5\"></svg:line>\n</ng-container>\n", styles: [":host{shape-rendering:crispEdges;pointer-events:none}\n"] }]
2595
- }], ctorParameters: function () { return [{ type: ScaleService }, { type: ChartService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { size: [{
2596
- type: Input
2597
- }] } });
2598
-
2599
- class ChartContainerComponent {
2600
- constructor(_svc, _cdr, _scaleService, _zoomService, _elementRef, _zone) {
2601
- this._svc = _svc;
2602
- this._cdr = _cdr;
2603
- this._scaleService = _scaleService;
2604
- this._zoomService = _zoomService;
2605
- this._elementRef = _elementRef;
2606
- this._zone = _zone;
2607
- this.zoomType = ZoomType;
2608
- this.filterPositionMap = new Map()
2609
- .set(true, (axis) => (_) => _.options.opposite && _.options.visible && axis.index <= _.index)
2610
- .set(false, (axis) => (_) => _.options.opposite !== true &&
2611
- _.options.visible &&
2612
- _.index <= axis.index);
2613
- this.sumSize = (acc, curr) => acc + curr.selfSize;
2614
- this.config = this._svc.config;
2615
- this.size = this._svc.size;
2616
- this.scales = this._scaleService.scales.pipe(observeOn(animationFrameScheduler), tetaZoneFull(this._zone), shareReplay({
2617
- bufferSize: 1,
2618
- refCount: true,
2619
- }));
2620
- this.brushScale = this._scaleService.scales.pipe(withLatestFrom(this.config), map((data) => {
2621
- var _a, _b, _c, _d;
2622
- const [{ x, y }, config] = data;
2623
- return ((_a = config.brush) === null || _a === void 0 ? void 0 : _a.type) === BrushType.x || ((_b = config === null || config === void 0 ? void 0 : config.zoom) === null || _b === void 0 ? void 0 : _b.type) === ZoomType.x ? (_c = x.get(0)) === null || _c === void 0 ? void 0 : _c.scale : (_d = y.get(0)) === null || _d === void 0 ? void 0 : _d.scale;
2624
- }), shareReplay({
2625
- bufferSize: 1,
2626
- refCount: true,
2627
- }));
2628
- this.visibleRect = combineLatest([this.size, this.scales, this.config])
2629
- .pipe(map((data) => {
2630
- var _a, _b, _c, _d, _e, _f;
2631
- const [size, { x, y }, config] = data;
2632
- const yAxesArray = Array.from(y.values());
2633
- const xAxesArray = Array.from(x.values());
2634
- const left = yAxesArray
2635
- .filter((_) => _.options.opposite !== true && _.options.visible)
2636
- .reduce(this.sumSize, 0);
2637
- const right = yAxesArray
2638
- .filter((_) => _.options.opposite && _.options.visible)
2639
- .reduce(this.sumSize, 0);
2640
- const bottom = xAxesArray
2641
- .filter((_) => _.options.opposite !== true && _.options.visible)
2642
- .reduce(this.sumSize, 0);
2643
- const top = xAxesArray
2644
- .filter((_) => _.options.opposite && _.options.visible)
2645
- .reduce(this.sumSize, 0);
2646
- return {
2647
- x: left + ((_a = config.bounds) === null || _a === void 0 ? void 0 : _a.left),
2648
- y: top + ((_b = config.bounds) === null || _b === void 0 ? void 0 : _b.top),
2649
- width: size.width -
2650
- left -
2651
- right -
2652
- ((_c = config.bounds) === null || _c === void 0 ? void 0 : _c.left) -
2653
- ((_d = config.bounds) === null || _d === void 0 ? void 0 : _d.right),
2654
- height: size.height -
2655
- top -
2656
- bottom -
2657
- ((_e = config.bounds) === null || _e === void 0 ? void 0 : _e.top) -
2658
- ((_f = config.bounds) === null || _f === void 0 ? void 0 : _f.bottom),
2659
- };
2660
- }), tetaZoneFull(this._zone), shareReplay({
2661
- bufferSize: 1,
2662
- refCount: true,
2663
- }));
2664
- }
2665
- ngOnInit() {
2666
- }
2667
- ngAfterViewInit() {
2668
- this._observer = new ResizeObserver((entries) => {
2669
- requestAnimationFrame(() => {
2670
- if (!Array.isArray(entries) ||
2671
- !entries.length ||
2672
- entries[0].contentRect.width <= 0 ||
2673
- entries[0].contentRect.height <= 0) {
2674
- return;
2675
- }
2676
- this._svc.setSize(entries[0].contentRect);
2677
- });
2678
- });
2679
- this._observer.observe(this._elementRef.nativeElement);
2680
- }
2681
- ngOnDestroy() {
2682
- this._observer.unobserve(this._elementRef.nativeElement);
2683
- this._observer.disconnect();
2684
- }
2685
- getTranslate(axis, size) {
2686
- return this.scales.pipe(withLatestFrom(this.config), map((data) => {
2687
- var _a, _b, _c, _d, _e, _f;
2688
- const [{ x, y }, config] = data;
2689
- const xAxesArray = Array.from(x.values());
2690
- const yAxesArray = Array.from(y.values());
2691
- const oppositeFilter = this.filterPositionMap.get(true);
2692
- const nonOppositeFilter = this.filterPositionMap.get(false);
2693
- const oppositeOffsetY = yAxesArray.filter(oppositeFilter(axis));
2694
- const nonOppositeOffsetY = yAxesArray.filter(nonOppositeFilter(axis));
2695
- const oppositeOffsetX = xAxesArray.filter(oppositeFilter(axis));
2696
- const nonOppositeOffsetX = xAxesArray.filter(nonOppositeFilter(axis));
2697
- const oppositeTranslateY = oppositeOffsetY.reduce((acc, curr) => acc + curr.selfSize, (_a = config.bounds) === null || _a === void 0 ? void 0 : _a.right);
2698
- const nonOppisteTranslateY = nonOppositeOffsetY.reduce((acc, curr) => acc + curr.selfSize, (_b = config.bounds) === null || _b === void 0 ? void 0 : _b.left);
2699
- const oppositeTranslateX = oppositeOffsetX.reduce((acc, curr) => acc + curr.selfSize, (_c = config.bounds) === null || _c === void 0 ? void 0 : _c.top);
2700
- const nonOppisteTranslateX = nonOppositeOffsetX.reduce((acc, curr) => acc + curr.selfSize, (_d = config.bounds) === null || _d === void 0 ? void 0 : _d.bottom);
2701
- const left = yAxesArray
2702
- .filter((_) => _.options.visible && _.options.opposite !== true)
2703
- .reduce((acc, curr) => acc + curr.selfSize, (_e = config.bounds) === null || _e === void 0 ? void 0 : _e.left);
2704
- const top = xAxesArray
2705
- .filter((_) => _.options.visible && _.options.opposite === true)
2706
- .reduce((acc, curr) => acc + curr.selfSize, (_f = config.bounds) === null || _f === void 0 ? void 0 : _f.top);
2707
- if (axis.orientation === AxisOrientation.x) {
2708
- return `translate(${left}, ${axis.options.opposite
2709
- ? oppositeTranslateX
2710
- : size.height - nonOppisteTranslateX})`;
2711
- }
2712
- if (axis.orientation === AxisOrientation.y) {
2713
- return `translate(${axis.options.opposite
2714
- ? size.width - oppositeTranslateY
2715
- : nonOppisteTranslateY}, ${top})`;
2716
- }
2717
- return 'translate(0, 0)';
2718
- }));
2719
- }
2720
- identify(index, item) {
2721
- return item.value.index;
2722
- }
2723
- click(event, xScales, yScales) {
2724
- var _a, _b;
2725
- const x = (_a = xScales.get(0)) === null || _a === void 0 ? void 0 : _a.scale;
2726
- const y = (_b = yScales.get(0)) === null || _b === void 0 ? void 0 : _b.scale;
2727
- this._svc.emitChartClick({
2728
- event: event,
2729
- target: {
2730
- x: x.invert(event.offsetX),
2731
- y: y.invert(event.offsetY),
2732
- },
2733
- });
2734
- }
2735
- contextMenu(event, xScales, yScales) {
2736
- var _a, _b;
2737
- const x = (_a = xScales.get(0)) === null || _a === void 0 ? void 0 : _a.scale;
2738
- const y = (_b = yScales.get(0)) === null || _b === void 0 ? void 0 : _b.scale;
2739
- this._svc.emitChartContextMenu({
2740
- event: event,
2741
- target: {
2742
- x: x.invert(event.offsetX),
2743
- y: y.invert(event.offsetY),
2744
- },
2745
- });
2746
- }
2747
- mouseMove(event) {
2748
- this._svc.setPointerMove(event);
2749
- }
2750
- mouseLeave(event) {
2751
- this._svc.setPointerMove(event);
2752
- }
2753
- trackSerie(index, item) {
2754
- var _a;
2755
- return ((_a = item.name) === null || _a === void 0 ? void 0 : _a.length) ? item.name : index;
2756
- }
2757
- }
2758
- ChartContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartContainerComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
2759
- ChartContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: ChartContainerComponent, selector: "teta-chart-container", ngImport: i0, template: "<ng-container *ngIf=\"{\n size: size | async,\n config: config | async,\n scales: scales | async,\n visibleRect: visibleRect | async\n} as data\" xmlns:svg=\"http://www.w3.org/1999/html\">\n <teta-tooltip *ngIf=\"data.config?.tooltip?.enable\"\n [size]=\"data.size\"\n [config]=\"data.config\"></teta-tooltip>\n <ng-container *ngIf=\"data.size?.height > 0\n && data.size?.width > 0\n && data.visibleRect?.height > 0\n && data.visibleRect?.width > 0\n && data.scales?.x.size === data.config.xAxis.length\n && data.scales?.y.size === data.config.yAxis.length\">\n <svg height=\"100%\" width=\"100%\" class=\"position-absolute\">\n <g class=\"y-axis-container\">\n <ng-container *ngFor=\"let item of data.scales.y | keyvalue; trackBy: identify\">\n <ng-container *ngIf=\"item.value.selfSize > 0\n && item.value.options.visible\n && data.scales.x.size > 0\n && data.scales.y.size > 0\">\n <g\n teta-y-axis\n [axis]=\"item.value\"\n [size]=\"data.visibleRect\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></g>\n <rect\n tetaZoomable\n fill-opacity=\"0\"\n [axis]=\"item.value\"\n [config]=\"data.config\"\n [size]=\"data.visibleRect\"\n [attr.x]=\"item.value.options.opposite ? 0 : -item.value.selfSize\"\n [attr.y]=\"0\"\n [attr.height]=\"data.visibleRect.height\"\n [attr.width]=\"item.value.selfSize\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></rect>\n </ng-container>\n\n </ng-container>\n </g>\n <g class=\"x-axis-container\">\n <ng-container *ngFor=\"let item of data.scales.x | keyvalue; trackBy: identify\">\n <ng-container *ngIf=\"item.value.options.visible && data.scales.x.size > 0 && data.scales.y.size > 0\">\n <g\n teta-x-axis\n [axis]=\"item.value\"\n [size]=\"data.visibleRect\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></g>\n <rect\n tetaZoomable\n fill-opacity=\"0\"\n [axis]=\"item.value\"\n [config]=\"data.config\"\n [size]=\"data.visibleRect\"\n [attr.x]=\"0\"\n [attr.y]=\"item.value.options.opposite ? -item.value.selfSize : 0\"\n [attr.width]=\"data.visibleRect.width\"\n [attr.height]=\"item.value.selfSize\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></rect>\n </ng-container>\n </ng-container>\n </g>\n </svg>\n </ng-container>\n <ng-container\n *ngIf=\"data.size?.height > 0\n && data.size?.width > 0\n && data.visibleRect?.height > 0\n && data.visibleRect?.width > 0\n && data.scales?.x.size === data.config.xAxis.length\n && data.scales?.y.size === data.config.yAxis.length\">\n <svg\n tetaZoomable\n tetaBrushable\n class=\"position-absolute\"\n [size]=\"data.visibleRect\"\n [config]=\"data.config\"\n [axis]=\"data.config?.zoom?.type === zoomType.x ? data.scales.x.get(0) : data.scales.y.get(0)\"\n [attr.width]=\"data.visibleRect.width\"\n [attr.height]=\"data.visibleRect.height\"\n [attr.viewBox]=\"'0 0 ' + data.visibleRect.width + ' ' + data.visibleRect.height\"\n [style.transform]=\"'translate('+ data.visibleRect.x +'px, '+ data.visibleRect.y +'px)'\"\n (contextmenu)=\"contextMenu($event, data.scales.x, data.scales.y)\"\n (click)=\"click($event, data.scales.x, data.scales.y)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousemove)=\"mouseMove($event)\">\n\n <g class=\"gridlines\"\n teta-gridlines\n *ngIf=\"data.config.gridLines?.enable !== false\"\n [size]=\"data.size\"></g>\n\n <g class=\"x-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of data.config.xAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotBand of axis.plotBands\"\n [plotBand]=\"plotBand\"\n [scale]=\"data.scales.x.get(i).scale\"\n [size]=\"data.visibleRect\"\n [axis]=\"data.scales.x.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"y-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of data.config.yAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotBand of axis.plotBands\"\n [plotBand]=\"plotBand\"\n [scale]=\"data.scales.y.get(i).scale\"\n [size]=\"data.visibleRect\"\n [axis]=\"data.scales.y.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"x-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of data.config.xAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotLine of axis.plotLines\"\n [plotLine]=\"plotLine\"\n [scale]=\"data.scales.x.get(i).scale\"\n [size]=\"data.size\"\n [axis]=\"data.scales.x.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"y-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of data.config.yAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotLine of axis.plotLines\"\n [plotLine]=\"plotLine\"\n [scale]=\"data.scales.y.get(i).scale\"\n [size]=\"data.size\"\n [axis]=\"data.scales.y.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"series-container\">\n <ng-container *ngFor=\"let series of data.config.series;\">\n <g teta-series-host\n *ngIf=\"series.visible\"\n [config]=\"data.config\"\n [series]=\"series\"></g>\n </ng-container>\n </g>\n <g class=\"annotations\">\n <g teta-annotation\n [visibleRect]=\"data.visibleRect\"\n *ngFor=\"let annotation of data.config.annotations\"\n [annotation]=\"annotation\"></g>\n </g>\n <g class=\"crosshair\" *ngIf=\"data.config.tooltip?.showCrosshair\">\n <g teta-crosshair [size]=\"data.visibleRect\"></g>\n </g>\n </svg>\n\n </ng-container>\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}:host .crosshair{cursor:crosshair}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: SeriesHostComponent, selector: "[teta-series-host]", inputs: ["config", "series"] }, { kind: "component", type: GridlinesComponent, selector: "[teta-gridlines]", inputs: ["size"] }, { kind: "component", type: XAxisComponent, selector: "[teta-x-axis]", inputs: ["axis", "size"] }, { kind: "component", type: YAxisComponent, selector: "[teta-y-axis]", inputs: ["axis", "size"] }, { kind: "component", type: PlotlineComponent, selector: "[teta-plot-line]", inputs: ["plotLine", "size", "axis", "scale"] }, { kind: "component", type: PlotBandComponent, selector: "[teta-plot-band]", inputs: ["plotBand", "axis", "scale", "size"] }, { kind: "component", type: TooltipComponent, selector: "teta-tooltip", inputs: ["size", "config"] }, { kind: "directive", type: ZoomableDirective, selector: "[tetaZoomable]", inputs: ["config", "axis", "size"] }, { kind: "directive", type: BrushableDirective, selector: "[tetaBrushable]", inputs: ["config", "axis"] }, { kind: "component", type: AnnotationComponent, selector: "[teta-annotation]", inputs: ["visibleRect", "annotation"] }, { kind: "component", type: CrosshairComponent, selector: "[teta-crosshair]", inputs: ["size"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i4.KeyValuePipe, name: "keyvalue" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2760
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartContainerComponent, decorators: [{
2761
- type: Component,
2762
- args: [{ selector: 'teta-chart-container', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n size: size | async,\n config: config | async,\n scales: scales | async,\n visibleRect: visibleRect | async\n} as data\" xmlns:svg=\"http://www.w3.org/1999/html\">\n <teta-tooltip *ngIf=\"data.config?.tooltip?.enable\"\n [size]=\"data.size\"\n [config]=\"data.config\"></teta-tooltip>\n <ng-container *ngIf=\"data.size?.height > 0\n && data.size?.width > 0\n && data.visibleRect?.height > 0\n && data.visibleRect?.width > 0\n && data.scales?.x.size === data.config.xAxis.length\n && data.scales?.y.size === data.config.yAxis.length\">\n <svg height=\"100%\" width=\"100%\" class=\"position-absolute\">\n <g class=\"y-axis-container\">\n <ng-container *ngFor=\"let item of data.scales.y | keyvalue; trackBy: identify\">\n <ng-container *ngIf=\"item.value.selfSize > 0\n && item.value.options.visible\n && data.scales.x.size > 0\n && data.scales.y.size > 0\">\n <g\n teta-y-axis\n [axis]=\"item.value\"\n [size]=\"data.visibleRect\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></g>\n <rect\n tetaZoomable\n fill-opacity=\"0\"\n [axis]=\"item.value\"\n [config]=\"data.config\"\n [size]=\"data.visibleRect\"\n [attr.x]=\"item.value.options.opposite ? 0 : -item.value.selfSize\"\n [attr.y]=\"0\"\n [attr.height]=\"data.visibleRect.height\"\n [attr.width]=\"item.value.selfSize\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></rect>\n </ng-container>\n\n </ng-container>\n </g>\n <g class=\"x-axis-container\">\n <ng-container *ngFor=\"let item of data.scales.x | keyvalue; trackBy: identify\">\n <ng-container *ngIf=\"item.value.options.visible && data.scales.x.size > 0 && data.scales.y.size > 0\">\n <g\n teta-x-axis\n [axis]=\"item.value\"\n [size]=\"data.visibleRect\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></g>\n <rect\n tetaZoomable\n fill-opacity=\"0\"\n [axis]=\"item.value\"\n [config]=\"data.config\"\n [size]=\"data.visibleRect\"\n [attr.x]=\"0\"\n [attr.y]=\"item.value.options.opposite ? -item.value.selfSize : 0\"\n [attr.width]=\"data.visibleRect.width\"\n [attr.height]=\"item.value.selfSize\"\n [attr.transform]=\"getTranslate(item.value, data.size) | async\"></rect>\n </ng-container>\n </ng-container>\n </g>\n </svg>\n </ng-container>\n <ng-container\n *ngIf=\"data.size?.height > 0\n && data.size?.width > 0\n && data.visibleRect?.height > 0\n && data.visibleRect?.width > 0\n && data.scales?.x.size === data.config.xAxis.length\n && data.scales?.y.size === data.config.yAxis.length\">\n <svg\n tetaZoomable\n tetaBrushable\n class=\"position-absolute\"\n [size]=\"data.visibleRect\"\n [config]=\"data.config\"\n [axis]=\"data.config?.zoom?.type === zoomType.x ? data.scales.x.get(0) : data.scales.y.get(0)\"\n [attr.width]=\"data.visibleRect.width\"\n [attr.height]=\"data.visibleRect.height\"\n [attr.viewBox]=\"'0 0 ' + data.visibleRect.width + ' ' + data.visibleRect.height\"\n [style.transform]=\"'translate('+ data.visibleRect.x +'px, '+ data.visibleRect.y +'px)'\"\n (contextmenu)=\"contextMenu($event, data.scales.x, data.scales.y)\"\n (click)=\"click($event, data.scales.x, data.scales.y)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousemove)=\"mouseMove($event)\">\n\n <g class=\"gridlines\"\n teta-gridlines\n *ngIf=\"data.config.gridLines?.enable !== false\"\n [size]=\"data.size\"></g>\n\n <g class=\"x-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of data.config.xAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotBand of axis.plotBands\"\n [plotBand]=\"plotBand\"\n [scale]=\"data.scales.x.get(i).scale\"\n [size]=\"data.visibleRect\"\n [axis]=\"data.scales.x.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"y-axis-plotband-container\">\n <ng-container *ngFor=\"let axis of data.config.yAxis; let i = index\">\n <g teta-plot-band *ngFor=\"let plotBand of axis.plotBands\"\n [plotBand]=\"plotBand\"\n [scale]=\"data.scales.y.get(i).scale\"\n [size]=\"data.visibleRect\"\n [axis]=\"data.scales.y.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"x-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of data.config.xAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotLine of axis.plotLines\"\n [plotLine]=\"plotLine\"\n [scale]=\"data.scales.x.get(i).scale\"\n [size]=\"data.size\"\n [axis]=\"data.scales.x.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"y-axis-plotline-container\">\n <ng-container *ngFor=\"let axis of data.config.yAxis; let i = index\">\n <g teta-plot-line *ngFor=\"let plotLine of axis.plotLines\"\n [plotLine]=\"plotLine\"\n [scale]=\"data.scales.y.get(i).scale\"\n [size]=\"data.size\"\n [axis]=\"data.scales.y.get(i)\"></g>\n </ng-container>\n </g>\n <g class=\"series-container\">\n <ng-container *ngFor=\"let series of data.config.series;\">\n <g teta-series-host\n *ngIf=\"series.visible\"\n [config]=\"data.config\"\n [series]=\"series\"></g>\n </ng-container>\n </g>\n <g class=\"annotations\">\n <g teta-annotation\n [visibleRect]=\"data.visibleRect\"\n *ngFor=\"let annotation of data.config.annotations\"\n [annotation]=\"annotation\"></g>\n </g>\n <g class=\"crosshair\" *ngIf=\"data.config.tooltip?.showCrosshair\">\n <g teta-crosshair [size]=\"data.visibleRect\"></g>\n </g>\n </svg>\n\n </ng-container>\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}:host .crosshair{cursor:crosshair}\n"] }]
2763
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }, { type: i0.NgZone }]; } });
2764
-
2765
- class LegendComponent {
2766
- constructor(chartService) {
2767
- this.chartService = chartService;
2768
- this.sizeMapping = new Map()
2769
- .set(SeriesType.line, 2)
2770
- .set(SeriesType.scatter, 2)
2771
- .set(SeriesType.bar, 12)
2772
- .set(SeriesType.area, 2)
2773
- .set(SeriesType.block, 12)
2774
- .set(SeriesType.blockArea, 2);
2775
- this.classLegend = true;
2776
- }
2777
- getHeight(serie) {
2778
- var _a;
2779
- return this.sizeMapping.get((_a = serie.type) !== null && _a !== void 0 ? _a : SeriesType.line);
2780
- }
2781
- click(serie) {
2782
- this.chartService.toggleVisibilitySeries([serie.id]);
2783
- }
2784
- }
2785
- LegendComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: LegendComponent, deps: [{ token: ChartService }], target: i0.ɵɵFactoryTarget.Component });
2786
- LegendComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: LegendComponent, selector: "teta-legend", inputs: { series: "series" }, host: { properties: { "class.padding-bottom-4": "this.classLegend" } }, ngImport: i0, template: "<ng-container *ngFor=\"let serie of series\" class=\"padding-bottom-4\">\n <div *ngIf=\"serie?.showInLegend !== false\">\n <div class=\"legend-item cursor-pointer\" (click)=\"click(serie)\">\n <div class=\"legend-icon-form\"\n [style.height.px]=\"getHeight(serie)\"\n [style.border-top-color]=\"serie.visible ? serie.color : 'var(--color-text-30)'\"\n [style.border-top-style]=\"serie.style?.strokeDasharray ? 'dashed' : 'solid'\"\n [style.border-width.px]=\"serie.style?.strokeDasharray ? 1 : 2\"></div>\n <div class=\"legend-label\" style=\"user-select: none\" [style.text-decoration]=\"serie.visible ? 'none' : 'line-through'\">{{ serie.name }}</div>\n </div>\n </div>\n</ng-container>\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"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2787
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: LegendComponent, decorators: [{
2788
- type: Component,
2789
- args: [{ selector: 'teta-legend', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngFor=\"let serie of series\" class=\"padding-bottom-4\">\n <div *ngIf=\"serie?.showInLegend !== false\">\n <div class=\"legend-item cursor-pointer\" (click)=\"click(serie)\">\n <div class=\"legend-icon-form\"\n [style.height.px]=\"getHeight(serie)\"\n [style.border-top-color]=\"serie.visible ? serie.color : 'var(--color-text-30)'\"\n [style.border-top-style]=\"serie.style?.strokeDasharray ? 'dashed' : 'solid'\"\n [style.border-width.px]=\"serie.style?.strokeDasharray ? 1 : 2\"></div>\n <div class=\"legend-label\" style=\"user-select: none\" [style.text-decoration]=\"serie.visible ? 'none' : 'line-through'\">{{ serie.name }}</div>\n </div>\n </div>\n</ng-container>\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"] }]
2790
- }], ctorParameters: function () { return [{ type: ChartService }]; }, propDecorators: { series: [{
2791
- type: Input
2792
- }], classLegend: [{
2793
- type: HostBinding,
2794
- args: ['class.padding-bottom-4']
2795
- }] } });
2796
-
2797
- class ChartComponent {
2798
- constructor(chartService, zoomService, brushService, scaleService) {
2799
- this.chartService = chartService;
2800
- this.zoomService = zoomService;
2801
- this.brushService = brushService;
2802
- this.scaleService = scaleService;
2803
- this.pointerMove = new EventEmitter();
2804
- this.plotBandsMove = new EventEmitter();
2805
- this.plotBandClick = new EventEmitter();
2806
- this.plotBandContextMenu = new EventEmitter();
2807
- this.plotLinesMove = new EventEmitter();
2808
- this.pointMove = new EventEmitter();
2809
- this.chartClick = new EventEmitter();
2810
- this.chartContextMenu = new EventEmitter();
2811
- this.annotationContextMenu = new EventEmitter();
2812
- this.annotationClick = new EventEmitter();
2813
- this.annotationMove = new EventEmitter();
2814
- this.zoomServiceInstance = new EventEmitter();
2815
- this.brushServiceInstance = new EventEmitter();
2816
- this._alive = true;
2817
- this.svcConfig = this.chartService.config;
2818
- this.hasSeriesData = this.svcConfig.pipe(map((_) => { var _a, _b; return ((_a = _.series) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = _.series) === null || _b === void 0 ? void 0 : _b.some((_) => { var _a; return ((_a = _.data) === null || _a === void 0 ? void 0 : _a.length) > 0; })); }));
2819
- }
2820
- set config(config) {
2821
- var _a;
2822
- this.chartService.setConfig(config);
2823
- this.zoomService.setBroadcastChannel((_a = config === null || config === void 0 ? void 0 : config.zoom) === null || _a === void 0 ? void 0 : _a.syncChannel);
2824
- }
2825
- resetZoom() {
2826
- this.scaleService.resetZoom();
2827
- }
2828
- // setZoom() {
2829
- // this.zoomService.fireZoom()
2830
- // }
2831
- ngOnChanges(changes) {
2832
- }
2833
- ngOnInit() {
2834
- this.zoomServiceInstance.emit(this.zoomService);
2835
- this.brushServiceInstance.emit(this.brushService);
2836
- this.chartService.pointerMove
2837
- .pipe(takeWhile(() => this._alive), withLatestFrom(this.scaleService.scales, this.chartService.config))
2838
- .subscribe((data) => {
2839
- var _a;
2840
- const [event, { x, y }, config] = data;
2841
- const tooltipTracking = (_a = config === null || config === void 0 ? void 0 : config.tooltip) === null || _a === void 0 ? void 0 : _a.tracking;
2842
- if (tooltipTracking === TooltipTracking.y) {
2843
- const result = new Map();
2844
- y.forEach((value, key) => {
2845
- if (value.options.scaleType.type === ScaleType.band) {
2846
- return;
2847
- }
2848
- result.set(key, value.scale.invert(event.offsetY));
2849
- });
2850
- this.pointerMove.emit({
2851
- event: event,
2852
- target: result
2853
- });
2854
- }
2855
- else {
2856
- const result = new Map();
2857
- x.forEach((value, key) => {
2858
- if (value.options.scaleType.type === ScaleType.band) {
2859
- return;
2860
- }
2861
- result.set(key, value.scale.invert(event.offsetX));
2862
- });
2863
- this.pointerMove.emit({
2864
- event: event,
2865
- target: result
2866
- });
2867
- }
2868
- });
2869
- this.chartService.plotBandEvent
2870
- .pipe(takeWhile(() => this._alive))
2871
- .subscribe((_) => {
2872
- this.plotBandsMove.emit(_);
2873
- });
2874
- this.chartService.plotLineMove.pipe(takeWhile(() => this._alive)).subscribe((_) => {
2875
- this.plotLinesMove.emit(_);
2876
- });
2877
- this.chartService.pointMove.pipe(takeWhile(() => this._alive)).subscribe((_) => {
2878
- this.pointMove.emit(_);
2879
- });
2880
- this.chartService.chartClick
2881
- .pipe(takeWhile(() => this._alive)).subscribe((_) => {
2882
- this.chartClick.emit(_);
2883
- });
2884
- this.chartService.chartContextMenu
2885
- .pipe(takeWhile(() => this._alive)).subscribe((_) => {
2886
- this.chartContextMenu.emit(_);
2887
- });
2888
- this.chartService.plotBandClick
2889
- .pipe(takeWhile(() => this._alive))
2890
- .subscribe((_) => {
2891
- this.plotBandClick.emit(_);
2892
- });
2893
- this.chartService.plotBandContextMenu
2894
- .pipe(takeWhile(() => this._alive))
2895
- .subscribe((_) => {
2896
- this.plotBandContextMenu.emit(_);
2897
- });
2898
- this.chartService.annotationContextMenu
2899
- .pipe(takeWhile(() => this._alive))
2900
- .subscribe((_) => {
2901
- this.annotationContextMenu.emit(_);
2902
- });
2903
- this.chartService.annotationClick
2904
- .pipe(takeWhile(() => this._alive))
2905
- .subscribe((_) => {
2906
- this.annotationClick.emit(_);
2907
- });
2908
- this.chartService.annotationMove
2909
- .pipe(takeWhile(() => this._alive))
2910
- .subscribe((_) => {
2911
- this.annotationMove.emit(_);
2912
- });
2913
- }
2914
- ngAfterViewInit() {
2915
- }
2916
- ngOnDestroy() {
2917
- this._alive = false;
2918
- }
2919
- }
2920
- ChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartComponent, deps: [{ token: ChartService }, { token: ZoomService }, { token: BrushService }, { token: ScaleService }], target: i0.ɵɵFactoryTarget.Component });
2921
- ChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: ChartComponent, selector: "teta-svg-chart", inputs: { config: "config" }, outputs: { pointerMove: "pointerMove", plotBandsMove: "plotBandsMove", plotBandClick: "plotBandClick", plotBandContextMenu: "plotBandContextMenu", plotLinesMove: "plotLinesMove", pointMove: "pointMove", chartClick: "chartClick", chartContextMenu: "chartContextMenu", annotationContextMenu: "annotationContextMenu", annotationClick: "annotationClick", annotationMove: "annotationMove", zoomServiceInstance: "zoomServiceInstance", brushServiceInstance: "brushServiceInstance" }, providers: [ChartService, ZoomService, ScaleService, BrushService], usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n hasSeriesData: hasSeriesData | async,\n svcConfig: svcConfig | async\n} as data\">\n <ng-container *ngIf=\"data.hasSeriesData === true else noData\">\n <div class=\"column column_auto\">\n <teta-chart-container class=\"chart-container position-relative\"></teta-chart-container>\n </div>\n <teta-legend *ngIf=\"data.svcConfig.legend?.enable === true\" [series]=\"data.svcConfig.series\"></teta-legend>\n </ng-container>\n</ng-container>\n<ng-template #noData>\n <div class=\"column column_auto justify-content-center\">\n <span class=\"font-body-3 color-text-40 overflow-hidden text-overflow-ellipsis nowrap text-align-center\">\n <div #ref><ng-content></ng-content></div>\n <span *ngIf=\"!ref.hasChildNodes()\">\n No data\n </span>\n </span>\n </div>\n</ng-template>\n", styles: [":host{position:relative;display:flex;flex-direction:column;height:100%;width:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ChartContainerComponent, selector: "teta-chart-container" }, { kind: "component", type: LegendComponent, selector: "teta-legend", inputs: ["series"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2922
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartComponent, decorators: [{
2923
- type: Component,
2924
- args: [{ selector: 'teta-svg-chart', providers: [ChartService, ZoomService, ScaleService, BrushService], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n hasSeriesData: hasSeriesData | async,\n svcConfig: svcConfig | async\n} as data\">\n <ng-container *ngIf=\"data.hasSeriesData === true else noData\">\n <div class=\"column column_auto\">\n <teta-chart-container class=\"chart-container position-relative\"></teta-chart-container>\n </div>\n <teta-legend *ngIf=\"data.svcConfig.legend?.enable === true\" [series]=\"data.svcConfig.series\"></teta-legend>\n </ng-container>\n</ng-container>\n<ng-template #noData>\n <div class=\"column column_auto justify-content-center\">\n <span class=\"font-body-3 color-text-40 overflow-hidden text-overflow-ellipsis nowrap text-align-center\">\n <div #ref><ng-content></ng-content></div>\n <span *ngIf=\"!ref.hasChildNodes()\">\n No data\n </span>\n </span>\n </div>\n</ng-template>\n", styles: [":host{position:relative;display:flex;flex-direction:column;height:100%;width:100%}\n"] }]
2925
- }], ctorParameters: function () { return [{ type: ChartService }, { type: ZoomService }, { type: BrushService }, { type: ScaleService }]; }, propDecorators: { pointerMove: [{
2926
- type: Output
2927
- }], plotBandsMove: [{
2928
- type: Output
2929
- }], plotBandClick: [{
2930
- type: Output
2931
- }], plotBandContextMenu: [{
2932
- type: Output
2933
- }], plotLinesMove: [{
2934
- type: Output
2935
- }], pointMove: [{
2936
- type: Output
2937
- }], chartClick: [{
2938
- type: Output
2939
- }], chartContextMenu: [{
2940
- type: Output
2941
- }], annotationContextMenu: [{
2942
- type: Output
2943
- }], annotationClick: [{
2944
- type: Output
2945
- }], annotationMove: [{
2946
- type: Output
2947
- }], zoomServiceInstance: [{
2948
- type: Output
2949
- }], brushServiceInstance: [{
2950
- type: Output
2951
- }], config: [{
2952
- type: Input
2953
- }] } });
2954
-
2955
- class BandseriesComponent extends SeriesBaseComponent {
2956
- constructor(svc, cdr, scaleService, zoomService, element) {
2957
- super(svc, cdr, scaleService, zoomService, element);
2958
- this.svc = svc;
2959
- this.cdr = cdr;
2960
- this.scaleService = scaleService;
2961
- this.zoomService = zoomService;
2962
- this.element = element;
2963
- }
2964
- ngOnInit() {
2965
- this.x = this.scaleService.scales.pipe(map(_ => { var _a; return (_a = _.x.get(this.series.xAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
2966
- this.y = this.scaleService.scales.pipe(map(_ => { var _a; return (_a = _.y.get(this.series.yAxisIndex)) === null || _a === void 0 ? void 0 : _a.scale; }));
2967
- }
2968
- }
2969
- BandseriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BandseriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
2970
- BandseriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: BandseriesComponent, selector: "svg:svg[teta-bandseries]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{x: x | async, y: y | async} as scales\">\n <ng-container *ngFor=\"let band of _series.data\">\n <svg:rect [attr.x]=\"scales.x(band.x)\"\n [attr.y]=\"scales.y(band.y) - scales.y.bandwidth() / 2\"\n [attr.width]=\"scales.x(band.x1) - scales.x(band.x)\"\n fill=\"red\"\n [attr.height]=\"scales.y.bandwidth()\">\n </svg:rect>\n <svg:text\n text-anchor=\"middle\"\n dominant-baseline=\"middle\"\n class=\"label font-caption fill-text-90\"\n [attr.x]=\"scales.x(band.x) + (scales.x(band.x1) - scales.x(band.x)) / 2\"\n [attr.y]=\"scales.y(band.y)\">{{band.y}}\n </svg:text>\n </ng-container>\n\n</ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] });
2971
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: BandseriesComponent, decorators: [{
2972
- type: Component,
2973
- args: [{ selector: 'svg:svg[teta-bandseries]', template: "<ng-container *ngIf=\"{x: x | async, y: y | async} as scales\">\n <ng-container *ngFor=\"let band of _series.data\">\n <svg:rect [attr.x]=\"scales.x(band.x)\"\n [attr.y]=\"scales.y(band.y) - scales.y.bandwidth() / 2\"\n [attr.width]=\"scales.x(band.x1) - scales.x(band.x)\"\n fill=\"red\"\n [attr.height]=\"scales.y.bandwidth()\">\n </svg:rect>\n <svg:text\n text-anchor=\"middle\"\n dominant-baseline=\"middle\"\n class=\"label font-caption fill-text-90\"\n [attr.x]=\"scales.x(band.x) + (scales.x(band.x1) - scales.x(band.x)) / 2\"\n [attr.y]=\"scales.y(band.y)\">{{band.y}}\n </svg:text>\n </ng-container>\n\n</ng-container>\n" }]
2974
- }], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
2975
-
2976
- class ChartModule {
2977
- }
2978
- ChartModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2979
- ChartModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: ChartModule, declarations: [ChartComponent,
2980
- SeriesHostComponent,
2981
- ChartContainerComponent,
2982
- LegendComponent,
2983
- SeriesBaseComponent,
2984
- LinearSeriesBase,
2985
- LineSeriesComponent,
2986
- GridlinesComponent,
2987
- XAxisComponent,
2988
- YAxisComponent,
2989
- PlotlineComponent,
2990
- PlotBandComponent,
2991
- BarSeriesComponent,
2992
- TooltipComponent,
2993
- ZoomableDirective,
2994
- BrushableDirective,
2995
- AreaSeriesComponent,
2996
- ScatterSeriesComponent,
2997
- BlockSeriesComponent,
2998
- BlockAreaSeriesComponent,
2999
- AnnotationComponent,
3000
- CrosshairComponent,
3001
- DraggablePointDirective,
3002
- BandseriesComponent], imports: [CommonModule, LetModule], exports: [ChartComponent,
3003
- LegendComponent,
3004
- SeriesBaseComponent,
3005
- LineSeriesComponent,
3006
- BarSeriesComponent,
3007
- ScatterSeriesComponent,
3008
- AreaSeriesComponent,
3009
- BlockSeriesComponent,
3010
- BlockAreaSeriesComponent] });
3011
- ChartModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartModule, imports: [CommonModule, LetModule] });
3012
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ChartModule, decorators: [{
3013
- type: NgModule,
3014
- args: [{
3015
- declarations: [
3016
- ChartComponent,
3017
- SeriesHostComponent,
3018
- ChartContainerComponent,
3019
- LegendComponent,
3020
- SeriesBaseComponent,
3021
- LinearSeriesBase,
3022
- LineSeriesComponent,
3023
- GridlinesComponent,
3024
- XAxisComponent,
3025
- YAxisComponent,
3026
- PlotlineComponent,
3027
- PlotBandComponent,
3028
- BarSeriesComponent,
3029
- TooltipComponent,
3030
- ZoomableDirective,
3031
- BrushableDirective,
3032
- AreaSeriesComponent,
3033
- ScatterSeriesComponent,
3034
- BlockSeriesComponent,
3035
- BlockAreaSeriesComponent,
3036
- AnnotationComponent,
3037
- CrosshairComponent,
3038
- DraggablePointDirective,
3039
- BandseriesComponent,
3040
- ],
3041
- exports: [
3042
- ChartComponent,
3043
- LegendComponent,
3044
- SeriesBaseComponent,
3045
- LineSeriesComponent,
3046
- BarSeriesComponent,
3047
- ScatterSeriesComponent,
3048
- AreaSeriesComponent,
3049
- BlockSeriesComponent,
3050
- BlockAreaSeriesComponent,
3051
- ],
3052
- imports: [CommonModule, LetModule],
3053
- }]
3054
- }] });
3055
-
3056
- class PlotBand {
3057
- constructor(options) {
3058
- this.id = options === null || options === void 0 ? void 0 : options.id;
3059
- this.name = options === null || options === void 0 ? void 0 : options.name;
3060
- this.from = options === null || options === void 0 ? void 0 : options.from;
3061
- this.to = options === null || options === void 0 ? void 0 : options.to;
3062
- this.label = options === null || options === void 0 ? void 0 : options.label;
3063
- this.showGrabbers =
3064
- (options === null || options === void 0 ? void 0 : options.showGrabbers) != null ? options.showGrabbers : true;
3065
- this.draggable = (options === null || options === void 0 ? void 0 : options.draggable) != null ? options === null || options === void 0 ? void 0 : options.draggable : false;
3066
- this.resizable = (options === null || options === void 0 ? void 0 : options.resizable) != null ? options === null || options === void 0 ? void 0 : options.resizable : true;
3067
- this.min = options === null || options === void 0 ? void 0 : options.min;
3068
- this.max = options === null || options === void 0 ? void 0 : options.max;
3069
- this.style = options === null || options === void 0 ? void 0 : options.style;
3070
- }
3071
- }
3072
-
3073
- class PlotLine {
3074
- constructor(options) {
3075
- this.id = options === null || options === void 0 ? void 0 : options.id;
3076
- this.name = options === null || options === void 0 ? void 0 : options.name;
3077
- this.value = options === null || options === void 0 ? void 0 : options.value;
3078
- this.label = options === null || options === void 0 ? void 0 : options.label;
3079
- this.min = options === null || options === void 0 ? void 0 : options.min;
3080
- this.max = options === null || options === void 0 ? void 0 : options.max;
3081
- this.draggable = options === null || options === void 0 ? void 0 : options.draggable;
3082
- this.style = options === null || options === void 0 ? void 0 : options.style;
3083
- }
3084
- }
3085
-
3086
- /*
3087
- * Public API Surface of chart
3088
- */
3089
-
3090
- /**
3091
- * Generated bundle index. Do not edit.
3092
- */
3093
-
3094
- export { AreaSeriesComponent, Axis, AxisOrientation, BarSeriesComponent, BlockAreaSeriesComponent, BlockSeriesComponent, BroadcastService, BrushMessage, BrushService, BrushType, ChartBounds, ChartComponent, ChartModule, ChartService, ClipPointsDirection, DragPointType, FillDirection, FillType, LegendComponent, LineSeriesComponent, PlotBand, PlotLine, ScaleService, ScaleType, ScatterSeriesComponent, SeriesBaseComponent, SeriesType, TooltipTracking, ZoomBehaviorType, ZoomMessage, ZoomService, ZoomType, generateTicks, getTextWidth };
3095
- //# sourceMappingURL=tetacom-svg-charts.mjs.map