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