@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
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Except } from 'type-fest';
3
3
  import { CartesianChartLayout, Data, ThemeVariants } from '../../types';
4
- import { LineChartIndex, LineChartOverlay, LineChartRenderType, LineChartSeries, LineChartTooltip } from '../../types/line-chart';
4
+ import { LineChartIndex, LineChartRenderType, LineChartSeries, LineChartTooltip } from '../../types/line-chart';
5
5
  import { CartesianBaseProps } from '../cartesian-base/cartesian-base';
6
6
  export declare type LineChartProps = {
7
7
  /**
@@ -21,25 +21,33 @@ export declare type LineChartProps = {
21
21
  */
22
22
  renderAs?: LineChartRenderType;
23
23
  /**
24
- * Set the properties associated with the Index Axis.
24
+ * Set the properties associated with the `Index` axis.
25
25
  */
26
26
  index: LineChartIndex;
27
27
  /**
28
- * Set the properties associated with any Series of lines.
28
+ * Set properties associated with any `Series` of lines.
29
29
  */
30
30
  series: LineChartSeries;
31
31
  /**
32
- * Set the properties associated with the Overlay Axis.
32
+ * Set properties associated with the `Overlay` axis.
33
33
  */
34
- overlay?: LineChartOverlay;
34
+ overlay?: LineChartSeries;
35
35
  /**
36
- * Display an average line and label when true.
36
+ * Display an average line and label when `true`.
37
37
  */
38
38
  showAverage?: boolean;
39
39
  /**
40
- * Set extra data or custom content to be displayed in the tooltip.
40
+ * Display a trend line for every single line when `true`.
41
+ */
42
+ showTrendline?: boolean;
43
+ /**
44
+ * Set extra data or custom content to be displayed in the `tooltip`.
41
45
  */
42
46
  tooltip?: LineChartTooltip;
47
+ /**
48
+ * Prevent from displaying the tooltip on the chart when `true`.
49
+ */
50
+ preventTooltipDisplay?: boolean;
43
51
  /**
44
52
  * Prevent showing a connecting line between points when data is missing.
45
53
  */
@@ -75,25 +83,33 @@ export declare const LineChart: import("react").ForwardRefExoticComponent<{
75
83
  */
76
84
  renderAs?: LineChartRenderType | undefined;
77
85
  /**
78
- * Set the properties associated with the Index Axis.
86
+ * Set the properties associated with the `Index` axis.
79
87
  */
80
88
  index: LineChartIndex;
81
89
  /**
82
- * Set the properties associated with any Series of lines.
90
+ * Set properties associated with any `Series` of lines.
83
91
  */
84
92
  series: LineChartSeries;
85
93
  /**
86
- * Set the properties associated with the Overlay Axis.
94
+ * Set properties associated with the `Overlay` axis.
87
95
  */
88
- overlay?: LineChartOverlay | undefined;
96
+ overlay?: LineChartSeries | undefined;
89
97
  /**
90
- * Display an average line and label when true.
98
+ * Display an average line and label when `true`.
91
99
  */
92
100
  showAverage?: boolean | undefined;
93
101
  /**
94
- * Set extra data or custom content to be displayed in the tooltip.
102
+ * Display a trend line for every single line when `true`.
103
+ */
104
+ showTrendline?: boolean | undefined;
105
+ /**
106
+ * Set extra data or custom content to be displayed in the `tooltip`.
95
107
  */
96
108
  tooltip?: LineChartTooltip | undefined;
109
+ /**
110
+ * Prevent from displaying the tooltip on the chart when `true`.
111
+ */
112
+ preventTooltipDisplay?: boolean | undefined;
97
113
  /**
98
114
  * Prevent showing a connecting line between points when data is missing.
99
115
  */
@@ -1 +1 @@
1
- {"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../src/components/line-chart/line-chart.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAOnC,OAAO,EACL,oBAAoB,EACpB,IAAI,EACJ,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,gBAAgB,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EACzE,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAiB,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAErF,oBAAY,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,cAAc,GAAG,eAAe,CAAC,CAAA;AAEzE,eAAO,MAAM,SAAS;IAtDpB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;WACI,cAAc;IACrB;;OAEG;YACK,eAAe;IACvB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;uHAgEH,CAAC"}
1
+ {"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../src/components/line-chart/line-chart.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAOnC,OAAO,EACL,oBAAoB,EACpB,IAAI,EACJ,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EACvD,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAiB,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAErF,oBAAY,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,cAAc,GAAG,eAAe,CAAC,CAAA;AAEzE,eAAO,MAAM,SAAS;IA9DpB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;WACI,cAAc;IACrB;;OAEG;YACK,eAAe;IACvB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;uHAoEH,CAAC"}
@@ -19,7 +19,7 @@ import { useLineChart } from '../../hooks';
19
19
  import { DataProvider, LayoutProvider, ThemeProvider, } from '../../providers';
20
20
  import { CartesianChartLayout, } from '../../types';
21
21
  import { CartesianBase } from '../cartesian-base/cartesian-base';
22
- export const LineChart = forwardRef(({ theme = 'light', layout = CartesianChartLayout.HORIZONTAL, renderAs = 'curves', data = [], index, series, overlay, tooltip, showAverage = false, hideMissingDataConnection = false, showMarker = false, showMarkerLabel = false, hidePadding = false, ...otherProps }, forwardedRef) => {
22
+ export const LineChart = forwardRef(({ theme = 'light', layout = CartesianChartLayout.HORIZONTAL, renderAs = 'curves', data = [], index, series, overlay, tooltip, preventTooltipDisplay = false, showAverage = false, showTrendline = false, hidePadding = false, hideMissingDataConnection = false, showMarker = false, showMarkerLabel = false, ...otherProps }, forwardedRef) => {
23
23
  const { axis, axisFiltered, isHorizontal, metadata, zeroPadding, brushFilteredData, setBrushFilteredData, } = useLineChart({
24
24
  theme,
25
25
  layout,
@@ -29,11 +29,13 @@ export const LineChart = forwardRef(({ theme = 'light', layout = CartesianChartL
29
29
  series,
30
30
  overlay,
31
31
  tooltip,
32
+ preventTooltipDisplay,
33
+ hidePadding,
32
34
  showAverage,
35
+ showTrendline,
33
36
  hideMissingDataConnection,
34
37
  showMarker,
35
38
  showMarkerLabel,
36
- hidePadding,
37
39
  });
38
40
  return (_jsx(ThemeProvider, { theme: theme, children: _jsx(LayoutProvider, { layout: layout, children: _jsx(DataProvider, { data: data, metadata: metadata, filteredData: brushFilteredData, children: _jsx(CartesianBase, { ...otherProps, axis: axis[layout], axisFiltered: axisFiltered[layout], grid: {
39
41
  hideRows: !isHorizontal,
@@ -8,12 +8,12 @@ global.ResizeObserver = jest.fn().mockImplementation(() => ({
8
8
  }));
9
9
  describe('<LineChart>', () => {
10
10
  it('should render the component', () => {
11
- render(_jsx(LineChart, { data: [{ date: 'a', value: 1 }, { date: 'b', value: 2 }], index: { dataKey: 'date' }, series: { dataKey: ['value'] }, overlay: { dataKey: 'value' }, title: "Title" }));
11
+ render(_jsx(LineChart, { data: [{ date: 'a', value: 1 }, { date: 'b', value: 2 }], index: { dataKey: 'date' }, series: { dataKey: ['value'] }, overlay: { dataKey: ['value'] }, title: "Title" }));
12
12
  const element = screen.getByTestId('cartesian');
13
13
  expect(element).toBeDefined();
14
14
  });
15
15
  it('should render the component w/o padding', () => {
16
- render(_jsx(LineChart, { data: [{ date: 'a', value: 1 }, { date: 'b', value: 2 }], index: { dataKey: 'date' }, series: { dataKey: ['value'] }, overlay: { dataKey: 'value' }, hidePadding: true, hideLegend: true }));
16
+ render(_jsx(LineChart, { data: [{ date: 'a', value: 1 }, { date: 'b', value: 2 }], index: { dataKey: 'date' }, series: { dataKey: ['value'] }, overlay: { dataKey: ['value'] }, hidePadding: true, hideLegend: true }));
17
17
  const element = screen.getByTestId('cartesian');
18
18
  expect(element).toBeDefined();
19
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"bar-chart-loader.d.ts","sourceRoot":"","sources":["../../../src/components/loader/bar-chart-loader.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,oBAAY,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,GAAG,aAAa,CAAC,CAAC;CACxD,CAAA;AAED,eAAO,MAAM,cAAc;qCAIxB,mBAAmB;;CA2BrB,CAAC"}
1
+ {"version":3,"file":"bar-chart-loader.d.ts","sourceRoot":"","sources":["../../../src/components/loader/bar-chart-loader.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,oBAAY,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,GAAG,aAAa,CAAC,CAAC;CACxD,CAAA;AAED,eAAO,MAAM,cAAc;qCAIxB,mBAAmB;;CAiDrB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const BarChartLoader = ({ width = 800, height = 600, otherProps, }) => (_jsx("svg", { version: "1.1", id: "Line-Chart-Loader", xmlns: "http:www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}`, "data-testid": "bar-chart-loader", ...otherProps, children: _jsx("g", { transform: `matrix(${width / 848},0,0,${height / (160 * 3)},0,0)`, children: _jsx("g", { transform: `translate(0 ${height / 3})`, children: _jsxs("g", { children: [_jsx("rect", { fill: "#454545", width: "10", height: "100", rx: "4", transform: "translate(0) rotate(180 5 50)", children: _jsx("animate", { attributeName: "height", dur: "1.1s", values: "30; 100; 30", repeatCount: "indefinite" }) }), _jsx("rect", { x: "17", fill: "#454545", width: "10", height: "100", rx: "4", transform: "translate(3) rotate(180 20 50)", children: _jsx("animate", { attributeName: "height", dur: "1.25s", values: "30; 100; 30", repeatCount: "indefinite", begin: "0.1s" }) }), _jsx("rect", { x: "40", fill: "#454545", width: "10", height: "100", rx: "4", transform: "translate(6) rotate(180 38 50)", children: _jsx("animate", { attributeName: "height", dur: "1.15s", values: "30; 100; 30", repeatCount: "indefinite", begin: "0.3s" }) }), _jsx("rect", { x: "60", fill: "#454545", width: "10", height: "100", rx: "4", transform: "translate(9) rotate(180 55 50)", children: _jsx("animate", { attributeName: "height", dur: "1.25s", values: "30; 100; 30", repeatCount: "indefinite", begin: "0.5s" }) }), _jsx("rect", { x: "80", fill: "#454545", width: "10", height: "100", rx: "4", transform: "translate(12) rotate(180 72 50)", children: _jsx("animate", { attributeName: "height", dur: "1.0s", values: "30; 100; 30", repeatCount: "indefinite", begin: "0.1s" }) })] }) }) }) }));
2
+ export const BarChartLoader = ({ width = 800, height = 600, otherProps, }) => (_jsx("svg", { version: "1.1", id: "Bar-Chart-Loader", xmlns: "http:www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}`, "data-testid": "bar-chart-loader", ...otherProps, children: _jsxs("g", { className: "visx-group", transform: "translate(0, 0)", clipPath: "url(#clip-path-loader)", children: [_jsx("rect", { "data-testid": "loader", x: "0", y: "62", width: "1086", height: "270", fill: "transparent" }), _jsx("svg", { version: "1.1", id: "Line-Chart-Loader", xmlns: "http:www.w3.org/2000/svg", viewBox: "0 0 1074 270", children: _jsx("g", { children: _jsxs("g", { transform: "translate(0 250)", children: [_jsx("rect", { x: "0", fill: "slateGray", fillOpacity: "0.75", width: "24", height: "51", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.64s", values: "31; 201; 30", repeatCount: "indefinite", begin: "0.95s" }) }), _jsx("rect", { x: "30", fill: "slateGray", fillOpacity: "0.93", width: "24", height: "60", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.2s5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.01s", values: "30; 201; 30", repeatCount: "indefinite", begin: "0.25s" }) }), _jsx("rect", { x: "60", fill: "slateGray", fillOpacity: "0.32", width: "24", height: "100", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.06s", values: "31; 201; 31", repeatCount: "indefinite", begin: "0.51s" }) }), _jsx("rect", { x: "90", fill: "slateGray", fillOpacity: "0.23", width: "24", height: "200", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.96s", values: "31; 200; 30", repeatCount: "indefinite", begin: "0.60s" }) }), _jsx("rect", { x: "120", fill: "slateGray", fillOpacity: "0.51", width: "24", height: "120", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.98s", values: "31; 200; 31", repeatCount: "indefinite", begin: "0.22s" }) }), _jsx("rect", { x: "150", fill: "slateGray", fillOpacity: "0.12", width: "24", height: "180", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.85s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.41s" }) }), _jsx("rect", { x: "180", fill: "slateGray", fillOpacity: "0.74", width: "24", height: "130", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.28s", values: "30; 201; 31", repeatCount: "indefinite", begin: "0.70s" }) }), _jsx("rect", { x: "210", fill: "slateGray", fillOpacity: "0.04", width: "24", height: "900", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.90s", values: "30; 201; 31", repeatCount: "indefinite", begin: "0.34s" }) }), _jsx("rect", { x: "240", fill: "slateGray", fillOpacity: "0.14", width: "24", height: "110", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.79s", values: "31; 200; 31", repeatCount: "indefinite", begin: "0.49s" }) }), _jsx("rect", { x: "270", fill: "slateGray", fillOpacity: "0.73", width: "24", height: "40", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.27s", values: "30; 201; 31", repeatCount: "indefinite", begin: "0.66s" }) }), _jsx("rect", { x: "300", fill: "slateGray", fillOpacity: "0.25", width: "24", height: "60", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.40s", values: "30; 200; 31", repeatCount: "indefinite", begin: "0.64s" }) }), _jsx("rect", { x: "330", fill: "slateGray", fillOpacity: "0.82", width: "24", height: "30", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.33s", values: "31; 200; 30", repeatCount: "indefinite", begin: "0.64s" }) }), _jsx("rect", { x: "360", fill: "slateGray", fillOpacity: "0.67", width: "24", height: "70", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.05s", values: "30; 201; 31", repeatCount: "indefinite", begin: "0.66s" }) }), _jsx("rect", { x: "390", fill: "slateGray", fillOpacity: "0.29", width: "24", height: "75", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.92s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.76s" }) }), _jsx("rect", { x: "420", fill: "slateGray", fillOpacity: "0.68", width: "24", height: "130", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.74s", values: "30; 200; 31", repeatCount: "indefinite", begin: "0.70s" }) }), _jsx("rect", { x: "450", fill: "slateGray", fillOpacity: "0.70", width: "24", height: "140", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.45s", values: "31; 201; 30", repeatCount: "indefinite", begin: "0.41s" }) }), _jsx("rect", { x: "480", fill: "slateGray", fillOpacity: "0.76", width: "24", height: "190", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.87s", values: "31; 201; 31", repeatCount: "indefinite", begin: "0.08s" }) }), _jsx("rect", { x: "510", fill: "slateGray", fillOpacity: "0.19", width: "24", height: "110", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.64s", values: "31; 201; 30", repeatCount: "indefinite", begin: "0.32s" }) }), _jsx("rect", { x: "540", fill: "slateGray", fillOpacity: "0.20", width: "24", height: "90", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.24s", values: "30; 200; 31", repeatCount: "indefinite", begin: "0.33s" }) }), _jsx("rect", { x: "570", fill: "slateGray", fillOpacity: "0.32", width: "24", height: "120", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.06s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.59s" }) }), _jsx("rect", { x: "600", fill: "slateGray", fillOpacity: "0.49", width: "24", height: "20", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.51s", values: "31; 201; 31", repeatCount: "indefinite", begin: "0.83s" }) }), _jsx("rect", { x: "630", fill: "slateGray", fillOpacity: "0.63", width: "24", height: "60", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.45s", values: "30; 201; 31", repeatCount: "indefinite", begin: "0.42s" }) }), _jsx("rect", { x: "660", fill: "slateGray", fillOpacity: "0.73", width: "24", height: "90", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.13s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.19s" }) }), _jsx("rect", { x: "690", fill: "slateGray", fillOpacity: "0.61", width: "24", height: "120", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.77s", values: "30; 201; 30", repeatCount: "indefinite", begin: "0.23s" }) }), _jsx("rect", { x: "720", fill: "slateGray", fillOpacity: "0.76", width: "24", height: "110", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.34s", values: "31; 201; 30", repeatCount: "indefinite", begin: "0.51s" }) }), _jsx("rect", { x: "750", fill: "slateGray", fillOpacity: "0.21", width: "24", height: "180", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.47s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.66s" }) }), _jsx("rect", { x: "780", fill: "slateGray", fillOpacity: "0.76", width: "24", height: "150", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.49s", values: "31; 200; 31", repeatCount: "indefinite", begin: "0.46s" }) }), _jsx("rect", { x: "810", fill: "slateGray", fillOpacity: "0.86", width: "24", height: "20", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.50s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.56s" }) }), _jsx("rect", { x: "840", fill: "slateGray", fillOpacity: "0.86", width: "24", height: "200", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.18s", values: "31; 201; 31", repeatCount: "indefinite", begin: "0.50s" }) }), _jsx("rect", { x: "870", fill: "slateGray", fillOpacity: "0.63", width: "24", height: "120", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.82s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.40s" }) }), _jsx("rect", { x: "900", fill: "slateGray", fillOpacity: "0.03", width: "24", height: "100", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.11s", values: "30; 201; 31", repeatCount: "indefinite", begin: "0.83s" }) }), _jsx("rect", { x: "930", fill: "slateGray", fillOpacity: "0.97", width: "24", height: "190", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.80s", values: "30; 200; 30", repeatCount: "indefinite", begin: "0.26s" }) }), _jsx("rect", { x: "960", fill: "slateGray", fillOpacity: "0.04", width: "24", height: "80", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.84s", values: "31; 200; 30", repeatCount: "indefinite", begin: "0.33s" }) }), _jsx("rect", { x: "990", fill: "slateGray", fillOpacity: "0.58", width: "24", height: "30", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.25px)' }, children: _jsx("animate", { attributeName: "height", dur: "1.99s", values: "30; 200; 31", repeatCount: "indefinite", begin: "0.69s" }) }), _jsx("rect", { x: "1020", fill: "slateGray", fillOpacity: "0.81", width: "24", height: "50", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.57s", values: "30; 200; 31", repeatCount: "indefinite", begin: "0.48s" }) }), _jsx("rect", { x: "1050", fill: "slateGray", fillOpacity: "0.95", width: "24", height: "20", rx: "4", transform: "scale(1 -1)", style: { style: 'blur(0.5px)' }, children: _jsx("animate", { attributeName: "height", dur: "2.66s", values: "30; 201; 30", repeatCount: "indefinite", begin: "0.73s" }) })] }) }) })] }) }));
3
3
  BarChartLoader.displayName = 'BarChartLoader';
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /*
3
- * Copyright 2022-2023 Wonderflow Design Team
3
+ * Copyright 2022-2024 Wonderflow Design Team
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -31,5 +31,5 @@ export const Loader = ({ isLoading = false, left = 0, top = 0, width = 800, heig
31
31
  const rightExtraPadding = metadata?.hidePadding ? 12 : 0;
32
32
  if (!isLoading)
33
33
  return null;
34
- return (_jsxs(Group, { children: [_jsx(RectClipPath, { id: "clip-path-loader", x: left, y: top, width: width + rightExtraPadding, height: height }), _jsx(LinearGradient, { id: "loader-gradient", from: to, to: from }), _jsxs(Group, { clipPath: "url(#clip-path-loader)", children: [_jsx("rect", { "data-testid": "loader", x: left, y: top, width: width + rightExtraPadding, height: height, fill: "url(#loader-gradient)" }), isLineChart && (_jsx(LineChartLoader, { width: width, height: height })), isBarChart && (_jsx(BarChartLoader, {}))] })] }));
34
+ return (_jsxs(Group, { children: [_jsx(RectClipPath, { id: "clip-path-loader", x: left, y: top, width: width + rightExtraPadding, height: height }), _jsx(LinearGradient, { id: "loader-gradient", from: to, to: from }), _jsxs(Group, { clipPath: "url(#clip-path-loader)", children: [_jsx("rect", { "data-testid": "loader", x: left, y: top, width: width + rightExtraPadding, height: height, fill: "url(#loader-gradient)" }), isLineChart && (_jsx(LineChartLoader, { width: width, height: height })), isBarChart && (_jsx(BarChartLoader, { width: width, height: height }))] })] }));
35
35
  };
@@ -13,11 +13,13 @@ const mockMetadata = {
13
13
  names: ['A', 'B'],
14
14
  colors: ['ca', 'cb'],
15
15
  average: undefined,
16
+ trendline: undefined,
16
17
  },
17
18
  overlay: {
18
- name: '',
19
- color: '',
19
+ names: [''],
20
+ colors: [''],
20
21
  average: undefined,
22
+ trendline: undefined,
21
23
  },
22
24
  hidePadding: true,
23
25
  };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const BarsAverage: React.FC;
3
+ //# sourceMappingURL=bars-average.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bars-average.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars-average.tsx"],"names":[],"mappings":";AAyBA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EA+F/B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023-2024 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 { Line } from '@visx/shape';
20
+ import { useAverage } from '../../../hooks';
21
+ import { useLayoutContext, useStyleConfigContext, useThemeContext, } from '../../../providers';
22
+ export const BarsAverage = () => {
23
+ const theme = useThemeContext();
24
+ const { themes } = useStyleConfigContext();
25
+ const { isHorizontal } = useLayoutContext();
26
+ const { averageSeries, averageOverlay, hasAverageSeries, hasAverageOverlay, hasAverageOverlayLabel, hasAverageSeriesLabel, coordinates, style, } = useAverage();
27
+ const { backgroundPadding, backgroundProps, maxLabelWidth, opacity, pointerEvents, strokeDasharray, strokeWidth, titleFontSize, titleFontWeight, titleProps, } = style;
28
+ return (_jsxs(Group, { children: [hasAverageSeries && (_jsx(Line, { from: coordinates.series.from, to: coordinates.series.to, stroke: themes[theme].lines.average, strokeWidth: strokeWidth, pointerEvents: pointerEvents, strokeDasharray: strokeDasharray, opacity: opacity })), hasAverageOverlay && (_jsx(Line, { from: coordinates.overlay.from, to: coordinates.overlay.to, stroke: themes[theme].lines.average, strokeWidth: strokeWidth, pointerEvents: pointerEvents, strokeDasharray: strokeDasharray, opacity: opacity })), hasAverageSeriesLabel && (_jsx(Label, { backgroundFill: themes[theme].lines.average, x: coordinates.series.label.x, y: coordinates.series.label.y, fontColor: themes[theme].lines.averageFontColor, title: `Average: ${averageSeries}`, titleFontSize: titleFontSize, titleFontWeight: titleFontWeight, titleProps: titleProps, showAnchorLine: false, horizontalAnchor: isHorizontal ? 'start' : 'middle', verticalAnchor: "middle", showBackground: true, backgroundPadding: backgroundPadding, backgroundProps: backgroundProps, maxWidth: maxLabelWidth })), hasAverageOverlayLabel && (_jsx(Label, { backgroundFill: themes[theme].lines.average, x: coordinates.overlay.label.x, y: coordinates.overlay.label.y, fontColor: themes[theme].lines.averageFontColor, title: `Average: ${averageOverlay}`, titleFontSize: titleFontSize, titleFontWeight: titleFontWeight, titleProps: titleProps, showAnchorLine: false, horizontalAnchor: isHorizontal ? 'end' : 'middle', verticalAnchor: "middle", showBackground: true, backgroundPadding: backgroundPadding, backgroundProps: backgroundProps, maxWidth: maxLabelWidth }))] }));
29
+ };
30
+ BarsAverage.displayName = 'BarsAverage';
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const BarsOverlay: {
3
+ (): JSX.Element | null;
4
+ displayName: string;
5
+ };
6
+ //# sourceMappingURL=bars-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bars-overlay.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars-overlay.tsx"],"names":[],"mappings":";AA8BA,eAAO,MAAM,WAAW;;;CAmJvB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2024 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 { Bar, BarGroup, BarGroupHorizontal } from '@visx/shape';
19
+ import _ from 'lodash';
20
+ import { useCallback } from 'react';
21
+ import { useBars } from '../../../hooks';
22
+ import { extractBarValueFromNestedKey, getBarSizeAndPosition, getBarThickness } from '../../../utils';
23
+ import { useCartesianContext, useStyleConfigContext, useThemeContext, } from '../../../providers';
24
+ import { sortBarsBy } from '../../../utils';
25
+ import { BarsItem, BarsItemBlurred } from './bars.module.css';
26
+ export const BarsOverlay = () => {
27
+ const { hoveredLegendItem: overLegend } = useCartesianContext();
28
+ const theme = useThemeContext();
29
+ const { themes } = useStyleConfigContext();
30
+ const { data, isHorizontal, overlay, sortBy, hasBackgroundOverlay, overlayAxis, hasOverlay, maxWidth, maxHeight, X0Y0, scaleXY0, scaleXY1, fixedBarSize, style, } = useBars();
31
+ const { bar: barStyle, background, maxSize } = style;
32
+ const bgColor = themes[theme].bars.backgroundColor;
33
+ const dynamicClassName = useCallback((overLegend, dataKey) => ((overLegend === dataKey || overLegend === '')
34
+ ? BarsItem
35
+ : BarsItemBlurred), []);
36
+ if (!hasOverlay)
37
+ return null;
38
+ if (!isHorizontal) {
39
+ return (_jsx(BarGroupHorizontal, { data: data, keys: overlay.dataKey, width: maxWidth, y0: X0Y0, y0Scale: scaleXY0, y1Scale: scaleXY1, xScale: overlayAxis.scale, color: (_, i) => overlay.colors[i], children: barGroups => barGroups.map((barGroup, i) => {
40
+ const updatedBars = extractBarValueFromNestedKey(barGroup, i, data, overlayAxis.scale, maxWidth, isHorizontal);
41
+ const sortedBars = sortBarsBy(updatedBars, sortBy, isHorizontal);
42
+ return (_jsx(Group, { top: barGroup.y0, children: sortedBars.map((bar) => {
43
+ const { x, width } = getBarSizeAndPosition(bar, overlayAxis, isHorizontal);
44
+ const thickness = getBarThickness(bar.height, maxSize, fixedBarSize);
45
+ return (_jsxs(Group, { children: [hasBackgroundOverlay && (_jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: 0, y: bar.y, width: maxWidth, height: thickness, fill: bgColor, opacity: background.opacity, rx: background.rx })), _jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: x, y: bar.y, width: width, height: thickness, fill: bar.color, rx: barStyle.rx, opacity: barStyle.opacity, onClick: () => ({}) })] }, _.uniqueId()));
46
+ }) }, _.uniqueId()));
47
+ }) }));
48
+ }
49
+ return (_jsx(BarGroup, { data: data, keys: overlay.dataKey, height: maxHeight, x0: X0Y0, x0Scale: scaleXY0, x1Scale: scaleXY1, yScale: overlayAxis.scale, color: (_, i) => overlay.colors[i], children: barGroups => barGroups.map((barGroup, i) => {
50
+ const updatedBars = extractBarValueFromNestedKey(barGroup, i, data, overlayAxis.scale, maxHeight, isHorizontal);
51
+ const sortedBars = sortBarsBy(updatedBars, sortBy, isHorizontal);
52
+ return (_jsx(Group, { left: barGroup.x0, children: sortedBars.map((bar) => {
53
+ const { y, height } = getBarSizeAndPosition(bar, overlayAxis, isHorizontal);
54
+ const thickness = getBarThickness(bar.width, maxSize, fixedBarSize);
55
+ return (_jsxs(Group, { children: [hasBackgroundOverlay && (_jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: bar.x, y: 0, width: thickness, height: maxHeight, fill: bgColor, opacity: background.opacity, rx: background.rx })), _jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: bar.x, y: y, width: thickness, height: height, fill: bar.color, opacity: barStyle.opacity, rx: barStyle.rx, onClick: () => ({}) })] }, _.uniqueId()));
56
+ }) }, _.uniqueId()));
57
+ }) }));
58
+ };
59
+ BarsOverlay.displayName = 'BarOverlay';
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const BarsSeries: {
3
+ (): JSX.Element;
4
+ displayName: string;
5
+ };
6
+ //# sourceMappingURL=bars-series.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bars-series.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars-series.tsx"],"names":[],"mappings":";AA+BA,eAAO,MAAM,UAAU;;;CA8ItB,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2024 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 { Bar, BarGroup, BarGroupHorizontal } from '@visx/shape';
19
+ import _ from 'lodash';
20
+ import { useCallback } from 'react';
21
+ import { useBars } from '../../../hooks';
22
+ import { extractBarValueFromNestedKey, getBarSizeAndPosition, getBarThickness, sortBarsBy, } from '../../../utils';
23
+ import { useCartesianContext, useStyleConfigContext, useThemeContext } from '../../../providers';
24
+ import { BarsItem, BarsItemBlurred } from './bars.module.css';
25
+ export const BarsSeries = () => {
26
+ const { hoveredLegendItem: overLegend } = useCartesianContext();
27
+ const theme = useThemeContext();
28
+ const { themes } = useStyleConfigContext();
29
+ const { data, isHorizontal, series, sortBy, hasBackgroundSeries, seriesAxis, maxWidth, maxHeight, X0Y0, scaleXY0, scaleXY1, style, fixedBarSize, } = useBars();
30
+ const { bar: barStyle, background, maxSize } = style;
31
+ const bgColor = themes[theme].bars.backgroundColor;
32
+ const dynamicClassName = useCallback((overLegend, dataKey) => ((overLegend === dataKey || overLegend === '')
33
+ ? BarsItem
34
+ : BarsItemBlurred), []);
35
+ if (!isHorizontal) {
36
+ return (_jsx(BarGroupHorizontal, { data: data, keys: series.dataKey, width: maxWidth, y0: X0Y0, y0Scale: scaleXY0, y1Scale: scaleXY1, xScale: seriesAxis.scale, color: (_, i) => series.colors[i], children: barGroups => barGroups.map((barGroup, i) => {
37
+ const updatedBars = extractBarValueFromNestedKey(barGroup, i, data, seriesAxis.scale, maxWidth, isHorizontal);
38
+ const sortedBars = sortBarsBy(updatedBars, sortBy, isHorizontal);
39
+ return (_jsx(Group, { top: barGroup.y0, children: sortedBars.map((bar) => {
40
+ const { x, width } = getBarSizeAndPosition(bar, seriesAxis, isHorizontal);
41
+ const thickness = getBarThickness(bar.height, maxSize, fixedBarSize);
42
+ return (_jsxs(Group, { children: [hasBackgroundSeries && (_jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: 0, y: bar.y, width: maxWidth, height: thickness, fill: bgColor, opacity: background.opacity, rx: background.rx })), _jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: x, y: bar.y, width: width, height: thickness, fill: bar.color, rx: barStyle.rx, opacity: barStyle.opacity, onClick: () => ({}) })] }, _.uniqueId()));
43
+ }) }, _.uniqueId()));
44
+ }) }));
45
+ }
46
+ return (_jsx(BarGroup, { data: data, keys: series.dataKey, height: maxHeight, x0: X0Y0, x0Scale: scaleXY0, x1Scale: scaleXY1, yScale: seriesAxis.scale, color: (_, i) => series.colors[i], children: barGroups => barGroups.map((barGroup, i) => {
47
+ const updatedBars = extractBarValueFromNestedKey(barGroup, i, data, seriesAxis.scale, maxHeight, isHorizontal);
48
+ const sortedBars = sortBarsBy(updatedBars, sortBy, isHorizontal);
49
+ return (_jsx(Group, { left: barGroup.x0, children: sortedBars.map((bar) => {
50
+ const { y, height } = getBarSizeAndPosition(bar, seriesAxis, isHorizontal);
51
+ const thickness = getBarThickness(bar.width, maxSize, fixedBarSize);
52
+ return (_jsxs(Group, { children: [hasBackgroundSeries && (_jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: bar.x, y: 0, width: thickness, height: maxHeight, fill: bgColor, opacity: background.opacity, rx: background.rx })), _jsx(Bar, { className: dynamicClassName(overLegend, bar.key), x: bar.x, y: y, width: thickness, height: height, fill: bar.color, opacity: barStyle.opacity, rx: barStyle.rx, onClick: () => ({}) }, _.uniqueId())] }, _.uniqueId()));
53
+ }) }, _.uniqueId()));
54
+ }) }));
55
+ };
56
+ BarsSeries.displayName = 'BarSeries';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const BarsTooltip: React.FC;
3
+ //# sourceMappingURL=bars-tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bars-tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars-tooltip.tsx"],"names":[],"mappings":";AA0DA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAkN/B,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023-2024 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 { useTooltip, useTooltipInPortal } from '@visx/tooltip';
22
+ import _ from 'lodash';
23
+ import { useCallback } from 'react';
24
+ import { v4 as uuid } from 'uuid';
25
+ import { useBars } from '../../../hooks';
26
+ import { useStyleConfigContext, useThemeContext, } from '../../../providers';
27
+ import { tooltipTheme } from '../../../style-config/tooltip';
28
+ import { accessorInvert, bisectIndex, getLabelFromPath, getPrimitiveFromObjectByPath, } from '../../../utils';
29
+ import { Placeholder } from '../../placeholder';
30
+ import { Tooltip } from '../../tooltip';
31
+ import { BarsTooltipContent, BarsTooltipItem, ExtraContent, NoData, } from './bars.module.css';
32
+ export const BarsTooltip = ({ children }) => {
33
+ const theme = useThemeContext();
34
+ const { bars, themes } = useStyleConfigContext();
35
+ const { data, hasOverlay, isHorizontal, index, indexAxis, maxWidth: xMax, maxHeight: yMax, overlay, series,
36
+ // sortBy,
37
+ preventTooltipDisplay, preventTooltipOpening, tooltip, scaleXY0, } = useBars();
38
+ const { tooltipLeft, tooltipTop, tooltipOpen, tooltipData, hideTooltip, showTooltip, } = useTooltip();
39
+ const { containerRef, containerBounds } = useTooltipInPortal({
40
+ detectBounds: true,
41
+ scroll: true,
42
+ debounce: 500,
43
+ zIndex: 4,
44
+ });
45
+ const handleTooltip = useCallback((event) => {
46
+ const { scaleType, domain, } = indexAxis;
47
+ const { top: tBound, left: lBound } = containerBounds;
48
+ const hiddenPos = { x: -999, y: -999 };
49
+ const xy = isHorizontal ? 'x' : 'y';
50
+ const coords = localPoint(event.target.ownerSVGElement, event) ?? hiddenPos;
51
+ const accessorInvertValue = accessorInvert({ ...indexAxis, domain: scaleXY0.domain() }, coords[xy]);
52
+ const indexOfBisectValue = scaleType === 'label'
53
+ ? domain.indexOf(accessorInvertValue)
54
+ : bisectIndex(domain, accessorInvertValue, 0) - 1;
55
+ const domainIndexValue = domain[indexOfBisectValue];
56
+ const indexScaleValue = scaleType === 'label'
57
+ ? accessorInvertValue
58
+ : new Date(domainIndexValue);
59
+ const barIndicatorPos = scaleXY0(indexScaleValue) ?? -999;
60
+ const barIndicatorSize = scaleXY0.bandwidth();
61
+ const tooltipLeft = ('clientX' in event ? event.clientX : 0) - lBound / 8;
62
+ const tooltipTop = ('clientY' in event ? event.clientY : 0) - tBound / 8;
63
+ const datum = data[indexOfBisectValue];
64
+ const hasSeriesData = series.dataKey.every(s => !_.isNil(getPrimitiveFromObjectByPath(datum, s)));
65
+ const hasOverlayData = overlay.dataKey?.every(s => !_.isNil(getPrimitiveFromObjectByPath(datum, s)));
66
+ const tooltipData = {
67
+ coords,
68
+ data: datum,
69
+ hasData: hasSeriesData || hasOverlayData,
70
+ barIndicatorPos,
71
+ barIndicatorSize,
72
+ };
73
+ showTooltip({
74
+ tooltipLeft,
75
+ tooltipTop,
76
+ tooltipData,
77
+ });
78
+ }, [indexAxis, containerBounds, isHorizontal, scaleXY0, data, series.dataKey, overlay.dataKey, showTooltip]);
79
+ const hasTooltip = Boolean(tooltipData?.data && !preventTooltipOpening && !preventTooltipDisplay);
80
+ return (_jsxs(_Fragment, { children: [hasTooltip && (_jsx("rect", { x: isHorizontal ? tooltipData?.barIndicatorPos : 0, y: isHorizontal ? 0 : tooltipData?.barIndicatorPos, width: isHorizontal ? tooltipData?.barIndicatorSize : xMax, height: isHorizontal ? yMax : tooltipData?.barIndicatorSize, fill: themes[theme].bars.overlayColor, fillOpacity: bars.overlay.opacity })), children, _jsx("rect", { id: "transparent-overlay-layer", "data-testid": "transparent-overlay-layer", x: -5, y: -5, width: Number(xMax) + 10, height: Number(yMax) + 10, fill: "transparent", ref: containerRef, onMouseMove: e => handleTooltip(e), onTouchMove: e => handleTooltip(e), onTouchStart: e => handleTooltip(e), onMouseOut: hideTooltip, onMouseLeave: hideTooltip }), hasTooltip
81
+ && (_jsxs(Tooltip, { isOpen: tooltipOpen, top: tooltipTop, left: tooltipLeft, children: [_jsxs("div", { className: BarsTooltipContent, "data-testid": "tooltip", children: [_jsx("p", { children: _jsx("b", { children: indexAxis?.tickFormat
82
+ ? indexAxis.tickFormat(getPrimitiveFromObjectByPath(tooltipData?.data, index) ?? '')
83
+ : getPrimitiveFromObjectByPath(tooltipData?.data, index) ?? '' }) }), _jsxs("ul", { children: [series.dataKey.map((dataKey, di) => (_jsxs("li", { children: [_jsxs("div", { className: BarsTooltipItem, 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 && overlay.dataKey?.map((dataKey, di) => (_jsxs("li", { children: [_jsxs("div", { className: BarsTooltipItem, children: [_jsx(Placeholder, { color: overlay.colors?.[di] }), _jsx("span", { children: overlay.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())))] })] }), (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" })] }))] }))] }));
84
+ };
85
+ BarsTooltip.displayName = 'BarsTooltip';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const BarsTrendline: React.FC;
3
+ //# sourceMappingURL=bars-trendline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bars-trendline.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars-trendline.tsx"],"names":[],"mappings":";AA+BA,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAqEjC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023-2024 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 { Line } from '@visx/shape';
19
+ import _ from 'lodash';
20
+ import { useCallback } from 'react';
21
+ import { useTrendline } from '../../../hooks';
22
+ import { useCartesianContext, } from '../../../providers';
23
+ import { BarsItem, BarsItemBlurred, } from './bars.module.css';
24
+ export const BarsTrendline = () => {
25
+ const { hoveredLegendItem: overLegend } = useCartesianContext();
26
+ const { series, overlay, seriesAxis, overlayAxis, hasTrendlineSeries, hasTrendlineOverlay, getCoordinates, style, } = useTrendline();
27
+ const { opacity, pointerEvents, strokeDasharray, strokeWidth, } = style;
28
+ const dynamicClassName = useCallback((overLegend, dataKey) => ((overLegend === dataKey || overLegend === '')
29
+ ? BarsItem
30
+ : BarsItemBlurred), []);
31
+ return (_jsxs(Group, { children: [hasTrendlineSeries && series.trendline.map((t, i) => {
32
+ const from = seriesAxis?.scale(t.from) ?? 0;
33
+ const to = seriesAxis?.scale(t.to) ?? 0;
34
+ const coordinates = getCoordinates(from, to);
35
+ return (_jsx(Line, { className: dynamicClassName(overLegend, series.dataKey[i]), from: coordinates.from, to: coordinates.to, stroke: series.colors[i], strokeWidth: strokeWidth, pointerEvents: pointerEvents, strokeDasharray: strokeDasharray, opacity: opacity }, _.uniqueId()));
36
+ }), hasTrendlineOverlay && overlay.trendline.map((t, i) => {
37
+ const from = overlayAxis?.scale(t.from) ?? 0;
38
+ const to = overlayAxis?.scale(t.to) ?? 0;
39
+ const coordinates = getCoordinates(from, to);
40
+ return (_jsx(Line, { className: dynamicClassName(overLegend, overlay.dataKey[i]), from: coordinates.from, to: coordinates.to, stroke: overlay.colors[i], strokeWidth: strokeWidth, pointerEvents: pointerEvents, strokeDasharray: strokeDasharray, opacity: opacity }, _.uniqueId()));
41
+ })] }));
42
+ };
43
+ BarsTrendline.displayName = 'BarsTrendline';
@@ -1 +1 @@
1
- {"version":3,"file":"bars.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars.tsx"],"names":[],"mappings":";AAuBA,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAiBxB,CAAC"}
1
+ {"version":3,"file":"bars.d.ts","sourceRoot":"","sources":["../../../../src/components/shapes/bars/bars.tsx"],"names":[],"mappings":";AA2BA,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAgCxB,CAAC"}