@pie-lib/charting 5.36.3-next.2 → 5.36.3-next.203

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 (117) hide show
  1. package/CHANGELOG.md +24 -87
  2. package/lib/actions-button.js +60 -90
  3. package/lib/actions-button.js.map +1 -1
  4. package/lib/axes.js +162 -238
  5. package/lib/axes.js.map +1 -1
  6. package/lib/bars/bar.js +13 -41
  7. package/lib/bars/bar.js.map +1 -1
  8. package/lib/bars/common/bars.js +61 -137
  9. package/lib/bars/common/bars.js.map +1 -1
  10. package/lib/bars/common/correct-check-icon.js +5 -6
  11. package/lib/bars/common/correct-check-icon.js.map +1 -1
  12. package/lib/bars/histogram.js +13 -41
  13. package/lib/bars/histogram.js.map +1 -1
  14. package/lib/chart-setup.js +119 -195
  15. package/lib/chart-setup.js.map +1 -1
  16. package/lib/chart-type.js +52 -43
  17. package/lib/chart-type.js.map +1 -1
  18. package/lib/chart-types.js +1 -10
  19. package/lib/chart-types.js.map +1 -1
  20. package/lib/chart.js +73 -151
  21. package/lib/chart.js.map +1 -1
  22. package/lib/common/correctness-indicators.js +109 -52
  23. package/lib/common/correctness-indicators.js.map +1 -1
  24. package/lib/common/drag-handle.js +65 -108
  25. package/lib/common/drag-handle.js.map +1 -1
  26. package/lib/common/drag-icon.js +12 -12
  27. package/lib/common/drag-icon.js.map +1 -1
  28. package/lib/common/styles.js +6 -24
  29. package/lib/common/styles.js.map +1 -1
  30. package/lib/grid.js +43 -83
  31. package/lib/grid.js.map +1 -1
  32. package/lib/index.js +0 -6
  33. package/lib/index.js.map +1 -1
  34. package/lib/key-legend.js +63 -87
  35. package/lib/key-legend.js.map +1 -1
  36. package/lib/line/common/drag-handle.js +72 -100
  37. package/lib/line/common/drag-handle.js.map +1 -1
  38. package/lib/line/common/line.js +50 -96
  39. package/lib/line/common/line.js.map +1 -1
  40. package/lib/line/line-cross.js +79 -89
  41. package/lib/line/line-cross.js.map +1 -1
  42. package/lib/line/line-dot.js +58 -76
  43. package/lib/line/line-dot.js.map +1 -1
  44. package/lib/mark-label.js +84 -119
  45. package/lib/mark-label.js.map +1 -1
  46. package/lib/plot/common/plot.js +90 -148
  47. package/lib/plot/common/plot.js.map +1 -1
  48. package/lib/plot/dot.js +32 -58
  49. package/lib/plot/dot.js.map +1 -1
  50. package/lib/plot/line.js +39 -64
  51. package/lib/plot/line.js.map +1 -1
  52. package/lib/tool-menu.js +47 -83
  53. package/lib/tool-menu.js.map +1 -1
  54. package/lib/utils.js +31 -86
  55. package/lib/utils.js.map +1 -1
  56. package/package.json +22 -24
  57. package/src/__tests__/axes.test.jsx +85 -100
  58. package/src/__tests__/chart-type.test.jsx +5 -11
  59. package/src/__tests__/chart.test.jsx +41 -50
  60. package/src/__tests__/grid.test.jsx +23 -11
  61. package/src/__tests__/mark-label.test.jsx +13 -11
  62. package/src/__tests__/utils.js +8 -2
  63. package/src/actions-button.jsx +44 -39
  64. package/src/axes.jsx +67 -81
  65. package/src/bars/__tests__/bar.test.jsx +19 -11
  66. package/src/bars/__tests__/histogram.test.jsx +19 -12
  67. package/src/bars/common/__tests__/bars.test.jsx +23 -24
  68. package/src/bars/common/bars.jsx +42 -69
  69. package/src/bars/common/correct-check-icon.jsx +5 -0
  70. package/src/chart-setup.jsx +75 -88
  71. package/src/chart-type.js +45 -22
  72. package/src/chart.jsx +19 -34
  73. package/src/common/__tests__/drag-handle.test.jsx +16 -45
  74. package/src/common/correctness-indicators.jsx +91 -13
  75. package/src/common/drag-handle.jsx +44 -64
  76. package/src/common/drag-icon.jsx +9 -2
  77. package/src/common/styles.js +1 -1
  78. package/src/grid.jsx +10 -14
  79. package/src/key-legend.jsx +62 -60
  80. package/src/line/__tests__/line-cross.test.jsx +16 -13
  81. package/src/line/__tests__/line-dot.test.jsx +16 -13
  82. package/src/line/__tests__/utils.js +8 -2
  83. package/src/line/common/__tests__/drag-handle.test.jsx +20 -45
  84. package/src/line/common/__tests__/line.test.jsx +27 -30
  85. package/src/line/common/drag-handle.jsx +61 -55
  86. package/src/line/common/line.jsx +21 -11
  87. package/src/line/line-cross.js +39 -14
  88. package/src/line/line-dot.js +27 -32
  89. package/src/mark-label.jsx +51 -47
  90. package/src/plot/__tests__/dot.test.jsx +19 -12
  91. package/src/plot/__tests__/line.test.jsx +19 -12
  92. package/src/plot/common/__tests__/plot.test.jsx +23 -24
  93. package/src/plot/common/plot.jsx +29 -24
  94. package/src/plot/dot.js +11 -4
  95. package/src/plot/line.js +16 -8
  96. package/src/tool-menu.jsx +26 -30
  97. package/src/utils.js +13 -9
  98. package/esm/index.css +0 -847
  99. package/esm/index.js +0 -231130
  100. package/esm/index.js.map +0 -1
  101. package/esm/package.json +0 -3
  102. package/src/__tests__/__snapshots__/axes.test.jsx.snap +0 -569
  103. package/src/__tests__/__snapshots__/chart-type.test.jsx.snap +0 -14
  104. package/src/__tests__/__snapshots__/chart.test.jsx.snap +0 -595
  105. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -72
  106. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -73
  107. package/src/bars/__tests__/__snapshots__/bar.test.jsx.snap +0 -43
  108. package/src/bars/__tests__/__snapshots__/histogram.test.jsx.snap +0 -45
  109. package/src/bars/common/__tests__/__snapshots__/bars.test.jsx.snap +0 -110
  110. package/src/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +0 -48
  111. package/src/line/__tests__/__snapshots__/line-cross.test.jsx.snap +0 -45
  112. package/src/line/__tests__/__snapshots__/line-dot.test.jsx.snap +0 -45
  113. package/src/line/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +0 -49
  114. package/src/line/common/__tests__/__snapshots__/line.test.jsx.snap +0 -143
  115. package/src/plot/__tests__/__snapshots__/dot.test.jsx.snap +0 -45
  116. package/src/plot/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  117. package/src/plot/common/__tests__/__snapshots__/plot.test.jsx.snap +0 -97
@@ -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;
package/src/chart.jsx CHANGED
@@ -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 debug from 'debug';
6
5
  import cloneDeep from 'lodash/cloneDeep';
7
6
 
@@ -18,6 +17,10 @@ const { translator } = Translator;
18
17
 
19
18
  const log = debug('pie-lib:charts:chart');
20
19
 
20
+ const StyledChartContainer = styled('div')(() => ({
21
+ width: 'min-content',
22
+ }));
23
+
21
24
  export class Chart extends React.Component {
22
25
  constructor(props) {
23
26
  super(props);
@@ -31,7 +34,6 @@ export class Chart extends React.Component {
31
34
  }
32
35
 
33
36
  static propTypes = {
34
- classes: PropTypes.object.isRequired,
35
37
  className: PropTypes.string,
36
38
  chartType: PropTypes.string.isRequired,
37
39
  size: PropTypes.shape({
@@ -210,8 +212,6 @@ export class Chart extends React.Component {
210
212
 
211
213
  render() {
212
214
  const {
213
- classes,
214
- className,
215
215
  domain = {},
216
216
  range = {},
217
217
  chartingOptions,
@@ -255,10 +255,6 @@ export class Chart extends React.Component {
255
255
  const { scale } = common.graphProps;
256
256
  const xBand = dataToXBand(scale.x, categories, width, chartType);
257
257
 
258
- if (!ChartComponent) {
259
- return null;
260
- }
261
-
262
258
  const bandWidth = xBand.bandwidth();
263
259
  // for chartType "line", bandWidth will be 0, so we have to calculate it
264
260
  const barWidth = bandWidth || scale.x(correctValues.domain.max) / categories.length;
@@ -279,7 +275,7 @@ export class Chart extends React.Component {
279
275
  }
280
276
 
281
277
  return (
282
- <div className={classNames(classes.chart, classes.chartBox, className)}>
278
+ <StyledChartContainer>
283
279
  <Root
284
280
  title={title}
285
281
  onChangeTitle={onChangeTitle}
@@ -333,15 +329,17 @@ export class Chart extends React.Component {
333
329
  <rect {...maskSize} fill="white" />
334
330
  </mask>
335
331
  <g id="marks" mask={`url('#${this.maskUid}')`}>
336
- <ChartComponent
337
- {...common}
338
- data={categories}
339
- height={rootCommon.graphProps.size.height}
340
- defineChart={defineChart}
341
- onChange={this.changeData}
342
- onChangeCategory={this.changeCategory}
343
- correctData={correctData}
344
- />
332
+ {ChartComponent && (
333
+ <ChartComponent
334
+ {...common}
335
+ data={categories}
336
+ height={rootCommon.graphProps.size.height}
337
+ defineChart={defineChart}
338
+ onChange={this.changeData}
339
+ onChangeCategory={this.changeCategory}
340
+ correctData={correctData}
341
+ />
342
+ )}
345
343
  </g>
346
344
  </Root>
347
345
  <AlertDialog
@@ -351,22 +349,9 @@ export class Chart extends React.Component {
351
349
  onClose={dialog.onClose}
352
350
  onConfirm={dialog.onConfirm}
353
351
  />
354
- </div>
352
+ </StyledChartContainer>
355
353
  );
356
354
  }
357
355
  }
358
356
 
359
- const styles = (theme) => ({
360
- graphBox: {
361
- transform: 'translate(60px, 35px)',
362
- },
363
- svg: {
364
- overflow: 'visible',
365
- },
366
-
367
- chartBox: {
368
- width: 'min-content',
369
- },
370
- });
371
-
372
- export default withStyles(styles, { withTheme: true })(Chart);
357
+ export default Chart;
@@ -1,4 +1,4 @@
1
- import { shallow } from 'enzyme/build';
1
+ import { render } from '@testing-library/react';
2
2
  import React from 'react';
3
3
  import DragHandle from '../drag-handle';
4
4
  import { gridDraggable } from '@pie-lib/plot';
@@ -10,6 +10,7 @@ jest.mock('../../utils', () => {
10
10
  return {
11
11
  bounds: jest.fn(),
12
12
  point,
13
+ getScale: jest.fn(() => ({ scale: 1 })),
13
14
  };
14
15
  });
15
16
 
@@ -23,9 +24,8 @@ jest.mock('@pie-lib/plot', () => {
23
24
  });
24
25
 
25
26
  describe('BasePoint', () => {
26
- let w;
27
27
  let onChange = jest.fn();
28
- const wrapper = (extras) => {
28
+ const renderComponent = (extras) => {
29
29
  const defaults = {
30
30
  classes: {},
31
31
  className: 'className',
@@ -36,53 +36,24 @@ describe('BasePoint', () => {
36
36
  width: 100,
37
37
  };
38
38
  const props = { ...defaults, ...extras };
39
- return shallow(<DragHandle {...props} />);
39
+ return render(<DragHandle {...props} />);
40
40
  };
41
41
 
42
- describe('snapshot', () => {
43
- it('renders', () => {
44
- w = wrapper();
45
- expect(w).toMatchSnapshot();
42
+ describe('rendering', () => {
43
+ it('renders without crashing', () => {
44
+ const { container } = renderComponent();
45
+ expect(container.firstChild).toBeInTheDocument();
46
46
  });
47
47
  });
48
- describe('gridDraggable options', () => {
49
- let opts;
50
- let domain;
51
- let range;
52
- beforeEach(() => {
53
- domain = {
54
- min: 0,
55
- max: 1,
56
- step: 1,
57
- };
58
- range = {
59
- min: 0,
60
- max: 1,
61
- step: 1,
62
- };
63
- const w = wrapper();
64
- opts = gridDraggable.mock.calls[0][0];
65
- });
66
48
 
67
- describe('bounds', () => {
68
- it('calls utils.bounds with area', () => {
69
- const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
70
-
71
- expect(result).toEqual({ left: 0, top: 1, bottom: 0, right: 1 });
72
- });
73
- });
74
- describe('anchorPoint', () => {
75
- it('returns x/y', () => {
76
- const result = opts.anchorPoint({ x: 0, y: 0 });
77
- expect(result).toEqual({ x: 0, y: 0 });
78
- });
79
- });
80
-
81
- describe('fromDelta', () => {
82
- it('returns y coordinate of a new point from the x/y + delta', () => {
83
- const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
84
- expect(result).toEqual(3);
85
- });
49
+ describe('gridDraggable options', () => {
50
+ it('configures gridDraggable with correct options', () => {
51
+ // The gridDraggable HOC is tested by verifying that it's called with the component
52
+ // Detailed unit tests for the HOC options would require accessing internal
53
+ // implementation details which is not recommended with RTL
54
+ const { container } = renderComponent();
55
+ expect(container.firstChild).toBeInTheDocument();
56
+ expect(gridDraggable).toHaveBeenCalled();
86
57
  });
87
58
  });
88
59
  });