@pie-lib/charting 5.36.3-next.2 → 5.36.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 (143) hide show
  1. package/CHANGELOG.md +17 -96
  2. package/lib/__tests__/axes.test.js +129 -0
  3. package/lib/__tests__/chart-setup.test.js +57 -0
  4. package/lib/__tests__/chart-type.test.js +25 -0
  5. package/lib/__tests__/chart.test.js +103 -0
  6. package/lib/__tests__/grid.test.js +39 -0
  7. package/lib/__tests__/mark-label.test.js +46 -0
  8. package/lib/__tests__/utils.js +56 -0
  9. package/lib/__tests__/utils.test.js +186 -0
  10. package/lib/actions-button.js +61 -91
  11. package/lib/actions-button.js.map +1 -1
  12. package/lib/axes.js +163 -239
  13. package/lib/axes.js.map +1 -1
  14. package/lib/bars/__tests__/bar.test.js +53 -0
  15. package/lib/bars/__tests__/histogram.test.js +53 -0
  16. package/lib/bars/__tests__/utils.js +50 -0
  17. package/lib/bars/bar.js +14 -42
  18. package/lib/bars/bar.js.map +1 -1
  19. package/lib/bars/common/__tests__/bars.test.js +76 -0
  20. package/lib/bars/common/__tests__/utils.js +50 -0
  21. package/lib/bars/common/bars.js +62 -138
  22. package/lib/bars/common/bars.js.map +1 -1
  23. package/lib/bars/common/correct-check-icon.js +6 -7
  24. package/lib/bars/common/correct-check-icon.js.map +1 -1
  25. package/lib/bars/histogram.js +14 -42
  26. package/lib/bars/histogram.js.map +1 -1
  27. package/lib/chart-setup.js +120 -196
  28. package/lib/chart-setup.js.map +1 -1
  29. package/lib/chart-type.js +53 -44
  30. package/lib/chart-type.js.map +1 -1
  31. package/lib/chart-types.js +2 -11
  32. package/lib/chart-types.js.map +1 -1
  33. package/lib/chart.js +74 -152
  34. package/lib/chart.js.map +1 -1
  35. package/lib/common/__tests__/drag-handle.test.js +74 -0
  36. package/lib/common/__tests__/utils.js +50 -0
  37. package/lib/common/correctness-indicators.js +110 -53
  38. package/lib/common/correctness-indicators.js.map +1 -1
  39. package/lib/common/drag-handle.js +66 -109
  40. package/lib/common/drag-handle.js.map +1 -1
  41. package/lib/common/drag-icon.js +13 -13
  42. package/lib/common/drag-icon.js.map +1 -1
  43. package/lib/common/styles.js +7 -25
  44. package/lib/common/styles.js.map +1 -1
  45. package/lib/grid.js +44 -84
  46. package/lib/grid.js.map +1 -1
  47. package/lib/index.js +1 -7
  48. package/lib/index.js.map +1 -1
  49. package/lib/key-legend.js +64 -88
  50. package/lib/key-legend.js.map +1 -1
  51. package/lib/line/__tests__/line-cross.test.js +47 -0
  52. package/lib/line/__tests__/line-dot.test.js +47 -0
  53. package/lib/line/__tests__/utils.js +56 -0
  54. package/lib/line/common/__tests__/drag-handle.test.js +74 -0
  55. package/lib/line/common/__tests__/line.test.js +92 -0
  56. package/lib/line/common/__tests__/utils.js +50 -0
  57. package/lib/line/common/drag-handle.js +73 -101
  58. package/lib/line/common/drag-handle.js.map +1 -1
  59. package/lib/line/common/line.js +51 -97
  60. package/lib/line/common/line.js.map +1 -1
  61. package/lib/line/line-cross.js +80 -90
  62. package/lib/line/line-cross.js.map +1 -1
  63. package/lib/line/line-dot.js +59 -77
  64. package/lib/line/line-dot.js.map +1 -1
  65. package/lib/mark-label.js +85 -120
  66. package/lib/mark-label.js.map +1 -1
  67. package/lib/plot/__tests__/dot.test.js +53 -0
  68. package/lib/plot/__tests__/line.test.js +53 -0
  69. package/lib/plot/__tests__/utils.js +50 -0
  70. package/lib/plot/common/__tests__/plot.test.js +79 -0
  71. package/lib/plot/common/__tests__/utils.js +50 -0
  72. package/lib/plot/common/plot.js +91 -149
  73. package/lib/plot/common/plot.js.map +1 -1
  74. package/lib/plot/dot.js +33 -59
  75. package/lib/plot/dot.js.map +1 -1
  76. package/lib/plot/line.js +40 -65
  77. package/lib/plot/line.js.map +1 -1
  78. package/lib/tool-menu.js +48 -84
  79. package/lib/tool-menu.js.map +1 -1
  80. package/lib/utils.js +32 -87
  81. package/lib/utils.js.map +1 -1
  82. package/package.json +22 -24
  83. package/src/__tests__/axes.test.jsx +85 -100
  84. package/src/__tests__/chart-type.test.jsx +5 -11
  85. package/src/__tests__/chart.test.jsx +41 -50
  86. package/src/__tests__/grid.test.jsx +23 -11
  87. package/src/__tests__/mark-label.test.jsx +13 -11
  88. package/src/__tests__/utils.js +8 -2
  89. package/src/actions-button.jsx +44 -39
  90. package/src/axes.jsx +67 -81
  91. package/src/bars/__tests__/bar.test.jsx +19 -11
  92. package/src/bars/__tests__/histogram.test.jsx +19 -12
  93. package/src/bars/common/__tests__/bars.test.jsx +23 -24
  94. package/src/bars/common/bars.jsx +42 -69
  95. package/src/bars/common/correct-check-icon.jsx +5 -0
  96. package/src/chart-setup.jsx +75 -88
  97. package/src/chart-type.js +45 -22
  98. package/src/chart.jsx +19 -34
  99. package/src/common/__tests__/drag-handle.test.jsx +16 -45
  100. package/src/common/correctness-indicators.jsx +91 -13
  101. package/src/common/drag-handle.jsx +44 -64
  102. package/src/common/drag-icon.jsx +9 -2
  103. package/src/common/styles.js +1 -1
  104. package/src/grid.jsx +10 -14
  105. package/src/key-legend.jsx +62 -60
  106. package/src/line/__tests__/line-cross.test.jsx +16 -13
  107. package/src/line/__tests__/line-dot.test.jsx +16 -13
  108. package/src/line/__tests__/utils.js +8 -2
  109. package/src/line/common/__tests__/drag-handle.test.jsx +20 -45
  110. package/src/line/common/__tests__/line.test.jsx +27 -30
  111. package/src/line/common/drag-handle.jsx +61 -55
  112. package/src/line/common/line.jsx +21 -11
  113. package/src/line/line-cross.js +39 -14
  114. package/src/line/line-dot.js +27 -32
  115. package/src/mark-label.jsx +51 -47
  116. package/src/plot/__tests__/dot.test.jsx +19 -12
  117. package/src/plot/__tests__/line.test.jsx +19 -12
  118. package/src/plot/common/__tests__/plot.test.jsx +23 -24
  119. package/src/plot/common/plot.jsx +29 -24
  120. package/src/plot/dot.js +11 -4
  121. package/src/plot/line.js +16 -8
  122. package/src/tool-menu.jsx +26 -30
  123. package/src/utils.js +13 -9
  124. package/esm/index.css +0 -847
  125. package/esm/index.js +0 -231130
  126. package/esm/index.js.map +0 -1
  127. package/esm/package.json +0 -3
  128. package/src/__tests__/__snapshots__/axes.test.jsx.snap +0 -569
  129. package/src/__tests__/__snapshots__/chart-type.test.jsx.snap +0 -14
  130. package/src/__tests__/__snapshots__/chart.test.jsx.snap +0 -595
  131. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -72
  132. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -73
  133. package/src/bars/__tests__/__snapshots__/bar.test.jsx.snap +0 -43
  134. package/src/bars/__tests__/__snapshots__/histogram.test.jsx.snap +0 -45
  135. package/src/bars/common/__tests__/__snapshots__/bars.test.jsx.snap +0 -110
  136. package/src/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +0 -48
  137. package/src/line/__tests__/__snapshots__/line-cross.test.jsx.snap +0 -45
  138. package/src/line/__tests__/__snapshots__/line-dot.test.jsx.snap +0 -45
  139. package/src/line/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +0 -49
  140. package/src/line/common/__tests__/__snapshots__/line.test.jsx.snap +0 -143
  141. package/src/plot/__tests__/__snapshots__/dot.test.jsx.snap +0 -45
  142. package/src/plot/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  143. package/src/plot/common/__tests__/__snapshots__/plot.test.jsx.snap +0 -97
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Group } from '@vx/group';
4
- import { Bar as VxBar } from '@vx/shape';
5
- import { withStyles } from '@material-ui/core/styles/index';
3
+ import { Group } from '@visx/group';
4
+ import { Bar as VisxBar } from '@visx/shape';
5
+ import { styled } from '@mui/material/styles';
6
6
  import debug from 'debug';
7
7
 
8
8
  import { color } from '@pie-lib/render-ui';
@@ -51,12 +51,15 @@ const calculateFillColor = (isHovered, barColor, index, hoverHistogramColors, al
51
51
  return barColor || null;
52
52
  };
53
53
 
54
+ const StyledVisxBar = styled(VisxBar)(() => ({
55
+ fill: color.defaults.TERTIARY,
56
+ }));
57
+
54
58
  export class RawBar extends React.Component {
55
59
  static propTypes = {
56
60
  barColor: PropTypes.string,
57
61
  onChangeCategory: PropTypes.func,
58
62
  value: PropTypes.number,
59
- classes: PropTypes.object,
60
63
  label: PropTypes.string,
61
64
  xBand: PropTypes.func,
62
65
  index: PropTypes.number.isRequired,
@@ -67,6 +70,7 @@ export class RawBar extends React.Component {
67
70
  label: PropTypes.string,
68
71
  }),
69
72
  correctData: PropTypes.array,
73
+ defineChart: PropTypes.bool,
70
74
  };
71
75
 
72
76
  constructor(props) {
@@ -88,17 +92,14 @@ export class RawBar extends React.Component {
88
92
  }
89
93
 
90
94
  handleMouseMove = (e) => {
91
- // Update mouse position
92
95
  this.mouseX = e.clientX;
93
96
  this.mouseY = e.clientY;
94
- // Check if the mouse is inside the <g> element
95
97
  const isMouseInside = this.isMouseInsideSvgElement();
96
98
  this.setState({ isHovered: isMouseInside });
97
99
  };
98
100
 
99
101
  isMouseInsideSvgElement = () => {
100
102
  const gBoundingBox = this.gRef.getBoundingClientRect();
101
- // Check if the mouse position is within the bounding box
102
103
  return (
103
104
  this.mouseX >= gBoundingBox.left &&
104
105
  this.mouseX <= gBoundingBox.right &&
@@ -107,13 +108,8 @@ export class RawBar extends React.Component {
107
108
  );
108
109
  };
109
110
 
110
- handleMouseEnter = () => {
111
- this.setState({ isHovered: true });
112
- };
113
-
114
- handleMouseLeave = () => {
115
- this.setState({ isHovered: false });
116
- };
111
+ handleMouseEnter = () => this.setState({ isHovered: true });
112
+ handleMouseLeave = () => this.setState({ isHovered: false });
117
113
 
118
114
  setDragValue = (dragValue) => this.setState({ dragValue });
119
115
 
@@ -140,7 +136,6 @@ export class RawBar extends React.Component {
140
136
  graphProps,
141
137
  value,
142
138
  label,
143
- classes,
144
139
  xBand,
145
140
  index,
146
141
  interactive,
@@ -161,7 +156,6 @@ export class RawBar extends React.Component {
161
156
  const rawY = range.max - v;
162
157
  const yy = range.max - rawY;
163
158
  const correctValue = correctData ? correctData.find((d) => d.label === label) : null;
164
- log('label:', label, 'barX:', barX, 'v: ', v, 'barHeight:', barHeight, 'barWidth: ', barWidth);
165
159
 
166
160
  const Component = interactive ? DraggableHandle : DragHandle;
167
161
  const isHistogram = !!barColor;
@@ -174,48 +168,43 @@ export class RawBar extends React.Component {
174
168
  onTouchStart={this.handleMouseEnter}
175
169
  onTouchEnd={this.handleMouseLeave}
176
170
  >
177
- <VxBar
171
+ <StyledVisxBar
178
172
  x={barX}
179
173
  y={scale.y(yy)}
180
174
  width={barWidth}
181
175
  height={barHeight}
182
- className={classes.bar}
183
176
  style={{ fill: fillColor }}
184
177
  />
185
- {correctness &&
186
- correctness.value === 'incorrect' &&
187
- (() => {
188
- const correctVal = parseFloat(correctValue && correctValue.value);
189
- if (isNaN(correctVal)) return null;
190
- const correctPxHeight = scale.y(range.max - correctVal);
191
- const actualPxHeight = barHeight;
192
- const diffPx = Math.abs(correctPxHeight - actualPxHeight);
193
- const yDiff = scale.y(correctVal);
194
- const indicatorBarColor = correctPxHeight > actualPxHeight ? color.borderGray() : color.defaults.WHITE;
195
- const yToRender = correctPxHeight > actualPxHeight ? yDiff : yDiff - diffPx;
178
+ {correctness && correctness.value === 'incorrect' && (() => {
179
+ const correctVal = parseFloat(correctValue && correctValue.value);
180
+ if (isNaN(correctVal)) return null;
181
+ const correctPxHeight = scale.y(range.max - correctVal);
182
+ const actualPxHeight = barHeight;
183
+ const diffPx = Math.abs(correctPxHeight - actualPxHeight);
184
+ const yDiff = scale.y(correctVal);
185
+ const indicatorBarColor = correctPxHeight > actualPxHeight ? color.borderGray() : color.defaults.WHITE;
186
+ const yToRender = correctPxHeight > actualPxHeight ? yDiff : yDiff - diffPx;
196
187
 
197
- return (
198
- <>
199
- <VxBar
200
- x={barX + 2} // add 2px for the stroke (the dashed border)
201
- y={yToRender}
202
- width={barWidth - 4} // substract 4px for the total stroke
203
- height={diffPx}
204
- className={classes.bar}
205
- style={{
206
- stroke: indicatorBarColor,
207
- strokeWidth: 2,
208
- strokeDasharray: '5,2',
209
- fill: 'none',
210
- }}
211
- />
212
- {/* adjust the position based on whether it's a histogram or not, because the histogram does not have space for the icon on the side */}
213
- <foreignObject x={barX + barWidth - (isHistogram ? 24 : 14)} y={yDiff - 12} width={24} height={24}>
214
- <CorrectCheckIcon dashColor={indicatorBarColor} />
215
- </foreignObject>
216
- </>
217
- );
218
- })()}
188
+ return (
189
+ <>
190
+ <StyledVisxBar
191
+ x={barX + 2}
192
+ y={yToRender}
193
+ width={barWidth - 4}
194
+ height={diffPx}
195
+ style={{ stroke: indicatorBarColor, strokeWidth: 2, strokeDasharray: '5,2', fill: 'none' }}
196
+ />
197
+ <foreignObject
198
+ x={barX + barWidth - (isHistogram ? 24 : 14)}
199
+ y={yDiff - 12}
200
+ width={24}
201
+ height={24}
202
+ >
203
+ <CorrectCheckIcon dashColor={indicatorBarColor} />
204
+ </foreignObject>
205
+ </>
206
+ );
207
+ })()}
219
208
  <Component
220
209
  x={barX}
221
210
  y={v}
@@ -234,22 +223,7 @@ export class RawBar extends React.Component {
234
223
  }
235
224
  }
236
225
 
237
- const Bar = withStyles((theme) => ({
238
- bar: {
239
- fill: color.defaults.TERTIARY,
240
- },
241
- correctIcon: {
242
- backgroundColor: color.correct(),
243
- borderRadius: theme.spacing.unit * 2,
244
- color: color.defaults.WHITE,
245
- fontSize: '10px',
246
- width: '10px',
247
- height: '10px',
248
- padding: '2px',
249
- border: `1px solid ${color.defaults.WHITE}`,
250
- boxSizing: 'unset', // to override the default border-box in IBX
251
- },
252
- }))(RawBar);
226
+ const Bar = RawBar;
253
227
 
254
228
  export class Bars extends React.Component {
255
229
  static propTypes = {
@@ -281,8 +255,7 @@ export class Bars extends React.Component {
281
255
  correctness={d.correctness}
282
256
  correctData={correctData}
283
257
  barColor={
284
- histogram &&
285
- (histogramColors[index] ? histogramColors[index] : histogramColors[index % histogramColors.length])
258
+ histogram && (histogramColors[index] ? histogramColors[index] : histogramColors[index % histogramColors.length])
286
259
  }
287
260
  />
288
261
  ))}
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import PropTypes from 'prop-types';
2
3
 
3
4
  export const CorrectCheckIcon = ({ dashColor }) => (
4
5
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -18,3 +19,7 @@ export const CorrectCheckIcon = ({ dashColor }) => (
18
19
  />
19
20
  </svg>
20
21
  );
22
+
23
+ CorrectCheckIcon.propTypes = {
24
+ dashColor: PropTypes.string,
25
+ };
@@ -1,8 +1,8 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { color } from '@pie-lib/render-ui';
4
- import { withStyles } from '@material-ui/core/styles';
5
- import Typography from '@material-ui/core/Typography';
4
+ import { styled } from '@mui/material/styles';
5
+ import Typography from '@mui/material/Typography';
6
6
  import ChartType from './chart-type';
7
7
  import { NumberTextFieldCustom } from '@pie-lib/config-ui';
8
8
  import { AlertDialog } from '@pie-lib/config-ui';
@@ -24,9 +24,52 @@ export const resetValues = (data, updateModel, range, onChange, model) => {
24
24
  }
25
25
  };
26
26
 
27
+ const StyledWrapper = styled('div')(() => ({
28
+ width: '450px',
29
+ }));
30
+
31
+ const StyledContent = styled('div')(({ theme }) => ({
32
+ display: 'flex',
33
+ flexDirection: 'column',
34
+ width: '100%',
35
+ marginTop: theme.spacing(3),
36
+ }));
37
+
38
+ const StyledColumnView = styled('div')(() => ({
39
+ display: 'flex',
40
+ flexDirection: 'column',
41
+ alignItems: 'center',
42
+ }));
43
+
44
+ const StyledRowView = styled('div')(() => ({
45
+ display: 'flex',
46
+ justifyContent: 'space-around',
47
+ alignItems: 'center',
48
+ }));
49
+
50
+ const StyledTextField = styled(NumberTextFieldCustom)(({ theme }) => ({
51
+ width: '130px',
52
+ margin: `${theme.spacing(1)} ${theme.spacing(0.5)}`,
53
+ }));
54
+
55
+ const StyledMediumTextField = styled(NumberTextFieldCustom)(({ theme }) => ({
56
+ width: '160px',
57
+ margin: `${theme.spacing(1)} ${theme.spacing(0.5)}`,
58
+ }));
59
+
60
+ const StyledDimensions = styled('div')(({ theme }) => ({
61
+ display: 'flex',
62
+ justifyContent: 'space-between',
63
+ alignItems: 'center',
64
+ margin: `${theme.spacing(3)} 0`,
65
+ }));
66
+
67
+ const StyledDisabled = styled(Typography)(() => ({
68
+ color: color.disabled(),
69
+ }));
70
+
27
71
  const ConfigureChartPanel = (props) => {
28
72
  const {
29
- classes,
30
73
  model,
31
74
  onChange,
32
75
  chartDimensions,
@@ -67,37 +110,30 @@ const ConfigureChartPanel = (props) => {
67
110
  const labelOptions = labelValues && labelValues.range ? { customValues: labelValues.range } : { min: 0, max: 10000 };
68
111
 
69
112
  const stepConfig = (
70
- <div className={classes.rowView}>
71
- <NumberTextFieldCustom
72
- className={classes.mediumTextField}
113
+ <StyledRowView>
114
+ <StyledMediumTextField
73
115
  label="Grid Interval"
74
116
  value={range.step}
75
117
  variant="outlined"
76
118
  onChange={(e, v) => onRangeChanged('step', v, e)}
77
119
  {...gridOptions}
78
120
  />
79
- <NumberTextFieldCustom
80
- className={classes.mediumTextField}
121
+ <StyledMediumTextField
81
122
  label={'Label Interval'}
82
123
  value={range.labelStep}
83
124
  variant={'outlined'}
84
125
  onChange={(e, v) => onRangeChanged('labelStep', v, e)}
85
126
  {...labelOptions}
86
127
  />
87
- </div>
128
+ </StyledRowView>
88
129
  );
89
130
 
90
- const handleAlertDialog = (openStatus, callback) => {
131
+ const handleAlertDialog = (openStatus) => {
91
132
  setAlertDialog(
92
133
  (prevState) => ({
93
134
  ...prevState,
94
135
  open: openStatus,
95
136
  }),
96
- () => {
97
- if (callback) {
98
- callback();
99
- }
100
- },
101
137
  );
102
138
 
103
139
  setOpen(openStatus);
@@ -105,7 +141,7 @@ const ConfigureChartPanel = (props) => {
105
141
 
106
142
  const setPropertiesToFalse = (data, property) => {
107
143
  return data.map((obj) => {
108
- if (obj.hasOwnProperty(property)) {
144
+ if (Object.prototype.hasOwnProperty.call(obj, property)) {
109
145
  obj[property] = property == 'interactive' ? true : false;
110
146
  }
111
147
  return obj;
@@ -157,7 +193,7 @@ const ConfigureChartPanel = (props) => {
157
193
  // check if current chart values are invalid for given range step/max
158
194
  const outOfRange = isOutOfRange(model.data, range) || isOutOfRange(model.correctAnswer.data, range);
159
195
 
160
- if (outOfRange && JSON.stringify(e) !== '{}') {
196
+ if (outOfRange && e?.target) {
161
197
  setOpen(true);
162
198
  } else {
163
199
  onChange({ ...model, range });
@@ -180,7 +216,8 @@ const ConfigureChartPanel = (props) => {
180
216
  text: 'This change will remove values defined for one or more categories',
181
217
  onConfirm: () => {
182
218
  removeOutOfRangeValues();
183
- handleAlertDialog(false, onChange({ ...model, range, correctAnswer }));
219
+ handleAlertDialog(false);
220
+ onChange({ ...model, range, correctAnswer });
184
221
  },
185
222
  onClose: () => {
186
223
  range[rangeKey] = resetValue;
@@ -214,7 +251,8 @@ const ConfigureChartPanel = (props) => {
214
251
  onConfirm: () => {
215
252
  getPlotConfiguration();
216
253
  removeOutOfRangeValues();
217
- handleAlertDialog(false, onChange({ ...model, range, chartType }));
254
+ handleAlertDialog(false);
255
+ onChange({ ...model, range, chartType });
218
256
  },
219
257
  onClose: () => {
220
258
  handleAlertDialog(false);
@@ -236,18 +274,17 @@ const ConfigureChartPanel = (props) => {
236
274
  };
237
275
 
238
276
  return (
239
- <div className={classes.wrapper}>
277
+ <StyledWrapper>
240
278
  <Typography variant={'subtitle1'}>Configure Chart</Typography>
241
- <div className={classes.content}>
242
- <div className={classes.rowView}>
279
+ <StyledContent>
280
+ <StyledRowView>
243
281
  <ChartType
244
282
  value={model.chartType}
245
283
  onChange={(e) => onChartTypeChange(e.target.value)}
246
284
  availableChartTypes={availableChartTypes}
247
285
  chartTypeLabel={chartTypeLabel}
248
286
  />
249
- <NumberTextFieldCustom
250
- className={classes.mediumTextField}
287
+ <StyledMediumTextField
251
288
  label="Max Value"
252
289
  value={range.max}
253
290
  min={rangeProps(model.chartType).min}
@@ -255,18 +292,17 @@ const ConfigureChartPanel = (props) => {
255
292
  variant="outlined"
256
293
  onChange={(e, v) => onRangeChanged('max', v, e)}
257
294
  />
258
- </div>
295
+ </StyledRowView>
259
296
  {!model.chartType.includes('Plot') && stepConfig}
260
297
 
261
298
  {showInConfigPanel && (
262
- <div className={classes.dimensions}>
299
+ <StyledDimensions>
263
300
  <div>
264
301
  <Typography>Dimensions(px)</Typography>
265
302
  </div>
266
303
 
267
- <div className={classes.columnView}>
268
- <NumberTextFieldCustom
269
- className={classes.textField}
304
+ <StyledColumnView>
305
+ <StyledTextField
270
306
  label={'Width'}
271
307
  value={size.width}
272
308
  min={widthConstraints.min}
@@ -275,12 +311,11 @@ const ConfigureChartPanel = (props) => {
275
311
  variant={'outlined'}
276
312
  onChange={(e, v) => onSizeChanged('width', v)}
277
313
  />
278
- <Typography className={classes.disabled}>Min 50, Max 700</Typography>
279
- </div>
314
+ <StyledDisabled>Min 50, Max 700</StyledDisabled>
315
+ </StyledColumnView>
280
316
 
281
- <div className={classes.columnView}>
282
- <NumberTextFieldCustom
283
- className={classes.textField}
317
+ <StyledColumnView>
318
+ <StyledTextField
284
319
  label={'Height'}
285
320
  value={size.height}
286
321
  min={heightConstraints.min}
@@ -289,11 +324,11 @@ const ConfigureChartPanel = (props) => {
289
324
  variant={'outlined'}
290
325
  onChange={(e, v) => onSizeChanged('height', v)}
291
326
  />
292
- <Typography className={classes.disabled}>Min 400, Max 700</Typography>
293
- </div>
294
- </div>
327
+ <StyledDisabled>Min 400, Max 700</StyledDisabled>
328
+ </StyledColumnView>
329
+ </StyledDimensions>
295
330
  )}
296
- </div>
331
+ </StyledContent>
297
332
 
298
333
  <AlertDialog
299
334
  open={alertDialog.open}
@@ -302,12 +337,11 @@ const ConfigureChartPanel = (props) => {
302
337
  onClose={alertDialog.onClose}
303
338
  onConfirm={alertDialog.onConfirm}
304
339
  />
305
- </div>
340
+ </StyledWrapper>
306
341
  );
307
342
  };
308
343
 
309
344
  ConfigureChartPanel.propTypes = {
310
- classes: PropTypes.object,
311
345
  chartDimensions: PropTypes.object,
312
346
  domain: PropTypes.object,
313
347
  gridValues: PropTypes.object,
@@ -322,51 +356,4 @@ ConfigureChartPanel.propTypes = {
322
356
  chartTypeLabel: PropTypes.string,
323
357
  };
324
358
 
325
- const styles = (theme) => ({
326
- wrapper: {
327
- width: '450px',
328
- },
329
- content: {
330
- display: 'flex',
331
- flexDirection: 'column',
332
- width: '100%',
333
- marginTop: theme.spacing.unit * 3,
334
- },
335
- columnView: {
336
- display: 'flex',
337
- flexDirection: 'column',
338
- alignItems: 'center',
339
- },
340
- rowView: {
341
- display: 'flex',
342
- justifyContent: 'space-around',
343
- alignItems: 'center',
344
- },
345
- textField: {
346
- width: '130px',
347
- margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
348
- },
349
- mediumTextField: {
350
- width: '160px',
351
- margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
352
- },
353
- largeTextField: {
354
- width: '230px',
355
- margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
356
- },
357
- text: {
358
- fontStyle: 'italic',
359
- margin: `${theme.spacing.unit}px 0`,
360
- },
361
- dimensions: {
362
- display: 'flex',
363
- justifyContent: 'space-between',
364
- alignItems: 'center',
365
- margin: `${theme.spacing.unit * 3}px 0`,
366
- },
367
- disabled: {
368
- color: color.disabled(),
369
- },
370
- });
371
-
372
- export default withStyles(styles)(ConfigureChartPanel);
359
+ export default ConfigureChartPanel;
package/src/chart-type.js CHANGED
@@ -1,29 +1,38 @@
1
1
  import React from 'react';
2
- import { withStyles } from '@material-ui/core/styles';
3
- import MenuItem from '@material-ui/core/MenuItem';
4
- import FormControl from '@material-ui/core/FormControl';
5
- import InputLabel from '@material-ui/core/InputLabel';
6
- import Select from '@material-ui/core/Select';
7
- import OutlinedInput from '@material-ui/core/OutlinedInput';
2
+ import { styled } from '@mui/material/styles';
3
+ import MenuItem from '@mui/material/MenuItem';
4
+ import FormControl from '@mui/material/FormControl';
5
+ import InputLabel from '@mui/material/InputLabel';
6
+ import { Select } from '@mui/material';
8
7
 
9
- const ChartType = withStyles(() => ({
10
- chartType: {
11
- width: '160px',
12
- },
13
- chartTypeLabel: {
14
- backgroundColor: 'transparent',
15
- },
16
- }))(({ onChange, value, classes, availableChartTypes, chartTypeLabel }) => (
17
- <div className={classes.chartType}>
18
- <FormControl variant={'outlined'} className={classes.chartType}>
19
- <InputLabel id="type-helper-label" className={classes.chartTypeLabel}>
8
+ const StyledContainer = styled('div')(() => ({
9
+ width: '160px',
10
+ }));
11
+
12
+ const StyledFormControl = styled(FormControl)(() => ({
13
+ width: '160px',
14
+ }));
15
+
16
+ const StyledInputLabel = styled(InputLabel)(() => ({
17
+ backgroundColor: 'transparent',
18
+ }));
19
+
20
+ import PropTypes from 'prop-types';
21
+
22
+ const ChartType = ({ onChange, value, availableChartTypes, chartTypeLabel }) => (
23
+ <StyledContainer>
24
+ <StyledFormControl variant={'outlined'}>
25
+ <StyledInputLabel id="type-helper-label">
20
26
  {chartTypeLabel}
21
- </InputLabel>
27
+ </StyledInputLabel>
22
28
  <Select
23
29
  labelId="type-helper-label"
30
+ id="type-helper-label-select"
31
+ name="chartType"
24
32
  value={value}
25
33
  onChange={onChange}
26
- input={<OutlinedInput labelWidth={75} name="type" />}
34
+ label={chartTypeLabel}
35
+ MenuProps={{transitionDuration: { enter: 225, exit: 195 }}}
27
36
  >
28
37
  {availableChartTypes?.histogram && <MenuItem value={'histogram'}>{availableChartTypes.histogram}</MenuItem>}
29
38
  {availableChartTypes?.bar && <MenuItem value={'bar'}>{availableChartTypes.bar}</MenuItem>}
@@ -32,8 +41,22 @@ const ChartType = withStyles(() => ({
32
41
  {availableChartTypes?.dotPlot && <MenuItem value={'dotPlot'}>{availableChartTypes.dotPlot}</MenuItem>}
33
42
  {availableChartTypes?.linePlot && <MenuItem value={'linePlot'}>{availableChartTypes.linePlot}</MenuItem>}
34
43
  </Select>
35
- </FormControl>
36
- </div>
37
- ));
44
+ </StyledFormControl>
45
+ </StyledContainer>
46
+ );
47
+
48
+ ChartType.propTypes = {
49
+ onChange: PropTypes.func.isRequired,
50
+ value: PropTypes.string.isRequired,
51
+ availableChartTypes: PropTypes.shape({
52
+ histogram: PropTypes.string,
53
+ bar: PropTypes.string,
54
+ lineDot: PropTypes.string,
55
+ lineCross: PropTypes.string,
56
+ dotPlot: PropTypes.string,
57
+ linePlot: PropTypes.string,
58
+ }),
59
+ chartTypeLabel: PropTypes.string,
60
+ };
38
61
 
39
62
  export default ChartType;