@pie-lib/charting 7.1.0-beta.7 → 8.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 (293) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +20 -0
  2. package/dist/actions-button.d.ts +26 -0
  3. package/dist/actions-button.js +84 -0
  4. package/dist/autosize-input.d.ts +10 -0
  5. package/dist/autosize-input.js +66 -0
  6. package/dist/axes.d.ts +84 -0
  7. package/dist/axes.js +376 -0
  8. package/dist/bars/bar.d.ts +47 -0
  9. package/dist/bars/bar.js +27 -0
  10. package/dist/bars/common/bars.d.ts +98 -0
  11. package/dist/bars/common/bars.js +174 -0
  12. package/dist/bars/common/correct-check-icon.d.ts +18 -0
  13. package/dist/bars/common/correct-check-icon.js +50 -0
  14. package/dist/bars/histogram.d.ts +47 -0
  15. package/dist/bars/histogram.js +28 -0
  16. package/dist/chart-setup.d.ts +29 -0
  17. package/dist/chart-setup.js +231 -0
  18. package/dist/chart-type.d.ts +32 -0
  19. package/dist/chart-type.js +68 -0
  20. package/dist/chart-types.d.ts +41 -0
  21. package/dist/chart-types.js +17 -0
  22. package/dist/chart.d.ts +88 -0
  23. package/dist/chart.js +250 -0
  24. package/dist/common/correctness-indicators.d.ts +70 -0
  25. package/dist/common/correctness-indicators.js +106 -0
  26. package/dist/common/drag-handle.d.ts +129 -0
  27. package/dist/common/drag-handle.js +120 -0
  28. package/dist/common/drag-icon.d.ts +23 -0
  29. package/dist/common/drag-icon.js +45 -0
  30. package/dist/common/styles.d.ts +23 -0
  31. package/dist/common/styles.js +17 -0
  32. package/dist/grid.d.ts +45 -0
  33. package/dist/grid.js +56 -0
  34. package/dist/index.d.ts +14 -0
  35. package/dist/index.js +6 -0
  36. package/dist/key-legend.d.ts +19 -0
  37. package/dist/key-legend.js +46 -0
  38. package/dist/line/common/drag-handle.d.ts +120 -0
  39. package/dist/line/common/drag-handle.js +92 -0
  40. package/dist/line/common/line.d.ts +96 -0
  41. package/dist/line/common/line.js +114 -0
  42. package/dist/line/line-cross.d.ts +47 -0
  43. package/dist/line/line-cross.js +133 -0
  44. package/dist/line/line-dot.d.ts +47 -0
  45. package/dist/line/line-dot.js +101 -0
  46. package/dist/mark-label.d.ts +55 -0
  47. package/dist/mark-label.js +138 -0
  48. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Axis.js +67 -0
  49. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisBottom.js +29 -0
  50. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisLeft.js +30 -0
  51. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +66 -0
  52. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Ticks.js +39 -0
  53. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
  54. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
  55. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +13 -0
  56. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
  57. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
  58. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickPosition.js +14 -0
  59. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridColumns.js +46 -0
  60. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridRows.js +46 -0
  61. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
  62. package/dist/node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_modules/@visx/group/esm/Group.js +17 -0
  63. package/dist/node_modules/.bun/@visx_point@4.0.0/node_modules/@visx/point/esm/Point.js +20 -0
  64. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/align.js +6 -0
  65. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
  66. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
  67. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
  68. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
  69. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
  70. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
  71. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
  72. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
  73. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
  74. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
  75. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
  76. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +56 -0
  77. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
  78. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
  79. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
  80. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/scales/point.js +9 -0
  81. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
  82. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +29 -0
  83. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/getTicks.js +7 -0
  84. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +7 -0
  85. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
  86. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Bar.js +15 -0
  87. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Circle.js +15 -0
  88. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Line.js +27 -0
  89. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/LinePath.js +24 -0
  90. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
  91. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
  92. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/Text.js +27 -0
  93. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/hooks/useText.js +68 -0
  94. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/getStringWidth.js +19 -0
  95. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/memoize.js +13 -0
  96. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
  97. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
  98. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-shape.js +8 -0
  99. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-time.js +8 -0
  100. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
  101. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
  102. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
  103. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  104. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
  105. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
  106. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
  107. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
  108. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
  109. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
  110. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
  111. package/dist/plot/common/plot.d.ts +103 -0
  112. package/dist/plot/common/plot.js +227 -0
  113. package/dist/plot/dot.d.ts +47 -0
  114. package/dist/plot/dot.js +62 -0
  115. package/dist/plot/line.d.ts +47 -0
  116. package/dist/plot/line.js +84 -0
  117. package/dist/tool-menu.d.ts +31 -0
  118. package/dist/utils.d.ts +39 -0
  119. package/dist/utils.js +101 -0
  120. package/package.json +45 -36
  121. package/CHANGELOG.json +0 -17
  122. package/CHANGELOG.md +0 -1116
  123. package/lib/__tests__/actions-button.test.js +0 -332
  124. package/lib/__tests__/actions-button.test.js.map +0 -1
  125. package/lib/__tests__/axes.test.js +0 -746
  126. package/lib/__tests__/axes.test.js.map +0 -1
  127. package/lib/__tests__/chart-setup.test.js +0 -796
  128. package/lib/__tests__/chart-setup.test.js.map +0 -1
  129. package/lib/__tests__/chart-type.test.js +0 -25
  130. package/lib/__tests__/chart-type.test.js.map +0 -1
  131. package/lib/__tests__/chart.test.js +0 -103
  132. package/lib/__tests__/chart.test.js.map +0 -1
  133. package/lib/__tests__/grid.test.js +0 -39
  134. package/lib/__tests__/grid.test.js.map +0 -1
  135. package/lib/__tests__/key-legend.test.js +0 -235
  136. package/lib/__tests__/key-legend.test.js.map +0 -1
  137. package/lib/__tests__/mark-label.test.js +0 -46
  138. package/lib/__tests__/mark-label.test.js.map +0 -1
  139. package/lib/__tests__/tool-menu.test.js +0 -627
  140. package/lib/__tests__/tool-menu.test.js.map +0 -1
  141. package/lib/__tests__/utils.js +0 -56
  142. package/lib/__tests__/utils.js.map +0 -1
  143. package/lib/__tests__/utils.test.js +0 -186
  144. package/lib/__tests__/utils.test.js.map +0 -1
  145. package/lib/actions-button.js +0 -145
  146. package/lib/actions-button.js.map +0 -1
  147. package/lib/axes.js +0 -643
  148. package/lib/axes.js.map +0 -1
  149. package/lib/bars/__tests__/bar.test.js +0 -53
  150. package/lib/bars/__tests__/bar.test.js.map +0 -1
  151. package/lib/bars/__tests__/histogram.test.js +0 -53
  152. package/lib/bars/__tests__/histogram.test.js.map +0 -1
  153. package/lib/bars/__tests__/utils.js +0 -50
  154. package/lib/bars/__tests__/utils.js.map +0 -1
  155. package/lib/bars/bar.js +0 -58
  156. package/lib/bars/bar.js.map +0 -1
  157. package/lib/bars/common/__tests__/bars.test.js +0 -76
  158. package/lib/bars/common/__tests__/bars.test.js.map +0 -1
  159. package/lib/bars/common/__tests__/utils.js +0 -50
  160. package/lib/bars/common/__tests__/utils.js.map +0 -1
  161. package/lib/bars/common/bars.js +0 -277
  162. package/lib/bars/common/bars.js.map +0 -1
  163. package/lib/bars/common/correct-check-icon.js +0 -54
  164. package/lib/bars/common/correct-check-icon.js.map +0 -1
  165. package/lib/bars/histogram.js +0 -59
  166. package/lib/bars/histogram.js.map +0 -1
  167. package/lib/chart-setup.js +0 -382
  168. package/lib/chart-setup.js.map +0 -1
  169. package/lib/chart-type.js +0 -80
  170. package/lib/chart-type.js.map +0 -1
  171. package/lib/chart-types.js +0 -22
  172. package/lib/chart-types.js.map +0 -1
  173. package/lib/chart.js +0 -384
  174. package/lib/chart.js.map +0 -1
  175. package/lib/common/__tests__/correctness-indicators.test.js +0 -887
  176. package/lib/common/__tests__/correctness-indicators.test.js.map +0 -1
  177. package/lib/common/__tests__/drag-handle.test.js +0 -73
  178. package/lib/common/__tests__/drag-handle.test.js.map +0 -1
  179. package/lib/common/__tests__/utils.js +0 -50
  180. package/lib/common/__tests__/utils.js.map +0 -1
  181. package/lib/common/correctness-indicators.js +0 -156
  182. package/lib/common/correctness-indicators.js.map +0 -1
  183. package/lib/common/drag-handle.js +0 -160
  184. package/lib/common/drag-handle.js.map +0 -1
  185. package/lib/common/drag-icon.js +0 -52
  186. package/lib/common/drag-icon.js.map +0 -1
  187. package/lib/common/styles.js +0 -22
  188. package/lib/common/styles.js.map +0 -1
  189. package/lib/grid.js +0 -112
  190. package/lib/grid.js.map +0 -1
  191. package/lib/index.js +0 -42
  192. package/lib/index.js.map +0 -1
  193. package/lib/key-legend.js +0 -87
  194. package/lib/key-legend.js.map +0 -1
  195. package/lib/line/__tests__/line-cross.test.js +0 -617
  196. package/lib/line/__tests__/line-cross.test.js.map +0 -1
  197. package/lib/line/__tests__/line-dot.test.js +0 -47
  198. package/lib/line/__tests__/line-dot.test.js.map +0 -1
  199. package/lib/line/__tests__/utils.js +0 -56
  200. package/lib/line/__tests__/utils.js.map +0 -1
  201. package/lib/line/common/__tests__/drag-handle.test.js +0 -73
  202. package/lib/line/common/__tests__/drag-handle.test.js.map +0 -1
  203. package/lib/line/common/__tests__/line.test.js +0 -92
  204. package/lib/line/common/__tests__/line.test.js.map +0 -1
  205. package/lib/line/common/__tests__/utils.js +0 -50
  206. package/lib/line/common/__tests__/utils.js.map +0 -1
  207. package/lib/line/common/drag-handle.js +0 -146
  208. package/lib/line/common/drag-handle.js.map +0 -1
  209. package/lib/line/common/line.js +0 -214
  210. package/lib/line/common/line.js.map +0 -1
  211. package/lib/line/line-cross.js +0 -214
  212. package/lib/line/line-cross.js.map +0 -1
  213. package/lib/line/line-dot.js +0 -158
  214. package/lib/line/line-dot.js.map +0 -1
  215. package/lib/mark-label.js +0 -237
  216. package/lib/mark-label.js.map +0 -1
  217. package/lib/plot/__tests__/dot.test.js +0 -513
  218. package/lib/plot/__tests__/dot.test.js.map +0 -1
  219. package/lib/plot/__tests__/line.test.js +0 -566
  220. package/lib/plot/__tests__/line.test.js.map +0 -1
  221. package/lib/plot/__tests__/utils.js +0 -50
  222. package/lib/plot/__tests__/utils.js.map +0 -1
  223. package/lib/plot/common/__tests__/plot.test.js +0 -79
  224. package/lib/plot/common/__tests__/plot.test.js.map +0 -1
  225. package/lib/plot/common/__tests__/utils.js +0 -50
  226. package/lib/plot/common/__tests__/utils.js.map +0 -1
  227. package/lib/plot/common/plot.js +0 -349
  228. package/lib/plot/common/plot.js.map +0 -1
  229. package/lib/plot/dot.js +0 -110
  230. package/lib/plot/dot.js.map +0 -1
  231. package/lib/plot/line.js +0 -140
  232. package/lib/plot/line.js.map +0 -1
  233. package/lib/tool-menu.js +0 -106
  234. package/lib/tool-menu.js.map +0 -1
  235. package/lib/utils.js +0 -189
  236. package/lib/utils.js.map +0 -1
  237. package/src/__tests__/actions-button.test.jsx +0 -280
  238. package/src/__tests__/axes.test.jsx +0 -667
  239. package/src/__tests__/chart-setup.test.jsx +0 -532
  240. package/src/__tests__/chart-type.test.jsx +0 -23
  241. package/src/__tests__/chart.test.jsx +0 -86
  242. package/src/__tests__/grid.test.jsx +0 -37
  243. package/src/__tests__/key-legend.test.jsx +0 -223
  244. package/src/__tests__/mark-label.test.jsx +0 -33
  245. package/src/__tests__/tool-menu.test.jsx +0 -522
  246. package/src/__tests__/utils.js +0 -36
  247. package/src/__tests__/utils.test.js +0 -100
  248. package/src/actions-button.jsx +0 -115
  249. package/src/axes.jsx +0 -594
  250. package/src/bars/__tests__/bar.test.jsx +0 -45
  251. package/src/bars/__tests__/histogram.test.jsx +0 -45
  252. package/src/bars/__tests__/utils.js +0 -30
  253. package/src/bars/bar.js +0 -28
  254. package/src/bars/common/__tests__/bars.test.jsx +0 -68
  255. package/src/bars/common/__tests__/utils.js +0 -30
  256. package/src/bars/common/bars.jsx +0 -249
  257. package/src/bars/common/correct-check-icon.jsx +0 -25
  258. package/src/bars/histogram.js +0 -28
  259. package/src/chart-setup.jsx +0 -356
  260. package/src/chart-type.js +0 -59
  261. package/src/chart-types.js +0 -8
  262. package/src/chart.jsx +0 -357
  263. package/src/common/__tests__/correctness-indicators.test.jsx +0 -720
  264. package/src/common/__tests__/drag-handle.test.jsx +0 -58
  265. package/src/common/__tests__/utils.js +0 -30
  266. package/src/common/correctness-indicators.jsx +0 -128
  267. package/src/common/drag-handle.jsx +0 -125
  268. package/src/common/drag-icon.jsx +0 -36
  269. package/src/common/styles.js +0 -19
  270. package/src/grid.jsx +0 -80
  271. package/src/index.js +0 -7
  272. package/src/key-legend.jsx +0 -77
  273. package/src/line/__tests__/line-cross.test.jsx +0 -463
  274. package/src/line/__tests__/line-dot.test.jsx +0 -41
  275. package/src/line/__tests__/utils.js +0 -36
  276. package/src/line/common/__tests__/drag-handle.test.jsx +0 -62
  277. package/src/line/common/__tests__/line.test.jsx +0 -79
  278. package/src/line/common/__tests__/utils.js +0 -30
  279. package/src/line/common/drag-handle.jsx +0 -114
  280. package/src/line/common/line.jsx +0 -171
  281. package/src/line/line-cross.js +0 -144
  282. package/src/line/line-dot.js +0 -111
  283. package/src/mark-label.jsx +0 -238
  284. package/src/plot/__tests__/dot.test.jsx +0 -344
  285. package/src/plot/__tests__/line.test.jsx +0 -375
  286. package/src/plot/__tests__/utils.js +0 -30
  287. package/src/plot/common/__tests__/plot.test.jsx +0 -69
  288. package/src/plot/common/__tests__/utils.js +0 -30
  289. package/src/plot/common/plot.jsx +0 -358
  290. package/src/plot/dot.js +0 -74
  291. package/src/plot/line.js +0 -98
  292. package/src/tool-menu.jsx +0 -85
  293. package/src/utils.js +0 -201
@@ -1,375 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@pie-lib/test-utils';
3
- import { createTheme, ThemeProvider } from '@mui/material/styles';
4
- import Line, { LinePlot } from '../line';
5
- import { graphProps } from './utils';
6
-
7
- jest.mock('@mui/icons-material/Check', () => {
8
- return function Check(props) {
9
- return <div data-testid="check-icon" {...props} />;
10
- };
11
- });
12
-
13
- jest.mock('@visx/shape', () => ({
14
- LinePath: ({ data, x, y, ...rest }) => (
15
- <path d={data.map((d, i) => `${i === 0 ? 'M' : 'L'}${x(d)},${y(d)}`).join(' ')} {...rest} />
16
- ),
17
- }));
18
-
19
- jest.mock('@visx/group', () => ({
20
- Group: ({ children }) => <g className="visx-group">{children}</g>,
21
- }));
22
-
23
- let theme;
24
-
25
- beforeAll(() => {
26
- theme = createTheme();
27
- });
28
-
29
- describe('LinePlot', () => {
30
- const renderComponent = (extras) => {
31
- const defaults = {
32
- classes: {},
33
- className: 'className',
34
- graphProps: graphProps(),
35
- xBand: () => {
36
- return {
37
- bandwidth: () => {},
38
- };
39
- },
40
- };
41
- const props = { ...defaults, ...extras };
42
- return render(
43
- <ThemeProvider theme={theme}>
44
- <svg>
45
- <LinePlot {...props} />
46
- </svg>
47
- </ThemeProvider>,
48
- );
49
- };
50
-
51
- describe('rendering', () => {
52
- it('renders line plot', () => {
53
- const { container } = renderComponent();
54
- expect(container.firstChild).toBeInTheDocument();
55
- });
56
-
57
- it('renders without graphProps', () => {
58
- const { container } = renderComponent({ graphProps: undefined });
59
- expect(container.firstChild).toBeInTheDocument();
60
- });
61
-
62
- it('renders with data array', () => {
63
- const data = [
64
- { value: 1, label: 'A' },
65
- { value: 2, label: 'B' },
66
- { value: 3, label: 'C' },
67
- ];
68
- const { container } = renderComponent({ data });
69
- expect(container.firstChild).toBeInTheDocument();
70
- });
71
-
72
- it('renders with empty data array', () => {
73
- const { container } = renderComponent({ data: [] });
74
- expect(container.firstChild).toBeInTheDocument();
75
- });
76
-
77
- it('renders with null data', () => {
78
- const { container } = renderComponent({ data: null });
79
- expect(container.firstChild).toBeInTheDocument();
80
- });
81
-
82
- it('renders with undefined data', () => {
83
- const { container } = renderComponent({ data: undefined });
84
- expect(container.firstChild).toBeInTheDocument();
85
- });
86
-
87
- it('renders with custom className', () => {
88
- const { container } = renderComponent({ className: 'custom-line-plot' });
89
- expect(container.firstChild).toBeInTheDocument();
90
- });
91
-
92
- it('renders with onChange handler', () => {
93
- const onChange = jest.fn();
94
- const { container } = renderComponent({ onChange });
95
- expect(container.firstChild).toBeInTheDocument();
96
- });
97
-
98
- it('renders in defineChart mode', () => {
99
- const { container } = renderComponent({ defineChart: true });
100
- expect(container.firstChild).toBeInTheDocument();
101
- });
102
-
103
- it('renders with correctData', () => {
104
- const data = [{ value: 2, label: 'A' }];
105
- const correctData = [{ value: 3, label: 'A' }];
106
- const { container } = renderComponent({ data, correctData });
107
- expect(container.firstChild).toBeInTheDocument();
108
- });
109
- });
110
-
111
- describe('graphProps handling', () => {
112
- it('handles graphProps with missing scale', () => {
113
- const props = graphProps();
114
- delete props.scale;
115
- const { container } = renderComponent({ graphProps: props });
116
- expect(container.firstChild).toBeInTheDocument();
117
- });
118
-
119
- it('handles graphProps with missing size', () => {
120
- const props = graphProps();
121
- delete props.size;
122
- const { container } = renderComponent({ graphProps: props });
123
- expect(container.firstChild).toBeInTheDocument();
124
- });
125
-
126
- it('handles graphProps with empty scale object', () => {
127
- const props = graphProps();
128
- props.scale = {};
129
- const { container } = renderComponent({ graphProps: props });
130
- expect(container.firstChild).toBeInTheDocument();
131
- });
132
-
133
- it('handles graphProps with empty size object', () => {
134
- const props = graphProps();
135
- props.size = {};
136
- const { container } = renderComponent({ graphProps: props });
137
- expect(container.firstChild).toBeInTheDocument();
138
- });
139
- });
140
-
141
- describe('data variations', () => {
142
- it('renders with single data point', () => {
143
- const data = [{ value: 1, label: 'A' }];
144
- const { container } = renderComponent({ data });
145
- expect(container.firstChild).toBeInTheDocument();
146
- });
147
-
148
- it('renders with multiple data points', () => {
149
- const data = [
150
- { value: 1, label: 'A' },
151
- { value: 2, label: 'B' },
152
- { value: 3, label: 'C' },
153
- { value: 4, label: 'D' },
154
- ];
155
- const { container } = renderComponent({ data });
156
- expect(container.firstChild).toBeInTheDocument();
157
- });
158
-
159
- it('renders with zero values', () => {
160
- const data = [
161
- { value: 0, label: 'A' },
162
- { value: 0, label: 'B' },
163
- ];
164
- const { container } = renderComponent({ data });
165
- expect(container.firstChild).toBeInTheDocument();
166
- });
167
-
168
- it('renders with mixed values', () => {
169
- const data = [
170
- { value: 0, label: 'A' },
171
- { value: 5, label: 'B' },
172
- { value: 1, label: 'C' },
173
- ];
174
- const { container } = renderComponent({ data });
175
- expect(container.firstChild).toBeInTheDocument();
176
- });
177
-
178
- it('renders with large values', () => {
179
- const data = [
180
- { value: 100, label: 'A' },
181
- { value: 200, label: 'B' },
182
- ];
183
- const { container } = renderComponent({ data });
184
- expect(container.firstChild).toBeInTheDocument();
185
- });
186
-
187
- it('renders with correctness data', () => {
188
- const data = [
189
- { value: 2, label: 'A', correctness: { value: 'correct', label: 'Correct' } },
190
- { value: 3, label: 'B', correctness: { value: 'correct', label: 'Correct' } },
191
- ];
192
- const { container } = renderComponent({ data });
193
- expect(container.firstChild).toBeInTheDocument();
194
- });
195
-
196
- it('renders with incorrect correctness and correctData', () => {
197
- const data = [
198
- { value: 2, label: 'A', correctness: { value: 'incorrect', label: 'Incorrect' } },
199
- { value: 3, label: 'B', correctness: { value: 'incorrect', label: 'Incorrect' } },
200
- ];
201
- const correctData = [
202
- { value: 3, label: 'A' },
203
- { value: 4, label: 'B' },
204
- ];
205
- const { container } = renderComponent({ data, correctData });
206
- expect(container.firstChild).toBeInTheDocument();
207
- });
208
-
209
- it('renders with interactive data points', () => {
210
- const data = [
211
- { value: 2, label: 'A', interactive: true },
212
- { value: 3, label: 'B', interactive: false },
213
- ];
214
- const { container } = renderComponent({ data });
215
- expect(container.firstChild).toBeInTheDocument();
216
- });
217
- });
218
-
219
- describe('callbacks', () => {
220
- it('passes onChange handler to Plot component', () => {
221
- const onChange = jest.fn();
222
- const data = [{ value: 1, label: 'A' }];
223
- const { container } = renderComponent({ data, onChange });
224
- expect(container.firstChild).toBeInTheDocument();
225
- });
226
-
227
- it('handles onChangeCategory callback', () => {
228
- const onChangeCategory = jest.fn();
229
- const data = [{ value: 1, label: 'A' }];
230
- const { container } = renderComponent({ data, onChangeCategory });
231
- expect(container.firstChild).toBeInTheDocument();
232
- });
233
- });
234
-
235
- describe('component', () => {
236
- it('returns correct chart object', () => {
237
- const chart = Line();
238
-
239
- expect(chart).toEqual({
240
- type: 'linePlot',
241
- Component: LinePlot,
242
- name: 'Line Plot',
243
- });
244
- });
245
-
246
- it('returns object with Component that can be rendered', () => {
247
- const chart = Line();
248
- const { Component } = chart;
249
-
250
- const { container } = render(<Component graphProps={graphProps()} />);
251
- expect(container.firstChild).toBeInTheDocument();
252
- });
253
- });
254
- });
255
-
256
- describe('CustomBarElement (Line)', () => {
257
- const renderLinePlot = (props) =>
258
- render(
259
- <ThemeProvider theme={theme}>
260
- <svg>
261
- <LinePlot {...props} />
262
- </svg>
263
- </ThemeProvider>,
264
- );
265
-
266
- it('renders line elements', () => {
267
- const data = [{ value: 1, label: 'A' }];
268
- const { container } = renderLinePlot({
269
- data,
270
- graphProps: graphProps(),
271
- });
272
- expect(container).toBeInTheDocument();
273
- });
274
-
275
- it('renders with dottedOverline prop', () => {
276
- const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
277
- const correctData = [{ value: 3, label: 'A' }];
278
- const { container } = renderLinePlot({
279
- data,
280
- graphProps: graphProps(),
281
- correctData,
282
- });
283
- expect(container).toBeInTheDocument();
284
- });
285
-
286
- it('renders without dottedOverline prop', () => {
287
- const data = [{ value: 2, label: 'A' }];
288
- const { container } = renderLinePlot({
289
- data,
290
- graphProps: graphProps(),
291
- });
292
- expect(container).toBeInTheDocument();
293
- });
294
-
295
- it('renders two LinePath elements for X shape when not dotted', () => {
296
- const data = [{ value: 3, label: 'A' }];
297
- const { container } = renderLinePlot({
298
- data,
299
- graphProps: graphProps(),
300
- });
301
- expect(container).toBeInTheDocument();
302
- });
303
-
304
- it('renders rect with dashed stroke when dottedOverline is true', () => {
305
- const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
306
- const correctData = [{ value: 3, label: 'A' }];
307
- const { container } = renderLinePlot({
308
- data,
309
- graphProps: graphProps(),
310
- correctData,
311
- });
312
- expect(container).toBeInTheDocument();
313
- });
314
-
315
- it('calculates correct line positions', () => {
316
- const data = [{ value: 2, label: 'A' }];
317
- const { container } = renderLinePlot({
318
- data,
319
- graphProps: graphProps(),
320
- });
321
- expect(container).toBeInTheDocument();
322
- });
323
-
324
- it('handles zero pointDiameter', () => {
325
- const props = graphProps();
326
- props.size = { width: 0, height: 0 };
327
- const data = [{ value: 1, label: 'A' }];
328
- const { container } = renderLinePlot({
329
- data,
330
- graphProps: props,
331
- });
332
- expect(container).toBeInTheDocument();
333
- });
334
-
335
- it('handles large pointDiameter values', () => {
336
- const props = graphProps();
337
- props.size = { width: 1000, height: 1000 };
338
- const data = [{ value: 1, label: 'A' }];
339
- const { container } = renderLinePlot({
340
- data,
341
- graphProps: props,
342
- });
343
- expect(container).toBeInTheDocument();
344
- });
345
-
346
- it('applies correct strokeWidth based on pointDiameter', () => {
347
- const data = [{ value: 2, label: 'A' }];
348
- const { container } = renderLinePlot({
349
- data,
350
- graphProps: graphProps(),
351
- });
352
- // strokeWidth should be pointDiameter / 5
353
- expect(container).toBeInTheDocument();
354
- });
355
-
356
- it('renders Group component wrapping LinePaths', () => {
357
- const data = [{ value: 1, label: 'A' }];
358
- const { container } = renderLinePlot({
359
- data,
360
- graphProps: graphProps(),
361
- });
362
- expect(container).toBeInTheDocument();
363
- });
364
-
365
- it('handles rect with extra padding when dotted', () => {
366
- const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
367
- const correctData = [{ value: 3, label: 'A' }];
368
- const { container } = renderLinePlot({
369
- data,
370
- graphProps: graphProps(),
371
- correctData,
372
- });
373
- expect(container).toBeInTheDocument();
374
- });
375
- });
@@ -1,30 +0,0 @@
1
- export const scaleMock = () => {
2
- const fn = jest.fn((n) => n);
3
- fn.invert = jest.fn((n) => n);
4
- return fn;
5
- };
6
-
7
- export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
8
- scale: {
9
- x: scaleMock(),
10
- y: scaleMock(),
11
- },
12
- snap: {
13
- x: jest.fn((n) => n),
14
- y: jest.fn((n) => n),
15
- },
16
- domain: {
17
- min: dmin,
18
- max: dmax,
19
- step: 1,
20
- },
21
- range: {
22
- min: rmin,
23
- max: rmax,
24
- step: 1,
25
- },
26
- size: {
27
- width: 400,
28
- height: 400,
29
- },
30
- });
@@ -1,69 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import Plot, { RawPlot } from '../plot';
4
- import { graphProps } from './utils';
5
-
6
- describe('Plot', () => {
7
- const xBand = () => {};
8
- xBand.bandwidth = () => {};
9
- const onChange = jest.fn();
10
-
11
- const renderComponent = (extras) => {
12
- const defaults = {
13
- classes: {},
14
- className: 'className',
15
- graphProps: graphProps(),
16
- xBand,
17
- onChange,
18
- data: [{ value: 0, label: '0' }],
19
- };
20
- const props = { ...defaults, ...extras };
21
- return render(<Plot {...props} />);
22
- };
23
-
24
- describe('rendering', () => {
25
- it('renders without crashing', () => {
26
- const { container } = renderComponent();
27
- expect(container.firstChild).toBeInTheDocument();
28
- });
29
- });
30
- });
31
-
32
- describe('RawPlot', () => {
33
- const xBand = () => {};
34
- xBand.bandwidth = () => {};
35
- const onChangeCategory = jest.fn();
36
-
37
- const renderComponent = (extras) => {
38
- const defaults = {
39
- classes: {},
40
- className: 'className',
41
- graphProps: graphProps(),
42
- xBand,
43
- onChangeCategory,
44
- data: [],
45
- label: 'label',
46
- CustomBarElement: () => <div />,
47
- };
48
- const props = { ...defaults, ...extras };
49
- return render(<RawPlot {...props} />);
50
- };
51
-
52
- describe('rendering', () => {
53
- it('renders without crashing', () => {
54
- const { container } = renderComponent();
55
- expect(container.firstChild).toBeInTheDocument();
56
- });
57
- });
58
-
59
- describe('functionality', () => {
60
- it('calls onChangeCategory when drag completes with a value', () => {
61
- const { container } = renderComponent();
62
- // Testing drag functionality requires interaction - the component should
63
- // call onChangeCategory when a drag operation completes with a new value
64
- // This would typically be tested through user interactions rather than
65
- // directly calling instance methods
66
- expect(container.firstChild).toBeInTheDocument();
67
- });
68
- });
69
- });
@@ -1,30 +0,0 @@
1
- export const scaleMock = () => {
2
- const fn = jest.fn((n) => n);
3
- fn.invert = jest.fn((n) => n);
4
- return fn;
5
- };
6
-
7
- export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
8
- scale: {
9
- x: scaleMock(),
10
- y: scaleMock(),
11
- },
12
- snap: {
13
- x: jest.fn((n) => n),
14
- y: jest.fn((n) => n),
15
- },
16
- domain: {
17
- min: dmin,
18
- max: dmax,
19
- step: 1,
20
- },
21
- range: {
22
- min: rmin,
23
- max: rmax,
24
- step: 1,
25
- },
26
- size: {
27
- width: 400,
28
- height: 400,
29
- },
30
- });