@redsift/charts 9.2.3-patch → 9.2.3

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 (270) hide show
  1. package/coverage/clover.xml +1096 -0
  2. package/coverage/coverage-final.json +60 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +87 -0
  5. package/coverage/lcov-report/components/Arc/Arc.tsx.html +304 -0
  6. package/coverage/lcov-report/components/Arc/index.html +146 -0
  7. package/coverage/lcov-report/components/Arc/index.ts.html +94 -0
  8. package/coverage/lcov-report/components/Arc/styles.ts.html +208 -0
  9. package/coverage/lcov-report/components/Arcs/Arcs.tsx.html +409 -0
  10. package/coverage/lcov-report/components/Arcs/index.html +146 -0
  11. package/coverage/lcov-report/components/Arcs/index.ts.html +94 -0
  12. package/coverage/lcov-report/components/Arcs/styles.ts.html +106 -0
  13. package/coverage/lcov-report/components/Axis/Axis.tsx.html +754 -0
  14. package/coverage/lcov-report/components/Axis/computeTicks.ts.html +481 -0
  15. package/coverage/lcov-report/components/Axis/index.html +176 -0
  16. package/coverage/lcov-report/components/Axis/index.ts.html +94 -0
  17. package/coverage/lcov-report/components/Axis/styles.ts.html +148 -0
  18. package/coverage/lcov-report/components/Axis/types.ts.html +253 -0
  19. package/coverage/lcov-report/components/Bar/Bar.tsx.html +421 -0
  20. package/coverage/lcov-report/components/Bar/index.html +161 -0
  21. package/coverage/lcov-report/components/Bar/index.ts.html +94 -0
  22. package/coverage/lcov-report/components/Bar/styles.ts.html +247 -0
  23. package/coverage/lcov-report/components/Bar/types.ts.html +178 -0
  24. package/coverage/lcov-report/components/BarChart/BarChart.tsx.html +352 -0
  25. package/coverage/lcov-report/components/BarChart/EmptyBarChart.tsx.html +259 -0
  26. package/coverage/lcov-report/components/BarChart/LoadingBarChart.tsx.html +145 -0
  27. package/coverage/lcov-report/components/BarChart/RenderedBarChart.tsx.html +430 -0
  28. package/coverage/lcov-report/components/BarChart/index.html +206 -0
  29. package/coverage/lcov-report/components/BarChart/index.ts.html +94 -0
  30. package/coverage/lcov-report/components/BarChart/styles.ts.html +190 -0
  31. package/coverage/lcov-report/components/BarChart/utils.ts.html +145 -0
  32. package/coverage/lcov-report/components/BottomAxis/BottomAxis.tsx.html +247 -0
  33. package/coverage/lcov-report/components/BottomAxis/index.html +146 -0
  34. package/coverage/lcov-report/components/BottomAxis/index.ts.html +94 -0
  35. package/coverage/lcov-report/components/BottomAxis/styles.ts.html +139 -0
  36. package/coverage/lcov-report/components/ChartContainer/ChartContainer.tsx.html +361 -0
  37. package/coverage/lcov-report/components/ChartContainer/index.html +146 -0
  38. package/coverage/lcov-report/components/ChartContainer/index.ts.html +94 -0
  39. package/coverage/lcov-report/components/ChartContainer/intl/index.html +116 -0
  40. package/coverage/lcov-report/components/ChartContainer/intl/index.ts.html +106 -0
  41. package/coverage/lcov-report/components/ChartContainer/styles.ts.html +208 -0
  42. package/coverage/lcov-report/components/DataPoint/DataPoint.tsx.html +391 -0
  43. package/coverage/lcov-report/components/DataPoint/index.html +146 -0
  44. package/coverage/lcov-report/components/DataPoint/index.ts.html +94 -0
  45. package/coverage/lcov-report/components/DataPoint/styles.ts.html +109 -0
  46. package/coverage/lcov-report/components/Dot/Dot.tsx.html +232 -0
  47. package/coverage/lcov-report/components/Dot/index.html +146 -0
  48. package/coverage/lcov-report/components/Dot/index.ts.html +94 -0
  49. package/coverage/lcov-report/components/Dot/styles.ts.html +184 -0
  50. package/coverage/lcov-report/components/HorizontalBar/HorizontalBar.tsx.html +541 -0
  51. package/coverage/lcov-report/components/HorizontalBar/index.html +161 -0
  52. package/coverage/lcov-report/components/HorizontalBar/index.ts.html +94 -0
  53. package/coverage/lcov-report/components/HorizontalBar/styles.ts.html +187 -0
  54. package/coverage/lcov-report/components/HorizontalBar/types.ts.html +301 -0
  55. package/coverage/lcov-report/components/HorizontalBarChart/HorizontalBarChart.tsx.html +691 -0
  56. package/coverage/lcov-report/components/HorizontalBarChart/index.html +146 -0
  57. package/coverage/lcov-report/components/HorizontalBarChart/index.ts.html +94 -0
  58. package/coverage/lcov-report/components/HorizontalBarChart/styles.ts.html +196 -0
  59. package/coverage/lcov-report/components/HorizontalBarChart/types.ts.html +301 -0
  60. package/coverage/lcov-report/components/Legend/Legend.tsx.html +268 -0
  61. package/coverage/lcov-report/components/Legend/index.html +146 -0
  62. package/coverage/lcov-report/components/Legend/index.ts.html +94 -0
  63. package/coverage/lcov-report/components/Legend/styles.ts.html +130 -0
  64. package/coverage/lcov-report/components/LegendItem/LegendItem.tsx.html +325 -0
  65. package/coverage/lcov-report/components/LegendItem/index.html +146 -0
  66. package/coverage/lcov-report/components/LegendItem/index.ts.html +94 -0
  67. package/coverage/lcov-report/components/LegendItem/styles.ts.html +205 -0
  68. package/coverage/lcov-report/components/PieChart/EmptyPieChart.tsx.html +343 -0
  69. package/coverage/lcov-report/components/PieChart/LoadingPieChart.tsx.html +145 -0
  70. package/coverage/lcov-report/components/PieChart/PieChart.tsx.html +385 -0
  71. package/coverage/lcov-report/components/PieChart/RenderedPieChart.tsx.html +607 -0
  72. package/coverage/lcov-report/components/PieChart/index.html +221 -0
  73. package/coverage/lcov-report/components/PieChart/index.ts.html +94 -0
  74. package/coverage/lcov-report/components/PieChart/styles.ts.html +370 -0
  75. package/coverage/lcov-report/components/PieChart/types.ts.html +367 -0
  76. package/coverage/lcov-report/components/PieChart/utils.ts.html +199 -0
  77. package/coverage/lcov-report/components/ScatterPlot/EmptyScatterPlot.tsx.html +295 -0
  78. package/coverage/lcov-report/components/ScatterPlot/LoadingScatterPlot.tsx.html +145 -0
  79. package/coverage/lcov-report/components/ScatterPlot/RenderedScatterPlot.tsx.html +1048 -0
  80. package/coverage/lcov-report/components/ScatterPlot/ScatterPlot.tsx.html +367 -0
  81. package/coverage/lcov-report/components/ScatterPlot/index.html +221 -0
  82. package/coverage/lcov-report/components/ScatterPlot/index.ts.html +94 -0
  83. package/coverage/lcov-report/components/ScatterPlot/styles.ts.html +190 -0
  84. package/coverage/lcov-report/components/ScatterPlot/types.ts.html +394 -0
  85. package/coverage/lcov-report/components/ScatterPlot/utils.ts.html +388 -0
  86. package/coverage/lcov-report/core/Arc/Arc.tsx.html +304 -0
  87. package/coverage/lcov-report/core/Arc/index.html +146 -0
  88. package/coverage/lcov-report/core/Arc/index.ts.html +94 -0
  89. package/coverage/lcov-report/core/Arc/styles.ts.html +202 -0
  90. package/coverage/lcov-report/core/Arcs/Arcs.tsx.html +421 -0
  91. package/coverage/lcov-report/core/Arcs/index.html +146 -0
  92. package/coverage/lcov-report/core/Arcs/index.ts.html +94 -0
  93. package/coverage/lcov-report/core/Arcs/styles.ts.html +106 -0
  94. package/coverage/lcov-report/core/Axis/Axis.tsx.html +754 -0
  95. package/coverage/lcov-report/core/Axis/computeTicks.ts.html +481 -0
  96. package/coverage/lcov-report/core/Axis/index.html +176 -0
  97. package/coverage/lcov-report/core/Axis/index.ts.html +94 -0
  98. package/coverage/lcov-report/core/Axis/styles.ts.html +145 -0
  99. package/coverage/lcov-report/core/Axis/types.ts.html +253 -0
  100. package/coverage/lcov-report/core/Bar/Bar.tsx.html +421 -0
  101. package/coverage/lcov-report/core/Bar/index.html +161 -0
  102. package/coverage/lcov-report/core/Bar/index.ts.html +94 -0
  103. package/coverage/lcov-report/core/Bar/styles.ts.html +190 -0
  104. package/coverage/lcov-report/core/Bar/types.ts.html +178 -0
  105. package/coverage/lcov-report/core/BottomAxis/BottomAxis.tsx.html +277 -0
  106. package/coverage/lcov-report/core/BottomAxis/index.html +146 -0
  107. package/coverage/lcov-report/core/BottomAxis/index.ts.html +94 -0
  108. package/coverage/lcov-report/core/BottomAxis/styles.ts.html +139 -0
  109. package/coverage/lcov-report/core/ChartConfig/ChartConfig.ts.html +97 -0
  110. package/coverage/lcov-report/core/ChartConfig/index.html +131 -0
  111. package/coverage/lcov-report/core/ChartConfig/index.ts.html +88 -0
  112. package/coverage/lcov-report/core/ChartContainer/ChartContainer.tsx.html +421 -0
  113. package/coverage/lcov-report/core/ChartContainer/index.html +146 -0
  114. package/coverage/lcov-report/core/ChartContainer/index.ts.html +94 -0
  115. package/coverage/lcov-report/core/ChartContainer/intl/index.html +116 -0
  116. package/coverage/lcov-report/core/ChartContainer/intl/index.ts.html +106 -0
  117. package/coverage/lcov-report/core/ChartContainer/styles.ts.html +205 -0
  118. package/coverage/lcov-report/core/DataPoint/DataPoint.tsx.html +442 -0
  119. package/coverage/lcov-report/core/DataPoint/index.html +146 -0
  120. package/coverage/lcov-report/core/DataPoint/index.ts.html +94 -0
  121. package/coverage/lcov-report/core/DataPoint/styles.ts.html +109 -0
  122. package/coverage/lcov-report/core/Dot/Dot.tsx.html +232 -0
  123. package/coverage/lcov-report/core/Dot/index.html +146 -0
  124. package/coverage/lcov-report/core/Dot/index.ts.html +94 -0
  125. package/coverage/lcov-report/core/Dot/styles.ts.html +184 -0
  126. package/coverage/lcov-report/core/Legend/Legend.tsx.html +277 -0
  127. package/coverage/lcov-report/core/Legend/index.html +146 -0
  128. package/coverage/lcov-report/core/Legend/index.ts.html +94 -0
  129. package/coverage/lcov-report/core/Legend/styles.ts.html +172 -0
  130. package/coverage/lcov-report/core/Point/Point.tsx.html +484 -0
  131. package/coverage/lcov-report/core/Point/index.html +146 -0
  132. package/coverage/lcov-report/core/Point/index.ts.html +94 -0
  133. package/coverage/lcov-report/core/Point/styles.ts.html +169 -0
  134. package/coverage/lcov-report/favicon.png +0 -0
  135. package/coverage/lcov-report/gallery/HorizontalBarChart/HorizontalBarChart.tsx.html +706 -0
  136. package/coverage/lcov-report/gallery/HorizontalBarChart/index.html +161 -0
  137. package/coverage/lcov-report/gallery/HorizontalBarChart/index.ts.html +94 -0
  138. package/coverage/lcov-report/gallery/HorizontalBarChart/styles.ts.html +316 -0
  139. package/coverage/lcov-report/gallery/HorizontalBarChart/types.ts.html +310 -0
  140. package/coverage/lcov-report/gallery/PieChart/PieChart.tsx.html +1252 -0
  141. package/coverage/lcov-report/gallery/PieChart/index.html +161 -0
  142. package/coverage/lcov-report/gallery/PieChart/index.ts.html +94 -0
  143. package/coverage/lcov-report/gallery/PieChart/styles.ts.html +517 -0
  144. package/coverage/lcov-report/gallery/PieChart/types.ts.html +388 -0
  145. package/coverage/lcov-report/gallery/ScatterPlot/index.html +146 -0
  146. package/coverage/lcov-report/gallery/ScatterPlot/index.ts.html +94 -0
  147. package/coverage/lcov-report/gallery/ScatterPlot/styles.ts.html +343 -0
  148. package/coverage/lcov-report/gallery/ScatterPlot/types.ts.html +433 -0
  149. package/coverage/lcov-report/hooks/index.html +176 -0
  150. package/coverage/lcov-report/hooks/index.ts.html +97 -0
  151. package/coverage/lcov-report/hooks/useBrush.tsx.html +430 -0
  152. package/coverage/lcov-report/hooks/useColor.tsx.html +163 -0
  153. package/coverage/lcov-report/hooks/useFormatCategoricalData.tsx.html +289 -0
  154. package/coverage/lcov-report/hooks/useIsEmpty.tsx.html +118 -0
  155. package/coverage/lcov-report/hooks/useZoom.tsx.html +235 -0
  156. package/coverage/lcov-report/index.html +311 -0
  157. package/coverage/lcov-report/prettify.css +1 -0
  158. package/coverage/lcov-report/prettify.js +2 -0
  159. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  160. package/coverage/lcov-report/sorter.js +196 -0
  161. package/coverage/lcov.info +2345 -0
  162. package/coverage/storybook/coverage-storybook.json +79382 -0
  163. package/dist/package.json +98 -0
  164. package/index.ts +1 -0
  165. package/jest.config.js +3 -0
  166. package/package.json +2 -3
  167. package/rollup.config.js +13 -0
  168. package/src/components/Arc/Arc.test.tsx +80 -0
  169. package/src/components/Arc/Arc.tsx +73 -0
  170. package/src/components/Arc/index.ts +3 -0
  171. package/src/components/Arc/styles.ts +41 -0
  172. package/src/components/Arc/types.ts +18 -0
  173. package/src/components/Arcs/Arcs.stories.tsx +177 -0
  174. package/src/components/Arcs/Arcs.tsx +108 -0
  175. package/src/components/Arcs/index.ts +3 -0
  176. package/src/components/Arcs/styles.ts +7 -0
  177. package/src/components/Arcs/types.ts +26 -0
  178. package/src/components/Axis/Axis.stories.tsx +297 -0
  179. package/src/components/Axis/Axis.tsx +223 -0
  180. package/src/components/Axis/computeTicks.ts +132 -0
  181. package/src/components/Axis/index.ts +3 -0
  182. package/src/components/Axis/styles.ts +21 -0
  183. package/src/components/Axis/types.ts +56 -0
  184. package/src/components/Bar/Bar.stories.tsx +152 -0
  185. package/src/components/Bar/Bar.test.tsx +156 -0
  186. package/src/components/Bar/Bar.tsx +112 -0
  187. package/src/components/Bar/index.ts +3 -0
  188. package/src/components/Bar/styles.ts +54 -0
  189. package/src/components/Bar/types.ts +31 -0
  190. package/src/components/BarChart/BarChart.stories.tsx +74 -0
  191. package/src/components/BarChart/BarChart.test.tsx +178 -0
  192. package/src/components/BarChart/BarChart.tsx +89 -0
  193. package/src/components/BarChart/EmptyBarChart.tsx +58 -0
  194. package/src/components/BarChart/LoadingBarChart.tsx +20 -0
  195. package/src/components/BarChart/RenderedBarChart.tsx +115 -0
  196. package/src/components/BarChart/__snapshots__/BarChart.test.tsx.snap +7028 -0
  197. package/src/components/BarChart/index.ts +3 -0
  198. package/src/components/BarChart/styles.ts +35 -0
  199. package/src/components/BarChart/types.ts +58 -0
  200. package/src/components/BarChart/utils.ts +20 -0
  201. package/src/components/ChartContainer/ChartContainer.stories.tsx +81 -0
  202. package/src/components/ChartContainer/ChartContainer.test.tsx +71 -0
  203. package/src/components/ChartContainer/ChartContainer.tsx +92 -0
  204. package/src/components/ChartContainer/index.ts +3 -0
  205. package/src/components/ChartContainer/intl/en-US.json +3 -0
  206. package/src/components/ChartContainer/intl/fr-FR.json +3 -0
  207. package/src/components/ChartContainer/intl/index.ts +7 -0
  208. package/src/components/ChartContainer/styles.ts +41 -0
  209. package/src/components/ChartContainer/types.ts +26 -0
  210. package/src/components/DataPoint/DataPoint.tsx +102 -0
  211. package/src/components/DataPoint/index.ts +3 -0
  212. package/src/components/DataPoint/styles.ts +8 -0
  213. package/src/components/DataPoint/types.ts +33 -0
  214. package/src/components/Dot/Dot.stories.tsx +157 -0
  215. package/src/components/Dot/Dot.test.tsx +136 -0
  216. package/src/components/Dot/Dot.tsx +49 -0
  217. package/src/components/Dot/index.ts +3 -0
  218. package/src/components/Dot/styles.ts +33 -0
  219. package/src/components/Dot/types.ts +16 -0
  220. package/src/components/Legend/Legend.stories.tsx +108 -0
  221. package/src/components/Legend/Legend.tsx +61 -0
  222. package/src/components/Legend/index.ts +3 -0
  223. package/src/components/Legend/styles.ts +15 -0
  224. package/src/components/Legend/types.ts +27 -0
  225. package/src/components/LegendItem/LegendItem.test.tsx +69 -0
  226. package/src/components/LegendItem/LegendItem.tsx +80 -0
  227. package/src/components/LegendItem/index.ts +3 -0
  228. package/src/components/LegendItem/styles.ts +40 -0
  229. package/src/components/LegendItem/types.ts +30 -0
  230. package/src/components/PieChart/EmptyPieChart.tsx +86 -0
  231. package/src/components/PieChart/LoadingPieChart.tsx +20 -0
  232. package/src/components/PieChart/PieChart.stories.tsx +85 -0
  233. package/src/components/PieChart/PieChart.test.tsx +183 -0
  234. package/src/components/PieChart/PieChart.tsx +100 -0
  235. package/src/components/PieChart/RenderedPieChart.tsx +174 -0
  236. package/src/components/PieChart/__snapshots__/PieChart.test.tsx.snap +21020 -0
  237. package/src/components/PieChart/index.ts +3 -0
  238. package/src/components/PieChart/styles.ts +95 -0
  239. package/src/components/PieChart/types.ts +94 -0
  240. package/src/components/PieChart/utils.ts +38 -0
  241. package/src/components/ScatterPlot/EmptyScatterPlot.tsx +70 -0
  242. package/src/components/ScatterPlot/LoadingScatterPlot.tsx +20 -0
  243. package/src/components/ScatterPlot/RenderedScatterPlot.tsx +321 -0
  244. package/src/components/ScatterPlot/ScatterPlot.stories.tsx +101 -0
  245. package/src/components/ScatterPlot/ScatterPlot.test.tsx +61 -0
  246. package/src/components/ScatterPlot/ScatterPlot.tsx +94 -0
  247. package/src/components/ScatterPlot/__snapshots__/ScatterPlot.test.tsx.snap +91712 -0
  248. package/src/components/ScatterPlot/index.ts +3 -0
  249. package/src/components/ScatterPlot/styles.ts +35 -0
  250. package/src/components/ScatterPlot/types.ts +103 -0
  251. package/src/components/ScatterPlot/utils.ts +101 -0
  252. package/src/config.ts +10 -0
  253. package/src/hooks/index.ts +4 -0
  254. package/src/hooks/useBrush.tsx +115 -0
  255. package/src/hooks/useColor.tsx +26 -0
  256. package/src/hooks/useFormatCategoricalData.tsx +68 -0
  257. package/src/hooks/useZoom.tsx +50 -0
  258. package/src/index.ts +15 -0
  259. package/src/scheme.ts +213 -0
  260. package/src/types/data.ts +52 -0
  261. package/src/types/index.ts +5 -0
  262. package/src/types/legend.ts +19 -0
  263. package/src/types/scale.ts +79 -0
  264. package/src/types/size.ts +17 -0
  265. package/src/types/theme.ts +27 -0
  266. package/tsconfig.json +3 -0
  267. /package/{CONTRIBUTING.md → dist/CONTRIBUTING.md} +0 -0
  268. /package/{index.d.ts → dist/index.d.ts} +0 -0
  269. /package/{index.js → dist/index.js} +0 -0
  270. /package/{index.js.map → dist/index.js.map} +0 -0
@@ -0,0 +1,98 @@
1
+ {
2
+ "author": {
3
+ "name": "Red Sift"
4
+ },
5
+ "bugs": {
6
+ "url": "https://github.com/redsift/design-system/issues"
7
+ },
8
+ "description": "Chart component library as part of Red Sift's Design System. This package is based on d3.js for computation, react for rendering and events and react-spring for animations and transitions.",
9
+ "homepage": "https://github.com/redsift/design-system",
10
+ "license": "MIT",
11
+ "main": "index.js",
12
+ "module": "index.js",
13
+ "name": "@redsift/charts",
14
+ "publishConfig": {
15
+ "directory": "dist"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/redsift/design-system"
20
+ },
21
+ "sideEffects": false,
22
+ "scripts": {
23
+ "build": "rollup -c",
24
+ "check-types": "tsc && tsc-strict",
25
+ "lint": "eslint --ext .js,.jsx,.ts,.tsx src/",
26
+ "prepare": "install-peers || exit 0",
27
+ "prepublishOnly": "yarn build",
28
+ "test:unit": "NODE_ENV=test jest --verbose",
29
+ "test:storybook": "test-storybook -c ../../.storybook --url http://localhost:9000/ --coverage",
30
+ "test": "yarn test:unit && yarn test:storybook"
31
+ },
32
+ "types": "types.d.ts",
33
+ "version": "9.2.3",
34
+ "dependencies": {
35
+ "@emotion/react": "^11.10.4",
36
+ "@emotion/styled": "^11.10.4",
37
+ "@react-aria/i18n": "3.7.2",
38
+ "classnames": "^2.3.1",
39
+ "d3": "^7.8.0",
40
+ "d3-shape": "^3.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@babel/core": "^7.8.3",
44
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
45
+ "@babel/plugin-proposal-export-default-from": "^7.16.7",
46
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
47
+ "@babel/plugin-proposal-object-rest-spread": "^7.17.3",
48
+ "@babel/plugin-proposal-optional-chaining": "^7.16.7",
49
+ "@babel/plugin-proposal-private-methods": "^7.16.11",
50
+ "@babel/plugin-proposal-private-property-in-object": "^7.16.7",
51
+ "@babel/preset-env": "^7.17.10",
52
+ "@babel/preset-react": "^7.17.12",
53
+ "@babel/preset-typescript": "^7.16.7",
54
+ "@react-spring/web": "^9.7.1",
55
+ "@rollup/plugin-babel": "^6.0.2",
56
+ "@rollup/plugin-commonjs": "^24.0.0",
57
+ "@rollup/plugin-json": "^6.0.0",
58
+ "@rollup/plugin-node-resolve": "^13.3.0",
59
+ "@testing-library/dom": "^8.5.0",
60
+ "@testing-library/jest-dom": "^5.16.4",
61
+ "@testing-library/react": "^13.4.0",
62
+ "@testing-library/react-hooks": "^8.0.1",
63
+ "@testing-library/user-event": "14.2.1",
64
+ "@types/d3": "^7.4.0",
65
+ "@types/d3-shape": "^3.1.0",
66
+ "@types/jest": "^27.5.1",
67
+ "@types/react": "18.0.12",
68
+ "@types/react-dom": "18.0.5",
69
+ "@types/styled-components": "^5.1.25",
70
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
71
+ "@typescript-eslint/parser": "^5.26.0",
72
+ "identity-obj-proxy": "^3.0.0",
73
+ "install-peers-cli": "^2.2.0",
74
+ "jest": "^28.1.0",
75
+ "jest-environment-jsdom": "^29.3.0",
76
+ "msw": "^0.47.4",
77
+ "react": "18.2.0",
78
+ "react-dom": "18.2.0",
79
+ "rollup": "^2.72.1",
80
+ "rollup-plugin-analyzer": "^4.0.0",
81
+ "rollup-plugin-auto-external": "^2.0.0",
82
+ "rollup-plugin-cleaner": "^1.0.0",
83
+ "rollup-plugin-copy": "^3.4.0",
84
+ "rollup-plugin-dts": "^5.0.0",
85
+ "rollup-plugin-execute": "^1.1.0",
86
+ "rollup-plugin-svg": "^2.0.0",
87
+ "rollup-plugin-ts-paths-resolve": "^1.7.1",
88
+ "rollup-plugin-typescript-paths": "^1.3.1",
89
+ "ts-jest": "^28.0.3"
90
+ },
91
+ "peerDependencies": {
92
+ "@redsift/design-system": ">=9.0.0-alpha.0",
93
+ "@redsift/popovers": ">=9.0.0-alpha.0",
94
+ "react": ">=17",
95
+ "react-dom": ">=17",
96
+ "styled-components": "^5.3.5"
97
+ }
98
+ }
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src';
package/jest.config.js ADDED
@@ -0,0 +1,3 @@
1
+ var JEST_CONFIG = require('../../configs/jest.config');
2
+
3
+ module.exports = { ...JEST_CONFIG };
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "test": "yarn test:unit && yarn test:storybook"
31
31
  },
32
32
  "types": "types.d.ts",
33
- "version": "9.2.3-patch",
33
+ "version": "9.2.3",
34
34
  "dependencies": {
35
35
  "@emotion/react": "^11.10.4",
36
36
  "@emotion/styled": "^11.10.4",
@@ -94,6 +94,5 @@
94
94
  "react": ">=17",
95
95
  "react-dom": ">=17",
96
96
  "styled-components": "^5.3.5"
97
- },
98
- "gitHead": "44635b1b3181bd68befd7efc0c3519a81342ad7b"
97
+ }
99
98
  }
@@ -0,0 +1,13 @@
1
+ import { rollupConfig } from '../../configs/rollup.base.config';
2
+
3
+ import pkg from './package.json';
4
+
5
+ const baseRollupConfig = rollupConfig(__dirname, pkg);
6
+
7
+ // Bundle JS code
8
+ const bundleJS = { ...baseRollupConfig.bundleJS };
9
+
10
+ // Bundle TS types in D.TS files
11
+ const bundleType = { ...baseRollupConfig.bundleType };
12
+
13
+ export default [bundleJS, bundleType];
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { arc as d3arc, pie as d3pie } from 'd3';
5
+
6
+ import { Arc } from './Arc';
7
+ import { ArcDatum, TooltipVariant, CategoryDatum } from '../../types';
8
+
9
+ jest.mock('@redsift/design-system', () => ({
10
+ ...jest.requireActual('@redsift/design-system'),
11
+ useId: () => ['123'],
12
+ }));
13
+
14
+ const createArc = d3arc<ArcDatum>().innerRadius(0).outerRadius(150);
15
+ const createPie = d3pie<CategoryDatum>()
16
+ .value((d) => d.value)
17
+ .sort(null);
18
+ const data = [
19
+ {
20
+ key: 'Croissant',
21
+ value: 333,
22
+ },
23
+ ];
24
+ const pieData = createPie(data);
25
+
26
+ describe('Arc', () => {
27
+ const onClickSpy = jest.fn();
28
+
29
+ afterEach(() => {
30
+ onClickSpy.mockClear();
31
+ });
32
+
33
+ it('supports click', async () => {
34
+ const { getByRole } = render(
35
+ <svg width={500} height={500}>
36
+ <Arc id="123" index={0} data={pieData[0]} createArc={createArc} onClick={onClickSpy} />
37
+ </svg>
38
+ );
39
+
40
+ const bar = getByRole('button');
41
+ fireEvent.click(bar);
42
+ expect(onClickSpy).toHaveBeenCalledWith(pieData[0]);
43
+ });
44
+
45
+ it('supports keydown', async () => {
46
+ const { getByRole } = render(
47
+ <svg width={500} height={500}>
48
+ <Arc id="123" index={0} data={pieData[0]} createArc={createArc} onClick={onClickSpy} />
49
+ </svg>
50
+ );
51
+
52
+ const bar = getByRole('button');
53
+ fireEvent.keyDown(bar, { key: 'Enter', code: 'Enter', charCode: 13 });
54
+ expect(onClickSpy).toHaveBeenCalledWith(pieData[0]);
55
+ });
56
+
57
+ it('shows a tooltip on hover', async () => {
58
+ const user = userEvent.setup();
59
+ const { getByRole } = render(
60
+ <svg width={500} height={500}>
61
+ <Arc
62
+ index={0}
63
+ // The onClick gives the bar the role "button" which is then used to access the bars.
64
+ onClick={onClickSpy}
65
+ data={pieData[0]}
66
+ createArc={createArc}
67
+ tooltipVariant={TooltipVariant.label}
68
+ />
69
+ </svg>
70
+ );
71
+
72
+ const bar = getByRole('button');
73
+ await user.hover(bar);
74
+ await waitFor(() => {
75
+ expect(screen.getByRole('tooltip', { exact: true })).toBeInTheDocument();
76
+ });
77
+ const tooltip = screen.getByRole('tooltip');
78
+ expect(tooltip.textContent).toContain('Croissant');
79
+ });
80
+ });
@@ -0,0 +1,73 @@
1
+ import React, { forwardRef } from 'react';
2
+ import classNames from 'classnames';
3
+ import { animated, useSpring } from '@react-spring/web';
4
+ import { interpolate as d3interpolate } from 'd3';
5
+
6
+ import { Comp } from '@redsift/design-system';
7
+
8
+ import { ArcProps } from './types';
9
+ import { StyledArc } from './styles';
10
+ import { monochrome } from '../../scheme';
11
+ import { config } from '../../config';
12
+
13
+ const COMPONENT_NAME = 'Arc';
14
+ const CLASSNAME = 'redsift-arc';
15
+ const DEFAULT_PROPS: Partial<ArcProps> = {
16
+ color: monochrome,
17
+ index: 0,
18
+ previousData: {
19
+ data: {
20
+ key: '',
21
+ value: 0,
22
+ },
23
+ startAngle: 0,
24
+ endAngle: 0,
25
+ padAngle: 0,
26
+ value: 0,
27
+ index: 0,
28
+ },
29
+ };
30
+
31
+ export const Arc: Comp<ArcProps, SVGGElement> = forwardRef((props, ref) => {
32
+ const { color, data, isSelected: propsIsSelected, onClick, role } = props;
33
+
34
+ const { className, createArc, hasStroke, previousData, ...forwardedProps } =
35
+ props;
36
+
37
+ const interpolator = d3interpolate(previousData, data);
38
+
39
+ const isSelectable = role === 'option';
40
+ const isDeselected = isSelectable && propsIsSelected === false;
41
+
42
+ const animatedProps = useSpring({
43
+ ...config,
44
+ to: async (next: (props?: object) => Promise<void>) => {
45
+ await next({ t: 1 });
46
+ },
47
+ from: { t: 0 },
48
+ });
49
+
50
+ return (
51
+ <StyledArc
52
+ {...forwardedProps}
53
+ ref={ref}
54
+ className={classNames(Arc.className, className)}
55
+ $clickable={Boolean(onClick)}
56
+ $hasStroke={Boolean(hasStroke)}
57
+ >
58
+ <animated.path
59
+ d={
60
+ config.immediate
61
+ ? (createArc(data) as unknown as string)
62
+ : (animatedProps.t.to((t) =>
63
+ createArc(interpolator(t))
64
+ ) as unknown as string)
65
+ }
66
+ fill={isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color}
67
+ />
68
+ </StyledArc>
69
+ );
70
+ });
71
+ Arc.className = CLASSNAME;
72
+ Arc.defaultProps = DEFAULT_PROPS;
73
+ Arc.displayName = COMPONENT_NAME;
@@ -0,0 +1,3 @@
1
+ export * from './Arc';
2
+ export * from './types';
3
+ export * from './styles';
@@ -0,0 +1,41 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { StyledArcProps } from './types';
3
+ import { DataPoint } from '../DataPoint';
4
+
5
+ /**
6
+ * Component style.
7
+ */
8
+ export const StyledArc = styled(DataPoint)<StyledArcProps>`
9
+ ${({ $hasStroke }) =>
10
+ $hasStroke
11
+ ? css`
12
+ path {
13
+ stroke-width: 2px;
14
+ stroke: #fff;
15
+ }
16
+ `
17
+ : ''}
18
+
19
+ ${({ $clickable }) =>
20
+ $clickable
21
+ ? css`
22
+ cursor: pointer;
23
+
24
+ &:hover,
25
+ &:focus,
26
+ &.focused {
27
+ opacity: 0.8;
28
+ outline: none;
29
+ }
30
+
31
+ &:focus-visible,
32
+ &.focused {
33
+ path {
34
+ stroke: var(--redsift-color-default-primary);
35
+ stroke-width: 4px;
36
+ paint-order: stroke;
37
+ }
38
+ }
39
+ `
40
+ : ''}}
41
+ `;
@@ -0,0 +1,18 @@
1
+ import { Arc as d3Arc } from 'd3';
2
+ import { ArcDatum } from '../../types';
3
+ import { DataPointProps, StyledDataPointProps } from '../DataPoint';
4
+
5
+ /**
6
+ * Component props.
7
+ */
8
+ export interface ArcProps extends DataPointProps<ArcDatum> {
9
+ /** Arc generator used to determine the width of the arc. */
10
+ createArc: d3Arc<any, ArcDatum>;
11
+ /** Whether the arc has a stroke or not. Used to create a gap between two siblings. */
12
+ hasStroke?: boolean;
13
+ }
14
+
15
+ export type StyledArcProps = StyledDataPointProps &
16
+ Omit<ArcProps, 'createArc'> & {
17
+ $hasStroke: ArcProps['hasStroke'];
18
+ };
@@ -0,0 +1,177 @@
1
+ import React from 'react';
2
+ // @ts-ignore
3
+ import type { StoryObj } from '@storybook/react';
4
+ import { arc as d3arc, pie as d3pie } from 'd3';
5
+
6
+ import { Arcs, ArcsProps } from '.';
7
+ import { ArcDatum, TooltipVariant, CategoryDatum } from '../../types';
8
+
9
+ const meta = {
10
+ title: 'Charts/Core/Arcs',
11
+ component: Arcs,
12
+ };
13
+
14
+ export default meta;
15
+ type Story = StoryObj<ArcsProps>;
16
+
17
+ const createArc = d3arc<ArcDatum>().innerRadius(0).outerRadius(150);
18
+
19
+ export const Simple: Story = {
20
+ render: () => {
21
+ const createPie = d3pie<CategoryDatum>()
22
+ .value((d) => d.value)
23
+ .sort(null);
24
+ const data = [
25
+ {
26
+ key: 'Croissant',
27
+ value: 333,
28
+ },
29
+ ];
30
+ const pieData = createPie(data);
31
+
32
+ return (
33
+ <svg width={500} height={500}>
34
+ <Arcs
35
+ hasLabels
36
+ transform="translate(250,250)"
37
+ arcs={[
38
+ {
39
+ id: '123',
40
+ createArc,
41
+ data: pieData[0],
42
+ },
43
+ ]}
44
+ />
45
+ </svg>
46
+ );
47
+ },
48
+ };
49
+
50
+ export const Clickable: Story = {
51
+ render: () => {
52
+ const createPie = d3pie<CategoryDatum>()
53
+ .value((d) => d.value)
54
+ .sort(null);
55
+ const data = [
56
+ {
57
+ key: 'Button',
58
+ value: 150,
59
+ },
60
+ {
61
+ key: 'Link',
62
+ value: 333,
63
+ },
64
+ ];
65
+ const pieData = createPie(data);
66
+
67
+ return (
68
+ <svg width={500} height={500}>
69
+ <Arcs
70
+ hasLabels
71
+ transform="translate(250,250)"
72
+ id="123"
73
+ hasStroke
74
+ arcs={[
75
+ {
76
+ createArc,
77
+ onClick: (datum) => console.log(datum),
78
+ data: pieData[0],
79
+ },
80
+ {
81
+ createArc,
82
+ onClick: (datum) => {
83
+ window.open(
84
+ `https://en.wikipedia.org/wiki/${datum.data.key}`,
85
+ '_blank'
86
+ );
87
+ },
88
+ data: pieData[1],
89
+ },
90
+ ]}
91
+ />
92
+ </svg>
93
+ );
94
+ },
95
+ };
96
+
97
+ export const Selectable: Story = {
98
+ render: () => {
99
+ const createPie = d3pie<CategoryDatum>()
100
+ .value((d) => d.value)
101
+ .sort(null);
102
+ const data = [
103
+ {
104
+ key: 'Deselected',
105
+ value: 150,
106
+ },
107
+ {
108
+ key: 'Selected',
109
+ value: 333,
110
+ },
111
+ ];
112
+ const pieData = createPie(data);
113
+
114
+ return (
115
+ <svg width={500} height={500}>
116
+ <Arcs
117
+ hasLabels
118
+ transform="translate(250,250)"
119
+ role="option"
120
+ arcs={[
121
+ {
122
+ createArc,
123
+ isSelected: false,
124
+ onClick: (datum) =>
125
+ console.log('Clicked on the non-selected arc', datum),
126
+ data: pieData[0],
127
+ },
128
+ {
129
+ createArc,
130
+ isSelected: true,
131
+ onClick: (datum) =>
132
+ console.log('Clicked on the selected arc', datum),
133
+ data: pieData[1],
134
+ },
135
+ ]}
136
+ />
137
+ </svg>
138
+ );
139
+ },
140
+ };
141
+
142
+ export const WithTooltip: Story = {
143
+ render: () => {
144
+ const createPie = d3pie<CategoryDatum>()
145
+ .value((d) => d.value)
146
+ .sort(null);
147
+ const data = Object.keys(TooltipVariant).map((tooltipVariant) => ({
148
+ key: tooltipVariant,
149
+ value: 333,
150
+ }));
151
+ const pieData = createPie(data);
152
+
153
+ return (
154
+ <svg width={500} height={500}>
155
+ <Arcs
156
+ hasLabels
157
+ transform="translate(250,250)"
158
+ arcs={Object.keys(TooltipVariant).map((tooltipVariant, index) => ({
159
+ createArc,
160
+ hasStroke: true,
161
+ index,
162
+ isSelected: true,
163
+ key: tooltipVariant,
164
+ labelDecorator: (datum: ArcDatum) =>
165
+ `${datum.data.key.charAt(0).toUpperCase()}${datum.data.key.slice(
166
+ 1
167
+ )}`,
168
+ percent: 0.25,
169
+ data: pieData[index],
170
+ tooltipVariant,
171
+ role: 'option',
172
+ }))}
173
+ />
174
+ </svg>
175
+ );
176
+ },
177
+ };
@@ -0,0 +1,108 @@
1
+ import React, { RefObject, forwardRef } from 'react';
2
+ import classNames from 'classnames';
3
+ import { animated, useSpring } from '@react-spring/web';
4
+ import { interpolate as d3interpolate } from 'd3';
5
+
6
+ import { Comp, useId } from '@redsift/design-system';
7
+
8
+ import { ArcsProps } from './types';
9
+ import { StyledArcs } from './styles';
10
+ import { Arc } from '../Arc';
11
+ import { config } from '../../config';
12
+
13
+ const COMPONENT_NAME = 'Arcs';
14
+ const CLASSNAME = 'redsift-arcs';
15
+ const DEFAULT_PROPS: Partial<ArcsProps> = {};
16
+
17
+ export const Arcs: Comp<ArcsProps, SVGGElement> = forwardRef((props, ref) => {
18
+ const {
19
+ arcs,
20
+ className,
21
+ color,
22
+ hasLabels,
23
+ hasStroke,
24
+ id: propsId,
25
+ labelDecorator,
26
+ onClick,
27
+ role,
28
+ sliceProps,
29
+ tooltipVariant,
30
+ ...forwardedProps
31
+ } = props;
32
+ const [_id] = useId();
33
+ const id = propsId ?? _id;
34
+
35
+ const animatedProps = useSpring({
36
+ ...config,
37
+ to: async (next: (props?: object) => Promise<void>) => {
38
+ await next({ t: 1 });
39
+ },
40
+ from: { t: 0 },
41
+ });
42
+
43
+ return (
44
+ <StyledArcs
45
+ {...forwardedProps}
46
+ className={classNames(Arcs.className, className)}
47
+ ref={ref as RefObject<SVGGElement>}
48
+ >
49
+ <g className="arc-group">
50
+ {arcs.map((arc, index) => {
51
+ const arcIndex = arc.index ?? index;
52
+ const arcId = arc.id ?? `id${id}__arc-${arcIndex}`;
53
+
54
+ return (
55
+ <Arc
56
+ {...sliceProps}
57
+ color={color}
58
+ hasStroke={hasStroke}
59
+ labelDecorator={labelDecorator}
60
+ onClick={onClick}
61
+ role={role}
62
+ tooltipVariant={tooltipVariant}
63
+ {...arc}
64
+ key={arcId}
65
+ id={arcId}
66
+ index={arcIndex}
67
+ />
68
+ );
69
+ })}
70
+ </g>
71
+ {hasLabels ? (
72
+ <g className="arc-label-group">
73
+ {arcs
74
+ .filter((arc) => {
75
+ const value = arc.data.data.value;
76
+ const percent = arc.data.data.percent;
77
+ return percent ? value > 0 && percent >= 0.1 : value > 0;
78
+ })
79
+ .map((arc, index) => {
80
+ const arcIndex = arc.index ?? index;
81
+ const arcId = arc.id ?? `id${id}__arc-${arcIndex}`;
82
+ const arcLabelDecorator = arc.labelDecorator ?? labelDecorator;
83
+ const interpolator = d3interpolate(arc.from, arc.data);
84
+
85
+ return (
86
+ <animated.text
87
+ alignmentBaseline="middle"
88
+ className={`arc-label _${index}`}
89
+ key={`${arcId}-label`}
90
+ textAnchor="middle"
91
+ transform={
92
+ config.immediate
93
+ ? `translate(${arc.createArc.centroid(arc.data)})`
94
+ : animatedProps.t.to((t) => `translate(${arc.createArc.centroid(interpolator(t))})`)
95
+ }
96
+ >
97
+ {arcLabelDecorator ? arcLabelDecorator(arc.data) : arc.data.data.key}
98
+ </animated.text>
99
+ );
100
+ })}
101
+ </g>
102
+ ) : null}
103
+ </StyledArcs>
104
+ );
105
+ });
106
+ Arcs.className = CLASSNAME;
107
+ Arcs.defaultProps = DEFAULT_PROPS;
108
+ Arcs.displayName = COMPONENT_NAME;
@@ -0,0 +1,3 @@
1
+ export * from './Arcs';
2
+ export * from './types';
3
+ export * from './styles';
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components';
2
+ import { StyledArcsProps } from './types';
3
+
4
+ /**
5
+ * Component style.
6
+ */
7
+ export const StyledArcs = styled.g<StyledArcsProps>``;
@@ -0,0 +1,26 @@
1
+ import { ComponentProps } from 'react';
2
+ import { ArcProps } from '../Arc/types';
3
+
4
+ /**
5
+ * Component props.
6
+ */
7
+ export interface ArcsProps
8
+ extends Omit<ComponentProps<'g'>, 'onClick' | 'role'>,
9
+ Pick<
10
+ ArcProps,
11
+ | 'id'
12
+ | 'labelDecorator'
13
+ | 'onClick'
14
+ | 'role'
15
+ | 'hasStroke'
16
+ | 'tooltipVariant'
17
+ > {
18
+ /** Arc props. */
19
+ arcs: Omit<ArcProps, 'ref'>[];
20
+ /** Whether arcs have internal labels or not. */
21
+ hasLabels?: boolean;
22
+ /** Native HTML props to forward to each slice. */
23
+ sliceProps?: Omit<ComponentProps<'g'>, 'onClick' | 'ref' | 'width'>;
24
+ }
25
+
26
+ export type StyledArcsProps = Omit<ArcsProps, 'arcs'> & {};