@wonderflow/charts 12.8.0

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 (259) hide show
  1. package/dist/components/cartesian-base/cartesian-base-axis.d.ts +15 -0
  2. package/dist/components/cartesian-base/cartesian-base-axis.d.ts.map +1 -0
  3. package/dist/components/cartesian-base/cartesian-base-axis.js +53 -0
  4. package/dist/components/cartesian-base/cartesian-base-grid.d.ts +23 -0
  5. package/dist/components/cartesian-base/cartesian-base-grid.d.ts.map +1 -0
  6. package/dist/components/cartesian-base/cartesian-base-grid.js +35 -0
  7. package/dist/components/cartesian-base/cartesian-base-legend.d.ts +7 -0
  8. package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -0
  9. package/dist/components/cartesian-base/cartesian-base-legend.js +35 -0
  10. package/dist/components/cartesian-base/cartesian-base.d.ts +78 -0
  11. package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -0
  12. package/dist/components/cartesian-base/cartesian-base.js +98 -0
  13. package/dist/components/cartesian-base/cartesian-base.module.css +1 -0
  14. package/dist/components/cartesian-base/cartesian-base.test.d.ts +2 -0
  15. package/dist/components/cartesian-base/cartesian-base.test.d.ts.map +1 -0
  16. package/dist/components/cartesian-base/cartesian-base.test.js +51 -0
  17. package/dist/components/cartesian-base/index.d.ts +3 -0
  18. package/dist/components/cartesian-base/index.d.ts.map +1 -0
  19. package/dist/components/cartesian-base/index.js +16 -0
  20. package/dist/components/empty-state/empty-state.d.ts +16 -0
  21. package/dist/components/empty-state/empty-state.d.ts.map +1 -0
  22. package/dist/components/empty-state/empty-state.js +31 -0
  23. package/dist/components/empty-state/empty-state.test.d.ts +2 -0
  24. package/dist/components/empty-state/empty-state.test.d.ts.map +1 -0
  25. package/dist/components/empty-state/empty-state.test.js +67 -0
  26. package/dist/components/empty-state/index.d.ts +2 -0
  27. package/dist/components/empty-state/index.d.ts.map +1 -0
  28. package/dist/components/empty-state/index.js +16 -0
  29. package/dist/components/headings/headings.d.ts +27 -0
  30. package/dist/components/headings/headings.d.ts.map +1 -0
  31. package/dist/components/headings/headings.js +31 -0
  32. package/dist/components/headings/headings.test.d.ts +2 -0
  33. package/dist/components/headings/headings.test.d.ts.map +1 -0
  34. package/dist/components/headings/headings.test.js +14 -0
  35. package/dist/components/headings/index.d.ts +3 -0
  36. package/dist/components/headings/index.d.ts.map +1 -0
  37. package/dist/components/headings/index.js +16 -0
  38. package/dist/components/index.d.ts +7 -0
  39. package/dist/components/index.d.ts.map +1 -0
  40. package/dist/components/index.js +21 -0
  41. package/dist/components/line-chart/index.d.ts +3 -0
  42. package/dist/components/line-chart/index.d.ts.map +1 -0
  43. package/dist/components/line-chart/index.js +16 -0
  44. package/dist/components/line-chart/line-chart.d.ts +57 -0
  45. package/dist/components/line-chart/line-chart.d.ts.map +1 -0
  46. package/dist/components/line-chart/line-chart.js +68 -0
  47. package/dist/components/line-chart/line-chart.test.d.ts +2 -0
  48. package/dist/components/line-chart/line-chart.test.d.ts.map +1 -0
  49. package/dist/components/line-chart/line-chart.test.js +20 -0
  50. package/dist/components/loader/bar-chart-loader.d.ts +11 -0
  51. package/dist/components/loader/bar-chart-loader.d.ts.map +1 -0
  52. package/dist/components/loader/bar-chart-loader.js +3 -0
  53. package/dist/components/loader/index.d.ts +2 -0
  54. package/dist/components/loader/index.d.ts.map +1 -0
  55. package/dist/components/loader/index.js +16 -0
  56. package/dist/components/loader/line-chart-loader.d.ts +11 -0
  57. package/dist/components/loader/line-chart-loader.d.ts.map +1 -0
  58. package/dist/components/loader/line-chart-loader.js +3 -0
  59. package/dist/components/loader/loader.d.ts +10 -0
  60. package/dist/components/loader/loader.d.ts.map +1 -0
  61. package/dist/components/loader/loader.js +35 -0
  62. package/dist/components/loader/loader.test.d.ts +2 -0
  63. package/dist/components/loader/loader.test.d.ts.map +1 -0
  64. package/dist/components/loader/loader.test.js +50 -0
  65. package/dist/components/placeholder/index.d.ts +3 -0
  66. package/dist/components/placeholder/index.d.ts.map +1 -0
  67. package/dist/components/placeholder/index.js +16 -0
  68. package/dist/components/placeholder/placeholder.d.ts +9 -0
  69. package/dist/components/placeholder/placeholder.d.ts.map +1 -0
  70. package/dist/components/placeholder/placeholder.js +19 -0
  71. package/dist/components/placeholder/placeholder.test.d.ts +2 -0
  72. package/dist/components/placeholder/placeholder.test.d.ts.map +1 -0
  73. package/dist/components/placeholder/placeholder.test.js +15 -0
  74. package/dist/components/shapes/index.d.ts +2 -0
  75. package/dist/components/shapes/index.d.ts.map +1 -0
  76. package/dist/components/shapes/index.js +16 -0
  77. package/dist/components/shapes/lines/index.d.ts +2 -0
  78. package/dist/components/shapes/lines/index.d.ts.map +1 -0
  79. package/dist/components/shapes/lines/index.js +16 -0
  80. package/dist/components/shapes/lines/lines-marker-labels.d.ts +3 -0
  81. package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -0
  82. package/dist/components/shapes/lines/lines-marker-labels.js +72 -0
  83. package/dist/components/shapes/lines/lines-overlay.d.ts +3 -0
  84. package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -0
  85. package/dist/components/shapes/lines/lines-overlay.js +52 -0
  86. package/dist/components/shapes/lines/lines-series.d.ts +3 -0
  87. package/dist/components/shapes/lines/lines-series.d.ts.map +1 -0
  88. package/dist/components/shapes/lines/lines-series.js +58 -0
  89. package/dist/components/shapes/lines/lines-tooltip.d.ts +3 -0
  90. package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -0
  91. package/dist/components/shapes/lines/lines-tooltip.js +107 -0
  92. package/dist/components/shapes/lines/lines.d.ts +3 -0
  93. package/dist/components/shapes/lines/lines.d.ts.map +1 -0
  94. package/dist/components/shapes/lines/lines.js +28 -0
  95. package/dist/components/shapes/lines/lines.module.css +1 -0
  96. package/dist/components/shapes/lines/lines.test.d.ts +2 -0
  97. package/dist/components/shapes/lines/lines.test.d.ts.map +1 -0
  98. package/dist/components/shapes/lines/lines.test.js +142 -0
  99. package/dist/components/tooltip/index.d.ts +3 -0
  100. package/dist/components/tooltip/index.d.ts.map +1 -0
  101. package/dist/components/tooltip/index.js +16 -0
  102. package/dist/components/tooltip/tooltip.d.ts +35 -0
  103. package/dist/components/tooltip/tooltip.d.ts.map +1 -0
  104. package/dist/components/tooltip/tooltip.js +37 -0
  105. package/dist/components/tooltip/tooltip.module.css +1 -0
  106. package/dist/components/tooltip/tooltip.test.d.ts +2 -0
  107. package/dist/components/tooltip/tooltip.test.d.ts.map +1 -0
  108. package/dist/components/tooltip/tooltip.test.js +20 -0
  109. package/dist/index.d.ts +5 -0
  110. package/dist/index.d.ts.map +1 -0
  111. package/dist/index.js +19 -0
  112. package/dist/providers/cartesian.d.ts +20 -0
  113. package/dist/providers/cartesian.d.ts.map +1 -0
  114. package/dist/providers/cartesian.js +43 -0
  115. package/dist/providers/data.d.ts +11 -0
  116. package/dist/providers/data.d.ts.map +1 -0
  117. package/dist/providers/data.js +32 -0
  118. package/dist/providers/index.d.ts +6 -0
  119. package/dist/providers/index.d.ts.map +1 -0
  120. package/dist/providers/index.js +20 -0
  121. package/dist/providers/layout.d.ts +14 -0
  122. package/dist/providers/layout.d.ts.map +1 -0
  123. package/dist/providers/layout.js +34 -0
  124. package/dist/providers/style-config.d.ts +11 -0
  125. package/dist/providers/style-config.d.ts.map +1 -0
  126. package/dist/providers/style-config.js +29 -0
  127. package/dist/providers/theme.d.ts +10 -0
  128. package/dist/providers/theme.d.ts.map +1 -0
  129. package/dist/providers/theme.js +29 -0
  130. package/dist/style-config/axis.d.ts +3 -0
  131. package/dist/style-config/axis.d.ts.map +1 -0
  132. package/dist/style-config/axis.js +86 -0
  133. package/dist/style-config/cartesian.d.ts +3 -0
  134. package/dist/style-config/cartesian.d.ts.map +1 -0
  135. package/dist/style-config/cartesian.js +31 -0
  136. package/dist/style-config/colors.d.ts +9 -0
  137. package/dist/style-config/colors.d.ts.map +1 -0
  138. package/dist/style-config/colors.js +271 -0
  139. package/dist/style-config/grid.d.ts +7 -0
  140. package/dist/style-config/grid.d.ts.map +1 -0
  141. package/dist/style-config/grid.js +24 -0
  142. package/dist/style-config/headings.d.ts +3 -0
  143. package/dist/style-config/headings.d.ts.map +1 -0
  144. package/dist/style-config/headings.js +39 -0
  145. package/dist/style-config/index.d.ts +10 -0
  146. package/dist/style-config/index.d.ts.map +1 -0
  147. package/dist/style-config/index.js +24 -0
  148. package/dist/style-config/legend.d.ts +3 -0
  149. package/dist/style-config/legend.d.ts.map +1 -0
  150. package/dist/style-config/legend.js +18 -0
  151. package/dist/style-config/linear-gradient.d.ts +3 -0
  152. package/dist/style-config/linear-gradient.d.ts.map +1 -0
  153. package/dist/style-config/linear-gradient.js +20 -0
  154. package/dist/style-config/lines.d.ts +3 -0
  155. package/dist/style-config/lines.d.ts.map +1 -0
  156. package/dist/style-config/lines.js +39 -0
  157. package/dist/style-config/themes.d.ts +5 -0
  158. package/dist/style-config/themes.d.ts.map +1 -0
  159. package/dist/style-config/themes.js +86 -0
  160. package/dist/style-config/tooltip.d.ts +8 -0
  161. package/dist/style-config/tooltip.d.ts.map +1 -0
  162. package/dist/style-config/tooltip.js +56 -0
  163. package/dist/style-config/viewport.d.ts +3 -0
  164. package/dist/style-config/viewport.d.ts.map +1 -0
  165. package/dist/style-config/viewport.js +30 -0
  166. package/dist/types/axis.d.ts +108 -0
  167. package/dist/types/axis.d.ts.map +1 -0
  168. package/dist/types/axis.js +16 -0
  169. package/dist/types/cartesian.d.ts +58 -0
  170. package/dist/types/cartesian.d.ts.map +1 -0
  171. package/dist/types/cartesian.js +20 -0
  172. package/dist/types/colors.d.ts +9 -0
  173. package/dist/types/colors.d.ts.map +1 -0
  174. package/dist/types/colors.js +16 -0
  175. package/dist/types/grid.d.ts +14 -0
  176. package/dist/types/grid.d.ts.map +1 -0
  177. package/dist/types/grid.js +1 -0
  178. package/dist/types/headings.d.ts +26 -0
  179. package/dist/types/headings.d.ts.map +1 -0
  180. package/dist/types/headings.js +16 -0
  181. package/dist/types/index.d.ts +13 -0
  182. package/dist/types/index.d.ts.map +1 -0
  183. package/dist/types/index.js +27 -0
  184. package/dist/types/legend.d.ts +4 -0
  185. package/dist/types/legend.d.ts.map +1 -0
  186. package/dist/types/legend.js +16 -0
  187. package/dist/types/line-chart.d.ts +53 -0
  188. package/dist/types/line-chart.d.ts.map +1 -0
  189. package/dist/types/line-chart.js +16 -0
  190. package/dist/types/linear-gradient.d.ts +5 -0
  191. package/dist/types/linear-gradient.d.ts.map +1 -0
  192. package/dist/types/linear-gradient.js +16 -0
  193. package/dist/types/lines.d.ts +25 -0
  194. package/dist/types/lines.d.ts.map +1 -0
  195. package/dist/types/lines.js +16 -0
  196. package/dist/types/main.d.ts +11 -0
  197. package/dist/types/main.d.ts.map +1 -0
  198. package/dist/types/main.js +20 -0
  199. package/dist/types/themes.d.ts +31 -0
  200. package/dist/types/themes.d.ts.map +1 -0
  201. package/dist/types/themes.js +16 -0
  202. package/dist/types/tooltip.d.ts +23 -0
  203. package/dist/types/tooltip.d.ts.map +1 -0
  204. package/dist/types/tooltip.js +16 -0
  205. package/dist/types/viewport.d.ts +8 -0
  206. package/dist/types/viewport.d.ts.map +1 -0
  207. package/dist/types/viewport.js +16 -0
  208. package/dist/utils/axis.d.ts +60 -0
  209. package/dist/utils/axis.d.ts.map +1 -0
  210. package/dist/utils/axis.js +401 -0
  211. package/dist/utils/axis.test.d.ts +2 -0
  212. package/dist/utils/axis.test.d.ts.map +1 -0
  213. package/dist/utils/axis.test.js +1071 -0
  214. package/dist/utils/colors.d.ts +8 -0
  215. package/dist/utils/colors.d.ts.map +1 -0
  216. package/dist/utils/colors.js +33 -0
  217. package/dist/utils/colors.test.d.ts +2 -0
  218. package/dist/utils/colors.test.d.ts.map +1 -0
  219. package/dist/utils/colors.test.js +31 -0
  220. package/dist/utils/data.d.ts +14 -0
  221. package/dist/utils/data.d.ts.map +1 -0
  222. package/dist/utils/data.js +116 -0
  223. package/dist/utils/data.test.d.ts +2 -0
  224. package/dist/utils/data.test.d.ts.map +1 -0
  225. package/dist/utils/data.test.js +371 -0
  226. package/dist/utils/format.d.ts +15 -0
  227. package/dist/utils/format.d.ts.map +1 -0
  228. package/dist/utils/format.js +41 -0
  229. package/dist/utils/format.test.d.ts +2 -0
  230. package/dist/utils/format.test.d.ts.map +1 -0
  231. package/dist/utils/format.test.js +101 -0
  232. package/dist/utils/index.d.ts +8 -0
  233. package/dist/utils/index.d.ts.map +1 -0
  234. package/dist/utils/index.js +22 -0
  235. package/dist/utils/lines.d.ts +52 -0
  236. package/dist/utils/lines.d.ts.map +1 -0
  237. package/dist/utils/lines.js +190 -0
  238. package/dist/utils/lines.test.d.ts +2 -0
  239. package/dist/utils/lines.test.d.ts.map +1 -0
  240. package/dist/utils/lines.test.js +498 -0
  241. package/dist/utils/math.d.ts +13 -0
  242. package/dist/utils/math.d.ts.map +1 -0
  243. package/dist/utils/math.js +89 -0
  244. package/dist/utils/math.test.d.ts +2 -0
  245. package/dist/utils/math.test.d.ts.map +1 -0
  246. package/dist/utils/math.test.js +142 -0
  247. package/dist/utils/metadata.d.ts +6 -0
  248. package/dist/utils/metadata.d.ts.map +1 -0
  249. package/dist/utils/metadata.js +36 -0
  250. package/dist/utils/metadata.test.d.ts +2 -0
  251. package/dist/utils/metadata.test.d.ts.map +1 -0
  252. package/dist/utils/metadata.test.js +102 -0
  253. package/dist/utils/viewport.d.ts +3 -0
  254. package/dist/utils/viewport.d.ts.map +1 -0
  255. package/dist/utils/viewport.js +29 -0
  256. package/dist/utils/viewport.test.d.ts +2 -0
  257. package/dist/utils/viewport.test.d.ts.map +1 -0
  258. package/dist/utils/viewport.test.js +63 -0
  259. package/package.json +106 -0
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2023 Wonderflow Design Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { Lines } from './lines';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const LinesMarkerLabels: React.FC;
3
+ //# sourceMappingURL=lines-marker-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines-marker-labels.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/lines/lines-marker-labels.tsx"],"names":[],"mappings":";AAkCA,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EA4IrC,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Label } from '@visx/annotation';
18
+ import { Group } from '@visx/group';
19
+ import { v4 as uuid } from 'uuid';
20
+ import { useCartesianContext, useDataContext, useLayoutContext, useThemeContext, } from '../../../providers';
21
+ import { themes } from '../../../style-config';
22
+ import { getCoordinates, getMarkerLabelProps, getPrimitiveFromObjectByPath, isMarkerLabelVisible, } from '../../../utils';
23
+ import { LinesItem, } from './lines.module.css';
24
+ export const LinesMarkerLabels = () => {
25
+ const theme = useThemeContext();
26
+ const { data, metadata } = useDataContext();
27
+ const { isHorizontal } = useLayoutContext();
28
+ const { axis, dimension } = useCartesianContext();
29
+ const { index, showMarkerLabel, series, overlay, } = metadata;
30
+ const indexAxis = isHorizontal ? axis.bottom : axis.left;
31
+ const seriesAxis = isHorizontal ? axis.left : axis.bottom;
32
+ const overlayAxis = isHorizontal ? axis?.right : axis?.top;
33
+ const hasOverlay = Boolean(overlayAxis && overlay.dataKey);
34
+ const themeConfig = themes[theme];
35
+ const totalLabels = data.length;
36
+ const getSeriesCoordinates = (datum, dataKey, isHorizontal) => getCoordinates({
37
+ datum,
38
+ indexAxis: indexAxis,
39
+ indexDataKey: index,
40
+ otherAxis: seriesAxis,
41
+ otherDataKey: dataKey,
42
+ isHorizontal,
43
+ });
44
+ const getOverlayCoordinates = (datum, dataKey, isHorizontal) => getCoordinates({
45
+ datum,
46
+ indexAxis: indexAxis,
47
+ indexDataKey: index,
48
+ otherAxis: overlayAxis,
49
+ otherDataKey: dataKey,
50
+ isHorizontal,
51
+ });
52
+ return (_jsxs(_Fragment, { children: [series.dataKey.map((k, i) => (_jsx(Group, { className: LinesItem, children: (showMarkerLabel || series.style?.[i]?.showMarkerLabel)
53
+ && data.map((d, di) => {
54
+ const isVisible = isMarkerLabelVisible(di, totalLabels);
55
+ const title = `${getPrimitiveFromObjectByPath(d, k) ?? ''}`;
56
+ const coordinates = getSeriesCoordinates(d, k, isHorizontal);
57
+ const markerLabelProps = getMarkerLabelProps(coordinates, dimension, isHorizontal, themeConfig);
58
+ const { background, fontColor, fontSize, fontWeight, titleProps, anchor, verticalAnchor, padding, backgroundProps, } = markerLabelProps;
59
+ return (isVisible
60
+ ? (_jsx(Label, { "data-testid": "lines-marker-label", backgroundFill: background, x: coordinates.x, y: coordinates.y, fontColor: fontColor, title: title, titleFontSize: fontSize, titleFontWeight: fontWeight, titleProps: titleProps, showAnchorLine: false, horizontalAnchor: anchor, verticalAnchor: verticalAnchor, showBackground: true, backgroundPadding: padding, backgroundProps: backgroundProps }, uuid())) : null);
61
+ }) }, uuid()))), hasOverlay && (showMarkerLabel || overlay.style?.showMarkerLabel)
62
+ && data.map((d, di) => {
63
+ const isVisible = isMarkerLabelVisible(di, totalLabels);
64
+ const title = `${getPrimitiveFromObjectByPath(d, overlay.dataKey) ?? ''}`;
65
+ const coordinates = getOverlayCoordinates(d, overlay.dataKey, isHorizontal);
66
+ const markerLabelProps = getMarkerLabelProps(coordinates, dimension, isHorizontal, themeConfig);
67
+ const { background, fontColor, fontSize, fontWeight, titleProps, anchor, verticalAnchor, padding, backgroundProps, } = markerLabelProps;
68
+ return (isVisible
69
+ ? (_jsx(Label, { backgroundFill: background, x: coordinates.x, y: coordinates.y, fontColor: fontColor, title: title, titleFontSize: fontSize, titleFontWeight: fontWeight, titleProps: titleProps, showAnchorLine: false, horizontalAnchor: anchor, verticalAnchor: verticalAnchor, showBackground: true, backgroundPadding: padding, backgroundProps: backgroundProps }, uuid())) : null);
70
+ })] }));
71
+ };
72
+ LinesMarkerLabels.displayName = 'LinesMarkerLabels';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const LinesOverlay: React.FC;
3
+ //# sourceMappingURL=lines-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines-overlay.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/lines/lines-overlay.tsx"],"names":[],"mappings":";AAiCA,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAiFhC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Group } from '@visx/group';
18
+ import { LinePath } from '@visx/shape';
19
+ import _ from 'lodash';
20
+ import { useMemo } from 'react';
21
+ import { v4 as uuid } from 'uuid';
22
+ import { useCartesianContext, useDataContext, useLayoutContext, useStyleConfigContext, useThemeContext, } from '../../../providers';
23
+ import { createSubPaths, getCoordinates, getLinesRenderer, getValueFromObjectByPath, } from '../../../utils';
24
+ import { LinesItem, } from './lines.module.css';
25
+ export const LinesOverlay = () => {
26
+ const theme = useThemeContext();
27
+ const { lines: defaultStyle, themes } = useStyleConfigContext();
28
+ const { data, metadata } = useDataContext();
29
+ const { isHorizontal } = useLayoutContext();
30
+ const { axis } = useCartesianContext();
31
+ const { index, renderAs, showMarker, showMarkerLabel, overlay, hideMissingDataConnection, } = metadata;
32
+ const indexAxis = isHorizontal ? axis.bottom : axis.left;
33
+ const overlayAxis = isHorizontal ? axis?.right : axis?.top;
34
+ const hasOverlay = Boolean(overlayAxis && overlay.dataKey);
35
+ const renderer = useMemo(() => getLinesRenderer(renderAs, isHorizontal), [isHorizontal, renderAs]);
36
+ const getOverlayCoordinates = useMemo(() => (datum, dataKey, isHorizontal) => getCoordinates({
37
+ datum,
38
+ indexAxis,
39
+ indexDataKey: index,
40
+ otherAxis: overlayAxis,
41
+ otherDataKey: dataKey,
42
+ isHorizontal,
43
+ }), [index, indexAxis, overlayAxis]);
44
+ const subPaths = useMemo(() => createSubPaths(data, d => hasOverlay && _.isNil(getValueFromObjectByPath(d, overlay.dataKey))), [data, hasOverlay, overlay.dataKey]);
45
+ const hasMarker = Boolean(showMarker
46
+ || showMarkerLabel
47
+ || overlay.style?.showMarker
48
+ || overlay.style?.showMarkerLabel);
49
+ const segmentStroke = hideMissingDataConnection ? 'transparent' : themes[theme].lines.noData;
50
+ return (_jsx(_Fragment, { children: hasOverlay && (subPaths.map((subPathData, si) => (_jsxs(Group, { className: LinesItem, children: [_jsx(LinePath, { "data-testid": "lines-overlay", data: subPathData, curve: renderer, x: datum => getOverlayCoordinates(datum, overlay.dataKey, isHorizontal).x, y: datum => getOverlayCoordinates(datum, overlay.dataKey, isHorizontal).y, stroke: si % 2 === 0 ? overlay.color : segmentStroke, strokeWidth: overlay.style?.strokeWidth ?? defaultStyle.path.strokeWidth, strokeOpacity: overlay.style?.strokeOpacity ?? defaultStyle.path.strokeOpacity, strokeDasharray: si % 2 === 0 ? overlay.style?.strokeDasharray : defaultStyle.segment.strokeDashArray }), hasMarker && subPathData.map((d) => (_jsx("circle", { r: defaultStyle.marker.radius, cx: getOverlayCoordinates(d, overlay.dataKey, isHorizontal).x, cy: getOverlayCoordinates(d, overlay.dataKey, isHorizontal).y, stroke: overlay.color, fill: themes[theme].marker.fill, strokeWidth: overlay.style?.strokeWidth ?? defaultStyle.marker.strokeWidth, strokeOpacity: overlay.style?.strokeOpacity ?? defaultStyle.marker.strokeOpacity }, uuid())))] }, uuid())))) }));
51
+ };
52
+ LinesOverlay.displayName = 'LinesOverlay';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const LinesSeries: React.FC;
3
+ //# sourceMappingURL=lines-series.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines-series.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/lines/lines-series.tsx"],"names":[],"mappings":";AAiCA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAyF/B,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Group } from '@visx/group';
18
+ import { LinePath } from '@visx/shape';
19
+ import _ from 'lodash';
20
+ import { useMemo } from 'react';
21
+ import { v4 as uuid } from 'uuid';
22
+ import { useCartesianContext, useDataContext, useLayoutContext, useStyleConfigContext, useThemeContext, } from '../../../providers';
23
+ import { createSubPaths, getCoordinates, getLinesRenderer, getValueFromObjectByPath, } from '../../../utils';
24
+ import { LinesItem, } from './lines.module.css';
25
+ export const LinesSeries = () => {
26
+ const theme = useThemeContext();
27
+ const { lines: defaultStyle, themes } = useStyleConfigContext();
28
+ const { data, metadata } = useDataContext();
29
+ const { isHorizontal } = useLayoutContext();
30
+ const { axis } = useCartesianContext();
31
+ const { left, bottom } = axis;
32
+ const { index, renderAs, showMarker, showMarkerLabel, series, hideMissingDataConnection, } = metadata;
33
+ const indexAxis = isHorizontal ? bottom : left;
34
+ const seriesAxis = isHorizontal ? left : bottom;
35
+ const renderer = useMemo(() => getLinesRenderer(renderAs, isHorizontal), [isHorizontal, renderAs]);
36
+ const getSeriesCoordinates = (datum, dataKey, isHorizontal) => getCoordinates({
37
+ datum,
38
+ indexAxis: indexAxis,
39
+ indexDataKey: index,
40
+ otherAxis: seriesAxis,
41
+ otherDataKey: dataKey,
42
+ isHorizontal,
43
+ });
44
+ return (_jsx(_Fragment, { children: series.dataKey.map((dataKey, di) => {
45
+ const subPaths = createSubPaths(data, d => _.isNil(getValueFromObjectByPath(d, dataKey)));
46
+ const hasMarker = Boolean(showMarker
47
+ || showMarkerLabel
48
+ || series.style?.[di]?.showMarker
49
+ || series.style?.[di]?.showMarkerLabel);
50
+ const segmentStroke = hideMissingDataConnection ? 'transparent' : themes[theme].lines.noData;
51
+ return (subPaths.map((subPathData, si) => (_jsxs(Group, { className: LinesItem, children: [_jsx(LinePath, { "data-testid": "lines-series", data: subPathData, curve: renderer, x: datum => getSeriesCoordinates(datum, dataKey, isHorizontal).x, y: datum => getSeriesCoordinates(datum, dataKey, isHorizontal).y, stroke: si % 2 === 0
52
+ ? series.colors[di]
53
+ : segmentStroke, strokeWidth: series.style?.[di]?.strokeWidth ?? defaultStyle.path.strokeWidth, strokeOpacity: series.style?.[di]?.strokeOpacity ?? defaultStyle.path.strokeOpacity, strokeDasharray: si % 2 === 0
54
+ ? series.style?.[di]?.strokeDasharray
55
+ : defaultStyle.segment.strokeDashArray }), hasMarker && subPathData.map((d) => (_jsx("circle", { r: defaultStyle.marker.radius, cx: getSeriesCoordinates(d, dataKey, isHorizontal).x, cy: getSeriesCoordinates(d, dataKey, isHorizontal).y, stroke: series.colors[di], fill: themes[theme].marker.fill, strokeWidth: series.style?.[di]?.strokeWidth ?? defaultStyle.marker.strokeWidth, strokeOpacity: series.style?.[di]?.strokeOpacity ?? defaultStyle.marker.strokeOpacity }, uuid())))] }, uuid()))));
56
+ }) }));
57
+ };
58
+ LinesSeries.displayName = 'LinesSeries';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const LinesTooltip: React.FC;
3
+ //# sourceMappingURL=lines-tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines-tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/lines/lines-tooltip.tsx"],"names":[],"mappings":";AA6CA,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAyPhC,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
18
+ /* eslint-disable @typescript-eslint/naming-convention */
19
+ // @ts-nocheck
20
+ import { localPoint } from '@visx/event';
21
+ import { Group } from '@visx/group';
22
+ import { Line } from '@visx/shape';
23
+ import { useTooltip, useTooltipInPortal } from '@visx/tooltip';
24
+ import _ from 'lodash';
25
+ import { useCallback } from 'react';
26
+ import { v4 as uuid } from 'uuid';
27
+ import { useCartesianContext, useDataContext, useLayoutContext, useStyleConfigContext, useThemeContext, } from '../../../providers';
28
+ import { tooltipTheme } from '../../../style-config/tooltip';
29
+ import { accessorInvert, bisectIndex, getLabelFromPath, getPrimitiveFromObjectByPath, } from '../../../utils';
30
+ import { Placeholder } from '../../placeholder';
31
+ import { Tooltip } from '../../tooltip';
32
+ import { ExtraContent, LinesTooltipContent, LinesTooltipItem, NoData, } from './lines.module.css';
33
+ export const LinesTooltip = () => {
34
+ const theme = useThemeContext();
35
+ const { lines: defaultStyle } = useStyleConfigContext();
36
+ const { data, metadata } = useDataContext();
37
+ const { isHorizontal } = useLayoutContext();
38
+ const { axis, dimension } = useCartesianContext();
39
+ const { maxHeight: yMax, maxWidth: xMax } = dimension;
40
+ const { top, right, bottom, left, } = axis;
41
+ const { index, tooltip, series, overlay, } = metadata;
42
+ const indexAxis = isHorizontal ? bottom : left;
43
+ const seriesAxis = isHorizontal ? left : bottom;
44
+ const overlayAxis = isHorizontal ? right : top;
45
+ const hasOverlay = Boolean(overlayAxis && overlay.dataKey);
46
+ const { tooltipLeft, tooltipTop, tooltipOpen, tooltipData, hideTooltip, showTooltip, } = useTooltip();
47
+ const { containerRef, containerBounds } = useTooltipInPortal({
48
+ detectBounds: true,
49
+ scroll: true,
50
+ debounce: 500,
51
+ zIndex: 10,
52
+ });
53
+ const handleTooltip = useCallback((event) => {
54
+ const { scaleType, domain, scale, } = indexAxis;
55
+ const { top: tBound, left: lBound } = containerBounds;
56
+ const hiddenPos = { x: -999, y: -999 };
57
+ const xy = isHorizontal ? 'x' : 'y';
58
+ const coords = localPoint(event.target.ownerSVGElement, event) ?? hiddenPos;
59
+ const accessorInvertValue = accessorInvert(indexAxis, coords[xy]);
60
+ const indexOfBisectValue = scaleType === 'label'
61
+ ? domain.indexOf(accessorInvertValue)
62
+ : bisectIndex(domain, accessorInvertValue, 0) - 1;
63
+ const domainIndexValue = domain[indexOfBisectValue];
64
+ const indexScaleValue = scaleType === 'label'
65
+ ? accessorInvertValue
66
+ : new Date(domainIndexValue);
67
+ const lineIndicatorPos = scale(indexScaleValue);
68
+ const tooltipLeft = isHorizontal
69
+ ? (coords.x + lBound / 8)
70
+ : coords.x;
71
+ const tooltipTop = isHorizontal
72
+ ? coords.y
73
+ : (coords.y + tBound / 8);
74
+ const datum = data[indexOfBisectValue];
75
+ const hasSeriesData = series.dataKey.every(s => !_.isNil(getPrimitiveFromObjectByPath(datum, s)));
76
+ const hasOverlayData = !_.isNil(getPrimitiveFromObjectByPath(datum, overlay.dataKey));
77
+ const tooltipData = {
78
+ coords,
79
+ data: datum,
80
+ hasData: hasSeriesData || hasOverlayData,
81
+ lineIndicatorPos,
82
+ };
83
+ showTooltip({
84
+ tooltipLeft,
85
+ tooltipTop,
86
+ tooltipData,
87
+ });
88
+ }, [indexAxis, containerBounds, isHorizontal, data, series.dataKey, overlay.dataKey, showTooltip]);
89
+ return (_jsxs(_Fragment, { children: [_jsx("rect", { id: "transparent-overlay-layer", "data-testid": "transparent-overlay-layer", x: -5, y: -5, width: xMax + 10, height: yMax + 10, fill: "transparent", ref: containerRef, onMouseMove: e => handleTooltip(e), onTouchMove: e => handleTooltip(e), onTouchStart: e => handleTooltip(e), onMouseOut: hideTooltip, onMouseLeave: hideTooltip }), tooltipData?.data && (_jsxs(_Fragment, { children: [_jsxs(Group, { children: [_jsx(Line, { from: {
90
+ x: isHorizontal ? tooltipData.lineIndicatorPos : 0,
91
+ y: isHorizontal ? 0 : tooltipData.lineIndicatorPos,
92
+ }, to: {
93
+ x: isHorizontal ? tooltipData.lineIndicatorPos : xMax,
94
+ y: isHorizontal ? yMax : tooltipData.lineIndicatorPos,
95
+ }, stroke: tooltipTheme[theme].lineIndicatorStroke, strokeWidth: defaultStyle.lineIndicator.strokeWidth, opacity: defaultStyle.lineIndicator.opacity, pointerEvents: defaultStyle.lineIndicator.pointerEvents, strokeDasharray: defaultStyle.lineIndicator.strokeDasharray }), series.dataKey.map((dataKey, di) => (tooltipData.data[dataKey] && (_jsx("circle", { r: defaultStyle.dataPoint.radius, cx: isHorizontal
96
+ ? tooltipData.lineIndicatorPos
97
+ : seriesAxis.scale(getPrimitiveFromObjectByPath(tooltipData.data, dataKey)), cy: isHorizontal
98
+ ? seriesAxis.scale(getPrimitiveFromObjectByPath(tooltipData.data, dataKey))
99
+ : tooltipData.lineIndicatorPos, stroke: series.colors[di], fill: series.colors[di], strokeWidth: defaultStyle.dataPoint.strokeWidth }, uuid())))), hasOverlay && tooltipData.data[overlay.dataKey] && (_jsx("circle", { r: defaultStyle.dataPoint.radius, cx: isHorizontal
100
+ ? tooltipData.lineIndicatorPos
101
+ : overlayAxis?.scale(getPrimitiveFromObjectByPath(tooltipData.data, overlay.dataKey)), cy: isHorizontal
102
+ ? overlayAxis?.scale(getPrimitiveFromObjectByPath(tooltipData.data, overlay.dataKey))
103
+ : tooltipData.lineIndicatorPos, stroke: overlay.color, fill: overlay.color, strokeWidth: defaultStyle.dataPoint.strokeWidth }))] }), _jsxs(Tooltip, { theme: theme, isOpen: tooltipOpen, top: tooltipTop, left: tooltipLeft, children: [_jsxs("div", { className: LinesTooltipContent, "data-testid": "tooltip", children: [_jsx("p", { children: _jsx("b", { children: indexAxis.tickFormat
104
+ ? indexAxis.tickFormat(getPrimitiveFromObjectByPath(tooltipData.data, index) ?? '')
105
+ : getPrimitiveFromObjectByPath(tooltipData.data, index) ?? '' }) }), _jsxs("ul", { children: [series.dataKey.map((dataKey, di) => (_jsxs("li", { children: [_jsxs("div", { className: LinesTooltipItem, children: [_jsx(Placeholder, { color: series.colors[di] }), _jsx("span", { children: series.names[di] })] }), _jsx("div", { children: tooltip?.extraSeriesData && (_jsx("p", { children: tooltip.extraSeriesData(_.at(tooltipData.data, getLabelFromPath(dataKey))[0]) })) }), _jsx("div", { children: _jsx("p", { children: _jsx("b", { children: `${getPrimitiveFromObjectByPath(tooltipData.data, dataKey) ?? 'n/a'}` }) }) })] }, uuid()))), hasOverlay && (_jsxs("li", { children: [_jsxs("div", { className: LinesTooltipItem, children: [_jsx(Placeholder, { color: overlay.color }), _jsx("span", { children: overlay.name })] }), _jsx("div", { children: tooltip?.extraOverlayData && (_jsx("p", { children: tooltip.extraOverlayData(_.at(tooltipData.data, getLabelFromPath(overlay.dataKey))[0]) })) }), _jsx("div", { children: _jsx("p", { children: _jsx("b", { children: `${getPrimitiveFromObjectByPath(tooltipData.data, overlay.dataKey) ?? 'n/a'}` }) }) })] }))] })] }), (tooltip?.extraContent || !tooltipData.hasData) && (_jsxs("div", { className: ExtraContent, style: { borderColor: tooltipTheme[theme].separatorStroke }, children: [tooltip?.extraContent && tooltip.extraContent, !tooltipData.hasData && _jsx("p", { className: NoData, children: "No data available" })] }))] })] }))] }));
106
+ };
107
+ LinesTooltip.displayName = 'LinesTooltip';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const Lines: React.FC;
3
+ //# sourceMappingURL=lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/lines/lines.tsx"],"names":[],"mappings":";AA2BA,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAiBzB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Group } from '@visx/group';
18
+ import { useCartesianContext } from '../../../providers/cartesian';
19
+ import { LinesItemGroup, } from './lines.module.css';
20
+ import { LinesMarkerLabels } from './lines-marker-labels';
21
+ import { LinesOverlay } from './lines-overlay';
22
+ import { LinesSeries } from './lines-series';
23
+ import { LinesTooltip } from './lines-tooltip';
24
+ export const Lines = () => {
25
+ const { position } = useCartesianContext();
26
+ return (_jsxs(Group, { top: position.top, left: position.left, children: [_jsxs(Group, { className: LinesItemGroup, "data-testid": "lines", children: [_jsx(LinesSeries, {}), _jsx(LinesOverlay, {})] }), _jsx(LinesTooltip, {}), _jsx(LinesMarkerLabels, {})] }));
27
+ };
28
+ Lines.displayName = 'Lines';
@@ -0,0 +1 @@
1
+ .LinesItem,.LinesItem:hover{filter:saturate(100%) opacity(1)}.LinesItemGroup:hover .LinesItem:not(:hover){filter:saturate(80%) opacity(.3) blur(2px)}.LinesTooltipContent{display:block;padding:0 1rem .5rem}.LinesTooltipContent p{font-size:12px}.LinesTooltipContent ul{list-style:none;padding:0;width:100%}.LinesTooltipContent li{grid-gap:8px 4px;display:grid;grid-template-columns:1fr auto .5fr;grid-template-rows:1fr}.LinesTooltipContent li div:nth-child(n+2){text-align:right}.LinesTooltipItem{align-items:center;display:flex;flex-direction:row;font-size:12px;gap:4px;justify-content:flex-start}.ExtraContent{border-style:solid;border-width:1px;border-bottom:none;border-left:none;border-right:none;padding:.25rem 1rem}.NoData{font-size:12px}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=lines.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.test.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/lines/lines.test.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,142 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import '@testing-library/jest-dom';
3
+ import { fireEvent, render, screen, } from '@testing-library/react';
4
+ import { scaleLinear, scaleUtc } from '@visx/scale';
5
+ import { CartesianProvider, DataProvider, LayoutProvider, ThemeProvider, } from '../../../providers';
6
+ import { CartesianChartLayout, Charts, } from '../../../types';
7
+ import { Lines } from './lines';
8
+ global.ResizeObserver = jest.fn().mockImplementation(() => ({
9
+ observe: jest.fn(),
10
+ unobserve: jest.fn(),
11
+ disconnect: jest.fn(),
12
+ }));
13
+ const mockMetadata = {
14
+ type: Charts.LINE_CHART,
15
+ index: 'date',
16
+ series: {
17
+ dataKey: ['a'],
18
+ names: ['A'],
19
+ colors: ['ca'],
20
+ },
21
+ overlay: {
22
+ dataKey: 'b',
23
+ name: 'B',
24
+ color: 'ob',
25
+ },
26
+ hidePadding: true,
27
+ };
28
+ const mockedAxisSystem = {
29
+ top: {
30
+ domain: [0, 1],
31
+ scaleType: 'linear',
32
+ orientation: 'top',
33
+ top: 0,
34
+ left: 0,
35
+ scale: jest.fn(),
36
+ },
37
+ right: {
38
+ domain: ['a', 'b'],
39
+ scaleType: 'label',
40
+ orientation: 'right',
41
+ top: 0,
42
+ left: 800,
43
+ scale: jest.fn(),
44
+ },
45
+ bottom: {
46
+ domain: ['01-01-2020', '01-01-2024'],
47
+ scaleType: 'time',
48
+ orientation: 'bottom',
49
+ top: 600,
50
+ left: 0,
51
+ scale: jest.fn(),
52
+ },
53
+ left: {
54
+ domain: [0, 1],
55
+ scaleType: 'linear',
56
+ orientation: 'left',
57
+ top: 0,
58
+ left: 0,
59
+ scale: jest.fn(),
60
+ },
61
+ };
62
+ const mockedAxisSystem2 = {
63
+ top: undefined,
64
+ right: {
65
+ domain: [0, 10],
66
+ scaleType: 'linear',
67
+ orientation: 'right',
68
+ top: 0,
69
+ left: 800,
70
+ scale: scaleLinear(),
71
+ },
72
+ bottom: {
73
+ domain: ['01-01-2020', '01-01-2023'],
74
+ scaleType: 'time',
75
+ orientation: 'bottom',
76
+ top: 600,
77
+ left: 0,
78
+ scale: scaleUtc(),
79
+ },
80
+ left: {
81
+ domain: [0, 10],
82
+ scaleType: 'linear',
83
+ orientation: 'left',
84
+ top: 0,
85
+ left: 0,
86
+ scale: scaleLinear(),
87
+ },
88
+ };
89
+ describe('<Lines>', () => {
90
+ it('should render the component', () => {
91
+ render(_jsx(ThemeProvider, { theme: "light", children: _jsx(LayoutProvider, { layout: CartesianChartLayout.HORIZONTAL, children: _jsx(DataProvider, { data: [{ date: 0, a: 1, b: 2 }], metadata: mockMetadata, children: _jsx(CartesianProvider, { position: {
92
+ top: 24, right: 24, bottom: 24, left: 24,
93
+ }, dimension: { maxHeight: 600, maxWidth: 800 }, axis: mockedAxisSystem, children: _jsx(Lines, {}) }) }) }) }));
94
+ const elementSeries = screen.getByTestId('lines-series');
95
+ const elementOverlay = screen.getByTestId('lines-overlay');
96
+ expect(elementSeries).toBeDefined();
97
+ expect(elementOverlay).toBeDefined();
98
+ });
99
+ it('should render the component w vertical layout', () => {
100
+ render(_jsx(ThemeProvider, { theme: "light", children: _jsx(LayoutProvider, { layout: CartesianChartLayout.VERTICAL, children: _jsx(DataProvider, { data: [{ date: 0, a: 1, b: 2 }], metadata: mockMetadata, children: _jsx(CartesianProvider, { position: {
101
+ top: 24, right: 24, bottom: 24, left: 24,
102
+ }, dimension: { maxHeight: 600, maxWidth: 800 }, axis: mockedAxisSystem, children: _jsx(Lines, {}) }) }) }) }));
103
+ const elementSeries = screen.getByTestId('lines-series');
104
+ const elementOverlay = screen.getByTestId('lines-overlay');
105
+ expect(elementSeries).toBeDefined();
106
+ expect(elementOverlay).toBeDefined();
107
+ });
108
+ it('should render the component w markerLabel', () => {
109
+ render(_jsx(ThemeProvider, { theme: "light", children: _jsx(LayoutProvider, { layout: CartesianChartLayout.HORIZONTAL, children: _jsx(DataProvider, { data: [{ date: 0, a: 1, b: 2 }], metadata: { ...mockMetadata, showMarkerLabel: true }, children: _jsx(CartesianProvider, { position: {
110
+ top: 24, right: 24, bottom: 24, left: 24,
111
+ }, dimension: { maxHeight: 600, maxWidth: 800 }, axis: mockedAxisSystem, children: _jsx(Lines, {}) }) }) }) }));
112
+ const elementSeries = screen.getByTestId('lines-series');
113
+ const elementOverlay = screen.getByTestId('lines-overlay');
114
+ expect(elementSeries).toBeDefined();
115
+ expect(elementOverlay).toBeDefined();
116
+ });
117
+ it('should render the component w/o missing connection', () => {
118
+ render(_jsx(ThemeProvider, { theme: "light", children: _jsx(LayoutProvider, { layout: CartesianChartLayout.HORIZONTAL, children: _jsx(DataProvider, { data: [{ date: 0, a: 1, b: 2 },
119
+ { date: 0, a: undefined, b: 2 },
120
+ { date: 0, a: 1, b: 2 }], metadata: { ...mockMetadata, hideMissingDataConnection: true }, children: _jsx(CartesianProvider, { position: {
121
+ top: 24, right: 24, bottom: 24, left: 24,
122
+ }, dimension: { maxHeight: 600, maxWidth: 800 }, axis: mockedAxisSystem, children: _jsx(Lines, {}) }) }) }) }));
123
+ const elementOverlay = screen.getByTestId('lines-overlay');
124
+ expect(elementOverlay).toBeDefined();
125
+ });
126
+ it.skip('should trigger tooltip', async () => {
127
+ const { getByTestId, queryByTestId } = render(_jsx(ThemeProvider, { theme: "light", children: _jsx(LayoutProvider, { layout: CartesianChartLayout.HORIZONTAL, children: _jsx(DataProvider, { data: [{ date: '01-01-2020', a: 1, b: 2 },
128
+ { date: '01-01-2021', a: 3, b: 4 },
129
+ { date: '01-01-2022', a: 1, b: 2 }], metadata: mockMetadata, children: _jsx(CartesianProvider, { position: {
130
+ top: 24, right: 24, bottom: 24, left: 24,
131
+ }, dimension: { maxHeight: 600, maxWidth: 800 }, axis: mockedAxisSystem2, children: _jsx(Lines, {}) }) }) }) }));
132
+ const overlay = getByTestId('transparent-overlay-layer');
133
+ const tooltip = queryByTestId('lines-tooltip');
134
+ expect(overlay).toBeDefined();
135
+ expect(tooltip).toBeNull();
136
+ fireEvent.mouseOver(overlay);
137
+ // await waitFor(() => {
138
+ // const tooltip = document.querySelector('div[style="z-index: 10;"]');
139
+ // expect(tooltip).toBeInTheDocument();
140
+ // });
141
+ });
142
+ });
@@ -0,0 +1,3 @@
1
+ export type { TooltipProps } from './tooltip';
2
+ export { Tooltip } from './tooltip';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2023 Wonderflow Design Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { Tooltip } from './tooltip';
@@ -0,0 +1,35 @@
1
+ /// <reference types="react" />
2
+ import { TooltipStyleConfig } from '../../types';
3
+ import { DeepPartial } from '../../types/main';
4
+ export declare type TooltipProps = {
5
+ /**
6
+ * Set if the tooltip should be shown or hidden.
7
+ */
8
+ isOpen?: boolean;
9
+ /**
10
+ * Set the position from top (Y axis).
11
+ */
12
+ top?: number;
13
+ /**
14
+ * Set the position from left (X axis).
15
+ */
16
+ left?: number;
17
+ /**
18
+ * Set an offset for the top position.
19
+ */
20
+ offsetTop?: number;
21
+ /**
22
+ * Set an offset for the left position.
23
+ */
24
+ offsetLeft?: number;
25
+ /**
26
+ * Set the tooltip content.
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Set custom tooltip style attributes.
31
+ */
32
+ config?: DeepPartial<TooltipStyleConfig>;
33
+ };
34
+ export declare const Tooltip: React.FC<TooltipProps>;
35
+ //# sourceMappingURL=tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.tsx"],"names":[],"mappings":";AAuBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;CAC1C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAkC1C,CAAC"}