@pie-lib/graphing-solution-set 4.1.0-beta.7 → 5.0.0-next.35

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 (332) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +20 -0
  2. package/dist/autosize-input.d.ts +10 -0
  3. package/dist/autosize-input.js +66 -0
  4. package/dist/axis/arrow.d.ts +13 -0
  5. package/dist/axis/arrow.js +34 -0
  6. package/dist/axis/axes.d.ts +132 -0
  7. package/dist/axis/axes.js +214 -0
  8. package/dist/axis/index.d.ts +10 -0
  9. package/dist/bg.d.ts +51 -0
  10. package/dist/bg.js +44 -0
  11. package/dist/container/actions.d.ts +15 -0
  12. package/dist/container/actions.js +7 -0
  13. package/dist/container/index.d.ts +58 -0
  14. package/dist/container/index.js +48 -0
  15. package/dist/container/marks.d.ts +10 -0
  16. package/dist/container/marks.js +11 -0
  17. package/dist/container/middleware.d.ts +10 -0
  18. package/dist/container/middleware.js +4 -0
  19. package/dist/container/reducer.d.ts +14 -0
  20. package/dist/container/reducer.js +7 -0
  21. package/dist/coordinates-label.d.ts +50 -0
  22. package/dist/coordinates-label.js +46 -0
  23. package/dist/graph-with-controls.d.ts +85 -0
  24. package/dist/graph-with-controls.js +155 -0
  25. package/dist/graph.d.ts +119 -0
  26. package/dist/graph.js +221 -0
  27. package/dist/grid-setup.d.ts +27 -0
  28. package/dist/grid-setup.js +307 -0
  29. package/dist/grid.d.ts +43 -0
  30. package/dist/grid.js +59 -0
  31. package/dist/index.d.ts +14 -0
  32. package/dist/index.js +6 -0
  33. package/dist/labels.d.ts +73 -0
  34. package/dist/labels.js +134 -0
  35. package/dist/mark-label.d.ts +50 -0
  36. package/dist/mark-label.js +84 -0
  37. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Axis.js +67 -0
  38. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +66 -0
  39. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Ticks.js +39 -0
  40. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
  41. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
  42. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +13 -0
  43. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
  44. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
  45. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickPosition.js +14 -0
  46. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/Grid.js +43 -0
  47. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridColumns.js +46 -0
  48. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridRows.js +46 -0
  49. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
  50. package/dist/node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_modules/@visx/group/esm/Group.js +17 -0
  51. package/dist/node_modules/.bun/@visx_point@4.0.0/node_modules/@visx/point/esm/Point.js +20 -0
  52. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
  53. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/getTicks.js +7 -0
  54. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
  55. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Line.js +27 -0
  56. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/Text.js +27 -0
  57. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/hooks/useText.js +68 -0
  58. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/getStringWidth.js +19 -0
  59. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/memoize.js +13 -0
  60. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
  61. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
  62. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
  63. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  64. package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
  65. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
  66. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
  67. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
  68. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
  69. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
  70. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
  71. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
  72. package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +185 -0
  73. package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +198 -0
  74. package/dist/toggle-bar.d.ts +40 -0
  75. package/dist/tool-menu.d.ts +21 -0
  76. package/dist/tool-menu.js +188 -0
  77. package/dist/tools/index.d.ts +17 -0
  78. package/dist/tools/index.js +12 -0
  79. package/dist/tools/line/component.d.ts +113 -0
  80. package/dist/tools/line/component.js +58 -0
  81. package/dist/tools/line/index.d.ts +13 -0
  82. package/dist/tools/line/index.js +6 -0
  83. package/dist/tools/polygon/component.d.ts +117 -0
  84. package/dist/tools/polygon/component.js +194 -0
  85. package/dist/tools/polygon/index.d.ts +19 -0
  86. package/dist/tools/polygon/index.js +55 -0
  87. package/dist/tools/polygon/line.d.ts +125 -0
  88. package/dist/tools/polygon/polygon.d.ts +122 -0
  89. package/dist/tools/polygon/polygon.js +62 -0
  90. package/dist/tools/shared/arrow-head.d.ts +43 -0
  91. package/dist/tools/shared/arrow-head.js +37 -0
  92. package/dist/tools/shared/line/index.d.ts +240 -0
  93. package/dist/tools/shared/line/index.js +320 -0
  94. package/dist/tools/shared/line/line-path.d.ts +57 -0
  95. package/dist/tools/shared/line/with-root-edge.d.ts +143 -0
  96. package/dist/tools/shared/point/arrow-point.d.ts +57 -0
  97. package/dist/tools/shared/point/arrow-point.js +47 -0
  98. package/dist/tools/shared/point/arrow.d.ts +46 -0
  99. package/dist/tools/shared/point/arrow.js +36 -0
  100. package/dist/tools/shared/point/base-point.d.ts +50 -0
  101. package/dist/tools/shared/point/base-point.js +88 -0
  102. package/dist/tools/shared/point/index.d.ts +217 -0
  103. package/dist/tools/shared/point/index.js +51 -0
  104. package/dist/tools/shared/styles.d.ts +24 -0
  105. package/dist/tools/shared/styles.js +17 -0
  106. package/dist/tools/shared/types.d.ts +15 -0
  107. package/dist/tools/shared/types.js +10 -0
  108. package/dist/undo-redo.d.ts +20 -0
  109. package/dist/undo-redo.js +33 -0
  110. package/dist/use-debounce.d.ts +9 -0
  111. package/dist/use-debounce.js +13 -0
  112. package/dist/utils.d.ts +58 -0
  113. package/dist/utils.js +72 -0
  114. package/package.json +52 -42
  115. package/CHANGELOG.json +0 -1
  116. package/CHANGELOG.md +0 -449
  117. package/lib/__tests__/bg.test.js +0 -282
  118. package/lib/__tests__/bg.test.js.map +0 -1
  119. package/lib/__tests__/coordinates-label.test.js +0 -276
  120. package/lib/__tests__/coordinates-label.test.js.map +0 -1
  121. package/lib/__tests__/graph-with-controls.test.js +0 -256
  122. package/lib/__tests__/graph-with-controls.test.js.map +0 -1
  123. package/lib/__tests__/graph.test.js +0 -113
  124. package/lib/__tests__/graph.test.js.map +0 -1
  125. package/lib/__tests__/grid-setup.test.js +0 -729
  126. package/lib/__tests__/grid-setup.test.js.map +0 -1
  127. package/lib/__tests__/grid.test.js +0 -29
  128. package/lib/__tests__/grid.test.js.map +0 -1
  129. package/lib/__tests__/labels.test.js +0 -45
  130. package/lib/__tests__/labels.test.js.map +0 -1
  131. package/lib/__tests__/mark-label.test.js +0 -133
  132. package/lib/__tests__/mark-label.test.js.map +0 -1
  133. package/lib/__tests__/toggle-bar.test.js +0 -146
  134. package/lib/__tests__/toggle-bar.test.js.map +0 -1
  135. package/lib/__tests__/tool-menu.test.js +0 -540
  136. package/lib/__tests__/tool-menu.test.js.map +0 -1
  137. package/lib/__tests__/undo-redo.test.js +0 -31
  138. package/lib/__tests__/undo-redo.test.js.map +0 -1
  139. package/lib/__tests__/use-debounce.test.js +0 -24
  140. package/lib/__tests__/use-debounce.test.js.map +0 -1
  141. package/lib/__tests__/utils.js +0 -70
  142. package/lib/__tests__/utils.js.map +0 -1
  143. package/lib/__tests__/utils.test.js +0 -123
  144. package/lib/__tests__/utils.test.js.map +0 -1
  145. package/lib/axis/__tests__/arrow.test.js +0 -60
  146. package/lib/axis/__tests__/arrow.test.js.map +0 -1
  147. package/lib/axis/__tests__/axes.test.js +0 -160
  148. package/lib/axis/__tests__/axes.test.js.map +0 -1
  149. package/lib/axis/arrow.js +0 -79
  150. package/lib/axis/arrow.js.map +0 -1
  151. package/lib/axis/axes.js +0 -327
  152. package/lib/axis/axes.js.map +0 -1
  153. package/lib/axis/index.js +0 -21
  154. package/lib/axis/index.js.map +0 -1
  155. package/lib/bg.js +0 -114
  156. package/lib/bg.js.map +0 -1
  157. package/lib/container/__tests__/actions.test.js +0 -108
  158. package/lib/container/__tests__/actions.test.js.map +0 -1
  159. package/lib/container/__tests__/index.test.js +0 -346
  160. package/lib/container/__tests__/index.test.js.map +0 -1
  161. package/lib/container/__tests__/marks.test.js +0 -259
  162. package/lib/container/__tests__/marks.test.js.map +0 -1
  163. package/lib/container/__tests__/middleware.test.js +0 -244
  164. package/lib/container/__tests__/middleware.test.js.map +0 -1
  165. package/lib/container/__tests__/reducer.test.js +0 -450
  166. package/lib/container/__tests__/reducer.test.js.map +0 -1
  167. package/lib/container/actions.js +0 -18
  168. package/lib/container/actions.js.map +0 -1
  169. package/lib/container/index.js +0 -129
  170. package/lib/container/index.js.map +0 -1
  171. package/lib/container/marks.js +0 -22
  172. package/lib/container/marks.js.map +0 -1
  173. package/lib/container/middleware.js +0 -19
  174. package/lib/container/middleware.js.map +0 -1
  175. package/lib/container/reducer.js +0 -18
  176. package/lib/container/reducer.js.map +0 -1
  177. package/lib/coordinates-label.js +0 -77
  178. package/lib/coordinates-label.js.map +0 -1
  179. package/lib/graph-with-controls.js +0 -297
  180. package/lib/graph-with-controls.js.map +0 -1
  181. package/lib/graph.js +0 -353
  182. package/lib/graph.js.map +0 -1
  183. package/lib/grid-setup.js +0 -414
  184. package/lib/grid-setup.js.map +0 -1
  185. package/lib/grid.js +0 -131
  186. package/lib/grid.js.map +0 -1
  187. package/lib/index.js +0 -40
  188. package/lib/index.js.map +0 -1
  189. package/lib/labels.js +0 -199
  190. package/lib/labels.js.map +0 -1
  191. package/lib/mark-label.js +0 -159
  192. package/lib/mark-label.js.map +0 -1
  193. package/lib/toggle-bar.js +0 -248
  194. package/lib/toggle-bar.js.map +0 -1
  195. package/lib/tool-menu.js +0 -218
  196. package/lib/tool-menu.js.map +0 -1
  197. package/lib/tools/index.js +0 -24
  198. package/lib/tools/index.js.map +0 -1
  199. package/lib/tools/line/__tests__/component.test.js +0 -45
  200. package/lib/tools/line/__tests__/component.test.js.map +0 -1
  201. package/lib/tools/line/component.js +0 -92
  202. package/lib/tools/line/component.js.map +0 -1
  203. package/lib/tools/line/index.js +0 -11
  204. package/lib/tools/line/index.js.map +0 -1
  205. package/lib/tools/polygon/__tests__/component.test.js +0 -501
  206. package/lib/tools/polygon/__tests__/component.test.js.map +0 -1
  207. package/lib/tools/polygon/__tests__/index.test.js +0 -92
  208. package/lib/tools/polygon/__tests__/index.test.js.map +0 -1
  209. package/lib/tools/polygon/__tests__/line.test.js +0 -30
  210. package/lib/tools/polygon/__tests__/line.test.js.map +0 -1
  211. package/lib/tools/polygon/__tests__/polygon.test.js +0 -61
  212. package/lib/tools/polygon/__tests__/polygon.test.js.map +0 -1
  213. package/lib/tools/polygon/component.js +0 -358
  214. package/lib/tools/polygon/component.js.map +0 -1
  215. package/lib/tools/polygon/index.js +0 -89
  216. package/lib/tools/polygon/index.js.map +0 -1
  217. package/lib/tools/polygon/line.js +0 -114
  218. package/lib/tools/polygon/line.js.map +0 -1
  219. package/lib/tools/polygon/polygon.js +0 -128
  220. package/lib/tools/polygon/polygon.js.map +0 -1
  221. package/lib/tools/shared/__tests__/arrow-head.test.js +0 -45
  222. package/lib/tools/shared/__tests__/arrow-head.test.js.map +0 -1
  223. package/lib/tools/shared/arrow-head.js +0 -62
  224. package/lib/tools/shared/arrow-head.js.map +0 -1
  225. package/lib/tools/shared/line/__tests__/index.test.js +0 -725
  226. package/lib/tools/shared/line/__tests__/index.test.js.map +0 -1
  227. package/lib/tools/shared/line/__tests__/line-path.test.js +0 -64
  228. package/lib/tools/shared/line/__tests__/line-path.test.js.map +0 -1
  229. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +0 -618
  230. package/lib/tools/shared/line/__tests__/with-root-edge.test.js.map +0 -1
  231. package/lib/tools/shared/line/index.js +0 -539
  232. package/lib/tools/shared/line/index.js.map +0 -1
  233. package/lib/tools/shared/line/line-path.js +0 -121
  234. package/lib/tools/shared/line/line-path.js.map +0 -1
  235. package/lib/tools/shared/line/with-root-edge.js +0 -121
  236. package/lib/tools/shared/line/with-root-edge.js.map +0 -1
  237. package/lib/tools/shared/point/__tests__/arrow-point.test.js +0 -127
  238. package/lib/tools/shared/point/__tests__/arrow-point.test.js.map +0 -1
  239. package/lib/tools/shared/point/__tests__/arrow.test.js +0 -619
  240. package/lib/tools/shared/point/__tests__/arrow.test.js.map +0 -1
  241. package/lib/tools/shared/point/__tests__/base-point.test.js +0 -122
  242. package/lib/tools/shared/point/__tests__/base-point.test.js.map +0 -1
  243. package/lib/tools/shared/point/arrow-point.js +0 -86
  244. package/lib/tools/shared/point/arrow-point.js.map +0 -1
  245. package/lib/tools/shared/point/arrow.js +0 -70
  246. package/lib/tools/shared/point/arrow.js.map +0 -1
  247. package/lib/tools/shared/point/base-point.js +0 -137
  248. package/lib/tools/shared/point/base-point.js.map +0 -1
  249. package/lib/tools/shared/point/index.js +0 -80
  250. package/lib/tools/shared/point/index.js.map +0 -1
  251. package/lib/tools/shared/styles.js +0 -26
  252. package/lib/tools/shared/styles.js.map +0 -1
  253. package/lib/tools/shared/types.js +0 -15
  254. package/lib/tools/shared/types.js.map +0 -1
  255. package/lib/undo-redo.js +0 -67
  256. package/lib/undo-redo.js.map +0 -1
  257. package/lib/use-debounce.js +0 -25
  258. package/lib/use-debounce.js.map +0 -1
  259. package/lib/utils.js +0 -235
  260. package/lib/utils.js.map +0 -1
  261. package/src/__tests__/bg.test.jsx +0 -250
  262. package/src/__tests__/coordinates-label.test.jsx +0 -243
  263. package/src/__tests__/graph-with-controls.test.jsx +0 -184
  264. package/src/__tests__/graph.test.jsx +0 -93
  265. package/src/__tests__/grid-setup.test.jsx +0 -645
  266. package/src/__tests__/grid.test.jsx +0 -23
  267. package/src/__tests__/labels.test.jsx +0 -41
  268. package/src/__tests__/mark-label.test.jsx +0 -66
  269. package/src/__tests__/toggle-bar.test.jsx +0 -106
  270. package/src/__tests__/tool-menu.test.jsx +0 -453
  271. package/src/__tests__/undo-redo.test.jsx +0 -26
  272. package/src/__tests__/use-debounce.test.js +0 -21
  273. package/src/__tests__/utils.js +0 -41
  274. package/src/__tests__/utils.test.js +0 -105
  275. package/src/axis/__tests__/arrow.test.jsx +0 -43
  276. package/src/axis/__tests__/axes.test.jsx +0 -182
  277. package/src/axis/arrow.jsx +0 -57
  278. package/src/axis/axes.jsx +0 -284
  279. package/src/axis/index.js +0 -3
  280. package/src/bg.jsx +0 -96
  281. package/src/container/__tests__/actions.test.js +0 -105
  282. package/src/container/__tests__/index.test.jsx +0 -227
  283. package/src/container/__tests__/marks.test.js +0 -172
  284. package/src/container/__tests__/middleware.test.js +0 -235
  285. package/src/container/__tests__/reducer.test.js +0 -324
  286. package/src/container/actions.js +0 -8
  287. package/src/container/index.jsx +0 -93
  288. package/src/container/marks.js +0 -14
  289. package/src/container/middleware.js +0 -7
  290. package/src/container/reducer.js +0 -5
  291. package/src/coordinates-label.jsx +0 -62
  292. package/src/graph-with-controls.jsx +0 -242
  293. package/src/graph.jsx +0 -333
  294. package/src/grid-setup.jsx +0 -432
  295. package/src/grid.jsx +0 -133
  296. package/src/index.js +0 -7
  297. package/src/labels.jsx +0 -173
  298. package/src/mark-label.jsx +0 -125
  299. package/src/toggle-bar.jsx +0 -221
  300. package/src/tool-menu.jsx +0 -235
  301. package/src/tools/index.js +0 -8
  302. package/src/tools/line/__tests__/component.test.jsx +0 -37
  303. package/src/tools/line/component.jsx +0 -77
  304. package/src/tools/line/index.js +0 -4
  305. package/src/tools/polygon/__tests__/component.test.jsx +0 -487
  306. package/src/tools/polygon/__tests__/index.test.js +0 -65
  307. package/src/tools/polygon/__tests__/line.test.jsx +0 -23
  308. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -44
  309. package/src/tools/polygon/component.jsx +0 -324
  310. package/src/tools/polygon/index.js +0 -52
  311. package/src/tools/polygon/line.jsx +0 -80
  312. package/src/tools/polygon/polygon.jsx +0 -93
  313. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -33
  314. package/src/tools/shared/arrow-head.jsx +0 -46
  315. package/src/tools/shared/line/__tests__/index.test.jsx +0 -553
  316. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -56
  317. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -488
  318. package/src/tools/shared/line/index.jsx +0 -471
  319. package/src/tools/shared/line/line-path.jsx +0 -85
  320. package/src/tools/shared/line/with-root-edge.jsx +0 -97
  321. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  322. package/src/tools/shared/point/__tests__/arrow.test.jsx +0 -469
  323. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
  324. package/src/tools/shared/point/arrow-point.jsx +0 -60
  325. package/src/tools/shared/point/arrow.jsx +0 -40
  326. package/src/tools/shared/point/base-point.jsx +0 -113
  327. package/src/tools/shared/point/index.jsx +0 -58
  328. package/src/tools/shared/styles.js +0 -20
  329. package/src/tools/shared/types.js +0 -8
  330. package/src/undo-redo.jsx +0 -37
  331. package/src/use-debounce.js +0 -13
  332. package/src/utils.js +0 -230
@@ -1,41 +0,0 @@
1
- export const scaleMock = () => {
2
- const fn = jest.fn((n) => n);
3
- fn.invert = jest.fn((n) => n);
4
- fn.domain = jest.fn(() => fn);
5
- fn.range = jest.fn(() => fn);
6
- fn.copy = jest.fn(() => scaleMock());
7
- return fn;
8
- };
9
-
10
- export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
11
- scale: {
12
- x: scaleMock(),
13
- y: scaleMock(),
14
- },
15
- snap: {
16
- x: jest.fn((n) => n),
17
- y: jest.fn((n) => n),
18
- },
19
- domain: {
20
- min: dmin,
21
- max: dmax,
22
- step: 1,
23
- },
24
- range: {
25
- min: rmin,
26
- max: rmax,
27
- step: 1,
28
- },
29
- size: {
30
- width: 400,
31
- height: 400,
32
- },
33
- });
34
-
35
- export const xy = (x, y, index) => {
36
- const out = { x, y, index };
37
- if (!Number.isFinite(index)) {
38
- delete out.index;
39
- }
40
- return out;
41
- };
@@ -1,105 +0,0 @@
1
- import * as utils from '../utils';
2
-
3
- const xy = (x, y) => ({ x, y });
4
-
5
- const tick = (isMajor, v) => ({
6
- major: isMajor,
7
- value: v,
8
- x: v,
9
- });
10
-
11
- const major = tick.bind(null, true);
12
- const minor = tick.bind(null, false);
13
-
14
- describe('utils', () => {
15
- describe('polygonToArea', () => {
16
- const assertPolygon = (points, area) => {
17
- it(`converts ${points} -> ${area}`, () => {
18
- const result = utils.polygonToArea(points);
19
- expect(result).toEqual(area);
20
- });
21
- };
22
- assertPolygon([xy(0, 0), xy(1, 1), xy(1, -1)], {
23
- left: 0,
24
- top: 1,
25
- bottom: -1,
26
- right: 1,
27
- });
28
- assertPolygon([xy(0, 0), xy(3, 0), xy(2, -1), xy(4, -3), xy(1, -4), xy(2, -2)], {
29
- left: 0,
30
- top: 0,
31
- bottom: -4,
32
- right: 4,
33
- });
34
- });
35
-
36
- describe('lineToArea', () => {
37
- const assertLine = (from, to, expected) => {
38
- it(`${from},${to} => ${expected}`, () => {
39
- const result = utils.lineToArea(from, to);
40
- expect(result).toEqual(expected);
41
- });
42
- };
43
-
44
- assertLine(xy(1, 1), xy(2, 2), { left: 1, top: 2, bottom: 1, right: 2 });
45
- assertLine(xy(-1, 4), xy(4, -3), {
46
- left: -1,
47
- top: 4,
48
- bottom: -3,
49
- right: 4,
50
- });
51
- });
52
-
53
- describe('getTickValues', () => {
54
- const assertGetTickValues = (props, expected) => {
55
- it(` => ${expected}`, () => {
56
- const result = utils.getTickValues(props);
57
- expect(result).toEqual(expected);
58
- });
59
- };
60
-
61
- assertGetTickValues({ min: 0, max: 10, step: 1 }, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
62
- assertGetTickValues({ min: 0, max: 3, step: 0.5 }, [0, 0.5, 1, 1.5, 2, 2.5, 3]);
63
- assertGetTickValues({ min: -0.2, max: 2, step: 0.6 }, [0, 0.6, 1.2, 1.8]);
64
- assertGetTickValues({ min: -3.4, max: 6.2, step: 1.2 }, [0, -1.2, -2.4, 1.2, 2.4, 3.6, 4.8, 6]);
65
-
66
- assertGetTickValues(
67
- { min: 0.6, max: 4.8, step: 0.3 },
68
- [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.2, 4.5, 4.8],
69
- );
70
- assertGetTickValues(
71
- { min: 0.5, max: 4.9, step: 0.3 },
72
- [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.2, 4.5, 4.8],
73
- );
74
- assertGetTickValues(
75
- { min: 0, max: 3, step: 0.125 },
76
- [
77
- 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2, 2.125, 2.25,
78
- 2.375, 2.5, 2.625, 2.75, 2.875, 3,
79
- ],
80
- );
81
- });
82
-
83
- describe('countWords', () => {
84
- it('should return 1 if label is undefined', () => {
85
- const label = undefined;
86
- const result = utils.countWords(label);
87
-
88
- expect(result).toEqual(1);
89
- });
90
-
91
- it('should return 1 if label is null', () => {
92
- const label = null;
93
- const result = utils.countWords(label);
94
-
95
- expect(result).toEqual(1);
96
- });
97
-
98
- it('should return 3 if label has 3 words', () => {
99
- const label = 'Number of months';
100
- const result = utils.countWords(label);
101
-
102
- expect(result).toEqual(3);
103
- });
104
- });
105
- });
@@ -1,43 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { Arrow } from '../arrow';
4
-
5
- describe('Arrow', () => {
6
- let onChange = jest.fn();
7
-
8
- const renderComponent = (extras) => {
9
- const defaults = {
10
- classes: {},
11
- className: 'className',
12
- onChange,
13
- scale: {
14
- x: jest.fn((n) => n),
15
- y: jest.fn((n) => n),
16
- },
17
- };
18
- const props = { ...defaults, ...extras };
19
- return render(<Arrow {...props} />);
20
- };
21
-
22
- describe('rendering', () => {
23
- it('renders with direction up', () => {
24
- const { container } = renderComponent({ direction: 'up' });
25
- expect(container.firstChild).toBeInTheDocument();
26
- });
27
-
28
- it('renders with direction down', () => {
29
- const { container } = renderComponent({ direction: 'down' });
30
- expect(container.firstChild).toBeInTheDocument();
31
- });
32
-
33
- it('renders with direction left', () => {
34
- const { container } = renderComponent({ direction: 'left' });
35
- expect(container.firstChild).toBeInTheDocument();
36
- });
37
-
38
- it('renders with direction right', () => {
39
- const { container } = renderComponent({ direction: 'right' });
40
- expect(container.firstChild).toBeInTheDocument();
41
- });
42
- });
43
- });
@@ -1,182 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { graphProps } from '../../__tests__/utils';
4
-
5
- import { firstNegativeValue, RawXAxis, RawYAxis, sharedValues } from '../axes';
6
-
7
- describe('RawXAxis', () => {
8
- let onChange = jest.fn();
9
-
10
- const renderComponent = (extras) => {
11
- const defaults = {
12
- classes: {},
13
- className: 'className',
14
- onChange,
15
- graphProps: graphProps(),
16
- includeArrows: {
17
- left: true,
18
- right: true,
19
- up: true,
20
- down: true,
21
- },
22
- columnTicksValues: [-1, 0, 1],
23
- skipValues: [],
24
- distanceFromOriginToFirstNegativeY: 0,
25
- dy: 0,
26
- };
27
- const props = { ...defaults, ...extras };
28
- return render(<RawXAxis {...props} />);
29
- };
30
-
31
- describe('rendering', () => {
32
- it('renders without crashing', () => {
33
- const { container } = renderComponent();
34
- expect(container.firstChild).toBeInTheDocument();
35
- });
36
- });
37
- });
38
-
39
- describe('RawYAxis', () => {
40
- let onChange = jest.fn();
41
-
42
- const renderComponent = (extras) => {
43
- const defaults = {
44
- classes: {},
45
- className: 'className',
46
- onChange,
47
- graphProps: graphProps(),
48
- includeArrows: {
49
- left: true,
50
- right: true,
51
- up: true,
52
- down: true,
53
- },
54
- rowTickValues: [-1, 0, 1],
55
- skipValues: [],
56
- };
57
- const props = { ...defaults, ...extras };
58
- return render(<RawYAxis {...props} />);
59
- };
60
-
61
- describe('rendering', () => {
62
- it('renders without crashing', () => {
63
- const { container } = renderComponent();
64
- expect(container.firstChild).toBeInTheDocument();
65
- });
66
- });
67
- });
68
-
69
- const customScaleMock = (distance) => {
70
- const fn = jest.fn((n) => n * distance);
71
- fn.invert = jest.fn((n) => n * distance);
72
- fn.domain = jest.fn(() => fn);
73
- fn.range = jest.fn(() => fn);
74
- fn.copy = jest.fn(() => customScaleMock(distance));
75
- return fn;
76
- };
77
-
78
- // Note: Instance method tests (xValues, yValues) have been removed.
79
- // These methods are internal implementation details and should be tested through
80
- // component rendering and integration tests that verify the axes render correctly.
81
-
82
- describe('firstNegativeValue', () => {
83
- it('should return undefined for undefined interval', () => {
84
- const interval = undefined;
85
- const result = firstNegativeValue(interval);
86
- expect(result).toEqual(undefined);
87
- });
88
-
89
- it('should return undefined for empty interval', () => {
90
- const interval = [];
91
- const result = firstNegativeValue(interval);
92
- expect(result).toEqual(undefined);
93
- });
94
-
95
- it('should return undefined if there is no negative in interval array', () => {
96
- const interval = [1, 5, 7, 4, 5];
97
- const result = firstNegativeValue(interval);
98
- expect(result).toEqual(undefined);
99
- });
100
-
101
- it('should return first negative number from interval', () => {
102
- const interval = [1, 5, 7, -2, 4, 5, -1];
103
- const result = firstNegativeValue(interval);
104
- expect(result).toEqual(-2);
105
- });
106
- });
107
-
108
- describe('sharedValues', () => {
109
- it('should be empty array if firstNegativeValue for one of the axes is undefined', () => {
110
- // x
111
- const intervalX = [1, 2, 3, 4, 5, 6];
112
- const firstNegativeX = firstNegativeValue(intervalX);
113
- const distanceFromOriginToFirstNegativeX = -22;
114
-
115
- // y
116
- const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
117
- const firstNegativeY = firstNegativeValue(intervalY);
118
- const distanceFromOriginToFirstNegativeY = -22;
119
-
120
- const deltaAllowance = 5;
121
-
122
- const result = sharedValues(
123
- firstNegativeX,
124
- firstNegativeY,
125
- distanceFromOriginToFirstNegativeX,
126
- distanceFromOriginToFirstNegativeY,
127
- deltaAllowance,
128
- );
129
-
130
- expect(result).toEqual([]);
131
- });
132
-
133
- it('should be empty array if firstNegativeX and firstNegativeY are equal but they do not overlap', () => {
134
- // x
135
- const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
136
- const firstNegativeX = firstNegativeValue(intervalX);
137
- const distanceFromOriginToFirstNegativeX = -7;
138
-
139
- // y
140
- const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
141
- const firstNegativeY = firstNegativeValue(intervalY);
142
- const distanceFromOriginToFirstNegativeY = -22;
143
-
144
- const deltaAllowance = 5;
145
-
146
- const result = sharedValues(
147
- firstNegativeX,
148
- firstNegativeY,
149
- distanceFromOriginToFirstNegativeX,
150
- distanceFromOriginToFirstNegativeY,
151
- deltaAllowance,
152
- );
153
-
154
- expect(result).toEqual([]);
155
- });
156
-
157
- it('should be -1 if firstNegativeX and firstNegativeY are equal and they overlap', () => {
158
- // x
159
- const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
160
- const firstNegativeX = firstNegativeValue(intervalX);
161
- const distanceFromOriginToFirstNegativeX = -20;
162
-
163
- // y
164
- const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
165
- const firstNegativeY = firstNegativeValue(intervalY);
166
- const distanceFromOriginToFirstNegativeY = -22;
167
-
168
- const deltaAllowance = 5;
169
- const dy = -20; // dy needs to be within the range for the condition to pass
170
-
171
- const result = sharedValues(
172
- firstNegativeX,
173
- firstNegativeY,
174
- distanceFromOriginToFirstNegativeX,
175
- distanceFromOriginToFirstNegativeY,
176
- deltaAllowance,
177
- dy,
178
- );
179
-
180
- expect(result).toEqual([-1]);
181
- });
182
- });
@@ -1,57 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import { styled } from '@mui/material/styles';
5
- import { types } from '@pie-lib/plot';
6
-
7
- const StyledPath = styled('path')(({ theme }) => ({
8
- fill: `var(--arrow-color, ${theme.palette.common.black})`,
9
- }));
10
-
11
- export class Arrow extends React.Component {
12
- render() {
13
- const { x, y, className, scale } = this.props;
14
- let direction = this.props.direction || 'left';
15
-
16
- const xv = scale.x(x);
17
- const yv = scale.y(y);
18
-
19
- let transform = '';
20
-
21
- const getTransform = (x, y, rotate) => `translate(${x}, ${y}) rotate(${rotate})`;
22
-
23
- if (direction === 'left') {
24
- transform = getTransform(xv - 15, yv, 0);
25
- }
26
-
27
- if (direction === 'right') {
28
- transform = getTransform(xv + 15, yv, 180);
29
- }
30
-
31
- if (direction === 'up') {
32
- transform = getTransform(xv, yv - 15, 90);
33
- }
34
-
35
- if (direction === 'down') {
36
- transform = getTransform(xv, yv + 15, 270);
37
- }
38
-
39
- return <StyledPath d="m 0,0 8,-5 0,10 -8,-5" transform={transform} className={className} />;
40
- }
41
- }
42
-
43
- Arrow.propTypes = {
44
- y: PropTypes.number,
45
- x: PropTypes.number,
46
- direction: PropTypes.oneOf(['left', 'right', 'up', 'down']),
47
- className: PropTypes.string,
48
- scale: types.ScaleType.isRequired,
49
- };
50
-
51
- Arrow.defaultProps = {
52
- y: 0,
53
- x: 0,
54
- direction: 'left',
55
- };
56
-
57
- export default Arrow;
package/src/axis/axes.jsx DELETED
@@ -1,284 +0,0 @@
1
- import React from 'react';
2
- import { Axis } from '@visx/axis';
3
- import { types } from '@pie-lib/plot';
4
- import PropTypes from 'prop-types';
5
- import Arrow from './arrow';
6
- import { styled } from '@mui/material/styles';
7
- import { amountToIncreaseWidth, countWords, findLongestWord, getTickValues } from '../utils';
8
- import { color, Readable } from '@pie-lib/render-ui';
9
-
10
- export const AxisPropTypes = {
11
- includeArrows: PropTypes.object,
12
- graphProps: PropTypes.object,
13
- };
14
-
15
- const AxisDefaultProps = {
16
- includeArrows: {
17
- left: true,
18
- right: true,
19
- up: true,
20
- down: true,
21
- },
22
- };
23
-
24
- const StyledAxesGroup = styled('g')(() => ({
25
- '& .visx-axis-line': {
26
- stroke: '#8a92c0',
27
- strokeWidth: 4,
28
- },
29
- '& .visx-axis-tick': {
30
- fill: color.defaults.BLACK,
31
- '& > line': {
32
- stroke: '#8a92c0',
33
- },
34
- },
35
- }));
36
-
37
- const AxisLabelHolder = styled('div')(({ theme, centered }) => ({
38
- padding: 0,
39
- margin: 0,
40
- '* > *': {
41
- margin: 0,
42
- padding: 0,
43
- },
44
- '& p': {
45
- margin: 0,
46
- },
47
- fontSize: theme.typography.fontSize,
48
- ...(centered && { textAlign: 'center' }),
49
- }));
50
-
51
- const StyledArrow = styled(Arrow)({
52
- fill: '#8a92c0',
53
- });
54
-
55
- const tickLabelStyles = {
56
- fontFamily: 'Roboto',
57
- fontSize: '14px',
58
- cursor: 'inherit',
59
- };
60
-
61
- export const sharedValues = (
62
- firstNegativeX,
63
- firstNegativeY,
64
- distanceFromOriginToFirstNegativeX,
65
- distanceFromOriginToFirstNegativeY,
66
- deltaAllowance,
67
- dy,
68
- ) => {
69
- let result = [];
70
-
71
- if (
72
- firstNegativeX === firstNegativeY &&
73
- distanceFromOriginToFirstNegativeX - deltaAllowance < distanceFromOriginToFirstNegativeY &&
74
- distanceFromOriginToFirstNegativeY < distanceFromOriginToFirstNegativeX + deltaAllowance &&
75
- distanceFromOriginToFirstNegativeX - deltaAllowance < dy &&
76
- dy < distanceFromOriginToFirstNegativeX + deltaAllowance
77
- ) {
78
- result.push(firstNegativeX);
79
- }
80
-
81
- return result;
82
- };
83
-
84
- export const firstNegativeValue = (interval) => (interval || []).find((element) => element < 0);
85
-
86
- export class RawXAxis extends React.Component {
87
- static propTypes = {
88
- ...AxisPropTypes,
89
- graphProps: types.GraphPropsType.isRequired,
90
- };
91
- static defaultProps = AxisDefaultProps;
92
-
93
- render() {
94
- const { includeArrows, graphProps, columnTicksValues, skipValues, distanceFromOriginToFirstNegativeY, dy } =
95
- this.props;
96
- const { scale, domain, size, range } = graphProps || {};
97
-
98
- const labelProps = (label) => {
99
- const y = skipValues && skipValues[0] === label ? distanceFromOriginToFirstNegativeY + 4 : dy;
100
-
101
- return {
102
- ...tickLabelStyles,
103
- textAnchor: 'middle',
104
- y: y,
105
- dx: label === 0 ? -10 : 0,
106
- dy: label === 0 ? -7 : 0,
107
- };
108
- };
109
-
110
- const necessaryRows = countWords(domain.axisLabel);
111
- const longestWord = findLongestWord(domain.axisLabel);
112
- const necessaryWidth = amountToIncreaseWidth(longestWord) + 2;
113
-
114
- return (
115
- <StyledAxesGroup>
116
- <Axis
117
- scale={scale.x}
118
- top={scale.y(0)}
119
- left={0}
120
- label={domain.label}
121
- rangePadding={8}
122
- tickFormat={(value) => value}
123
- tickLabelProps={labelProps}
124
- tickValues={columnTicksValues}
125
- hideZero={!(domain.labelStep || range.labelStep) && domain.min <= 0}
126
- />
127
- {includeArrows && includeArrows.left && <StyledArrow direction="left" x={domain.min} y={0} scale={scale} />}
128
- {includeArrows && includeArrows.right && <StyledArrow direction="right" x={domain.max} y={0} scale={scale} />}
129
- {domain.axisLabel && (
130
- <foreignObject x={size.width + 17} y={scale.y(0) - 9} width={necessaryWidth} height={20 * necessaryRows}>
131
- <Readable false>
132
- <AxisLabelHolder dangerouslySetInnerHTML={{ __html: domain.axisLabel }} />
133
- </Readable>
134
- </foreignObject>
135
- )}
136
- </StyledAxesGroup>
137
- );
138
- }
139
- }
140
-
141
- const XAxis = RawXAxis;
142
-
143
- export class RawYAxis extends React.Component {
144
- static propTypes = {
145
- ...AxisPropTypes,
146
- graphProps: types.GraphPropsType.isRequired,
147
- };
148
- static defaultProps = AxisDefaultProps;
149
-
150
- render() {
151
- const { includeArrows, graphProps, skipValues, rowTickValues } = this.props;
152
- const { scale, range, size } = graphProps || {};
153
-
154
- const necessaryWidth = range.axisLabel ? amountToIncreaseWidth(range.axisLabel.length) : 0;
155
-
156
- const customTickFormat = (value) => (skipValues && skipValues.indexOf(value) >= 0 ? '' : value);
157
-
158
- return (
159
- <StyledAxesGroup>
160
- <Axis
161
- orientation={'left'}
162
- scale={scale.y}
163
- top={0}
164
- height={size.height}
165
- left={scale.x(0)}
166
- label={range.label}
167
- labelProps={{ 'data-pie-readable': false }}
168
- rangePadding={8}
169
- tickLength={10}
170
- tickFormat={customTickFormat}
171
- tickLabelProps={(value) => {
172
- let digits = value.toLocaleString().replace(/[.-]/g, '').length || 1;
173
-
174
- return {
175
- ...tickLabelStyles,
176
- dy: 4,
177
- dx: -10 - digits * 9,
178
- 'data-pie-readable': false,
179
- };
180
- }}
181
- hideZero={true}
182
- tickTextAnchor={'bottom'}
183
- tickValues={rowTickValues}
184
- />
185
- {includeArrows && includeArrows.down && <StyledArrow direction="down" x={0} y={range.min} scale={scale} />}
186
- {includeArrows && includeArrows.up && <StyledArrow direction="up" x={0} y={range.max} scale={scale} />}
187
- {range.axisLabel && (
188
- <foreignObject x={scale.x(0) - necessaryWidth / 2} y={-33} width={necessaryWidth} height="20">
189
- <Readable false>
190
- <AxisLabelHolder centered dangerouslySetInnerHTML={{ __html: range.axisLabel }} />
191
- </Readable>
192
- </foreignObject>
193
- )}
194
- </StyledAxesGroup>
195
- );
196
- }
197
- }
198
-
199
- const YAxis = RawYAxis;
200
-
201
- export default class Axes extends React.Component {
202
- static propTypes = {
203
- ...AxisPropTypes,
204
- graphProps: types.GraphPropsType.isRequired,
205
- };
206
- static defaultProps = AxisDefaultProps;
207
-
208
- xValues = () => {
209
- const { graphProps } = this.props;
210
- const { scale, domain } = graphProps || {};
211
-
212
- if (!domain || !scale) {
213
- return;
214
- }
215
-
216
- const ticks = getTickValues({ ...domain, step: domain.labelStep });
217
- const negative = firstNegativeValue(ticks);
218
-
219
- return {
220
- columnTicksValues: ticks,
221
- firstNegativeX: negative,
222
- distanceFromOriginToFirstNegativeX: Math.abs(scale.y(0) - scale.y(negative)),
223
- };
224
- };
225
-
226
- yValues = () => {
227
- const { graphProps } = this.props;
228
- const { scale, range } = graphProps || {};
229
-
230
- if (!range || !scale) {
231
- return;
232
- }
233
-
234
- const ticks = getTickValues({ ...range, step: range.labelStep });
235
- const negative = firstNegativeValue(ticks);
236
-
237
- return {
238
- rowTickValues: ticks,
239
- firstNegativeY: negative,
240
- distanceFromOriginToFirstNegativeY: Math.abs(scale.x(0) - scale.x(negative)),
241
- };
242
- };
243
-
244
- render() {
245
- const { graphProps } = this.props;
246
- const { domain, range } = graphProps || {};
247
- const { columnTicksValues, firstNegativeX, distanceFromOriginToFirstNegativeX } = this.xValues();
248
- const { rowTickValues, firstNegativeY, distanceFromOriginToFirstNegativeY } = this.yValues();
249
- const deltaAllowance = 6;
250
- const dy = 25;
251
-
252
- const skipValues = sharedValues(
253
- firstNegativeX,
254
- firstNegativeY,
255
- distanceFromOriginToFirstNegativeX,
256
- distanceFromOriginToFirstNegativeY,
257
- deltaAllowance,
258
- dy,
259
- );
260
-
261
- // each axis has to be displayed only if the domain & range include it
262
- return (
263
- <StyledAxesGroup>
264
- {range.min <= 0 ? (
265
- <XAxis
266
- {...this.props}
267
- skipValues={skipValues}
268
- columnTicksValues={columnTicksValues}
269
- distanceFromOriginToFirstNegativeY={distanceFromOriginToFirstNegativeY}
270
- dy={dy}
271
- />
272
- ) : null}
273
- {domain.min <= 0 ? (
274
- <YAxis
275
- {...this.props}
276
- skipValues={skipValues}
277
- rowTickValues={rowTickValues}
278
- distanceFromOriginToFirstNegativeX={distanceFromOriginToFirstNegativeX}
279
- />
280
- ) : null}
281
- </StyledAxesGroup>
282
- );
283
- }
284
- }