@gravity-ui/chartkit 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/build/components/ChartKit.css +23 -0
  3. package/build/components/ChartKit.d.ts +0 -1
  4. package/build/components/ChartKit.js +4 -5
  5. package/build/i18n/keysets/en.json +60 -0
  6. package/build/i18n/keysets/ru.json +62 -0
  7. package/build/libs/chartkit-error/chartkit-error.d.ts +1 -0
  8. package/build/libs/chartkit-error/chartkit-error.js +1 -0
  9. package/build/libs/settings/__tests__/settings.test.js +1 -1
  10. package/build/libs/settings/settings.d.ts +6 -3
  11. package/build/libs/settings/settings.js +4 -2
  12. package/build/plugins/highcharts/__stories__/AreaRange.stories.d.ts +4 -0
  13. package/build/plugins/highcharts/__stories__/AreaRange.stories.js +22 -0
  14. package/build/plugins/highcharts/__stories__/Line.stories.d.ts +4 -0
  15. package/build/plugins/highcharts/__stories__/Line.stories.js +21 -0
  16. package/build/plugins/highcharts/__stories__/mocks/area-range.d.ts +2 -0
  17. package/build/plugins/highcharts/__stories__/mocks/area-range.js +61 -0
  18. package/build/plugins/highcharts/__stories__/mocks/holidays.d.ts +7070 -0
  19. package/build/plugins/highcharts/__stories__/mocks/holidays.js +7065 -0
  20. package/build/plugins/highcharts/__stories__/mocks/line.d.ts +2 -0
  21. package/build/plugins/highcharts/__stories__/mocks/line.js +129 -0
  22. package/build/plugins/highcharts/index.d.ts +2 -0
  23. package/build/plugins/highcharts/index.js +5 -0
  24. package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +23 -0
  25. package/build/plugins/highcharts/renderer/HighchartsWidget.js +6 -0
  26. package/build/plugins/highcharts/renderer/components/HighchartsComponent.css +4 -0
  27. package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +575 -0
  28. package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +115 -0
  29. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +50 -0
  30. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.d.ts +10 -0
  31. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.js +32 -0
  32. package/build/plugins/highcharts/renderer/components/withSplitPane/WithSplitPane.css +4 -0
  33. package/build/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.d.ts +10 -0
  34. package/build/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.js +207 -0
  35. package/build/plugins/highcharts/renderer/helpers/add-holidays.d.ts +1 -0
  36. package/build/plugins/highcharts/renderer/helpers/add-holidays.js +43 -0
  37. package/build/plugins/highcharts/renderer/helpers/comments/drawing.d.ts +11 -0
  38. package/build/plugins/highcharts/renderer/helpers/comments/drawing.js +571 -0
  39. package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +575 -0
  40. package/build/plugins/highcharts/renderer/helpers/config/config.js +1483 -0
  41. package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.d.ts +1 -0
  42. package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.js +57 -0
  43. package/build/plugins/highcharts/renderer/helpers/config/options.d.ts +465 -0
  44. package/build/plugins/highcharts/renderer/helpers/config/options.js +350 -0
  45. package/build/plugins/highcharts/renderer/helpers/config/types.d.ts +6 -0
  46. package/build/plugins/highcharts/renderer/helpers/config/types.js +1 -0
  47. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.d.ts +10 -0
  48. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.js +42 -0
  49. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.test.d.ts +1 -0
  50. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.test.js +99 -0
  51. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.d.ts +1 -0
  52. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.js +17 -0
  53. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.test.d.ts +1 -0
  54. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.test.js +28 -0
  55. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.d.ts +5 -0
  56. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.js +20 -0
  57. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.test.d.ts +1 -0
  58. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.test.js +27 -0
  59. package/build/plugins/highcharts/renderer/helpers/config/utils/concatStrings.d.ts +1 -0
  60. package/build/plugins/highcharts/renderer/helpers/config/utils/concatStrings.js +1 -0
  61. package/build/plugins/highcharts/renderer/helpers/config/utils/getChartKitFormattedValue.d.ts +2 -0
  62. package/build/plugins/highcharts/renderer/helpers/config/utils/getChartKitFormattedValue.js +15 -0
  63. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.d.ts +3 -0
  64. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.js +15 -0
  65. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.d.ts +1 -0
  66. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.js +11 -0
  67. package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.d.ts +1 -0
  68. package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.js +9 -0
  69. package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.d.ts +1 -0
  70. package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.js +20 -0
  71. package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +13 -0
  72. package/build/plugins/highcharts/renderer/helpers/config/utils/index.js +13 -0
  73. package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.d.ts +2 -0
  74. package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.js +3 -0
  75. package/build/plugins/highcharts/renderer/helpers/config/utils/isSafari.d.ts +1 -0
  76. package/build/plugins/highcharts/renderer/helpers/config/utils/isSafari.js +12 -0
  77. package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.d.ts +1 -0
  78. package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.js +8 -0
  79. package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.test.d.ts +1 -0
  80. package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.test.js +31 -0
  81. package/build/plugins/highcharts/renderer/helpers/config/utils/localStorage.d.ts +5 -0
  82. package/build/plugins/highcharts/renderer/helpers/config/utils/localStorage.js +23 -0
  83. package/build/plugins/highcharts/renderer/helpers/config/utils/mergeArrayWithObject.d.ts +1 -0
  84. package/build/plugins/highcharts/renderer/helpers/config/utils/mergeArrayWithObject.js +10 -0
  85. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.d.ts +2 -0
  86. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.js +19 -0
  87. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.test.d.ts +1 -0
  88. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.test.js +20 -0
  89. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.d.ts +13 -0
  90. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.js +27 -0
  91. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.d.ts +1 -0
  92. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.js +45 -0
  93. package/build/plugins/highcharts/renderer/helpers/constants.d.ts +28 -0
  94. package/build/plugins/highcharts/renderer/helpers/constants.js +30 -0
  95. package/build/plugins/highcharts/renderer/helpers/graph.css +89 -0
  96. package/build/plugins/highcharts/renderer/helpers/graph.d.ts +552 -0
  97. package/build/plugins/highcharts/renderer/helpers/graph.js +85 -0
  98. package/build/plugins/highcharts/renderer/helpers/highcharts/colors.d.ts +2 -0
  99. package/build/plugins/highcharts/renderer/helpers/highcharts/colors.js +17 -0
  100. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.d.ts +4 -0
  101. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +346 -0
  102. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calcucalteClosestPointManually.d.ts +1 -0
  103. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calcucalteClosestPointManually.js +19 -0
  104. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calculateClosestPointManually.test.d.ts +1 -0
  105. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calculateClosestPointManually.test.js +42 -0
  106. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/index.d.ts +1 -0
  107. package/build/plugins/highcharts/renderer/helpers/highcharts/utils/index.js +1 -0
  108. package/build/plugins/highcharts/renderer/helpers/init-highcharts-modules.d.ts +1 -0
  109. package/build/plugins/highcharts/renderer/helpers/init-highcharts-modules.js +49 -0
  110. package/build/plugins/highcharts/renderer/helpers/prepare-data.d.ts +1 -0
  111. package/build/plugins/highcharts/renderer/helpers/prepare-data.js +175 -0
  112. package/build/plugins/highcharts/renderer/helpers/tooltip/constants.d.ts +13 -0
  113. package/build/plugins/highcharts/renderer/helpers/tooltip/constants.js +14 -0
  114. package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.d.ts +1 -0
  115. package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.js +5 -0
  116. package/build/plugins/highcharts/renderer/helpers/tooltip/index.d.ts +13 -0
  117. package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +253 -0
  118. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/index.d.ts +6 -0
  119. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/index.js +22 -0
  120. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashDotLineIcon.d.ts +2 -0
  121. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashDotLineIcon.js +20 -0
  122. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashLineIcon.d.ts +2 -0
  123. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashLineIcon.js +25 -0
  124. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DotLineIcon.d.ts +2 -0
  125. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DotLineIcon.js +20 -0
  126. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotDotLineIcon.d.ts +2 -0
  127. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotDotLineIcon.js +18 -0
  128. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotLineIcon.d.ts +2 -0
  129. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotLineIcon.js +18 -0
  130. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashLineIcon.d.ts +2 -0
  131. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashLineIcon.js +15 -0
  132. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotDotLineIcon.d.ts +2 -0
  133. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotDotLineIcon.js +18 -0
  134. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotLineIcon.d.ts +2 -0
  135. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotLineIcon.js +18 -0
  136. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashLineIcon.d.ts +2 -0
  137. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashLineIcon.js +18 -0
  138. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDotLineIcon.d.ts +2 -0
  139. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDotLineIcon.js +20 -0
  140. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/SolidLineIcon.d.ts +2 -0
  141. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/SolidLineIcon.js +13 -0
  142. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/index.d.ts +11 -0
  143. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/index.js +11 -0
  144. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/types.d.ts +4 -0
  145. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/types.js +1 -0
  146. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/utils.d.ts +7 -0
  147. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/utils.js +5 -0
  148. package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +367 -0
  149. package/build/plugins/highcharts/renderer/helpers/tooltip/types.d.ts +85 -0
  150. package/build/plugins/highcharts/renderer/helpers/tooltip/types.js +1 -0
  151. package/build/plugins/highcharts/renderer/helpers/types.d.ts +22 -0
  152. package/build/plugins/highcharts/renderer/helpers/types.js +1 -0
  153. package/build/plugins/highcharts/types/comments.d.ts +51 -0
  154. package/build/plugins/highcharts/types/comments.js +1 -0
  155. package/build/plugins/highcharts/types/highcharts-extends.d.ts +38 -0
  156. package/build/plugins/highcharts/types/index.d.ts +4 -0
  157. package/build/plugins/highcharts/types/index.js +1 -0
  158. package/build/plugins/highcharts/types/lib.d.ts +1 -0
  159. package/build/plugins/highcharts/types/lib.js +1 -0
  160. package/build/plugins/highcharts/types/misc.d.ts +19 -0
  161. package/build/plugins/highcharts/types/misc.js +1 -0
  162. package/build/plugins/highcharts/types/widget.d.ts +47 -0
  163. package/build/plugins/highcharts/types/widget.js +1 -0
  164. package/build/plugins/index.d.ts +4 -2
  165. package/build/plugins/index.js +1 -0
  166. package/build/plugins/indicator/renderer/IndicatorItem.d.ts +3 -2
  167. package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +10 -2
  168. package/build/plugins/indicator/renderer/IndicatorWidget.js +1 -1
  169. package/build/plugins/indicator/types.d.ts +0 -6
  170. package/build/plugins/shared/format-number/format-number.d.ts +4 -0
  171. package/build/plugins/shared/format-number/format-number.js +88 -0
  172. package/build/plugins/shared/format-number/format-number.test.d.ts +1 -0
  173. package/build/plugins/shared/format-number/format-number.test.js +14 -0
  174. package/build/plugins/shared/format-number/i18n/en.json +17 -0
  175. package/build/plugins/shared/format-number/i18n/i18n.d.ts +5 -0
  176. package/build/plugins/shared/format-number/i18n/i18n.js +8 -0
  177. package/build/plugins/shared/format-number/i18n/ru.json +17 -0
  178. package/build/plugins/shared/format-number/types.d.ts +14 -0
  179. package/build/plugins/shared/format-number/types.js +1 -0
  180. package/build/plugins/shared/index.d.ts +2 -0
  181. package/build/plugins/shared/index.js +1 -0
  182. package/build/plugins/yagr/renderer/YagrWidget.d.ts +11 -3
  183. package/build/plugins/yagr/renderer/YagrWidget.js +2 -1
  184. package/build/plugins/yagr/types.d.ts +0 -7
  185. package/build/types/index.d.ts +1 -2
  186. package/build/types/misc.d.ts +4 -0
  187. package/build/types/misc.js +1 -0
  188. package/build/types/widget.d.ts +17 -0
  189. package/package.json +4 -1
@@ -0,0 +1,346 @@
1
+ /* eslint-disable complexity */
2
+ import Highcharts from 'highcharts';
3
+ import get from 'lodash/get';
4
+ import { i18n } from '../../../../../i18n';
5
+ import { hideFixedTooltip, getTooltipPositioner, handleScroll, synchronizeTooltipTablesCellsWidth, } from '../config/config';
6
+ import { TOOLTIP_ROW_CLASS_NAME, TOOLTIP_LIST_CLASS_NAME, TOOLTIP_FOOTER_CLASS_NAME, TOOLTIP_CONTAINER_CLASS_NAME, TOOLTIP_ROW_NAME_CLASS_NANE, } from '../tooltip';
7
+ import colors from './colors';
8
+ import { calculateClosestPointManually } from './utils';
9
+ function formatQ(timestamp) {
10
+ const date = new Date(timestamp);
11
+ const month = date.getUTCMonth() + 1;
12
+ return 'Q' + Math.ceil(month / 3);
13
+ }
14
+ const REST_SECTION_HEIGHT = 25;
15
+ Highcharts.dateFormats = {
16
+ Q: formatQ,
17
+ q: formatQ,
18
+ quarter: formatQ,
19
+ };
20
+ Math.easeInQuint = function (pos) {
21
+ return Math.pow(pos, 5);
22
+ };
23
+ Highcharts.setOptions({
24
+ colors: colors,
25
+ credits: {
26
+ enabled: false,
27
+ },
28
+ chart: {
29
+ animation: false,
30
+ displayErrors: false,
31
+ resetZoomButton: {
32
+ relativeTo: 'chart',
33
+ theme: {
34
+ width: 16,
35
+ height: 16,
36
+ 'text-align': 'center',
37
+ opacity: '0.8',
38
+ cursor: 'pointer',
39
+ },
40
+ position: {
41
+ y: 30,
42
+ },
43
+ },
44
+ },
45
+ title: {
46
+ text: '',
47
+ style: {
48
+ fontSize: '15px',
49
+ fontWeight: 'bold',
50
+ },
51
+ },
52
+ legend: {
53
+ enabled: true,
54
+ itemStyle: {
55
+ fontWeight: 'normal',
56
+ },
57
+ navigation: {
58
+ animation: false,
59
+ },
60
+ },
61
+ tooltip: {
62
+ borderRadius: '0px',
63
+ borderWidth: 0,
64
+ useHTML: true,
65
+ hideDelay: 0,
66
+ animation: false,
67
+ shadow: false,
68
+ },
69
+ xAxis: {
70
+ gridLineColor: '#dbdbdb',
71
+ gridLineWidth: 1,
72
+ lineColor: '#dbdbdb',
73
+ },
74
+ yAxis: {
75
+ title: {
76
+ text: null,
77
+ },
78
+ },
79
+ plotOptions: {
80
+ series: {
81
+ animation: false,
82
+ shadow: false,
83
+ connectNulls: false,
84
+ dataGrouping: {
85
+ enabled: false,
86
+ },
87
+ states: {
88
+ normal: {
89
+ animation: false,
90
+ },
91
+ hover: {
92
+ animation: false,
93
+ },
94
+ inactive: {
95
+ animation: false,
96
+ opacity: 0.7,
97
+ },
98
+ },
99
+ marker: {
100
+ states: {
101
+ hover: {
102
+ animation: false,
103
+ },
104
+ normal: {
105
+ animation: false,
106
+ },
107
+ },
108
+ },
109
+ },
110
+ },
111
+ });
112
+ function initHighcharts({ isMobile }) {
113
+ Highcharts.setOptions({
114
+ lang: {
115
+ resetZoom: '⟲',
116
+ resetZoomTitle: i18n('highcharts', 'reset-zoom-title'),
117
+ months: [
118
+ i18n('highcharts', 'January'),
119
+ i18n('highcharts', 'February'),
120
+ i18n('highcharts', 'March'),
121
+ i18n('highcharts', 'April'),
122
+ i18n('highcharts', 'May'),
123
+ i18n('highcharts', 'June'),
124
+ i18n('highcharts', 'July'),
125
+ i18n('highcharts', 'August'),
126
+ i18n('highcharts', 'September'),
127
+ i18n('highcharts', 'October'),
128
+ i18n('highcharts', 'November'),
129
+ i18n('highcharts', 'December'),
130
+ ],
131
+ shortMonths: [
132
+ i18n('highcharts', 'Jan'),
133
+ i18n('highcharts', 'Feb'),
134
+ i18n('highcharts', 'Mar'),
135
+ i18n('highcharts', 'Apr'),
136
+ i18n('highcharts', 'May'),
137
+ i18n('highcharts', 'Jun'),
138
+ i18n('highcharts', 'Jul'),
139
+ i18n('highcharts', 'Aug'),
140
+ i18n('highcharts', 'Sep'),
141
+ i18n('highcharts', 'Oct'),
142
+ i18n('highcharts', 'Nov'),
143
+ i18n('highcharts', 'Dec'),
144
+ ],
145
+ weekdays: [
146
+ i18n('highcharts', 'Sun'),
147
+ i18n('highcharts', 'Mon'),
148
+ i18n('highcharts', 'Tue'),
149
+ i18n('highcharts', 'Wed'),
150
+ i18n('highcharts', 'Thu'),
151
+ i18n('highcharts', 'Fri'),
152
+ i18n('highcharts', 'Sat'),
153
+ ],
154
+ decimalPoint: i18n('highcharts', 'decimal-point'),
155
+ thousandsSep: i18n('highcharts', 'thousands-sep'),
156
+ },
157
+ });
158
+ // https://github.com/highcharts/highcharts/issues/11494
159
+ (function (H) {
160
+ H.wrap(H.Tooltip.prototype, 'getLabel', function (proceed, ...rest) {
161
+ const t = proceed.apply(this, rest);
162
+ if (this.container) {
163
+ H.css(this.container, {
164
+ zIndex: 100001,
165
+ });
166
+ }
167
+ return t;
168
+ });
169
+ })(Highcharts);
170
+ Highcharts.wrap(Highcharts.Chart.prototype, 'redraw', function (proceed, ...rest) {
171
+ if (this.tooltip.fixed) {
172
+ hideFixedTooltip(this.tooltip, isMobile);
173
+ }
174
+ proceed.apply(this, rest);
175
+ if (this.afterRedrawCallback) {
176
+ this.afterRedrawCallback();
177
+ delete this.afterRedrawCallback;
178
+ }
179
+ });
180
+ Highcharts.wrap(Highcharts.Chart.prototype, 'destroy', function (proceed, ...rest) {
181
+ if (this.tooltip.clickOutsideHandler) {
182
+ window.document.removeEventListener('click', this.tooltip.clickOutsideHandler);
183
+ }
184
+ if (this.tooltip.fixed) {
185
+ hideFixedTooltip(this.tooltip, isMobile);
186
+ }
187
+ proceed.apply(this, ...rest);
188
+ });
189
+ Highcharts.wrap(Highcharts.Point.prototype, 'setState', function (proceed, ...rest) {
190
+ if (!this.series.chart.tooltip.fixed) {
191
+ proceed.apply(this, rest);
192
+ }
193
+ });
194
+ Highcharts.wrap(Highcharts.Tooltip.prototype, 'init', function (proceed, ...rest) {
195
+ this.orientationChangeHandler = () => {
196
+ if (isMobile) {
197
+ const resizeHandler = () => {
198
+ this.update({
199
+ positioner: getTooltipPositioner(isMobile),
200
+ });
201
+ if (this.chart.hoverPoints) {
202
+ this.chart.hoverPoints.forEach((point) => {
203
+ point.setState('');
204
+ });
205
+ delete this.chart.hoverPoints;
206
+ }
207
+ if (this.chart.hoverPoint) {
208
+ this.chart.hoverPoint.setState('');
209
+ delete this.chart.hoverPoint;
210
+ }
211
+ window.removeEventListener('resize', resizeHandler);
212
+ };
213
+ window.addEventListener('resize', resizeHandler);
214
+ }
215
+ };
216
+ window.addEventListener('orientationchange', this.orientationChangeHandler);
217
+ proceed.apply(this, rest);
218
+ });
219
+ Highcharts.wrap(Highcharts.Tooltip.prototype, 'destroy', function (proceed, ...rest) {
220
+ window.removeEventListener('orientationchange', this.orientationChangeHandler);
221
+ window.removeEventListener('scroll', this.scrollHandler);
222
+ proceed.apply(this, rest);
223
+ });
224
+ Highcharts.wrap(Highcharts.Tooltip.prototype, 'hide', function (proceed, ...rest) {
225
+ if (this.lastVisibleRowIndex) {
226
+ this.lastVisibleRowIndex = null;
227
+ }
228
+ if (this.scrollHandler && !this.fixed) {
229
+ window.removeEventListener('scroll', this.scrollHandler);
230
+ this.scrollHandler = null;
231
+ this.chart.topPosition = null;
232
+ }
233
+ if (!this.fixed) {
234
+ proceed.apply(this, rest);
235
+ }
236
+ });
237
+ Highcharts.wrap(Highcharts.Tooltip.prototype, 'hideFixedTooltip', function () {
238
+ if (this.fixed) {
239
+ hideFixedTooltip(this, isMobile);
240
+ }
241
+ });
242
+ Highcharts.wrap(Highcharts.Tooltip.prototype, 'refresh', function (proceed, points, ...rest) {
243
+ const isNonBodyScroll = get(this.chart, 'userOptions._config.nonBodyScroll');
244
+ const maxTooltipLines = get(this.chart, 'userOptions._config.maxTooltipLines');
245
+ const chartType = this.chart.options.chart.type;
246
+ if (isNonBodyScroll && !this.scrollHandler) {
247
+ this.scrollHandler = handleScroll.bind(this);
248
+ this.chart.topPosition = this.chart.container.getBoundingClientRect().top;
249
+ window.addEventListener('scroll', this.scrollHandler, true);
250
+ }
251
+ if (this.chart.pointsForInitialRefresh) {
252
+ delete this.chart.pointsForInitialRefresh;
253
+ }
254
+ if (chartType === 'map' && !this.fixed) {
255
+ proceed.apply(this, [points, ...rest]);
256
+ }
257
+ const isFixation = rest[1];
258
+ if ((!this.fixed || isFixation) && points) {
259
+ if (isFixation) {
260
+ this.lastVisibleRowIndex = null;
261
+ }
262
+ proceed.apply(this, [points, ...rest]);
263
+ if (chartType === 'timeline') {
264
+ return false;
265
+ }
266
+ if (this.container) {
267
+ synchronizeTooltipTablesCellsWidth(this.container, isMobile);
268
+ }
269
+ if (isFixation) {
270
+ const rowNames = this.container.querySelectorAll(`.${TOOLTIP_ROW_NAME_CLASS_NANE}`);
271
+ for (let i = 0; i < rowNames.length; i++) {
272
+ const rowNameNode = rowNames[i];
273
+ if (rowNameNode.scrollWidth > rowNameNode.clientWidth) {
274
+ const rowNameNodeText = rowNameNode.innerText;
275
+ rowNameNode.setAttribute('title', rowNameNodeText);
276
+ }
277
+ }
278
+ return false;
279
+ }
280
+ }
281
+ if (this.container && !this.fixed && !this.lastVisibleRowIndex) {
282
+ const tooltipNode = this.container.querySelector(`.${TOOLTIP_CONTAINER_CLASS_NAME}`);
283
+ if (!tooltipNode) {
284
+ return false;
285
+ }
286
+ const hasScroll = tooltipNode.scrollHeight > tooltipNode.clientHeight;
287
+ const moreThanMaxLines = maxTooltipLines && points.length > maxTooltipLines;
288
+ if (hasScroll || moreThanMaxLines) {
289
+ const footerNode = tooltipNode.querySelector(`.${TOOLTIP_FOOTER_CLASS_NAME}`);
290
+ const { top, height } = tooltipNode.getBoundingClientRect();
291
+ const footerNodeHeight = footerNode ? footerNode.clientHeight : 0;
292
+ const bottomPadding = parseFloat(window.getComputedStyle(tooltipNode, null).getPropertyValue('padding-bottom'), 10);
293
+ const containerBottomEdge = top + height;
294
+ const rows = tooltipNode.querySelectorAll(`.${TOOLTIP_LIST_CLASS_NAME} .${TOOLTIP_ROW_CLASS_NAME}`);
295
+ let lastVisibleRowIndex = null;
296
+ const selectedSeriesIndex = this.chart.hoverPoints.indexOf(this.chart.hoverPoint);
297
+ const rowForSelectedSeriesHeight = selectedSeriesIndex >= 0
298
+ ? rows[selectedSeriesIndex].getBoundingClientRect().height
299
+ : 0;
300
+ if (maxTooltipLines && rows.length > maxTooltipLines) {
301
+ lastVisibleRowIndex = maxTooltipLines - 1;
302
+ }
303
+ else {
304
+ for (let i = rows.length - 1; i > 0; i--) {
305
+ const row = rows[i];
306
+ const { top: rowTop, height: rowHeight } = row.getBoundingClientRect();
307
+ const rowBottomEdge = rowTop + rowHeight;
308
+ const containerBottomEdgeWithPadding = containerBottomEdge - bottomPadding;
309
+ const margin = REST_SECTION_HEIGHT + footerNodeHeight + rowForSelectedSeriesHeight;
310
+ const rowBottomEdgeWithMargin = rowBottomEdge + margin;
311
+ if (rowBottomEdgeWithMargin <= containerBottomEdgeWithPadding) {
312
+ lastVisibleRowIndex = i;
313
+ break;
314
+ }
315
+ }
316
+ }
317
+ if (lastVisibleRowIndex) {
318
+ this.lastVisibleRowIndex = lastVisibleRowIndex;
319
+ this.refresh(points, ...rest);
320
+ }
321
+ }
322
+ }
323
+ });
324
+ Highcharts.wrap(Highcharts.Axis.prototype, 'getClosest', function (proceed, ...rest) {
325
+ const userOptions = this.userOptions || {};
326
+ if (userOptions.calcClosestPointManually) {
327
+ return calculateClosestPointManually.apply(this);
328
+ }
329
+ else {
330
+ return proceed.apply(this, rest);
331
+ }
332
+ });
333
+ }
334
+ function initHighchartsMap() {
335
+ Highcharts.wrap(Highcharts.ColorAxis.prototype, 'drawCrosshair', function (proceed, ...rest) {
336
+ if (!this.chart.tooltip.fixed) {
337
+ proceed.apply(this, rest);
338
+ }
339
+ });
340
+ Highcharts.wrap(Highcharts.ColorAxis.prototype, 'hideCrosshair', function (proceed, ...rest) {
341
+ if (!this.chart.tooltip.fixed) {
342
+ proceed.apply(this, rest);
343
+ }
344
+ });
345
+ }
346
+ export { initHighcharts, initHighchartsMap };
@@ -0,0 +1 @@
1
+ export declare function calculateClosestPointManually(this: any): number | undefined;
@@ -0,0 +1,19 @@
1
+ export function calculateClosestPointManually() {
2
+ const series = this.series;
3
+ const xValues = series.reduce((values, currSeries) => {
4
+ return values.concat(currSeries.processedXData);
5
+ }, []);
6
+ xValues.sort((a, b) => b - a);
7
+ let closestPointRange;
8
+ xValues.forEach((xValue, index) => {
9
+ const nextXValue = xValues[index + 1];
10
+ if (nextXValue) {
11
+ const distance = xValue - nextXValue;
12
+ if (distance > 0 &&
13
+ (typeof closestPointRange === 'undefined' || distance < closestPointRange)) {
14
+ closestPointRange = distance;
15
+ }
16
+ }
17
+ });
18
+ return closestPointRange;
19
+ }
@@ -0,0 +1,42 @@
1
+ import { calculateClosestPointManually } from './calcucalteClosestPointManually';
2
+ describe('calculateClosestPointManually', () => {
3
+ it('Должна вернуть наименьшее расстояние между точками и если оно больше 0', () => {
4
+ const MOCKED_SERIES = [
5
+ {
6
+ processedXData: [1, 5, 12],
7
+ },
8
+ {
9
+ processedXData: [12, 65],
10
+ },
11
+ {
12
+ processedXData: [3, 140],
13
+ },
14
+ ];
15
+ const MOCKED_CONTEXT = {
16
+ series: MOCKED_SERIES,
17
+ };
18
+ const expectedResult = 2;
19
+ const result = calculateClosestPointManually.apply(MOCKED_CONTEXT);
20
+ expect(result).toEqual(expectedResult);
21
+ });
22
+ it('Должна вернуть undefined, если передан пустой массив', () => {
23
+ const MOCKED_CONTEXT = { series: [] };
24
+ const result = calculateClosestPointManually.apply(MOCKED_CONTEXT);
25
+ expect(result).toBeUndefined();
26
+ });
27
+ it('Должна вернуть undefined, если наименьшее расстояние это 0', () => {
28
+ const MOCKED_SERIES = [
29
+ {
30
+ processedXData: [12],
31
+ },
32
+ {
33
+ processedXData: [12],
34
+ },
35
+ ];
36
+ const MOCKED_CONTEXT = {
37
+ series: MOCKED_SERIES,
38
+ };
39
+ const result = calculateClosestPointManually.apply(MOCKED_CONTEXT);
40
+ expect(result).toBeUndefined();
41
+ });
42
+ });
@@ -0,0 +1 @@
1
+ export { calculateClosestPointManually } from './calcucalteClosestPointManually';
@@ -0,0 +1 @@
1
+ export { calculateClosestPointManually } from './calcucalteClosestPointManually';
@@ -0,0 +1 @@
1
+ export function initHighchartsModules(): void;
@@ -0,0 +1,49 @@
1
+ import Highcharts from 'highcharts';
2
+ import highchartsMore from 'highcharts/highcharts-more';
3
+ import stock from 'highcharts/modules/stock';
4
+ import solidGauge from 'highcharts/modules/solid-gauge';
5
+ import funnel from 'highcharts/modules/funnel';
6
+ import histogramBellcurve from 'highcharts/modules/histogram-bellcurve';
7
+ import sankey from 'highcharts/modules/sankey';
8
+ import heatmap from 'highcharts/modules/heatmap';
9
+ import treemap from 'highcharts/modules/treemap';
10
+ import variwide from 'highcharts/modules/variwide';
11
+ import streamgraph from 'highcharts/modules/streamgraph';
12
+ import drilldown from 'highcharts/modules/drilldown';
13
+ import parallelCoordinates from 'highcharts/modules/parallel-coordinates';
14
+ import patternFill from 'highcharts/modules/pattern-fill';
15
+ import wordcloud from 'highcharts/modules/wordcloud';
16
+ import xrange from 'highcharts/modules/xrange';
17
+ import networkgraph from 'highcharts/modules/networkgraph';
18
+ import timeline from 'highcharts/modules/timeline';
19
+ import bullet from 'highcharts/modules/bullet';
20
+ import annotations from 'highcharts/modules/annotations';
21
+ import seriesLabel from 'highcharts/modules/series-label';
22
+ import indicators from 'highcharts/indicators/indicators';
23
+ import ema from 'highcharts/indicators/ema';
24
+ import venn from 'highcharts/modules/venn';
25
+ export function initHighchartsModules() {
26
+ highchartsMore(Highcharts);
27
+ stock(Highcharts);
28
+ solidGauge(Highcharts);
29
+ funnel(Highcharts);
30
+ histogramBellcurve(Highcharts);
31
+ sankey(Highcharts);
32
+ heatmap(Highcharts);
33
+ treemap(Highcharts);
34
+ variwide(Highcharts);
35
+ streamgraph(Highcharts);
36
+ drilldown(Highcharts);
37
+ annotations(Highcharts);
38
+ seriesLabel(Highcharts);
39
+ parallelCoordinates(Highcharts);
40
+ patternFill(Highcharts);
41
+ wordcloud(Highcharts);
42
+ xrange(Highcharts);
43
+ networkgraph(Highcharts);
44
+ timeline(Highcharts);
45
+ bullet(Highcharts);
46
+ venn(Highcharts);
47
+ indicators(Highcharts);
48
+ ema(Highcharts);
49
+ }
@@ -0,0 +1 @@
1
+ export function prepareData(data: any, options: any, holidays: any): void;
@@ -0,0 +1,175 @@
1
+ import moment from 'moment';
2
+ import lodashMin from 'lodash/min';
3
+ import { ChartKitError, CHARTKIT_ERROR_CODE } from '../../../../libs';
4
+ function prepareValue(value, firstValue, options) {
5
+ if (value === null) {
6
+ return null;
7
+ }
8
+ if (options.normalizeDiv) {
9
+ return value / (firstValue || 1);
10
+ }
11
+ if (options.normalizeSub) {
12
+ return value - firstValue;
13
+ }
14
+ return value;
15
+ }
16
+ function sortByLastValue(a, b) {
17
+ if (a._lastValue < b._lastValue) {
18
+ return -1;
19
+ }
20
+ if (a._lastValue > b._lastValue) {
21
+ return 1;
22
+ }
23
+ return 0;
24
+ }
25
+ function sortByAlphabet(a, b) {
26
+ if (a.name < b.name) {
27
+ return -1;
28
+ }
29
+ if (a.name > b.name) {
30
+ return 1;
31
+ }
32
+ return 0;
33
+ }
34
+ const HIGHCHARTS_SCALE = {
35
+ s: 'second',
36
+ h: 'hour',
37
+ d: 'day',
38
+ w: 'week',
39
+ m: 'month',
40
+ q: 'quarter',
41
+ y: 'year',
42
+ };
43
+ function computeXTickScale(range) {
44
+ const timeUnits = {
45
+ s: 1000,
46
+ i: 60000,
47
+ h: 3600000,
48
+ d: 86400000,
49
+ w: 604800000,
50
+ m: 2419200000,
51
+ q: 7344000000,
52
+ y: 31449600000,
53
+ };
54
+ let previous = 's';
55
+ // eslint-disable-next-line guard-for-in
56
+ for (const current in timeUnits) {
57
+ if (timeUnits[current] > range) {
58
+ return previous;
59
+ }
60
+ previous = current;
61
+ }
62
+ return previous;
63
+ }
64
+ function removeHolidays(data, options, holidays) {
65
+ const timeline = [];
66
+ const graphsData = [];
67
+ data.graphs.forEach((graph, i) => {
68
+ graphsData[i] = [];
69
+ });
70
+ data.categories_ms.forEach((ts, i) => {
71
+ const datetime = moment(ts).format('YYYYMMDD');
72
+ const region = (options.region && options.region.toLowerCase()) || 'tot';
73
+ const holiday = holidays.holiday[region][datetime] || holidays.weekend[region][datetime];
74
+ if (!holiday) {
75
+ timeline.push(ts);
76
+ data.graphs.forEach((graph, j) => graphsData[j].push(graph.data[i]));
77
+ }
78
+ });
79
+ data.categories_ms = timeline;
80
+ data.graphs.forEach((graph, i) => {
81
+ graph.data = graphsData[i];
82
+ });
83
+ }
84
+ // eslint-disable-next-line complexity
85
+ export function prepareData(data, options, holidays) {
86
+ if (!data ||
87
+ (typeof data === 'object' && !Object.keys(data).length) ||
88
+ (data.graphs &&
89
+ !(data.graphs.length && data.graphs.some((graph) => graph.data && graph.data.length))) ||
90
+ (Array.isArray(data) && !data.length)) {
91
+ throw new ChartKitError({ code: CHARTKIT_ERROR_CODE.NO_DATA });
92
+ }
93
+ if (data.graphs) {
94
+ if (data.graphs.length > 50 && !options.withoutLineLimit) {
95
+ throw new ChartKitError({ code: CHARTKIT_ERROR_CODE.TOO_MANY_LINES });
96
+ }
97
+ data.graphs.forEach((graph) => {
98
+ graph.name = graph.name || graph.title;
99
+ });
100
+ let min = false;
101
+ let max = false;
102
+ if (data.categories_ms) {
103
+ options.highchartsScale = HIGHCHARTS_SCALE[options.scale];
104
+ const closestPointRange = lodashMin(data.categories_ms.map((timestamp, index) => timestamp - data.categories_ms[index - 1]));
105
+ options.scale = options.scale || computeXTickScale(closestPointRange);
106
+ if (options.scale && options.scale.length > 1) {
107
+ const match = options.scale.match(/^[sihyqmwd]/g);
108
+ options.scale = match ? match[0] : null;
109
+ }
110
+ data.graphs
111
+ .filter(({ data }) => Boolean(data))
112
+ .forEach((graph, index) => {
113
+ let result = [];
114
+ const aloneOrHasNull = graph.data.length === 1 || graph.data.indexOf(null) !== -1;
115
+ const firstValue = graph.data[0];
116
+ if (aloneOrHasNull) {
117
+ result = graph.data.map((val, pos) => {
118
+ if (val !== null && typeof val === 'object') {
119
+ return val;
120
+ }
121
+ const preparedVal = prepareValue(val, firstValue, options);
122
+ const currentPoint = {
123
+ x: data.categories_ms[pos],
124
+ y: preparedVal,
125
+ };
126
+ if (preparedVal !== null) {
127
+ min = Math.min(min, preparedVal);
128
+ max = Math.max(max, preparedVal);
129
+ }
130
+ return currentPoint;
131
+ });
132
+ }
133
+ else {
134
+ result = graph.data.map((val, pos) => {
135
+ if (val !== null && typeof val === 'object') {
136
+ return val;
137
+ }
138
+ const preparedVal = prepareValue(val, firstValue, options);
139
+ min = Math.min(min, preparedVal);
140
+ max = Math.max(max, preparedVal);
141
+ return [data.categories_ms[pos], preparedVal];
142
+ });
143
+ }
144
+ data.graphs[index].data = result;
145
+ });
146
+ delete data.categories;
147
+ }
148
+ if (data.categories) {
149
+ delete data.categories_ms;
150
+ }
151
+ if (options.orderType === 'byLastValue') {
152
+ data.graphs.forEach((graphItem) => {
153
+ graphItem._lastValue =
154
+ (graphItem.data &&
155
+ graphItem.data[graphItem.data.length - 1] &&
156
+ (graphItem.data[graphItem.data.length - 1][1] ||
157
+ graphItem.data[graphItem.data.length - 1].y)) ||
158
+ 0;
159
+ });
160
+ data.graphs.sort(sortByLastValue);
161
+ }
162
+ if (options.orderType === 'alphabet') {
163
+ data.graphs.sort(sortByAlphabet);
164
+ }
165
+ if ((options.orderType === 'byLastValue' || options.orderType === 'alphabet') &&
166
+ options.orderSort === 'fromBottom') {
167
+ data.graphs.reverse();
168
+ }
169
+ if (holidays && options.hideHolidays) {
170
+ removeHolidays(data, options, holidays);
171
+ }
172
+ options.max = max;
173
+ options.min = min;
174
+ }
175
+ }
@@ -0,0 +1,13 @@
1
+ export declare enum LineShapeType {
2
+ Solid = "Solid",
3
+ ShortDash = "ShortDash",
4
+ ShortDot = "ShortDot",
5
+ ShortDashDot = "ShortDashDot",
6
+ ShortDashDotDot = "ShortDashDotDot",
7
+ Dot = "Dot",
8
+ Dash = "Dash",
9
+ LongDash = "LongDash",
10
+ DashDot = "DashDot",
11
+ LongDashDot = "LongDashDot",
12
+ LongDashDotDot = "LongDashDotDot"
13
+ }
@@ -0,0 +1,14 @@
1
+ export var LineShapeType;
2
+ (function (LineShapeType) {
3
+ LineShapeType["Solid"] = "Solid";
4
+ LineShapeType["ShortDash"] = "ShortDash";
5
+ LineShapeType["ShortDot"] = "ShortDot";
6
+ LineShapeType["ShortDashDot"] = "ShortDashDot";
7
+ LineShapeType["ShortDashDotDot"] = "ShortDashDotDot";
8
+ LineShapeType["Dot"] = "Dot";
9
+ LineShapeType["Dash"] = "Dash";
10
+ LineShapeType["LongDash"] = "LongDash";
11
+ LineShapeType["DashDot"] = "DashDot";
12
+ LineShapeType["LongDashDot"] = "LongDashDot";
13
+ LineShapeType["LongDashDotDot"] = "LongDashDotDot";
14
+ })(LineShapeType || (LineShapeType = {}));
@@ -0,0 +1 @@
1
+ export declare const escapeHTML: (html?: string) => string;