@pioneer-code/pioneer-charts 1.0.2 → 1.0.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 (253) hide show
  1. package/README.md +27 -50
  2. package/esm2022/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.builder.mjs +272 -0
  3. package/esm2022/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.mjs +47 -0
  4. package/esm2022/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.model.mjs +2 -0
  5. package/esm2022/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.module.mjs +20 -0
  6. package/esm2022/lib/bar-chart/bar-horizontal-chart/public_api.mjs +5 -0
  7. package/esm2022/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.builder.mjs +284 -0
  8. package/esm2022/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.component.mjs +47 -0
  9. package/esm2022/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.model.mjs +2 -0
  10. package/esm2022/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.module.mjs +20 -0
  11. package/esm2022/lib/bar-chart/bar-vertical-chart/public_api.mjs +5 -0
  12. package/esm2022/lib/core/axis.builder.mjs +58 -0
  13. package/esm2022/lib/core/chart.mjs +90 -0
  14. package/esm2022/lib/core/chart.model.mjs +7 -0
  15. package/esm2022/lib/core/color.service.mjs +74 -0
  16. package/esm2022/lib/core/grid.builder.mjs +40 -0
  17. package/esm2022/lib/core/index.mjs +2 -0
  18. package/esm2022/lib/core/public_api.mjs +8 -0
  19. package/esm2022/lib/core/tooltip.builder.mjs +42 -0
  20. package/esm2022/lib/core/transition.service.mjs +19 -0
  21. package/esm2022/lib/line-area-chart/line-area-chart-effects.builders.mjs +117 -0
  22. package/esm2022/lib/line-area-chart/line-area-chart.builder.mjs +206 -0
  23. package/esm2022/lib/line-area-chart/line-area-chart.component.mjs +47 -0
  24. package/esm2022/lib/line-area-chart/line-area-chart.model.mjs +2 -0
  25. package/esm2022/lib/line-area-chart/line-area-chart.module.mjs +24 -0
  26. package/esm2022/lib/line-area-chart/public_api.mjs +5 -0
  27. package/esm2022/lib/pie-chart/pie-chart.builder.mjs +99 -0
  28. package/esm2022/lib/pie-chart/pie-chart.component.mjs +47 -0
  29. package/esm2022/lib/pie-chart/pie-chart.model.mjs +2 -0
  30. package/esm2022/lib/pie-chart/pie-chart.module.mjs +24 -0
  31. package/esm2022/lib/pie-chart/public_api.mjs +5 -0
  32. package/esm2022/pioneer-code-pioneer-charts.mjs +5 -0
  33. package/esm2022/public-api.mjs +9 -0
  34. package/fesm2022/pioneer-code-pioneer-charts.mjs +1493 -0
  35. package/fesm2022/pioneer-code-pioneer-charts.mjs.map +1 -0
  36. package/index.d.ts +5 -0
  37. package/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.builder.d.ts +41 -39
  38. package/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.d.ts +21 -18
  39. package/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.model.d.ts +15 -15
  40. package/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.module.d.ts +7 -2
  41. package/lib/bar-chart/bar-horizontal-chart/public_api.d.ts +4 -4
  42. package/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.builder.d.ts +42 -40
  43. package/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.component.d.ts +21 -18
  44. package/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.model.d.ts +15 -15
  45. package/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.module.d.ts +7 -2
  46. package/lib/bar-chart/bar-vertical-chart/public_api.d.ts +4 -4
  47. package/lib/core/axis.builder.d.ts +21 -18
  48. package/lib/core/chart.d.ts +55 -52
  49. package/lib/core/chart.model.d.ts +21 -21
  50. package/lib/core/color.service.d.ts +32 -29
  51. package/lib/core/grid.builder.d.ts +22 -19
  52. package/lib/core/index.d.ts +1 -1
  53. package/lib/core/public_api.d.ts +7 -8
  54. package/lib/core/tooltip.builder.d.ts +10 -11
  55. package/lib/core/transition.service.d.ts +7 -4
  56. package/lib/line-area-chart/line-area-chart-effects.builders.d.ts +27 -27
  57. package/lib/line-area-chart/line-area-chart.builder.d.ts +39 -38
  58. package/lib/line-area-chart/line-area-chart.component.d.ts +21 -18
  59. package/lib/line-area-chart/line-area-chart.model.d.ts +9 -9
  60. package/lib/line-area-chart/line-area-chart.module.d.ts +8 -2
  61. package/lib/line-area-chart/public_api.d.ts +4 -4
  62. package/lib/pie-chart/pie-chart.builder.d.ts +33 -34
  63. package/lib/pie-chart/pie-chart.component.d.ts +21 -18
  64. package/lib/pie-chart/pie-chart.model.d.ts +4 -4
  65. package/lib/pie-chart/pie-chart.module.d.ts +8 -2
  66. package/lib/pie-chart/public_api.d.ts +4 -4
  67. package/package.json +21 -19
  68. package/public-api.d.ts +5 -0
  69. package/scss/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.scss +19 -0
  70. package/scss/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.component.scss +8 -0
  71. package/scss/{core → lib/core}/theme/imports.scss +12 -12
  72. package/scss/lib/line-area-chart/line-area-chart.component.scss +35 -0
  73. package/scss/{pie-chart → lib/pie-chart}/pie-chart.component.scss +10 -10
  74. package/scss/{core/core.scss → lib/pioneer-charts.scss} +26 -13
  75. package/themes/pioneer-charts.css +22 -0
  76. package/themes/pioneer-charts.css.map +10 -0
  77. package/themes/pioneer-charts.min.css +3 -0
  78. package/themes/pioneer-charts.min.css.map +10 -0
  79. package/bundles/pioneer-code-pioneer-charts.umd.js +0 -3700
  80. package/bundles/pioneer-code-pioneer-charts.umd.js.map +0 -1
  81. package/bundles/pioneer-code-pioneer-charts.umd.min.js +0 -2
  82. package/bundles/pioneer-code-pioneer-charts.umd.min.js.map +0 -1
  83. package/esm2015/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.builder.js +0 -486
  84. package/esm2015/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.js +0 -89
  85. package/esm2015/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.model.js +0 -37
  86. package/esm2015/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.module.js +0 -19
  87. package/esm2015/lib/bar-chart/bar-horizontal-chart/index.js +0 -6
  88. package/esm2015/lib/bar-chart/bar-horizontal-chart/public_api.js +0 -9
  89. package/esm2015/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.builder.js +0 -518
  90. package/esm2015/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.component.js +0 -89
  91. package/esm2015/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.model.js +0 -37
  92. package/esm2015/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.module.js +0 -19
  93. package/esm2015/lib/bar-chart/bar-vertical-chart/index.js +0 -6
  94. package/esm2015/lib/bar-chart/bar-vertical-chart/public_api.js +0 -9
  95. package/esm2015/lib/core/axis.builder.js +0 -99
  96. package/esm2015/lib/core/chart.js +0 -144
  97. package/esm2015/lib/core/chart.model.js +0 -39
  98. package/esm2015/lib/core/color.service.js +0 -149
  99. package/esm2015/lib/core/core.module.js +0 -24
  100. package/esm2015/lib/core/grid.builder.js +0 -88
  101. package/esm2015/lib/core/index.js +0 -6
  102. package/esm2015/lib/core/public_api.js +0 -13
  103. package/esm2015/lib/core/tooltip.builder.js +0 -74
  104. package/esm2015/lib/core/transition.service.js +0 -23
  105. package/esm2015/lib/dialog/dialog.component.js +0 -50
  106. package/esm2015/lib/dialog/dialog.module.js +0 -23
  107. package/esm2015/lib/dialog/index.js +0 -6
  108. package/esm2015/lib/dialog/public_api.js +0 -7
  109. package/esm2015/lib/header/header.component.js +0 -21
  110. package/esm2015/lib/header/header.model.js +0 -13
  111. package/esm2015/lib/header/header.module.js +0 -19
  112. package/esm2015/lib/header/index.js +0 -6
  113. package/esm2015/lib/header/public_api.js +0 -8
  114. package/esm2015/lib/line-area-chart/index.js +0 -6
  115. package/esm2015/lib/line-area-chart/line-area-chart-effects.builders.js +0 -236
  116. package/esm2015/lib/line-area-chart/line-area-chart.builder.js +0 -386
  117. package/esm2015/lib/line-area-chart/line-area-chart.component.js +0 -89
  118. package/esm2015/lib/line-area-chart/line-area-chart.model.js +0 -23
  119. package/esm2015/lib/line-area-chart/line-area-chart.module.js +0 -19
  120. package/esm2015/lib/line-area-chart/public_api.js +0 -9
  121. package/esm2015/lib/pagination/index.js +0 -6
  122. package/esm2015/lib/pagination/pagination.component.js +0 -144
  123. package/esm2015/lib/pagination/pagination.model.js +0 -48
  124. package/esm2015/lib/pagination/pagination.module.js +0 -25
  125. package/esm2015/lib/pagination/public_api.js +0 -8
  126. package/esm2015/lib/pie-chart/index.js +0 -6
  127. package/esm2015/lib/pie-chart/pie-chart.builder.js +0 -221
  128. package/esm2015/lib/pie-chart/pie-chart.component.js +0 -89
  129. package/esm2015/lib/pie-chart/pie-chart.model.js +0 -13
  130. package/esm2015/lib/pie-chart/pie-chart.module.js +0 -19
  131. package/esm2015/lib/pie-chart/public_api.js +0 -9
  132. package/esm2015/lib/spinner/index.js +0 -6
  133. package/esm2015/lib/spinner/public_api.js +0 -7
  134. package/esm2015/lib/spinner/spinner.component.js +0 -28
  135. package/esm2015/lib/spinner/spinner.module.js +0 -23
  136. package/esm2015/lib/table/index.js +0 -6
  137. package/esm2015/lib/table/public_api.js +0 -8
  138. package/esm2015/lib/table/table-sort.service.js +0 -95
  139. package/esm2015/lib/table/table.component.js +0 -232
  140. package/esm2015/lib/table/table.model.js +0 -51
  141. package/esm2015/lib/table/table.module.js +0 -23
  142. package/esm2015/pioneer-code-pioneer-charts.js +0 -10
  143. package/esm2015/public_api.js +0 -18
  144. package/esm5/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.builder.js +0 -550
  145. package/esm5/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.js +0 -102
  146. package/esm5/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.model.js +0 -37
  147. package/esm5/lib/bar-chart/bar-horizontal-chart/bar-horizontal-chart.module.js +0 -23
  148. package/esm5/lib/bar-chart/bar-horizontal-chart/index.js +0 -6
  149. package/esm5/lib/bar-chart/bar-horizontal-chart/public_api.js +0 -9
  150. package/esm5/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.builder.js +0 -582
  151. package/esm5/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.component.js +0 -102
  152. package/esm5/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.model.js +0 -37
  153. package/esm5/lib/bar-chart/bar-vertical-chart/bar-vertical-chart.module.js +0 -23
  154. package/esm5/lib/bar-chart/bar-vertical-chart/index.js +0 -6
  155. package/esm5/lib/bar-chart/bar-vertical-chart/public_api.js +0 -9
  156. package/esm5/lib/core/axis.builder.js +0 -117
  157. package/esm5/lib/core/chart.js +0 -182
  158. package/esm5/lib/core/chart.model.js +0 -39
  159. package/esm5/lib/core/color.service.js +0 -199
  160. package/esm5/lib/core/core.module.js +0 -28
  161. package/esm5/lib/core/grid.builder.js +0 -100
  162. package/esm5/lib/core/index.js +0 -6
  163. package/esm5/lib/core/public_api.js +0 -13
  164. package/esm5/lib/core/tooltip.builder.js +0 -92
  165. package/esm5/lib/core/transition.service.js +0 -28
  166. package/esm5/lib/dialog/dialog.component.js +0 -58
  167. package/esm5/lib/dialog/dialog.module.js +0 -27
  168. package/esm5/lib/dialog/index.js +0 -6
  169. package/esm5/lib/dialog/public_api.js +0 -7
  170. package/esm5/lib/header/header.component.js +0 -25
  171. package/esm5/lib/header/header.model.js +0 -13
  172. package/esm5/lib/header/header.module.js +0 -23
  173. package/esm5/lib/header/index.js +0 -6
  174. package/esm5/lib/header/public_api.js +0 -8
  175. package/esm5/lib/line-area-chart/index.js +0 -6
  176. package/esm5/lib/line-area-chart/line-area-chart-effects.builders.js +0 -280
  177. package/esm5/lib/line-area-chart/line-area-chart.builder.js +0 -439
  178. package/esm5/lib/line-area-chart/line-area-chart.component.js +0 -102
  179. package/esm5/lib/line-area-chart/line-area-chart.model.js +0 -23
  180. package/esm5/lib/line-area-chart/line-area-chart.module.js +0 -23
  181. package/esm5/lib/line-area-chart/public_api.js +0 -9
  182. package/esm5/lib/pagination/index.js +0 -6
  183. package/esm5/lib/pagination/pagination.component.js +0 -182
  184. package/esm5/lib/pagination/pagination.model.js +0 -48
  185. package/esm5/lib/pagination/pagination.module.js +0 -29
  186. package/esm5/lib/pagination/public_api.js +0 -8
  187. package/esm5/lib/pie-chart/index.js +0 -6
  188. package/esm5/lib/pie-chart/pie-chart.builder.js +0 -242
  189. package/esm5/lib/pie-chart/pie-chart.component.js +0 -102
  190. package/esm5/lib/pie-chart/pie-chart.model.js +0 -13
  191. package/esm5/lib/pie-chart/pie-chart.module.js +0 -23
  192. package/esm5/lib/pie-chart/public_api.js +0 -9
  193. package/esm5/lib/spinner/index.js +0 -6
  194. package/esm5/lib/spinner/public_api.js +0 -7
  195. package/esm5/lib/spinner/spinner.component.js +0 -30
  196. package/esm5/lib/spinner/spinner.module.js +0 -27
  197. package/esm5/lib/table/index.js +0 -6
  198. package/esm5/lib/table/public_api.js +0 -8
  199. package/esm5/lib/table/table-sort.service.js +0 -119
  200. package/esm5/lib/table/table.component.js +0 -299
  201. package/esm5/lib/table/table.model.js +0 -51
  202. package/esm5/lib/table/table.module.js +0 -27
  203. package/esm5/pioneer-code-pioneer-charts.js +0 -10
  204. package/esm5/public_api.js +0 -18
  205. package/fesm2015/pioneer-code-pioneer-charts.js +0 -3077
  206. package/fesm2015/pioneer-code-pioneer-charts.js.map +0 -1
  207. package/fesm5/pioneer-code-pioneer-charts.js +0 -3665
  208. package/fesm5/pioneer-code-pioneer-charts.js.map +0 -1
  209. package/lib/bar-chart/bar-horizontal-chart/index.d.ts +0 -1
  210. package/lib/bar-chart/bar-vertical-chart/index.d.ts +0 -1
  211. package/lib/core/core.module.d.ts +0 -2
  212. package/lib/dialog/dialog.component.d.ts +0 -9
  213. package/lib/dialog/dialog.module.d.ts +0 -2
  214. package/lib/dialog/index.d.ts +0 -1
  215. package/lib/dialog/public_api.d.ts +0 -2
  216. package/lib/header/header.component.d.ts +0 -4
  217. package/lib/header/header.model.d.ts +0 -3
  218. package/lib/header/header.module.d.ts +0 -2
  219. package/lib/header/index.d.ts +0 -1
  220. package/lib/header/public_api.d.ts +0 -3
  221. package/lib/line-area-chart/index.d.ts +0 -1
  222. package/lib/pagination/index.d.ts +0 -1
  223. package/lib/pagination/pagination.component.d.ts +0 -20
  224. package/lib/pagination/pagination.model.d.ts +0 -28
  225. package/lib/pagination/pagination.module.d.ts +0 -2
  226. package/lib/pagination/public_api.d.ts +0 -3
  227. package/lib/pie-chart/index.d.ts +0 -1
  228. package/lib/spinner/index.d.ts +0 -1
  229. package/lib/spinner/public_api.d.ts +0 -2
  230. package/lib/spinner/spinner.component.d.ts +0 -4
  231. package/lib/spinner/spinner.module.d.ts +0 -2
  232. package/lib/table/index.d.ts +0 -1
  233. package/lib/table/public_api.d.ts +0 -3
  234. package/lib/table/table-sort.service.d.ts +0 -10
  235. package/lib/table/table.component.d.ts +0 -51
  236. package/lib/table/table.model.d.ts +0 -28
  237. package/lib/table/table.module.d.ts +0 -2
  238. package/pioneer-code-pioneer-charts.d.ts +0 -5
  239. package/pioneer-code-pioneer-charts.metadata.json +0 -1
  240. package/public_api.d.ts +0 -10
  241. package/scss/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.scss +0 -7
  242. package/scss/bar-chart/bar-vertical-chart/bar-vertical-chart.component.scss +0 -7
  243. package/scss/dialog/dialog.component.scss +0 -42
  244. package/scss/header/header.component.scss +0 -8
  245. package/scss/line-area-chart/line-area-chart.component.scss +0 -28
  246. package/scss/pagination/pagination.component.scss +0 -94
  247. package/scss/pcac.scss +0 -61
  248. package/scss/spinner/spinner.component.scss +0 -34
  249. package/scss/table/table.component.scss +0 -143
  250. package/themes/pcac.css +0 -291
  251. package/themes/pcac.css.map +0 -19
  252. package/themes/pcac.min.css +0 -3
  253. package/themes/pcac.min.css.map +0 -19
@@ -1,3077 +0,0 @@
1
- import { axisLeft, axisBottom } from 'd3-axis';
2
- import { format } from 'd3-format';
3
- import { select, event, mouse } from 'd3-selection';
4
- import { Injectable, NgModule, Component, Input, EventEmitter, ChangeDetectorRef, Output, ViewChild, ViewChildren, HostListener } from '@angular/core';
5
- import { BrowserModule } from '@angular/platform-browser';
6
- import { scaleLinear, scaleBand } from 'd3-scale';
7
- import { color } from 'd3-color';
8
- import { transition } from 'd3-transition';
9
- import { Subject } from 'rxjs';
10
- import { arc, pie, line, area } from 'd3-shape';
11
- import { interpolate } from 'd3-interpolate';
12
- import { range } from 'd3-array';
13
- import { CommonModule } from '@angular/common';
14
- import { FormsModule } from '@angular/forms';
15
-
16
- /**
17
- * @fileoverview added by tsickle
18
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
19
- */
20
- /** @enum {string} */
21
- const PcacTickFormatEnum = {
22
- None: 'none',
23
- Percentage: 'percentage',
24
- Minutes: 'minutes',
25
- };
26
-
27
- /**
28
- * @fileoverview added by tsickle
29
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
30
- */
31
- class PcacAxisBuilder {
32
- /**
33
- * @param {?} config
34
- * @return {?}
35
- */
36
- drawAxis(config) {
37
- if (!config.hideXAxis) {
38
- this.drawXAxis(config);
39
- }
40
- if (!config.hideYAxis) {
41
- this.drawYAxis(config);
42
- }
43
- }
44
- /**
45
- * @private
46
- * @param {?} config
47
- * @return {?}
48
- */
49
- drawYAxis(config) {
50
- /** @type {?} */
51
- const yAxis = axisLeft(config.yScale).ticks(config.numberOfTicks);
52
- if (config.yFormat) {
53
- switch (config.yFormat.toLocaleLowerCase()) {
54
- case PcacTickFormatEnum.Percentage:
55
- yAxis.tickFormat(format('.0%'));
56
- break;
57
- case PcacTickFormatEnum.Minutes:
58
- yAxis.tickFormat((/**
59
- * @param {?} d
60
- * @return {?}
61
- */
62
- (d) => d + 'm'));
63
- break;
64
- }
65
- }
66
- config.svg.append('g')
67
- .attr('class', 'pcac-y-axis')
68
- .call(yAxis);
69
- }
70
- /**
71
- * @private
72
- * @param {?} config
73
- * @return {?}
74
- */
75
- drawXAxis(config) {
76
- /** @type {?} */
77
- const xAxis = axisBottom(config.xScale).ticks(config.numberOfTicks);
78
- if (config.xFormat) {
79
- switch (config.xFormat.toLocaleLowerCase()) {
80
- case PcacTickFormatEnum.Percentage:
81
- xAxis.tickFormat(format('.0%'));
82
- break;
83
- case PcacTickFormatEnum.Minutes:
84
- xAxis.tickFormat((/**
85
- * @param {?} d
86
- * @return {?}
87
- */
88
- (d) => d + 'm'));
89
- break;
90
- }
91
- }
92
- config.svg.append('g')
93
- .attr('class', 'pcac-x-axis')
94
- .attr('transform', 'translate(0,' + config.height + ')')
95
- .call(xAxis);
96
- }
97
- }
98
-
99
- /**
100
- * @fileoverview added by tsickle
101
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
102
- */
103
- class PcacGridBuilder {
104
- /**
105
- * @param {?} config
106
- * @return {?}
107
- */
108
- drawVerticalGrid(config) {
109
- config.svg.append('g')
110
- .attr('class', 'pcac-grid')
111
- .selectAll('g.rule')
112
- .data(config.xScale.ticks(5))
113
- .enter().append('svg:g')
114
- .attr('class', 'pcac-grid-rule')
115
- .attr('transform', (/**
116
- * @param {?} d
117
- * @return {?}
118
- */
119
- (d) => (`translate(${config.xScale(d)}, 0)`)))
120
- .append('svg:line')
121
- .attr('y1', 0)
122
- .attr('y2', config.height)
123
- .attr('class', (/**
124
- * @param {?} d
125
- * @param {?} i
126
- * @return {?}
127
- */
128
- (d, i) => (i === 0 ? 'pcac-grid-rule-last' : '')));
129
- }
130
- /**
131
- * @param {?} config
132
- * @return {?}
133
- */
134
- drawHorizontalGrid(config) {
135
- config.svg.append('g')
136
- .attr('class', 'pcac-grid')
137
- .selectAll('g.pcac-grid-rule')
138
- .data(config.yScale.ticks(config.numberOfTicks))
139
- .enter().append('svg:g')
140
- .attr('class', 'pcac-grid-rule')
141
- .append('svg:line')
142
- .attr('y1', (/**
143
- * @param {?} d
144
- * @return {?}
145
- */
146
- (d) => config.yScale(d)))
147
- .attr('y2', (/**
148
- * @param {?} d
149
- * @return {?}
150
- */
151
- (d) => config.yScale(d)))
152
- .attr('x1', 0)
153
- .attr('x2', config.width)
154
- .attr('class', (/**
155
- * @param {?} d
156
- * @param {?} i
157
- * @return {?}
158
- */
159
- (d, i) => (i === 0 ? 'pcac-grid-rule-last' : '')));
160
- }
161
- }
162
-
163
- /**
164
- * @fileoverview added by tsickle
165
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
166
- */
167
- class PcacColorService {
168
- constructor() {
169
- this.primary = '#43425d';
170
- this.primaryLight = '#a3a1fb';
171
- this.success = '#5ee2a0';
172
- this.danger = '#ff6565';
173
- this.warning = '#fec163';
174
- this.orange = '#ffa177';
175
- this.blue = '#55d8fe';
176
- this.scale = (/** @type {?} */ ([
177
- this.primaryLight,
178
- this.success,
179
- this.danger,
180
- this.warning,
181
- this.orange,
182
- this.blue
183
- ]));
184
- this.alert = 'red';
185
- }
186
- /**
187
- * Get a scale of colors dynamically
188
- * @param {?} numberOfNodes Number of items in dynamically build collection of colors
189
- * @return {?}
190
- */
191
- getColorScale(numberOfNodes) {
192
- /** @type {?} */
193
- const pallette = (/** @type {?} */ ([]));
194
- for (let i = 0; i < numberOfNodes; i++) {
195
- /** @type {?} */
196
- const mark = i % this.scale.length;
197
- pallette.push(this.scale[mark]);
198
- }
199
- return pallette;
200
- }
201
- /**
202
- * @return {?}
203
- */
204
- getAlert() {
205
- return this.alert;
206
- }
207
- /**
208
- * Set the scale that charts use to set colors of data[x] on the UI.
209
- * @param {?} colors A collection of hex values
210
- * @return {?}
211
- */
212
- setScale(colors) {
213
- this.scale = colors;
214
- }
215
- /**
216
- * @param {?} color
217
- * @return {?}
218
- */
219
- setPrimary(color) {
220
- this.primary = color;
221
- }
222
- /**
223
- * @param {?} color
224
- * @return {?}
225
- */
226
- setPrimaryLight(color) {
227
- this.primaryLight = color;
228
- }
229
- /**
230
- * @param {?} color
231
- * @return {?}
232
- */
233
- setSuccess(color) {
234
- this.success = color;
235
- }
236
- /**
237
- * @param {?} color
238
- * @return {?}
239
- */
240
- setDanger(color) {
241
- this.danger = color;
242
- }
243
- /**
244
- * @param {?} color
245
- * @return {?}
246
- */
247
- setOrange(color) {
248
- this.orange = color;
249
- }
250
- /**
251
- * @param {?} color
252
- * @return {?}
253
- */
254
- setBlue(color) {
255
- this.blue = color;
256
- }
257
- /**
258
- * @return {?}
259
- */
260
- setAlert() {
261
- return this.alert;
262
- }
263
- }
264
-
265
- /**
266
- * @fileoverview added by tsickle
267
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
268
- */
269
- class PcacTransitionService {
270
- constructor() {
271
- this.transitionDuration = 750;
272
- }
273
- /**
274
- * @return {?}
275
- */
276
- getTransitionDuration() {
277
- return this.transitionDuration;
278
- }
279
- }
280
-
281
- /**
282
- * @fileoverview added by tsickle
283
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
284
- */
285
- class PcacTooltipBuilder {
286
- constructor() {
287
- this.tooltip = (/** @type {?} */ (select('body').append('div').attr('class', 'pcac-d3-tooltip'))); // TODO: Strongly type
288
- }
289
- // TODO: Strongly type
290
- /**
291
- * @param {?} data
292
- * @param {?=} tickFormat
293
- * @return {?}
294
- */
295
- showBarTooltip(data, tickFormat) {
296
- this.tooltip.style('left', event.pageX - 50 + 'px')
297
- .style('top', event.pageY - 70 + 'px')
298
- .style('display', 'inline-block')
299
- .html(this.getBarTipData(data, tickFormat));
300
- }
301
- /**
302
- * @return {?}
303
- */
304
- hideTooltip() {
305
- this.tooltip.style('display', 'none');
306
- }
307
- /**
308
- * @private
309
- * @param {?} data
310
- * @param {?=} tickFormat
311
- * @return {?}
312
- */
313
- getBarTipData(data, tickFormat) {
314
- /** @type {?} */
315
- let value = data.value;
316
- if (tickFormat) {
317
- switch (tickFormat.toLocaleLowerCase()) {
318
- case PcacTickFormatEnum.Percentage:
319
- value = (/** @type {?} */ (value)) * 100 + '%';
320
- break;
321
- case PcacTickFormatEnum.Minutes:
322
- break;
323
- }
324
- }
325
- return data.key ? data.key + '</br>' + value.toString() : value.toString();
326
- }
327
- }
328
- PcacTooltipBuilder.decorators = [
329
- { type: Injectable }
330
- ];
331
-
332
- /**
333
- * @fileoverview added by tsickle
334
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
335
- */
336
- class PcacChart {
337
- // TODO: Strongly type
338
- /**
339
- * @param {?} axisBuilder
340
- * @param {?} gridBuilder
341
- * @param {?} transitionService
342
- * @param {?} tooltipBuilder
343
- * @param {?} colorService
344
- */
345
- constructor(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService) {
346
- this.axisBuilder = axisBuilder;
347
- this.gridBuilder = gridBuilder;
348
- this.transitionService = transitionService;
349
- this.tooltipBuilder = tooltipBuilder;
350
- this.colorService = colorService;
351
- this.margin = { top: 8, right: 16, bottom: 20, left: 40 };
352
- this.width = 400;
353
- this.height = 400;
354
- this.colors = (/** @type {?} */ ([]));
355
- this.startData = (/** @type {?} */ ([])); // TODO: Strongly type
356
- // TODO: Strongly type
357
- this.endData = (/** @type {?} */ ([])); // TODO: Strongly type
358
- }
359
- /**
360
- * Prior to building a chart, we need to initialize the state of the chart
361
- * @param {?} chartElm Reference to SVG on dom
362
- * @param {?} config Chart specific configuration
363
- * @return {?}
364
- */
365
- initializeChartState(chartElm, config) {
366
- select(chartElm.nativeElement).select('g').remove();
367
- this.width = chartElm.nativeElement.parentNode.clientWidth - this.margin.left - this.margin.right;
368
- this.height = config.height;
369
- this.colors = this.colorService.getColorScale(Math.max(config.data.length, config.data[0].data ? config.data[0].data.length : 0));
370
- }
371
- /**
372
- * 1) Set the width and height of the SVG
373
- * 2) Add a group and translate it to state of {{center}} option
374
- * @param {?} chartElm Reference to SVG on dom
375
- * @param {?=} center Are we pinning x,y to the top,left, or are we centering our drawing group inside the SVG.
376
- * @return {?}
377
- */
378
- buildContainer(chartElm, center = false) {
379
- /** @type {?} */
380
- const combinedHeight = this.height + this.margin.top + this.margin.bottom;
381
- /** @type {?} */
382
- const combinedWidth = this.width + this.margin.left + this.margin.right;
383
- this.svg = select(chartElm.nativeElement)
384
- .attr('width', combinedWidth)
385
- .attr('height', combinedHeight);
386
- if (center) {
387
- this.svg = this.svg
388
- .append('g')
389
- .attr('transform', 'translate(' + combinedWidth / 2 + ',' + combinedHeight / 2 + ')');
390
- return;
391
- }
392
- this.svg = this.svg
393
- .append('g')
394
- .attr('transform', 'translate(' + this.margin.left + ',' + this.margin.top + ')');
395
- }
396
- /**
397
- * Most charts share a default margin(s) state.
398
- * In some cases, that state needs to be calculated based on the content that resides in that margin.
399
- * For example, labels on a horizontal bar chart are dynamic and such the margin needs to be calculated ahead of
400
- * chart axis construction.
401
- * @param {?} chartElm Reference to SVG on dom
402
- * @param {?} data Generic multi-dimensional IPcacData structure
403
- * @param {?} yScale D3 scale transformation object (d3.ScaleBand)
404
- * @return {?}
405
- */
406
- setHorizontalMarginsBasedOnContent(chartElm, data, yScale) {
407
- /** @type {?} */
408
- const axisY = axisLeft(yScale).ticks(5);
409
- /** @type {?} */
410
- let max = 0;
411
- select(chartElm.nativeElement).append('g')
412
- .call(axisY)
413
- .each((/**
414
- * @param {?} d
415
- * @param {?} i
416
- * @param {?} n
417
- * @return {?}
418
- */
419
- (d, i, n) => {
420
- if (n[i].getBBox().width > max) {
421
- max = n[i].getBBox().width;
422
- }
423
- }))
424
- .remove();
425
- this.margin.left = max;
426
- this.margin.bottom = this.margin.bottom;
427
- this.width = this.width - this.margin.left;
428
- }
429
- }
430
- PcacChart.decorators = [
431
- { type: Injectable }
432
- ];
433
- /** @nocollapse */
434
- PcacChart.ctorParameters = () => [
435
- { type: PcacAxisBuilder },
436
- { type: PcacGridBuilder },
437
- { type: PcacTransitionService },
438
- { type: PcacTooltipBuilder },
439
- { type: PcacColorService }
440
- ];
441
-
442
- /**
443
- * @fileoverview added by tsickle
444
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
445
- */
446
- class PcacCoreModule {
447
- }
448
- PcacCoreModule.decorators = [
449
- { type: NgModule, args: [{
450
- providers: [
451
- PcacColorService,
452
- PcacTransitionService,
453
- PcacGridBuilder,
454
- PcacAxisBuilder,
455
- PcacTooltipBuilder
456
- ]
457
- },] }
458
- ];
459
-
460
- /**
461
- * @fileoverview added by tsickle
462
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
463
- */
464
-
465
- /**
466
- * @fileoverview added by tsickle
467
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
468
- */
469
-
470
- /**
471
- * @fileoverview added by tsickle
472
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
473
- */
474
- class PcacHeaderComponent {
475
- }
476
- PcacHeaderComponent.decorators = [
477
- { type: Component, args: [{
478
- selector: 'pcac-header',
479
- template: "<section class=\"pcac-font-family pcac-header\">\r\n <div class=\"clearfix\">\r\n <div class=\"float-left\">\r\n <h3>{{config?.title}}</h3>\r\n </div>\r\n </div>\r\n</section>\r\n"
480
- }] }
481
- ];
482
- PcacHeaderComponent.propDecorators = {
483
- config: [{ type: Input }]
484
- };
485
-
486
- /**
487
- * @fileoverview added by tsickle
488
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
489
- */
490
-
491
- /**
492
- * @fileoverview added by tsickle
493
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
494
- */
495
- class PcacHeaderModule {
496
- }
497
- PcacHeaderModule.decorators = [
498
- { type: NgModule, args: [{
499
- exports: [
500
- PcacHeaderComponent
501
- ],
502
- declarations: [
503
- PcacHeaderComponent
504
- ]
505
- },] }
506
- ];
507
-
508
- /**
509
- * @fileoverview added by tsickle
510
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
511
- */
512
-
513
- /**
514
- * @fileoverview added by tsickle
515
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
516
- */
517
-
518
- /**
519
- * @fileoverview added by tsickle
520
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
521
- */
522
- /** @enum {string} */
523
- const PcacTableSortIconsEnum = {
524
- Sort: 'pcac-icon pcac-icon-sort',
525
- SortAsc: 'pcac-icon pcac-icon-sort-asc',
526
- SortDesc: 'pcac-icon pcac-icon-sort-desc',
527
- };
528
-
529
- /**
530
- * @fileoverview added by tsickle
531
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
532
- */
533
- class TableSortService {
534
- /**
535
- * @param {?} data
536
- * @param {?} columnIndex
537
- * @param {?} direction
538
- * @return {?}
539
- */
540
- sort(data, columnIndex, direction) {
541
- if (data) {
542
- this.sortData(data, columnIndex, direction);
543
- }
544
- }
545
- /**
546
- * @private
547
- * @param {?} data
548
- * @param {?} columnIndex
549
- * @param {?} direction
550
- * @return {?}
551
- */
552
- sortData(data, columnIndex, direction) {
553
- data.sort((/**
554
- * @param {?} a
555
- * @param {?} b
556
- * @return {?}
557
- */
558
- (a, b) => {
559
- /** @type {?} */
560
- const comparison = (direction === PcacTableSortIconsEnum.SortAsc)
561
- ? -this.orderByComparer(a.data[columnIndex].value, b.data[columnIndex].value)
562
- : this.orderByComparer(a.data[columnIndex].value, b.data[columnIndex].value);
563
- if (comparison !== 0) {
564
- return comparison;
565
- }
566
- // equal each other
567
- return 0;
568
- }));
569
- }
570
- /**
571
- * @private
572
- * @param {?} a
573
- * @param {?} b
574
- * @return {?}
575
- */
576
- orderByComparer(a, b) {
577
- if (a === null || typeof a === 'undefined') {
578
- a = 0;
579
- }
580
- if (b === null || typeof b === 'undefined') {
581
- b = 0;
582
- }
583
- if ((isNaN(parseFloat(a)) || !isFinite(a)) || (isNaN(parseFloat(b)) || !isFinite(b))) {
584
- // is not a number so lowercase the string to properly compare
585
- if (a.toLowerCase() < b.toLowerCase()) {
586
- return -1;
587
- }
588
- if (a.toLowerCase() > b.toLowerCase()) {
589
- return 1;
590
- }
591
- }
592
- else {
593
- // parse strings as numbers to compare properly
594
- if (parseFloat(a) < parseFloat(b)) {
595
- return -1;
596
- }
597
- if (parseFloat(a) > parseFloat(b)) {
598
- return 1;
599
- }
600
- }
601
- // equal each other
602
- return 0;
603
- }
604
- }
605
- TableSortService.decorators = [
606
- { type: Injectable }
607
- ];
608
-
609
- /**
610
- * @fileoverview added by tsickle
611
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
612
- */
613
- class PcacTableComponent {
614
- /**
615
- * @param {?} sortService
616
- * @param {?} changeDetector
617
- */
618
- constructor(sortService, changeDetector) {
619
- this.sortService = sortService;
620
- this.changeDetector = changeDetector;
621
- this.config = (/** @type {?} */ ({ height: 400 }));
622
- this.deleteClicked = new EventEmitter();
623
- this.editClicked = new EventEmitter();
624
- this.historyClicked = new EventEmitter();
625
- this.columnWidths = (/** @type {?} */ ([]));
626
- this.headers = (/** @type {?} */ ([]));
627
- this.rowData = (/** @type {?} */ ([]));
628
- this.adjustedHeight = 200;
629
- }
630
- /**
631
- * @return {?}
632
- */
633
- ngAfterViewInit() {
634
- this.initTableUi();
635
- // @ngFor rows finished
636
- this.rows.changes.subscribe((/**
637
- * @return {?}
638
- */
639
- () => {
640
- if (this.config.enableStickyHeader || this.config.enableStickyFooter) {
641
- this.calculateColumnWidths();
642
- }
643
- }));
644
- }
645
- /**
646
- * @return {?}
647
- */
648
- ngOnChanges() {
649
- this.initTableUi();
650
- }
651
- /**
652
- * @param {?} row
653
- * @return {?}
654
- */
655
- onEditClicked(row) {
656
- this.editClicked.emit(row);
657
- }
658
- /**
659
- * @param {?} row
660
- * @return {?}
661
- */
662
- onDeleteClicked(row) {
663
- this.deleteClicked.emit(row);
664
- }
665
- /**
666
- * @param {?} row
667
- * @return {?}
668
- */
669
- onHistoryClicked(row) {
670
- this.historyClicked.emit(row);
671
- }
672
- /**
673
- * @private
674
- * @return {?}
675
- */
676
- initTableUi() {
677
- if (this.config && this.config.data && this.config.data.length > 0) {
678
- this.adjustedHeight = this.config.height + 28;
679
- if (this.config.enableStickyHeader || this.config.enableStickyFooter) {
680
- this.calculateColumnWidths();
681
- }
682
- this.setHeaders();
683
- this.setRows();
684
- }
685
- }
686
- /**
687
- * When dealing with sticky header/footer, we need to calc widths of absolute positioned
688
- * table columns.
689
- * @private
690
- * @return {?}
691
- */
692
- calculateColumnWidths() {
693
- if (this.tableBody.nativeElement.rows[0]) {
694
- /** @type {?} */
695
- const cells = this.tableBody.nativeElement.rows[0].cells;
696
- this.columnWidths = (/** @type {?} */ ([]));
697
- for (let i = 0; i < cells.length; i++) {
698
- this.columnWidths.push(cells[i].clientWidth);
699
- }
700
- // https://stackoverflow.com/questions/44922384/angular4-change-detection-expressionchangedafterithasbeencheckederror
701
- this.changeDetector.detectChanges();
702
- }
703
- }
704
- /**
705
- * Set internal cache of headers to ease template manipulation and apply icon
706
- * @private
707
- * @return {?}
708
- */
709
- setHeaders() {
710
- this.headers = (/** @type {?} */ ([]));
711
- for (let i = 0; i < this.config.data[0].data.length; i++) {
712
- this.headers.push((/** @type {?} */ ({
713
- key: this.config.data[0].data[i].key,
714
- value: this.config.data[0].data[i].value,
715
- icon: PcacTableSortIconsEnum.Sort
716
- })));
717
- }
718
- }
719
- /**
720
- * Deep copy of rows to ease template manipulation and sorting
721
- * @private
722
- * @return {?}
723
- */
724
- setRows() {
725
- this.rowData = JSON.parse(JSON.stringify(this.config.data)).slice(1);
726
- }
727
- /**
728
- * On header click, sort column.
729
- * @param {?} columnIndex
730
- * @return {?}
731
- */
732
- sortTable(columnIndex) {
733
- /** @type {?} */
734
- const direction = this.headers[columnIndex].icon === PcacTableSortIconsEnum.SortAsc ?
735
- PcacTableSortIconsEnum.SortDesc :
736
- PcacTableSortIconsEnum.SortAsc;
737
- this.clearStateExceptCurrent(columnIndex);
738
- this.sortService.sort(this.rowData, columnIndex, direction);
739
- this.headers[columnIndex].icon = direction;
740
- }
741
- /**
742
- * @private
743
- * @param {?} columnIndex
744
- * @return {?}
745
- */
746
- clearStateExceptCurrent(columnIndex) {
747
- for (let i = 0; i < this.headers.length; i++) {
748
- if (i !== columnIndex) {
749
- this.headers[i].icon = PcacTableSortIconsEnum.Sort;
750
- }
751
- }
752
- }
753
- /**
754
- * Opting against fromEvent due to incompatibility with rxjs 5 => 6
755
- * @return {?}
756
- */
757
- onResize() {
758
- /** @type {?} */
759
- const self = this;
760
- clearTimeout(this.resizeWindowTimeout);
761
- this.resizeWindowTimeout = setTimeout((/**
762
- * @return {?}
763
- */
764
- () => {
765
- self.initTableUi();
766
- }), 300);
767
- }
768
- }
769
- PcacTableComponent.decorators = [
770
- { type: Component, args: [{
771
- selector: 'pcac-table',
772
- template: "<section class=\"pcac-table-container pcac-font-family\" [style.max-height.px]=\"adjustedHeight\"\r\n [ngClass]=\"{'hide-first-column':config?.hideColumnOne}\">\r\n <table class=\"pcac-table\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let header of headers; let i = index\" (click)=\"sortTable(i)\">\r\n <i [ngClass]=\"header.icon\"></i>\r\n {{header.value}}\r\n </th>\r\n <th *ngIf=\"config?.enableDeleteAction || config?.enableEditAction || config?.enableHistoryAction\"></th>\r\n </tr>\r\n </thead>\r\n <tbody #tableBody>\r\n <tr *ngFor=\"let row of rowData\" #rows>\r\n <td *ngFor=\"let cell of row.data\">{{cell.value}}</td>\r\n <td *ngIf=\"config?.enableDeleteAction || config?.enableEditAction || config?.enableHistoryAction\">\r\n <section class=\"action-list\">\r\n <div (click)=\"onHistoryClicked(row)\" *ngIf=\"config?.enableHistoryAction\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\r\n <path\r\n d=\"M504 255.531c.253 136.64-111.18 248.372-247.82 248.468-59.015.042-113.223-20.53-155.822-54.911-11.077-8.94-11.905-25.541-1.839-35.607l11.267-11.267c8.609-8.609 22.353-9.551 31.891-1.984C173.062 425.135 212.781 440 256 440c101.705 0 184-82.311 184-184 0-101.705-82.311-184-184-184-48.814 0-93.149 18.969-126.068 49.932l50.754 50.754c10.08 10.08 2.941 27.314-11.313 27.314H24c-8.837 0-16-7.163-16-16V38.627c0-14.254 17.234-21.393 27.314-11.314l49.372 49.372C129.209 34.136 189.552 8 256 8c136.81 0 247.747 110.78 248 247.531zm-180.912 78.784l9.823-12.63c8.138-10.463 6.253-25.542-4.21-33.679L288 256.349V152c0-13.255-10.745-24-24-24h-16c-13.255 0-24 10.745-24 24v135.651l65.409 50.874c10.463 8.137 25.541 6.253 33.679-4.21z\">\r\n </path>\r\n </svg>\r\n </div>\r\n <div (click)=\"onEditClicked(row)\" *ngIf=\"config?.enableEditAction\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\r\n <path\r\n d=\"M290.74 93.24l128.02 128.02-277.99 277.99-114.14 12.6C11.35 513.54-1.56 500.62.14 485.34l12.7-114.22 277.9-277.88zm207.2-19.06l-60.11-60.11c-18.75-18.75-49.16-18.75-67.91 0l-56.55 56.55 128.02 128.02 56.55-56.55c18.75-18.76 18.75-49.16 0-67.91z\">\r\n </path>\r\n </svg>\r\n </div>\r\n <div (click)=\"onDeleteClicked(row)\" *ngIf=\"config?.enableDeleteAction\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\">\r\n <path\r\n d=\"M0 84V56c0-13.3 10.7-24 24-24h112l9.4-18.7c4-8.2 12.3-13.3 21.4-13.3h114.3c9.1 0 17.4 5.1 21.5 13.3L312 32h112c13.3 0 24 10.7 24 24v28c0 6.6-5.4 12-12 12H12C5.4 96 0 90.6 0 84zm415.2 56.7L394.8 467c-1.6 25.3-22.6 45-47.9 45H101.1c-25.3 0-46.3-19.7-47.9-45L32.8 140.7c-.4-6.9 5.1-12.7 12-12.7h358.5c6.8 0 12.3 5.8 11.9 12.7z\">\r\n </path>\r\n </svg>\r\n </div>\r\n </section>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div *ngIf=\"config?.enableStickyHeader\" class=\"header\">\r\n <table class=\"pcac-table\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let header of headers; let i = index\" class=\"sortable\" [style.width.px]=\"columnWidths[i]\"\r\n (click)=\"sortTable(i)\">\r\n <i [ngClass]=\"header.icon\"></i>\r\n {{header.value}}\r\n </th>\r\n <th [style.width.px]=\"columnWidths[columnWidths.length - 1]\"\r\n *ngIf=\"config?.enableDeleteAction || config?.enableEditAction\"></th>\r\n </tr>\r\n </thead>\r\n </table>\r\n </div>\r\n <div *ngIf=\"config?.enableStickyFooter && config?.data.length > 0\" class=\"footer\" #tableFooter>\r\n <table class=\"pcac-table\">\r\n <tfoot>\r\n <tr>\r\n <td *ngFor=\"let data of config?.data[config?.data.length - 1].data; let i = index\"\r\n [style.width.px]=\"columnWidths[i]\" class=\"sticky-resize\">{{data.value}}</td>\r\n <td [style.width.px]=\"columnWidths[columnWidths.length - 1]\"\r\n *ngIf=\"config?.enableDeleteAction || config?.enableEditAction || config?.enableHistoryAction\">\r\n <section class=\"action-list action-footer\">\r\n <div (click)=\"onHistoryClicked(config?.data[config?.data.length - 1])\" *ngIf=\"config?.enableHistoryAction\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\r\n <path\r\n d=\"M504 255.531c.253 136.64-111.18 248.372-247.82 248.468-59.015.042-113.223-20.53-155.822-54.911-11.077-8.94-11.905-25.541-1.839-35.607l11.267-11.267c8.609-8.609 22.353-9.551 31.891-1.984C173.062 425.135 212.781 440 256 440c101.705 0 184-82.311 184-184 0-101.705-82.311-184-184-184-48.814 0-93.149 18.969-126.068 49.932l50.754 50.754c10.08 10.08 2.941 27.314-11.313 27.314H24c-8.837 0-16-7.163-16-16V38.627c0-14.254 17.234-21.393 27.314-11.314l49.372 49.372C129.209 34.136 189.552 8 256 8c136.81 0 247.747 110.78 248 247.531zm-180.912 78.784l9.823-12.63c8.138-10.463 6.253-25.542-4.21-33.679L288 256.349V152c0-13.255-10.745-24-24-24h-16c-13.255 0-24 10.745-24 24v135.651l65.409 50.874c10.463 8.137 25.541 6.253 33.679-4.21z\">\r\n </path>\r\n </svg>\r\n </div>\r\n <div (click)=\"onEditClicked(config?.data[config?.data.length - 1])\" *ngIf=\"config?.enableEditAction\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\r\n <path\r\n d=\"M290.74 93.24l128.02 128.02-277.99 277.99-114.14 12.6C11.35 513.54-1.56 500.62.14 485.34l12.7-114.22 277.9-277.88zm207.2-19.06l-60.11-60.11c-18.75-18.75-49.16-18.75-67.91 0l-56.55 56.55 128.02 128.02 56.55-56.55c18.75-18.76 18.75-49.16 0-67.91z\">\r\n </path>\r\n </svg>\r\n </div>\r\n <div (click)=\"onDeleteClicked(config?.data[config?.data.length - 1])\" *ngIf=\"config?.enableDeleteAction\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\">\r\n <path\r\n d=\"M0 84V56c0-13.3 10.7-24 24-24h112l9.4-18.7c4-8.2 12.3-13.3 21.4-13.3h114.3c9.1 0 17.4 5.1 21.5 13.3L312 32h112c13.3 0 24 10.7 24 24v28c0 6.6-5.4 12-12 12H12C5.4 96 0 90.6 0 84zm415.2 56.7L394.8 467c-1.6 25.3-22.6 45-47.9 45H101.1c-25.3 0-46.3-19.7-47.9-45L32.8 140.7c-.4-6.9 5.1-12.7 12-12.7h358.5c6.8 0 12.3 5.8 11.9 12.7z\">\r\n </path>\r\n </svg>\r\n </div>\r\n </section>\r\n </td>\r\n </tr>\r\n </tfoot>\r\n </table>\r\n </div>\r\n</section>\r\n",
773
- providers: [
774
- TableSortService
775
- ],
776
- styles: ["pcac-table{position:relative;width:100%;display:block}pcac-table .footer,pcac-table table.pcac-table,pcac-table tbody,pcac-table td,pcac-table tfoot,pcac-table th,pcac-table thead,pcac-table tr .header{box-sizing:border-box}pcac-table table.pcac-table{border-collapse:collapse;width:100%;border-radius:3px;line-height:18px;margin:0}pcac-table table.pcac-table tbody,pcac-table table.pcac-table tfoot,pcac-table table.pcac-table thead{background-color:#fff}pcac-table table.pcac-table caption{padding:.5rem .625rem .625rem;font-weight:700}pcac-table table.pcac-table thead{background:#f8f9fa;color:#24282e}pcac-table table.pcac-table thead i{margin:0 0 -2px;width:10px}pcac-table table.pcac-table tfoot{background:#24282e;color:#fff}pcac-table table.pcac-table tfoot tr,pcac-table table.pcac-table thead tr{background:0 0}pcac-table table.pcac-table tfoot td,pcac-table table.pcac-table tfoot th,pcac-table table.pcac-table thead td,pcac-table table.pcac-table thead th{padding:.5rem .625rem .625rem;font-weight:700;text-align:left}pcac-table table.pcac-table tbody td,pcac-table table.pcac-table tbody th{padding:.5rem .625rem .625rem}pcac-table table.pcac-table tbody tr:nth-child(even){border-bottom:0;background-color:#e9ecef}pcac-table table.pcac-table thead th{cursor:pointer;transition:background-color .25s}pcac-table table.pcac-table thead th:hover{transition:background-color .25s;background-color:#e9ecef}pcac-table .header{position:absolute;top:0}pcac-table .footer{position:absolute;bottom:0}pcac-table .action-list{display:flex;align-items:center;justify-content:flex-end}pcac-table .action-list div{margin-left:.5rem;width:12px}pcac-table .action-list svg path{fill:#adb5bd}pcac-table .action-list svg{cursor:pointer}pcac-table .action-list svg:hover path{transition:.25s;fill:#495057}pcac-table .action-list.action-footer svg path{fill:#e9ecef}pcac-table .action-list.action-footer svg path:hover{fill:#fff}.pcac-table-container{overflow:auto}.pcac-table-container.hide-first-column td:first-child,.pcac-table-container.hide-first-column th:first-child{display:none}"]
777
- }] }
778
- ];
779
- /** @nocollapse */
780
- PcacTableComponent.ctorParameters = () => [
781
- { type: TableSortService },
782
- { type: ChangeDetectorRef }
783
- ];
784
- PcacTableComponent.propDecorators = {
785
- config: [{ type: Input }],
786
- deleteClicked: [{ type: Output }],
787
- editClicked: [{ type: Output }],
788
- historyClicked: [{ type: Output }],
789
- tableBody: [{ type: ViewChild, args: ['tableBody', { static: true },] }],
790
- tableFooter: [{ type: ViewChild, args: ['tableFooter', { static: true },] }],
791
- rows: [{ type: ViewChildren, args: ['rows',] }],
792
- onResize: [{ type: HostListener, args: ['window:resize',] }]
793
- };
794
-
795
- /**
796
- * @fileoverview added by tsickle
797
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
798
- */
799
- class PcacTableModule {
800
- }
801
- PcacTableModule.decorators = [
802
- { type: NgModule, args: [{
803
- imports: [
804
- BrowserModule
805
- ],
806
- exports: [
807
- PcacTableComponent
808
- ],
809
- declarations: [
810
- PcacTableComponent
811
- ]
812
- },] }
813
- ];
814
-
815
- /**
816
- * @fileoverview added by tsickle
817
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
818
- */
819
-
820
- /**
821
- * @fileoverview added by tsickle
822
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
823
- */
824
-
825
- /**
826
- * @fileoverview added by tsickle
827
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
828
- */
829
- class BarVerticalChartBuilder extends PcacChart {
830
- /**
831
- * @param {?} axisBuilder
832
- * @param {?} gridBuilder
833
- * @param {?} transitionService
834
- * @param {?} tooltipBuilder
835
- * @param {?} colorService
836
- */
837
- constructor(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService) {
838
- super(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService);
839
- this.axisBuilder = axisBuilder;
840
- this.gridBuilder = gridBuilder;
841
- this.transitionService = transitionService;
842
- this.tooltipBuilder = tooltipBuilder;
843
- this.colorService = colorService;
844
- this.barClickedSource = new Subject();
845
- this.barClicked$ = this.barClickedSource.asObservable();
846
- }
847
- /**
848
- * @param {?} chartElm
849
- * @param {?} config
850
- * @return {?}
851
- */
852
- buildChart(chartElm, config) {
853
- if (config.colorOverride && config.colorOverride.colors) {
854
- this.colors = config.colorOverride.colors;
855
- }
856
- if (config.hideAxis) {
857
- this.adjustForHiddenAxis(config);
858
- }
859
- this.initializeChartState(chartElm, config);
860
- if (config.colorOverride && config.colorOverride.colors) {
861
- this.colors = config.colorOverride.colors.reverse();
862
- }
863
- this.buildScales(config);
864
- this.drawChart(chartElm, config);
865
- }
866
- /**
867
- * @private
868
- * @param {?} config
869
- * @return {?}
870
- */
871
- adjustForHiddenAxis(config) {
872
- /** @type {?} */
873
- const hasGroupLabel = this.hasGroupLabel(config);
874
- config.height = config.height + this.margin.top;
875
- if (!hasGroupLabel) {
876
- config.height = config.height + this.margin.bottom;
877
- }
878
- this.margin.top = 0;
879
- this.margin.bottom = hasGroupLabel ? this.margin.bottom : 0;
880
- this.margin.left = 0;
881
- this.margin.right = 0;
882
- }
883
- /**
884
- * @private
885
- * @param {?} config
886
- * @return {?}
887
- */
888
- hasGroupLabel(config) {
889
- /** @type {?} */
890
- let hasGroupLabel = false;
891
- config.data.forEach((/**
892
- * @param {?} node
893
- * @return {?}
894
- */
895
- node => {
896
- if (node.key) {
897
- hasGroupLabel = true;
898
- }
899
- }));
900
- return hasGroupLabel;
901
- }
902
- /**
903
- * @private
904
- * @param {?} config
905
- * @return {?}
906
- */
907
- buildScales(config) {
908
- this.yScale = scaleLinear()
909
- .rangeRound([0, config.height])
910
- .domain([config.domainMax, 0]);
911
- this.xScaleStacked = scaleBand()
912
- .domain(config.data.map((/**
913
- * @param {?} d
914
- * @return {?}
915
- */
916
- (d) => (/** @type {?} */ (d.key)))))
917
- .rangeRound([0, this.width])
918
- .padding(0.1);
919
- this.xScaleGrouped = scaleBand()
920
- .padding(0.2)
921
- .rangeRound([0, this.xScaleStacked.bandwidth()])
922
- .domain(config.data[0].data.map((/**
923
- * @param {?} d
924
- * @return {?}
925
- */
926
- (d) => (/** @type {?} */ (d.key)))));
927
- }
928
- /**
929
- * @private
930
- * @param {?} chartElm
931
- * @param {?} config
932
- * @return {?}
933
- */
934
- drawChart(chartElm, config) {
935
- this.buildContainer(chartElm);
936
- this.axisBuilder.drawAxis({
937
- svg: this.svg,
938
- numberOfTicks: config.numberOfTicks || 5,
939
- height: this.height,
940
- xScale: this.xScaleStacked,
941
- yScale: this.yScale,
942
- xFormat: PcacTickFormatEnum.None,
943
- yFormat: config.tickFormat || PcacTickFormatEnum.None,
944
- hideYAxis: config.hideAxis
945
- });
946
- if (!config.hideGrid) {
947
- this.gridBuilder.drawHorizontalGrid({
948
- svg: this.svg,
949
- numberOfTicks: config.numberOfTicks || 5,
950
- width: this.width,
951
- xScale: this.xScaleStacked,
952
- yScale: this.yScale
953
- });
954
- }
955
- this.addGroups(config);
956
- }
957
- /**
958
- * @private
959
- * @param {?} config
960
- * @return {?}
961
- */
962
- addGroups(config) {
963
- /** @type {?} */
964
- const groupsContainer = this.svg.append('g')
965
- .attr('class', 'pcac-bars')
966
- .selectAll('g')
967
- .data(config.data)
968
- .enter().append('g')
969
- .attr('class', 'pcac-bar-group')
970
- .attr('data-group-id', (/**
971
- * @param {?} d
972
- * @param {?} i
973
- * @return {?}
974
- */
975
- (d, i) => {
976
- return i;
977
- }))
978
- .attr('transform', (/**
979
- * @param {?} d
980
- * @param {?} i
981
- * @return {?}
982
- */
983
- (d, i) => {
984
- return 'translate(' + this.xScaleStacked((/** @type {?} */ (d.key))) + ',0)';
985
- }));
986
- /** @type {?} */
987
- const group = groupsContainer.selectAll('rect')
988
- .data((/**
989
- * @param {?} d
990
- * @param {?} i
991
- * @return {?}
992
- */
993
- (d, i) => {
994
- return d.data;
995
- }));
996
- this.drawBarsPerGroup(group, config);
997
- // We have no thresholds to draw
998
- if (!config.thresholds) {
999
- return;
1000
- }
1001
- // Draw threshold across entire chart
1002
- if (config.thresholds.length === 1 && !config.thresholds[0].data) {
1003
- this.drawThresholdAcrossChart(config);
1004
- }
1005
- // Draw threshold across each group
1006
- if (config.thresholds.length > 1 && (!config.thresholds[0].data || config.isStacked)) {
1007
- this.drawThresholdsPerGroup(group, config);
1008
- }
1009
- // Draw threshold across each bar in group
1010
- if (config.thresholds.length > 1 && config.thresholds[0].data && !config.isStacked) {
1011
- this.drawThresholdsPerBarInGroup(group, config);
1012
- }
1013
- }
1014
- /**
1015
- * @private
1016
- * @param {?} group
1017
- * @param {?} config
1018
- * @return {?}
1019
- */
1020
- drawBarsPerGroup(group, config) {
1021
- /** @type {?} */
1022
- const self = this;
1023
- group.enter().append('rect')
1024
- .attr('class', 'pcac-bar')
1025
- .attr('x', (/**
1026
- * @param {?} d
1027
- * @param {?} i
1028
- * @return {?}
1029
- */
1030
- (d, i) => {
1031
- return !config.isStacked ? this.xScaleGrouped((/** @type {?} */ (d.key))) : this.xScaleStacked((/** @type {?} */ (d.key)));
1032
- }))
1033
- .style('fill', (/**
1034
- * @param {?} d
1035
- * @param {?} i
1036
- * @param {?} n
1037
- * @return {?}
1038
- */
1039
- (d, i, n) => {
1040
- if (config.spreadColorsPerGroup) {
1041
- /** @type {?} */
1042
- const groupIndex = parseInt(n[0].parentNode.getAttribute('data-group-id'), 10);
1043
- return this.colors[groupIndex];
1044
- }
1045
- return this.colors[i];
1046
- }))
1047
- .attr('y', (/**
1048
- * @return {?}
1049
- */
1050
- () => {
1051
- return this.height;
1052
- }))
1053
- .attr('height', 0)
1054
- .on('mouseover', (/**
1055
- * @param {?} d
1056
- * @param {?} i
1057
- * @param {?} n
1058
- * @return {?}
1059
- */
1060
- function (d, i, n) {
1061
- select(this).transition(transition()
1062
- .duration(self.transitionService.getTransitionDuration() / 5))
1063
- .style('fill', (/**
1064
- * @return {?}
1065
- */
1066
- () => {
1067
- if (config.spreadColorsPerGroup) {
1068
- /** @type {?} */
1069
- const groupIndex = parseInt(n[0].parentNode.getAttribute('data-group-id'), 10);
1070
- return color(self.colors[groupIndex]).darker(1).toString();
1071
- }
1072
- return color(self.colors[i]).darker(1).toString();
1073
- }));
1074
- }))
1075
- .on('mousemove', (/**
1076
- * @param {?} d
1077
- * @param {?} i
1078
- * @return {?}
1079
- */
1080
- function (d, i) {
1081
- self.tooltipBuilder.showBarTooltip(d, config.tickFormat || PcacTickFormatEnum.None);
1082
- }))
1083
- .on('mouseout', (/**
1084
- * @param {?} d
1085
- * @param {?} i
1086
- * @param {?} n
1087
- * @return {?}
1088
- */
1089
- function (d, i, n) {
1090
- self.tooltipBuilder.hideTooltip();
1091
- select(this).transition(transition()
1092
- .duration(self.transitionService.getTransitionDuration() / 5))
1093
- .style('fill', (/**
1094
- * @return {?}
1095
- */
1096
- () => {
1097
- if (config.spreadColorsPerGroup) {
1098
- /** @type {?} */
1099
- const groupIndex = parseInt(n[0].parentNode.getAttribute('data-group-id'), 10);
1100
- return self.colors[groupIndex];
1101
- }
1102
- return self.colors[i];
1103
- }));
1104
- }))
1105
- .on('click', (/**
1106
- * @param {?} d
1107
- * @param {?} i
1108
- * @return {?}
1109
- */
1110
- (d, i) => {
1111
- this.barClickedSource.next(d);
1112
- }))
1113
- .transition(transition()
1114
- .duration(this.transitionService.getTransitionDuration()))
1115
- .attr('width', !config.isStacked ? this.xScaleGrouped.bandwidth() : this.xScaleStacked.bandwidth())
1116
- .attr('y', (/**
1117
- * @param {?} d
1118
- * @return {?}
1119
- */
1120
- (d) => {
1121
- return this.yScale((/** @type {?} */ (d.value)));
1122
- }))
1123
- .attr('height', (/**
1124
- * @param {?} d
1125
- * @return {?}
1126
- */
1127
- (d) => {
1128
- return this.height - this.yScale((/** @type {?} */ (d.value)));
1129
- }));
1130
- }
1131
- /**
1132
- * @private
1133
- * @param {?} config
1134
- * @return {?}
1135
- */
1136
- drawThresholdAcrossChart(config) {
1137
- this.applyPreTransitionThresholdStyles(this.svg.select('.pcac-bars').append('rect'), config)
1138
- .attr('width', this.width)
1139
- .on('mousemove', (/**
1140
- * @param {?} d
1141
- * @param {?} i
1142
- * @return {?}
1143
- */
1144
- (d, i) => {
1145
- this.tooltipBuilder.showBarTooltip(config.thresholds[i], config.tickFormat || PcacTickFormatEnum.None);
1146
- }))
1147
- .transition(transition()
1148
- .duration(this.transitionService.getTransitionDuration()))
1149
- .attr('y', (/**
1150
- * @param {?} d
1151
- * @param {?} i
1152
- * @return {?}
1153
- */
1154
- (d, i) => {
1155
- return this.yScale((/** @type {?} */ (config.thresholds[i].value)));
1156
- }));
1157
- }
1158
- /**
1159
- * @private
1160
- * @param {?} group
1161
- * @param {?} config
1162
- * @return {?}
1163
- */
1164
- drawThresholdsPerGroup(group, config) {
1165
- this.applyPreTransitionThresholdStyles(this.svg.selectAll('.pcac-bar-group').append('rect'), config)
1166
- .attr('width', this.xScaleStacked.bandwidth())
1167
- .on('mousemove', (/**
1168
- * @param {?} d
1169
- * @param {?} i
1170
- * @return {?}
1171
- */
1172
- (d, i) => {
1173
- this.tooltipBuilder.showBarTooltip(config.isStacked ?
1174
- config.thresholds[i].data[0] :
1175
- config.thresholds[i], config.tickFormat || PcacTickFormatEnum.None);
1176
- }))
1177
- .transition(transition()
1178
- .duration(this.transitionService.getTransitionDuration()))
1179
- .attr('y', (/**
1180
- * @param {?} d
1181
- * @param {?} i
1182
- * @return {?}
1183
- */
1184
- (d, i) => {
1185
- return this.yScale(config.isStacked ? (/** @type {?} */ (config.thresholds[i].data[0].value)) : (/** @type {?} */ (config.thresholds[i].value)));
1186
- }));
1187
- }
1188
- /**
1189
- * @private
1190
- * @param {?} group
1191
- * @param {?} config
1192
- * @return {?}
1193
- */
1194
- drawThresholdsPerBarInGroup(group, config) {
1195
- this.applyPreTransitionThresholdStyles(group.enter().append('rect'), config)
1196
- .on('mousemove', (/**
1197
- * @param {?} d
1198
- * @param {?} i
1199
- * @param {?} n
1200
- * @return {?}
1201
- */
1202
- (d, i, n) => {
1203
- this.tooltipBuilder.showBarTooltip(config.thresholds[n[0].parentElement.dataset['groupId']].data[i], config.tickFormat || PcacTickFormatEnum.None);
1204
- }))
1205
- .attr('width', this.xScaleGrouped.bandwidth())
1206
- .transition(transition()
1207
- .duration(this.transitionService.getTransitionDuration()))
1208
- .attr('y', (/**
1209
- * @param {?} d
1210
- * @param {?} i
1211
- * @param {?} n
1212
- * @return {?}
1213
- */
1214
- (d, i, n) => {
1215
- return this.yScale((/** @type {?} */ (config.thresholds[n[0].parentElement.dataset['groupId']].data[i].value)));
1216
- }));
1217
- }
1218
- /**
1219
- * @private
1220
- * @param {?} elm
1221
- * @param {?} config
1222
- * @return {?}
1223
- */
1224
- applyPreTransitionThresholdStyles(elm, config) {
1225
- return elm.attr('class', 'pcac-threshold')
1226
- .attr('x', (/**
1227
- * @param {?} d
1228
- * @return {?}
1229
- */
1230
- (d) => {
1231
- return this.xScaleGrouped(d ? (/** @type {?} */ (d.key)) : '');
1232
- }))
1233
- .attr('y', (/**
1234
- * @return {?}
1235
- */
1236
- () => {
1237
- return this.height;
1238
- }))
1239
- .attr('height', 0)
1240
- .style('fill', (/**
1241
- * @return {?}
1242
- */
1243
- () => {
1244
- return this.colorService.getAlert();
1245
- }))
1246
- .style('stroke', (/**
1247
- * @return {?}
1248
- */
1249
- () => {
1250
- return this.colorService.getAlert();
1251
- }))
1252
- .style('stroke-width', (/**
1253
- * @return {?}
1254
- */
1255
- () => {
1256
- return 2;
1257
- }))
1258
- .on('mouseout', (/**
1259
- * @return {?}
1260
- */
1261
- () => {
1262
- this.tooltipBuilder.hideTooltip();
1263
- }))
1264
- .attr('height', (/**
1265
- * @return {?}
1266
- */
1267
- () => {
1268
- return '3px';
1269
- }));
1270
- }
1271
- }
1272
- BarVerticalChartBuilder.decorators = [
1273
- { type: Injectable }
1274
- ];
1275
- /** @nocollapse */
1276
- BarVerticalChartBuilder.ctorParameters = () => [
1277
- { type: PcacAxisBuilder },
1278
- { type: PcacGridBuilder },
1279
- { type: PcacTransitionService },
1280
- { type: PcacTooltipBuilder },
1281
- { type: PcacColorService }
1282
- ];
1283
-
1284
- /**
1285
- * @fileoverview added by tsickle
1286
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1287
- */
1288
- class PcacBarVerticalChartComponent {
1289
- /**
1290
- * @param {?} chartBuilder
1291
- */
1292
- constructor(chartBuilder) {
1293
- this.chartBuilder = chartBuilder;
1294
- this.barClicked = new EventEmitter();
1295
- this.chartBuilder.barClicked$.subscribe((/**
1296
- * @param {?} data
1297
- * @return {?}
1298
- */
1299
- data => {
1300
- this.barClicked.emit(data);
1301
- }));
1302
- }
1303
- /**
1304
- * @return {?}
1305
- */
1306
- ngOnChanges() {
1307
- this.buildChart();
1308
- }
1309
- /**
1310
- * @return {?}
1311
- */
1312
- buildChart() {
1313
- if (this.config && this.config.data && this.config.data.length > 0) {
1314
- this.chartBuilder.buildChart(this.chartElm, this.config);
1315
- }
1316
- }
1317
- /**
1318
- * Opting against fromEvent due to incompatibility with rxjs 5 => 6
1319
- * @return {?}
1320
- */
1321
- onResize() {
1322
- /** @type {?} */
1323
- const self = this;
1324
- clearTimeout(this.resizeWindowTimeout);
1325
- this.resizeWindowTimeout = setTimeout((/**
1326
- * @return {?}
1327
- */
1328
- () => {
1329
- self.buildChart();
1330
- }), 300);
1331
- }
1332
- }
1333
- PcacBarVerticalChartComponent.decorators = [
1334
- { type: Component, args: [{
1335
- selector: 'pcac-bar-vertical-chart',
1336
- template: "<section class=\"pcac-bar-vertical-chart\">\r\n <svg #chart></svg>\r\n</section>\r\n",
1337
- providers: [
1338
- BarVerticalChartBuilder
1339
- ]
1340
- }] }
1341
- ];
1342
- /** @nocollapse */
1343
- PcacBarVerticalChartComponent.ctorParameters = () => [
1344
- { type: BarVerticalChartBuilder }
1345
- ];
1346
- PcacBarVerticalChartComponent.propDecorators = {
1347
- config: [{ type: Input }],
1348
- chartElm: [{ type: ViewChild, args: ['chart', { static: true },] }],
1349
- barClicked: [{ type: Output }],
1350
- onResize: [{ type: HostListener, args: ['window:resize',] }]
1351
- };
1352
-
1353
- /**
1354
- * @fileoverview added by tsickle
1355
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1356
- */
1357
-
1358
- /**
1359
- * @fileoverview added by tsickle
1360
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1361
- */
1362
- class PcacBarVerticalChartModule {
1363
- }
1364
- PcacBarVerticalChartModule.decorators = [
1365
- { type: NgModule, args: [{
1366
- exports: [
1367
- PcacBarVerticalChartComponent
1368
- ],
1369
- declarations: [
1370
- PcacBarVerticalChartComponent
1371
- ]
1372
- },] }
1373
- ];
1374
-
1375
- /**
1376
- * @fileoverview added by tsickle
1377
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1378
- */
1379
-
1380
- /**
1381
- * @fileoverview added by tsickle
1382
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1383
- */
1384
-
1385
- /**
1386
- * @fileoverview added by tsickle
1387
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1388
- */
1389
- class BarHorizontalChartBuilder extends PcacChart {
1390
- /**
1391
- * @param {?} axisBuilder
1392
- * @param {?} gridBuilder
1393
- * @param {?} transitionService
1394
- * @param {?} tooltipBuilder
1395
- * @param {?} colorService
1396
- */
1397
- constructor(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService) {
1398
- super(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService);
1399
- this.axisBuilder = axisBuilder;
1400
- this.gridBuilder = gridBuilder;
1401
- this.transitionService = transitionService;
1402
- this.tooltipBuilder = tooltipBuilder;
1403
- this.colorService = colorService;
1404
- this.barClickedSource = new Subject();
1405
- this.barClicked$ = this.barClickedSource.asObservable();
1406
- }
1407
- /**
1408
- * @param {?} chartElm
1409
- * @param {?} config
1410
- * @return {?}
1411
- */
1412
- buildChart(chartElm, config) {
1413
- this.config = JSON.parse(JSON.stringify(config));
1414
- if (this.config.hideAxis) {
1415
- this.adjustForHiddenAxis();
1416
- }
1417
- this.initializeChartState(chartElm, this.config);
1418
- if (config.colorOverride && config.colorOverride.colors) {
1419
- this.colors = config.colorOverride.colors.reverse();
1420
- }
1421
- this.buildScales(chartElm, this.config);
1422
- this.drawChart(chartElm, this.config);
1423
- }
1424
- /**
1425
- * @private
1426
- * @return {?}
1427
- */
1428
- adjustForHiddenAxis() {
1429
- if (!this.cachedMargins) {
1430
- this.cachedMargins = JSON.parse(JSON.stringify(this.margin));
1431
- }
1432
- this.margin = JSON.parse(JSON.stringify(this.cachedMargins));
1433
- this.config.height = this.config.height + this.margin.top + this.margin.bottom;
1434
- this.margin.top = 0;
1435
- this.margin.bottom = 0;
1436
- this.margin.left = 0;
1437
- this.margin.right = 0;
1438
- }
1439
- /**
1440
- * @private
1441
- * @param {?} data
1442
- * @return {?}
1443
- */
1444
- setStartState(data) {
1445
- if (data && data.data) {
1446
- for (let i = 0, l = data.data.length; i < l; ++i) {
1447
- data.data[i].value = 0;
1448
- this.setStartState(data.data[i]);
1449
- }
1450
- }
1451
- }
1452
- /**
1453
- * @private
1454
- * @param {?} chartElm
1455
- * @param {?} config
1456
- * @return {?}
1457
- */
1458
- buildScales(chartElm, config) {
1459
- config.data[0].data.map((/**
1460
- * @param {?} d
1461
- * @return {?}
1462
- */
1463
- (d) => {
1464
- return d.value;
1465
- }));
1466
- this.xScale = scaleLinear()
1467
- .domain([0, config.domainMax]);
1468
- this.yScaleStacked = scaleBand()
1469
- .domain(config.data.map((/**
1470
- * @param {?} d
1471
- * @return {?}
1472
- */
1473
- (d) => (/** @type {?} */ (d.key)))))
1474
- .range([this.height, 0])
1475
- .padding(0.1);
1476
- this.yScaleGrouped = scaleBand()
1477
- .padding(0.05)
1478
- .rangeRound([0, this.yScaleStacked.bandwidth()])
1479
- .domain(config.data[0].data.map((/**
1480
- * @param {?} d
1481
- * @return {?}
1482
- */
1483
- (d) => (/** @type {?} */ (d.key)))));
1484
- this.setHorizontalMarginsBasedOnContent(chartElm, config.data, this.yScaleStacked);
1485
- this.xScale.range([0, this.width]);
1486
- }
1487
- /**
1488
- * @private
1489
- * @param {?} chartElm
1490
- * @param {?} config
1491
- * @return {?}
1492
- */
1493
- drawChart(chartElm, config) {
1494
- this.buildContainer(chartElm);
1495
- this.axisBuilder.drawAxis({
1496
- svg: this.svg,
1497
- numberOfTicks: config.numberOfTicks || 5,
1498
- height: this.height,
1499
- xScale: this.xScale,
1500
- yScale: this.yScaleStacked,
1501
- xFormat: config.tickFormat || PcacTickFormatEnum.None,
1502
- yFormat: PcacTickFormatEnum.None,
1503
- hideXAxis: config.hideAxis
1504
- });
1505
- if (!config.hideGrid) {
1506
- this.gridBuilder.drawVerticalGrid({
1507
- svg: this.svg,
1508
- numberOfTicks: config.numberOfTicks || 5,
1509
- height: this.height,
1510
- xScale: this.xScale,
1511
- yScale: this.yScaleStacked
1512
- });
1513
- }
1514
- this.addGroups(config);
1515
- }
1516
- /**
1517
- * @private
1518
- * @param {?} config
1519
- * @return {?}
1520
- */
1521
- addGroups(config) {
1522
- /** @type {?} */
1523
- const groupsContainer = this.svg.append('g')
1524
- .attr('class', 'pcac-bars')
1525
- .selectAll('g')
1526
- .data(config.data)
1527
- .enter().append('g')
1528
- .attr('class', 'pcac-bar-group')
1529
- .attr('data-group-id', (/**
1530
- * @param {?} d
1531
- * @param {?} i
1532
- * @return {?}
1533
- */
1534
- (d, i) => {
1535
- return i;
1536
- }))
1537
- .attr('transform', (/**
1538
- * @param {?} d
1539
- * @return {?}
1540
- */
1541
- (d) => 'translate(0,' + this.yScaleStacked((/** @type {?} */ (d.key))) + ')'));
1542
- /** @type {?} */
1543
- const group = groupsContainer.selectAll('rect')
1544
- .data((/**
1545
- * @param {?} d
1546
- * @return {?}
1547
- */
1548
- (d) => {
1549
- return d.data;
1550
- }));
1551
- this.drawBarsPerGroup(group, config);
1552
- // We have no thresholds to draw
1553
- if (!config.thresholds) {
1554
- return;
1555
- }
1556
- // Draw threshold across entire chart
1557
- if (config.thresholds.length === 1 && !config.thresholds[0].data) {
1558
- this.drawThresholdAcrossChart(config);
1559
- }
1560
- // Draw threshold across each group
1561
- if (config.thresholds.length > 1 && (!config.thresholds[0].data || config.isStacked)) {
1562
- this.drawThresholdsPerGroup(group, config);
1563
- }
1564
- // Draw threshold across each bar in group
1565
- if (config.thresholds.length > 1 && config.thresholds[0].data && !config.isStacked) {
1566
- this.drawThresholdsPerBarInGroup(group, config);
1567
- }
1568
- }
1569
- /**
1570
- * @private
1571
- * @param {?} groups
1572
- * @param {?} config
1573
- * @return {?}
1574
- */
1575
- drawBarsPerGroup(groups, config) {
1576
- /** @type {?} */
1577
- const self = this;
1578
- groups.enter().append('rect')
1579
- .attr('class', 'pcac-bar')
1580
- .attr('x', 0)
1581
- .attr('y', (/**
1582
- * @param {?} d
1583
- * @return {?}
1584
- */
1585
- (d) => {
1586
- return !config.isStacked ? this.yScaleGrouped((/** @type {?} */ (d.key))) : this.yScaleStacked((/** @type {?} */ (d.key)));
1587
- }))
1588
- .attr('height', !config.isStacked ? this.yScaleGrouped.bandwidth() : this.yScaleStacked.bandwidth())
1589
- .style('fill', (/**
1590
- * @param {?} d
1591
- * @param {?} i
1592
- * @param {?} n
1593
- * @return {?}
1594
- */
1595
- (d, i, n) => {
1596
- if (config.spreadColorsPerGroup) {
1597
- /** @type {?} */
1598
- const groupIndex = parseInt(n[0].parentNode.getAttribute('data-group-id'), 10);
1599
- return this.colors[groupIndex];
1600
- }
1601
- return this.colors[i];
1602
- }))
1603
- .attr('width', 0)
1604
- .on('mouseover', (/**
1605
- * @param {?} d
1606
- * @param {?} i
1607
- * @param {?} n
1608
- * @return {?}
1609
- */
1610
- function (d, i, n) {
1611
- select(this).transition(transition()
1612
- .duration(self.transitionService.getTransitionDuration() / 7.5))
1613
- .style('fill', (/**
1614
- * @return {?}
1615
- */
1616
- () => {
1617
- if (config.spreadColorsPerGroup) {
1618
- /** @type {?} */
1619
- const groupIndex = parseInt(n[0].parentNode.getAttribute('data-group-id'), 10);
1620
- return color(self.colors[groupIndex]).darker(1).toString();
1621
- }
1622
- return color(self.colors[i]).darker(1).toString();
1623
- }));
1624
- }))
1625
- .on('mousemove', (/**
1626
- * @param {?} d
1627
- * @param {?} i
1628
- * @return {?}
1629
- */
1630
- function (d, i) {
1631
- self.tooltipBuilder.showBarTooltip(d, config.tickFormat || PcacTickFormatEnum.None);
1632
- }))
1633
- .on('mouseout', (/**
1634
- * @param {?} d
1635
- * @param {?} i
1636
- * @param {?} n
1637
- * @return {?}
1638
- */
1639
- function (d, i, n) {
1640
- self.tooltipBuilder.hideTooltip();
1641
- select(this).transition(transition()
1642
- .duration(self.transitionService.getTransitionDuration() / 5))
1643
- .style('fill', (/**
1644
- * @return {?}
1645
- */
1646
- () => {
1647
- if (config.spreadColorsPerGroup) {
1648
- /** @type {?} */
1649
- const groupIndex = parseInt(n[0].parentNode.getAttribute('data-group-id'), 10);
1650
- return self.colors[groupIndex];
1651
- }
1652
- return self.colors[i];
1653
- }));
1654
- }))
1655
- .on('click', (/**
1656
- * @param {?} d
1657
- * @param {?} i
1658
- * @return {?}
1659
- */
1660
- (d, i) => {
1661
- this.barClickedSource.next(d);
1662
- }))
1663
- .transition(transition()
1664
- .duration(this.transitionService.getTransitionDuration()))
1665
- .attr('width', (/**
1666
- * @param {?} d
1667
- * @return {?}
1668
- */
1669
- (d) => {
1670
- return this.xScale((/** @type {?} */ (d.value)));
1671
- }));
1672
- }
1673
- /**
1674
- * @private
1675
- * @param {?} config
1676
- * @return {?}
1677
- */
1678
- drawThresholdAcrossChart(config) {
1679
- this.applyPreTransitionThresholdStyles(this.svg.select('.pcac-bars').append('rect'), config)
1680
- .attr('height', this.height)
1681
- .on('mousemove', (/**
1682
- * @param {?} d
1683
- * @param {?} i
1684
- * @return {?}
1685
- */
1686
- (d, i) => {
1687
- this.tooltipBuilder.showBarTooltip(config.thresholds[i], config.tickFormat || PcacTickFormatEnum.None);
1688
- }))
1689
- .transition(transition()
1690
- .duration(this.transitionService.getTransitionDuration()))
1691
- .attr('x', (/**
1692
- * @param {?} d
1693
- * @param {?} i
1694
- * @return {?}
1695
- */
1696
- (d, i) => {
1697
- return this.xScale((/** @type {?} */ (config.thresholds[i].value)));
1698
- }));
1699
- }
1700
- /**
1701
- * @private
1702
- * @param {?} group
1703
- * @param {?} config
1704
- * @return {?}
1705
- */
1706
- drawThresholdsPerGroup(group, config) {
1707
- this.applyPreTransitionThresholdStyles(this.svg.selectAll('.pcac-bar-group').append('rect'), config)
1708
- .attr('height', this.yScaleStacked.bandwidth())
1709
- .on('mousemove', (/**
1710
- * @param {?} d
1711
- * @param {?} i
1712
- * @return {?}
1713
- */
1714
- (d, i) => {
1715
- this.tooltipBuilder.showBarTooltip(config.isStacked ?
1716
- config.thresholds[i].data[0] :
1717
- config.thresholds[i], config.tickFormat || PcacTickFormatEnum.None);
1718
- }))
1719
- .transition(transition()
1720
- .duration(this.transitionService.getTransitionDuration()))
1721
- .attr('x', (/**
1722
- * @param {?} d
1723
- * @param {?} i
1724
- * @return {?}
1725
- */
1726
- (d, i) => {
1727
- return this.xScale(config.isStacked ? (/** @type {?} */ (config.thresholds[i].data[0].value)) : (/** @type {?} */ (config.thresholds[i].value)));
1728
- }));
1729
- }
1730
- /**
1731
- * @private
1732
- * @param {?} group
1733
- * @param {?} config
1734
- * @return {?}
1735
- */
1736
- drawThresholdsPerBarInGroup(group, config) {
1737
- this.applyPreTransitionThresholdStyles(group.enter().append('rect'), config)
1738
- .attr('height', this.yScaleGrouped.bandwidth())
1739
- .on('mousemove', (/**
1740
- * @param {?} d
1741
- * @param {?} i
1742
- * @param {?} n
1743
- * @return {?}
1744
- */
1745
- (d, i, n) => {
1746
- this.tooltipBuilder.showBarTooltip(config.thresholds[n[0].parentElement.dataset['groupId']].data[i], config.tickFormat || PcacTickFormatEnum.None);
1747
- }))
1748
- .transition(transition()
1749
- .duration(this.transitionService.getTransitionDuration()))
1750
- .attr('y', (/**
1751
- * @param {?} d
1752
- * @return {?}
1753
- */
1754
- (d) => {
1755
- return this.yScaleGrouped((/** @type {?} */ (d.key)));
1756
- }))
1757
- .attr('x', (/**
1758
- * @param {?} d
1759
- * @param {?} i
1760
- * @param {?} n
1761
- * @return {?}
1762
- */
1763
- (d, i, n) => {
1764
- return this.xScale((/** @type {?} */ (config.thresholds[n[0].parentElement.dataset['groupId']].data[i].value)));
1765
- }));
1766
- }
1767
- /**
1768
- * @private
1769
- * @param {?} elm
1770
- * @param {?} config
1771
- * @return {?}
1772
- */
1773
- applyPreTransitionThresholdStyles(elm, config) {
1774
- return elm.attr('class', 'pcac-threshold')
1775
- .style('fill', (/**
1776
- * @return {?}
1777
- */
1778
- () => {
1779
- return this.colorService.getAlert();
1780
- }))
1781
- .style('stroke', (/**
1782
- * @return {?}
1783
- */
1784
- () => {
1785
- return this.colorService.getAlert();
1786
- }))
1787
- .style('stroke-width', (/**
1788
- * @return {?}
1789
- */
1790
- () => {
1791
- return 2;
1792
- }))
1793
- .attr('width', '3px')
1794
- .on('mouseout', (/**
1795
- * @return {?}
1796
- */
1797
- () => {
1798
- this.tooltipBuilder.hideTooltip();
1799
- }));
1800
- }
1801
- }
1802
- BarHorizontalChartBuilder.decorators = [
1803
- { type: Injectable }
1804
- ];
1805
- /** @nocollapse */
1806
- BarHorizontalChartBuilder.ctorParameters = () => [
1807
- { type: PcacAxisBuilder },
1808
- { type: PcacGridBuilder },
1809
- { type: PcacTransitionService },
1810
- { type: PcacTooltipBuilder },
1811
- { type: PcacColorService }
1812
- ];
1813
-
1814
- /**
1815
- * @fileoverview added by tsickle
1816
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1817
- */
1818
- class PcacBarChartHorizontalComponent {
1819
- /**
1820
- * @param {?} chartBuilder
1821
- */
1822
- constructor(chartBuilder) {
1823
- this.chartBuilder = chartBuilder;
1824
- this.barClicked = new EventEmitter();
1825
- this.chartBuilder.barClicked$.subscribe((/**
1826
- * @param {?} data
1827
- * @return {?}
1828
- */
1829
- data => {
1830
- this.barClicked.emit(data);
1831
- }));
1832
- }
1833
- /**
1834
- * @return {?}
1835
- */
1836
- ngOnChanges() {
1837
- this.buildChart();
1838
- }
1839
- /**
1840
- * @return {?}
1841
- */
1842
- buildChart() {
1843
- if (this.config && this.config.data && this.config.data.length > 0) {
1844
- this.chartBuilder.buildChart(this.chartElm, this.config);
1845
- }
1846
- }
1847
- /**
1848
- * Opting against fromEvent due to incompatibility with rxjs 5 => 6
1849
- * @return {?}
1850
- */
1851
- onResize() {
1852
- /** @type {?} */
1853
- const self = this;
1854
- clearTimeout(this.resizeWindowTimeout);
1855
- this.resizeWindowTimeout = setTimeout((/**
1856
- * @return {?}
1857
- */
1858
- () => {
1859
- self.buildChart();
1860
- }), 300);
1861
- }
1862
- }
1863
- PcacBarChartHorizontalComponent.decorators = [
1864
- { type: Component, args: [{
1865
- selector: 'pcac-bar-horizontal-chart',
1866
- template: "<section class=\"pcac-bar-horizontal-chart\">\r\n <svg #chart></svg>\r\n</section>\r\n",
1867
- providers: [
1868
- BarHorizontalChartBuilder
1869
- ]
1870
- }] }
1871
- ];
1872
- /** @nocollapse */
1873
- PcacBarChartHorizontalComponent.ctorParameters = () => [
1874
- { type: BarHorizontalChartBuilder }
1875
- ];
1876
- PcacBarChartHorizontalComponent.propDecorators = {
1877
- config: [{ type: Input }],
1878
- chartElm: [{ type: ViewChild, args: ['chart', { static: true },] }],
1879
- barClicked: [{ type: Output }],
1880
- onResize: [{ type: HostListener, args: ['window:resize',] }]
1881
- };
1882
-
1883
- /**
1884
- * @fileoverview added by tsickle
1885
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1886
- */
1887
-
1888
- /**
1889
- * @fileoverview added by tsickle
1890
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1891
- */
1892
- class PcacBarHorizontalChartModule {
1893
- }
1894
- PcacBarHorizontalChartModule.decorators = [
1895
- { type: NgModule, args: [{
1896
- exports: [
1897
- PcacBarChartHorizontalComponent
1898
- ],
1899
- declarations: [
1900
- PcacBarChartHorizontalComponent
1901
- ]
1902
- },] }
1903
- ];
1904
-
1905
- /**
1906
- * @fileoverview added by tsickle
1907
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1908
- */
1909
-
1910
- /**
1911
- * @fileoverview added by tsickle
1912
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1913
- */
1914
-
1915
- /**
1916
- * @fileoverview added by tsickle
1917
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1918
- */
1919
- class PieChartBuilder extends PcacChart {
1920
- /**
1921
- * @param {?} axisBuilder
1922
- * @param {?} gridBuilder
1923
- * @param {?} transitionService
1924
- * @param {?} tooltipBuilder
1925
- * @param {?} colorService
1926
- */
1927
- constructor(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService) {
1928
- super(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService);
1929
- this.axisBuilder = axisBuilder;
1930
- this.gridBuilder = gridBuilder;
1931
- this.transitionService = transitionService;
1932
- this.tooltipBuilder = tooltipBuilder;
1933
- this.colorService = colorService;
1934
- this.sliceClickedSource = new Subject();
1935
- this.sliceClicked$ = this.sliceClickedSource.asObservable();
1936
- }
1937
- /**
1938
- * @param {?} chartElm
1939
- * @param {?} config
1940
- * @return {?}
1941
- */
1942
- buildChart(chartElm, config) {
1943
- this.initializeChartState(chartElm, config);
1944
- this.radius = Math.min(Math.min(this.height, this.width), Math.min(this.height, this.width)) / 2;
1945
- this.buildShapes(config);
1946
- this.drawChart(chartElm, config);
1947
- }
1948
- /**
1949
- * @private
1950
- * @param {?} config
1951
- * @return {?}
1952
- */
1953
- buildShapes(config) {
1954
- /** @type {?} */
1955
- const radiusOffset = 10;
1956
- this.arcShape = arc()
1957
- .innerRadius(0)
1958
- .outerRadius(this.radius - radiusOffset);
1959
- this.arcOverShape = arc()
1960
- .innerRadius(0)
1961
- .outerRadius(this.radius - radiusOffset + radiusOffset);
1962
- this.pieAngles = pie()
1963
- .sort(null)
1964
- .value((/**
1965
- * @param {?} d
1966
- * @return {?}
1967
- */
1968
- (d) => d.value)); // TODO: Strongly type
1969
- }
1970
- /**
1971
- * @private
1972
- * @param {?} chartElm
1973
- * @param {?} config
1974
- * @return {?}
1975
- */
1976
- drawChart(chartElm, config) {
1977
- this.buildContainer(chartElm, true);
1978
- /** @type {?} */
1979
- const self = this;
1980
- this.svg.selectAll('.pcac-arc')
1981
- .data(this.pieAngles(config.data))
1982
- .enter().append('g')
1983
- .attr('class', 'pcac-arc')
1984
- .append('path')
1985
- .style('fill', (/**
1986
- * @param {?} d
1987
- * @param {?} i
1988
- * @return {?}
1989
- */
1990
- (d, i) => {
1991
- return this.colors[i];
1992
- }))
1993
- .on('mouseover', (/**
1994
- * @param {?} d
1995
- * @param {?} i
1996
- * @return {?}
1997
- */
1998
- function (d, i) {
1999
- select(this).transition(transition()
2000
- .duration(self.transitionService.getTransitionDuration() / 3))
2001
- .attr('d', self.arcOverShape)
2002
- .style('fill', color(self.colors[i]).darker(1).toString());
2003
- }))
2004
- .on('mousemove', (/**
2005
- * @param {?} d
2006
- * @return {?}
2007
- */
2008
- function (d) {
2009
- self.tooltipBuilder.showBarTooltip(d.data);
2010
- }))
2011
- .on('mouseout', (/**
2012
- * @param {?} d
2013
- * @param {?} i
2014
- * @return {?}
2015
- */
2016
- function (d, i) {
2017
- self.tooltipBuilder.hideTooltip();
2018
- select(this).transition(transition()
2019
- .duration(self.transitionService.getTransitionDuration() / 3))
2020
- .attr('d', self.arcShape)
2021
- .style('fill', self.colors[i]);
2022
- }))
2023
- .on('click', (/**
2024
- * @param {?} d
2025
- * @param {?} i
2026
- * @return {?}
2027
- */
2028
- (d, i) => {
2029
- this.sliceClickedSource.next(d.data);
2030
- }))
2031
- .transition(transition()
2032
- .duration(this.transitionService.getTransitionDuration()))
2033
- .attrTween('d', (/**
2034
- * @param {?} b
2035
- * @return {?}
2036
- */
2037
- (b) => {
2038
- return this.tweenChart(b);
2039
- }));
2040
- }
2041
- /**
2042
- * @private
2043
- * @param {?} b
2044
- * @return {?}
2045
- */
2046
- tweenChart(b) {
2047
- b.innerRadius = 0;
2048
- /** @type {?} */
2049
- const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
2050
- return (/**
2051
- * @param {?} t
2052
- * @return {?}
2053
- */
2054
- (t) => this.arcShape(i(t))); // TODO: Strongly type
2055
- }
2056
- }
2057
- PieChartBuilder.decorators = [
2058
- { type: Injectable }
2059
- ];
2060
- /** @nocollapse */
2061
- PieChartBuilder.ctorParameters = () => [
2062
- { type: PcacAxisBuilder },
2063
- { type: PcacGridBuilder },
2064
- { type: PcacTransitionService },
2065
- { type: PcacTooltipBuilder },
2066
- { type: PcacColorService }
2067
- ];
2068
-
2069
- /**
2070
- * @fileoverview added by tsickle
2071
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2072
- */
2073
- class PcacPieChartComponent {
2074
- /**
2075
- * @param {?} chartBuilder
2076
- */
2077
- constructor(chartBuilder) {
2078
- this.chartBuilder = chartBuilder;
2079
- this.sliceClicked = new EventEmitter();
2080
- this.chartBuilder.sliceClicked$.subscribe((/**
2081
- * @param {?} data
2082
- * @return {?}
2083
- */
2084
- data => {
2085
- this.sliceClicked.emit(data);
2086
- }));
2087
- }
2088
- /**
2089
- * @return {?}
2090
- */
2091
- ngOnChanges() {
2092
- this.buildChart();
2093
- }
2094
- /**
2095
- * @return {?}
2096
- */
2097
- buildChart() {
2098
- if (this.config && this.config.data && this.config.data.length > 0) {
2099
- this.chartBuilder.buildChart(this.chartElm, this.config);
2100
- }
2101
- }
2102
- /**
2103
- * Opting against fromEvent due to incompatibility with rxjs 5 => 6
2104
- * @return {?}
2105
- */
2106
- onResize() {
2107
- /** @type {?} */
2108
- const self = this;
2109
- clearTimeout(this.resizeWindowTimeout);
2110
- this.resizeWindowTimeout = setTimeout((/**
2111
- * @return {?}
2112
- */
2113
- () => {
2114
- self.buildChart();
2115
- }), 300);
2116
- }
2117
- }
2118
- PcacPieChartComponent.decorators = [
2119
- { type: Component, args: [{
2120
- selector: 'pcac-pie-chart',
2121
- template: "<section class=\"pcac-pie-chart\">\r\n <svg #chart></svg>\r\n</section>\r\n\r\n",
2122
- providers: [
2123
- PieChartBuilder
2124
- ]
2125
- }] }
2126
- ];
2127
- /** @nocollapse */
2128
- PcacPieChartComponent.ctorParameters = () => [
2129
- { type: PieChartBuilder }
2130
- ];
2131
- PcacPieChartComponent.propDecorators = {
2132
- config: [{ type: Input }],
2133
- chartElm: [{ type: ViewChild, args: ['chart', { static: true },] }],
2134
- sliceClicked: [{ type: Output }],
2135
- onResize: [{ type: HostListener, args: ['window:resize',] }]
2136
- };
2137
-
2138
- /**
2139
- * @fileoverview added by tsickle
2140
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2141
- */
2142
-
2143
- /**
2144
- * @fileoverview added by tsickle
2145
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2146
- */
2147
- class PcacPieChartModule {
2148
- }
2149
- PcacPieChartModule.decorators = [
2150
- { type: NgModule, args: [{
2151
- exports: [
2152
- PcacPieChartComponent
2153
- ],
2154
- declarations: [
2155
- PcacPieChartComponent
2156
- ]
2157
- },] }
2158
- ];
2159
-
2160
- /**
2161
- * @fileoverview added by tsickle
2162
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2163
- */
2164
-
2165
- /**
2166
- * @fileoverview added by tsickle
2167
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2168
- */
2169
-
2170
- /**
2171
- * @fileoverview added by tsickle
2172
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2173
- */
2174
- class LineAreaChartEffectsBuilder {
2175
- constructor() {
2176
- this.lines = (/** @type {?} */ ([]));
2177
- }
2178
- /**
2179
- * @param {?} config
2180
- * @return {?}
2181
- */
2182
- buildEffects(config) {
2183
- this.config = config;
2184
- this.lines = (/** @type {?} */ ([]));
2185
- this.config.svg.selectAll('.line').each((/**
2186
- * @param {?} d
2187
- * @param {?} i
2188
- * @param {?} n
2189
- * @return {?}
2190
- */
2191
- (d, i, n) => {
2192
- this.lines.push(n[i]);
2193
- }));
2194
- this.buildCollection();
2195
- this.buildCanvas();
2196
- }
2197
- /**
2198
- * @private
2199
- * @return {?}
2200
- */
2201
- buildCollection() {
2202
- /** @type {?} */
2203
- const collection = this.config.svg.append('g')
2204
- .attr('class', 'effects');
2205
- collection.append('path')
2206
- .attr('class', 'effect-line');
2207
- /** @type {?} */
2208
- const mousePerLine = collection.selectAll('.effect-group')
2209
- .data(this.config.data.filter((/**
2210
- * @param {?} elm
2211
- * @return {?}
2212
- */
2213
- (elm) => {
2214
- return elm.data.length > 0;
2215
- })))
2216
- .enter().append('g')
2217
- .attr('class', 'effect-group');
2218
- mousePerLine.append('circle')
2219
- .attr('r', 7)
2220
- .attr('class', 'effect-circle')
2221
- .style('stroke', (/**
2222
- * @param {?} d
2223
- * @param {?} i
2224
- * @return {?}
2225
- */
2226
- (d, i) => {
2227
- return this.config.colors[i];
2228
- }));
2229
- mousePerLine.append('text')
2230
- .attr('class', 'effect-text')
2231
- .attr('y', 1.5)
2232
- .attr('transform', 'translate(10,3)');
2233
- }
2234
- /**
2235
- * @private
2236
- * @return {?}
2237
- */
2238
- buildCanvas() {
2239
- this.config.svg.append('rect')
2240
- .attr('class', 'effects-canvas')
2241
- .attr('width', this.config.width)
2242
- .attr('height', this.config.height)
2243
- .attr('pointer-events', 'all')
2244
- .on('mouseout', (/**
2245
- * @return {?}
2246
- */
2247
- () => {
2248
- this.hideEffects();
2249
- }))
2250
- .on('mouseover', (/**
2251
- * @return {?}
2252
- */
2253
- () => {
2254
- this.showEffects();
2255
- }))
2256
- .on('mousemove', (/**
2257
- * @param {?} d
2258
- * @param {?} i
2259
- * @param {?} nodes
2260
- * @return {?}
2261
- */
2262
- (d, i, nodes) => {
2263
- this.onMouseMove(d, i, nodes);
2264
- }));
2265
- }
2266
- /**
2267
- * @private
2268
- * @return {?}
2269
- */
2270
- showEffects() {
2271
- this.config.svg.select('.effect-line')
2272
- .style('opacity', '1');
2273
- this.config.svg.selectAll('.effect-group circle')
2274
- .style('opacity', '1');
2275
- this.config.svg.selectAll('.effect-group text')
2276
- .style('opacity', '1');
2277
- }
2278
- /**
2279
- * @private
2280
- * @return {?}
2281
- */
2282
- hideEffects() {
2283
- this.config.svg.select('.effect-line')
2284
- .style('opacity', '0');
2285
- this.config.svg.selectAll('.effect-group circle')
2286
- .style('opacity', '0');
2287
- this.config.svg.selectAll('.effect-group text')
2288
- .style('opacity', '0');
2289
- }
2290
- /**
2291
- * @private
2292
- * @param {?} d
2293
- * @param {?} i
2294
- * @param {?} nodes
2295
- * @return {?}
2296
- */
2297
- onMouseMove(d, i, nodes) {
2298
- /** @type {?} */
2299
- const mousePos = mouse(nodes[i]);
2300
- this.updateLine(mousePos);
2301
- this.updateEffects(mousePos);
2302
- }
2303
- /**
2304
- * @private
2305
- * @param {?} mousePos
2306
- * @return {?}
2307
- */
2308
- updateLine(mousePos) {
2309
- this.config.svg.select('.effect-line')
2310
- .attr('d', (/**
2311
- * @return {?}
2312
- */
2313
- () => {
2314
- return 'M' + mousePos[0] + ',' + this.config.height + ' ' + mousePos[0] + ',' + 0;
2315
- }));
2316
- }
2317
- /**
2318
- * @private
2319
- * @param {?} mousePos
2320
- * @return {?}
2321
- */
2322
- updateEffects(mousePos) {
2323
- this.config.svg.selectAll('.effect-group')
2324
- .attr('transform', (/**
2325
- * @param {?} data
2326
- * @param {?} index
2327
- * @param {?} nodes
2328
- * @return {?}
2329
- */
2330
- (data, index, nodes) => {
2331
- /** @type {?} */
2332
- let beginning = 0;
2333
- /** @type {?} */
2334
- let end = this.lines[index].getTotalLength();
2335
- /** @type {?} */
2336
- let target = 0;
2337
- /** @type {?} */
2338
- let pos;
2339
- while (true) {
2340
- target = Math.floor((beginning + end) / 2);
2341
- pos = this.lines[index].getPointAtLength(target);
2342
- if ((target === end || target === beginning) && pos.x !== mousePos[0]) {
2343
- break;
2344
- }
2345
- if (pos.x > mousePos[0]) {
2346
- end = target;
2347
- }
2348
- else if (pos.x < mousePos[0]) {
2349
- beginning = target;
2350
- }
2351
- else {
2352
- break;
2353
- }
2354
- }
2355
- select(nodes[index]).select('text')
2356
- .text(this.config.y.invert(pos.y).toFixed(0));
2357
- return 'translate(' + mousePos[0] + ',' + pos.y + ')';
2358
- }));
2359
- }
2360
- }
2361
-
2362
- /**
2363
- * @fileoverview added by tsickle
2364
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2365
- */
2366
- class LineAreaChartBuilder extends PcacChart {
2367
- /**
2368
- * @param {?} axisBuilder
2369
- * @param {?} gridBuilder
2370
- * @param {?} transitionService
2371
- * @param {?} tooltipBuilder
2372
- * @param {?} colorService
2373
- */
2374
- constructor(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService) {
2375
- super(axisBuilder, gridBuilder, transitionService, tooltipBuilder, colorService);
2376
- this.axisBuilder = axisBuilder;
2377
- this.gridBuilder = gridBuilder;
2378
- this.transitionService = transitionService;
2379
- this.tooltipBuilder = tooltipBuilder;
2380
- this.colorService = colorService;
2381
- this.dotClickedSource = new Subject();
2382
- this.dotClicked$ = this.dotClickedSource.asObservable();
2383
- }
2384
- /**
2385
- * @param {?} chartElm
2386
- * @param {?} config
2387
- * @return {?}
2388
- */
2389
- buildChart(chartElm, config) {
2390
- this.config = JSON.parse(JSON.stringify(config));
2391
- this.startData = range(this.config.data[0].data.length).map((/**
2392
- * @param {?} d
2393
- * @return {?}
2394
- */
2395
- (d) => {
2396
- return {
2397
- value: 0,
2398
- key: ''
2399
- };
2400
- }));
2401
- if (this.config.hideAxis) {
2402
- this.adjustForHiddenAxis();
2403
- }
2404
- this.initializeChartState(chartElm, this.config);
2405
- this.buildScales(this.config);
2406
- this.drawChart(chartElm, this.config);
2407
- }
2408
- /**
2409
- * @private
2410
- * @return {?}
2411
- */
2412
- adjustForHiddenAxis() {
2413
- this.config.height = this.config.height + 12;
2414
- this.margin.top = 8;
2415
- this.margin.bottom = 8;
2416
- this.margin.left = 8;
2417
- this.margin.right = 8;
2418
- }
2419
- /**
2420
- * @private
2421
- * @param {?} config
2422
- * @return {?}
2423
- */
2424
- buildScales(config) {
2425
- this.xScale = scaleLinear()
2426
- .domain([0, config.data[0].data.length - 1])
2427
- .range([0, this.width]);
2428
- this.yScale = scaleLinear()
2429
- .domain([0, config.domainMax])
2430
- .range([this.height, 0]);
2431
- this.line = line()
2432
- .x((/**
2433
- * @param {?} d
2434
- * @param {?} i
2435
- * @return {?}
2436
- */
2437
- (d, i) => {
2438
- return this.xScale(i);
2439
- }))
2440
- .y((/**
2441
- * @param {?} d
2442
- * @return {?}
2443
- */
2444
- (d) => {
2445
- return this.yScale(d.value);
2446
- }));
2447
- this.area = area()
2448
- .x((/**
2449
- * @param {?} d
2450
- * @param {?} i
2451
- * @return {?}
2452
- */
2453
- (d, i) => {
2454
- return this.xScale(i);
2455
- }))
2456
- .y0(this.height)
2457
- .y1((/**
2458
- * @param {?} d
2459
- * @return {?}
2460
- */
2461
- (d) => {
2462
- return this.yScale(d.value);
2463
- }));
2464
- }
2465
- /**
2466
- * @private
2467
- * @param {?} chartElm
2468
- * @param {?} config
2469
- * @return {?}
2470
- */
2471
- drawChart(chartElm, config) {
2472
- this.buildContainer(chartElm);
2473
- if (!config.hideAxis) {
2474
- this.axisBuilder.drawAxis({
2475
- svg: this.svg,
2476
- numberOfTicks: config.numberOfTicks || 5,
2477
- height: this.height,
2478
- xScale: this.xScale,
2479
- yScale: this.yScale
2480
- });
2481
- }
2482
- if (!config.hideGrid) {
2483
- this.gridBuilder.drawHorizontalGrid({
2484
- svg: this.svg,
2485
- numberOfTicks: config.numberOfTicks || 5,
2486
- width: this.width,
2487
- xScale: this.xScale,
2488
- yScale: this.yScale
2489
- });
2490
- }
2491
- this.drawLineArea(config);
2492
- if (config.enableEffects) {
2493
- this.drawEffects(config);
2494
- }
2495
- this.drawDots(config);
2496
- }
2497
- /**
2498
- * @private
2499
- * @param {?} config
2500
- * @return {?}
2501
- */
2502
- drawLineArea(config) {
2503
- for (let i = 0; i < config.data.length; i++) {
2504
- if (config.isArea) {
2505
- this.drawArea(config.data[i].data, i);
2506
- }
2507
- this.drawLine(config.data[i].data, i);
2508
- }
2509
- }
2510
- /**
2511
- * @private
2512
- * @param {?} lineData
2513
- * @param {?} index
2514
- * @return {?}
2515
- */
2516
- drawLine(lineData, index) {
2517
- this.svg.append('g')
2518
- .attr('class', 'lines')
2519
- .append('path')
2520
- .datum(lineData)
2521
- .attr('class', 'line')
2522
- .attr('d', this.line(this.startData))
2523
- .transition(transition()
2524
- .duration(this.transitionService.getTransitionDuration()))
2525
- .attr('d', (/** @type {?} */ (this.line))) // TODO: strongly type
2526
- .attr('stroke', (/**
2527
- * @return {?}
2528
- */
2529
- () => {
2530
- return this.colors[index];
2531
- }))
2532
- .attr('fill', 'none');
2533
- }
2534
- /**
2535
- * @private
2536
- * @param {?} lineData
2537
- * @param {?} index
2538
- * @return {?}
2539
- */
2540
- drawArea(lineData, index) {
2541
- this.svg.append('g')
2542
- .attr('class', 'areas')
2543
- .append('path')
2544
- .datum(lineData)
2545
- .attr('class', 'area')
2546
- .style('opacity', 0.5)
2547
- .style('fill', (/**
2548
- * @return {?}
2549
- */
2550
- () => {
2551
- return this.colors[index]; // TODO: strongly type
2552
- }))
2553
- .attr('d', this.line(this.startData))
2554
- .transition(transition()
2555
- .duration(this.transitionService.getTransitionDuration()))
2556
- .attr('d', (/** @type {?} */ (this.area))); // TODO: strongly type
2557
- }
2558
- /**
2559
- * @private
2560
- * @param {?} config
2561
- * @return {?}
2562
- */
2563
- drawEffects(config) {
2564
- if (config.enableEffects) {
2565
- /** @type {?} */
2566
- const effectsBuilder = new LineAreaChartEffectsBuilder();
2567
- effectsBuilder.buildEffects({
2568
- svg: this.svg,
2569
- height: this.height,
2570
- width: this.width,
2571
- data: config.data,
2572
- colors: this.colors,
2573
- x: this.xScale,
2574
- y: this.yScale
2575
- });
2576
- }
2577
- }
2578
- /**
2579
- * @private
2580
- * @param {?} config
2581
- * @return {?}
2582
- */
2583
- drawDots(config) {
2584
- /** @type {?} */
2585
- const self = this;
2586
- for (let index = 0; index < config.data.length; index++) {
2587
- this.svg.append('g')
2588
- .attr('class', 'dots')
2589
- .selectAll('.dot')
2590
- .data(config.data[index].data)
2591
- .enter().append('circle')
2592
- .attr('class', 'dot')
2593
- .attr('stroke', (/**
2594
- * @param {?} d
2595
- * @return {?}
2596
- */
2597
- (d) => {
2598
- return this.colors[index];
2599
- }))
2600
- .attr('cx', (/**
2601
- * @param {?} d
2602
- * @param {?} i
2603
- * @return {?}
2604
- */
2605
- (d, i) => {
2606
- return this.xScale(i);
2607
- }))
2608
- .attr('cy', (/**
2609
- * @param {?} d
2610
- * @return {?}
2611
- */
2612
- (d) => {
2613
- return this.yScale(0);
2614
- }))
2615
- .attr('fill', '#fff')
2616
- .on('mouseover', (/**
2617
- * @param {?} d
2618
- * @return {?}
2619
- */
2620
- function (d) {
2621
- self.tooltipBuilder.showBarTooltip(d);
2622
- select(this).transition(transition()
2623
- .duration(self.transitionService.getTransitionDuration() / 3))
2624
- .attr('r', 6)
2625
- .attr('fill', self.colors[index]);
2626
- }))
2627
- .on('mouseout', (/**
2628
- * @return {?}
2629
- */
2630
- function () {
2631
- self.tooltipBuilder.hideTooltip();
2632
- select(this).transition(transition()
2633
- .duration(self.transitionService.getTransitionDuration() / 3))
2634
- .attr('r', 4)
2635
- .attr('fill', '#fff');
2636
- }))
2637
- .on('click', (/**
2638
- * @param {?} d
2639
- * @param {?} i
2640
- * @return {?}
2641
- */
2642
- (d, i) => {
2643
- this.dotClickedSource.next(d);
2644
- }))
2645
- .transition(transition()
2646
- .duration(this.transitionService.getTransitionDuration()))
2647
- .attr('cy', (/**
2648
- * @param {?} d
2649
- * @return {?}
2650
- */
2651
- (d) => {
2652
- return this.yScale((/** @type {?} */ (d.value)));
2653
- }))
2654
- .attr('r', 4);
2655
- }
2656
- }
2657
- }
2658
- LineAreaChartBuilder.decorators = [
2659
- { type: Injectable }
2660
- ];
2661
- /** @nocollapse */
2662
- LineAreaChartBuilder.ctorParameters = () => [
2663
- { type: PcacAxisBuilder },
2664
- { type: PcacGridBuilder },
2665
- { type: PcacTransitionService },
2666
- { type: PcacTooltipBuilder },
2667
- { type: PcacColorService }
2668
- ];
2669
-
2670
- /**
2671
- * @fileoverview added by tsickle
2672
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2673
- */
2674
- class PcacLineAreaChartComponent {
2675
- /**
2676
- * @param {?} chartBuilder
2677
- */
2678
- constructor(chartBuilder) {
2679
- this.chartBuilder = chartBuilder;
2680
- this.dotClicked = new EventEmitter();
2681
- this.chartBuilder.dotClicked$.subscribe((/**
2682
- * @param {?} data
2683
- * @return {?}
2684
- */
2685
- data => {
2686
- this.dotClicked.emit(data);
2687
- }));
2688
- }
2689
- /**
2690
- * @return {?}
2691
- */
2692
- ngOnChanges() {
2693
- this.buildChart();
2694
- }
2695
- /**
2696
- * @return {?}
2697
- */
2698
- buildChart() {
2699
- if (this.config && this.config.data && this.config.data.length > 0) {
2700
- this.chartBuilder.buildChart(this.chartElm, this.config);
2701
- }
2702
- }
2703
- /**
2704
- * Opting against fromEvent due to incompatibility with rxjs 5 => 6
2705
- * @return {?}
2706
- */
2707
- onResize() {
2708
- /** @type {?} */
2709
- const self = this;
2710
- clearTimeout(this.resizeWindowTimeout);
2711
- this.resizeWindowTimeout = setTimeout((/**
2712
- * @return {?}
2713
- */
2714
- () => {
2715
- self.buildChart();
2716
- }), 300);
2717
- }
2718
- }
2719
- PcacLineAreaChartComponent.decorators = [
2720
- { type: Component, args: [{
2721
- selector: 'pcac-line-area-chart',
2722
- template: "<section class=\"pcac-line-area-chart\">\r\n <svg #chart></svg>\r\n</section>\r\n\r\n",
2723
- providers: [
2724
- LineAreaChartBuilder
2725
- ]
2726
- }] }
2727
- ];
2728
- /** @nocollapse */
2729
- PcacLineAreaChartComponent.ctorParameters = () => [
2730
- { type: LineAreaChartBuilder }
2731
- ];
2732
- PcacLineAreaChartComponent.propDecorators = {
2733
- config: [{ type: Input }],
2734
- chartElm: [{ type: ViewChild, args: ['chart', { static: true },] }],
2735
- dotClicked: [{ type: Output }],
2736
- onResize: [{ type: HostListener, args: ['window:resize',] }]
2737
- };
2738
-
2739
- /**
2740
- * @fileoverview added by tsickle
2741
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2742
- */
2743
-
2744
- /**
2745
- * @fileoverview added by tsickle
2746
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2747
- */
2748
- class PcacLineAreaChartModule {
2749
- }
2750
- PcacLineAreaChartModule.decorators = [
2751
- { type: NgModule, args: [{
2752
- exports: [
2753
- PcacLineAreaChartComponent
2754
- ],
2755
- declarations: [
2756
- PcacLineAreaChartComponent
2757
- ]
2758
- },] }
2759
- ];
2760
-
2761
- /**
2762
- * @fileoverview added by tsickle
2763
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2764
- */
2765
-
2766
- /**
2767
- * @fileoverview added by tsickle
2768
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2769
- */
2770
-
2771
- /**
2772
- * @fileoverview added by tsickle
2773
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2774
- */
2775
- class PcacDialogComponent {
2776
- constructor() {
2777
- this.width = '50%';
2778
- this.closed = new EventEmitter();
2779
- this.opened = new EventEmitter();
2780
- this.show = false;
2781
- }
2782
- /**
2783
- * @return {?}
2784
- */
2785
- close() {
2786
- this.show = false;
2787
- this.closed.emit();
2788
- }
2789
- /**
2790
- * @return {?}
2791
- */
2792
- open() {
2793
- this.show = true;
2794
- this.opened.emit();
2795
- }
2796
- }
2797
- PcacDialogComponent.decorators = [
2798
- { type: Component, args: [{
2799
- selector: 'pcac-dialog',
2800
- template: "<div class=\"pcac-modal\" *ngIf=\"show\">\r\n <div class=\"pcac-modal-overlay\" (click)=\"close()\"></div>\r\n <div class=\"pcac-modal-dialog\" ng-style=\"dialogStyle\" [style.width]=\"width\">\r\n <div class=\"pcac-modal-dialog-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n",
2801
- styles: [".pcac-modal{position:fixed;z-index:9999;top:0;left:0;width:100%;height:100%;border:1px solid #212529}.pcac-modal-overlay{position:absolute;z-index:9000;top:0;left:0;width:100%;height:100%;background-color:#212529;opacity:.8}.pcac-modal-dialog{z-index:9999;position:absolute;top:50%;left:50%;width:50%;overflow-x:hidden;overflow-y:auto;max-height:95%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#fff;box-shadow:4px 4px 80px #212529;padding:1rem}.pcac-modal-dialog-content{position:relative;overflow:hidden;height:100%}"]
2802
- }] }
2803
- ];
2804
- PcacDialogComponent.propDecorators = {
2805
- width: [{ type: Input }],
2806
- closed: [{ type: Output }],
2807
- opened: [{ type: Output }]
2808
- };
2809
-
2810
- /**
2811
- * @fileoverview added by tsickle
2812
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2813
- */
2814
- class PcacDialogModule {
2815
- }
2816
- PcacDialogModule.decorators = [
2817
- { type: NgModule, args: [{
2818
- imports: [
2819
- CommonModule
2820
- ],
2821
- exports: [
2822
- PcacDialogComponent
2823
- ],
2824
- declarations: [
2825
- PcacDialogComponent
2826
- ]
2827
- },] }
2828
- ];
2829
-
2830
- /**
2831
- * @fileoverview added by tsickle
2832
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2833
- */
2834
-
2835
- /**
2836
- * @fileoverview added by tsickle
2837
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2838
- */
2839
-
2840
- /**
2841
- * @fileoverview added by tsickle
2842
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2843
- */
2844
- class PcacSpinnerComponent {
2845
- constructor() {
2846
- this.showSpinner = true;
2847
- this.showOverlay = true;
2848
- }
2849
- }
2850
- PcacSpinnerComponent.decorators = [
2851
- { type: Component, args: [{
2852
- selector: 'pcac-spinner',
2853
- template: "<section *ngIf=\"showSpinner\" class=\"pcac-spinner\">\r\n <div class=\"overlay\" *ngIf=\"showOverlay\"></div>\r\n <div class=\"wrapper\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\r\n <path d=\"M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z\"></path>\r\n </svg>\r\n </div>\r\n</section>\r\n"
2854
- }] }
2855
- ];
2856
- PcacSpinnerComponent.propDecorators = {
2857
- showSpinner: [{ type: Input }],
2858
- showOverlay: [{ type: Input }]
2859
- };
2860
-
2861
- /**
2862
- * @fileoverview added by tsickle
2863
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2864
- */
2865
- class PcacSpinnerModule {
2866
- }
2867
- PcacSpinnerModule.decorators = [
2868
- { type: NgModule, args: [{
2869
- imports: [
2870
- CommonModule
2871
- ],
2872
- exports: [
2873
- PcacSpinnerComponent
2874
- ],
2875
- declarations: [
2876
- PcacSpinnerComponent
2877
- ]
2878
- },] }
2879
- ];
2880
-
2881
- /**
2882
- * @fileoverview added by tsickle
2883
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2884
- */
2885
-
2886
- /**
2887
- * @fileoverview added by tsickle
2888
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2889
- */
2890
-
2891
- /**
2892
- * @fileoverview added by tsickle
2893
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2894
- */
2895
- /** @enum {number} */
2896
- const PcacPaginationPageSizeEnum = {
2897
- Ten: 10,
2898
- TwentyFive: 25,
2899
- Fifty: 50,
2900
- OneHundred: 100,
2901
- };
2902
- PcacPaginationPageSizeEnum[PcacPaginationPageSizeEnum.Ten] = 'Ten';
2903
- PcacPaginationPageSizeEnum[PcacPaginationPageSizeEnum.TwentyFive] = 'TwentyFive';
2904
- PcacPaginationPageSizeEnum[PcacPaginationPageSizeEnum.Fifty] = 'Fifty';
2905
- PcacPaginationPageSizeEnum[PcacPaginationPageSizeEnum.OneHundred] = 'OneHundred';
2906
-
2907
- /**
2908
- * @fileoverview added by tsickle
2909
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2910
- */
2911
- class PaginationComponent {
2912
- constructor() {
2913
- this.config = (/** @type {?} */ ({
2914
- currentPageIndex: 1,
2915
- countPerPage: PcacPaginationPageSizeEnum.Ten,
2916
- totalItemsInCollection: 10,
2917
- show: false,
2918
- isCompactView: false
2919
- }));
2920
- this.perPageChanged = new EventEmitter();
2921
- this.startClicked = new EventEmitter();
2922
- this.leftClicked = new EventEmitter();
2923
- this.rightClicked = new EventEmitter();
2924
- this.endClicked = new EventEmitter();
2925
- }
2926
- /**
2927
- * @return {?}
2928
- */
2929
- get leftIsActive() {
2930
- return this.config.currentPageIndex !== 1;
2931
- }
2932
- /**
2933
- * @return {?}
2934
- */
2935
- get rightIsActive() {
2936
- return this.config.currentPageIndex !== Math.ceil(this.config.totalItemsInCollection / this.config.countPerPage);
2937
- }
2938
- /**
2939
- * @return {?}
2940
- */
2941
- get currentRangeText() {
2942
- /** @type {?} */
2943
- let text = `${this.getStartingRangeText()}-${this.getEndingRangeText()}`;
2944
- if (!this.config.isCompactView) {
2945
- text = text + ` of ${this.config.totalItemsInCollection}`;
2946
- }
2947
- return text;
2948
- }
2949
- /**
2950
- * @param {?} count
2951
- * @return {?}
2952
- */
2953
- onPerPageChanged(count) {
2954
- this.config.countPerPage = parseInt(count, 10);
2955
- this.perPageChanged.emit(this.config.countPerPage);
2956
- }
2957
- /**
2958
- * @return {?}
2959
- */
2960
- onStartClicked() {
2961
- if (this.leftIsActive) {
2962
- this.config.currentPageIndex = 1;
2963
- this.startClicked.emit(1);
2964
- }
2965
- }
2966
- /**
2967
- * @return {?}
2968
- */
2969
- onLeftClicked() {
2970
- if (this.leftIsActive) {
2971
- this.config.currentPageIndex = this.config.currentPageIndex - 1;
2972
- this.leftClicked.emit(this.config.currentPageIndex);
2973
- }
2974
- }
2975
- /**
2976
- * @return {?}
2977
- */
2978
- onRightClicked() {
2979
- if (this.rightIsActive) {
2980
- this.config.currentPageIndex = this.config.currentPageIndex + 1;
2981
- this.rightClicked.emit(this.config.currentPageIndex);
2982
- }
2983
- }
2984
- /**
2985
- * @return {?}
2986
- */
2987
- onEndClicked() {
2988
- if (this.rightIsActive) {
2989
- this.config.currentPageIndex = Math.ceil(this.config.totalItemsInCollection / this.config.countPerPage);
2990
- this.endClicked.emit(this.config.currentPageIndex);
2991
- }
2992
- }
2993
- /**
2994
- * @private
2995
- * @return {?}
2996
- */
2997
- getStartingRangeText() {
2998
- return this.config.countPerPage * (this.config.currentPageIndex - 1) + 1;
2999
- }
3000
- /**
3001
- * @private
3002
- * @return {?}
3003
- */
3004
- getEndingRangeText() {
3005
- /** @type {?} */
3006
- const totalPossiblePage = Math.ceil(this.config.totalItemsInCollection / this.config.countPerPage);
3007
- if (totalPossiblePage === 1) {
3008
- return this.config.totalItemsInCollection;
3009
- }
3010
- if (totalPossiblePage === this.config.currentPageIndex) {
3011
- /** @type {?} */
3012
- const total = this.config.countPerPage * (this.config.currentPageIndex - 1);
3013
- /** @type {?} */
3014
- const modulus = this.config.totalItemsInCollection % total;
3015
- return total + modulus;
3016
- }
3017
- return this.config.countPerPage * this.config.currentPageIndex;
3018
- }
3019
- }
3020
- PaginationComponent.decorators = [
3021
- { type: Component, args: [{
3022
- selector: 'pcac-pagination',
3023
- template: "<section class=\"pcac-pager\" *ngIf=\"config?.show\">\r\n <div class=\"per-page\">\r\n <div *ngIf=\"!config.isCompactView\">\r\n Per Page:\r\n </div>\r\n <div>\r\n <select [(ngModel)]=\"config.countPerPage\" (change)=\"onPerPageChanged($event.target.value)\">\r\n <option value=\"10\">10</option>\r\n <option value=\"25\">25</option>\r\n <option value=\"50\">50</option>\r\n <option value=\"100\">100</option>\r\n </select>\r\n </div>\r\n </div>\r\n <div class=\"range-text\">\r\n {{currentRangeText}}\r\n </div>\r\n <div class=\"direction left-end\" [ngClass]=\"{'active': leftIsActive}\" (click)=\"onStartClicked()\">\r\n <svg class=\"pcac-icon \" viewBox=\"0 0 20 20\">\r\n <path fill=\"none\" d=\"M8.388,10.049l4.76-4.873c0.303-0.31,0.297-0.804-0.012-1.105c-0.309-0.304-0.803-0.293-1.105,0.012L6.726,9.516c-0.303,0.31-0.296,0.805,0.012,1.105l5.433,5.307c0.152,0.148,0.35,0.223,0.547,0.223c0.203,0,0.406-0.08,0.559-0.236c0.303-0.309,0.295-0.803-0.012-1.104L8.388,10.049z\"></path>\r\n </svg>\r\n <svg class=\"pcac-icon pull-left\" viewBox=\"0 0 20 20\">\r\n <path fill=\"none\" d=\"M8.388,10.049l4.76-4.873c0.303-0.31,0.297-0.804-0.012-1.105c-0.309-0.304-0.803-0.293-1.105,0.012L6.726,9.516c-0.303,0.31-0.296,0.805,0.012,1.105l5.433,5.307c0.152,0.148,0.35,0.223,0.547,0.223c0.203,0,0.406-0.08,0.559-0.236c0.303-0.309,0.295-0.803-0.012-1.104L8.388,10.049z\"></path>\r\n </svg>\r\n </div>\r\n <div class=\"direction left\" [ngClass]=\"{'active': leftIsActive}\" (click)=\"onLeftClicked()\">\r\n <svg class=\"pcac-icon \" viewBox=\"0 0 20 20\">\r\n <path fill=\"none\" d=\"M8.388,10.049l4.76-4.873c0.303-0.31,0.297-0.804-0.012-1.105c-0.309-0.304-0.803-0.293-1.105,0.012L6.726,9.516c-0.303,0.31-0.296,0.805,0.012,1.105l5.433,5.307c0.152,0.148,0.35,0.223,0.547,0.223c0.203,0,0.406-0.08,0.559-0.236c0.303-0.309,0.295-0.803-0.012-1.104L8.388,10.049z\"></path>\r\n </svg>\r\n </div>\r\n <div class=\"direction right\" [ngClass]=\"{'active': rightIsActive}\" (click)=\"onRightClicked()\">\r\n <svg class=\"pcac-icon \" viewBox=\"0 0 20 20\">\r\n <path fill=\"none\" d=\"M11.611,10.049l-4.76-4.873c-0.303-0.31-0.297-0.804,0.012-1.105c0.309-0.304,0.803-0.293,1.105,0.012l5.306,5.433c0.304,0.31,0.296,0.805-0.012,1.105L7.83,15.928c-0.152,0.148-0.35,0.223-0.547,0.223c-0.203,0-0.406-0.08-0.559-0.236c-0.303-0.309-0.295-0.803,0.012-1.104L11.611,10.049z\"></path>\r\n </svg>\r\n </div>\r\n <div class=\"direction right-end\" [ngClass]=\"{'active': rightIsActive}\" (click)=\"onEndClicked()\">\r\n <svg class=\"pcac-icon \" viewBox=\"0 0 20 20\">\r\n <path fill=\"none\" d=\"M11.611,10.049l-4.76-4.873c-0.303-0.31-0.297-0.804,0.012-1.105c0.309-0.304,0.803-0.293,1.105,0.012l5.306,5.433c0.304,0.31,0.296,0.805-0.012,1.105L7.83,15.928c-0.152,0.148-0.35,0.223-0.547,0.223c-0.203,0-0.406-0.08-0.559-0.236c-0.303-0.309-0.295-0.803,0.012-1.104L11.611,10.049z\"></path>\r\n </svg>\r\n <svg class=\"pcac-icon pull-left\" viewBox=\"0 0 20 20\">\r\n <path fill=\"none\" d=\"M11.611,10.049l-4.76-4.873c-0.303-0.31-0.297-0.804,0.012-1.105c0.309-0.304,0.803-0.293,1.105,0.012l5.306,5.433c0.304,0.31,0.296,0.805-0.012,1.105L7.83,15.928c-0.152,0.148-0.35,0.223-0.547,0.223c-0.203,0-0.406-0.08-0.559-0.236c-0.303-0.309-0.295-0.803,0.012-1.104L11.611,10.049z\"></path>\r\n </svg>\r\n </div>\r\n</section>\r\n"
3024
- }] }
3025
- ];
3026
- PaginationComponent.propDecorators = {
3027
- config: [{ type: Input }],
3028
- perPageChanged: [{ type: Output }],
3029
- startClicked: [{ type: Output }],
3030
- leftClicked: [{ type: Output }],
3031
- rightClicked: [{ type: Output }],
3032
- endClicked: [{ type: Output }]
3033
- };
3034
-
3035
- /**
3036
- * @fileoverview added by tsickle
3037
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3038
- */
3039
- class PcacPaginationModule {
3040
- }
3041
- PcacPaginationModule.decorators = [
3042
- { type: NgModule, args: [{
3043
- imports: [
3044
- CommonModule,
3045
- FormsModule
3046
- ],
3047
- exports: [
3048
- PaginationComponent
3049
- ],
3050
- declarations: [
3051
- PaginationComponent
3052
- ]
3053
- },] }
3054
- ];
3055
-
3056
- /**
3057
- * @fileoverview added by tsickle
3058
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3059
- */
3060
-
3061
- /**
3062
- * @fileoverview added by tsickle
3063
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3064
- */
3065
-
3066
- /**
3067
- * @fileoverview added by tsickle
3068
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3069
- */
3070
-
3071
- /**
3072
- * @fileoverview added by tsickle
3073
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3074
- */
3075
-
3076
- export { BarHorizontalChartBuilder, BarVerticalChartBuilder, LineAreaChartBuilder, PaginationComponent, PcacAxisBuilder, PcacBarChartHorizontalComponent, PcacBarHorizontalChartModule, PcacBarVerticalChartComponent, PcacBarVerticalChartModule, PcacChart, PcacColorService, PcacCoreModule, PcacDialogComponent, PcacDialogModule, PcacGridBuilder, PcacHeaderComponent, PcacHeaderModule, PcacLineAreaChartComponent, PcacLineAreaChartModule, PcacPaginationModule, PcacPaginationPageSizeEnum, PcacPieChartComponent, PcacPieChartModule, PcacSpinnerComponent, PcacSpinnerModule, PcacTableComponent, PcacTableModule, PcacTableSortIconsEnum, PcacTickFormatEnum, PcacTooltipBuilder, PcacTransitionService, PieChartBuilder, TableSortService as ɵa };
3077
- //# sourceMappingURL=pioneer-code-pioneer-charts.js.map