@wonderflow/charts 12.11.0 → 13.0.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 (161) hide show
  1. package/dist/components/bar-chart/bar-chart.d.ts +33 -5
  2. package/dist/components/bar-chart/bar-chart.d.ts.map +1 -1
  3. package/dist/components/bar-chart/bar-chart.js +20 -45
  4. package/dist/components/bar-chart/bar-chart.test.js +7 -1
  5. package/dist/components/cartesian-base/cartesian-base-axis.d.ts.map +1 -1
  6. package/dist/components/cartesian-base/cartesian-base-axis.js +10 -11
  7. package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -1
  8. package/dist/components/cartesian-base/cartesian-base-legend.js +3 -3
  9. package/dist/components/cartesian-base/cartesian-base.d.ts +27 -0
  10. package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -1
  11. package/dist/components/cartesian-base/cartesian-base.js +7 -3
  12. package/dist/components/cartesian-base/cartesian-base.module.css +1 -1
  13. package/dist/components/headings/headings.d.ts +19 -2
  14. package/dist/components/headings/headings.d.ts.map +1 -1
  15. package/dist/components/headings/headings.js +72 -6
  16. package/dist/components/headings/headings.module.css +1 -0
  17. package/dist/components/headings/headings.test.d.ts +1 -1
  18. package/dist/components/headings/headings.test.d.ts.map +1 -1
  19. package/dist/components/headings/headings.test.js +37 -3
  20. package/dist/components/line-chart/line-chart.d.ts +29 -13
  21. package/dist/components/line-chart/line-chart.d.ts.map +1 -1
  22. package/dist/components/line-chart/line-chart.js +4 -2
  23. package/dist/components/line-chart/line-chart.test.js +2 -2
  24. package/dist/components/loader/bar-chart-loader.d.ts.map +1 -1
  25. package/dist/components/loader/bar-chart-loader.js +1 -1
  26. package/dist/components/loader/loader.js +2 -2
  27. package/dist/components/loader/loader.test.js +4 -2
  28. package/dist/components/shapes/bars/bars-average.d.ts +3 -0
  29. package/dist/components/shapes/bars/bars-average.d.ts.map +1 -0
  30. package/dist/components/shapes/bars/bars-average.js +30 -0
  31. package/dist/components/shapes/bars/bars-overlay.d.ts +6 -0
  32. package/dist/components/shapes/bars/bars-overlay.d.ts.map +1 -0
  33. package/dist/components/shapes/bars/bars-overlay.js +59 -0
  34. package/dist/components/shapes/bars/bars-series.d.ts +6 -0
  35. package/dist/components/shapes/bars/bars-series.d.ts.map +1 -0
  36. package/dist/components/shapes/bars/bars-series.js +56 -0
  37. package/dist/components/shapes/bars/bars-tooltip.d.ts +3 -0
  38. package/dist/components/shapes/bars/bars-tooltip.d.ts.map +1 -0
  39. package/dist/components/shapes/bars/bars-tooltip.js +85 -0
  40. package/dist/components/shapes/bars/bars-trendline.d.ts +3 -0
  41. package/dist/components/shapes/bars/bars-trendline.d.ts.map +1 -0
  42. package/dist/components/shapes/bars/bars-trendline.js +43 -0
  43. package/dist/components/shapes/bars/bars.d.ts.map +1 -1
  44. package/dist/components/shapes/bars/bars.js +25 -18
  45. package/dist/components/shapes/bars/bars.module.css +1 -1
  46. package/dist/components/shapes/bars/bars.test.js +39 -8
  47. package/dist/components/shapes/bars/index.d.ts +5 -0
  48. package/dist/components/shapes/bars/index.d.ts.map +1 -1
  49. package/dist/components/shapes/bars/index.js +6 -1
  50. package/dist/components/shapes/lines/lines-average.d.ts.map +1 -1
  51. package/dist/components/shapes/lines/lines-average.js +8 -46
  52. package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -1
  53. package/dist/components/shapes/lines/lines-marker-labels.js +10 -10
  54. package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -1
  55. package/dist/components/shapes/lines/lines-overlay.js +21 -26
  56. package/dist/components/shapes/lines/lines-series.d.ts.map +1 -1
  57. package/dist/components/shapes/lines/lines-series.js +6 -19
  58. package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -1
  59. package/dist/components/shapes/lines/lines-tooltip.js +20 -27
  60. package/dist/components/shapes/lines/lines-trendline.d.ts +3 -0
  61. package/dist/components/shapes/lines/lines-trendline.d.ts.map +1 -0
  62. package/dist/components/shapes/lines/lines-trendline.js +43 -0
  63. package/dist/components/shapes/lines/lines.d.ts.map +1 -1
  64. package/dist/components/shapes/lines/lines.js +2 -1
  65. package/dist/components/shapes/lines/lines.test.js +29 -8
  66. package/dist/hooks/hooks.test.d.ts.map +1 -1
  67. package/dist/hooks/hooks.test.js +157 -5
  68. package/dist/hooks/index.d.ts +4 -0
  69. package/dist/hooks/index.d.ts.map +1 -1
  70. package/dist/hooks/index.js +4 -0
  71. package/dist/hooks/useAverage.d.ts +82 -0
  72. package/dist/hooks/useAverage.d.ts.map +1 -0
  73. package/dist/hooks/useAverage.js +83 -0
  74. package/dist/hooks/useBarChart.d.ts +16 -0
  75. package/dist/hooks/useBarChart.d.ts.map +1 -0
  76. package/dist/hooks/useBarChart.js +104 -0
  77. package/dist/hooks/useBars.d.ts +52 -0
  78. package/dist/hooks/useBars.d.ts.map +1 -0
  79. package/dist/hooks/useBars.js +82 -0
  80. package/dist/hooks/useCartesian.d.ts +11 -2
  81. package/dist/hooks/useCartesian.d.ts.map +1 -1
  82. package/dist/hooks/useCartesian.js +16 -5
  83. package/dist/hooks/useLineChart.d.ts +3 -27
  84. package/dist/hooks/useLineChart.d.ts.map +1 -1
  85. package/dist/hooks/useLineChart.js +22 -13
  86. package/dist/hooks/useLines.d.ts +48 -0
  87. package/dist/hooks/useLines.d.ts.map +1 -0
  88. package/dist/hooks/useLines.js +70 -0
  89. package/dist/hooks/useTrendline.d.ts +56 -0
  90. package/dist/hooks/useTrendline.d.ts.map +1 -0
  91. package/dist/hooks/useTrendline.js +84 -0
  92. package/dist/providers/cartesian.d.ts +5 -1
  93. package/dist/providers/cartesian.d.ts.map +1 -1
  94. package/dist/providers/cartesian.js +19 -3
  95. package/dist/providers/data.d.ts +6 -7
  96. package/dist/providers/data.d.ts.map +1 -1
  97. package/dist/providers/data.js +4 -3
  98. package/dist/style-config/axis.js +3 -3
  99. package/dist/style-config/bars.d.ts +3 -0
  100. package/dist/style-config/bars.d.ts.map +1 -0
  101. package/dist/style-config/bars.js +33 -0
  102. package/dist/style-config/cartesian.d.ts.map +1 -1
  103. package/dist/style-config/cartesian.js +2 -0
  104. package/dist/style-config/colors.d.ts +1 -4
  105. package/dist/style-config/colors.d.ts.map +1 -1
  106. package/dist/style-config/colors.js +30 -36
  107. package/dist/style-config/headings.d.ts.map +1 -1
  108. package/dist/style-config/headings.js +16 -1
  109. package/dist/style-config/lines.d.ts.map +1 -1
  110. package/dist/style-config/lines.js +6 -0
  111. package/dist/style-config/themes.d.ts.map +1 -1
  112. package/dist/style-config/themes.js +18 -0
  113. package/dist/types/bar-chart.d.ts +20 -15
  114. package/dist/types/bar-chart.d.ts.map +1 -1
  115. package/dist/types/bar-chart.js +1 -39
  116. package/dist/types/bars.d.ts +29 -0
  117. package/dist/types/bars.d.ts.map +1 -0
  118. package/dist/types/bars.js +16 -0
  119. package/dist/types/cartesian.d.ts +3 -0
  120. package/dist/types/cartesian.d.ts.map +1 -1
  121. package/dist/types/headings.d.ts +15 -0
  122. package/dist/types/headings.d.ts.map +1 -1
  123. package/dist/types/headings.js +1 -1
  124. package/dist/types/index.d.ts +3 -0
  125. package/dist/types/index.d.ts.map +1 -1
  126. package/dist/types/index.js +4 -1
  127. package/dist/types/line-chart.d.ts +12 -12
  128. package/dist/types/line-chart.d.ts.map +1 -1
  129. package/dist/types/lines.d.ts +6 -0
  130. package/dist/types/lines.d.ts.map +1 -1
  131. package/dist/types/main.d.ts +14 -1
  132. package/dist/types/main.d.ts.map +1 -1
  133. package/dist/types/themes.d.ts +9 -0
  134. package/dist/types/themes.d.ts.map +1 -1
  135. package/dist/utils/axis.d.ts +12 -2
  136. package/dist/utils/axis.d.ts.map +1 -1
  137. package/dist/utils/axis.js +52 -15
  138. package/dist/utils/axis.test.js +72 -8
  139. package/dist/utils/bars.d.ts +15 -0
  140. package/dist/utils/bars.d.ts.map +1 -0
  141. package/dist/utils/bars.js +71 -0
  142. package/dist/utils/bars.test.d.ts +2 -0
  143. package/dist/utils/bars.test.d.ts.map +1 -0
  144. package/dist/utils/bars.test.js +95 -0
  145. package/dist/utils/data.d.ts +9 -6
  146. package/dist/utils/data.d.ts.map +1 -1
  147. package/dist/utils/data.js +87 -15
  148. package/dist/utils/data.test.js +173 -80
  149. package/dist/utils/format.d.ts +1 -0
  150. package/dist/utils/format.d.ts.map +1 -1
  151. package/dist/utils/format.js +2 -1
  152. package/dist/utils/index.d.ts +1 -0
  153. package/dist/utils/index.d.ts.map +1 -1
  154. package/dist/utils/index.js +2 -1
  155. package/dist/utils/lines.test.js +25 -0
  156. package/dist/utils/metadata.d.ts +7 -8
  157. package/dist/utils/metadata.d.ts.map +1 -1
  158. package/dist/utils/metadata.js +3 -20
  159. package/dist/utils/metadata.test.js +3 -56
  160. package/dist/utils/viewport.test.js +8 -0
  161. package/package.json +4 -2
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Copyright 2024 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
+ import { scaleBand } from '@visx/scale';
17
+ import { useMemo } from 'react';
18
+ import { useCartesianContext, useDataContext, useLayoutContext, useStyleConfigContext, } from '../providers';
19
+ export const useBars = () => {
20
+ const { data, metadata } = useDataContext();
21
+ const { isHorizontal } = useLayoutContext();
22
+ const { axis, dimension, preventTooltipOpening, hasReversedIndex, } = useCartesianContext();
23
+ const { bars } = useStyleConfigContext();
24
+ const { left, bottom, right, top, } = axis;
25
+ const { maxWidth, maxHeight } = dimension;
26
+ const { series, index, overlay, sortBy, showBackground: hasBackground, fixedBarSize, preventTooltipDisplay, tooltip, } = metadata;
27
+ const { showBackground: hasBackgroundSeries } = series;
28
+ const { showBackground: hasBackgroundOverlay } = overlay;
29
+ const indexAxis = isHorizontal ? bottom : left;
30
+ const seriesAxis = isHorizontal
31
+ ? left
32
+ : bottom;
33
+ const hasOverlay = Boolean(overlay && (right || top));
34
+ const overlayAxis = isHorizontal
35
+ ? right
36
+ : top;
37
+ const { maxSize, paddingInner, paddingOuter, paddingInnerGroup, paddingOuterGroup, bar, background, } = bars;
38
+ const X0Y0 = (d) => d[index];
39
+ const scaleXY0 = scaleBand({
40
+ domain: hasReversedIndex ? data.map(X0Y0).reverse() : data.map(X0Y0),
41
+ paddingOuter,
42
+ paddingInner,
43
+ });
44
+ scaleXY0.rangeRound((isHorizontal ? [0, maxWidth] : [maxHeight, 0]));
45
+ const combinedDataKeys = useMemo(() => (hasOverlay
46
+ ? [...series.dataKey, ...overlay.dataKey]
47
+ : series.dataKey), [hasOverlay, overlay.dataKey, series.dataKey]);
48
+ const scaleXY1 = scaleBand({
49
+ domain: combinedDataKeys,
50
+ paddingInner: paddingInnerGroup,
51
+ paddingOuter: paddingOuterGroup,
52
+ });
53
+ scaleXY1.rangeRound([0, scaleXY0.bandwidth()]);
54
+ return {
55
+ data,
56
+ isHorizontal,
57
+ index,
58
+ series,
59
+ overlay,
60
+ sortBy,
61
+ hasBackgroundSeries: (hasBackgroundSeries || hasBackground),
62
+ hasBackgroundOverlay: (hasBackgroundOverlay || hasBackground),
63
+ indexAxis,
64
+ seriesAxis,
65
+ overlayAxis,
66
+ hasOverlay,
67
+ maxWidth,
68
+ maxHeight,
69
+ X0Y0,
70
+ scaleXY0,
71
+ scaleXY1,
72
+ fixedBarSize: Boolean(fixedBarSize),
73
+ style: {
74
+ bar,
75
+ background,
76
+ maxSize,
77
+ },
78
+ preventTooltipOpening,
79
+ preventTooltipDisplay,
80
+ tooltip,
81
+ };
82
+ };
@@ -11,12 +11,16 @@ export declare type UseCartesianProps = {
11
11
  isLoading?: boolean;
12
12
  margin?: MarginProps;
13
13
  preventResponsive?: boolean;
14
+ reverseIndex?: boolean;
15
+ mirrorDomains?: boolean;
16
+ overrideInnerHeight?: number;
14
17
  showBrush?: boolean;
15
18
  styleConfig?: DeepPartial<CartesianStyleConfig>;
16
19
  title?: string;
20
+ menu?: React.ReactNode;
17
21
  width?: number;
18
22
  };
19
- export declare const useCartesian: ({ axis, axisFiltered, background, headings, height, hideLegend, isLoading, margin, preventResponsive, showBrush, styleConfig, title, width, }: UseCartesianProps) => {
23
+ export declare const useCartesian: ({ axis, axisFiltered, background, headings, height, hideLegend, isLoading, margin, preventResponsive, reverseIndex, mirrorDomains, overrideInnerHeight, showBrush, styleConfig, title, menu, width, }: UseCartesianProps) => {
20
24
  axisConfig: AxisConfig;
21
25
  axisFilteredSystem: CartesianxAxisSystem;
22
26
  axisSystem: CartesianxAxisSystem;
@@ -41,10 +45,14 @@ export declare const useCartesian: ({ axis, axisFiltered, background, headings,
41
45
  hasData: boolean;
42
46
  hasLegend: boolean;
43
47
  hasBrush: boolean;
48
+ hasReversedIndex: boolean;
49
+ hasMirroredDomainsHorizontal: boolean;
50
+ hasMirroredDomainsVertical: boolean;
44
51
  filteredData: import("../types").Data;
45
52
  hasEmptyState: boolean;
46
53
  hoveredLegendItem: string;
47
- metadata: import("../types").BarChartMetadata | import("../types").LineChartMetadata | undefined;
54
+ isMenuOpen: boolean;
55
+ metadata: import("../types").CartesianChartMetadata | undefined;
48
56
  position: {
49
57
  headings: {
50
58
  top: number;
@@ -69,5 +77,6 @@ export declare const useCartesian: ({ axis, axisFiltered, background, headings,
69
77
  refLegend: import("react").RefObject<HTMLDivElement>;
70
78
  theme: import("../types").ThemeVariants;
71
79
  setHoveredLegendItem: import("react").Dispatch<import("react").SetStateAction<string>>;
80
+ setIsMenuOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
72
81
  };
73
82
  //# sourceMappingURL=useCartesian.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCartesian.d.ts","sourceRoot":"","sources":["../../src/hooks/useCartesian.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,aAAa,EACd,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EACL,UAAU,EACV,eAAe,EACf,SAAS,EACT,UAAU,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EACjF,MAAM,UAAU,CAAC;AAIlB,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACrD,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IAC7D,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAE,MAAM,GAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,eAAO,MAAM,YAAY,kJAmBtB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6JnB,CAAC"}
1
+ {"version":3,"file":"useCartesian.d.ts","sourceRoot":"","sources":["../../src/hooks/useCartesian.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,aAAa,EACd,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EACL,UAAU,EACV,eAAe,EACf,SAAS,EACT,UAAU,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EACjF,MAAM,UAAU,CAAC;AAIlB,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACrD,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IAC7D,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAE,MAAM,GAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,eAAO,MAAM,YAAY,0MAuBtB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyKnB,CAAC"}
@@ -25,7 +25,7 @@ export const useCartesian = ({ axis, axisFiltered, background, headings, height
25
25
  right: 24,
26
26
  bottom: 24,
27
27
  left: 24,
28
- }, preventResponsive = false, showBrush = false, styleConfig, title, width = 800, }) => {
28
+ }, preventResponsive = false, reverseIndex = false, mirrorDomains = false, overrideInnerHeight, showBrush = false, styleConfig, title, menu, width = 800, }) => {
29
29
  const theme = useThemeContext();
30
30
  const { isHorizontal } = useLayoutContext();
31
31
  const { metadata, data, filteredData } = useDataContext();
@@ -34,6 +34,7 @@ export const useCartesian = ({ axis, axisFiltered, background, headings, height
34
34
  const { axis: aStyle, legend: lStyle, themes, headings: hStyle, viewport, } = cartesianConfig;
35
35
  const { from: bgFrom, to: bgTo } = useMemo(() => _.merge(themes[theme].background, background), [background, theme, themes]);
36
36
  const [hoveredLegendItem, setHoveredLegendItem] = useState('');
37
+ const [isMenuOpen, setIsMenuOpen] = useState(false);
37
38
  const ref = useRef(null);
38
39
  const size = useSize(ref);
39
40
  const refLegend = useRef(null);
@@ -53,10 +54,10 @@ export const useCartesian = ({ axis, axisFiltered, background, headings, height
53
54
  height: (hasBrush && isHorizontal) ? brushTotalArea : 0,
54
55
  width: (hasBrush && !isHorizontal) ? brushTotalArea : 0,
55
56
  };
56
- const hasHeadings = !!title;
57
+ const hasHeadings = Boolean(title || menu);
57
58
  const headingsHeight = hasHeadings ? hStyle.height : 0;
58
59
  const w = size ? size.width : width;
59
- const h = size ? size.height : height;
60
+ const h = size ? (overrideInnerHeight ?? size.height) : height;
60
61
  const dynamicWidth = preventResponsive ? width : w;
61
62
  const dynamicHeight = preventResponsive ? height : h;
62
63
  const dynamicStyle = {
@@ -112,8 +113,13 @@ export const useCartesian = ({ axis, axisFiltered, background, headings, height
112
113
  : ml + lOff + xMax,
113
114
  },
114
115
  };
115
- const axisSystem = useMemo(() => computeAxisSystemProperties(axis, dimension.axis, position.axis), [axis, dimension.axis, position.axis]);
116
- const axisFilteredSystem = useMemo(() => computeAxisSystemProperties(axisFiltered, dimension.axis, position.axis), [axisFiltered, dimension.axis, position.axis]);
116
+ const config = useMemo(() => ({
117
+ hasReversedIndex: Boolean(reverseIndex && !isHorizontal),
118
+ hasMirroredDomainsHorizontal: Boolean(mirrorDomains && isHorizontal),
119
+ hasMirroredDomainsVertical: Boolean(mirrorDomains && !isHorizontal), // will affect Top/Bottom axis
120
+ }), [isHorizontal, mirrorDomains, reverseIndex]);
121
+ const axisSystem = useMemo(() => computeAxisSystemProperties(axis, dimension.axis, position.axis, config), [axis, dimension.axis, position.axis, config]);
122
+ const axisFilteredSystem = useMemo(() => computeAxisSystemProperties(axisFiltered, dimension.axis, position.axis, config), [axisFiltered, dimension.axis, position.axis, config]);
117
123
  return {
118
124
  axisConfig,
119
125
  axisFilteredSystem,
@@ -130,14 +136,19 @@ export const useCartesian = ({ axis, axisFiltered, background, headings, height
130
136
  hasData,
131
137
  hasLegend,
132
138
  hasBrush,
139
+ hasReversedIndex: config.hasReversedIndex,
140
+ hasMirroredDomainsHorizontal: config.hasMirroredDomainsHorizontal,
141
+ hasMirroredDomainsVertical: config.hasMirroredDomainsVertical,
133
142
  filteredData,
134
143
  hasEmptyState,
135
144
  hoveredLegendItem,
145
+ isMenuOpen,
136
146
  metadata,
137
147
  position,
138
148
  ref,
139
149
  refLegend,
140
150
  theme,
141
151
  setHoveredLegendItem,
152
+ setIsMenuOpen,
142
153
  };
143
154
  };
@@ -1,37 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { Except } from 'type-fest';
3
3
  import { LineChartProps } from '../components';
4
- import { CartesianChartLayout, Charts, Data, MarginProps } from '../types';
4
+ import { CartesianChartLayout, Data, LineChartMetadata, MarginProps } from '../types';
5
5
  export declare type UseLineChartProps = Except<LineChartProps, 'otherProps'>;
6
- export declare const useLineChart: ({ theme, layout, renderAs, data, index, series, overlay, tooltip, showAverage, hideMissingDataConnection, showMarker, showMarkerLabel, hidePadding, }: UseLineChartProps) => {
6
+ export declare const useLineChart: ({ theme, layout, renderAs, data, index, series, overlay, tooltip, preventTooltipDisplay, showAverage, showTrendline, hideMissingDataConnection, showMarker, showMarkerLabel, hidePadding, }: UseLineChartProps) => {
7
7
  axis: Record<CartesianChartLayout, Record<import("../types").AxisOrientation, import("../types").AxisProps | undefined>>;
8
8
  axisFiltered: Record<CartesianChartLayout, Record<import("../types").AxisOrientation, import("../types").AxisProps | undefined>>;
9
9
  isHorizontal: boolean;
10
- metadata: {
11
- type: Charts;
12
- renderAs: import("../types").LineChartRenderType;
13
- index: string;
14
- series: {
15
- dataKey: string[];
16
- names: string[];
17
- colors: (string | undefined)[];
18
- style: (import("../types").LineStyle | undefined)[] | undefined;
19
- average: import("../types").AverageType;
20
- };
21
- overlay: {
22
- dataKey: string | undefined;
23
- name: string;
24
- color: string;
25
- style: import("../types").LineStyle | undefined;
26
- average: import("../types").AverageType;
27
- };
28
- tooltip: import("../types").LineChartTooltip | undefined;
29
- showAverage: boolean;
30
- hideMissingDataConnection: boolean;
31
- showMarker: boolean;
32
- showMarkerLabel: boolean;
33
- hidePadding: boolean;
34
- };
10
+ metadata: LineChartMetadata;
35
11
  zeroPadding: MarginProps | undefined;
36
12
  brushFilteredData: Data;
37
13
  setBrushFilteredData: import("react").Dispatch<import("react").SetStateAction<Data>>;
@@ -1 +1 @@
1
- {"version":3,"file":"useLineChart.d.ts","sourceRoot":"","sources":["../../src/hooks/useLineChart.ts"],"names":[],"mappings":";AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,oBAAoB,EAAE,MAAM,EAAE,IAAI,EAClC,WAAW,EACZ,MAAM,UAAU,CAAC;AAWlB,oBAAY,iBAAiB,GAAG,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEpE,eAAO,MAAM,YAAY,0JActB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EnB,CAAC"}
1
+ {"version":3,"file":"useLineChart.d.ts","sourceRoot":"","sources":["../../src/hooks/useLineChart.ts"],"names":[],"mappings":";AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,oBAAoB,EAAU,IAAI,EAClC,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAC;AAUlB,oBAAY,iBAAiB,GAAG,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEpE,eAAO,MAAM,YAAY,gMAgBtB,iBAAiB;;;;;;;;CAoFnB,CAAC"}
@@ -14,10 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { useMemo, useState } from 'react';
17
- import { defaultLineChartPalette } from '../style-config';
17
+ import { colorPaletteDefault } from '../style-config';
18
18
  import { CartesianChartLayout, Charts, } from '../types';
19
- import { computeAverage, handleChartAxisLayout, handleChartDomainAndScaleType, handleLineChartOverlayColor, handleLineChartSeriesColors, handleOverlayName, handleSeriesNames, } from '../utils';
20
- export const useLineChart = ({ theme = 'light', layout = CartesianChartLayout.HORIZONTAL, renderAs = 'curves', data = [], index, series, overlay, tooltip, showAverage = false, hideMissingDataConnection = false, showMarker = false, showMarkerLabel = false, hidePadding = false, }) => {
19
+ import { computeAverage, computeTrendline, handleChartAxisLayout, handleChartDomainAndScaleType, handleLineChartSeriesColors, handleSeriesNames, } from '../utils';
20
+ export const useLineChart = ({ theme = 'light', layout = CartesianChartLayout.HORIZONTAL, renderAs = 'curves', data = [], index, series, overlay, tooltip, preventTooltipDisplay = false, showAverage = false, showTrendline = false, hideMissingDataConnection = false, showMarker = false, showMarkerLabel = false, hidePadding = false, }) => {
21
21
  const [brushFilteredData, setBrushFilteredData] = useState(data);
22
22
  const isHorizontal = layout === CartesianChartLayout.HORIZONTAL;
23
23
  const zeroPadding = hidePadding
@@ -29,7 +29,8 @@ export const useLineChart = ({ theme = 'light', layout = CartesianChartLayout.HO
29
29
  const { index: iFiltered, series: sFiltered, overlay: oFiltered } = useMemo(() => handleChartDomainAndScaleType(brushFilteredData, index, series, overlay), [brushFilteredData, index, overlay, series]);
30
30
  const axis = useMemo(() => handleChartAxisLayout(i, s, o), [i, s, o]);
31
31
  const axisFiltered = useMemo(() => handleChartAxisLayout(iFiltered, sFiltered, oFiltered), [iFiltered, sFiltered, oFiltered]);
32
- const palette = defaultLineChartPalette[theme];
32
+ const paletteSeries = colorPaletteDefault[theme];
33
+ const paletteOverlay = useMemo(() => [...paletteSeries.slice(6), ...paletteSeries.slice(0, 6)], [paletteSeries]);
33
34
  const metadata = useMemo(() => ({
34
35
  type: Charts.LINE_CHART,
35
36
  renderAs,
@@ -37,36 +38,44 @@ export const useLineChart = ({ theme = 'light', layout = CartesianChartLayout.HO
37
38
  series: {
38
39
  dataKey: series.dataKey,
39
40
  names: handleSeriesNames(series),
40
- colors: handleLineChartSeriesColors(series, palette.series),
41
+ colors: handleLineChartSeriesColors(series, paletteSeries),
41
42
  style: series.style,
42
- average: computeAverage(data, series.dataKey),
43
+ average: showAverage ? computeAverage(data, series.dataKey) : undefined,
44
+ trendline: showTrendline ? computeTrendline(data, series.dataKey) : undefined,
43
45
  },
44
46
  overlay: {
45
47
  dataKey: overlay?.dataKey,
46
- name: handleOverlayName(overlay),
47
- color: handleLineChartOverlayColor(overlay, palette.overlay),
48
+ names: overlay ? handleSeriesNames(overlay) : undefined,
49
+ colors: overlay ? handleLineChartSeriesColors(overlay, paletteOverlay) : undefined,
48
50
  style: overlay?.style,
49
- average: overlay?.dataKey ? computeAverage(data, [overlay.dataKey]) : undefined,
51
+ average: (overlay?.dataKey && showAverage) ? computeAverage(data, overlay.dataKey) : undefined,
52
+ trendline: (overlay?.dataKey && showTrendline) ? computeTrendline(data, overlay.dataKey) : undefined,
50
53
  },
51
54
  tooltip,
55
+ preventTooltipDisplay,
52
56
  showAverage,
57
+ showTrendline,
53
58
  hideMissingDataConnection,
54
59
  showMarker,
55
60
  showMarkerLabel,
56
61
  hidePadding,
57
- }), [data,
62
+ }), [
63
+ data,
58
64
  hideMissingDataConnection,
59
65
  hidePadding,
60
66
  index.dataKey,
61
67
  overlay,
62
- palette.overlay,
63
- palette.series,
68
+ paletteOverlay,
69
+ paletteSeries,
64
70
  renderAs,
65
71
  series,
66
72
  showAverage,
73
+ showTrendline,
67
74
  showMarker,
68
75
  showMarkerLabel,
69
- tooltip]);
76
+ tooltip,
77
+ preventTooltipDisplay,
78
+ ]);
70
79
  return {
71
80
  axis,
72
81
  axisFiltered,
@@ -0,0 +1,48 @@
1
+ import { CartesianAxis } from '../types';
2
+ export declare const useLines: () => {
3
+ dimension: {
4
+ maxWidth: number;
5
+ maxHeight: number;
6
+ };
7
+ hasOverlay: boolean;
8
+ hideMissingDataConnection: boolean | undefined;
9
+ getOverlayCoordinates: (datum: Record<string, unknown>, dataKey: string, isHorizontal: boolean) => {
10
+ x: number | undefined;
11
+ y: number | undefined;
12
+ };
13
+ getSeriesCoordinates: (datum: Record<string, unknown>, dataKey: string, isHorizontal: boolean) => {
14
+ x: number | undefined;
15
+ y: number | undefined;
16
+ };
17
+ index: string;
18
+ isHorizontal: boolean;
19
+ indexAxis: CartesianAxis | undefined;
20
+ seriesAxis: CartesianAxis | undefined;
21
+ overlayAxis: CartesianAxis | undefined;
22
+ overlay: {
23
+ dataKey?: string[] | undefined;
24
+ names: string[] | undefined;
25
+ colors: (string | undefined)[] | undefined;
26
+ style?: (import("../types").LineStyle | undefined)[] | undefined;
27
+ average: import("../types").AverageType | undefined;
28
+ trendline: import("../types").TrendlineType[] | undefined;
29
+ };
30
+ maxHeight: number;
31
+ maxWidth: number;
32
+ preventTooltipDisplay: boolean | undefined;
33
+ preventTooltipOpening: boolean;
34
+ renderer: import("d3-shape").CurveFactory;
35
+ series: {
36
+ dataKey: string[];
37
+ names: string[];
38
+ colors: (string | undefined)[];
39
+ style?: (import("../types").LineStyle | undefined)[] | undefined;
40
+ average: import("../types").AverageType | undefined;
41
+ trendline: import("../types").TrendlineType[] | undefined;
42
+ };
43
+ showMarker: boolean | undefined;
44
+ showMarkerLabel: boolean | undefined;
45
+ tooltip: import("../types").LineChartTooltip | undefined;
46
+ data: import("../types").Data;
47
+ };
48
+ //# sourceMappingURL=useLines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLines.d.ts","sourceRoot":"","sources":["../../src/hooks/useLines.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,aAAa,EAAqB,MAAM,SAAS,CAAC;AAG3D,eAAO,MAAM,QAAQ;;;;;;;mCAuCV,OAAO,MAAM,EAAE,OAAO,CAAC,WACrB,MAAM,gBACD,OAAO;;;;kCAfd,OAAO,MAAM,EAAE,OAAO,CAAC,WACrB,MAAM,gBACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CxB,CAAC"}
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Copyright 2024 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
+ import { useMemo } from 'react';
17
+ import { useCartesianContext, useDataContext, useLayoutContext } from '../providers';
18
+ import { getCoordinates, getLinesRenderer } from '../utils';
19
+ export const useLines = () => {
20
+ const { data, metadata } = useDataContext();
21
+ const { isHorizontal } = useLayoutContext();
22
+ const { axis, dimension, preventTooltipOpening } = useCartesianContext();
23
+ const { maxHeight, maxWidth } = dimension;
24
+ const { index, series, renderAs, showMarker, showMarkerLabel, overlay, hideMissingDataConnection, preventTooltipDisplay, tooltip, } = metadata;
25
+ const { top, right, left, bottom, } = axis;
26
+ const indexAxis = isHorizontal ? bottom : left;
27
+ const seriesAxis = isHorizontal ? left : bottom;
28
+ const overlayAxis = isHorizontal ? right : top;
29
+ const hasOverlay = Boolean(overlayAxis && overlay.dataKey && overlay.dataKey.length);
30
+ const renderer = useMemo(() => getLinesRenderer(renderAs, isHorizontal), [isHorizontal, renderAs]);
31
+ const getSeriesCoordinates = useMemo(() => (datum, dataKey, isHorizontal) => getCoordinates({
32
+ datum,
33
+ indexAxis: indexAxis,
34
+ indexDataKey: index,
35
+ otherAxis: seriesAxis,
36
+ otherDataKey: dataKey,
37
+ isHorizontal,
38
+ }), [index, indexAxis, seriesAxis]);
39
+ const getOverlayCoordinates = useMemo(() => (datum, dataKey, isHorizontal) => getCoordinates({
40
+ datum,
41
+ indexAxis: indexAxis,
42
+ indexDataKey: index,
43
+ otherAxis: overlayAxis,
44
+ otherDataKey: dataKey,
45
+ isHorizontal,
46
+ }), [index, indexAxis, overlayAxis]);
47
+ return {
48
+ dimension,
49
+ hasOverlay,
50
+ hideMissingDataConnection,
51
+ getOverlayCoordinates,
52
+ getSeriesCoordinates,
53
+ index,
54
+ isHorizontal,
55
+ indexAxis,
56
+ seriesAxis,
57
+ overlayAxis,
58
+ overlay,
59
+ maxHeight,
60
+ maxWidth,
61
+ preventTooltipDisplay,
62
+ preventTooltipOpening,
63
+ renderer,
64
+ series,
65
+ showMarker,
66
+ showMarkerLabel,
67
+ tooltip,
68
+ data,
69
+ };
70
+ };
@@ -0,0 +1,56 @@
1
+ import { CartesianChartMetadata } from '../types';
2
+ export declare const useTrendline: <T extends CartesianChartMetadata>() => {
3
+ series: {
4
+ dataKey: string[];
5
+ names: string[];
6
+ colors: string[];
7
+ style?: (import("../types").BarStyle | undefined)[] | undefined;
8
+ average: import("../types").AverageType | undefined;
9
+ trendline: import("../types").TrendlineType[] | undefined;
10
+ showBackground?: boolean | undefined;
11
+ } | {
12
+ dataKey: string[];
13
+ names: string[];
14
+ colors: (string | undefined)[];
15
+ style?: (import("../types").LineStyle | undefined)[] | undefined;
16
+ average: import("../types").AverageType | undefined;
17
+ trendline: import("../types").TrendlineType[] | undefined;
18
+ };
19
+ overlay: {
20
+ dataKey?: string[] | undefined;
21
+ names: string[] | undefined;
22
+ colors: string[] | undefined;
23
+ style?: (import("../types").BarStyle | undefined)[] | undefined;
24
+ average: import("../types").AverageType | undefined;
25
+ trendline: import("../types").TrendlineType[] | undefined;
26
+ showBackground?: boolean | undefined;
27
+ } | {
28
+ dataKey?: string[] | undefined;
29
+ names: string[] | undefined;
30
+ colors: (string | undefined)[] | undefined;
31
+ style?: (import("../types").LineStyle | undefined)[] | undefined;
32
+ average: import("../types").AverageType | undefined;
33
+ trendline: import("../types").TrendlineType[] | undefined;
34
+ };
35
+ seriesAxis: import("../types").CartesianAxis | undefined;
36
+ overlayAxis: import("../types").CartesianAxis | undefined;
37
+ hasTrendlineSeries: boolean;
38
+ hasTrendlineOverlay: boolean;
39
+ getCoordinates: (from: number, to: number) => {
40
+ from: {
41
+ x: number;
42
+ y: number;
43
+ };
44
+ to: {
45
+ x: number;
46
+ y: number;
47
+ };
48
+ };
49
+ style: {
50
+ opacity: number;
51
+ pointerEvents: string;
52
+ strokeDasharray: string;
53
+ strokeWidth: number;
54
+ };
55
+ };
56
+ //# sourceMappingURL=useTrendline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTrendline.d.ts","sourceRoot":"","sources":["../../src/hooks/useTrendline.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA8BmB,MAAM,MAAM,MAAM;;;;;;;;;;;;;;;;CAsD7D,CAAC"}
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Copyright 2024 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
+ import { useCallback } from 'react';
17
+ import { useCartesianContext, useDataContext, useLayoutContext, useStyleConfigContext, } from '../providers';
18
+ export const useTrendline = () => {
19
+ const { lines: defaultStyle } = useStyleConfigContext();
20
+ const { metadata } = useDataContext();
21
+ const { isHorizontal } = useLayoutContext();
22
+ const { axis, dimension, hasReversedIndex } = useCartesianContext();
23
+ const { top, right, bottom, left, } = axis;
24
+ const seriesAxis = isHorizontal ? left : bottom;
25
+ const overlayAxis = isHorizontal ? right : top;
26
+ const { showTrendline, series, overlay } = metadata;
27
+ const { maxHeight, maxWidth } = dimension;
28
+ const { opacity, pointerEvents, strokeDasharray, strokeWidth, } = defaultStyle.trendline;
29
+ const trendlineSeries = series.trendline;
30
+ const trendlineOverlay = overlay.trendline;
31
+ const hasTrendlineSeries = Boolean(showTrendline && trendlineSeries?.length);
32
+ const hasTrendlineOverlay = Boolean(showTrendline && trendlineOverlay?.length);
33
+ const getCoordinates = useCallback((from, to) => {
34
+ if (isHorizontal) {
35
+ return ({
36
+ from: {
37
+ x: 0,
38
+ y: from,
39
+ },
40
+ to: {
41
+ x: maxWidth,
42
+ y: to,
43
+ },
44
+ });
45
+ }
46
+ if (hasReversedIndex) {
47
+ return ({
48
+ from: {
49
+ x: from,
50
+ y: 0,
51
+ },
52
+ to: {
53
+ x: to,
54
+ y: maxHeight,
55
+ },
56
+ });
57
+ }
58
+ return ({
59
+ from: {
60
+ x: to,
61
+ y: 0,
62
+ },
63
+ to: {
64
+ x: from,
65
+ y: maxHeight,
66
+ },
67
+ });
68
+ }, [isHorizontal, maxHeight, maxWidth, hasReversedIndex]);
69
+ return {
70
+ series,
71
+ overlay,
72
+ seriesAxis,
73
+ overlayAxis,
74
+ hasTrendlineSeries,
75
+ hasTrendlineOverlay,
76
+ getCoordinates,
77
+ style: {
78
+ opacity,
79
+ pointerEvents,
80
+ strokeDasharray,
81
+ strokeWidth,
82
+ },
83
+ };
84
+ };
@@ -11,8 +11,12 @@ export declare type CartesianContextProps = {
11
11
  maxWidth: number;
12
12
  maxHeight: number;
13
13
  };
14
- axis?: CartesianxAxisSystem;
14
+ axis: CartesianxAxisSystem;
15
15
  hoveredLegendItem: string;
16
+ preventTooltipOpening: boolean;
17
+ hasReversedIndex: boolean;
18
+ hasMirroredDomainsHorizontal: boolean;
19
+ hasMirroredDomainsVertical: boolean;
16
20
  };
17
21
  export declare type CartesianProviderProps = CartesianContextProps;
18
22
  export declare const CartesianContext: import("react").Context<CartesianContextProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian.d.ts","sourceRoot":"","sources":["../../src/providers/cartesian.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,qBAAqB,GAAG;IAClC,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,oBAAY,sBAAsB,GAAG,qBAAqB,CAAA;AAiB1D,eAAO,MAAM,gBAAgB,gDAAuD,CAAC;AAErF,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,sBAAsB,CAahE,CAAC;AAEF,eAAO,MAAM,mBAAmB,6BAS/B,CAAC"}
1
+ {"version":3,"file":"cartesian.d.ts","sourceRoot":"","sources":["../../src/providers/cartesian.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,qBAAqB,GAAG;IAClC,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,oBAAoB,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4BAA4B,EAAE,OAAO,CAAC;IACtC,0BAA0B,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,oBAAY,sBAAsB,GAAG,qBAAqB,CAAA;AA0B1D,eAAO,MAAM,gBAAgB,gDAAuD,CAAC;AAErF,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,sBAAsB,CAwBhE,CAAC;AAEF,eAAO,MAAM,mBAAmB,6BAS/B,CAAC"}
@@ -26,12 +26,28 @@ const defaultSetting = {
26
26
  maxWidth: 800,
27
27
  maxHeight: 600,
28
28
  },
29
- axis: undefined,
29
+ axis: {
30
+ top: undefined,
31
+ right: undefined,
32
+ bottom: undefined,
33
+ left: undefined,
34
+ },
30
35
  hoveredLegendItem: '',
36
+ preventTooltipOpening: false,
37
+ hasReversedIndex: false,
38
+ hasMirroredDomainsHorizontal: false,
39
+ hasMirroredDomainsVertical: false,
31
40
  };
32
41
  export const CartesianContext = createContext(defaultSetting);
33
- export const CartesianProvider = ({ children, position, dimension, axis, hoveredLegendItem, }) => (_jsx(CartesianContext.Provider, { value: {
34
- position, dimension, axis, hoveredLegendItem,
42
+ export const CartesianProvider = ({ children, position, dimension, axis, hoveredLegendItem, preventTooltipOpening, hasReversedIndex, hasMirroredDomainsVertical, hasMirroredDomainsHorizontal, }) => (_jsx(CartesianContext.Provider, { value: {
43
+ position,
44
+ dimension,
45
+ axis,
46
+ hoveredLegendItem,
47
+ preventTooltipOpening,
48
+ hasReversedIndex,
49
+ hasMirroredDomainsVertical,
50
+ hasMirroredDomainsHorizontal,
35
51
  }, children: children }));
36
52
  export const useCartesianContext = () => {
37
53
  const context = useContext(CartesianContext);