@redsift/charts 11.5.0 → 11.6.0-muiv5-alpha.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 (223) hide show
  1. package/_virtual/_rollupPluginBabelHelpers.js +93 -0
  2. package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/components/Arc/Arc.d.ts +6 -0
  4. package/components/Arc/Arc.js +74 -0
  5. package/components/Arc/Arc.js.map +1 -0
  6. package/components/Arc/styles.d.ts +17 -0
  7. package/components/Arc/styles.js +49 -0
  8. package/components/Arc/styles.js.map +1 -0
  9. package/components/Arc/types.d.ts +20 -0
  10. package/components/Arcs/Arcs.d.ts +6 -0
  11. package/components/Arcs/Arcs.js +90 -0
  12. package/components/Arcs/Arcs.js.map +1 -0
  13. package/components/Arcs/styles.d.ts +9 -0
  14. package/components/Arcs/styles.js +9 -0
  15. package/components/Arcs/styles.js.map +1 -0
  16. package/components/Arcs/types.d.ts +17 -0
  17. package/components/Axis/Axis.d.ts +7 -0
  18. package/components/Axis/Axis.js +211 -0
  19. package/components/Axis/Axis.js.map +1 -0
  20. package/components/Axis/computeTicks.js +117 -0
  21. package/components/Axis/computeTicks.js.map +1 -0
  22. package/components/Axis/styles.d.ts +14 -0
  23. package/components/Axis/styles.js +51 -0
  24. package/components/Axis/styles.js.map +1 -0
  25. package/components/Axis/types.d.ts +89 -0
  26. package/components/Axis/types.js +24 -0
  27. package/components/Axis/types.js.map +1 -0
  28. package/components/Bar/Bar.d.ts +6 -0
  29. package/components/Bar/Bar.js +95 -0
  30. package/components/Bar/Bar.js.map +1 -0
  31. package/components/Bar/styles.d.ts +16 -0
  32. package/components/Bar/styles.js +66 -0
  33. package/components/Bar/styles.js.map +1 -0
  34. package/components/Bar/types.d.ts +46 -0
  35. package/components/Bar/types.js +18 -0
  36. package/components/Bar/types.js.map +1 -0
  37. package/components/BarChart/BarChart.d.ts +29 -0
  38. package/components/BarChart/BarChart.js +141 -0
  39. package/components/BarChart/BarChart.js.map +1 -0
  40. package/components/BarChart/BarChartBars.js +168 -0
  41. package/components/BarChart/BarChartBars.js.map +1 -0
  42. package/components/BarChart/BarChartSection.js +139 -0
  43. package/components/BarChart/BarChartSection.js.map +1 -0
  44. package/components/BarChart/EmptyBarChart.js +57 -0
  45. package/components/BarChart/EmptyBarChart.js.map +1 -0
  46. package/components/BarChart/LoadingBarChart.js +18 -0
  47. package/components/BarChart/LoadingBarChart.js.map +1 -0
  48. package/components/BarChart/RenderedLinearBarChart.js +549 -0
  49. package/components/BarChart/RenderedLinearBarChart.js.map +1 -0
  50. package/components/BarChart/RenderedOrdinalBarChart.js +236 -0
  51. package/components/BarChart/RenderedOrdinalBarChart.js.map +1 -0
  52. package/components/BarChart/context.js +13 -0
  53. package/components/BarChart/context.js.map +1 -0
  54. package/components/BarChart/intl/en-US.json.js +17 -0
  55. package/components/BarChart/intl/en-US.json.js.map +1 -0
  56. package/components/BarChart/intl/fr-FR.json.js +17 -0
  57. package/components/BarChart/intl/fr-FR.json.js.map +1 -0
  58. package/components/BarChart/intl/index.js +10 -0
  59. package/components/BarChart/intl/index.js.map +1 -0
  60. package/components/BarChart/styles.d.ts +19 -0
  61. package/components/BarChart/styles.js +71 -0
  62. package/components/BarChart/styles.js.map +1 -0
  63. package/components/BarChart/types.d.ts +177 -0
  64. package/components/BarChart/types.js +17 -0
  65. package/components/BarChart/types.js.map +1 -0
  66. package/components/BarChart/utils.js +69 -0
  67. package/components/BarChart/utils.js.map +1 -0
  68. package/components/ChartContainer/ChartContainer.d.ts +9 -0
  69. package/components/ChartContainer/ChartContainer.js +167 -0
  70. package/components/ChartContainer/ChartContainer.js.map +1 -0
  71. package/components/ChartContainer/context.js +6 -0
  72. package/components/ChartContainer/context.js.map +1 -0
  73. package/components/ChartContainer/intl/en-US.json.js +14 -0
  74. package/components/ChartContainer/intl/en-US.json.js.map +1 -0
  75. package/components/ChartContainer/intl/fr-FR.json.js +14 -0
  76. package/components/ChartContainer/intl/fr-FR.json.js.map +1 -0
  77. package/components/ChartContainer/intl/index.js +10 -0
  78. package/components/ChartContainer/intl/index.js.map +1 -0
  79. package/components/ChartContainer/styles.d.ts +17 -0
  80. package/components/ChartContainer/styles.js +76 -0
  81. package/components/ChartContainer/styles.js.map +1 -0
  82. package/components/ChartContainer/types.d.ts +48 -0
  83. package/components/DataPoint/DataPoint.d.ts +6 -0
  84. package/components/DataPoint/DataPoint.js +104 -0
  85. package/components/DataPoint/DataPoint.js.map +1 -0
  86. package/components/DataPoint/styles.d.ts +12 -0
  87. package/components/DataPoint/styles.js +10 -0
  88. package/components/DataPoint/styles.js.map +1 -0
  89. package/components/DataPoint/types.d.ts +60 -0
  90. package/components/Dot/Dot.d.ts +6 -0
  91. package/components/Dot/Dot.js +55 -0
  92. package/components/Dot/Dot.js.map +1 -0
  93. package/components/Dot/styles.d.ts +16 -0
  94. package/components/Dot/styles.js +49 -0
  95. package/components/Dot/styles.js.map +1 -0
  96. package/components/Dot/types.d.ts +30 -0
  97. package/components/Dot/types.js +14 -0
  98. package/components/Dot/types.js.map +1 -0
  99. package/components/Legend/Legend.d.ts +6 -0
  100. package/components/Legend/Legend.js +73 -0
  101. package/components/Legend/Legend.js.map +1 -0
  102. package/components/Legend/styles.d.ts +11 -0
  103. package/components/Legend/styles.js +15 -0
  104. package/components/Legend/styles.js.map +1 -0
  105. package/components/Legend/types.d.ts +44 -0
  106. package/components/LegendItem/LegendItem.js +96 -0
  107. package/components/LegendItem/LegendItem.js.map +1 -0
  108. package/components/LegendItem/styles.js +63 -0
  109. package/components/LegendItem/styles.js.map +1 -0
  110. package/components/LegendItem/types.d.ts +20 -0
  111. package/components/Line/Line.d.ts +6 -0
  112. package/components/Line/Line.js +55 -0
  113. package/components/Line/Line.js.map +1 -0
  114. package/components/Line/styles.d.ts +9 -0
  115. package/components/Line/styles.js +9 -0
  116. package/components/Line/styles.js.map +1 -0
  117. package/components/Line/types.d.ts +21 -0
  118. package/components/LineChart/EmptyLineChart.js +58 -0
  119. package/components/LineChart/EmptyLineChart.js.map +1 -0
  120. package/components/LineChart/LineChart.d.ts +6 -0
  121. package/components/LineChart/LineChart.js +96 -0
  122. package/components/LineChart/LineChart.js.map +1 -0
  123. package/components/LineChart/LoadingLineChart.js +18 -0
  124. package/components/LineChart/LoadingLineChart.js.map +1 -0
  125. package/components/LineChart/RenderedLineChart.js +372 -0
  126. package/components/LineChart/RenderedLineChart.js.map +1 -0
  127. package/components/LineChart/intl/en-US.json.js +17 -0
  128. package/components/LineChart/intl/en-US.json.js.map +1 -0
  129. package/components/LineChart/intl/fr-FR.json.js +17 -0
  130. package/components/LineChart/intl/fr-FR.json.js.map +1 -0
  131. package/components/LineChart/intl/index.js +10 -0
  132. package/components/LineChart/intl/index.js.map +1 -0
  133. package/components/LineChart/styles.d.ts +17 -0
  134. package/components/LineChart/styles.js +53 -0
  135. package/components/LineChart/styles.js.map +1 -0
  136. package/components/LineChart/types.d.ts +90 -0
  137. package/components/LineChart/types.js +17 -0
  138. package/components/LineChart/types.js.map +1 -0
  139. package/components/LineChart/utils.js +67 -0
  140. package/components/LineChart/utils.js.map +1 -0
  141. package/components/PieChart/EmptyPieChart.js +85 -0
  142. package/components/PieChart/EmptyPieChart.js.map +1 -0
  143. package/components/PieChart/LoadingPieChart.js +18 -0
  144. package/components/PieChart/LoadingPieChart.js.map +1 -0
  145. package/components/PieChart/PieChart.d.ts +6 -0
  146. package/components/PieChart/PieChart.js +98 -0
  147. package/components/PieChart/PieChart.js.map +1 -0
  148. package/components/PieChart/RenderedPieChart.js +198 -0
  149. package/components/PieChart/RenderedPieChart.js.map +1 -0
  150. package/components/PieChart/intl/en-US.json.js +9 -0
  151. package/components/PieChart/intl/en-US.json.js.map +1 -0
  152. package/components/PieChart/intl/fr-FR.json.js +9 -0
  153. package/components/PieChart/intl/fr-FR.json.js.map +1 -0
  154. package/components/PieChart/intl/index.js +10 -0
  155. package/components/PieChart/intl/index.js.map +1 -0
  156. package/components/PieChart/styles.d.ts +24 -0
  157. package/components/PieChart/styles.js +168 -0
  158. package/components/PieChart/styles.js.map +1 -0
  159. package/components/PieChart/types.d.ts +115 -0
  160. package/components/PieChart/types.js +27 -0
  161. package/components/PieChart/types.js.map +1 -0
  162. package/components/PieChart/utils.js +37 -0
  163. package/components/PieChart/utils.js.map +1 -0
  164. package/components/ScatterPlot/EmptyScatterPlot.js +58 -0
  165. package/components/ScatterPlot/EmptyScatterPlot.js.map +1 -0
  166. package/components/ScatterPlot/LoadingScatterPlot.js +18 -0
  167. package/components/ScatterPlot/LoadingScatterPlot.js.map +1 -0
  168. package/components/ScatterPlot/RenderedScatterPlot.js +352 -0
  169. package/components/ScatterPlot/RenderedScatterPlot.js.map +1 -0
  170. package/components/ScatterPlot/ScatterPlot.d.ts +6 -0
  171. package/components/ScatterPlot/ScatterPlot.js +105 -0
  172. package/components/ScatterPlot/ScatterPlot.js.map +1 -0
  173. package/components/ScatterPlot/intl/en-US.json.js +12 -0
  174. package/components/ScatterPlot/intl/en-US.json.js.map +1 -0
  175. package/components/ScatterPlot/intl/fr-FR.json.js +17 -0
  176. package/components/ScatterPlot/intl/fr-FR.json.js.map +1 -0
  177. package/components/ScatterPlot/intl/index.js +10 -0
  178. package/components/ScatterPlot/intl/index.js.map +1 -0
  179. package/components/ScatterPlot/styles.d.ts +17 -0
  180. package/components/ScatterPlot/styles.js +53 -0
  181. package/components/ScatterPlot/styles.js.map +1 -0
  182. package/components/ScatterPlot/types.d.ts +109 -0
  183. package/components/ScatterPlot/types.js +24 -0
  184. package/components/ScatterPlot/types.js.map +1 -0
  185. package/components/ScatterPlot/utils.js +70 -0
  186. package/components/ScatterPlot/utils.js.map +1 -0
  187. package/config.js +15 -0
  188. package/config.js.map +1 -0
  189. package/design-system/src/react-aria/react-aria/i18n/useMessageFormatter.d.ts +5 -0
  190. package/hooks/useBrush.d.ts +17 -0
  191. package/hooks/useBrush.js +48 -0
  192. package/hooks/useBrush.js.map +1 -0
  193. package/hooks/useColor.d.ts +18 -0
  194. package/hooks/useColor.js +20 -0
  195. package/hooks/useColor.js.map +1 -0
  196. package/hooks/useFormatCategoricalData.d.ts +26 -0
  197. package/hooks/useFormatCategoricalData.js +57 -0
  198. package/hooks/useFormatCategoricalData.js.map +1 -0
  199. package/hooks/useZoom.d.ts +26 -0
  200. package/hooks/useZoom.js +39 -0
  201. package/hooks/useZoom.js.map +1 -0
  202. package/index.d.ts +51 -1277
  203. package/index.js +42 -5118
  204. package/index.js.map +1 -1
  205. package/package.json +4 -4
  206. package/scheme.d.ts +32 -0
  207. package/scheme.js +47 -0
  208. package/scheme.js.map +1 -0
  209. package/types/axis.d.ts +48 -0
  210. package/types/data.d.ts +72 -0
  211. package/types/legend.d.ts +30 -0
  212. package/types/legend.js +21 -0
  213. package/types/legend.js.map +1 -0
  214. package/types/scale.d.ts +48 -0
  215. package/types/size.d.ts +20 -0
  216. package/types/size.js +8 -0
  217. package/types/size.js.map +1 -0
  218. package/types/theme.d.ts +23 -0
  219. package/types/theme.js +13 -0
  220. package/types/theme.js.map +1 -0
  221. package/utils/index.d.ts +11 -0
  222. package/utils/index.js +44 -0
  223. package/utils/index.js.map +1 -0
@@ -0,0 +1,90 @@
1
+ import { ValueOf, Theme } from '@redsift/design-system';
2
+ import { ReactNode, ReactElement, MutableRefObject } from 'react';
3
+ import { SortingMethod } from '../../utils/index.js';
4
+ import { ChartDimensions, MarginProps, ChartSize } from '../../types/size.js';
5
+ import { ChartContainerProps } from '../ChartContainer/types.js';
6
+ import { ChartAxesProps } from '../../types/axis.js';
7
+ import { TwoCategoryData, DotDatum, Statistics } from '../../types/data.js';
8
+ import { DotProps } from '../Dot/types.js';
9
+ import { AnchorProps } from '../DataPoint/types.js';
10
+ import { LegendProps } from '../Legend/types.js';
11
+ import { ChartTheme } from '../../types/theme.js';
12
+ import { TooltipVariant } from '../../types/legend.js';
13
+
14
+ /**
15
+ * Component's labels variant.
16
+ */
17
+ declare const LineChartLegendVariant: {
18
+ readonly none: "none";
19
+ readonly externalLabel: "externalLabel";
20
+ readonly externalLabelValue: "externalLabelValue";
21
+ readonly externalLabelPercent: "externalLabelPercent";
22
+ readonly custom: "custom";
23
+ };
24
+ type LineChartLegendVariant = ValueOf<typeof LineChartLegendVariant>;
25
+ interface LocaleText {
26
+ emptyChartText: string;
27
+ }
28
+ type LineChartDimensions = ChartDimensions & {
29
+ fontSize: number;
30
+ };
31
+ /**
32
+ * Component props.
33
+ */
34
+ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
35
+ /** Dataset to use to generate the chart. */
36
+ data?: TwoCategoryData;
37
+ /** Dot role. If an onClick is provided, the dots will have the role `button`. For a navigation link, please use `getDotAnchorProps` instead. */
38
+ dotRole?: DotProps['role'];
39
+ /** Component to use if the chart is empty (replacing the default one). */
40
+ emptyComponent?: ReactNode;
41
+ /** Method used to define the anchor props to use when the dot is a navigation link. */
42
+ getDotAnchorProps?: (datum: DotDatum) => AnchorProps;
43
+ /** Method to determine whether a dot is selected or not. */
44
+ isDotSelected?: (datum: DotDatum) => boolean | undefined;
45
+ /** Method to override the data point labels. */
46
+ labelDecorator?: (datum: DotDatum, props?: {
47
+ index?: number;
48
+ isSelected?: boolean;
49
+ color?: string;
50
+ }) => string | ReactElement;
51
+ /** Method modifying what's displayed within the legend when the legendVariant is "custom". */
52
+ legendDecorator?: (datum: DotDatum, props?: {
53
+ index?: number;
54
+ isSelected?: boolean;
55
+ color?: string;
56
+ }) => string | ReactElement;
57
+ /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to "custom", use `legendDecorator` to customize it. */
58
+ legendVariant?: LineChartLegendVariant;
59
+ /** Props to forward to the Legend block. Can be used to make the legend selectable. */
60
+ legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'> & {
61
+ extraLegendItems?: Statistics;
62
+ };
63
+ /** Labels and texts. */
64
+ localeText?: LocaleText;
65
+ /** Custom margins, used to give more space for axes labels and legend for instance. */
66
+ margins?: MarginProps;
67
+ /** Method to be called on a click on a dot. For a navigation link, please use `getDotAnchorProps` instead. */
68
+ onDotClick?: (datum: DotDatum) => void;
69
+ /** LineChart size. */
70
+ size?: ChartSize | LineChartDimensions;
71
+ /** Define how to sort categories. */
72
+ sortingMethod?: SortingMethod;
73
+ /** Reference to the SVG tag. */
74
+ svgRef?: MutableRefObject<SVGSVGElement>;
75
+ /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
76
+ colorTheme?: ChartTheme;
77
+ /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
78
+ tooltipDecorator?: (data: DotDatum, props?: {
79
+ index?: number;
80
+ isSelected?: boolean;
81
+ color?: string;
82
+ }) => string | ReactElement;
83
+ /** Tooltip variant. */
84
+ tooltipVariant?: TooltipVariant;
85
+ /** Theme. */
86
+ theme?: Theme;
87
+ }
88
+ type StyledLineChartProps = LineChartProps & {};
89
+
90
+ export { LineChartDimensions, LineChartLegendVariant, LineChartProps, StyledLineChartProps };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Component's labels variant.
3
+ */
4
+ const LineChartLegendVariant = {
5
+ none: 'none',
6
+ externalLabel: 'externalLabel',
7
+ externalLabelValue: 'externalLabelValue',
8
+ externalLabelPercent: 'externalLabelPercent',
9
+ custom: 'custom'
10
+ };
11
+
12
+ /**
13
+ * Component props.
14
+ */
15
+
16
+ export { LineChartLegendVariant };
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/LineChart/types.ts"],"sourcesContent":["import {\n ChartDimensions,\n ChartSize,\n ChartTheme,\n TooltipVariant,\n DotDatum,\n TwoCategoryData,\n ChartAxesProps,\n MarginProps,\n Statistics,\n} from '../../types';\nimport { Theme, ValueOf } from '@redsift/design-system';\nimport { ChartContainerProps } from '../ChartContainer';\nimport { MutableRefObject, ReactElement, ReactNode } from 'react';\nimport { DotProps } from '../Dot';\nimport { LegendProps } from '../Legend';\nimport { SortingMethod } from '../../utils';\nimport { AnchorProps } from '../DataPoint';\n\n/**\n * Component's labels variant.\n */\nexport const LineChartLegendVariant = {\n none: 'none',\n externalLabel: 'externalLabel',\n externalLabelValue: 'externalLabelValue',\n externalLabelPercent: 'externalLabelPercent',\n custom: 'custom',\n} as const;\nexport type LineChartLegendVariant = ValueOf<typeof LineChartLegendVariant>;\n\ninterface LocaleText {\n emptyChartText: string;\n}\n\nexport type LineChartDimensions = ChartDimensions & {\n fontSize: number;\n};\n\n/**\n * Component props.\n */\nexport interface LineChartProps extends ChartContainerProps, ChartAxesProps {\n /** Dataset to use to generate the chart. */\n data?: TwoCategoryData;\n /** Dot role. If an onClick is provided, the dots will have the role `button`. For a navigation link, please use `getDotAnchorProps` instead. */\n dotRole?: DotProps['role'];\n /** Component to use if the chart is empty (replacing the default one). */\n emptyComponent?: ReactNode;\n /** Method used to define the anchor props to use when the dot is a navigation link. */\n getDotAnchorProps?: (datum: DotDatum) => AnchorProps;\n /** Method to determine whether a dot is selected or not. */\n isDotSelected?: (datum: DotDatum) => boolean | undefined;\n /** Method to override the data point labels. */\n labelDecorator?: (\n datum: DotDatum,\n props?: { index?: number; isSelected?: boolean; color?: string }\n ) => string | ReactElement;\n /** Method modifying what's displayed within the legend when the legendVariant is \"custom\". */\n legendDecorator?: (\n datum: DotDatum,\n props?: { index?: number; isSelected?: boolean; color?: string }\n ) => string | ReactElement;\n /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to \"custom\", use `legendDecorator` to customize it. */\n legendVariant?: LineChartLegendVariant;\n /** Props to forward to the Legend block. Can be used to make the legend selectable. */\n legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'> & { extraLegendItems?: Statistics };\n /** Labels and texts. */\n localeText?: LocaleText;\n /** Custom margins, used to give more space for axes labels and legend for instance. */\n margins?: MarginProps;\n /** Method to be called on a click on a dot. For a navigation link, please use `getDotAnchorProps` instead. */\n onDotClick?: (datum: DotDatum) => void;\n /** LineChart size. */\n size?: ChartSize | LineChartDimensions;\n /** Define how to sort categories. */\n sortingMethod?: SortingMethod;\n /** Reference to the SVG tag. */\n svgRef?: MutableRefObject<SVGSVGElement>;\n /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */\n colorTheme?: ChartTheme;\n /** Method modifying what's displayed within the tooltip when the tooltipVariant is \"custom\". */\n tooltipDecorator?: (\n data: DotDatum,\n props?: { index?: number; isSelected?: boolean; color?: string }\n ) => string | ReactElement;\n /** Tooltip variant. */\n tooltipVariant?: TooltipVariant;\n /** Theme. */\n theme?: Theme;\n}\n\nexport type StyledLineChartProps = LineChartProps & {};\n"],"names":["LineChartLegendVariant","none","externalLabel","externalLabelValue","externalLabelPercent","custom"],"mappings":"AAmBA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAG;AACpCC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,aAAa,EAAE,eAAe;AAC9BC,EAAAA,kBAAkB,EAAE,oBAAoB;AACxCC,EAAAA,oBAAoB,EAAE,sBAAsB;AAC5CC,EAAAA,MAAM,EAAE,QAAA;AACV,EAAU;;AAWV;AACA;AACA;;;;"}
@@ -0,0 +1,67 @@
1
+ import { getSortingMethod } from '../../utils/index.js';
2
+ import { ChartSize } from '../../types/size.js';
3
+
4
+ const sizeToDimension = size => {
5
+ if (typeof size !== 'string') {
6
+ return size;
7
+ }
8
+ switch (size) {
9
+ case ChartSize.small:
10
+ return {
11
+ width: 600,
12
+ height: 300,
13
+ fontSize: 30
14
+ };
15
+ case ChartSize.medium:
16
+ default:
17
+ return {
18
+ width: 750,
19
+ height: 375,
20
+ fontSize: 34
21
+ };
22
+ case ChartSize.large:
23
+ return {
24
+ width: 900,
25
+ height: 450,
26
+ fontSize: 38
27
+ };
28
+ }
29
+ };
30
+ const statsBy = (arr, sortingMethod) => {
31
+ const counts = arr.reduce((prev, curr) => {
32
+ if (!curr.value) {
33
+ return prev;
34
+ }
35
+ if (!prev[curr.key[1]]) {
36
+ prev[curr.key[1]] = {
37
+ value: curr.value,
38
+ min: curr.value,
39
+ max: curr.value,
40
+ values: [curr.value]
41
+ };
42
+ } else {
43
+ prev[curr.key[1]] = {
44
+ value: prev[curr.key[1]].value + curr.value,
45
+ min: Math.min(prev[curr.key[1]].min, curr.value),
46
+ max: Math.max(prev[curr.key[1]].max, curr.value),
47
+ values: [...prev[curr.key[1]].values, curr.value]
48
+ };
49
+ }
50
+ return prev;
51
+ }, {});
52
+ return Object.keys(counts).map(key => ({
53
+ key: key,
54
+ value: counts[key].value,
55
+ min: counts[key].min,
56
+ max: counts[key].max,
57
+ values: counts[key].values,
58
+ first: counts[key].values[0],
59
+ last: counts[key].values[counts[key].values.length - 1],
60
+ trending: {
61
+ overall: (counts[key].values[counts[key].values.length - 1] - counts[key].values[0]) * 100 / counts[key].values[0]
62
+ }
63
+ })).sort(getSortingMethod(sortingMethod));
64
+ };
65
+
66
+ export { sizeToDimension, statsBy };
67
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../src/components/LineChart/utils.ts"],"sourcesContent":["import { ScaleLinear as d3ScaleLinear } from 'd3';\n\nimport { CoordinatesCategoryData, CoordinatesCategoryDatum, Statistics, TwoCategoryData } from '../../types';\n\nimport { ChartSize } from '../../types';\nimport { LineChartDimensions } from './types';\nimport { SortingMethod, getSortingMethod } from '../../utils';\n\nexport const sizeToDimension = (size: ChartSize | LineChartDimensions): LineChartDimensions => {\n if (typeof size !== 'string') {\n return size;\n }\n\n switch (size) {\n case ChartSize.small:\n return { width: 600, height: 300, fontSize: 30 };\n case ChartSize.medium:\n default:\n return { width: 750, height: 375, fontSize: 34 };\n case ChartSize.large:\n return { width: 900, height: 450, fontSize: 38 };\n }\n};\n\nexport const BASE_NUMBER_OF_TICKS = 20;\n\nexport const getClosestLineIndex = (value: number, scale: d3ScaleLinear<number, number, never>) => {\n const ticks = scale.ticks(BASE_NUMBER_OF_TICKS);\n const delta = ticks[1] - ticks[0];\n const index = Math.round(value / delta);\n const roundValue = index * delta;\n return [index, roundValue];\n};\n\nexport const group = (\n data: CoordinatesCategoryData,\n x: d3ScaleLinear<number, number, never>,\n y: d3ScaleLinear<number, number, never>\n) => {\n const groupDict: Record<\n string,\n {\n category: string;\n x: number;\n y: number;\n data: CoordinatesCategoryDatum;\n points: CoordinatesCategoryData;\n }\n > = {};\n\n data.forEach((d) => {\n const [i, rx] = getClosestLineIndex(d.key[0], x);\n const [j, ry] = getClosestLineIndex(d.key[1], y);\n\n const key = `${i}_${j}_${d.key[2]}`;\n if (!(key in groupDict)) {\n groupDict[key] = {\n category: d.key[2] as string,\n x: rx,\n y: ry,\n data: {\n key: d.key,\n value: 0,\n },\n points: [],\n };\n }\n\n groupDict[key].points.push(d);\n groupDict[key].data.value += 1;\n });\n\n return Object.values(groupDict);\n};\n\nexport const countBy = (arr: CoordinatesCategoryData, sortingMethod: SortingMethod) => {\n const counts = arr.reduce(\n (prev, curr) => ((prev[curr.key[2] as string] = ++(prev[curr.key[2] as string] as number) || 1), prev),\n {} as Record<string, number>\n );\n\n return Object.keys(counts)\n .map((key) => ({ key: key, value: counts[key] as number }))\n .sort(getSortingMethod(sortingMethod));\n};\n\nexport const statsBy: (arr: TwoCategoryData, sortingMethod: SortingMethod) => Statistics = (arr, sortingMethod) => {\n const counts = arr.reduce((prev, curr) => {\n if (!curr.value) {\n return prev;\n }\n if (!prev[curr.key[1] as string]) {\n prev[curr.key[1] as string] = {\n value: curr.value,\n min: curr.value,\n max: curr.value,\n values: [curr.value],\n };\n } else {\n prev[curr.key[1] as string] = {\n value: prev[curr.key[1] as string].value + curr.value,\n min: Math.min(prev[curr.key[1] as string].min, curr.value),\n max: Math.max(prev[curr.key[1] as string].max, curr.value),\n values: [...prev[curr.key[1] as string].values, curr.value],\n };\n }\n return prev;\n }, {} as Record<string, { value: number; min: number; max: number; values: number[] }>);\n\n return Object.keys(counts)\n .map((key) => ({\n key: key,\n value: counts[key].value,\n min: counts[key].min,\n max: counts[key].max,\n values: counts[key].values,\n first: counts[key].values[0],\n last: counts[key].values[counts[key].values.length - 1],\n trending: {\n overall:\n ((counts[key].values[counts[key].values.length - 1] - counts[key].values[0]) * 100) / counts[key].values[0],\n },\n }))\n .sort(getSortingMethod(sortingMethod));\n};\n"],"names":["sizeToDimension","size","ChartSize","small","width","height","fontSize","medium","large","statsBy","arr","sortingMethod","counts","reduce","prev","curr","value","key","min","max","values","Math","Object","keys","map","first","last","length","trending","overall","sort","getSortingMethod"],"mappings":";;;AAQaA,MAAAA,eAAe,GAAIC,IAAqC,IAA0B;AAC7F,EAAA,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;AAC5B,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,QAAQA,IAAI;IACV,KAAKC,SAAS,CAACC,KAAK;MAClB,OAAO;AAAEC,QAAAA,KAAK,EAAE,GAAG;AAAEC,QAAAA,MAAM,EAAE,GAAG;AAAEC,QAAAA,QAAQ,EAAE,EAAA;OAAI,CAAA;IAClD,KAAKJ,SAAS,CAACK,MAAM,CAAA;AACrB,IAAA;MACE,OAAO;AAAEH,QAAAA,KAAK,EAAE,GAAG;AAAEC,QAAAA,MAAM,EAAE,GAAG;AAAEC,QAAAA,QAAQ,EAAE,EAAA;OAAI,CAAA;IAClD,KAAKJ,SAAS,CAACM,KAAK;MAClB,OAAO;AAAEJ,QAAAA,KAAK,EAAE,GAAG;AAAEC,QAAAA,MAAM,EAAE,GAAG;AAAEC,QAAAA,QAAQ,EAAE,EAAA;OAAI,CAAA;AACpD,GAAA;AACF,EAAC;MAgEYG,OAA2E,GAAGA,CAACC,GAAG,EAAEC,aAAa,KAAK;EACjH,MAAMC,MAAM,GAAGF,GAAG,CAACG,MAAM,CAAC,CAACC,IAAI,EAAEC,IAAI,KAAK;AACxC,IAAA,IAAI,CAACA,IAAI,CAACC,KAAK,EAAE;AACf,MAAA,OAAOF,IAAI,CAAA;AACb,KA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,IAAAA,GAAG,EAAEN,MAAM,CAACK,GAAG,CAAC,CAACC,GAAG;AACpBC,IAAAA,GAAG,EAAEP,MAAM,CAACK,GAAG,CAAC,CAACE,GAAG;AACpBC,IAAAA,MAAM,EAAER,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM;IAC1BK,KAAK,EAAEb,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAAC,CAAC,CAAC;AAC5BM,IAAAA,IAAI,EAAEd,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAACR,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAACO,MAAM,GAAG,CAAC,CAAC;AACvDC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,OAAO,EACJ,CAACjB,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAACR,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAACO,MAAM,GAAG,CAAC,CAAC,GAAGf,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,GAAIR,MAAM,CAACK,GAAG,CAAC,CAACG,MAAM,CAAC,CAAC,CAAA;AAC9G,KAAA;GACD,CAAC,CAAC,CACFU,IAAI,CAACC,gBAAgB,CAACpB,aAAa,CAAC,CAAC,CAAA;AAC1C;;;;"}
@@ -0,0 +1,85 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import { arc } from 'd3';
4
+ import { PieChartVariant } from './types.js';
5
+ import { StyledPieChart, StyledPieChartEmptyText } from './styles.js';
6
+ import { empty } from '../../scheme.js';
7
+ import { sizeToDimension } from './utils.js';
8
+ import { useTheme } from '@redsift/design-system';
9
+ import { Arcs } from '../Arcs/Arcs.js';
10
+
11
+ const _excluded = ["className", "emptyComponent", "localeText", "size", "variant"];
12
+ const EmptyPieChart = /*#__PURE__*/forwardRef((props, ref) => {
13
+ const {
14
+ className,
15
+ emptyComponent,
16
+ localeText,
17
+ size,
18
+ variant
19
+ } = props,
20
+ forwardedProps = _objectWithoutProperties(props, _excluded);
21
+ const theme = useTheme();
22
+ const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
23
+ const {
24
+ width,
25
+ height,
26
+ fontSize,
27
+ innerRadius
28
+ } = sizeToDimension(size);
29
+ const externalRadiusPadding = 8;
30
+ const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(width / 2 - externalRadiusPadding);
31
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({}, forwardedProps, {
32
+ className: className,
33
+ ref: ref
34
+ }), emptyComponent !== null && emptyComponent !== void 0 ? emptyComponent : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledPieChartEmptyText, {
35
+ $maxWidth: innerRadius * 2,
36
+ $textSize: fontSize / 2,
37
+ $isDonut: isDonut,
38
+ $theme: theme
39
+ }, /*#__PURE__*/React__default.createElement("span", null, localeText === null || localeText === void 0 ? void 0 : localeText.emptyChartText)), /*#__PURE__*/React__default.createElement("svg", {
40
+ width: width,
41
+ height: height
42
+ }, /*#__PURE__*/React__default.createElement(Arcs, {
43
+ arcs: [{
44
+ createArc,
45
+ previousData: {
46
+ data: {
47
+ key: '',
48
+ value: 0
49
+ },
50
+ startAngle: 0,
51
+ endAngle: 0,
52
+ padAngle: 0,
53
+ value: 0,
54
+ index: 0
55
+ },
56
+ data: {
57
+ data: {
58
+ key: 'No Data',
59
+ value: 0
60
+ },
61
+ index: 0,
62
+ value: 0,
63
+ startAngle: 0,
64
+ endAngle: 2 * Math.PI,
65
+ padAngle: 0
66
+ },
67
+ dataset: [{
68
+ data: {
69
+ key: 'No Data',
70
+ value: 0
71
+ },
72
+ index: 0,
73
+ value: 0,
74
+ startAngle: 0,
75
+ endAngle: 2 * Math.PI,
76
+ padAngle: 0
77
+ }],
78
+ color: empty
79
+ }],
80
+ transform: `translate(${width / 2} ${height / 2})`
81
+ }))));
82
+ });
83
+
84
+ export { EmptyPieChart };
85
+ //# sourceMappingURL=EmptyPieChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyPieChart.js","sources":["../../../src/components/PieChart/EmptyPieChart.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport { arc as d3arc } from 'd3';\n\nimport { ArcDatum } from '../../types';\nimport { PieChartProps, PieChartVariant } from './types';\nimport { StyledPieChart, StyledPieChartEmptyText } from './styles';\nimport { Arcs } from '../Arcs';\nimport { empty } from '../../scheme';\nimport { sizeToDimension } from './utils';\nimport { useTheme } from '@redsift/design-system';\n\nexport const EmptyPieChart = forwardRef<HTMLDivElement, PieChartProps>((props, ref) => {\n const { className, emptyComponent, localeText, size, variant, ...forwardedProps } = props;\n const theme = useTheme();\n\n const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;\n\n const { width, height, fontSize, innerRadius } = sizeToDimension(size!);\n const externalRadiusPadding = 8;\n\n const createArc = d3arc<ArcDatum>()\n .innerRadius(isDonut ? innerRadius : 0)\n .outerRadius(width / 2 - externalRadiusPadding);\n\n return (\n <StyledPieChart {...forwardedProps} className={className} ref={ref as RefObject<HTMLDivElement>}>\n {emptyComponent ?? (\n <>\n <StyledPieChartEmptyText\n $maxWidth={innerRadius * 2}\n $textSize={fontSize / 2}\n $isDonut={isDonut}\n $theme={theme}\n >\n <span>{localeText?.emptyChartText}</span>\n </StyledPieChartEmptyText>\n <svg width={width} height={height}>\n <Arcs\n arcs={[\n {\n createArc,\n previousData: {\n data: {\n key: '',\n value: 0,\n },\n startAngle: 0,\n endAngle: 0,\n padAngle: 0,\n value: 0,\n index: 0,\n },\n data: {\n data: {\n key: 'No Data',\n value: 0,\n },\n index: 0,\n value: 0,\n startAngle: 0,\n endAngle: 2 * Math.PI,\n padAngle: 0,\n },\n dataset: [\n {\n data: {\n key: 'No Data',\n value: 0,\n },\n index: 0,\n value: 0,\n startAngle: 0,\n endAngle: 2 * Math.PI,\n padAngle: 0,\n },\n ],\n color: empty,\n },\n ]}\n transform={`translate(${width / 2} ${height / 2})`}\n />\n </svg>\n </>\n )}\n </StyledPieChart>\n );\n});\n"],"names":["EmptyPieChart","forwardRef","props","ref","className","emptyComponent","localeText","size","variant","forwardedProps","_objectWithoutProperties","_excluded","theme","useTheme","isDonut","PieChartVariant","donut","spacedDonut","width","height","fontSize","innerRadius","sizeToDimension","externalRadiusPadding","createArc","d3arc","outerRadius","React","createElement","StyledPieChart","_extends","Fragment","StyledPieChartEmptyText","$maxWidth","$textSize","$isDonut","$theme","emptyChartText","Arcs","arcs","previousData","data","key","value","startAngle","endAngle","padAngle","index","Math","PI","dataset","color","empty","transform"],"mappings":";;;;;;;;;;;AAWO,MAAMA,aAAa,gBAAGC,UAAU,CAAgC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACrF,MAAM;MAAEC,SAAS;MAAEC,cAAc;MAAEC,UAAU;MAAEC,IAAI;AAAEC,MAAAA,OAAAA;AAA2B,KAAC,GAAGN,KAAK;AAAxBO,IAAAA,cAAc,GAAAC,wBAAA,CAAKR,KAAK,EAAAS,SAAA,CAAA,CAAA;AACzF,EAAA,MAAMC,KAAK,GAAGC,QAAQ,EAAE,CAAA;AAExB,EAAA,MAAMC,OAAO,GAAGN,OAAO,KAAKO,eAAe,CAACC,KAAK,IAAIR,OAAO,KAAKO,eAAe,CAACE,WAAW,CAAA;EAE5F,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,QAAQ;AAAEC,IAAAA,WAAAA;AAAY,GAAC,GAAGC,eAAe,CAACf,IAAK,CAAC,CAAA;EACvE,MAAMgB,qBAAqB,GAAG,CAAC,CAAA;EAE/B,MAAMC,SAAS,GAAGC,GAAK,EAAY,CAChCJ,WAAW,CAACP,OAAO,GAAGO,WAAW,GAAG,CAAC,CAAC,CACtCK,WAAW,CAACR,KAAK,GAAG,CAAC,GAAGK,qBAAqB,CAAC,CAAA;EAEjD,oBACEI,cAAA,CAA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,EAAE,CAAA;SACR;AACDI,QAAAA,KAAK,EAAE,CAAC;AACRJ,QAAAA,KAAK,EAAE,CAAC;AACRC,QAAAA,UAAU,EAAE,CAAC;AACbC,QAAAA,QAAQ,EAAE,CAAC,GAAGG,IAAI,CAACC,EAAE;AACrBH,QAAAA,QAAQ,EAAE,CAAA;OACX;AACDI,MAAAA,OAAO,EAAE,CACP;AACET,QAAAA,IAAI,EAAE;AACJC,UAAAA,GAAG,EAAE,SAAS;AACdC,UAAAA,KAAK,EAAE,CAAA;SACR;AACDI,QAAAA,KAAK,EAAE,CAAC;AACRJ,QAAAA,KAAK,EAAE,CAAC;AACRC,QAAAA,UAAU,EAAE,CAAC;AACbC,QAAAA,QAAQ,EAAE,CAAC,GAAGG,IAAI,CAACC,EAAE;AACrBH,QAAAA,QAAQ,EAAE,CAAA;AACZ,OAAC,CACF;AACDK,MAAAA,KAAK,EAAEC,KAAAA;AACT,KAAC,CACD;IACFC,SAAS,EAAG,aAAYnC,KAAK,GAAG,CAAE,CAAGC,CAAAA,EAAAA,MAAM,GAAG,CAAE,CAAA,CAAA,CAAA;GACjD,CACE,CACL,CAEU,CAAC,CAAA;AAErB,CAAC;;;;"}
@@ -0,0 +1,18 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import { StyledPieChart } from './styles.js';
4
+
5
+ const _excluded = ["className"];
6
+ const LoadingPieChart = /*#__PURE__*/forwardRef((props, ref) => {
7
+ const {
8
+ className
9
+ } = props,
10
+ forwardedProps = _objectWithoutProperties(props, _excluded);
11
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({}, forwardedProps, {
12
+ className: className,
13
+ ref: ref
14
+ }), "Loading...");
15
+ });
16
+
17
+ export { LoadingPieChart };
18
+ //# sourceMappingURL=LoadingPieChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingPieChart.js","sources":["../../../src/components/PieChart/LoadingPieChart.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\n\nimport { PieChartProps } from './types';\nimport { StyledPieChart } from './styles';\n\nexport const LoadingPieChart = forwardRef<HTMLDivElement, PieChartProps>(\n (props, ref) => {\n const { className, ...forwardedProps } = props;\n\n return (\n <StyledPieChart\n {...forwardedProps}\n className={className}\n ref={ref as RefObject<HTMLDivElement>}\n >\n Loading...\n </StyledPieChart>\n );\n }\n);\n"],"names":["LoadingPieChart","forwardRef","props","ref","className","forwardedProps","_objectWithoutProperties","_excluded","React","createElement","StyledPieChart","_extends"],"mappings":";;;;;AAKO,MAAMA,eAAe,gBAAGC,UAAU,CACvC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAM;AAAEC,MAAAA,SAAAA;AAA6B,KAAC,GAAGF,KAAK;AAAxBG,IAAAA,cAAc,GAAAC,wBAAA,CAAKJ,KAAK,EAAAK,SAAA,CAAA,CAAA;EAE9C,oBACEC,cAAA,CAAAC,aAAA,CAACC,cAAc,EAAAC,QAAA,KACTN,cAAc,EAAA;AAClBD,IAAAA,SAAS,EAAEA,SAAU;AACrBD,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EACvC,YAEe,CAAC,CAAA;AAErB,CACF;;;;"}
@@ -0,0 +1,6 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { PieChartProps } from './types.js';
3
+
4
+ declare const PieChart: Comp<PieChartProps, HTMLDivElement>;
5
+
6
+ export { PieChart };
@@ -0,0 +1,98 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import { useId } from '@redsift/design-system';
5
+ import { PieChartVariant, PieChartLegendVariant } from './types.js';
6
+ import { LoadingPieChart } from './LoadingPieChart.js';
7
+ import { EmptyPieChart } from './EmptyPieChart.js';
8
+ import { RenderedPieChart } from './RenderedPieChart.js';
9
+ import { ColorTheme } from '../../types/theme.js';
10
+ import { ChartSize } from '../../types/size.js';
11
+ import { TooltipVariant } from '../../types/legend.js';
12
+
13
+ const _excluded = ["caping", "chartRef", "className", "colorTheme", "data", "emptyComponent", "id", "isSliceSelected", "labelDecorator", "legendDecorator", "legendVariant", "localeText", "middleText", "onSliceClick", "others", "size", "sliceRole", "sortingMethod", "subtext", "text", "tooltipDecorator", "tooltipVariant", "variant"];
14
+ const COMPONENT_NAME = 'PieChart';
15
+ const CLASSNAME = 'redsift-piechart';
16
+ const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
17
+ const {
18
+ caping,
19
+ chartRef,
20
+ className,
21
+ colorTheme = ColorTheme.default,
22
+ data: propsData,
23
+ emptyComponent,
24
+ id: propsId,
25
+ isSliceSelected = () => true,
26
+ labelDecorator,
27
+ legendDecorator,
28
+ legendVariant: propsLegendVariant,
29
+ localeText = {
30
+ emptyChartText: 'No Data'
31
+ },
32
+ middleText,
33
+ onSliceClick,
34
+ others = true,
35
+ size = ChartSize.medium,
36
+ sliceRole,
37
+ sortingMethod = 'desc-value',
38
+ subtext,
39
+ text,
40
+ tooltipDecorator,
41
+ tooltipVariant = TooltipVariant.value,
42
+ variant = PieChartVariant.spaced
43
+ } = props,
44
+ forwardedProps = _objectWithoutProperties(props, _excluded);
45
+ const [_id] = useId();
46
+ const id = propsId !== null && propsId !== void 0 ? propsId : _id;
47
+ const legendVariant = propsLegendVariant !== null && propsLegendVariant !== void 0 ? propsLegendVariant : PieChartLegendVariant.none;
48
+ if (propsData === undefined || propsData === null) {
49
+ return /*#__PURE__*/React__default.createElement(LoadingPieChart, _extends({
50
+ id: id
51
+ }, forwardedProps, {
52
+ ref: ref
53
+ }));
54
+ }
55
+ if (propsData.length === 0) {
56
+ return /*#__PURE__*/React__default.createElement(EmptyPieChart, _extends({
57
+ data: propsData,
58
+ emptyComponent: emptyComponent,
59
+ id: id,
60
+ localeText: localeText,
61
+ size: size,
62
+ sortingMethod: sortingMethod,
63
+ variant: variant
64
+ }, forwardedProps, {
65
+ ref: ref
66
+ }));
67
+ }
68
+ return /*#__PURE__*/React__default.createElement(RenderedPieChart, _extends({
69
+ caping: caping,
70
+ chartRef: chartRef,
71
+ className: classNames(PieChart.className, className),
72
+ data: propsData,
73
+ id: id,
74
+ isSliceSelected: isSliceSelected,
75
+ labelDecorator: labelDecorator,
76
+ legendDecorator: legendDecorator,
77
+ legendVariant: legendVariant,
78
+ middleText: middleText,
79
+ onSliceClick: onSliceClick,
80
+ others: others,
81
+ size: size,
82
+ sliceRole: sliceRole,
83
+ sortingMethod: sortingMethod,
84
+ subtext: subtext,
85
+ text: text,
86
+ colorTheme: colorTheme,
87
+ tooltipDecorator: tooltipDecorator,
88
+ tooltipVariant: tooltipVariant,
89
+ variant: variant
90
+ }, forwardedProps, {
91
+ ref: ref
92
+ }));
93
+ });
94
+ PieChart.className = CLASSNAME;
95
+ PieChart.displayName = COMPONENT_NAME;
96
+
97
+ export { PieChart };
98
+ //# sourceMappingURL=PieChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PieChart.js","sources":["../../../src/components/PieChart/PieChart.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp, useId } from '@redsift/design-system';\n\nimport { ChartSize, ColorTheme, TooltipVariant } from '../../types';\nimport { PieChartLegendVariant, PieChartProps, PieChartVariant } from './types';\nimport { LoadingPieChart } from './LoadingPieChart';\nimport { EmptyPieChart } from './EmptyPieChart';\nimport { RenderedPieChart } from './RenderedPieChart';\n\nconst COMPONENT_NAME = 'PieChart';\nconst CLASSNAME = 'redsift-piechart';\n\nexport const PieChart: Comp<PieChartProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n caping,\n chartRef,\n className,\n colorTheme = ColorTheme.default,\n data: propsData,\n emptyComponent,\n id: propsId,\n isSliceSelected = () => true,\n labelDecorator,\n legendDecorator,\n legendVariant: propsLegendVariant,\n localeText = { emptyChartText: 'No Data' },\n middleText,\n onSliceClick,\n others = true,\n size = ChartSize.medium,\n sliceRole,\n sortingMethod = 'desc-value',\n subtext,\n text,\n tooltipDecorator,\n tooltipVariant = TooltipVariant.value,\n variant = PieChartVariant.spaced,\n ...forwardedProps\n } = props;\n const [_id] = useId();\n const id = propsId ?? _id;\n\n const legendVariant = propsLegendVariant ?? PieChartLegendVariant.none;\n\n if (propsData === undefined || propsData === null) {\n return <LoadingPieChart id={id} {...forwardedProps} ref={ref} />;\n }\n\n if (propsData.length === 0) {\n return (\n <EmptyPieChart\n data={propsData}\n emptyComponent={emptyComponent}\n id={id}\n localeText={localeText}\n size={size}\n sortingMethod={sortingMethod}\n variant={variant}\n {...forwardedProps}\n ref={ref}\n />\n );\n }\n\n return (\n <RenderedPieChart\n caping={caping}\n chartRef={chartRef}\n className={classNames(PieChart.className, className)}\n data={propsData}\n id={id}\n isSliceSelected={isSliceSelected}\n labelDecorator={labelDecorator}\n legendDecorator={legendDecorator}\n legendVariant={legendVariant}\n middleText={middleText}\n onSliceClick={onSliceClick}\n others={others}\n size={size}\n sliceRole={sliceRole}\n sortingMethod={sortingMethod}\n subtext={subtext}\n text={text}\n colorTheme={colorTheme}\n tooltipDecorator={tooltipDecorator}\n tooltipVariant={tooltipVariant}\n variant={variant}\n {...forwardedProps}\n ref={ref}\n />\n );\n});\nPieChart.className = CLASSNAME;\nPieChart.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","PieChart","forwardRef","props","ref","caping","chartRef","className","colorTheme","ColorTheme","default","data","propsData","emptyComponent","id","propsId","isSliceSelected","labelDecorator","legendDecorator","legendVariant","propsLegendVariant","localeText","emptyChartText","middleText","onSliceClick","others","size","ChartSize","medium","sliceRole","sortingMethod","subtext","text","tooltipDecorator","tooltipVariant","TooltipVariant","value","variant","PieChartVariant","spaced","forwardedProps","_objectWithoutProperties","_excluded","_id","useId","PieChartLegendVariant","none","undefined","React","createElement","LoadingPieChart","_extends","length","EmptyPieChart","R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,IAAAA,IAAI,EAAEA,IAAK;AACXG,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,aAAa,EAAEA,aAAc;AAC7BC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,IAAI,EAAEA,IAAK;AACXxB,IAAAA,UAAU,EAAEA,UAAW;AACvByB,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnCC,IAAAA,cAAc,EAAEA,cAAe;AAC/BG,IAAAA,OAAO,EAAEA,OAAAA;AAAQ,GAAA,EACbG,cAAc,EAAA;AAClBpC,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,CACV,CAAC,CAAA;AAEN,CAAC,EAAC;AACFH,QAAQ,CAACM,SAAS,GAAGP,SAAS,CAAA;AAC9BC,QAAQ,CAACuD,WAAW,GAAGzD,cAAc;;;;"}
@@ -0,0 +1,198 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useRef, useEffect } from 'react';
3
+ import { pie, arc, sum } from 'd3';
4
+ import { useTheme, useMessageFormatter } from '@redsift/design-system';
5
+ import intlMessages from './intl/index.js';
6
+ import { PieChartVariant, PieChartLegendVariant } from './types.js';
7
+ import { StyledPieChart, StyledPieChartCenterText } from './styles.js';
8
+ import { sizeToDimension } from './utils.js';
9
+ import { PieChart } from './PieChart.js';
10
+ import { mergeLegends, getSortingMethod } from '../../utils/index.js';
11
+ import { useFormatCategoricalData } from '../../hooks/useFormatCategoricalData.js';
12
+ import { Arcs } from '../Arcs/Arcs.js';
13
+ import { Legend } from '../Legend/Legend.js';
14
+ import { LegendVariant } from '../../types/legend.js';
15
+
16
+ const _excluded = ["caping", "className", "data", "disableAnimations", "getSliceAnchorProps", "id", "isHalf", "isSliceSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "middleText", "onSliceClick", "others", "size", "sliceProps", "sliceRole", "sortingMethod", "subtext", "text", "colorTheme", "tooltipVariant", "variant"],
17
+ _excluded2 = ["extraLegendItems"];
18
+ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
19
+ const {
20
+ caping,
21
+ className,
22
+ data: propsData,
23
+ disableAnimations,
24
+ getSliceAnchorProps,
25
+ id,
26
+ isHalf,
27
+ isSliceSelected,
28
+ labelDecorator,
29
+ legendDecorator,
30
+ legendVariant,
31
+ legendProps,
32
+ middleText: propsMiddleText,
33
+ onSliceClick,
34
+ others,
35
+ size,
36
+ sliceProps,
37
+ sliceRole,
38
+ sortingMethod,
39
+ subtext: propsSubtext,
40
+ text: propsText,
41
+ colorTheme,
42
+ tooltipVariant,
43
+ variant
44
+ } = props,
45
+ forwardedProps = _objectWithoutProperties(props, _excluded);
46
+ const cache = useRef();
47
+ const theme = useTheme();
48
+ const format = useMessageFormatter(intlMessages);
49
+ const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
50
+ const isSpaced = variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut;
51
+ const {
52
+ data,
53
+ colorScale
54
+ } = useFormatCategoricalData({
55
+ data: propsData,
56
+ colorTheme: colorTheme,
57
+ sortingMethod: sortingMethod,
58
+ caping,
59
+ others,
60
+ theme
61
+ });
62
+ useEffect(() => {
63
+ cache.current = data;
64
+ });
65
+ const {
66
+ width,
67
+ height,
68
+ smallFontSize,
69
+ fontSize,
70
+ innerRadius
71
+ } = sizeToDimension(size, isHalf);
72
+ const externalRadiusPadding = 8;
73
+ const createPie = pie().value(d => d.value).sort(null).startAngle(isHalf ? Math.PI * -0.5 : 0).endAngle(isHalf ? Math.PI * 0.5 : Math.PI * 2);
74
+ const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(width / 2 - externalRadiusPadding);
75
+ const pieData = createPie(data);
76
+ const previousPieData = cache.current ? createPie(cache.current) : undefined;
77
+ const total = sum(data, d => d.value);
78
+ const legendWidth = useRef();
79
+ if (data && !legendWidth.current) {
80
+ legendWidth.current = `${Math.max(...data.map(d => d.key.length + String(d.value).length)) * 8 + 32}px`;
81
+ }
82
+ const text = typeof propsText === 'function' ? propsText(pieData.map(datum => {
83
+ const percent = datum.data.value / total;
84
+ return _objectSpread2(_objectSpread2({}, datum), {}, {
85
+ data: _objectSpread2(_objectSpread2({}, datum.data), {}, {
86
+ percent
87
+ })
88
+ });
89
+ }), total) : propsText;
90
+ const subtext = typeof propsSubtext === 'function' ? propsSubtext(pieData.map(datum => {
91
+ const percent = datum.data.value / total;
92
+ return _objectSpread2(_objectSpread2({}, datum), {}, {
93
+ data: _objectSpread2(_objectSpread2({}, datum.data), {}, {
94
+ percent
95
+ })
96
+ });
97
+ }), total) : propsSubtext;
98
+ const middleText = typeof propsMiddleText === 'function' ? propsMiddleText(pieData.map(datum => {
99
+ const percent = datum.data.value / total;
100
+ return _objectSpread2(_objectSpread2({}, datum), {}, {
101
+ data: _objectSpread2(_objectSpread2({}, datum.data), {}, {
102
+ percent
103
+ })
104
+ });
105
+ }), total) : propsMiddleText;
106
+ const filteredPieData = pieData.filter(datum => datum.data.value);
107
+ const _ref = legendProps || {},
108
+ {
109
+ extraLegendItems
110
+ } = _ref,
111
+ forwardedLegendProps = _objectWithoutProperties(_ref, _excluded2);
112
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({
113
+ mode: typeof onSliceClick === 'function' || typeof getSliceAnchorProps === 'function' ? 'interactive' : 'static',
114
+ definition: format('definition', {
115
+ sliceLength: filteredPieData.length
116
+ }),
117
+ dataTableRepresentation: {
118
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
119
+ scope: "col"
120
+ }, "Key"), /*#__PURE__*/React__default.createElement("th", {
121
+ scope: "col"
122
+ }, "Value"))),
123
+ body: /*#__PURE__*/React__default.createElement("tbody", null, filteredPieData.map(datum => /*#__PURE__*/React__default.createElement("tr", {
124
+ key: datum.data.key
125
+ }, /*#__PURE__*/React__default.createElement("th", {
126
+ scope: "row"
127
+ }, datum.data.key), /*#__PURE__*/React__default.createElement("td", null, datum.data.value))))
128
+ }
129
+ }, forwardedProps, {
130
+ className: className,
131
+ id: id,
132
+ ref: ref
133
+ }), /*#__PURE__*/React__default.createElement("div", {
134
+ className: `${PieChart.className}__chart-wrapper`
135
+ }, text ? /*#__PURE__*/React__default.createElement(StyledPieChartCenterText, {
136
+ $maxWidth: innerRadius * 2,
137
+ $textSize: fontSize,
138
+ $smallTextSize: smallFontSize,
139
+ $theme: theme
140
+ }, subtext ? /*#__PURE__*/React__default.createElement("b", null, text) : /*#__PURE__*/React__default.createElement("span", null, text), middleText ? /*#__PURE__*/React__default.createElement("b", null, middleText) : null, /*#__PURE__*/React__default.createElement("span", null, subtext)) : null, /*#__PURE__*/React__default.createElement("svg", {
141
+ width: width,
142
+ height: isHalf ? height + externalRadiusPadding : height,
143
+ "aria-label": typeof onSliceClick === 'function' || typeof getSliceAnchorProps === 'function' ? format('interactive-chart') : format('static-chart'),
144
+ "aria-hidden": "false"
145
+ }, /*#__PURE__*/React__default.createElement(Arcs, {
146
+ arcs: filteredPieData.map((datum, index) => {
147
+ const percent = datum.data.value / total;
148
+ const from = previousPieData ? previousPieData[index] : {
149
+ data: {
150
+ key: '',
151
+ value: 0
152
+ },
153
+ startAngle: isHalf ? Math.PI * -0.5 : 0,
154
+ endAngle: isHalf ? Math.PI * -0.5 : 0,
155
+ padAngle: 0,
156
+ value: 0,
157
+ index: index
158
+ };
159
+ const to = _objectSpread2(_objectSpread2({}, datum), {}, {
160
+ data: _objectSpread2(_objectSpread2({}, datum.data), {}, {
161
+ percent
162
+ })
163
+ });
164
+ return {
165
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
166
+ createArc,
167
+ previousData: from,
168
+ id: `id${id}__arc-${index}`,
169
+ index,
170
+ isSelected: isSliceSelected(to),
171
+ key: `id${id}__arc-${index}`,
172
+ data: to,
173
+ dataset: pieData,
174
+ anchorProps: getSliceAnchorProps ? getSliceAnchorProps(to) : undefined
175
+ };
176
+ }),
177
+ disableAnimations: disableAnimations,
178
+ hasLabels: legendVariant === PieChartLegendVariant.internal,
179
+ hasStroke: isSpaced,
180
+ labelDecorator: labelDecorator,
181
+ onClick: onSliceClick,
182
+ role: sliceRole,
183
+ sliceProps: sliceProps,
184
+ tooltipVariant: tooltipVariant,
185
+ transform: `translate(${width / 2} ${isHalf ? height : height / 2})`
186
+ }))), legendVariant !== PieChartLegendVariant.none && legendVariant !== PieChartLegendVariant.internal ? /*#__PURE__*/React__default.createElement(Legend, _extends({
187
+ data: (extraLegendItems ? mergeLegends(extraLegendItems, data).sort(getSortingMethod(sortingMethod)) : data).map(d => _objectSpread2(_objectSpread2({}, d), {}, {
188
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
189
+ })),
190
+ variant: legendVariant === PieChartLegendVariant.externalLabelValue ? LegendVariant.value : legendVariant === PieChartLegendVariant.externalLabelPercent ? LegendVariant.percent : legendVariant === PieChartLegendVariant.externalLabel ? LegendVariant.label : LegendVariant.custom,
191
+ width: legendWidth.current,
192
+ labelDecorator: labelDecorator ? (datum, props) => labelDecorator(datum, props) : undefined,
193
+ legendDecorator: legendDecorator ? (datum, props) => legendDecorator(datum, props) : undefined
194
+ }, forwardedLegendProps)) : null);
195
+ });
196
+
197
+ export { RenderedPieChart };
198
+ //# sourceMappingURL=RenderedPieChart.js.map