@pie-lib/charting 7.0.4-next.3 → 7.0.4-next.31

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 (272) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +23 -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@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +101 -0
  49. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisBottom.js +46 -0
  50. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +47 -0
  51. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +63 -0
  52. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +44 -0
  53. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
  54. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
  55. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +21 -0
  56. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
  57. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
  58. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +15 -0
  59. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +79 -0
  60. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +79 -0
  61. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
  62. package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +50 -0
  63. package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +18 -0
  64. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/align.js +6 -0
  65. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
  66. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
  67. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
  68. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
  69. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
  70. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
  71. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
  72. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
  73. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
  74. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
  75. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
  76. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +58 -0
  77. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
  78. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
  79. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
  80. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +9 -0
  81. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
  82. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +29 -0
  83. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +9 -0
  84. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +7 -0
  85. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
  86. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Bar.js +29 -0
  87. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +29 -0
  88. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +47 -0
  89. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +50 -0
  90. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
  91. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
  92. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +53 -0
  93. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +57 -0
  94. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +91 -0
  95. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +21 -0
  96. package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
  97. package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
  98. package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +8 -0
  99. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
  100. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
  101. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
  102. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  103. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Hash.js +21 -0
  104. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_ListCache.js +21 -0
  105. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Map.js +10 -0
  106. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_MapCache.js +21 -0
  107. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Symbol.js +9 -0
  108. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +14 -0
  109. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +15 -0
  110. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +16 -0
  111. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_coreJsData.js +9 -0
  112. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +8 -0
  113. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getMapData.js +14 -0
  114. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getNative.js +15 -0
  115. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getRawTag.js +19 -0
  116. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getValue.js +11 -0
  117. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashClear.js +13 -0
  118. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashDelete.js +12 -0
  119. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashGet.js +18 -0
  120. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashHas.js +14 -0
  121. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashSet.js +14 -0
  122. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isKeyable.js +12 -0
  123. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isMasked.js +16 -0
  124. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +11 -0
  125. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +14 -0
  126. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +14 -0
  127. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +13 -0
  128. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +14 -0
  129. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +19 -0
  130. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +14 -0
  131. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +13 -0
  132. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +13 -0
  133. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +14 -0
  134. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +9 -0
  135. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_objectToString.js +12 -0
  136. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_root.js +10 -0
  137. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_toSource.js +20 -0
  138. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/eq.js +11 -0
  139. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isFunction.js +16 -0
  140. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isObject.js +12 -0
  141. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/memoize.js +20 -0
  142. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
  143. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
  144. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
  145. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
  146. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
  147. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
  148. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
  149. package/dist/plot/common/plot.d.ts +103 -0
  150. package/dist/plot/common/plot.js +227 -0
  151. package/dist/plot/dot.d.ts +47 -0
  152. package/dist/plot/dot.js +62 -0
  153. package/dist/plot/line.d.ts +47 -0
  154. package/dist/plot/line.js +84 -0
  155. package/dist/tool-menu.d.ts +31 -0
  156. package/dist/utils.d.ts +39 -0
  157. package/dist/utils.js +101 -0
  158. package/package.json +39 -28
  159. package/CHANGELOG.json +0 -17
  160. package/CHANGELOG.md +0 -1116
  161. package/LICENSE.md +0 -5
  162. package/lib/actions-button.js +0 -145
  163. package/lib/actions-button.js.map +0 -1
  164. package/lib/axes.js +0 -643
  165. package/lib/axes.js.map +0 -1
  166. package/lib/bars/bar.js +0 -58
  167. package/lib/bars/bar.js.map +0 -1
  168. package/lib/bars/common/bars.js +0 -277
  169. package/lib/bars/common/bars.js.map +0 -1
  170. package/lib/bars/common/correct-check-icon.js +0 -54
  171. package/lib/bars/common/correct-check-icon.js.map +0 -1
  172. package/lib/bars/histogram.js +0 -59
  173. package/lib/bars/histogram.js.map +0 -1
  174. package/lib/chart-setup.js +0 -382
  175. package/lib/chart-setup.js.map +0 -1
  176. package/lib/chart-type.js +0 -80
  177. package/lib/chart-type.js.map +0 -1
  178. package/lib/chart-types.js +0 -22
  179. package/lib/chart-types.js.map +0 -1
  180. package/lib/chart.js +0 -384
  181. package/lib/chart.js.map +0 -1
  182. package/lib/common/correctness-indicators.js +0 -156
  183. package/lib/common/correctness-indicators.js.map +0 -1
  184. package/lib/common/drag-handle.js +0 -160
  185. package/lib/common/drag-handle.js.map +0 -1
  186. package/lib/common/drag-icon.js +0 -52
  187. package/lib/common/drag-icon.js.map +0 -1
  188. package/lib/common/styles.js +0 -22
  189. package/lib/common/styles.js.map +0 -1
  190. package/lib/grid.js +0 -112
  191. package/lib/grid.js.map +0 -1
  192. package/lib/index.js +0 -42
  193. package/lib/index.js.map +0 -1
  194. package/lib/key-legend.js +0 -87
  195. package/lib/key-legend.js.map +0 -1
  196. package/lib/line/common/drag-handle.js +0 -146
  197. package/lib/line/common/drag-handle.js.map +0 -1
  198. package/lib/line/common/line.js +0 -214
  199. package/lib/line/common/line.js.map +0 -1
  200. package/lib/line/line-cross.js +0 -214
  201. package/lib/line/line-cross.js.map +0 -1
  202. package/lib/line/line-dot.js +0 -158
  203. package/lib/line/line-dot.js.map +0 -1
  204. package/lib/mark-label.js +0 -237
  205. package/lib/mark-label.js.map +0 -1
  206. package/lib/plot/common/plot.js +0 -349
  207. package/lib/plot/common/plot.js.map +0 -1
  208. package/lib/plot/dot.js +0 -110
  209. package/lib/plot/dot.js.map +0 -1
  210. package/lib/plot/line.js +0 -140
  211. package/lib/plot/line.js.map +0 -1
  212. package/lib/tool-menu.js +0 -106
  213. package/lib/tool-menu.js.map +0 -1
  214. package/lib/utils.js +0 -189
  215. package/lib/utils.js.map +0 -1
  216. package/src/__tests__/actions-button.test.jsx +0 -280
  217. package/src/__tests__/axes.test.jsx +0 -667
  218. package/src/__tests__/chart-setup.test.jsx +0 -532
  219. package/src/__tests__/chart-type.test.jsx +0 -23
  220. package/src/__tests__/chart.test.jsx +0 -86
  221. package/src/__tests__/grid.test.jsx +0 -37
  222. package/src/__tests__/key-legend.test.jsx +0 -223
  223. package/src/__tests__/mark-label.test.jsx +0 -33
  224. package/src/__tests__/tool-menu.test.jsx +0 -522
  225. package/src/__tests__/utils.js +0 -36
  226. package/src/__tests__/utils.test.js +0 -100
  227. package/src/actions-button.jsx +0 -115
  228. package/src/axes.jsx +0 -594
  229. package/src/bars/__tests__/bar.test.jsx +0 -45
  230. package/src/bars/__tests__/histogram.test.jsx +0 -45
  231. package/src/bars/__tests__/utils.js +0 -30
  232. package/src/bars/bar.js +0 -28
  233. package/src/bars/common/__tests__/bars.test.jsx +0 -68
  234. package/src/bars/common/__tests__/utils.js +0 -30
  235. package/src/bars/common/bars.jsx +0 -249
  236. package/src/bars/common/correct-check-icon.jsx +0 -25
  237. package/src/bars/histogram.js +0 -28
  238. package/src/chart-setup.jsx +0 -356
  239. package/src/chart-type.js +0 -59
  240. package/src/chart-types.js +0 -8
  241. package/src/chart.jsx +0 -357
  242. package/src/common/__tests__/correctness-indicators.test.jsx +0 -720
  243. package/src/common/__tests__/drag-handle.test.jsx +0 -58
  244. package/src/common/__tests__/utils.js +0 -30
  245. package/src/common/correctness-indicators.jsx +0 -128
  246. package/src/common/drag-handle.jsx +0 -125
  247. package/src/common/drag-icon.jsx +0 -36
  248. package/src/common/styles.js +0 -19
  249. package/src/grid.jsx +0 -80
  250. package/src/index.js +0 -7
  251. package/src/key-legend.jsx +0 -77
  252. package/src/line/__tests__/line-cross.test.jsx +0 -463
  253. package/src/line/__tests__/line-dot.test.jsx +0 -41
  254. package/src/line/__tests__/utils.js +0 -36
  255. package/src/line/common/__tests__/drag-handle.test.jsx +0 -62
  256. package/src/line/common/__tests__/line.test.jsx +0 -79
  257. package/src/line/common/__tests__/utils.js +0 -30
  258. package/src/line/common/drag-handle.jsx +0 -114
  259. package/src/line/common/line.jsx +0 -171
  260. package/src/line/line-cross.js +0 -144
  261. package/src/line/line-dot.js +0 -111
  262. package/src/mark-label.jsx +0 -238
  263. package/src/plot/__tests__/dot.test.jsx +0 -344
  264. package/src/plot/__tests__/line.test.jsx +0 -375
  265. package/src/plot/__tests__/utils.js +0 -30
  266. package/src/plot/common/__tests__/plot.test.jsx +0 -69
  267. package/src/plot/common/__tests__/utils.js +0 -30
  268. package/src/plot/common/plot.jsx +0 -358
  269. package/src/plot/dot.js +0 -74
  270. package/src/plot/line.js +0 -98
  271. package/src/tool-menu.jsx +0 -85
  272. package/src/utils.js +0 -201
@@ -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,114 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import PropTypes from 'prop-types';
4
- import { styled } from '@mui/material/styles';
5
-
6
- import { gridDraggable, types, utils } from '@pie-lib/plot';
7
- import { color } from '@pie-lib/render-ui';
8
- import { disabled } from '../../common/styles';
9
-
10
- const StyledDragHandle = styled('g')(({ theme }) => ({
11
- color: 'black',
12
- '& .handle': {
13
- transition: 'fill 200ms linear, height 200ms linear',
14
- '&.non-interactive': disabled('fill'),
15
- },
16
- '& .transparentHandle': {
17
- height: '20px',
18
- fill: 'transparent',
19
- stroke: 'transparent',
20
- },
21
- '& .line': {
22
- stroke: color.defaults.TEXT,
23
- transition: 'fill 200ms linear, height 200ms linear',
24
- '&.non-interactive': disabled('stroke'),
25
- },
26
- '& .disabledPoint': {
27
- fill: color.defaults.BLACK + ' !important',
28
- stroke: color.defaults.BLACK + ' !important',
29
- },
30
- '& .correctIcon': {
31
- backgroundColor: color.correct(),
32
- },
33
- '& .incorrectIcon': {
34
- backgroundColor: color.incorrectWithIcon(),
35
- },
36
- '& .correctnessIcon': {
37
- borderRadius: theme.spacing(2),
38
- color: color.defaults.WHITE,
39
- fontSize: '16px',
40
- width: '16px',
41
- height: '16px',
42
- padding: '2px',
43
- border: `1px solid ${color.defaults.WHITE}`,
44
- stroke: 'initial',
45
- boxSizing: 'unset', // to override the default border-box in IBX
46
- },
47
- '& .smallIcon': {
48
- fontSize: '10px',
49
- width: '10px',
50
- height: '10px',
51
- },
52
- }));
53
-
54
- class RawDragHandle extends React.Component {
55
- static propTypes = {
56
- x: PropTypes.number.isRequired,
57
- y: PropTypes.number.isRequired,
58
- width: PropTypes.number,
59
- graphProps: types.GraphPropsType.isRequired,
60
- className: PropTypes.string,
61
- interactive: PropTypes.bool,
62
- CustomDraggableComponent: PropTypes.func,
63
- correctness: PropTypes.shape({
64
- value: PropTypes.string,
65
- label: PropTypes.string,
66
- }),
67
- };
68
-
69
- render() {
70
- const { x, y, graphProps, className, interactive, CustomDraggableComponent, correctness, ...rest } = this.props;
71
- const { scale } = graphProps;
72
-
73
- if (!CustomDraggableComponent) {
74
- return null;
75
- }
76
-
77
- return (
78
- <StyledDragHandle>
79
- <CustomDraggableComponent
80
- scale={scale}
81
- x={x}
82
- y={y}
83
- className={classNames(className, !interactive && 'non-interactive')}
84
- correctness={correctness}
85
- interactive={interactive}
86
- {...rest}
87
- />
88
- </StyledDragHandle>
89
- );
90
- }
91
- }
92
-
93
- export const DragHandle = RawDragHandle;
94
-
95
- const DraggableHandle = gridDraggable({
96
- axis: 'y',
97
- fromDelta: (props, delta) => {
98
- //TODO: should be in grid-draggable, if axis is y delta.x should always be 0.
99
- delta.x = 0;
100
- const newPoint = utils.point(props).add(utils.point(delta));
101
-
102
- return newPoint.y;
103
- },
104
- bounds: (props, { domain, range }) => {
105
- const area = { left: 0, top: props.y, bottom: props.y, right: 0 };
106
-
107
- return utils.bounds(area, domain, range);
108
- },
109
- anchorPoint: (props) => {
110
- return { x: props.x, y: props.y };
111
- },
112
- })(DragHandle);
113
-
114
- export default DraggableHandle;
@@ -1,171 +0,0 @@
1
- import React from 'react';
2
- import { Group } from '@visx/group';
3
- import { LinePath } from '@visx/shape';
4
- import PropTypes from 'prop-types';
5
- import { types } from '@pie-lib/plot';
6
- import DraggableHandle, { DragHandle } from './drag-handle';
7
- import { styled } from '@mui/material/styles';
8
- import { isEqual } from 'lodash-es';
9
- import { color } from '@pie-lib/render-ui';
10
-
11
- const getData = (data, domain) => {
12
- const { max } = domain || {};
13
- const length = data.length;
14
-
15
- if (!max || !length) {
16
- return [];
17
- }
18
-
19
- return data.map((el, i) => ({
20
- ...el,
21
- x: length > 1 ? i * (max / (length - 1)) : 0.5,
22
- y: el.value,
23
- }));
24
- };
25
-
26
- const StyledLinePath = styled(LinePath)(() => ({
27
- fill: 'transparent',
28
- stroke: color.defaults.TERTIARY,
29
- strokeWidth: 3,
30
- transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
31
- }));
32
-
33
- export class RawLine extends React.Component {
34
- static propTypes = {
35
- onChange: PropTypes.func,
36
- value: PropTypes.number,
37
- label: PropTypes.string,
38
- xBand: PropTypes.func,
39
- index: PropTypes.number.isRequired,
40
- graphProps: types.GraphPropsType.isRequired,
41
- defineChart: PropTypes.bool,
42
- data: PropTypes.arrayOf(
43
- PropTypes.shape({
44
- label: PropTypes.string,
45
- value: PropTypes.number,
46
- }),
47
- ),
48
- CustomDraggableComponent: PropTypes.func,
49
- correctData: PropTypes.array,
50
- };
51
-
52
- static defaultProps = {
53
- index: 0,
54
- };
55
-
56
- constructor(props) {
57
- super(props);
58
- this.state = {
59
- dragValue: undefined,
60
- line: getData(props.data, props.graphProps.domain),
61
- };
62
- }
63
-
64
- UNSAFE_componentWillReceiveProps(nextProps) {
65
- if (!isEqual(this.props.data, nextProps.data)) {
66
- this.setState({
67
- line: getData(nextProps.data, nextProps.graphProps.domain),
68
- });
69
- }
70
- }
71
-
72
- setDragValue = (line) => this.setState({ line });
73
-
74
- dragStop = (index) => {
75
- const { onChange } = this.props;
76
- this.setState({ dragging: false }, () => {
77
- onChange(index, this.state.line[index]);
78
- });
79
- };
80
-
81
- dragValue = (index, existing, next) => {
82
- const newLine = [...this.state.line];
83
- newLine[index].dragValue = next;
84
- this.setDragValue(newLine);
85
- };
86
-
87
- render() {
88
- const { graphProps, data, CustomDraggableComponent, defineChart, correctData } = this.props;
89
- const { line: lineState, dragging } = this.state;
90
- const { scale } = graphProps;
91
- const lineToUse = dragging ? lineState : getData(data, graphProps.domain);
92
-
93
- return (
94
- <React.Fragment>
95
- <StyledLinePath
96
- data={lineToUse}
97
- x={(d) => scale.x(d.x)}
98
- y={(d) => scale.y(d.dragValue !== undefined ? d.dragValue : d.y)}
99
- className="line"
100
- />
101
- {lineToUse &&
102
- lineToUse.map((point, i) => {
103
- const r = 6;
104
- const enableDraggable = defineChart || point.interactive;
105
- const Component = enableDraggable ? DraggableHandle : DragHandle;
106
-
107
- return (
108
- <Component
109
- key={`point-${point.x}-${i}`}
110
- x={point.x}
111
- y={point.dragValue !== undefined ? point.dragValue : point.y}
112
- interactive={enableDraggable}
113
- r={r}
114
- onDragStart={() => this.setState({ dragging: true })}
115
- onDrag={(v) => this.dragValue(i, point.dragValue !== undefined ? point.dragValue : point.y, v)}
116
- onDragStop={() => this.dragStop(i)}
117
- graphProps={graphProps}
118
- CustomDraggableComponent={CustomDraggableComponent}
119
- correctness={point.correctness}
120
- correctData={correctData}
121
- label={point.label}
122
- />
123
- );
124
- })}
125
- </React.Fragment>
126
- );
127
- }
128
- }
129
-
130
- const StyledLine = styled(RawLine)(() => ({
131
- '& .line': {
132
- fill: 'transparent',
133
- stroke: color.defaults.TERTIARY,
134
- strokeWidth: 3,
135
- transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
136
- },
137
- }));
138
-
139
- export class Line extends React.Component {
140
- static propTypes = {
141
- data: PropTypes.array,
142
- onChange: PropTypes.func,
143
- xBand: PropTypes.func,
144
- graphProps: types.GraphPropsType.isRequired,
145
- CustomDraggableComponent: PropTypes.func,
146
- defineChart: PropTypes.bool,
147
- correctData: PropTypes.array,
148
- };
149
-
150
- changeLine = (index, category) => {
151
- const { onChange } = this.props;
152
- const newLine = [...this.props.data];
153
- const { dragValue, value } = category;
154
-
155
- newLine[index].value = dragValue >= 0 ? dragValue : value;
156
-
157
- onChange(newLine);
158
- };
159
-
160
- render() {
161
- const props = this.props;
162
-
163
- return (
164
- <Group>
165
- <StyledLine {...props} onChange={this.changeLine} />
166
- </Group>
167
- );
168
- }
169
- }
170
-
171
- export default Line;
@@ -1,144 +0,0 @@
1
- import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { LinePath } from '@visx/shape';
4
- import { Group } from '@visx/group';
5
- import { styled } from '@mui/material/styles';
6
-
7
- import { color } from '@pie-lib/render-ui';
8
- import { dataToXBand } from '../utils';
9
- import { types } from '@pie-lib/plot';
10
- import RawLine from './common/line';
11
- import { CorrectnessIndicator, SmallCorrectPointIndicator } from '../common/correctness-indicators';
12
-
13
- const StyledLinePath = styled(LinePath)(() => ({
14
- stroke: color.defaults.TEXT,
15
- transition: 'fill 200ms linear, height 200ms linear',
16
- '&.non-interactive': {
17
- stroke: color.disabled?.() || '#ccc',
18
- },
19
- }));
20
-
21
- const StyledGroup = styled(Group)(({ correctness, interactive }) => ({
22
- stroke: color.defaults.TEXT,
23
- transition: 'fill 200ms linear, height 200ms linear',
24
- ...(correctness &&
25
- !interactive && {
26
- fill: `${color.defaults.BLACK} !important`,
27
- stroke: `${color.defaults.BLACK} !important`,
28
- }),
29
- '&.non-interactive': {
30
- stroke: color.disabled?.() || '#ccc',
31
- },
32
- }));
33
-
34
- const StyledTransparentHandle = styled('circle')(() => ({
35
- height: '20px',
36
- fill: 'transparent',
37
- stroke: 'transparent',
38
- }));
39
-
40
- const DraggableComponent = (props) => {
41
- const { className, scale, x, y, r, correctness, interactive, correctData, label, ...rest } = props;
42
- const [hover, setHover] = useState(false);
43
-
44
- const squareSize = r * 4;
45
- const squareHalf = squareSize / 2;
46
- const cx = scale.x(x);
47
- const cy = scale.y(y);
48
-
49
- return (
50
- <StyledGroup className={className} correctness={correctness} interactive={interactive}>
51
- <StyledLinePath
52
- data={[
53
- { x: scale.x(x) - r, y: scale.y(y) + r },
54
- { x: scale.x(x) + r, y: scale.y(y) - r },
55
- ]}
56
- key={`point-${x}-${y}-1`}
57
- x={(d) => d.x}
58
- y={(d) => d.y}
59
- strokeWidth={5}
60
- style={{ pointerEvents: 'none' }}
61
- />
62
- <StyledLinePath
63
- data={[
64
- { x: scale.x(x) - r, y: scale.y(y) - r },
65
- { x: scale.x(x) + r, y: scale.y(y) + r },
66
- ]}
67
- key={`point-${x}-${y}-2`}
68
- x={(d) => d.x}
69
- y={(d) => d.y}
70
- strokeWidth={5}
71
- style={{ pointerEvents: 'none' }}
72
- />
73
- {hover && (
74
- <rect
75
- x={cx - squareHalf}
76
- y={cy - squareHalf}
77
- width={squareSize}
78
- height={squareSize}
79
- stroke={color.defaults.BORDER_GRAY}
80
- fill="none"
81
- strokeWidth={2}
82
- pointerEvents="none"
83
- />
84
- )}
85
- <StyledTransparentHandle
86
- cx={cx}
87
- cy={cy}
88
- r={r * 2}
89
- onMouseEnter={() => setHover(true)}
90
- onMouseLeave={() => setHover(false)}
91
- {...rest}
92
- />
93
- {/* show correctness indicators */}
94
- <CorrectnessIndicator scale={scale} x={x} y={y} r={r} correctness={correctness} interactive={interactive} />
95
- {/* show correct point if answer was incorrect */}
96
- <SmallCorrectPointIndicator
97
- scale={scale}
98
- x={x}
99
- r={r}
100
- correctness={correctness}
101
- correctData={correctData}
102
- label={label}
103
- />
104
- </StyledGroup>
105
- );
106
- };
107
-
108
- DraggableComponent.propTypes = {
109
- scale: PropTypes.object,
110
- x: PropTypes.number,
111
- y: PropTypes.number,
112
- r: PropTypes.number,
113
- className: PropTypes.string,
114
- correctness: PropTypes.shape({
115
- value: PropTypes.string,
116
- label: PropTypes.string,
117
- }),
118
- interactive: PropTypes.bool,
119
- correctData: PropTypes.array,
120
- label: PropTypes.string,
121
- };
122
-
123
- export class LineCross extends React.Component {
124
- static propTypes = {
125
- data: PropTypes.array,
126
- onChange: PropTypes.func,
127
- graphProps: types.GraphPropsType.isRequired,
128
- };
129
-
130
- render() {
131
- const props = this.props;
132
- const { data, graphProps } = props;
133
- const { scale = {}, size = {} } = graphProps || {};
134
- const xBand = dataToXBand(scale.x, data, size.width, 'lineCross');
135
-
136
- return <RawLine {...props} xBand={xBand} CustomDraggableComponent={DraggableComponent} />;
137
- }
138
- }
139
-
140
- export default () => ({
141
- type: 'lineCross',
142
- Component: LineCross,
143
- name: 'Line Cross',
144
- });
@@ -1,111 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
-
5
- import { types } from '@pie-lib/plot';
6
- import { color } from '@pie-lib/render-ui';
7
- import { dataToXBand } from '../utils';
8
- import RawLine from './common/line';
9
- import { CorrectnessIndicator, SmallCorrectPointIndicator } from '../common/correctness-indicators';
10
-
11
- const StyledHandle = styled('circle')(() => ({}));
12
-
13
- const StyledTransparentHandle = styled('circle')(() => ({
14
- height: '20px',
15
- fill: 'transparent', // keep it invisible
16
- stroke: 'none',
17
- pointerEvents: 'auto', // allow drag events
18
- }));
19
-
20
- const DraggableComponent = ({ scale, x, y, r, correctness, interactive, correctData, label, ...rest }) => {
21
- const [isHovered, setIsHovered] = React.useState(false);
22
- const allowRolloverEvent = !correctness && interactive;
23
-
24
- return (
25
- <g
26
- onMouseEnter={() => setIsHovered(true)}
27
- onMouseLeave={() => setIsHovered(false)}
28
- onTouchStart={() => setIsHovered(true)}
29
- onTouchEnd={() => setIsHovered(false)}
30
- >
31
- <StyledTransparentHandle
32
- cx={scale.x(x)}
33
- cy={scale.y(y)}
34
- r={r * 3}
35
- onMouseEnter={() => setIsHovered(true)}
36
- onMouseLeave={() => setIsHovered(false)}
37
- {...rest}
38
- />
39
- <StyledHandle
40
- cx={scale.x(x)}
41
- cy={scale.y(y)}
42
- r={r}
43
- correctness={correctness}
44
- interactive={interactive}
45
- {...rest}
46
- />
47
- {/* show correctness indicators */}
48
- <CorrectnessIndicator scale={scale} x={x} y={y} r={r} correctness={correctness} interactive={interactive} />
49
-
50
- {/* show correct point if answer was incorrect */}
51
- <SmallCorrectPointIndicator
52
- scale={scale}
53
- x={x}
54
- r={r}
55
- correctness={correctness}
56
- correctData={correctData}
57
- label={label}
58
- />
59
-
60
- {/* show rollover rectangle */}
61
- {isHovered && allowRolloverEvent && (
62
- <rect
63
- x={scale.x(x) - r * 2}
64
- y={scale.y(y) - r * 2}
65
- width={r * 4}
66
- height={r * 4}
67
- stroke={color.defaults.BORDER_GRAY}
68
- strokeWidth="1"
69
- fill="none"
70
- />
71
- )}
72
- </g>
73
- );
74
- };
75
-
76
- DraggableComponent.propTypes = {
77
- scale: PropTypes.object,
78
- x: PropTypes.number,
79
- y: PropTypes.number,
80
- r: PropTypes.number,
81
- correctness: PropTypes.shape({
82
- value: PropTypes.string,
83
- label: PropTypes.string,
84
- }),
85
- interactive: PropTypes.bool,
86
- correctData: PropTypes.array,
87
- label: PropTypes.string,
88
- };
89
-
90
- export class LineDot extends React.Component {
91
- static propTypes = {
92
- data: PropTypes.array,
93
- onChange: PropTypes.func,
94
- graphProps: types.GraphPropsType.isRequired,
95
- };
96
-
97
- render() {
98
- const props = this.props;
99
- const { data, graphProps } = props;
100
- const { scale = {}, size = {} } = graphProps || {};
101
- const xBand = dataToXBand(scale.x, data, size.width, 'lineDot');
102
-
103
- return <RawLine {...props} xBand={xBand} CustomDraggableComponent={DraggableComponent} />;
104
- }
105
- }
106
-
107
- export default () => ({
108
- type: 'lineDot',
109
- Component: LineDot,
110
- name: 'Line Dot',
111
- });