@pie-lib/charting 7.0.3-next.3 → 7.0.4-next.0

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 (269) 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/axes.d.ts +84 -0
  5. package/dist/axes.js +376 -0
  6. package/dist/bars/bar.d.ts +47 -0
  7. package/dist/bars/bar.js +27 -0
  8. package/dist/bars/common/bars.d.ts +98 -0
  9. package/dist/bars/common/bars.js +174 -0
  10. package/dist/bars/common/correct-check-icon.d.ts +18 -0
  11. package/dist/bars/common/correct-check-icon.js +50 -0
  12. package/dist/bars/histogram.d.ts +47 -0
  13. package/dist/bars/histogram.js +28 -0
  14. package/dist/chart-setup.d.ts +29 -0
  15. package/dist/chart-setup.js +231 -0
  16. package/dist/chart-type.d.ts +32 -0
  17. package/dist/chart-type.js +68 -0
  18. package/dist/chart-types.d.ts +41 -0
  19. package/dist/chart-types.js +17 -0
  20. package/dist/chart.d.ts +88 -0
  21. package/dist/chart.js +250 -0
  22. package/dist/common/correctness-indicators.d.ts +70 -0
  23. package/dist/common/correctness-indicators.js +106 -0
  24. package/dist/common/drag-handle.d.ts +129 -0
  25. package/dist/common/drag-handle.js +120 -0
  26. package/dist/common/drag-icon.d.ts +23 -0
  27. package/dist/common/drag-icon.js +45 -0
  28. package/dist/common/styles.d.ts +23 -0
  29. package/dist/common/styles.js +17 -0
  30. package/dist/grid.d.ts +45 -0
  31. package/dist/grid.js +56 -0
  32. package/dist/index.d.ts +14 -0
  33. package/dist/index.js +6 -0
  34. package/dist/key-legend.d.ts +19 -0
  35. package/dist/key-legend.js +46 -0
  36. package/dist/line/common/drag-handle.d.ts +120 -0
  37. package/dist/line/common/drag-handle.js +92 -0
  38. package/dist/line/common/line.d.ts +96 -0
  39. package/dist/line/common/line.js +114 -0
  40. package/dist/line/line-cross.d.ts +47 -0
  41. package/dist/line/line-cross.js +133 -0
  42. package/dist/line/line-dot.d.ts +47 -0
  43. package/dist/line/line-dot.js +101 -0
  44. package/dist/mark-label.d.ts +55 -0
  45. package/dist/mark-label.js +139 -0
  46. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +100 -0
  47. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisBottom.js +45 -0
  48. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +46 -0
  49. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +61 -0
  50. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +42 -0
  51. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
  52. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
  53. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +21 -0
  54. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
  55. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
  56. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +15 -0
  57. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +79 -0
  58. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +79 -0
  59. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
  60. package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +49 -0
  61. package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +18 -0
  62. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/align.js +6 -0
  63. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
  64. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
  65. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
  66. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
  67. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
  68. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
  69. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
  70. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
  71. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
  72. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
  73. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
  74. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +58 -0
  75. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
  76. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
  77. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
  78. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +9 -0
  79. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
  80. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +29 -0
  81. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +9 -0
  82. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +7 -0
  83. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
  84. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Bar.js +28 -0
  85. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +28 -0
  86. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +46 -0
  87. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +49 -0
  88. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
  89. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
  90. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +52 -0
  91. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +57 -0
  92. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +91 -0
  93. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +21 -0
  94. package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
  95. package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
  96. package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +8 -0
  97. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
  98. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
  99. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Hash.js +21 -0
  100. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +21 -0
  101. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +10 -0
  102. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +21 -0
  103. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +9 -0
  104. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +14 -0
  105. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +15 -0
  106. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +16 -0
  107. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +9 -0
  108. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +8 -0
  109. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +14 -0
  110. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +15 -0
  111. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +19 -0
  112. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +11 -0
  113. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +13 -0
  114. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +12 -0
  115. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +18 -0
  116. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +14 -0
  117. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +14 -0
  118. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +12 -0
  119. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +16 -0
  120. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +11 -0
  121. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +14 -0
  122. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +14 -0
  123. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +13 -0
  124. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +14 -0
  125. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +19 -0
  126. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +14 -0
  127. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +13 -0
  128. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +13 -0
  129. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +14 -0
  130. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +9 -0
  131. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +12 -0
  132. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +10 -0
  133. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +20 -0
  134. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +11 -0
  135. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +16 -0
  136. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +12 -0
  137. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/memoize.js +20 -0
  138. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
  139. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
  140. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
  141. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
  142. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
  143. package/dist/node_modules/.bun/react-input-autosize@2.2.2_f4eacebf2041cd4f/node_modules/react-input-autosize/lib/AutosizeInput.js +216 -0
  144. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
  145. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
  146. package/dist/plot/common/plot.d.ts +103 -0
  147. package/dist/plot/common/plot.js +227 -0
  148. package/dist/plot/dot.d.ts +47 -0
  149. package/dist/plot/dot.js +62 -0
  150. package/dist/plot/line.d.ts +47 -0
  151. package/dist/plot/line.js +84 -0
  152. package/dist/tool-menu.d.ts +31 -0
  153. package/dist/utils.d.ts +39 -0
  154. package/dist/utils.js +101 -0
  155. package/package.json +35 -25
  156. package/CHANGELOG.json +0 -17
  157. package/CHANGELOG.md +0 -1110
  158. package/LICENSE.md +0 -5
  159. package/lib/actions-button.js +0 -145
  160. package/lib/actions-button.js.map +0 -1
  161. package/lib/axes.js +0 -643
  162. package/lib/axes.js.map +0 -1
  163. package/lib/bars/bar.js +0 -58
  164. package/lib/bars/bar.js.map +0 -1
  165. package/lib/bars/common/bars.js +0 -277
  166. package/lib/bars/common/bars.js.map +0 -1
  167. package/lib/bars/common/correct-check-icon.js +0 -54
  168. package/lib/bars/common/correct-check-icon.js.map +0 -1
  169. package/lib/bars/histogram.js +0 -59
  170. package/lib/bars/histogram.js.map +0 -1
  171. package/lib/chart-setup.js +0 -382
  172. package/lib/chart-setup.js.map +0 -1
  173. package/lib/chart-type.js +0 -80
  174. package/lib/chart-type.js.map +0 -1
  175. package/lib/chart-types.js +0 -22
  176. package/lib/chart-types.js.map +0 -1
  177. package/lib/chart.js +0 -384
  178. package/lib/chart.js.map +0 -1
  179. package/lib/common/correctness-indicators.js +0 -156
  180. package/lib/common/correctness-indicators.js.map +0 -1
  181. package/lib/common/drag-handle.js +0 -160
  182. package/lib/common/drag-handle.js.map +0 -1
  183. package/lib/common/drag-icon.js +0 -52
  184. package/lib/common/drag-icon.js.map +0 -1
  185. package/lib/common/styles.js +0 -22
  186. package/lib/common/styles.js.map +0 -1
  187. package/lib/grid.js +0 -101
  188. package/lib/grid.js.map +0 -1
  189. package/lib/index.js +0 -42
  190. package/lib/index.js.map +0 -1
  191. package/lib/key-legend.js +0 -87
  192. package/lib/key-legend.js.map +0 -1
  193. package/lib/line/common/drag-handle.js +0 -146
  194. package/lib/line/common/drag-handle.js.map +0 -1
  195. package/lib/line/common/line.js +0 -214
  196. package/lib/line/common/line.js.map +0 -1
  197. package/lib/line/line-cross.js +0 -214
  198. package/lib/line/line-cross.js.map +0 -1
  199. package/lib/line/line-dot.js +0 -158
  200. package/lib/line/line-dot.js.map +0 -1
  201. package/lib/mark-label.js +0 -237
  202. package/lib/mark-label.js.map +0 -1
  203. package/lib/plot/common/plot.js +0 -349
  204. package/lib/plot/common/plot.js.map +0 -1
  205. package/lib/plot/dot.js +0 -110
  206. package/lib/plot/dot.js.map +0 -1
  207. package/lib/plot/line.js +0 -140
  208. package/lib/plot/line.js.map +0 -1
  209. package/lib/tool-menu.js +0 -106
  210. package/lib/tool-menu.js.map +0 -1
  211. package/lib/utils.js +0 -189
  212. package/lib/utils.js.map +0 -1
  213. package/src/__tests__/actions-button.test.jsx +0 -280
  214. package/src/__tests__/axes.test.jsx +0 -667
  215. package/src/__tests__/chart-setup.test.jsx +0 -532
  216. package/src/__tests__/chart-type.test.jsx +0 -23
  217. package/src/__tests__/chart.test.jsx +0 -86
  218. package/src/__tests__/grid.test.jsx +0 -37
  219. package/src/__tests__/key-legend.test.jsx +0 -223
  220. package/src/__tests__/mark-label.test.jsx +0 -33
  221. package/src/__tests__/tool-menu.test.jsx +0 -522
  222. package/src/__tests__/utils.js +0 -36
  223. package/src/__tests__/utils.test.js +0 -100
  224. package/src/actions-button.jsx +0 -115
  225. package/src/axes.jsx +0 -594
  226. package/src/bars/__tests__/bar.test.jsx +0 -45
  227. package/src/bars/__tests__/histogram.test.jsx +0 -45
  228. package/src/bars/__tests__/utils.js +0 -30
  229. package/src/bars/bar.js +0 -28
  230. package/src/bars/common/__tests__/bars.test.jsx +0 -68
  231. package/src/bars/common/__tests__/utils.js +0 -30
  232. package/src/bars/common/bars.jsx +0 -249
  233. package/src/bars/common/correct-check-icon.jsx +0 -25
  234. package/src/bars/histogram.js +0 -28
  235. package/src/chart-setup.jsx +0 -356
  236. package/src/chart-type.js +0 -59
  237. package/src/chart-types.js +0 -8
  238. package/src/chart.jsx +0 -357
  239. package/src/common/__tests__/correctness-indicators.test.jsx +0 -720
  240. package/src/common/__tests__/drag-handle.test.jsx +0 -58
  241. package/src/common/__tests__/utils.js +0 -30
  242. package/src/common/correctness-indicators.jsx +0 -128
  243. package/src/common/drag-handle.jsx +0 -125
  244. package/src/common/drag-icon.jsx +0 -36
  245. package/src/common/styles.js +0 -19
  246. package/src/grid.jsx +0 -68
  247. package/src/index.js +0 -7
  248. package/src/key-legend.jsx +0 -77
  249. package/src/line/__tests__/line-cross.test.jsx +0 -463
  250. package/src/line/__tests__/line-dot.test.jsx +0 -41
  251. package/src/line/__tests__/utils.js +0 -36
  252. package/src/line/common/__tests__/drag-handle.test.jsx +0 -62
  253. package/src/line/common/__tests__/line.test.jsx +0 -79
  254. package/src/line/common/__tests__/utils.js +0 -30
  255. package/src/line/common/drag-handle.jsx +0 -114
  256. package/src/line/common/line.jsx +0 -171
  257. package/src/line/line-cross.js +0 -144
  258. package/src/line/line-dot.js +0 -111
  259. package/src/mark-label.jsx +0 -238
  260. package/src/plot/__tests__/dot.test.jsx +0 -344
  261. package/src/plot/__tests__/line.test.jsx +0 -375
  262. package/src/plot/__tests__/utils.js +0 -30
  263. package/src/plot/common/__tests__/plot.test.jsx +0 -69
  264. package/src/plot/common/__tests__/utils.js +0 -30
  265. package/src/plot/common/plot.jsx +0 -358
  266. package/src/plot/dot.js +0 -74
  267. package/src/plot/line.js +0 -98
  268. package/src/tool-menu.jsx +0 -85
  269. package/src/utils.js +0 -201
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@pie-lib/test-utils';
3
- import Bar, { Bar as BarChart } from '../bar';
4
- import { graphProps } from './utils';
5
-
6
- describe('BarChart', () => {
7
- const renderComponent = (extras) => {
8
- const defaults = {
9
- classes: {},
10
- className: 'className',
11
- graphProps: graphProps(),
12
- xBand: () => {
13
- return {
14
- bandwidth: () => {},
15
- };
16
- },
17
- };
18
- const props = { ...defaults, ...extras };
19
- return render(<BarChart {...props} />);
20
- };
21
-
22
- describe('rendering', () => {
23
- it('renders bar chart', () => {
24
- const { container } = renderComponent();
25
- expect(container.firstChild).toBeInTheDocument();
26
- });
27
-
28
- it('renders without graphProps', () => {
29
- const { container } = renderComponent({ graphProps: undefined });
30
- expect(container.firstChild).toBeInTheDocument();
31
- });
32
- });
33
-
34
- describe('component', () => {
35
- it('returns correct chart object', () => {
36
- const chart = Bar();
37
-
38
- expect(chart).toEqual({
39
- type: 'bar',
40
- Component: BarChart,
41
- name: 'Bar',
42
- });
43
- });
44
- });
45
- });
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@pie-lib/test-utils';
3
- import Histogram, { Histogram as HistogramChart } from '../histogram';
4
- import { graphProps } from './utils';
5
-
6
- describe('HistogramChart', () => {
7
- const renderComponent = (extras) => {
8
- const defaults = {
9
- classes: {},
10
- className: 'className',
11
- graphProps: graphProps(),
12
- xBand: () => {
13
- return {
14
- bandwidth: () => {},
15
- };
16
- },
17
- };
18
- const props = { ...defaults, ...extras };
19
- return render(<HistogramChart {...props} />);
20
- };
21
-
22
- describe('rendering', () => {
23
- it('renders histogram chart', () => {
24
- const { container } = renderComponent();
25
- expect(container.firstChild).toBeInTheDocument();
26
- });
27
-
28
- it('renders without graphProps', () => {
29
- const { container } = renderComponent({ graphProps: undefined });
30
- expect(container.firstChild).toBeInTheDocument();
31
- });
32
- });
33
-
34
- describe('component', () => {
35
- it('returns correct chart object', () => {
36
- const chart = Histogram();
37
-
38
- expect(chart).toEqual({
39
- type: 'histogram',
40
- Component: HistogramChart,
41
- name: 'Histogram',
42
- });
43
- });
44
- });
45
- });
@@ -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
- });
package/src/bars/bar.js DELETED
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { types } from '@pie-lib/plot';
4
- import { dataToXBand } from '../utils';
5
- import Bars from './common/bars';
6
-
7
- export class Bar extends React.Component {
8
- static propTypes = {
9
- data: PropTypes.array,
10
- onChange: PropTypes.func,
11
- graphProps: types.GraphPropsType.isRequired,
12
- };
13
-
14
- render() {
15
- const props = this.props;
16
- const { data, graphProps } = props;
17
- const { scale = {}, size = {} } = graphProps || {};
18
- const xBand = dataToXBand(scale.x, data, size.width, 'bar');
19
-
20
- return <Bars {...props} xBand={xBand} />;
21
- }
22
- }
23
-
24
- export default () => ({
25
- type: 'bar',
26
- Component: Bar,
27
- name: 'Bar',
28
- });
@@ -1,68 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import Bars, { RawBar } from '../bars';
4
- import { graphProps } from './utils';
5
-
6
- describe('Bars', () => {
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(<Bars {...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('RawBar', () => {
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
- };
47
- const props = { ...defaults, ...extras };
48
- return render(<RawBar {...props} />);
49
- };
50
-
51
- describe('rendering', () => {
52
- it('renders without crashing', () => {
53
- const { container } = renderComponent();
54
- expect(container.firstChild).toBeInTheDocument();
55
- });
56
- });
57
-
58
- describe('functionality', () => {
59
- it('calls onChangeCategory when drag completes with a value', () => {
60
- const { container } = renderComponent();
61
- // Testing drag functionality requires interaction - the component should
62
- // call onChangeCategory when a drag operation completes with a new value
63
- // This would typically be tested through user interactions rather than
64
- // directly calling instance methods
65
- expect(container.firstChild).toBeInTheDocument();
66
- });
67
- });
68
- });
@@ -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,249 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Group } from '@visx/group';
4
- import { Bar as VisxBar } from '@visx/shape';
5
- import { styled } from '@mui/material/styles';
6
- import debug from 'debug';
7
-
8
- import { color } from '@pie-lib/render-ui';
9
- import { types } from '@pie-lib/plot';
10
- import { bandKey } from '../../utils';
11
- import DraggableHandle, { DragHandle } from '../../common/drag-handle';
12
- import { CorrectCheckIcon } from './correct-check-icon';
13
-
14
- const log = debug('pie-lib:chart:bars');
15
- const histogramColors = [
16
- '#006699',
17
- '#F59B00',
18
- '#08916D',
19
- '#529EE0',
20
- '#52B7D8',
21
- '#D9A6C2',
22
- '#FFB03B',
23
- '#54A77B',
24
- '#E16032',
25
- '#4FD2D2',
26
- '#F0E442',
27
- '#E287B2',
28
- ];
29
- const hoverHistogramColors = [
30
- '#003754',
31
- '#975616',
32
- '#00503B',
33
- '#225982',
34
- '#1F687D',
35
- '#825E6F',
36
- '#996428',
37
- '#255E44',
38
- '#8A331F',
39
- '#167A7A',
40
- '#91862D',
41
- '#894A65',
42
- ];
43
-
44
- const calculateFillColor = (isHovered, barColor, index, hoverHistogramColors, allowRolloverEvent) => {
45
- if (isHovered && barColor && allowRolloverEvent) {
46
- return hoverHistogramColors[index % hoverHistogramColors.length];
47
- }
48
- if (isHovered && allowRolloverEvent) {
49
- return color.visualElementsColors.ROLLOVER_FILL_BAR_COLOR;
50
- }
51
- return barColor || null;
52
- };
53
-
54
- const StyledVisxBar = styled(VisxBar)(() => ({
55
- fill: color.defaults.TERTIARY,
56
- }));
57
-
58
- export class RawBar extends React.Component {
59
- static propTypes = {
60
- barColor: PropTypes.string,
61
- onChangeCategory: PropTypes.func,
62
- value: PropTypes.number,
63
- label: PropTypes.string,
64
- xBand: PropTypes.func,
65
- index: PropTypes.number.isRequired,
66
- graphProps: types.GraphPropsType.isRequired,
67
- interactive: PropTypes.bool,
68
- correctness: PropTypes.shape({
69
- value: PropTypes.string,
70
- label: PropTypes.string,
71
- }),
72
- correctData: PropTypes.array,
73
- defineChart: PropTypes.bool,
74
- };
75
-
76
- constructor(props) {
77
- super(props);
78
- this.state = {
79
- dragValue: undefined,
80
- isHovered: false,
81
- };
82
- this.mouseX = 0;
83
- this.mouseY = 0;
84
- }
85
-
86
- componentDidMount() {
87
- window.addEventListener('mousemove', this.handleMouseMove);
88
- }
89
-
90
- componentWillUnmount() {
91
- window.removeEventListener('mousemove', this.handleMouseMove);
92
- }
93
-
94
- handleMouseMove = (e) => {
95
- this.mouseX = e.clientX;
96
- this.mouseY = e.clientY;
97
- const isMouseInside = this.isMouseInsideSvgElement();
98
- this.setState({ isHovered: isMouseInside });
99
- };
100
-
101
- isMouseInsideSvgElement = () => {
102
- const gBoundingBox = this.gRef.getBoundingClientRect();
103
- return (
104
- this.mouseX >= gBoundingBox.left &&
105
- this.mouseX <= gBoundingBox.right &&
106
- this.mouseY >= gBoundingBox.top &&
107
- this.mouseY <= gBoundingBox.bottom
108
- );
109
- };
110
-
111
- handleMouseEnter = () => this.setState({ isHovered: true });
112
- handleMouseLeave = () => this.setState({ isHovered: false });
113
-
114
- setDragValue = (dragValue) => this.setState({ dragValue });
115
-
116
- dragStop = () => {
117
- const { label, onChangeCategory } = this.props;
118
- const { dragValue } = this.state;
119
- log('[dragStop]', dragValue);
120
-
121
- if (dragValue !== undefined) {
122
- onChangeCategory({ label, value: dragValue });
123
- }
124
-
125
- this.setDragValue(undefined);
126
- };
127
-
128
- dragValue = (existing, next) => {
129
- log('[dragValue] next:', next);
130
-
131
- this.setDragValue(next);
132
- };
133
-
134
- render() {
135
- const { graphProps, value, label, xBand, index, interactive, correctness, barColor, defineChart, correctData } =
136
- this.props;
137
- const { scale, range } = graphProps;
138
- const { dragValue, isHovered } = this.state;
139
-
140
- const allowRolloverEvent = interactive && !correctness;
141
- const fillColor = calculateFillColor(isHovered, barColor, index, hoverHistogramColors, allowRolloverEvent);
142
- const v = Number.isFinite(dragValue) ? dragValue : value;
143
- const barWidth = xBand.bandwidth();
144
- const barHeight = scale.y(range.max - v);
145
- const barX = xBand(bandKey({ label }, index));
146
- const rawY = range.max - v;
147
- const yy = range.max - rawY;
148
- const correctValue = correctData ? correctData.find((d) => d.label === label) : null;
149
-
150
- const Component = interactive ? DraggableHandle : DragHandle;
151
- const isHistogram = !!barColor;
152
-
153
- return (
154
- <g
155
- ref={(ref) => (this.gRef = ref)}
156
- onMouseEnter={this.handleMouseEnter}
157
- onMouseLeave={this.handleMouseLeave}
158
- onTouchStart={this.handleMouseEnter}
159
- onTouchEnd={this.handleMouseLeave}
160
- >
161
- <StyledVisxBar x={barX} y={scale.y(yy)} width={barWidth} height={barHeight} style={{ fill: fillColor }} />
162
- {correctness &&
163
- correctness.value === 'incorrect' &&
164
- (() => {
165
- const correctVal = parseFloat(correctValue && correctValue.value);
166
- if (isNaN(correctVal)) return null;
167
- const correctPxHeight = scale.y(range.max - correctVal);
168
- const actualPxHeight = barHeight;
169
- const diffPx = Math.abs(correctPxHeight - actualPxHeight);
170
- const yDiff = scale.y(correctVal);
171
- const indicatorBarColor = correctPxHeight > actualPxHeight ? color.borderGray() : color.defaults.WHITE;
172
- const yToRender = correctPxHeight > actualPxHeight ? yDiff : yDiff - diffPx;
173
-
174
- return (
175
- <>
176
- <StyledVisxBar
177
- x={barX + 2}
178
- y={yToRender}
179
- width={barWidth - 4}
180
- height={diffPx}
181
- style={{ stroke: indicatorBarColor, strokeWidth: 2, strokeDasharray: '5,2', fill: 'none' }}
182
- />
183
- <foreignObject x={barX + barWidth - (isHistogram ? 24 : 14)} y={yDiff - 12} width={24} height={24}>
184
- <CorrectCheckIcon dashColor={indicatorBarColor} />
185
- </foreignObject>
186
- </>
187
- );
188
- })()}
189
- <Component
190
- x={barX}
191
- y={v}
192
- defineChart={defineChart}
193
- interactive={interactive}
194
- width={barWidth}
195
- onDrag={(v) => this.dragValue(value, v)}
196
- onDragStop={this.dragStop}
197
- graphProps={graphProps}
198
- correctness={correctness}
199
- isHovered={isHovered}
200
- color={fillColor}
201
- />
202
- </g>
203
- );
204
- }
205
- }
206
-
207
- const Bar = RawBar;
208
-
209
- export class Bars extends React.Component {
210
- static propTypes = {
211
- data: PropTypes.array,
212
- correctData: PropTypes.array,
213
- onChangeCategory: PropTypes.func,
214
- defineChart: PropTypes.bool,
215
- xBand: PropTypes.func,
216
- graphProps: types.GraphPropsType.isRequired,
217
- histogram: PropTypes.bool,
218
- };
219
-
220
- render() {
221
- const { data, graphProps, xBand, onChangeCategory, defineChart, histogram, correctData } = this.props;
222
-
223
- return (
224
- <Group>
225
- {(data || []).map((d, index) => (
226
- <Bar
227
- value={d.value}
228
- interactive={defineChart || d.interactive}
229
- defineChart={defineChart}
230
- label={d.label}
231
- xBand={xBand}
232
- index={index}
233
- key={`bar-${d.label}-${d.value}-${index}`}
234
- onChangeCategory={(category) => onChangeCategory(index, category)}
235
- graphProps={graphProps}
236
- correctness={d.correctness}
237
- correctData={correctData}
238
- barColor={
239
- histogram &&
240
- (histogramColors[index] ? histogramColors[index] : histogramColors[index % histogramColors.length])
241
- }
242
- />
243
- ))}
244
- </Group>
245
- );
246
- }
247
- }
248
-
249
- export default Bars;
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- export const CorrectCheckIcon = ({ dashColor }) => (
5
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
6
- <circle cx="12" cy="12" r="11" fill="white" stroke={dashColor || '#7E8494'} strokeWidth="2" strokeDasharray="5 5" />
7
- <mask id="path-2-outside-1_3089_3799" maskUnits="userSpaceOnUse" x="2" y="3" width="19" height="18" fill="black">
8
- <rect fill="white" x="2" y="3" width="19" height="18" />
9
- <path d="M12 20C9.125 20 6.5 18.5 5.0625 16C3.625 13.5312 3.625 10.5 5.0625 8C6.5 5.53125 9.125 4 12 4C14.8438 4 17.4688 5.53125 18.9062 8C20.3438 10.5 20.3438 13.5312 18.9062 16C17.4688 18.5 14.8438 20 12 20ZM15.5312 10.5312H15.5C15.8125 10.25 15.8125 9.78125 15.5 9.46875C15.2188 9.1875 14.75 9.1875 14.4688 9.46875L11 12.9688L9.53125 11.5C9.21875 11.1875 8.75 11.1875 8.46875 11.5C8.15625 11.7812 8.15625 12.25 8.46875 12.5312L10.4688 14.5312C10.75 14.8438 11.2188 14.8438 11.5312 14.5312L15.5312 10.5312Z" />
10
- </mask>
11
- <path
12
- d="M12 20C9.125 20 6.5 18.5 5.0625 16C3.625 13.5312 3.625 10.5 5.0625 8C6.5 5.53125 9.125 4 12 4C14.8438 4 17.4688 5.53125 18.9062 8C20.3438 10.5 20.3438 13.5312 18.9062 16C17.4688 18.5 14.8438 20 12 20ZM15.5312 10.5312H15.5C15.8125 10.25 15.8125 9.78125 15.5 9.46875C15.2188 9.1875 14.75 9.1875 14.4688 9.46875L11 12.9688L9.53125 11.5C9.21875 11.1875 8.75 11.1875 8.46875 11.5C8.15625 11.7812 8.15625 12.25 8.46875 12.5312L10.4688 14.5312C10.75 14.8438 11.2188 14.8438 11.5312 14.5312L15.5312 10.5312Z"
13
- fill="#0EA449"
14
- />
15
- <path
16
- d="M5.0625 16L5.92942 15.5015L5.92668 15.4968L5.0625 16ZM5.0625 8L4.19831 7.4968L4.19559 7.50153L5.0625 8ZM18.9062 8L19.7732 7.50152L19.7704 7.49681L18.9062 8ZM18.9062 16L18.0421 15.4968L18.0393 15.5015L18.9062 16ZM15.5312 10.5312L16.2384 11.2384L17.9455 9.53125H15.5312V10.5312ZM15.5 10.5312L14.831 9.78796L12.894 11.5312H15.5V10.5312ZM14.4688 9.46875L13.7616 8.76164L13.7585 8.76482L14.4688 9.46875ZM11 12.9688L10.2929 13.6759L11.0032 14.3861L11.7103 13.6727L11 12.9688ZM8.46875 11.5L9.13771 12.2433L9.17684 12.2081L9.21204 12.169L8.46875 11.5ZM8.46875 12.5312L9.17586 11.8241L9.15726 11.8055L9.13771 11.788L8.46875 12.5312ZM10.4688 14.5312L11.212 13.8623L11.1945 13.8427L11.1759 13.8241L10.4688 14.5312ZM12 20V19C9.479 19 7.18657 17.6879 5.92941 15.5015L5.0625 16L4.19559 16.4985C5.81343 19.3121 8.771 21 12 21V20ZM5.0625 16L5.92668 15.4968C4.6714 13.341 4.66824 10.6918 5.92941 8.49847L5.0625 8L4.19559 7.50153C2.58176 10.3082 2.5786 13.7215 4.19832 16.5032L5.0625 16ZM5.0625 8L5.92668 8.50319C7.18712 6.33851 9.48502 5 12 5V4V3C8.76498 3 5.81288 4.72399 4.19832 7.49681L5.0625 8ZM12 4V5C14.4816 5 16.7805 6.33661 18.0421 8.50319L18.9062 8L19.7704 7.49681C18.157 4.72589 15.2059 3 12 3V4ZM18.9062 8L18.0393 8.49847C19.3005 10.6918 19.2973 13.341 18.0421 15.4968L18.9062 16L19.7704 16.5032C21.3902 13.7215 21.387 10.3082 19.7732 7.50153L18.9062 8ZM18.9062 16L18.0393 15.5015C16.7811 17.6898 14.4876 19 12 19V20V21C15.1999 21 18.1564 19.3102 19.7732 16.4985L18.9062 16ZM15.5312 10.5312V9.53125H15.5V10.5312V11.5312H15.5312V10.5312ZM15.5 10.5312L16.169 11.2745C16.9447 10.5764 16.8883 9.44281 16.2071 8.76164L15.5 9.46875L14.7929 10.1759C14.7696 10.1525 14.7344 10.0966 14.7344 10.0117C14.7344 9.92377 14.7735 9.83972 14.831 9.78796L15.5 10.5312ZM15.5 9.46875L16.2071 8.76164C15.5353 8.08987 14.4334 8.08987 13.7616 8.76164L14.4688 9.46875L15.1759 10.1759C15.1167 10.235 15.0442 10.2578 14.9844 10.2578C14.9245 10.2578 14.8521 10.235 14.7929 10.1759L15.5 9.46875ZM14.4688 9.46875L13.7585 8.76482L10.2897 12.2648L11 12.9688L11.7103 13.6727L15.179 10.1727L14.4688 9.46875ZM11 12.9688L11.7071 12.2616L10.2384 10.7929L9.53125 11.5L8.82414 12.2071L10.2929 13.6759L11 12.9688ZM9.53125 11.5L10.2384 10.7929C9.55719 10.1117 8.42362 10.0553 7.72546 10.831L8.46875 11.5L9.21204 12.169C9.16028 12.2265 9.07623 12.2656 8.98828 12.2656C8.90344 12.2656 8.84748 12.2304 8.82414 12.2071L9.53125 11.5ZM8.46875 11.5L7.79979 10.7567C7.04591 11.4352 7.04591 12.5961 7.79979 13.2745L8.46875 12.5312L9.13771 11.788C9.19301 11.8377 9.23438 11.9208 9.23438 12.0156C9.23438 12.1105 9.19301 12.1935 9.13771 12.2433L8.46875 11.5ZM8.46875 12.5312L7.76164 13.2384L9.76164 15.2384L10.4688 14.5312L11.1759 13.8241L9.17586 11.8241L8.46875 12.5312ZM10.4688 14.5312L9.72546 15.2002C10.4236 15.976 11.5572 15.9195 12.2384 15.2384L11.5312 14.5312L10.8241 13.8241C10.8475 13.8008 10.9034 13.7656 10.9883 13.7656C11.0762 13.7656 11.1603 13.8048 11.212 13.8623L10.4688 14.5312ZM11.5312 14.5312L12.2384 15.2384L16.2384 11.2384L15.5312 10.5312L14.8241 9.82414L10.8241 13.8241L11.5312 14.5312Z"
17
- fill="white"
18
- mask="url(#path-2-outside-1_3089_3799)"
19
- />
20
- </svg>
21
- );
22
-
23
- CorrectCheckIcon.propTypes = {
24
- dashColor: PropTypes.string,
25
- };
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { types } from '@pie-lib/plot';
4
- import { dataToXBand } from '../utils';
5
- import Bars from './common/bars';
6
-
7
- export class Histogram extends React.Component {
8
- static propTypes = {
9
- data: PropTypes.array,
10
- onChange: PropTypes.func,
11
- graphProps: types.GraphPropsType.isRequired,
12
- };
13
-
14
- render() {
15
- const props = this.props;
16
- const { data, graphProps } = props;
17
- const { scale = {}, size = {} } = graphProps || {};
18
- const xBand = dataToXBand(scale.x, data, size.width, 'histogram');
19
-
20
- return <Bars {...props} xBand={xBand} histogram={true} />;
21
- }
22
- }
23
-
24
- export default () => ({
25
- type: 'histogram',
26
- Component: Histogram,
27
- name: 'Histogram',
28
- });