@pie-lib/graphing 2.34.3-next.2 → 2.34.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 (252) hide show
  1. package/CHANGELOG.md +6 -76
  2. package/lib/__tests__/graph-with-controls.test.js +226 -0
  3. package/lib/__tests__/graph.test.js +187 -0
  4. package/lib/__tests__/grid.test.js +29 -0
  5. package/lib/__tests__/labels.test.js +61 -0
  6. package/lib/__tests__/mark-label.test.js +133 -0
  7. package/lib/__tests__/toggle-bar.test.js +150 -0
  8. package/lib/__tests__/tool-menu.test.js +101 -0
  9. package/lib/__tests__/undo-redo.test.js +31 -0
  10. package/lib/__tests__/use-debounce.test.js +24 -0
  11. package/lib/__tests__/utils.js +70 -0
  12. package/lib/__tests__/utils.test.js +123 -0
  13. package/lib/axis/__tests__/arrow.test.js +60 -0
  14. package/lib/axis/__tests__/axes.test.js +195 -0
  15. package/lib/axis/arrow.js +20 -56
  16. package/lib/axis/arrow.js.map +1 -1
  17. package/lib/axis/axes.js +107 -195
  18. package/lib/axis/axes.js.map +1 -1
  19. package/lib/axis/index.js +2 -7
  20. package/lib/axis/index.js.map +1 -1
  21. package/lib/bg.js +22 -50
  22. package/lib/bg.js.map +1 -1
  23. package/lib/container/actions.js +3 -9
  24. package/lib/container/actions.js.map +1 -1
  25. package/lib/container/index.js +15 -60
  26. package/lib/container/index.js.map +1 -1
  27. package/lib/container/marks.js +2 -7
  28. package/lib/container/marks.js.map +1 -1
  29. package/lib/container/middleware.js +3 -9
  30. package/lib/container/middleware.js.map +1 -1
  31. package/lib/container/reducer.js +2 -9
  32. package/lib/container/reducer.js.map +1 -1
  33. package/lib/coordinates-label.js +25 -55
  34. package/lib/coordinates-label.js.map +1 -1
  35. package/lib/graph-with-controls.js +121 -185
  36. package/lib/graph-with-controls.js.map +1 -1
  37. package/lib/graph.js +60 -117
  38. package/lib/graph.js.map +1 -1
  39. package/lib/grid-setup.js +169 -225
  40. package/lib/grid-setup.js.map +1 -1
  41. package/lib/grid.js +30 -75
  42. package/lib/grid.js.map +1 -1
  43. package/lib/index.js +2 -14
  44. package/lib/index.js.map +1 -1
  45. package/lib/key-legend.js +41 -86
  46. package/lib/key-legend.js.map +1 -1
  47. package/lib/label-svg-icon.js +2 -8
  48. package/lib/label-svg-icon.js.map +1 -1
  49. package/lib/labels.js +66 -122
  50. package/lib/labels.js.map +1 -1
  51. package/lib/mark-label.js +121 -164
  52. package/lib/mark-label.js.map +1 -1
  53. package/lib/toggle-bar.js +156 -244
  54. package/lib/toggle-bar.js.map +1 -1
  55. package/lib/tool-menu.js +17 -51
  56. package/lib/tool-menu.js.map +1 -1
  57. package/lib/tools/absolute/__tests__/component.test.js +67 -0
  58. package/lib/tools/absolute/component.js +5 -11
  59. package/lib/tools/absolute/component.js.map +1 -1
  60. package/lib/tools/absolute/index.js +4 -17
  61. package/lib/tools/absolute/index.js.map +1 -1
  62. package/lib/tools/circle/__tests__/bg-circle.test.js +33 -0
  63. package/lib/tools/circle/__tests__/component.test.js +68 -0
  64. package/lib/tools/circle/bg-circle.js +43 -93
  65. package/lib/tools/circle/bg-circle.js.map +1 -1
  66. package/lib/tools/circle/component.js +79 -166
  67. package/lib/tools/circle/component.js.map +1 -1
  68. package/lib/tools/circle/index.js +4 -14
  69. package/lib/tools/circle/index.js.map +1 -1
  70. package/lib/tools/exponential/__tests__/component.test.js +66 -0
  71. package/lib/tools/exponential/component.js +5 -11
  72. package/lib/tools/exponential/component.js.map +1 -1
  73. package/lib/tools/exponential/index.js +4 -19
  74. package/lib/tools/exponential/index.js.map +1 -1
  75. package/lib/tools/index.js +4 -17
  76. package/lib/tools/index.js.map +1 -1
  77. package/lib/tools/line/__tests__/component.test.js +45 -0
  78. package/lib/tools/line/component.js +28 -49
  79. package/lib/tools/line/component.js.map +1 -1
  80. package/lib/tools/line/index.js +2 -7
  81. package/lib/tools/line/index.js.map +1 -1
  82. package/lib/tools/parabola/__tests__/component.test.js +66 -0
  83. package/lib/tools/parabola/component.js +5 -11
  84. package/lib/tools/parabola/component.js.map +1 -1
  85. package/lib/tools/parabola/index.js +4 -17
  86. package/lib/tools/parabola/index.js.map +1 -1
  87. package/lib/tools/point/__tests__/component.test.js +50 -0
  88. package/lib/tools/point/component.js +25 -72
  89. package/lib/tools/point/component.js.map +1 -1
  90. package/lib/tools/point/index.js +4 -12
  91. package/lib/tools/point/index.js.map +1 -1
  92. package/lib/tools/polygon/__tests__/component.test.js +85 -0
  93. package/lib/tools/polygon/__tests__/index.test.js +92 -0
  94. package/lib/tools/polygon/__tests__/line.test.js +29 -0
  95. package/lib/tools/polygon/__tests__/polygon.test.js +59 -0
  96. package/lib/tools/polygon/component.js +84 -185
  97. package/lib/tools/polygon/component.js.map +1 -1
  98. package/lib/tools/polygon/index.js +7 -24
  99. package/lib/tools/polygon/index.js.map +1 -1
  100. package/lib/tools/polygon/line.js +49 -92
  101. package/lib/tools/polygon/line.js.map +1 -1
  102. package/lib/tools/polygon/polygon.js +66 -99
  103. package/lib/tools/polygon/polygon.js.map +1 -1
  104. package/lib/tools/ray/__tests__/component.test.js +35 -0
  105. package/lib/tools/ray/component.js +42 -61
  106. package/lib/tools/ray/component.js.map +1 -1
  107. package/lib/tools/ray/index.js +2 -7
  108. package/lib/tools/ray/index.js.map +1 -1
  109. package/lib/tools/segment/__tests__/component.test.js +35 -0
  110. package/lib/tools/segment/component.js +26 -44
  111. package/lib/tools/segment/component.js.map +1 -1
  112. package/lib/tools/segment/index.js +2 -7
  113. package/lib/tools/segment/index.js.map +1 -1
  114. package/lib/tools/shared/__tests__/arrow-head.test.js +45 -0
  115. package/lib/tools/shared/arrow-head.js +70 -29
  116. package/lib/tools/shared/arrow-head.js.map +1 -1
  117. package/lib/tools/shared/icons/CorrectSVG.js +13 -9
  118. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
  119. package/lib/tools/shared/icons/IncorrectSVG.js +13 -9
  120. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
  121. package/lib/tools/shared/icons/MissingSVG.js +13 -9
  122. package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
  123. package/lib/tools/shared/line/__tests__/index.test.js +124 -0
  124. package/lib/tools/shared/line/__tests__/line-path.test.js +62 -0
  125. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +91 -0
  126. package/lib/tools/shared/line/index.js +141 -194
  127. package/lib/tools/shared/line/index.js.map +1 -1
  128. package/lib/tools/shared/line/line-path.js +71 -102
  129. package/lib/tools/shared/line/line-path.js.map +1 -1
  130. package/lib/tools/shared/line/with-root-edge.js +23 -57
  131. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  132. package/lib/tools/shared/point/__tests__/arrow-point.test.js +127 -0
  133. package/lib/tools/shared/point/__tests__/base-point.test.js +122 -0
  134. package/lib/tools/shared/point/arrow-point.js +22 -63
  135. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  136. package/lib/tools/shared/point/arrow.js +24 -53
  137. package/lib/tools/shared/point/arrow.js.map +1 -1
  138. package/lib/tools/shared/point/base-point.js +55 -73
  139. package/lib/tools/shared/point/base-point.js.map +1 -1
  140. package/lib/tools/shared/point/index.js +23 -58
  141. package/lib/tools/shared/point/index.js.map +1 -1
  142. package/lib/tools/shared/styles.js +11 -39
  143. package/lib/tools/shared/styles.js.map +1 -1
  144. package/lib/tools/shared/types.js +3 -10
  145. package/lib/tools/shared/types.js.map +1 -1
  146. package/lib/tools/sine/__tests__/component.test.js +72 -0
  147. package/lib/tools/sine/component.js +9 -20
  148. package/lib/tools/sine/component.js.map +1 -1
  149. package/lib/tools/sine/index.js +4 -17
  150. package/lib/tools/sine/index.js.map +1 -1
  151. package/lib/tools/vector/__tests__/component.test.js +32 -0
  152. package/lib/tools/vector/component.js +25 -45
  153. package/lib/tools/vector/component.js.map +1 -1
  154. package/lib/tools/vector/index.js +2 -7
  155. package/lib/tools/vector/index.js.map +1 -1
  156. package/lib/undo-redo.js +30 -70
  157. package/lib/undo-redo.js.map +1 -1
  158. package/lib/use-debounce.js +5 -12
  159. package/lib/use-debounce.js.map +1 -1
  160. package/lib/utils.js +52 -129
  161. package/lib/utils.js.map +1 -1
  162. package/package.json +25 -29
  163. package/src/__tests__/graph-with-controls.test.jsx +28 -11
  164. package/src/__tests__/graph.test.jsx +104 -168
  165. package/src/__tests__/grid.test.jsx +8 -6
  166. package/src/__tests__/labels.test.jsx +25 -8
  167. package/src/__tests__/mark-label.test.jsx +12 -17
  168. package/src/__tests__/toggle-bar.test.jsx +92 -17
  169. package/src/__tests__/tool-menu.test.jsx +61 -12
  170. package/src/__tests__/undo-redo.test.jsx +7 -8
  171. package/src/__tests__/utils.js +3 -0
  172. package/src/axis/__tests__/arrow.test.jsx +16 -17
  173. package/src/axis/__tests__/axes.test.jsx +118 -122
  174. package/src/axis/arrow.jsx +7 -12
  175. package/src/axis/axes.jsx +45 -55
  176. package/src/coordinates-label.jsx +14 -18
  177. package/src/graph-with-controls.jsx +52 -59
  178. package/src/grid-setup.jsx +210 -206
  179. package/src/grid.jsx +2 -4
  180. package/src/key-legend.jsx +52 -56
  181. package/src/labels.jsx +23 -30
  182. package/src/mark-label.jsx +92 -81
  183. package/src/toggle-bar.jsx +135 -164
  184. package/src/tool-menu.jsx +1 -1
  185. package/src/tools/circle/__tests__/bg-circle.test.jsx +7 -9
  186. package/src/tools/circle/__tests__/component.test.jsx +17 -189
  187. package/src/tools/circle/bg-circle.jsx +20 -28
  188. package/src/tools/circle/component.jsx +28 -63
  189. package/src/tools/line/__tests__/component.test.jsx +7 -7
  190. package/src/tools/line/component.jsx +22 -15
  191. package/src/tools/point/__tests__/component.test.jsx +18 -43
  192. package/src/tools/point/component.jsx +1 -1
  193. package/src/tools/polygon/__tests__/component.test.jsx +18 -162
  194. package/src/tools/polygon/__tests__/line.test.jsx +7 -10
  195. package/src/tools/polygon/__tests__/polygon.test.jsx +7 -8
  196. package/src/tools/polygon/component.jsx +3 -4
  197. package/src/tools/polygon/line.jsx +30 -33
  198. package/src/tools/polygon/polygon.jsx +52 -45
  199. package/src/tools/ray/__tests__/component.test.jsx +7 -8
  200. package/src/tools/ray/component.jsx +38 -25
  201. package/src/tools/segment/__tests__/component.test.jsx +7 -8
  202. package/src/tools/segment/component.jsx +19 -18
  203. package/src/tools/shared/__tests__/arrow-head.test.jsx +14 -17
  204. package/src/tools/shared/arrow-head.jsx +60 -7
  205. package/src/tools/shared/icons/CorrectSVG.jsx +10 -0
  206. package/src/tools/shared/icons/IncorrectSVG.jsx +10 -0
  207. package/src/tools/shared/icons/MissingSVG.jsx +10 -0
  208. package/src/tools/shared/line/__tests__/index.test.jsx +19 -165
  209. package/src/tools/shared/line/__tests__/line-path.test.jsx +8 -8
  210. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +22 -22
  211. package/src/tools/shared/line/index.jsx +52 -7
  212. package/src/tools/shared/line/line-path.jsx +55 -59
  213. package/src/tools/shared/line/with-root-edge.jsx +1 -1
  214. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
  215. package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
  216. package/src/tools/shared/point/arrow-point.jsx +10 -24
  217. package/src/tools/shared/point/arrow.jsx +5 -11
  218. package/src/tools/shared/point/base-point.jsx +42 -19
  219. package/src/tools/shared/point/index.jsx +27 -44
  220. package/src/tools/vector/__tests__/component.test.jsx +7 -8
  221. package/src/tools/vector/component.jsx +11 -16
  222. package/src/undo-redo.jsx +19 -21
  223. package/esm/index.css +0 -847
  224. package/esm/index.js +0 -239949
  225. package/esm/index.js.map +0 -1
  226. package/esm/package.json +0 -3
  227. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -237
  228. package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -211
  229. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
  230. package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
  231. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -45
  232. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
  233. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -13
  234. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -14
  235. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
  236. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
  237. package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +0 -46
  238. package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +0 -293
  239. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
  240. package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +0 -40
  241. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -415
  242. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  243. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -52
  244. package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +0 -23
  245. package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +0 -14
  246. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -27
  247. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
  248. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -58
  249. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
  250. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -56
  251. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -44
  252. package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +0 -12
package/src/axis/axes.jsx CHANGED
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { Axis } from '@vx/axis';
2
+ import { Axis } from '@visx/axis';
3
3
  import { types } from '@pie-lib/plot';
4
4
  import PropTypes from 'prop-types';
5
5
  import Arrow from './arrow';
6
- import { withStyles } from '@material-ui/core';
6
+ import { styled } from '@mui/material/styles';
7
7
  import { countWords, findLongestWord, amountToIncreaseWidth, getTickValues } from '../utils';
8
8
  import { color, Readable } from '@pie-lib/render-ui';
9
9
 
@@ -21,34 +21,37 @@ const AxisDefaultProps = {
21
21
  },
22
22
  };
23
23
 
24
- const axisStyles = (theme) => ({
25
- line: {
24
+ const StyledArrow = styled(Arrow)(() => ({
25
+ fill: color.defaults.PRIMARY,
26
+ }));
27
+
28
+ const StyledLabel = styled('div')(({ theme }) => ({
29
+ fontSize: theme.typography.fontSize,
30
+ }));
31
+
32
+ const StyledAxisLabelHolder = styled('div')(({ theme }) => ({
33
+ padding: 0,
34
+ margin: 0,
35
+ textAlign: 'center',
36
+ '* > *': {
37
+ margin: 0,
38
+ padding: 0,
39
+ },
40
+ fontSize: theme.typography.fontSize,
41
+ }));
42
+
43
+ const StyledAxesGroup = styled('g')(() => ({
44
+ '& .visx-axis-line': {
26
45
  stroke: color.defaults.PRIMARY,
27
46
  strokeWidth: 3,
28
47
  },
29
- arrow: {
30
- fill: color.defaults.PRIMARY,
31
- },
32
- tick: {
48
+ '& .visx-axis-tick': {
33
49
  fill: color.defaults.PRIMARY,
34
- '& > line': {
50
+ '& line': {
35
51
  stroke: color.defaults.PRIMARY,
36
52
  },
37
53
  },
38
- labelFontSize: {
39
- fontSize: theme.typography.fontSize,
40
- },
41
- axisLabelHolder: {
42
- padding: 0,
43
- margin: 0,
44
- textAlign: 'center',
45
- '* > *': {
46
- margin: 0,
47
- padding: 0,
48
- },
49
- fontSize: theme.typography.fontSize,
50
- },
51
- });
54
+ }));
52
55
 
53
56
  const tickLabelStyles = {
54
57
  fontFamily: 'Roboto',
@@ -84,7 +87,6 @@ export const firstNegativeValue = (interval) => (interval || []).find((element)
84
87
  export class RawXAxis extends React.Component {
85
88
  static propTypes = {
86
89
  ...AxisPropTypes,
87
- classes: PropTypes.object,
88
90
  graphProps: types.GraphPropsType.isRequired,
89
91
  };
90
92
  static defaultProps = AxisDefaultProps;
@@ -92,7 +94,6 @@ export class RawXAxis extends React.Component {
92
94
  render() {
93
95
  const {
94
96
  includeArrows,
95
- classes,
96
97
  graphProps,
97
98
  columnTicksValues,
98
99
  skipValues,
@@ -101,12 +102,6 @@ export class RawXAxis extends React.Component {
101
102
  } = this.props;
102
103
  const { scale, domain, size, range } = graphProps || {};
103
104
 
104
- // Having 0 as a number in columnTicksValues does not make 0 to show up
105
- // so we use this trick, by defining it as a string:
106
- const tickValues =
107
- (domain.labelStep || range.labelStep) && domain.min <= 0 ? ['0', ...columnTicksValues] : columnTicksValues;
108
- // However, the '0' has to be displayed only if other tick labels (y-axis or x-axis) are displayed
109
-
110
105
  const labelProps = (label) => {
111
106
  const y = skipValues && skipValues[0] === label ? distanceFromOriginToFirstNegativeY + 4 : dy;
112
107
 
@@ -114,8 +109,8 @@ export class RawXAxis extends React.Component {
114
109
  ...tickLabelStyles,
115
110
  textAnchor: 'middle',
116
111
  y: y,
117
- dx: label === '0' ? -10 : 0,
118
- dy: label === '0' ? -7 : 0,
112
+ dx: label === 0 ? -10 : 0,
113
+ dy: label === 0 ? -7 : 0,
119
114
  };
120
115
  };
121
116
 
@@ -124,36 +119,35 @@ export class RawXAxis extends React.Component {
124
119
  const necessaryWidth = amountToIncreaseWidth(longestWord) + 2;
125
120
 
126
121
  return (
127
- <React.Fragment>
122
+ <StyledAxesGroup>
128
123
  <Axis
129
- axisLineClassName={classes.line}
130
124
  scale={scale.x}
131
125
  top={scale.y(0)}
132
126
  left={0}
133
127
  label={domain.label}
134
128
  rangePadding={8}
135
- tickClassName={classes.tick}
136
129
  tickFormat={(value) => value}
137
130
  tickLabelProps={labelProps}
138
- tickValues={tickValues}
131
+ tickValues={columnTicksValues}
132
+ hideZero={!(domain.labelStep || range.labelStep) && domain.min <= 0}
139
133
  />
140
134
  {includeArrows && includeArrows.left && (
141
- <Arrow direction="left" x={domain.min} y={0} className={classes.arrow} scale={scale} />
135
+ <StyledArrow direction="left" x={domain.min} y={0} scale={scale} />
142
136
  )}
143
137
  {includeArrows && includeArrows.right && (
144
- <Arrow direction="right" x={domain.max} y={0} className={classes.arrow} scale={scale} />
138
+ <StyledArrow direction="right" x={domain.max} y={0} scale={scale} />
145
139
  )}
146
140
  {domain.axisLabel && (
147
141
  <foreignObject x={size.width + 17} y={scale.y(0) - 9} width={necessaryWidth} height={20 * necessaryRows}>
148
- <div dangerouslySetInnerHTML={{ __html: domain.axisLabel }} className={classes.labelFontSize} />
142
+ <StyledLabel dangerouslySetInnerHTML={{ __html: domain.axisLabel }} />
149
143
  </foreignObject>
150
144
  )}
151
- </React.Fragment>
145
+ </StyledAxesGroup>
152
146
  );
153
147
  }
154
148
  }
155
149
 
156
- const XAxis = withStyles(axisStyles)(RawXAxis);
150
+ const XAxis = RawXAxis;
157
151
 
158
152
  export class RawYAxis extends React.Component {
159
153
  static propTypes = {
@@ -163,7 +157,7 @@ export class RawYAxis extends React.Component {
163
157
  static defaultProps = AxisDefaultProps;
164
158
 
165
159
  render() {
166
- const { classes, includeArrows, graphProps, skipValues, rowTickValues } = this.props;
160
+ const { includeArrows, graphProps, skipValues, rowTickValues } = this.props;
167
161
  const { scale, range, size } = graphProps || {};
168
162
 
169
163
  const necessaryWidth = range.axisLabel ? amountToIncreaseWidth(range.axisLabel.length) : 0;
@@ -171,9 +165,8 @@ export class RawYAxis extends React.Component {
171
165
  const customTickFormat = (value) => (skipValues && skipValues.indexOf(value) >= 0 ? '' : value);
172
166
 
173
167
  return (
174
- <React.Fragment>
168
+ <StyledAxesGroup>
175
169
  <Axis
176
- axisLineClassName={classes.line}
177
170
  orientation={'left'}
178
171
  scale={scale.y}
179
172
  top={0}
@@ -183,7 +176,6 @@ export class RawYAxis extends React.Component {
183
176
  labelProps={{ 'data-pie-readable': false }}
184
177
  rangePadding={8}
185
178
  tickLength={10}
186
- tickClassName={classes.tick}
187
179
  tickFormat={customTickFormat}
188
180
  tickLabelProps={(value) => {
189
181
  let digits = value.toLocaleString().replace(/[.-]/g, '').length || 1;
@@ -199,31 +191,29 @@ export class RawYAxis extends React.Component {
199
191
  tickTextAnchor={'bottom'}
200
192
  tickValues={rowTickValues}
201
193
  />
202
-
203
194
  {includeArrows && includeArrows.down && (
204
- <Arrow direction="down" x={0} y={range.min} className={classes.arrow} scale={scale} />
195
+ <StyledArrow direction="down" x={0} y={range.min} scale={scale} />
205
196
  )}
206
197
  {includeArrows && includeArrows.up && (
207
- <Arrow direction="up" x={0} y={range.max} className={classes.arrow} scale={scale} />
198
+ <StyledArrow direction="up" x={0} y={range.max} scale={scale} />
208
199
  )}
209
200
  {range.axisLabel && (
210
201
  <foreignObject x={scale.x(0) - necessaryWidth / 2} y={-33} width={necessaryWidth} height="20">
211
202
  <Readable false>
212
- <div dangerouslySetInnerHTML={{ __html: range.axisLabel }} className={classes.axisLabelHolder} />
203
+ <StyledAxisLabelHolder dangerouslySetInnerHTML={{ __html: range.axisLabel }} />
213
204
  </Readable>
214
205
  </foreignObject>
215
206
  )}
216
- </React.Fragment>
207
+ </StyledAxesGroup>
217
208
  );
218
209
  }
219
210
  }
220
211
 
221
- const YAxis = withStyles(axisStyles)(RawYAxis);
212
+ const YAxis = RawYAxis;
222
213
 
223
214
  export default class Axes extends React.Component {
224
215
  static propTypes = {
225
216
  ...AxisPropTypes,
226
- classes: PropTypes.object,
227
217
  graphProps: types.GraphPropsType.isRequired,
228
218
  };
229
219
  static defaultProps = AxisDefaultProps;
@@ -283,7 +273,7 @@ export default class Axes extends React.Component {
283
273
 
284
274
  // each axis has to be displayed only if the domain & range include it
285
275
  return (
286
- <React.Fragment>
276
+ <StyledAxesGroup>
287
277
  {range.min <= 0 ? (
288
278
  <XAxis
289
279
  {...this.props}
@@ -301,7 +291,7 @@ export default class Axes extends React.Component {
301
291
  distanceFromOriginToFirstNegativeX={distanceFromOriginToFirstNegativeX}
302
292
  />
303
293
  ) : null}
304
- </React.Fragment>
294
+ </StyledAxesGroup>
305
295
  );
306
296
  }
307
297
  }
@@ -2,23 +2,22 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { types } from '@pie-lib/plot';
4
4
  import { color } from '@pie-lib/render-ui';
5
- import { withStyles } from '@material-ui/core/styles';
6
- import InputBase from '@material-ui/core/InputBase';
5
+ import { styled } from '@mui/material/styles';
6
+ import InputBase from '@mui/material/InputBase';
7
7
  import { roundNumber } from './utils';
8
8
 
9
- const styles = (theme) => ({
10
- input: {
11
- fontFamily: theme.typography.fontFamily,
12
- fontSize: theme.typography.fontSize,
13
- borderRadius: '8px',
14
- background: theme.palette.common.white,
15
- color: color.defaults.PRIMARY_DARK,
16
- },
17
- inputLabel: {
9
+ const StyledInputBase = styled(InputBase)(({ theme }) => ({
10
+ fontFamily: theme.typography.fontFamily,
11
+ fontSize: theme.typography.fontSize,
12
+ borderRadius: '8px',
13
+ background: theme.palette.common.white,
14
+ color: color.defaults.PRIMARY_DARK,
15
+ '& .MuiInputBase-input': {
18
16
  padding: 0,
19
17
  },
20
- });
18
+ }));
21
19
 
20
+ // eslint-disable-next-line react/prop-types
22
21
  export const getLabelPosition = (graphProps, x, y, labelLength) => {
23
22
  const { scale, domain, range } = graphProps;
24
23
  // treat corner cases for maximum and minimum
@@ -39,7 +38,7 @@ export const getLabelPosition = (graphProps, x, y, labelLength) => {
39
38
  };
40
39
  };
41
40
 
42
- export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
41
+ export const CoordinatesLabel = ({ x, y, graphProps }) => {
43
42
  const label = `(${roundNumber(x)}, ${roundNumber(y)})`;
44
43
  const labelLength = (label.length || 0) * 6;
45
44
  const labelPosition = getLabelPosition(graphProps, x, y, labelLength);
@@ -53,10 +52,8 @@ export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
53
52
  };
54
53
 
55
54
  return (
56
- <InputBase
55
+ <StyledInputBase
57
56
  style={style}
58
- classes={{ input: classes.inputLabel }}
59
- className={classes.input}
60
57
  value={label}
61
58
  inputProps={{ ariaLabel: 'naked' }}
62
59
  />
@@ -65,9 +62,8 @@ export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
65
62
 
66
63
  CoordinatesLabel.propTypes = {
67
64
  graphProps: types.GraphPropsType,
68
- classes: PropTypes.object,
69
65
  x: PropTypes.number,
70
66
  y: PropTypes.number,
71
67
  };
72
68
 
73
- export default withStyles(styles)(CoordinatesLabel);
69
+ export default CoordinatesLabel;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
4
- import classNames from 'classnames';
3
+ import { styled } from '@mui/material/styles';
5
4
  import uniq from 'lodash/uniq';
6
5
  import isString from 'lodash/isString';
7
6
  import { color } from '@pie-lib/render-ui';
@@ -10,8 +9,45 @@ import ToolMenu from './tool-menu';
10
9
  import Graph, { graphPropTypes } from './graph';
11
10
  import UndoRedo from './undo-redo';
12
11
  import { allTools, toolsArr } from './tools';
13
- import { ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary, Typography } from '@material-ui/core';
14
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
12
+ import { Accordion, AccordionDetails, AccordionSummary, Typography } from '@mui/material';
13
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
14
+
15
+ const StyledGraphContainer = styled('div')({
16
+ display: 'flex',
17
+ flexDirection: 'column',
18
+ width: 'min-content',
19
+ });
20
+
21
+ const StyledControls = styled('div')(({ theme }) => ({
22
+ display: 'flex',
23
+ justifyContent: 'space-between',
24
+ padding: theme.spacing(1),
25
+ color: color.text(),
26
+ backgroundColor: color.primaryLight(),
27
+ '& button': {
28
+ fontSize: theme.typography.fontSize,
29
+ },
30
+ }));
31
+
32
+ const StyledAccordion = styled(Accordion)({
33
+ backgroundColor: color.primaryLight(),
34
+ width: '100%',
35
+ });
36
+
37
+ const StyledAccordionSummary = styled(AccordionSummary)(({ theme }) => ({
38
+ padding: `0 ${theme.spacing(1)}px`,
39
+ minHeight: '32px !important',
40
+ '& .MuiAccordionSummary-content': {
41
+ margin: '4px 0 !important',
42
+ },
43
+ }));
44
+
45
+ const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
46
+ padding: 0,
47
+ marginTop: theme.spacing(1),
48
+ display: 'flex',
49
+ justifyContent: 'space-between',
50
+ }));
15
51
 
16
52
  export const setToolbarAvailability = (toolbarTools) =>
17
53
  toolsArr.map((tA) => ({ ...tA, toolbar: !!toolbarTools.find((t) => t === tA.type) })) || [];
@@ -29,23 +65,16 @@ export const filterByVisibleToolTypes = (toolbarTools, marks) =>
29
65
 
30
66
  const getDefaultCurrentTool = (toolType) => toolsArr.find((tool) => tool.type === toolType) || null;
31
67
 
32
- const Collapsible = ({ classes, children, title }) => (
33
- <ExpansionPanel elevation={0} className={classes.expansionPanel} disabledGutters={true} square={true}>
34
- <ExpansionPanelSummary
35
- classes={{
36
- root: classes.summaryRoot,
37
- content: classes.summaryContent,
38
- }}
39
- expandIcon={<ExpandMoreIcon />}
40
- >
68
+ const Collapsible = ({ children, title }) => (
69
+ <StyledAccordion elevation={0} disableGutters={true} square={true} TransitionProps={{ timeout: { enter: 225, exit: 195 } }}>
70
+ <StyledAccordionSummary expandIcon={<ExpandMoreIcon />}>
41
71
  <Typography variant="subheading">{title}</Typography>
42
- </ExpansionPanelSummary>
43
- <ExpansionPanelDetails className={classes.details}>{children}</ExpansionPanelDetails>
44
- </ExpansionPanel>
72
+ </StyledAccordionSummary>
73
+ <StyledAccordionDetails>{children}</StyledAccordionDetails>
74
+ </StyledAccordion>
45
75
  );
46
76
 
47
77
  Collapsible.propTypes = {
48
- classes: PropTypes.object,
49
78
  children: PropTypes.array,
50
79
  title: PropTypes.string,
51
80
  };
@@ -96,7 +125,6 @@ export class GraphWithControls extends React.Component {
96
125
  let { currentTool, labelModeEnabled } = this.state;
97
126
  const {
98
127
  axesSettings,
99
- classes,
100
128
  className,
101
129
  coordinatesOnHover,
102
130
  collapsibleToolbar,
@@ -162,16 +190,16 @@ export class GraphWithControls extends React.Component {
162
190
  );
163
191
 
164
192
  return (
165
- <div className={classNames(classes.graphWithControls, className)}>
166
- <div className={classes.controls}>
193
+ <StyledGraphContainer className={className}>
194
+ <StyledControls>
167
195
  {collapsibleToolbar ? (
168
- <Collapsible classes={classes} title={collapsibleToolbarTitle}>
196
+ <Collapsible title={collapsibleToolbarTitle}>
169
197
  {graphActions}
170
198
  </Collapsible>
171
199
  ) : (
172
200
  graphActions
173
201
  )}
174
- </div>
202
+ </StyledControls>
175
203
 
176
204
  <div ref={(r) => (this.labelNode = r)} />
177
205
 
@@ -201,44 +229,9 @@ export class GraphWithControls extends React.Component {
201
229
  removeIncompleteTool={removeIncompleteTool}
202
230
  limitLabeling={limitLabeling}
203
231
  />
204
- </div>
232
+ </StyledGraphContainer>
205
233
  );
206
234
  }
207
235
  }
208
236
 
209
- const styles = (theme) => ({
210
- graphWithControls: {
211
- display: 'flex',
212
- flexDirection: 'column',
213
- width: 'min-content',
214
- },
215
- controls: {
216
- display: 'flex',
217
- justifyContent: 'space-between',
218
- padding: theme.spacing.unit,
219
- color: color.text(),
220
- backgroundColor: color.primaryLight(),
221
- '& button': {
222
- fontSize: theme.typography.fontSize,
223
- },
224
- },
225
- expansionPanel: {
226
- backgroundColor: color.primaryLight(),
227
- width: '100%',
228
- },
229
- summaryRoot: {
230
- padding: `0 ${theme.spacing.unit}px`,
231
- minHeight: '32px !important',
232
- },
233
- summaryContent: {
234
- margin: '4px 0 !important',
235
- },
236
- details: {
237
- padding: 0,
238
- marginTop: theme.spacing.unit,
239
- display: 'flex',
240
- justifyContent: 'space-between',
241
- },
242
- });
243
-
244
- export default withStyles(styles)(GraphWithControls);
237
+ export default GraphWithControls;