@redsift/charts 9.2.3 → 9.2.4

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 (271) hide show
  1. package/{dist/index.js → index.js} +2 -1
  2. package/index.js.map +1 -0
  3. package/package.json +3 -2
  4. package/coverage/clover.xml +0 -1096
  5. package/coverage/coverage-final.json +0 -60
  6. package/coverage/lcov-report/base.css +0 -224
  7. package/coverage/lcov-report/block-navigation.js +0 -87
  8. package/coverage/lcov-report/components/Arc/Arc.tsx.html +0 -304
  9. package/coverage/lcov-report/components/Arc/index.html +0 -146
  10. package/coverage/lcov-report/components/Arc/index.ts.html +0 -94
  11. package/coverage/lcov-report/components/Arc/styles.ts.html +0 -208
  12. package/coverage/lcov-report/components/Arcs/Arcs.tsx.html +0 -409
  13. package/coverage/lcov-report/components/Arcs/index.html +0 -146
  14. package/coverage/lcov-report/components/Arcs/index.ts.html +0 -94
  15. package/coverage/lcov-report/components/Arcs/styles.ts.html +0 -106
  16. package/coverage/lcov-report/components/Axis/Axis.tsx.html +0 -754
  17. package/coverage/lcov-report/components/Axis/computeTicks.ts.html +0 -481
  18. package/coverage/lcov-report/components/Axis/index.html +0 -176
  19. package/coverage/lcov-report/components/Axis/index.ts.html +0 -94
  20. package/coverage/lcov-report/components/Axis/styles.ts.html +0 -148
  21. package/coverage/lcov-report/components/Axis/types.ts.html +0 -253
  22. package/coverage/lcov-report/components/Bar/Bar.tsx.html +0 -421
  23. package/coverage/lcov-report/components/Bar/index.html +0 -161
  24. package/coverage/lcov-report/components/Bar/index.ts.html +0 -94
  25. package/coverage/lcov-report/components/Bar/styles.ts.html +0 -247
  26. package/coverage/lcov-report/components/Bar/types.ts.html +0 -178
  27. package/coverage/lcov-report/components/BarChart/BarChart.tsx.html +0 -352
  28. package/coverage/lcov-report/components/BarChart/EmptyBarChart.tsx.html +0 -259
  29. package/coverage/lcov-report/components/BarChart/LoadingBarChart.tsx.html +0 -145
  30. package/coverage/lcov-report/components/BarChart/RenderedBarChart.tsx.html +0 -430
  31. package/coverage/lcov-report/components/BarChart/index.html +0 -206
  32. package/coverage/lcov-report/components/BarChart/index.ts.html +0 -94
  33. package/coverage/lcov-report/components/BarChart/styles.ts.html +0 -190
  34. package/coverage/lcov-report/components/BarChart/utils.ts.html +0 -145
  35. package/coverage/lcov-report/components/BottomAxis/BottomAxis.tsx.html +0 -247
  36. package/coverage/lcov-report/components/BottomAxis/index.html +0 -146
  37. package/coverage/lcov-report/components/BottomAxis/index.ts.html +0 -94
  38. package/coverage/lcov-report/components/BottomAxis/styles.ts.html +0 -139
  39. package/coverage/lcov-report/components/ChartContainer/ChartContainer.tsx.html +0 -361
  40. package/coverage/lcov-report/components/ChartContainer/index.html +0 -146
  41. package/coverage/lcov-report/components/ChartContainer/index.ts.html +0 -94
  42. package/coverage/lcov-report/components/ChartContainer/intl/index.html +0 -116
  43. package/coverage/lcov-report/components/ChartContainer/intl/index.ts.html +0 -106
  44. package/coverage/lcov-report/components/ChartContainer/styles.ts.html +0 -208
  45. package/coverage/lcov-report/components/DataPoint/DataPoint.tsx.html +0 -391
  46. package/coverage/lcov-report/components/DataPoint/index.html +0 -146
  47. package/coverage/lcov-report/components/DataPoint/index.ts.html +0 -94
  48. package/coverage/lcov-report/components/DataPoint/styles.ts.html +0 -109
  49. package/coverage/lcov-report/components/Dot/Dot.tsx.html +0 -232
  50. package/coverage/lcov-report/components/Dot/index.html +0 -146
  51. package/coverage/lcov-report/components/Dot/index.ts.html +0 -94
  52. package/coverage/lcov-report/components/Dot/styles.ts.html +0 -184
  53. package/coverage/lcov-report/components/HorizontalBar/HorizontalBar.tsx.html +0 -541
  54. package/coverage/lcov-report/components/HorizontalBar/index.html +0 -161
  55. package/coverage/lcov-report/components/HorizontalBar/index.ts.html +0 -94
  56. package/coverage/lcov-report/components/HorizontalBar/styles.ts.html +0 -187
  57. package/coverage/lcov-report/components/HorizontalBar/types.ts.html +0 -301
  58. package/coverage/lcov-report/components/HorizontalBarChart/HorizontalBarChart.tsx.html +0 -691
  59. package/coverage/lcov-report/components/HorizontalBarChart/index.html +0 -146
  60. package/coverage/lcov-report/components/HorizontalBarChart/index.ts.html +0 -94
  61. package/coverage/lcov-report/components/HorizontalBarChart/styles.ts.html +0 -196
  62. package/coverage/lcov-report/components/HorizontalBarChart/types.ts.html +0 -301
  63. package/coverage/lcov-report/components/Legend/Legend.tsx.html +0 -268
  64. package/coverage/lcov-report/components/Legend/index.html +0 -146
  65. package/coverage/lcov-report/components/Legend/index.ts.html +0 -94
  66. package/coverage/lcov-report/components/Legend/styles.ts.html +0 -130
  67. package/coverage/lcov-report/components/LegendItem/LegendItem.tsx.html +0 -325
  68. package/coverage/lcov-report/components/LegendItem/index.html +0 -146
  69. package/coverage/lcov-report/components/LegendItem/index.ts.html +0 -94
  70. package/coverage/lcov-report/components/LegendItem/styles.ts.html +0 -205
  71. package/coverage/lcov-report/components/PieChart/EmptyPieChart.tsx.html +0 -343
  72. package/coverage/lcov-report/components/PieChart/LoadingPieChart.tsx.html +0 -145
  73. package/coverage/lcov-report/components/PieChart/PieChart.tsx.html +0 -385
  74. package/coverage/lcov-report/components/PieChart/RenderedPieChart.tsx.html +0 -607
  75. package/coverage/lcov-report/components/PieChart/index.html +0 -221
  76. package/coverage/lcov-report/components/PieChart/index.ts.html +0 -94
  77. package/coverage/lcov-report/components/PieChart/styles.ts.html +0 -370
  78. package/coverage/lcov-report/components/PieChart/types.ts.html +0 -367
  79. package/coverage/lcov-report/components/PieChart/utils.ts.html +0 -199
  80. package/coverage/lcov-report/components/ScatterPlot/EmptyScatterPlot.tsx.html +0 -295
  81. package/coverage/lcov-report/components/ScatterPlot/LoadingScatterPlot.tsx.html +0 -145
  82. package/coverage/lcov-report/components/ScatterPlot/RenderedScatterPlot.tsx.html +0 -1048
  83. package/coverage/lcov-report/components/ScatterPlot/ScatterPlot.tsx.html +0 -367
  84. package/coverage/lcov-report/components/ScatterPlot/index.html +0 -221
  85. package/coverage/lcov-report/components/ScatterPlot/index.ts.html +0 -94
  86. package/coverage/lcov-report/components/ScatterPlot/styles.ts.html +0 -190
  87. package/coverage/lcov-report/components/ScatterPlot/types.ts.html +0 -394
  88. package/coverage/lcov-report/components/ScatterPlot/utils.ts.html +0 -388
  89. package/coverage/lcov-report/core/Arc/Arc.tsx.html +0 -304
  90. package/coverage/lcov-report/core/Arc/index.html +0 -146
  91. package/coverage/lcov-report/core/Arc/index.ts.html +0 -94
  92. package/coverage/lcov-report/core/Arc/styles.ts.html +0 -202
  93. package/coverage/lcov-report/core/Arcs/Arcs.tsx.html +0 -421
  94. package/coverage/lcov-report/core/Arcs/index.html +0 -146
  95. package/coverage/lcov-report/core/Arcs/index.ts.html +0 -94
  96. package/coverage/lcov-report/core/Arcs/styles.ts.html +0 -106
  97. package/coverage/lcov-report/core/Axis/Axis.tsx.html +0 -754
  98. package/coverage/lcov-report/core/Axis/computeTicks.ts.html +0 -481
  99. package/coverage/lcov-report/core/Axis/index.html +0 -176
  100. package/coverage/lcov-report/core/Axis/index.ts.html +0 -94
  101. package/coverage/lcov-report/core/Axis/styles.ts.html +0 -145
  102. package/coverage/lcov-report/core/Axis/types.ts.html +0 -253
  103. package/coverage/lcov-report/core/Bar/Bar.tsx.html +0 -421
  104. package/coverage/lcov-report/core/Bar/index.html +0 -161
  105. package/coverage/lcov-report/core/Bar/index.ts.html +0 -94
  106. package/coverage/lcov-report/core/Bar/styles.ts.html +0 -190
  107. package/coverage/lcov-report/core/Bar/types.ts.html +0 -178
  108. package/coverage/lcov-report/core/BottomAxis/BottomAxis.tsx.html +0 -277
  109. package/coverage/lcov-report/core/BottomAxis/index.html +0 -146
  110. package/coverage/lcov-report/core/BottomAxis/index.ts.html +0 -94
  111. package/coverage/lcov-report/core/BottomAxis/styles.ts.html +0 -139
  112. package/coverage/lcov-report/core/ChartConfig/ChartConfig.ts.html +0 -97
  113. package/coverage/lcov-report/core/ChartConfig/index.html +0 -131
  114. package/coverage/lcov-report/core/ChartConfig/index.ts.html +0 -88
  115. package/coverage/lcov-report/core/ChartContainer/ChartContainer.tsx.html +0 -421
  116. package/coverage/lcov-report/core/ChartContainer/index.html +0 -146
  117. package/coverage/lcov-report/core/ChartContainer/index.ts.html +0 -94
  118. package/coverage/lcov-report/core/ChartContainer/intl/index.html +0 -116
  119. package/coverage/lcov-report/core/ChartContainer/intl/index.ts.html +0 -106
  120. package/coverage/lcov-report/core/ChartContainer/styles.ts.html +0 -205
  121. package/coverage/lcov-report/core/DataPoint/DataPoint.tsx.html +0 -442
  122. package/coverage/lcov-report/core/DataPoint/index.html +0 -146
  123. package/coverage/lcov-report/core/DataPoint/index.ts.html +0 -94
  124. package/coverage/lcov-report/core/DataPoint/styles.ts.html +0 -109
  125. package/coverage/lcov-report/core/Dot/Dot.tsx.html +0 -232
  126. package/coverage/lcov-report/core/Dot/index.html +0 -146
  127. package/coverage/lcov-report/core/Dot/index.ts.html +0 -94
  128. package/coverage/lcov-report/core/Dot/styles.ts.html +0 -184
  129. package/coverage/lcov-report/core/Legend/Legend.tsx.html +0 -277
  130. package/coverage/lcov-report/core/Legend/index.html +0 -146
  131. package/coverage/lcov-report/core/Legend/index.ts.html +0 -94
  132. package/coverage/lcov-report/core/Legend/styles.ts.html +0 -172
  133. package/coverage/lcov-report/core/Point/Point.tsx.html +0 -484
  134. package/coverage/lcov-report/core/Point/index.html +0 -146
  135. package/coverage/lcov-report/core/Point/index.ts.html +0 -94
  136. package/coverage/lcov-report/core/Point/styles.ts.html +0 -169
  137. package/coverage/lcov-report/favicon.png +0 -0
  138. package/coverage/lcov-report/gallery/HorizontalBarChart/HorizontalBarChart.tsx.html +0 -706
  139. package/coverage/lcov-report/gallery/HorizontalBarChart/index.html +0 -161
  140. package/coverage/lcov-report/gallery/HorizontalBarChart/index.ts.html +0 -94
  141. package/coverage/lcov-report/gallery/HorizontalBarChart/styles.ts.html +0 -316
  142. package/coverage/lcov-report/gallery/HorizontalBarChart/types.ts.html +0 -310
  143. package/coverage/lcov-report/gallery/PieChart/PieChart.tsx.html +0 -1252
  144. package/coverage/lcov-report/gallery/PieChart/index.html +0 -161
  145. package/coverage/lcov-report/gallery/PieChart/index.ts.html +0 -94
  146. package/coverage/lcov-report/gallery/PieChart/styles.ts.html +0 -517
  147. package/coverage/lcov-report/gallery/PieChart/types.ts.html +0 -388
  148. package/coverage/lcov-report/gallery/ScatterPlot/index.html +0 -146
  149. package/coverage/lcov-report/gallery/ScatterPlot/index.ts.html +0 -94
  150. package/coverage/lcov-report/gallery/ScatterPlot/styles.ts.html +0 -343
  151. package/coverage/lcov-report/gallery/ScatterPlot/types.ts.html +0 -433
  152. package/coverage/lcov-report/hooks/index.html +0 -176
  153. package/coverage/lcov-report/hooks/index.ts.html +0 -97
  154. package/coverage/lcov-report/hooks/useBrush.tsx.html +0 -430
  155. package/coverage/lcov-report/hooks/useColor.tsx.html +0 -163
  156. package/coverage/lcov-report/hooks/useFormatCategoricalData.tsx.html +0 -289
  157. package/coverage/lcov-report/hooks/useIsEmpty.tsx.html +0 -118
  158. package/coverage/lcov-report/hooks/useZoom.tsx.html +0 -235
  159. package/coverage/lcov-report/index.html +0 -311
  160. package/coverage/lcov-report/prettify.css +0 -1
  161. package/coverage/lcov-report/prettify.js +0 -2
  162. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  163. package/coverage/lcov-report/sorter.js +0 -196
  164. package/coverage/lcov.info +0 -2345
  165. package/coverage/storybook/coverage-storybook.json +0 -79382
  166. package/dist/index.js.map +0 -1
  167. package/dist/package.json +0 -98
  168. package/index.ts +0 -1
  169. package/jest.config.js +0 -3
  170. package/rollup.config.js +0 -13
  171. package/src/components/Arc/Arc.test.tsx +0 -80
  172. package/src/components/Arc/Arc.tsx +0 -73
  173. package/src/components/Arc/index.ts +0 -3
  174. package/src/components/Arc/styles.ts +0 -41
  175. package/src/components/Arc/types.ts +0 -18
  176. package/src/components/Arcs/Arcs.stories.tsx +0 -177
  177. package/src/components/Arcs/Arcs.tsx +0 -108
  178. package/src/components/Arcs/index.ts +0 -3
  179. package/src/components/Arcs/styles.ts +0 -7
  180. package/src/components/Arcs/types.ts +0 -26
  181. package/src/components/Axis/Axis.stories.tsx +0 -297
  182. package/src/components/Axis/Axis.tsx +0 -223
  183. package/src/components/Axis/computeTicks.ts +0 -132
  184. package/src/components/Axis/index.ts +0 -3
  185. package/src/components/Axis/styles.ts +0 -21
  186. package/src/components/Axis/types.ts +0 -56
  187. package/src/components/Bar/Bar.stories.tsx +0 -152
  188. package/src/components/Bar/Bar.test.tsx +0 -156
  189. package/src/components/Bar/Bar.tsx +0 -112
  190. package/src/components/Bar/index.ts +0 -3
  191. package/src/components/Bar/styles.ts +0 -54
  192. package/src/components/Bar/types.ts +0 -31
  193. package/src/components/BarChart/BarChart.stories.tsx +0 -74
  194. package/src/components/BarChart/BarChart.test.tsx +0 -178
  195. package/src/components/BarChart/BarChart.tsx +0 -89
  196. package/src/components/BarChart/EmptyBarChart.tsx +0 -58
  197. package/src/components/BarChart/LoadingBarChart.tsx +0 -20
  198. package/src/components/BarChart/RenderedBarChart.tsx +0 -115
  199. package/src/components/BarChart/__snapshots__/BarChart.test.tsx.snap +0 -7028
  200. package/src/components/BarChart/index.ts +0 -3
  201. package/src/components/BarChart/styles.ts +0 -35
  202. package/src/components/BarChart/types.ts +0 -58
  203. package/src/components/BarChart/utils.ts +0 -20
  204. package/src/components/ChartContainer/ChartContainer.stories.tsx +0 -81
  205. package/src/components/ChartContainer/ChartContainer.test.tsx +0 -71
  206. package/src/components/ChartContainer/ChartContainer.tsx +0 -92
  207. package/src/components/ChartContainer/index.ts +0 -3
  208. package/src/components/ChartContainer/intl/en-US.json +0 -3
  209. package/src/components/ChartContainer/intl/fr-FR.json +0 -3
  210. package/src/components/ChartContainer/intl/index.ts +0 -7
  211. package/src/components/ChartContainer/styles.ts +0 -41
  212. package/src/components/ChartContainer/types.ts +0 -26
  213. package/src/components/DataPoint/DataPoint.tsx +0 -102
  214. package/src/components/DataPoint/index.ts +0 -3
  215. package/src/components/DataPoint/styles.ts +0 -8
  216. package/src/components/DataPoint/types.ts +0 -33
  217. package/src/components/Dot/Dot.stories.tsx +0 -157
  218. package/src/components/Dot/Dot.test.tsx +0 -136
  219. package/src/components/Dot/Dot.tsx +0 -49
  220. package/src/components/Dot/index.ts +0 -3
  221. package/src/components/Dot/styles.ts +0 -33
  222. package/src/components/Dot/types.ts +0 -16
  223. package/src/components/Legend/Legend.stories.tsx +0 -108
  224. package/src/components/Legend/Legend.tsx +0 -61
  225. package/src/components/Legend/index.ts +0 -3
  226. package/src/components/Legend/styles.ts +0 -15
  227. package/src/components/Legend/types.ts +0 -27
  228. package/src/components/LegendItem/LegendItem.test.tsx +0 -69
  229. package/src/components/LegendItem/LegendItem.tsx +0 -80
  230. package/src/components/LegendItem/index.ts +0 -3
  231. package/src/components/LegendItem/styles.ts +0 -40
  232. package/src/components/LegendItem/types.ts +0 -30
  233. package/src/components/PieChart/EmptyPieChart.tsx +0 -86
  234. package/src/components/PieChart/LoadingPieChart.tsx +0 -20
  235. package/src/components/PieChart/PieChart.stories.tsx +0 -85
  236. package/src/components/PieChart/PieChart.test.tsx +0 -183
  237. package/src/components/PieChart/PieChart.tsx +0 -100
  238. package/src/components/PieChart/RenderedPieChart.tsx +0 -174
  239. package/src/components/PieChart/__snapshots__/PieChart.test.tsx.snap +0 -21020
  240. package/src/components/PieChart/index.ts +0 -3
  241. package/src/components/PieChart/styles.ts +0 -95
  242. package/src/components/PieChart/types.ts +0 -94
  243. package/src/components/PieChart/utils.ts +0 -38
  244. package/src/components/ScatterPlot/EmptyScatterPlot.tsx +0 -70
  245. package/src/components/ScatterPlot/LoadingScatterPlot.tsx +0 -20
  246. package/src/components/ScatterPlot/RenderedScatterPlot.tsx +0 -321
  247. package/src/components/ScatterPlot/ScatterPlot.stories.tsx +0 -101
  248. package/src/components/ScatterPlot/ScatterPlot.test.tsx +0 -61
  249. package/src/components/ScatterPlot/ScatterPlot.tsx +0 -94
  250. package/src/components/ScatterPlot/__snapshots__/ScatterPlot.test.tsx.snap +0 -91712
  251. package/src/components/ScatterPlot/index.ts +0 -3
  252. package/src/components/ScatterPlot/styles.ts +0 -35
  253. package/src/components/ScatterPlot/types.ts +0 -103
  254. package/src/components/ScatterPlot/utils.ts +0 -101
  255. package/src/config.ts +0 -10
  256. package/src/hooks/index.ts +0 -4
  257. package/src/hooks/useBrush.tsx +0 -115
  258. package/src/hooks/useColor.tsx +0 -26
  259. package/src/hooks/useFormatCategoricalData.tsx +0 -68
  260. package/src/hooks/useZoom.tsx +0 -50
  261. package/src/index.ts +0 -15
  262. package/src/scheme.ts +0 -213
  263. package/src/types/data.ts +0 -52
  264. package/src/types/index.ts +0 -5
  265. package/src/types/legend.ts +0 -19
  266. package/src/types/scale.ts +0 -79
  267. package/src/types/size.ts +0 -17
  268. package/src/types/theme.ts +0 -27
  269. package/tsconfig.json +0 -3
  270. /package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
  271. /package/{dist/index.d.ts → index.d.ts} +0 -0
@@ -1,3 +0,0 @@
1
- export * from './BarChart';
2
- export * from './types';
3
- export * from './styles';
@@ -1,35 +0,0 @@
1
- import styled from 'styled-components';
2
- import { StyledBarChartProps } from './types';
3
- import { ChartContainer } from '../ChartContainer';
4
-
5
- /**
6
- * Component style.
7
- */
8
- export const StyledBarChart = styled(ChartContainer)<StyledBarChartProps>``;
9
-
10
- export const StyledBarChartEmptyText = styled.div<{
11
- $maxWidth: number;
12
- $textSize: number;
13
- }>`
14
- position: absolute;
15
- top: 0;
16
- left: 0;
17
- height: 100%;
18
- width: 100%;
19
- display: flex;
20
- flex-direction: column;
21
- justify-content: center;
22
- align-items: center;
23
- pointer-events: none;
24
-
25
- > * {
26
- max-width: ${({ $maxWidth }) => $maxWidth}px;
27
- }
28
-
29
- > span {
30
- font-family: var(--redsift-typography-font-family-poppins);
31
- color: var(--redsift-color-neutral-black);
32
- font-size: ${({ $textSize }) => $textSize}px;
33
- line-height: ${({ $textSize }) => $textSize}px;
34
- }
35
- `;
@@ -1,58 +0,0 @@
1
- import { ComponentProps, ReactNode } from 'react';
2
- import {
3
- ChartDimensions,
4
- ChartSize,
5
- ChartTheme,
6
- BarDatum,
7
- TooltipVariant,
8
- CategoryData,
9
- } from '../../types';
10
- import { ChartContainerProps } from '../ChartContainer';
11
- import { BarProps } from '../Bar';
12
-
13
- interface LocaleText {
14
- emptyChartText: string;
15
- }
16
-
17
- export type BarChartDimensions = ChartDimensions & {
18
- fontSize: number;
19
- };
20
-
21
- /**
22
- * Component props.
23
- */
24
- export interface BarChartProps extends ChartContainerProps {
25
- /** Whether the x axis labels are rotated or not. */
26
- areXLabelsRotated?: boolean;
27
- /** Native HTML props to forward to each bar. */
28
- barProps?: Omit<
29
- ComponentProps<'g'>,
30
- 'onClick' | 'orientation' | 'ref' | 'scale' | 'width'
31
- >;
32
- /** Number of categories to use, the rest being put into a new category called "Others". */
33
- caping?: number;
34
- /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
35
- data?: CategoryData;
36
- /** Component to use if the chart is empty (replacing the default one). */
37
- emptyComponent?: ReactNode;
38
- /** Method to determine whether a slice is selected or not. */
39
- isBarSelected?: (datum: BarDatum) => void;
40
- /** Method to override the data labels. */
41
- labelDecorator?: (datum: BarDatum) => string;
42
- /** Labels and texts. */
43
- localeText?: LocaleText;
44
- /** Method to be called on a click on a bar. */
45
- onBarClick?: (datum: BarDatum) => void;
46
- /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
47
- others?: boolean | string;
48
- /** BarChart size. */
49
- size?: ChartSize | BarChartDimensions;
50
- /** Bar role. Used to indicate that bars are to be considered buttons or links. If an onClick is provided, the bars will have the role `button` unless specifically set to `link` with this prop. */
51
- barRole?: BarProps['role'];
52
- /** 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. */
53
- theme?: ChartTheme;
54
- /** Tooltip variant. */
55
- tooltipVariant?: TooltipVariant;
56
- }
57
-
58
- export type StyledBarChartProps = BarChartProps & {};
@@ -1,20 +0,0 @@
1
- import { ChartSize } from '../../types';
2
- import { BarChartDimensions } from './types';
3
-
4
- export const sizeToDimension = (
5
- size: ChartSize | BarChartDimensions
6
- ): BarChartDimensions => {
7
- if (typeof size !== 'string') {
8
- return size;
9
- }
10
-
11
- switch (size) {
12
- case ChartSize.small:
13
- return { width: 300, height: 200, fontSize: 30 };
14
- case ChartSize.large:
15
- return { width: 500, height: 400, fontSize: 38 };
16
- case ChartSize.medium:
17
- default:
18
- return { width: 400, height: 300, fontSize: 34 };
19
- }
20
- };
@@ -1,81 +0,0 @@
1
- import React from 'react';
2
- // @ts-ignore
3
- import type { StoryObj } from '@storybook/react';
4
-
5
- import { monochrome } from '../../scheme';
6
-
7
- import { ChartContainer, ChartContainerProps } from '.';
8
- import { Heading } from '@redsift/design-system';
9
-
10
- const meta = {
11
- title: 'Charts/Core/Chart Container',
12
- component: ChartContainer,
13
- };
14
-
15
- export default meta;
16
- type Story = StoryObj<ChartContainerProps>;
17
-
18
- const Svg = (
19
- <svg width="100" height="100">
20
- <circle cx={50} cy={50} r={40} fill={monochrome} />
21
- </svg>
22
- );
23
-
24
- export const Empty: Story = {
25
- args: {
26
- 'aria-label': 'Chart',
27
- width: '500px',
28
- },
29
- };
30
-
31
- export const Simple: Story = {
32
- args: {
33
- 'aria-label': 'Chart',
34
- children: Svg,
35
- width: '500px',
36
- },
37
- };
38
-
39
- export const WithTitle: Story = {
40
- args: {
41
- children: Svg,
42
- title: 'Title',
43
- width: '500px',
44
- },
45
- };
46
-
47
- export const WithCustomTitle: Story = {
48
- args: {
49
- children: Svg,
50
- title: <Heading as="h2">Title</Heading>,
51
- width: '500px',
52
- },
53
- };
54
-
55
- export const WithCaption: Story = {
56
- args: {
57
- children: Svg,
58
- title: 'Title',
59
- caption:
60
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rhoncus accumsan massa. Morbi suscipit erat diam, sit amet euismod dolor lacinia et.',
61
- width: '500px',
62
- },
63
- };
64
-
65
- export const WithResetButton: Story = {
66
- args: {
67
- 'aria-label': 'Chart',
68
- children: Svg,
69
- onReset: () => console.log('reset'),
70
- width: '500px',
71
- },
72
- };
73
-
74
- export const WithTitleAndResetButton: Story = {
75
- args: {
76
- children: Svg,
77
- onReset: () => console.log('reset'),
78
- title: 'Title',
79
- width: '500px',
80
- },
81
- };
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
-
4
- import { ChartContainer } from './ChartContainer';
5
-
6
- jest.mock('@redsift/design-system', () => ({
7
- ...jest.requireActual('@redsift/design-system'),
8
- useId: () => ['123'],
9
- }));
10
-
11
- describe('ChartContainer', () => {
12
- it('supports custom className', () => {
13
- const tree = render(
14
- <ChartContainer aria-label="Chart" className="test">
15
- Chart content
16
- </ChartContainer>
17
- );
18
- const component = tree.asFragment().firstChild;
19
-
20
- expect(component).toHaveAttribute('class', expect.stringContaining('test'));
21
- });
22
-
23
- it('supports custom id', () => {
24
- const tree = render(
25
- <ChartContainer id="456" aria-label="Chart">
26
- Chart content
27
- </ChartContainer>
28
- );
29
- const component = tree.asFragment().firstChild;
30
- expect(component).toHaveAttribute('id', '456');
31
- });
32
-
33
- it('supports custom data attributes', () => {
34
- const tree = render(
35
- <ChartContainer aria-label="Chart" data-testid="test">
36
- Chart content
37
- </ChartContainer>
38
- );
39
- const component = tree.asFragment().firstChild;
40
- expect(component).toHaveAttribute('data-testid', 'test');
41
- });
42
-
43
- it('can be labelled using a title', () => {
44
- const { getByLabelText } = render(<ChartContainer title="Title">Chart content</ChartContainer>);
45
- const component = getByLabelText('Title');
46
- expect(component).toHaveAttribute('aria-labelledby', 'id123__title');
47
- });
48
-
49
- it('can be labelled using an aria-label', () => {
50
- const { getByLabelText } = render(<ChartContainer aria-label="Label">Chart content</ChartContainer>);
51
- const component = getByLabelText('Label');
52
- expect(component).toHaveAttribute('aria-label', 'Label');
53
- });
54
-
55
- it('can be labelled using an aria-labelledby', () => {
56
- const { getByLabelText } = render(
57
- <>
58
- <h1 id="123">Label</h1>
59
- <ChartContainer aria-labelledby="123">Chart content</ChartContainer>
60
- </>
61
- );
62
- const component = getByLabelText('Label');
63
- expect(component).toHaveAttribute('aria-labelledby', '123');
64
- });
65
-
66
- it('warns if there is no label for accessibility', () => {
67
- const spy = jest.spyOn(console, 'warn').mockImplementation(() => {});
68
- render(<ChartContainer>Chart content</ChartContainer>);
69
- expect(spy).toHaveBeenCalled();
70
- });
71
- });
@@ -1,92 +0,0 @@
1
- import React, { ComponentProps, forwardRef, RefObject } from 'react';
2
- import classNames from 'classnames';
3
-
4
- import { useLocalizedStringFormatter } from '@react-aria/i18n';
5
- import intlMessages from './intl';
6
-
7
- import { Button, Comp, Flexbox, Heading, useId, warnIfNoAccessibleLabelFound } from '@redsift/design-system';
8
-
9
- import { ChartContainerProps } from './types';
10
- import { StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle } from './styles';
11
-
12
- const COMPONENT_NAME = 'ChartContainer';
13
- const CLASSNAME = 'redsift-chart-container';
14
- const DEFAULT_PROPS: Partial<ChartContainerProps> = {};
15
-
16
- export const ChartContainer: Comp<ChartContainerProps, HTMLDivElement> = forwardRef((props, ref) => {
17
- const {
18
- 'aria-label': propsAriaLabel,
19
- 'aria-labelledby': propsAriaLabelledby,
20
- description,
21
- chartProps,
22
- chartRef,
23
- children,
24
- className,
25
- id: propsId,
26
- title,
27
- onReset,
28
- ...forwardedProps
29
- } = props;
30
- const [_id] = useId();
31
- const id = propsId ?? _id;
32
-
33
- warnIfNoAccessibleLabelFound(props as ComponentProps<keyof JSX.IntrinsicElements>, [title]);
34
-
35
- const stringFormatter = useLocalizedStringFormatter(intlMessages);
36
-
37
- const ariaLabel = propsAriaLabel ? propsAriaLabel : propsAriaLabelledby || title ? undefined : undefined;
38
- const ariaLabelledby = propsAriaLabelledby ? propsAriaLabelledby : title ? `id${id}__title` : undefined;
39
-
40
- return (
41
- <StyledChartContainer
42
- {...forwardedProps}
43
- ref={ref as RefObject<HTMLDivElement>}
44
- className={classNames(ChartContainer.className, className)}
45
- id={id}
46
- >
47
- {title || onReset ? (
48
- <StyledChartContainerTitle
49
- alignItems="center"
50
- justifyContent="space-between"
51
- className={`${ChartContainer.className}__title`}
52
- id={`id${id}__title`}
53
- >
54
- {typeof title === 'string' ? <Heading as="h3">{title}</Heading> : title ? title : null}
55
-
56
- {onReset ? (
57
- <Button
58
- className={`${ChartContainer.className}-title__reset-button`}
59
- color="question"
60
- variant="unstyled"
61
- onClick={onReset}
62
- >
63
- {stringFormatter.format('reset')}
64
- </Button>
65
- ) : null}
66
- </StyledChartContainerTitle>
67
- ) : null}
68
-
69
- <Flexbox flexDirection="column">
70
- {children ? (
71
- <div
72
- {...chartProps}
73
- ref={chartRef}
74
- className={`${ChartContainer.className}__content`}
75
- aria-label={ariaLabel}
76
- aria-labelledby={ariaLabelledby}
77
- >
78
- {children}
79
- </div>
80
- ) : null}
81
- {description ? (
82
- <StyledChartContainerCaption className={`${ChartContainer.className}__description`}>
83
- {description}
84
- </StyledChartContainerCaption>
85
- ) : null}
86
- </Flexbox>
87
- </StyledChartContainer>
88
- );
89
- });
90
- ChartContainer.className = CLASSNAME;
91
- ChartContainer.defaultProps = DEFAULT_PROPS;
92
- ChartContainer.displayName = COMPONENT_NAME;
@@ -1,3 +0,0 @@
1
- export * from './ChartContainer';
2
- export * from './types';
3
- export * from './styles';
@@ -1,3 +0,0 @@
1
- {
2
- "reset": "Reset"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "reset": "Réinitialiser"
3
- }
@@ -1,7 +0,0 @@
1
- import enUS from './en-US.json';
2
- import frFR from './fr-FR.json';
3
-
4
- export default {
5
- 'en-US': enUS,
6
- 'fr-FR': frFR,
7
- };
@@ -1,41 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Flexbox, baseStyling, focusRing } from '@redsift/design-system';
3
- import { StyledChartContainerProps } from './types';
4
-
5
- /**
6
- * Component style.
7
- */
8
- export const StyledChartContainer = styled.div<StyledChartContainerProps>`
9
- ${baseStyling}
10
-
11
- margin: 8px;
12
- padding: 8px;
13
- color: var(--redsift-color-neutral-black);
14
-
15
- .redsift-chart-container__content {
16
- display: flex;
17
- align-items: center;
18
- gap: 16px;
19
- font-family: var(--redsift-typography-font-family-poppins);
20
- font-size: 11px;
21
- justify-content: center;
22
- margin: 8px 0;
23
- position: relative;
24
-
25
- ${focusRing}
26
- }
27
-
28
- svg {
29
- display: block;
30
- }
31
- `;
32
-
33
- export const StyledChartContainerTitle = styled(Flexbox)<StyledChartContainerProps>``;
34
-
35
- export const StyledChartContainerCaption = styled.p<StyledChartContainerProps>`
36
- font-family: var(--redsift-typography-caption-font-family);
37
- font-size: var(--redsift-typography-caption-font-size);
38
- font-weight: var(--redsift-typography-caption-font-weight);
39
- line-height: var(--redsift-typography-caption-line-height);
40
- margin: 8px;
41
- `;
@@ -1,26 +0,0 @@
1
- import { StylingProps } from '@redsift/design-system';
2
- import { ComponentProps, ReactElement, RefObject } from 'react';
3
-
4
- /**
5
- * Component props.
6
- */
7
- export interface ChartContainerProps
8
- extends Omit<ComponentProps<'div'>, 'title'>,
9
- StylingProps {
10
- /** Caption. */
11
- caption?: string;
12
- /** Native HTML props to pass to the chart. */
13
- chartProps?: ComponentProps<'div'>;
14
- /** Ref to the chart. */
15
- chartRef?: RefObject<HTMLDivElement>;
16
- /** Description. */
17
- description?: string;
18
- /** Id. */
19
- id?: string;
20
- /** Method called when the Reset button is displayed (defines whether or not the button should be displayed). */
21
- onReset?: () => void;
22
- /** Title. */
23
- title?: string | ReactElement;
24
- }
25
-
26
- export type StyledChartContainerProps = ChartContainerProps & {};
@@ -1,102 +0,0 @@
1
- import React, { forwardRef, KeyboardEventHandler, RefObject } from 'react';
2
- import classNames from 'classnames';
3
-
4
- import { Comp, Number, Text, useId } from '@redsift/design-system';
5
- import { Tooltip } from '@redsift/popovers';
6
-
7
- import { DataPointProps } from './types';
8
- import { StyledDataPoint } from './styles';
9
- import { TooltipVariant } from '../../types';
10
-
11
- export const DataPoint: Comp<DataPointProps<any>, SVGGElement> = forwardRef((props, ref) => {
12
- const {
13
- children,
14
- className,
15
- data,
16
- id: propsId,
17
- index,
18
- isSelected: propsIsSelected,
19
- labelDecorator,
20
- onClick,
21
- role,
22
- tooltipVariant,
23
- ...forwardedProps
24
- } = props;
25
- const [_id] = useId();
26
- const id = propsId ?? _id;
27
-
28
- const text = labelDecorator ? labelDecorator(data) : data.data.key;
29
- const hasText = text && tooltipVariant !== TooltipVariant.none;
30
- const tooltipValue =
31
- tooltipVariant === TooltipVariant.value
32
- ? data.data.value
33
- : tooltipVariant === TooltipVariant.percent && data.data.percent
34
- ? data.data.percent
35
- : undefined;
36
- const hasValue = tooltipValue && [TooltipVariant.value, TooltipVariant.percent].includes(tooltipVariant!);
37
- const showTooltip = tooltipVariant !== TooltipVariant.none && (hasText || hasValue);
38
-
39
- const isEmpty = data.data.value === 0;
40
-
41
- const isSelectable = role === 'option';
42
- const isSelected = isSelectable && propsIsSelected === true;
43
- const isDeselected = isSelectable && propsIsSelected === false;
44
-
45
- const onKeyDown: KeyboardEventHandler<SVGElement> = (event) => {
46
- if (onClick) {
47
- event.stopPropagation();
48
-
49
- if (event.code === 'Enter' || event.code === 'Space') {
50
- event.preventDefault();
51
- onClick(data);
52
- }
53
- }
54
- };
55
-
56
- const DataPointComponent = (
57
- <StyledDataPoint
58
- tabIndex={onClick ? 0 : undefined}
59
- {...forwardedProps}
60
- className={classNames(className, `_${index}`, {
61
- selected: isSelected,
62
- deselected: isDeselected,
63
- })}
64
- ref={ref as RefObject<SVGGElement>}
65
- aria-label={showTooltip && !isEmpty ? `${text}: ${data.data.value}` : undefined}
66
- aria-labelledby={!showTooltip && !isEmpty ? `${id}-title` : undefined}
67
- aria-selected={isSelected ? true : isDeselected ? false : undefined}
68
- id={id}
69
- onClick={onClick ? () => onClick(data) : undefined}
70
- onKeyDown={onClick ? (e) => onKeyDown(e) : undefined}
71
- role={role ? role : onClick ? 'button' : undefined}
72
- $clickable={Boolean(onClick)}
73
- >
74
- {children}
75
- {!showTooltip && !isEmpty ? <title id={`${id}-title`}>{`${text}: ${data.data.value}`}</title> : null}
76
- </StyledDataPoint>
77
- );
78
-
79
- if (showTooltip) {
80
- return (
81
- <Tooltip placement="right">
82
- <Tooltip.Trigger>{DataPointComponent}</Tooltip.Trigger>
83
- <Tooltip.Content>
84
- <Text variant="caption">
85
- {text}
86
- {hasText && hasValue ? ' - ' : null}
87
- {hasValue ? (
88
- <Number
89
- value={tooltipValue!}
90
- type={tooltipVariant === TooltipVariant.percent ? 'percent' : 'decimal'}
91
- variant="caption"
92
- maximumFractionDigits={2}
93
- />
94
- ) : null}
95
- </Text>
96
- </Tooltip.Content>
97
- </Tooltip>
98
- );
99
- }
100
-
101
- return DataPointComponent;
102
- });
@@ -1,3 +0,0 @@
1
- export * from './DataPoint';
2
- export * from './types';
3
- export * from './styles';
@@ -1,8 +0,0 @@
1
- import styled from 'styled-components';
2
- import { animated } from '@react-spring/web';
3
- import { StyledDataPointProps } from './types';
4
-
5
- /**
6
- * Component style.
7
- */
8
- export const StyledDataPoint = styled(animated.g)<StyledDataPointProps>``;
@@ -1,33 +0,0 @@
1
- import { ComponentProps } from 'react';
2
- import { TooltipVariant } from '../../types';
3
-
4
- /**
5
- * Component props.
6
- */
7
- export interface DataPointProps<T>
8
- extends Omit<ComponentProps<'g'>, 'onClick' | 'scale'> {
9
- /** Color of the DataPoint. */
10
- color?: string;
11
- /** Data. Also state to which the component should end the animation, if any. */
12
- data: T;
13
- /** Id. Used for accessibility. */
14
- id?: string;
15
- /** Position in the list of siblings. Used for placement and selection. */
16
- index?: number;
17
- /** Whether the component is selected or not. Used only if the component is selectable. Set to `undefined` to make nor selected nor unselected. */
18
- isSelected?: boolean;
19
- /** Method modifying the label before displaying it. */
20
- labelDecorator?: (data: T) => string;
21
- /** Method called when a click or keydown occurs on the component. */
22
- onClick?: (data: T) => void;
23
- /** State from which the component should start the animation, if any. */
24
- previousData?: T;
25
- /** Role. Will be set to 'button' if onClick is provided. If 'option', then the component becomes selectable. */
26
- role?: 'button' | 'link' | 'option';
27
- /** Tooltip variant. */
28
- tooltipVariant?: TooltipVariant;
29
- }
30
-
31
- export type StyledDataPointProps = Omit<DataPointProps<any>, 'data'> & {
32
- $clickable: boolean;
33
- };