@tetacom/svg-charts 1.0.2 → 1.1.3

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