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

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.18.1/node_modules/lodash/_Hash.js +21 -0
  104. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +21 -0
  105. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +10 -0
  106. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +21 -0
  107. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +9 -0
  108. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +14 -0
  109. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +15 -0
  110. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +16 -0
  111. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +9 -0
  112. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +8 -0
  113. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +14 -0
  114. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +15 -0
  115. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +19 -0
  116. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +11 -0
  117. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +13 -0
  118. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +12 -0
  119. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +18 -0
  120. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +14 -0
  121. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +14 -0
  122. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +12 -0
  123. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +16 -0
  124. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +11 -0
  125. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +14 -0
  126. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +14 -0
  127. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +13 -0
  128. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +14 -0
  129. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +19 -0
  130. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +14 -0
  131. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +13 -0
  132. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +13 -0
  133. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +14 -0
  134. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +9 -0
  135. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +12 -0
  136. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +10 -0
  137. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +20 -0
  138. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +11 -0
  139. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +16 -0
  140. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +12 -0
  141. package/dist/node_modules/.bun/lodash@4.18.1/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,358 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import Check from '@mui/icons-material/Check';
4
- import { styled } from '@mui/material/styles';
5
- import { Group } from '@visx/group';
6
- import debug from 'debug';
7
-
8
- import { types } from '@pie-lib/plot';
9
- import DraggableHandle, { DragHandle } from '../../common/drag-handle';
10
- import { color } from '@pie-lib/render-ui';
11
- import { bandKey } from '../../utils';
12
- import { correct, incorrect } from '../../common/styles';
13
-
14
- const log = debug('pie-lib:chart:bars');
15
- const ICON_SIZE = 16; // 10px icon + 2px padding on all sides + 1px border
16
-
17
- export class RawPlot extends React.Component {
18
- static propTypes = {
19
- onChangeCategory: PropTypes.func,
20
- value: PropTypes.number,
21
- label: PropTypes.string,
22
- xBand: PropTypes.func,
23
- index: PropTypes.number.isRequired,
24
- graphProps: types.GraphPropsType.isRequired,
25
- CustomBarElement: PropTypes.func,
26
- interactive: PropTypes.bool,
27
- correctness: PropTypes.shape({
28
- value: PropTypes.string,
29
- label: PropTypes.string,
30
- }),
31
- defineChart: PropTypes.bool,
32
- correctData: PropTypes.arrayOf(
33
- PropTypes.shape({
34
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
35
- label: PropTypes.string,
36
- }),
37
- ),
38
- className: PropTypes.string,
39
- };
40
-
41
- constructor(props) {
42
- super(props);
43
- this.state = {
44
- dragValue: undefined,
45
- isHovered: false,
46
- };
47
- }
48
-
49
- handleMouseEnter = () => {
50
- this.setState({ isHovered: true });
51
- };
52
-
53
- handleMouseLeave = () => {
54
- this.setState({ isHovered: false });
55
- };
56
-
57
- setDragValue = (dragValue) => this.setState({ dragValue });
58
-
59
- dragStop = () => {
60
- const { label, onChangeCategory } = this.props;
61
- const { dragValue } = this.state;
62
- log('[dragStop]', dragValue);
63
-
64
- if (dragValue !== undefined) {
65
- onChangeCategory({ label, value: dragValue });
66
- }
67
-
68
- this.setDragValue(undefined);
69
- };
70
-
71
- dragValue = (existing, next) => {
72
- log('[dragValue] next:', next);
73
-
74
- this.setDragValue(next);
75
- };
76
-
77
- renderCorrectnessIcon = (barX, barWidth, correctVal, correctness, scale, pointHeight, pointDiameter) => {
78
- let iconY;
79
-
80
- if (correctVal === 0) {
81
- // if correct value is 0, position icon on the horizontal axis
82
- iconY = scale.y(0) - ICON_SIZE / 2;
83
- } else {
84
- const shapeIndex = correctVal - 1; // the index of the shape representing the correct value
85
- const shapeCenterY = scale.y(shapeIndex) - (pointHeight - pointDiameter) / 2 - pointDiameter / 2;
86
- iconY = shapeCenterY - ICON_SIZE / 2; // center the icon
87
- }
88
-
89
- return (
90
- <foreignObject x={barX + barWidth / 2 - ICON_SIZE / 2} y={iconY} width={ICON_SIZE} height={ICON_SIZE}>
91
- <Check className="correctnessIcon correctIcon smallIcon" title={correctness.label} />
92
- </foreignObject>
93
- );
94
- };
95
-
96
- render() {
97
- const {
98
- graphProps,
99
- value,
100
- label,
101
- xBand,
102
- index,
103
- CustomBarElement,
104
- interactive,
105
- correctness,
106
- defineChart,
107
- correctData,
108
- className,
109
- } = this.props;
110
-
111
- const { scale, range, size } = graphProps;
112
- const { max } = range || {};
113
- const { dragValue, isHovered } = this.state;
114
-
115
- const v = Number.isFinite(dragValue) ? dragValue : value;
116
- const barWidth = xBand.bandwidth();
117
- const barHeight = scale.y(range.max - v);
118
- const barX = xBand(bandKey({ label }, index));
119
-
120
- log('label:', label, 'barX:', barX, 'v: ', v, 'barHeight:', barHeight, 'barWidth: ', barWidth);
121
-
122
- const values = [];
123
-
124
- for (let i = 0; i < v; i++) {
125
- values.push(i);
126
- }
127
-
128
- const pointHeight = size.height / max;
129
- const pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;
130
- const Component = interactive ? DraggableHandle : DragHandle;
131
- const allowRolloverEvent = interactive && !correctness;
132
-
133
- return (
134
- <React.Fragment>
135
- <g
136
- className={className}
137
- onMouseEnter={this.handleMouseEnter}
138
- onMouseLeave={this.handleMouseLeave}
139
- onTouchStart={this.handleMouseEnter}
140
- onTouchEnd={this.handleMouseLeave}
141
- >
142
- {isHovered && allowRolloverEvent && (
143
- <rect
144
- x={barX}
145
- y={scale.y(v)}
146
- width={barWidth}
147
- height={values?.length ? pointHeight * values.length : 0}
148
- stroke={color.defaults.BORDER_GRAY}
149
- strokeWidth={'4px'}
150
- fill={'transparent'}
151
- />
152
- )}
153
- {values.map((index) =>
154
- CustomBarElement({
155
- index,
156
- pointDiameter,
157
- barX,
158
- barWidth,
159
- pointHeight,
160
- label,
161
- value,
162
- scale,
163
- }),
164
- )}
165
- {correctness &&
166
- correctness.value === 'incorrect' &&
167
- (() => {
168
- const correctVal = parseFloat(correctData[index] && correctData[index].value);
169
- if (isNaN(correctVal)) return null;
170
- const selectedVal = v;
171
-
172
- // special case: if correct value is 0, only show the icon on the axis
173
- if (correctVal === 0) {
174
- return this.renderCorrectnessIcon(
175
- barX,
176
- barWidth,
177
- correctVal,
178
- correctness,
179
- scale,
180
- pointHeight,
181
- pointDiameter,
182
- );
183
- }
184
-
185
- if (selectedVal > correctVal) {
186
- // selected is higher than correct: overlay the correct last segment
187
- const overlayValues = [];
188
- for (let i = 0; i < correctVal; i++) {
189
- overlayValues.push(i);
190
- }
191
- const lastIndexOfOverlay = overlayValues.length - 1;
192
- const lastOverlayValue = overlayValues[lastIndexOfOverlay];
193
- const barX = xBand(bandKey({ label }, index));
194
- const barWidth = xBand.bandwidth();
195
- const pointHeight = size.height / max;
196
- const pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;
197
- return (
198
- <>
199
- <CustomBarElement
200
- index={lastOverlayValue}
201
- pointDiameter={pointDiameter + 10} // increase point diameter for dotted line
202
- barX={barX}
203
- barWidth={barWidth}
204
- pointHeight={pointHeight}
205
- label={label}
206
- value={value}
207
- scale={scale}
208
- dottedOverline={true}
209
- />
210
- {this.renderCorrectnessIcon(
211
- barX,
212
- barWidth,
213
- correctVal,
214
- correctness,
215
- scale,
216
- pointHeight,
217
- pointDiameter,
218
- )}
219
- </>
220
- );
221
- }
222
- // selected is lower than correct, render missing segment below the correct bar
223
- const valuesToRender = [];
224
- for (let i = selectedVal; i < correctVal; i++) {
225
- valuesToRender.push(i);
226
- }
227
- return (
228
- <>
229
- {valuesToRender.map((idx) =>
230
- CustomBarElement({
231
- index: idx,
232
- pointDiameter,
233
- barX,
234
- barWidth,
235
- pointHeight,
236
- label,
237
- value,
238
- scale,
239
- dottedOverline: true,
240
- }),
241
- )}
242
- {this.renderCorrectnessIcon(
243
- barX,
244
- barWidth,
245
- correctVal,
246
- correctness,
247
- scale,
248
- pointHeight,
249
- pointDiameter,
250
- )}
251
- </>
252
- );
253
- })()}
254
- <Component
255
- x={barX}
256
- y={v}
257
- interactive={interactive}
258
- width={barWidth}
259
- onDrag={(v) => this.dragValue(value, v)}
260
- onDragStop={this.dragStop}
261
- graphProps={graphProps}
262
- correctness={correctness}
263
- isHovered={isHovered}
264
- defineChart={defineChart}
265
- color={color.primaryDark()}
266
- isPlot
267
- />
268
- </g>
269
- </React.Fragment>
270
- );
271
- }
272
- }
273
-
274
- const Bar = styled(RawPlot)(({ theme }) => ({
275
- '& .dot': {
276
- fill: color.visualElementsColors.PLOT_FILL_COLOR,
277
- '&.correct': correct('stroke'),
278
- '&.incorrect': incorrect('stroke'),
279
- },
280
- '& .dotColor': {
281
- fill: color.visualElementsColors.PLOT_FILL_COLOR,
282
- '&.correct': correct('fill'),
283
- '&.incorrect': incorrect('fill'),
284
- },
285
- '& .line': {
286
- stroke: color.visualElementsColors.PLOT_FILL_COLOR,
287
- '&.correct': correct('stroke'),
288
- '&.incorrect': incorrect('stroke'),
289
- },
290
- '& .correctIcon': {
291
- backgroundColor: color.correct(),
292
- },
293
- '& .incorrectIcon': {
294
- backgroundColor: color.incorrectWithIcon(),
295
- },
296
- '& .correctnessIcon': {
297
- borderRadius: theme.spacing(2),
298
- color: color.defaults.WHITE,
299
- fontSize: '16px',
300
- width: '16px',
301
- height: '16px',
302
- padding: '2px',
303
- border: `1px solid ${color.defaults.WHITE}`,
304
- stroke: 'initial',
305
- boxSizing: 'unset', // to override the default border-box in IBX
306
- display: 'block',
307
- },
308
- '& .smallIcon': {
309
- fontSize: '10px',
310
- width: '10px',
311
- height: '10px',
312
- },
313
- }));
314
-
315
- export class Plot extends React.Component {
316
- static propTypes = {
317
- data: PropTypes.array,
318
- onChangeCategory: PropTypes.func,
319
- xBand: PropTypes.func,
320
- graphProps: types.GraphPropsType.isRequired,
321
- defineChart: PropTypes.bool,
322
- CustomBarElement: PropTypes.func,
323
- correctData: PropTypes.arrayOf(
324
- PropTypes.shape({
325
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
326
- label: PropTypes.string,
327
- }),
328
- ),
329
- className: PropTypes.string,
330
- };
331
-
332
- render() {
333
- const { data, graphProps, xBand, CustomBarElement, onChangeCategory, defineChart, correctData } = this.props;
334
-
335
- return (
336
- <Group>
337
- {(data || []).map((d, index) => (
338
- <Bar
339
- value={d.value}
340
- label={d.label}
341
- interactive={defineChart || d.interactive}
342
- defineChart={defineChart}
343
- xBand={xBand}
344
- index={index}
345
- key={`bar-${d.label}-${d.value}-${index}`}
346
- onChangeCategory={(category) => onChangeCategory(index, category)}
347
- graphProps={graphProps}
348
- CustomBarElement={CustomBarElement}
349
- correctness={d.correctness}
350
- correctData={correctData}
351
- />
352
- ))}
353
- </Group>
354
- );
355
- }
356
- }
357
-
358
- export default Plot;
package/src/plot/dot.js DELETED
@@ -1,74 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Circle } from '@visx/shape';
4
-
5
- import { types } from '@pie-lib/plot';
6
- import { dataToXBand } from '../utils';
7
- import Plot from './common/plot';
8
- import { color } from '@pie-lib/render-ui';
9
- import { styled } from '@mui/material/styles';
10
- import { correct, incorrect } from '../common/styles';
11
-
12
- const StyledCircle = styled(Circle)(() => ({
13
- fill: color.visualElementsColors.PLOT_FILL_COLOR,
14
- '&.correct': correct('stroke'),
15
- '&.incorrect': incorrect('stroke'),
16
- }));
17
-
18
- const CustomBarElement = (props) => {
19
- const { index, pointDiameter, barX, barWidth, pointHeight, label, value, scale, dottedOverline } = props;
20
-
21
- const r = pointDiameter / 2;
22
- const cx = barX + (barWidth - pointDiameter) / 2 + r;
23
- const cy = scale.y(index) - (pointHeight - pointDiameter) / 2 - r;
24
- const EXTRA_PADDING = 2;
25
-
26
- return dottedOverline ? (
27
- <Circle
28
- key={`point-${label}-${value}-${index}`}
29
- cx={cx}
30
- cy={cy}
31
- r={r + EXTRA_PADDING}
32
- strokeDasharray="4,4"
33
- stroke={color.defaults.BORDER_GRAY}
34
- fill="none"
35
- />
36
- ) : (
37
- <StyledCircle key={`point-${label}-${value}-${index}`} cx={cx} cy={cy} r={r} />
38
- );
39
- };
40
-
41
- CustomBarElement.propTypes = {
42
- index: PropTypes.number,
43
- pointDiameter: PropTypes.number,
44
- barX: PropTypes.number,
45
- barWidth: PropTypes.number,
46
- pointHeight: PropTypes.number,
47
- value: PropTypes.number,
48
- label: PropTypes.string,
49
- scale: PropTypes.object,
50
- dottedOverline: PropTypes.bool,
51
- };
52
-
53
- export class DotPlot extends React.Component {
54
- static propTypes = {
55
- data: PropTypes.array,
56
- onChange: PropTypes.func,
57
- graphProps: types.GraphPropsType.isRequired,
58
- };
59
-
60
- render() {
61
- const props = this.props;
62
- const { data, graphProps } = props;
63
- const { scale = {}, size = {} } = graphProps || {};
64
- const xBand = dataToXBand(scale.x, data, size.width, 'dotPlot');
65
-
66
- return <Plot {...props} xBand={xBand} CustomBarElement={CustomBarElement} />;
67
- }
68
- }
69
-
70
- export default () => ({
71
- type: 'dotPlot',
72
- Component: DotPlot,
73
- name: 'Dot Plot',
74
- });
package/src/plot/line.js DELETED
@@ -1,98 +0,0 @@
1
- import React 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 { types } from '@pie-lib/plot';
8
- import { dataToXBand } from '../utils';
9
- import { color } from '@pie-lib/render-ui';
10
- import Plot from './common/plot';
11
- import { correct, incorrect } from '../common/styles';
12
-
13
- const StyledLinePath = styled(LinePath)(() => ({
14
- stroke: color.visualElementsColors.PLOT_FILL_COLOR,
15
- '&.correct': correct('stroke'),
16
- '&.incorrect': incorrect('stroke'),
17
- }));
18
-
19
- const CustomBarElement = (props) => {
20
- const { index, pointDiameter, barX, barWidth, pointHeight, label, value, scale, dottedOverline } = props;
21
-
22
- const x = barX + (barWidth - pointDiameter) / 2;
23
- const y = scale.y(index) - (pointHeight - pointDiameter) / 2;
24
- const EXTRA_PADDING = 2;
25
-
26
- return dottedOverline ? (
27
- <rect
28
- key={`point-${label}-${value}-${index}`}
29
- x={x - EXTRA_PADDING}
30
- y={y - pointDiameter - EXTRA_PADDING}
31
- width={pointDiameter + EXTRA_PADDING * 2}
32
- height={pointDiameter + EXTRA_PADDING * 2}
33
- strokeDasharray="4,4"
34
- stroke={color.defaults.BORDER_GRAY}
35
- fill="none"
36
- />
37
- ) : (
38
- <Group>
39
- <StyledLinePath
40
- data={[
41
- { x, y },
42
- { x: x + pointDiameter, y: y - pointDiameter },
43
- ]}
44
- key={`point-${label}-${value}-${index}-1`}
45
- className={'line'}
46
- x={(d) => d.x}
47
- y={(d) => d.y}
48
- strokeWidth={pointDiameter / 5}
49
- />
50
- <StyledLinePath
51
- data={[
52
- { x, y: y - pointDiameter },
53
- { x: x + pointDiameter, y },
54
- ]}
55
- key={`point-${label}-${value}-${index}-2`}
56
- x={(d) => d.x}
57
- y={(d) => d.y}
58
- strokeWidth={pointDiameter / 5}
59
- className={'line'}
60
- />
61
- </Group>
62
- );
63
- };
64
-
65
- CustomBarElement.propTypes = {
66
- index: PropTypes.number,
67
- pointDiameter: PropTypes.number,
68
- barX: PropTypes.number,
69
- barWidth: PropTypes.number,
70
- pointHeight: PropTypes.number,
71
- value: PropTypes.number,
72
- label: PropTypes.string,
73
- scale: PropTypes.object,
74
- dottedOverline: PropTypes.bool,
75
- };
76
-
77
- export class LinePlot extends React.Component {
78
- static propTypes = {
79
- data: PropTypes.array,
80
- onChange: PropTypes.func,
81
- graphProps: types.GraphPropsType.isRequired,
82
- };
83
-
84
- render() {
85
- const props = this.props;
86
- const { data, graphProps } = props;
87
- const { scale = {}, size = {} } = graphProps || {};
88
- const xBand = dataToXBand(scale.x, data, size.width, 'linePlot');
89
-
90
- return <Plot {...props} xBand={xBand} CustomBarElement={CustomBarElement} />;
91
- }
92
- }
93
-
94
- export default () => ({
95
- type: 'linePlot',
96
- Component: LinePlot,
97
- name: 'Line Plot',
98
- });
package/src/tool-menu.jsx DELETED
@@ -1,85 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { color } from '@pie-lib/render-ui';
4
-
5
- import { styled } from '@mui/material/styles';
6
- import Button from '@mui/material/Button';
7
- import Translator from '@pie-lib/translator';
8
-
9
- const { translator } = Translator;
10
-
11
- const StyledMiniButton = styled(Button)(({ theme, selected, disabled }) => ({
12
- color: color.text(),
13
- border: `1px solid ${color.secondary()}`,
14
- fontSize: theme.typography.fontSize,
15
- ...(selected && {
16
- backgroundColor: color.background(),
17
- '& span': {
18
- color: color.primaryDark(),
19
- },
20
- }),
21
- ...(!selected &&
22
- !disabled && {
23
- '& span': {
24
- color: color.primary(),
25
- },
26
- backgroundColor: color.background(),
27
- }),
28
- ...(disabled && {
29
- '& span': {
30
- color: color.primary(),
31
- },
32
- backgroundColor: color.disabled(),
33
- }),
34
- }));
35
-
36
- export const MiniButton = (props) => {
37
- const { disabled, selected, value, onClick } = props;
38
-
39
- return (
40
- <StyledMiniButton
41
- size="small"
42
- disabled={disabled}
43
- selected={selected}
44
- color={selected ? 'secondary' : 'default'}
45
- value={value}
46
- key={value}
47
- variant="outlined"
48
- onClick={onClick}
49
- >
50
- {value}
51
- </StyledMiniButton>
52
- );
53
- };
54
- MiniButton.propTypes = {
55
- disabled: PropTypes.bool,
56
- className: PropTypes.string,
57
- selected: PropTypes.bool,
58
- value: PropTypes.string,
59
- onClick: PropTypes.func,
60
- };
61
-
62
- export class ToolMenu extends React.Component {
63
- static propTypes = {
64
- className: PropTypes.string,
65
- addCategory: PropTypes.func,
66
- disabled: PropTypes.bool,
67
- language: PropTypes.string,
68
- };
69
-
70
- static defaultProps = {};
71
-
72
- render() {
73
- const { className, disabled, addCategory, language } = this.props;
74
-
75
- return (
76
- <div className={className}>
77
- {!disabled && (
78
- <MiniButton value={translator.t('charting.addCategory', { lng: language })} onClick={addCategory} />
79
- )}
80
- </div>
81
- );
82
- }
83
- }
84
-
85
- export default ToolMenu;