@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,50 @@
1
+ .styled-split-pane__pane-resizer {
2
+ background: var(--yc-color-base-generic);
3
+ z-index: 1;
4
+ box-sizing: border-box;
5
+ position: relative;
6
+ }
7
+
8
+ .styled-split-pane__pane-resizer_hovered {
9
+ opacity: 0.5;
10
+ }
11
+
12
+ .styled-split-pane__pane-resizer.horizontal {
13
+ height: 24px;
14
+ min-height: 24px;
15
+ width: 100%;
16
+ }
17
+
18
+ .styled-split-pane__pane-resizer.horizontal:before {
19
+ content: "";
20
+ width: 28px;
21
+ margin-left: -14px;
22
+ height: 1px;
23
+ background-color: var(--highcarts-navigator-body);
24
+ left: 50%;
25
+ top: 10px;
26
+ position: absolute;
27
+ }
28
+
29
+ .styled-split-pane__pane-resizer.horizontal:after {
30
+ content: "";
31
+ width: 28px;
32
+ margin-left: -14px;
33
+ height: 1px;
34
+ background-color: var(--highcarts-navigator-body);
35
+ left: 50%;
36
+ top: 13px;
37
+ position: absolute;
38
+ }
39
+
40
+ .styled-split-pane__pane-resizer.vertical {
41
+ height: 100%;
42
+ width: 1px;
43
+ min-width: 1px;
44
+ background: var(--data-table-border-color);
45
+ }
46
+
47
+ .styled-split-pane .Pane {
48
+ overflow: auto;
49
+ height: 100%;
50
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { Split, SplitPaneProps } from 'react-split-pane';
3
+ import './StyledSplitPane.css';
4
+ export declare type PaneSplit = Split;
5
+ declare type Props = SplitPaneProps & {
6
+ paneOneRender: () => React.ReactNode;
7
+ paneTwoRender: () => React.ReactNode;
8
+ };
9
+ export declare const StyledSplitPane: ({ paneOneRender, paneTwoRender, ...splitPaneProps }: Props) => JSX.Element;
10
+ export {};
@@ -0,0 +1,32 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ import SplitPane, { Pane } from 'react-split-pane';
4
+ import block from 'bem-cn-lite';
5
+ import './StyledSplitPane.css';
6
+ const b = block('styled-split-pane');
7
+ const resizerClassName = b('pane-resizer');
8
+ export const StyledSplitPane = (_a) => {
9
+ var { paneOneRender, paneTwoRender } = _a, splitPaneProps = __rest(_a, ["paneOneRender", "paneTwoRender"]);
10
+ // https://github.com/tomkp/react-split-pane/blob/master/src/SplitPane.js#L307
11
+ const splitPaneRef = React.useRef(null);
12
+ React.useEffect(() => {
13
+ var _a, _b;
14
+ const resizer = (_b = (_a = splitPaneRef.current) === null || _a === void 0 ? void 0 : _a.splitPane) === null || _b === void 0 ? void 0 : _b.getElementsByClassName(resizerClassName)[0];
15
+ const hoveredClassName = `${resizerClassName}_hovered`;
16
+ const onTouchStart = () => {
17
+ resizer === null || resizer === void 0 ? void 0 : resizer.classList.add(hoveredClassName);
18
+ };
19
+ const onTouchEnd = () => {
20
+ resizer === null || resizer === void 0 ? void 0 : resizer.classList.remove(hoveredClassName);
21
+ };
22
+ resizer === null || resizer === void 0 ? void 0 : resizer.addEventListener('touchstart', onTouchStart);
23
+ resizer === null || resizer === void 0 ? void 0 : resizer.addEventListener('touchend', onTouchEnd);
24
+ return function cleanup() {
25
+ resizer === null || resizer === void 0 ? void 0 : resizer.removeEventListener('touchstart', onTouchStart);
26
+ resizer === null || resizer === void 0 ? void 0 : resizer.removeEventListener('touchend', onTouchEnd);
27
+ };
28
+ }, []);
29
+ return (React.createElement(SplitPane, Object.assign({}, splitPaneProps, { ref: splitPaneRef, className: b(), resizerClassName: resizerClassName }),
30
+ React.createElement(Pane, null, paneOneRender()),
31
+ React.createElement(Pane, null, paneTwoRender())));
32
+ };
@@ -0,0 +1,4 @@
1
+ .with-split-pane {
2
+ position: relative;
3
+ height: 100%;
4
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { Highcharts } from '../../../types';
3
+ import './WithSplitPane.css';
4
+ export declare const withSplitPane: <ComposedComponentProps extends {}>(ComposedComponent: React.ComponentType<ComposedComponentProps>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<ComposedComponentProps & {
5
+ onPaneChange?: (() => void) | undefined;
6
+ onSplitPaneMountCallback?: ((chart: Highcharts.Chart) => void) | undefined;
7
+ } & {
8
+ current: any;
9
+ forwardedRef: React.Ref<ComposedComponentProps>;
10
+ }> & React.RefAttributes<ComposedComponentProps>>;
@@ -0,0 +1,207 @@
1
+ import React from 'react';
2
+ import block from 'bem-cn-lite';
3
+ import { get, debounce } from 'lodash';
4
+ import { chartTypesWithoutCrosshair } from '../../helpers/config/config';
5
+ import { StyledSplitPane } from '../StyledSplitPane/StyledSplitPane';
6
+ import './WithSplitPane.css';
7
+ const b = block('with-split-pane');
8
+ const PANE_RESIZER_HEIGHT = 24;
9
+ const CHART_SECTION_PERCENTAGE = 0.6;
10
+ const MIN_TOOLTIP_SECTION_HEIGHT = 62;
11
+ const seriesTypesNeedsOnlyHoverState = ['line', 'area', 'arearange', 'bubble', 'map'];
12
+ const deviceWithNavBarHeight = window.innerHeight;
13
+ function getPointsForInitialRefresh(chart) {
14
+ let minX = Infinity;
15
+ let points = null;
16
+ const type = get(chart, 'userOptions.chart.type');
17
+ if (type === 'streamgraph') {
18
+ points = chart.series[0].points[chart.series[0].points.length - 1];
19
+ }
20
+ else if (chart.series.length === 1) {
21
+ const series = chart.series[0];
22
+ const seriesType = (series && series.type) || (chart.options.chart && chart.options.chart.type);
23
+ points =
24
+ seriesType === 'sankey' || seriesType === 'map'
25
+ ? chart.series[0].points[0]
26
+ : [chart.series[0].points[0]];
27
+ }
28
+ else {
29
+ points = chart.series
30
+ .map((series) => {
31
+ if (series.points[0]) {
32
+ minX = Math.min(minX, series.points[0].x);
33
+ }
34
+ return series.points[0];
35
+ })
36
+ .filter((point) => {
37
+ return point && point.x === minX;
38
+ });
39
+ }
40
+ return points;
41
+ }
42
+ function forceHoverState(chart, activePoints) {
43
+ const chartType = get(chart, 'userOptions.chart.type');
44
+ if (chartType === 'pie') {
45
+ chart.tooltip.refresh(activePoints);
46
+ chart.pointsForInitialRefresh = activePoints;
47
+ }
48
+ else if (chart.series.length === 1) {
49
+ const series = chart.series[0];
50
+ const seriesType = (series && series.type) || (chart.options.chart && chart.options.chart.type);
51
+ if (seriesType && seriesTypesNeedsOnlyHoverState.indexOf(seriesType)) {
52
+ chart.series[0].points[0].setState('hover');
53
+ }
54
+ else {
55
+ for (let i = chart.series[0].points.length - 1; i >= 0; i--) {
56
+ chart.series[0].points[i].setState(i ? 'inactive' : 'hover');
57
+ }
58
+ }
59
+ }
60
+ if (chartTypesWithoutCrosshair.indexOf(chartType) === -1) {
61
+ const point = Array.isArray(activePoints) ? activePoints[0] : activePoints;
62
+ chart.xAxis[0].drawCrosshair(undefined, point);
63
+ chart.yAxis[0].drawCrosshair(undefined, point);
64
+ }
65
+ }
66
+ var PaneSplits;
67
+ (function (PaneSplits) {
68
+ PaneSplits["VERTICAL"] = "vertical";
69
+ PaneSplits["HORIZONTAL"] = "horizontal";
70
+ })(PaneSplits || (PaneSplits = {}));
71
+ export const withSplitPane = (ComposedComponent) => {
72
+ class WithSplitPane extends React.PureComponent {
73
+ constructor(props) {
74
+ super(props);
75
+ this.state = {
76
+ paneSize: undefined,
77
+ maxPaneSize: undefined,
78
+ paneSplit: window.innerWidth > window.innerHeight
79
+ ? PaneSplits.VERTICAL
80
+ : PaneSplits.HORIZONTAL,
81
+ };
82
+ this.tooltipContainerRef = React.createRef();
83
+ this.rootRef = React.createRef();
84
+ this.setInitialState = (waitForFirstRedraw = false) => {
85
+ // @ts-ignore
86
+ if (!this.props.forwardedRef.current) {
87
+ return;
88
+ }
89
+ // @ts-ignore
90
+ const { chart } = this.props.forwardedRef.current;
91
+ const points = getPointsForInitialRefresh(chart);
92
+ chart.tooltip.refresh(points);
93
+ chart.pointsForInitialRefresh = points;
94
+ const callback = () => {
95
+ forceHoverState(chart, points);
96
+ };
97
+ if (this.state.paneSplit === PaneSplits.HORIZONTAL) {
98
+ this.setInitialPaneSize(callback);
99
+ }
100
+ else {
101
+ if (waitForFirstRedraw) {
102
+ chart.afterRedrawCallback = callback;
103
+ }
104
+ else {
105
+ callback();
106
+ }
107
+ }
108
+ };
109
+ this.afterCreateCallback = (chart) => {
110
+ chart.tooltip.splitTooltip = true;
111
+ chart.tooltip.getTooltipContainer = this.getTooltipContainer;
112
+ };
113
+ this.setInitialPaneSize = (callback) => {
114
+ if (!this.tooltipContainerRef.current || !this.rootRef.current) {
115
+ return;
116
+ }
117
+ const tooltipContentHeight = this.tooltipContainerRef.current.getBoundingClientRect().height;
118
+ const rootHeight = this.rootRef.current.getBoundingClientRect().height;
119
+ const maxPaneSize = rootHeight - MIN_TOOLTIP_SECTION_HEIGHT;
120
+ const currentDeviceHeight = window.innerHeight;
121
+ const otherParticipantsHeight = PANE_RESIZER_HEIGHT + (currentDeviceHeight - deviceWithNavBarHeight) + 1;
122
+ const paneSize = rootHeight - tooltipContentHeight - otherParticipantsHeight;
123
+ this.setState({
124
+ paneSize: paneSize > maxPaneSize ? maxPaneSize : paneSize,
125
+ maxPaneSize,
126
+ }, () => {
127
+ this.reflow();
128
+ setTimeout(callback, 0);
129
+ });
130
+ };
131
+ this.handleOrientationChange = () => {
132
+ const handleResizeAfterOrientationChange = () => {
133
+ const deviceWidth = window.innerWidth;
134
+ const deviceHeight = window.innerHeight;
135
+ this.setState({
136
+ paneSplit: deviceWidth > deviceHeight
137
+ ? PaneSplits.VERTICAL
138
+ : PaneSplits.HORIZONTAL,
139
+ }, () => {
140
+ this.setInitialState(true);
141
+ });
142
+ window.removeEventListener('resize', handleResizeAfterOrientationChange);
143
+ };
144
+ window.addEventListener('resize', handleResizeAfterOrientationChange);
145
+ };
146
+ this.reflow = () => {
147
+ // @ts-ignore
148
+ if (this.props.forwardedRef.current) {
149
+ // @ts-ignore
150
+ this.props.forwardedRef.current.chart.reflow();
151
+ }
152
+ };
153
+ this.handlePaneChange = (size) => {
154
+ this.setState({ paneSize: size });
155
+ // @ts-ignore
156
+ if (this.props.forwardedRef && this.props.forwardedRef.current) {
157
+ if (this.props.onPaneChange) {
158
+ this.props.onPaneChange();
159
+ }
160
+ this.reflow();
161
+ // @ts-ignore
162
+ const { chart } = this.props.forwardedRef.current;
163
+ if (chart && chart.pointsForInitialRefresh) {
164
+ const points = getPointsForInitialRefresh(chart);
165
+ forceHoverState(chart, points);
166
+ }
167
+ }
168
+ };
169
+ this.getTooltipContainer = () => {
170
+ return this.tooltipContainerRef.current;
171
+ };
172
+ this.debouncedHandlePaneChange = debounce(this.handlePaneChange, 500);
173
+ }
174
+ componentDidMount() {
175
+ window.addEventListener('orientationchange', this.handleOrientationChange);
176
+ // @ts-ignore
177
+ if (!this.props.forwardedRef.current) {
178
+ return;
179
+ }
180
+ if (this.props.onSplitPaneMountCallback) {
181
+ // @ts-ignore
182
+ this.props.onSplitPaneMountCallback(this.props.forwardedRef.current.chart);
183
+ }
184
+ this.setInitialState();
185
+ }
186
+ componentWillUnmount() {
187
+ window.removeEventListener('orientationchange', this.handleOrientationChange);
188
+ }
189
+ render() {
190
+ return (React.createElement("div", { className: b(), ref: this.rootRef }, this.state.paneSplit === PaneSplits.VERTICAL
191
+ ? this.renderVertical()
192
+ : this.renderHorizontal()));
193
+ }
194
+ renderHorizontal() {
195
+ const { paneSize, maxPaneSize } = this.state;
196
+ const thirdOfViewport = window.innerHeight / 3;
197
+ return (React.createElement(StyledSplitPane, { split: "horizontal", onChange: this.debouncedHandlePaneChange, minSize: thirdOfViewport, maxSize: maxPaneSize || undefined, size: paneSize, paneOneRender: () => (React.createElement(ComposedComponent, Object.assign({}, this.props, { ref: this.props.forwardedRef, callback: this.afterCreateCallback }))), paneTwoRender: () => React.createElement("div", { ref: this.tooltipContainerRef }) }));
198
+ }
199
+ renderVertical() {
200
+ const paneSize = window.innerWidth * CHART_SECTION_PERCENTAGE;
201
+ return (React.createElement(StyledSplitPane, { split: "vertical", allowResize: false, size: paneSize, paneOneRender: () => (React.createElement(ComposedComponent, Object.assign({}, this.props, { ref: this.props.forwardedRef, callback: this.afterCreateCallback }))), paneTwoRender: () => React.createElement("div", { ref: this.tooltipContainerRef }) }));
202
+ }
203
+ }
204
+ return React.forwardRef((props, ref) => {
205
+ return React.createElement(WithSplitPane, Object.assign({ forwardedRef: ref }, props));
206
+ });
207
+ };
@@ -0,0 +1 @@
1
+ export function addHolidays(chart: any, holidays: any): boolean;
@@ -0,0 +1,43 @@
1
+ const HALF_DAY = 43200000;
2
+ const calculateConsistentClosestPointRange = (type, closestPointRange, series) => {
3
+ const isDatetimeAxis = type === 'datetime';
4
+ return (isDatetimeAxis &&
5
+ closestPointRange === 86400000 &&
6
+ series.every(({ xData }) => {
7
+ let consistent = true;
8
+ for (let i = 2; i < xData.length - 1; i++) {
9
+ if ((xData[i] - xData[i - 1]) % closestPointRange !== 0) {
10
+ consistent = false;
11
+ break;
12
+ }
13
+ }
14
+ return consistent;
15
+ }));
16
+ };
17
+ export function addHolidays(chart, holidays) {
18
+ const { userOptions: { _config: { region: configRegion = 'TOT' } = {} }, xAxis: [xAxis], } = chart;
19
+ const { dataMin, dataMax, closestPointRange, series } = xAxis;
20
+ const isConsistentClosestPointRange = calculateConsistentClosestPointRange(xAxis.options.type, closestPointRange, series);
21
+ let needRedraw = false;
22
+ if (isConsistentClosestPointRange) {
23
+ const region = configRegion.toLowerCase();
24
+ for (let passed = 0; dataMin + passed <= dataMax; passed += closestPointRange) {
25
+ const timestamp = dataMin + passed;
26
+ const pointDate = Number(chart.time.dateFormat('%Y%m%d', timestamp));
27
+ const holidayByRegion = holidays.holiday[region];
28
+ const weekendByRegion = holidays.weekend[region];
29
+ if ((holidayByRegion && holidayByRegion[pointDate]) ||
30
+ (weekendByRegion && weekendByRegion[pointDate])) {
31
+ const bandStart = timestamp - HALF_DAY;
32
+ const bandStop = timestamp + HALF_DAY;
33
+ xAxis.addPlotBand({
34
+ color: 'var(--highcharts-holiday-band)',
35
+ from: bandStart,
36
+ to: bandStop,
37
+ });
38
+ needRedraw = true;
39
+ }
40
+ }
41
+ }
42
+ return needRedraw;
43
+ }
@@ -0,0 +1,11 @@
1
+ export function extendComment({ meta, ...rest }: {
2
+ [x: string]: any;
3
+ meta: any;
4
+ }, chart: any): any;
5
+ export function drawComments(chart: any, comments: any, settings: any, force: any): void;
6
+ export function drawOnlyRendererComments(chart: any, comments: any[] | undefined, settings: any): void;
7
+ export function hideComments(chart: any, comments: any, settings: any, force: any): void;
8
+ export function getCommentsOnLine(xLine: any, comments: any, chart: any): {
9
+ xComments: any[];
10
+ xyComments: any[];
11
+ };