@pie-lib/charting 7.1.0-beta.9 → 8.0.0-next.20261002094057

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 (202) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +20 -0
  2. package/dist/actions-button.d.ts +26 -0
  3. package/dist/actions-button.js +84 -0
  4. package/dist/autosize-input.d.ts +10 -0
  5. package/dist/autosize-input.js +66 -0
  6. package/dist/axes.d.ts +84 -0
  7. package/dist/axes.js +376 -0
  8. package/dist/bars/bar.d.ts +47 -0
  9. package/dist/bars/bar.js +27 -0
  10. package/dist/bars/common/bars.d.ts +98 -0
  11. package/dist/bars/common/bars.js +174 -0
  12. package/dist/bars/common/correct-check-icon.d.ts +18 -0
  13. package/dist/bars/common/correct-check-icon.js +50 -0
  14. package/dist/bars/histogram.d.ts +47 -0
  15. package/dist/bars/histogram.js +28 -0
  16. package/dist/chart-setup.d.ts +29 -0
  17. package/dist/chart-setup.js +231 -0
  18. package/dist/chart-type.d.ts +32 -0
  19. package/dist/chart-type.js +68 -0
  20. package/dist/chart-types.d.ts +41 -0
  21. package/dist/chart-types.js +17 -0
  22. package/dist/chart.d.ts +88 -0
  23. package/dist/chart.js +250 -0
  24. package/dist/common/correctness-indicators.d.ts +70 -0
  25. package/dist/common/correctness-indicators.js +106 -0
  26. package/dist/common/drag-handle.d.ts +129 -0
  27. package/dist/common/drag-handle.js +120 -0
  28. package/dist/common/drag-icon.d.ts +23 -0
  29. package/dist/common/drag-icon.js +45 -0
  30. package/dist/common/styles.d.ts +23 -0
  31. package/dist/common/styles.js +17 -0
  32. package/dist/grid.d.ts +45 -0
  33. package/dist/grid.js +56 -0
  34. package/dist/index.d.ts +14 -0
  35. package/dist/index.js +6 -0
  36. package/dist/key-legend.d.ts +19 -0
  37. package/dist/key-legend.js +46 -0
  38. package/dist/line/common/drag-handle.d.ts +120 -0
  39. package/dist/line/common/drag-handle.js +92 -0
  40. package/dist/line/common/line.d.ts +96 -0
  41. package/dist/line/common/line.js +114 -0
  42. package/dist/line/line-cross.d.ts +47 -0
  43. package/dist/line/line-cross.js +133 -0
  44. package/dist/line/line-dot.d.ts +47 -0
  45. package/dist/line/line-dot.js +101 -0
  46. package/dist/mark-label.d.ts +55 -0
  47. package/dist/mark-label.js +143 -0
  48. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Axis.js +67 -0
  49. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisBottom.js +29 -0
  50. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisLeft.js +30 -0
  51. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +66 -0
  52. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Ticks.js +39 -0
  53. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
  54. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
  55. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +13 -0
  56. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
  57. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
  58. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickPosition.js +14 -0
  59. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridColumns.js +46 -0
  60. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridRows.js +46 -0
  61. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
  62. package/dist/node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_modules/@visx/group/esm/Group.js +17 -0
  63. package/dist/node_modules/.bun/@visx_point@4.0.0/node_modules/@visx/point/esm/Point.js +20 -0
  64. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/align.js +6 -0
  65. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
  66. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
  67. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
  68. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
  69. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
  70. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
  71. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
  72. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
  73. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
  74. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
  75. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
  76. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +56 -0
  77. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
  78. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
  79. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
  80. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/scales/point.js +9 -0
  81. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
  82. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +29 -0
  83. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/getTicks.js +7 -0
  84. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +7 -0
  85. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
  86. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Bar.js +15 -0
  87. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Circle.js +15 -0
  88. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Line.js +27 -0
  89. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/LinePath.js +24 -0
  90. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
  91. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
  92. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/Text.js +27 -0
  93. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/hooks/useText.js +68 -0
  94. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/getStringWidth.js +19 -0
  95. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/memoize.js +13 -0
  96. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
  97. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
  98. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-shape.js +8 -0
  99. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-time.js +8 -0
  100. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
  101. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
  102. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
  103. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  104. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
  105. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
  106. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
  107. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
  108. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
  109. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
  110. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
  111. package/dist/plot/common/plot.d.ts +103 -0
  112. package/dist/plot/common/plot.js +227 -0
  113. package/dist/plot/dot.d.ts +47 -0
  114. package/dist/plot/dot.js +62 -0
  115. package/dist/plot/line.d.ts +47 -0
  116. package/dist/plot/line.js +84 -0
  117. package/dist/utils.d.ts +39 -0
  118. package/dist/utils.js +101 -0
  119. package/package.json +45 -36
  120. package/CHANGELOG.json +0 -17
  121. package/CHANGELOG.md +0 -1116
  122. package/lib/actions-button.js +0 -145
  123. package/lib/actions-button.js.map +0 -1
  124. package/lib/axes.js +0 -643
  125. package/lib/axes.js.map +0 -1
  126. package/lib/bars/bar.js +0 -58
  127. package/lib/bars/bar.js.map +0 -1
  128. package/lib/bars/common/bars.js +0 -277
  129. package/lib/bars/common/bars.js.map +0 -1
  130. package/lib/bars/common/correct-check-icon.js +0 -54
  131. package/lib/bars/common/correct-check-icon.js.map +0 -1
  132. package/lib/bars/histogram.js +0 -59
  133. package/lib/bars/histogram.js.map +0 -1
  134. package/lib/chart-setup.js +0 -382
  135. package/lib/chart-setup.js.map +0 -1
  136. package/lib/chart-type.js +0 -80
  137. package/lib/chart-type.js.map +0 -1
  138. package/lib/chart-types.js +0 -22
  139. package/lib/chart-types.js.map +0 -1
  140. package/lib/chart.js +0 -384
  141. package/lib/chart.js.map +0 -1
  142. package/lib/common/correctness-indicators.js +0 -156
  143. package/lib/common/correctness-indicators.js.map +0 -1
  144. package/lib/common/drag-handle.js +0 -160
  145. package/lib/common/drag-handle.js.map +0 -1
  146. package/lib/common/drag-icon.js +0 -52
  147. package/lib/common/drag-icon.js.map +0 -1
  148. package/lib/common/styles.js +0 -22
  149. package/lib/common/styles.js.map +0 -1
  150. package/lib/grid.js +0 -112
  151. package/lib/grid.js.map +0 -1
  152. package/lib/index.js +0 -42
  153. package/lib/index.js.map +0 -1
  154. package/lib/key-legend.js +0 -87
  155. package/lib/key-legend.js.map +0 -1
  156. package/lib/line/common/drag-handle.js +0 -146
  157. package/lib/line/common/drag-handle.js.map +0 -1
  158. package/lib/line/common/line.js +0 -214
  159. package/lib/line/common/line.js.map +0 -1
  160. package/lib/line/line-cross.js +0 -214
  161. package/lib/line/line-cross.js.map +0 -1
  162. package/lib/line/line-dot.js +0 -158
  163. package/lib/line/line-dot.js.map +0 -1
  164. package/lib/mark-label.js +0 -237
  165. package/lib/mark-label.js.map +0 -1
  166. package/lib/plot/common/plot.js +0 -349
  167. package/lib/plot/common/plot.js.map +0 -1
  168. package/lib/plot/dot.js +0 -110
  169. package/lib/plot/dot.js.map +0 -1
  170. package/lib/plot/line.js +0 -140
  171. package/lib/plot/line.js.map +0 -1
  172. package/lib/tool-menu.js +0 -106
  173. package/lib/tool-menu.js.map +0 -1
  174. package/lib/utils.js +0 -189
  175. package/lib/utils.js.map +0 -1
  176. package/src/actions-button.jsx +0 -115
  177. package/src/axes.jsx +0 -594
  178. package/src/bars/bar.js +0 -28
  179. package/src/bars/common/bars.jsx +0 -249
  180. package/src/bars/common/correct-check-icon.jsx +0 -25
  181. package/src/bars/histogram.js +0 -28
  182. package/src/chart-setup.jsx +0 -356
  183. package/src/chart-type.js +0 -59
  184. package/src/chart-types.js +0 -8
  185. package/src/chart.jsx +0 -357
  186. package/src/common/correctness-indicators.jsx +0 -128
  187. package/src/common/drag-handle.jsx +0 -125
  188. package/src/common/drag-icon.jsx +0 -36
  189. package/src/common/styles.js +0 -19
  190. package/src/grid.jsx +0 -80
  191. package/src/index.js +0 -7
  192. package/src/key-legend.jsx +0 -77
  193. package/src/line/common/drag-handle.jsx +0 -114
  194. package/src/line/common/line.jsx +0 -171
  195. package/src/line/line-cross.js +0 -144
  196. package/src/line/line-dot.js +0 -111
  197. package/src/mark-label.jsx +0 -238
  198. package/src/plot/common/plot.jsx +0 -358
  199. package/src/plot/dot.js +0 -74
  200. package/src/plot/line.js +0 -98
  201. package/src/tool-menu.jsx +0 -85
  202. package/src/utils.js +0 -201
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;
package/src/utils.js DELETED
@@ -1,201 +0,0 @@
1
- import { scaleBand, scalePoint } from '@visx/scale';
2
- import { utils } from '@pie-lib/plot';
3
-
4
- export const tickCount = utils.tickCount;
5
- export const bounds = utils.bounds;
6
- export const point = utils.point;
7
-
8
- export const bandKey = (d, index) => `${index}-${d.label || '-'}`;
9
-
10
- export const dataToXBand = (scaleX, data, width, type) => {
11
- const chartWidth = width || 400; // fallback
12
- const domain = data && data.length ? data.map(bandKey) : ['default'];
13
-
14
- switch (type) {
15
- case 'bar':
16
- case 'dotPlot':
17
- case 'linePlot':
18
- return scaleBand({
19
- range: [0, chartWidth],
20
- domain,
21
- padding: 0.2,
22
- });
23
-
24
- case 'histogram':
25
- return scaleBand({
26
- range: [0, chartWidth],
27
- domain,
28
- padding: 0,
29
- });
30
-
31
- case 'lineCross':
32
- case 'lineDot':
33
- return scalePoint({
34
- domain,
35
- range: [0, chartWidth],
36
- });
37
-
38
- default:
39
- return scaleBand({
40
- range: [0, chartWidth],
41
- domain,
42
- padding: 0,
43
- });
44
- }
45
- };
46
-
47
- export const getTickValues = (prop = {}) => {
48
- const tickValues = [];
49
- let tickVal = prop.min;
50
-
51
- while (tickVal <= prop.max) {
52
- tickValues.push(tickVal);
53
- tickVal = Math.round((tickVal + prop.step) * 10000) / 10000;
54
- }
55
-
56
- return tickValues;
57
- };
58
-
59
- export const getDomainAndRangeByChartType = (domain, range, chartType) => {
60
- let { step, labelStep, min, max } = range || {};
61
-
62
- if (!min) {
63
- min = 0;
64
- }
65
-
66
- if (!max || max < 0) {
67
- max = range.min + 1;
68
- }
69
-
70
- if (!step) {
71
- step = labelStep || 1;
72
- }
73
- if (!labelStep || (isNaN(labelStep) && step)) {
74
- labelStep = step || 1;
75
- }
76
-
77
- range.max = max;
78
-
79
- switch (chartType) {
80
- // if chart is dot plot or line plot, we should ignore step and make sure that min & max are integer values
81
- case 'dotPlot':
82
- case 'linePlot': {
83
- const intMin = Math.round(min);
84
- const intMax = Math.round(max);
85
-
86
- return {
87
- domain: {
88
- ...domain,
89
- step: 1,
90
- labelStep: 1,
91
- min: 0,
92
- max: 1,
93
- },
94
- range: {
95
- ...range,
96
- min: intMin,
97
- max: intMin === intMax ? intMin + 1 : intMax,
98
- labelStep,
99
- step: 1,
100
- },
101
- };
102
- }
103
-
104
- default:
105
- return {
106
- domain: {
107
- ...domain,
108
- step: 1,
109
- labelStep: 1,
110
- min: 0,
111
- max: 1,
112
- },
113
- range: {
114
- ...range,
115
- labelStep,
116
- step,
117
- },
118
- };
119
- }
120
- };
121
-
122
- export const getGridLinesAndAxisByChartType = (range, chartType) => {
123
- switch (chartType) {
124
- case 'lineDot':
125
- case 'lineCross':
126
- return {
127
- verticalLines: undefined,
128
- horizontalLines: getTickValues(range),
129
- leftAxis: true,
130
- };
131
-
132
- case 'dotPlot':
133
- case 'linePlot':
134
- return {
135
- verticalLines: [],
136
- horizontalLines: [],
137
- leftAxis: false,
138
- };
139
-
140
- default:
141
- return {
142
- verticalLines: [],
143
- horizontalLines: getTickValues(range),
144
- leftAxis: true,
145
- };
146
- }
147
- };
148
-
149
- export const getRotateAngle = (fontSize, height) => {
150
- if (height >= fontSize * 2) {
151
- return 25;
152
- }
153
-
154
- return 0;
155
- };
156
-
157
- export const getTopPadding = (barWidth) => {
158
- if (barWidth < 30) {
159
- return 50;
160
- }
161
-
162
- if (barWidth < 40) {
163
- return 30;
164
- }
165
-
166
- if (barWidth < 60) {
167
- return 15;
168
- }
169
-
170
- return 0;
171
- };
172
-
173
- // This function calculates the transformation scale for SVG and the icon's vertical distance from its category
174
- export const getScale = (width) => {
175
- let scale, deltay;
176
-
177
- if (width > 91) {
178
- scale = 1.3;
179
- deltay = -55;
180
- } else if (width > 45) {
181
- scale = 1.1;
182
- deltay = -45;
183
- } else if (width > 40) {
184
- scale = 0.5 + (width - 34) * 0.02;
185
- deltay = -25;
186
- } else if (width > 30) {
187
- scale = 0.5 + (width - 34) * 0.02;
188
- deltay = -20;
189
- } else {
190
- scale = 0.5 * Math.pow(0.98, 34 - width); // 0.98 is the reduction factor. Adjust to control scaling.
191
- deltay = -15;
192
- }
193
-
194
- return { scale, deltay };
195
- };
196
-
197
- export const getAdjustedX = (width, scaleValue) => {
198
- const innerWidthOriginal = 57;
199
- const effectiveInnerWidth = innerWidthOriginal * scaleValue;
200
- return (width - effectiveInnerWidth) / 2;
201
- };