@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,58 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import DragHandle from '../drag-handle';
4
- import { gridDraggable } from '@pie-lib/plot';
5
- import { graphProps } from './utils';
6
-
7
- jest.mock('../../utils', () => {
8
- const { point } = jest.requireActual('../../utils');
9
- return {
10
- bounds: jest.fn(),
11
- point,
12
- getScale: jest.fn(() => ({ scale: 1 })),
13
- };
14
- });
15
-
16
- jest.mock('@pie-lib/plot', () => {
17
- const { types, utils } = jest.requireActual('@pie-lib/plot');
18
- return {
19
- gridDraggable: jest.fn((opts) => (Comp) => Comp),
20
- types,
21
- utils,
22
- };
23
- });
24
-
25
- describe('BasePoint', () => {
26
- let onChange = jest.fn();
27
- const renderComponent = (extras) => {
28
- const defaults = {
29
- classes: {},
30
- className: 'className',
31
- onChange,
32
- graphProps: graphProps(),
33
- x: 0,
34
- y: 0,
35
- width: 100,
36
- };
37
- const props = { ...defaults, ...extras };
38
- return render(<DragHandle {...props} />);
39
- };
40
-
41
- describe('rendering', () => {
42
- it('renders without crashing', () => {
43
- const { container } = renderComponent();
44
- expect(container.firstChild).toBeInTheDocument();
45
- });
46
- });
47
-
48
- describe('gridDraggable options', () => {
49
- it('configures gridDraggable with correct options', () => {
50
- // The gridDraggable HOC is tested by verifying that it's called with the component
51
- // Detailed unit tests for the HOC options would require accessing internal
52
- // implementation details which is not recommended with RTL
53
- const { container } = renderComponent();
54
- expect(container.firstChild).toBeInTheDocument();
55
- expect(gridDraggable).toHaveBeenCalled();
56
- });
57
- });
58
- });
@@ -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,128 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
- import Check from '@mui/icons-material/Check';
5
- import Close from '@mui/icons-material/Close';
6
- import { color as enumColor } from '@pie-lib/render-ui';
7
-
8
- const StyledCorrectIcon = styled(Check)(({ theme }) => ({
9
- borderRadius: theme.spacing(2),
10
- color: enumColor.defaults.WHITE,
11
- fontSize: '16px',
12
- width: '16px',
13
- height: '16px',
14
- padding: '2px',
15
- border: `1px solid ${enumColor.defaults.WHITE}`,
16
- stroke: 'initial',
17
- boxSizing: 'unset', // to override the default border-box in IBX
18
- backgroundColor: enumColor.correct(),
19
- display: 'block',
20
- '&.small': {
21
- fontSize: '10px',
22
- width: '10px',
23
- height: '10px',
24
- },
25
- }));
26
-
27
- const StyledIncorrectIcon = styled(Close)(({ theme }) => ({
28
- borderRadius: theme.spacing(2),
29
- color: enumColor.defaults.WHITE,
30
- fontSize: '16px',
31
- width: '16px',
32
- height: '16px',
33
- padding: '2px',
34
- border: `1px solid ${enumColor.defaults.WHITE}`,
35
- stroke: 'initial',
36
- boxSizing: 'unset', // to override the default border-box in IBX
37
- backgroundColor: enumColor.incorrectWithIcon(),
38
- display: 'block',
39
- '&.small': {
40
- fontSize: '10px',
41
- width: '10px',
42
- height: '10px',
43
- },
44
- }));
45
-
46
- export const CorrectnessIndicator = ({ scale, x, y, correctness, interactive }) => {
47
- if (!correctness || !interactive) return null;
48
- const cx = scale ? scale.x(x) : x;
49
- const cy = scale ? scale.y(y) : y;
50
- const isCorrect = correctness.value === 'correct';
51
-
52
- // the icon is 16px + 2px padding + 1px border, so total size is 22px
53
- return (
54
- <foreignObject x={cx - 11} y={cy - 11} width={22} height={22}>
55
- {isCorrect ? <StyledCorrectIcon title={correctness.label} /> : <StyledIncorrectIcon title={correctness.label} />}
56
- </foreignObject>
57
- );
58
- };
59
-
60
- export const SmallCorrectPointIndicator = ({ scale, x, correctness, correctData, label }) => {
61
- if (correctness && correctness.value === 'incorrect') {
62
- const correctVal = parseFloat(correctData.find((d) => d.label === label)?.value);
63
- if (isNaN(correctVal)) return null;
64
- const correctPxY = scale.y(correctVal);
65
- const yToRender = correctPxY - 7.5;
66
- const xToRender = scale.x(x) - 7.5;
67
-
68
- // small circle has 10px font + 2px padding + 1px border, so total size is 15px
69
- return (
70
- <foreignObject x={xToRender} y={yToRender} width={15} height={15}>
71
- <StyledCorrectIcon className="small" title={correctness.label} />
72
- </foreignObject>
73
- );
74
- }
75
-
76
- return null;
77
- };
78
-
79
- export const TickCorrectnessIndicator = ({ correctness, interactive }) => {
80
- if (!correctness || !interactive) return null;
81
-
82
- return correctness.value === 'correct' ? (
83
- <StyledCorrectIcon title={correctness.label} />
84
- ) : (
85
- <StyledIncorrectIcon title={correctness.label} />
86
- );
87
- };
88
-
89
- CorrectnessIndicator.propTypes = {
90
- scale: PropTypes.shape({
91
- x: PropTypes.func,
92
- y: PropTypes.func,
93
- }),
94
- x: PropTypes.number.isRequired,
95
- y: PropTypes.number.isRequired,
96
- correctness: PropTypes.shape({
97
- value: PropTypes.string,
98
- label: PropTypes.string,
99
- }),
100
- interactive: PropTypes.bool,
101
- };
102
-
103
- SmallCorrectPointIndicator.propTypes = {
104
- scale: PropTypes.shape({
105
- x: PropTypes.func,
106
- y: PropTypes.func,
107
- }).isRequired,
108
- x: PropTypes.number.isRequired,
109
- correctness: PropTypes.shape({
110
- value: PropTypes.string,
111
- label: PropTypes.string,
112
- }),
113
- correctData: PropTypes.arrayOf(
114
- PropTypes.shape({
115
- label: PropTypes.string,
116
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
117
- }),
118
- ),
119
- label: PropTypes.string,
120
- };
121
-
122
- TickCorrectnessIndicator.propTypes = {
123
- correctness: PropTypes.shape({
124
- value: PropTypes.string,
125
- label: PropTypes.string,
126
- }),
127
- interactive: PropTypes.bool,
128
- };
@@ -1,125 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
- import Check from '@mui/icons-material/Check';
5
- import Close from '@mui/icons-material/Close';
6
-
7
- import { gridDraggable, types, utils } from '@pie-lib/plot';
8
- import { color as enumColor } from '@pie-lib/render-ui';
9
- import { getScale } from '../utils';
10
- import DragIcon from './drag-icon';
11
-
12
- const StyledSvg = styled('svg')(() => ({
13
- overflow: 'visible !important',
14
- }));
15
-
16
- const StyledEllipse = styled('ellipse')(() => ({
17
- fill: 'transparent',
18
- clipPath: 'polygon(50% 0%, 100% 0%, 100% 50%, 0% 50%, 0% 0%)',
19
- }));
20
-
21
- const StyledCorrectIcon = styled(Check)(() => ({
22
- backgroundColor: enumColor.correct(),
23
- borderRadius: '16px', // equivalent to theme.spacing(2) for most themes
24
- color: enumColor.defaults.WHITE,
25
- fontSize: '16px',
26
- padding: '2px',
27
- border: `4px solid ${enumColor.defaults.WHITE}`,
28
- width: '16px',
29
- height: '16px',
30
- boxSizing: 'unset', // to override the default border-box in IBX
31
- }));
32
-
33
- const StyledIncorrectIcon = styled(Close)(() => ({
34
- backgroundColor: enumColor.incorrectWithIcon(),
35
- borderRadius: '16px', // equivalent to theme.spacing(2) for most themes
36
- color: enumColor.defaults.WHITE,
37
- fontSize: '16px',
38
- padding: '2px',
39
- border: `4px solid ${enumColor.defaults.WHITE}`,
40
- width: '16px',
41
- height: '16px',
42
- boxSizing: 'unset', // to override the default border-box in IBX
43
- }));
44
-
45
- const RawDragHandle = ({ x, y, width, graphProps, interactive, isHovered, correctness, isPlot, ...rest }) => {
46
- const { scale } = graphProps;
47
- const scaleValue = getScale(width)?.scale;
48
-
49
- return (
50
- <StyledSvg x={x} y={scale.y(y) - 10} width={width} overflow="visible">
51
- {isHovered && !correctness && interactive && (
52
- <DragIcon width={width} scaleValue={scaleValue} color={enumColor.defaults.BORDER_GRAY} />
53
- )}
54
- {interactive && !correctness && (
55
- <StyledEllipse
56
- cx={width / 2}
57
- cy={10}
58
- rx={width / 2}
59
- // the drag icon has a 22px fixed r value, so the ry value is 3 times that in order to cover all the area
60
- ry={66}
61
- {...rest}
62
- />
63
- )}
64
-
65
- <defs>
66
- <filter id="bottomShadow" x="0" y="0" width="140%" height="140%">
67
- <feGaussianBlur in="SourceAlpha" stdDeviation="3" />
68
- <feOffset dx="0" dy="5" result="offsetblur" />
69
- <feFlood floodColor="#00000033" />
70
- <feComposite in2="offsetblur" operator="in" />
71
- <feMerge>
72
- <feMergeNode />
73
- <feMergeNode in="SourceGraphic" />
74
- </feMerge>
75
- </filter>
76
- </defs>
77
-
78
- {correctness && interactive && !isPlot && (
79
- <foreignObject x={width / 2 - 14} y={0} width={40} height={40}>
80
- {correctness.value === 'correct' ? (
81
- <StyledCorrectIcon title={correctness.label} />
82
- ) : (
83
- <StyledIncorrectIcon title={correctness.label} />
84
- )}
85
- </foreignObject>
86
- )}
87
- </StyledSvg>
88
- );
89
- };
90
-
91
- RawDragHandle.propTypes = {
92
- x: PropTypes.number.isRequired,
93
- y: PropTypes.number.isRequired,
94
- width: PropTypes.number,
95
- graphProps: types.GraphPropsType.isRequired,
96
- interactive: PropTypes.bool,
97
- isHovered: PropTypes.bool,
98
- correctness: PropTypes.shape({
99
- value: PropTypes.string,
100
- label: PropTypes.string,
101
- }),
102
- isPlot: PropTypes.bool,
103
- };
104
-
105
- export const DragHandle = RawDragHandle;
106
-
107
- export const D = gridDraggable({
108
- axis: 'y',
109
- fromDelta: (props, delta) => {
110
- //TODO: should be in grid-draggable, if axis is y delta.x should always be 0.
111
- delta.x = 0;
112
- const newPoint = utils.point(props).add(utils.point(delta));
113
-
114
- return newPoint.y;
115
- },
116
- bounds: (props, { domain, range }) => {
117
- const area = { left: 0, top: props.y, bottom: props.y, right: 0 };
118
- return utils.bounds(area, domain, range);
119
- },
120
- anchorPoint: (props) => {
121
- return { x: props.x, y: props.y };
122
- },
123
- })(DragHandle);
124
-
125
- export default D;
@@ -1,36 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { getAdjustedX, getScale } from '../utils';
4
-
5
- const DragIcon = ({ width, scaleValue, color }) => (
6
- <svg
7
- x={getAdjustedX(width, scaleValue)}
8
- y={getScale(width)?.deltay}
9
- color={color}
10
- width={width}
11
- height={width}
12
- overflow="visible"
13
- viewBox={`0 0 ${width} ${width}`}
14
- style={{ overflow: 'visible !important' }}
15
- >
16
- <g xmlns="http://www.w3.org/2000/svg" fill="currentColor" stroke="currentColor" transform={`scale(${scaleValue})`}>
17
- <circle cx="28.5" cy="23.5" r="22" fill="white" stroke="currentColor" />
18
- <path
19
- d="M33.5 21.25H23.4609C22.7578 21.25 22.4062 20.4297 22.9141 19.9219L27.9141 14.9219C28.2266 14.6094 28.7344 14.6094 29.0469 14.9219L34.0469 19.9219C34.5547 20.4297 34.2031 21.25 33.5 21.25Z"
20
- fill="currentColor"
21
- />
22
- <path
23
- d="M23.5 25.75L33.5391 25.75C34.2422 25.75 34.5938 26.5703 34.0859 27.0781L29.0859 32.0781C28.7734 32.3906 28.2656 32.3906 27.9531 32.0781L22.9531 27.0781C22.4453 26.5703 22.7969 25.75 23.5 25.75Z"
24
- fill="currentColor"
25
- />
26
- </g>
27
- </svg>
28
- );
29
-
30
- DragIcon.propTypes = {
31
- width: PropTypes.number.isRequired,
32
- scaleValue: PropTypes.number.isRequired,
33
- color: PropTypes.string,
34
- };
35
-
36
- export default DragIcon;
@@ -1,19 +0,0 @@
1
- import { color } from '@pie-lib/render-ui';
2
-
3
- export const disabled = (key = 'fill') => ({
4
- [key]: `var(--graph-disabled, ${color.disabled()})`,
5
- pointerEvents: 'none',
6
- border: 'none',
7
- });
8
-
9
- export const correct = (key = 'fill') => ({
10
- [key]: color.correct(),
11
- pointerEvents: 'none',
12
- border: `solid 1px ${color.correct()}`,
13
- });
14
-
15
- export const incorrect = (key = 'fill') => ({
16
- [key]: color.incorrect(),
17
- pointerEvents: 'none',
18
- border: `solid 1px ${color.incorrect()}`,
19
- });
package/src/grid.jsx DELETED
@@ -1,80 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
- import { GridColumns, GridRows } from '@visx/grid';
5
-
6
- import { types } from '@pie-lib/plot';
7
- import { color } from '@pie-lib/render-ui';
8
-
9
- const StyledGridGroup = styled('g')(() => ({
10
- stroke: color.primaryLight(),
11
- }));
12
-
13
- export class Grid extends React.Component {
14
- static propTypes = {
15
- className: PropTypes.string,
16
- graphProps: types.GraphPropsType.isRequired,
17
- xBand: PropTypes.func,
18
- columnTickValues: PropTypes.array,
19
- rowTickValues: PropTypes.array,
20
- };
21
-
22
- static defaultProps = {};
23
-
24
- render() {
25
- const { graphProps, xBand, rowTickValues, columnTickValues } = this.props;
26
- const { scale = {}, size = {}, range = {} } = graphProps || {};
27
- const { step = 0, labelStep = 0 } = range;
28
- const highlightNonLabel = step && labelStep && step < labelStep;
29
-
30
- // Avoid floating-point precision errors in the % operator.
31
- // e.g. 0.6 % 0.2 = 0.19999999999999996, but safeModulo(0.6, 0.2) = 0
32
- const safeModulo = (value, step) => {
33
- const valueDecimals = (value.toString().split('.')[1] || '').length;
34
- const stepDecimals =(step.toString().split('.')[1] || '').length
35
- const decimals = Math.max(valueDecimals, stepDecimals);
36
- const factor = Math.pow(10, decimals);
37
-
38
- return ((value * factor) % (step * factor)) / factor;
39
- };
40
-
41
- // if highlightNonLabel is true, we need to separate the unlabeled lines in order to render them in a different color
42
- const { unlabeledLines, labeledLines } = (rowTickValues || []).reduce(
43
- (acc, value) => {
44
- if (highlightNonLabel && safeModulo(value, labelStep) !== 0) {
45
- acc.unlabeledLines.push(value);
46
- } else {
47
- acc.labeledLines.push(value);
48
- }
49
- return acc;
50
- },
51
- { unlabeledLines: [], labeledLines: [] },
52
- );
53
-
54
- return (
55
- <StyledGridGroup>
56
- <GridRows
57
- scale={scale.y}
58
- width={size.width}
59
- tickValues={unlabeledLines}
60
- lineStyle={{
61
- stroke: color.fadedPrimary(),
62
- strokeWidth: 1,
63
- }}
64
- />
65
- <GridRows
66
- scale={scale.y}
67
- width={size.width}
68
- tickValues={labeledLines}
69
- lineStyle={{
70
- stroke: unlabeledLines.length ? color.visualElementsColors.GRIDLINES_COLOR : color.fadedPrimary(),
71
- strokeWidth: 1,
72
- }}
73
- />
74
- <GridColumns scale={xBand} height={size.height} offset={xBand.bandwidth() / 2} tickValues={columnTickValues} />
75
- </StyledGridGroup>
76
- );
77
- }
78
- }
79
-
80
- export default Grid;
package/src/index.js DELETED
@@ -1,7 +0,0 @@
1
- import Chart from './chart';
2
- import chartTypes from './chart-types';
3
- import ConfigureChartPanel from './chart-setup';
4
- import ChartType from './chart-type';
5
- import KeyLegend from './key-legend';
6
-
7
- export { Chart, chartTypes, ChartType, ConfigureChartPanel, KeyLegend };
@@ -1,77 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
- import Check from '@mui/icons-material/Check';
5
- import Close from '@mui/icons-material/Close';
6
- import { color } from '@pie-lib/render-ui';
7
- import Translator from '@pie-lib/translator';
8
-
9
- const StyledContainer = styled('div')(({ theme }) => ({
10
- backgroundColor: color.defaults.WHITE,
11
- padding: theme.spacing(2),
12
- width: '355px',
13
- boxShadow: 'inset 0px 1px 5px 0px #9297A6',
14
- display: 'flex',
15
- flexDirection: 'column',
16
- gap: '16px',
17
- }));
18
-
19
- const StyledRow = styled('div')(() => ({
20
- display: 'flex',
21
- alignItems: 'center',
22
- gap: '12px',
23
- }));
24
-
25
- const StyledTitle = styled('div')(({ theme }) => ({
26
- fontSize: theme.typography.h6.fontSize,
27
- fontWeight: '700',
28
- }));
29
-
30
- const StyledSmallText = styled('div')(() => ({
31
- marginLeft: '2px',
32
- }));
33
-
34
- const StyledCorrectIcon = styled(Check)(({ theme }) => ({
35
- backgroundColor: color.correct(),
36
- borderRadius: theme.spacing(2),
37
- color: color.defaults.WHITE,
38
- }));
39
-
40
- const StyledIncorrectIcon = styled(Close)(({ theme }) => ({
41
- backgroundColor: color.incorrectWithIcon(),
42
- borderRadius: theme.spacing(2),
43
- color: color.defaults.WHITE,
44
- }));
45
-
46
- const StyledLastRow = styled('div')(() => ({
47
- marginLeft: '3px',
48
- display: 'flex',
49
- alignItems: 'center',
50
- gap: '12px',
51
- }));
52
-
53
- const { translator } = Translator;
54
-
55
- const KeyLegend = ({ language }) => (
56
- <StyledContainer>
57
- <StyledTitle>Key</StyledTitle>
58
- <StyledRow>
59
- <StyledIncorrectIcon />
60
- <div>{translator.t('charting.keyLegend.incorrectAnswer', { lng: language })}</div>
61
- </StyledRow>
62
- <StyledRow>
63
- <StyledCorrectIcon />
64
- <div>{translator.t('charting.keyLegend.correctAnswer', { lng: language })}</div>
65
- </StyledRow>
66
- <StyledLastRow>
67
- <StyledCorrectIcon fontSize={'small'} />
68
- <StyledSmallText>{translator.t('charting.keyLegend.correctKeyAnswer', { lng: language })}</StyledSmallText>
69
- </StyledLastRow>
70
- </StyledContainer>
71
- );
72
-
73
- KeyLegend.propTypes = {
74
- language: PropTypes.string,
75
- };
76
-
77
- export default KeyLegend;