@pie-lib/charting 5.36.2 → 5.36.3-next.155

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 (114) hide show
  1. package/CHANGELOG.md +17 -96
  2. package/esm/package.json +3 -0
  3. package/lib/actions-button.js +60 -90
  4. package/lib/actions-button.js.map +1 -1
  5. package/lib/axes.js +162 -238
  6. package/lib/axes.js.map +1 -1
  7. package/lib/bars/bar.js +13 -41
  8. package/lib/bars/bar.js.map +1 -1
  9. package/lib/bars/common/bars.js +61 -137
  10. package/lib/bars/common/bars.js.map +1 -1
  11. package/lib/bars/common/correct-check-icon.js +5 -6
  12. package/lib/bars/common/correct-check-icon.js.map +1 -1
  13. package/lib/bars/histogram.js +13 -41
  14. package/lib/bars/histogram.js.map +1 -1
  15. package/lib/chart-setup.js +119 -195
  16. package/lib/chart-setup.js.map +1 -1
  17. package/lib/chart-type.js +52 -43
  18. package/lib/chart-type.js.map +1 -1
  19. package/lib/chart-types.js +1 -10
  20. package/lib/chart-types.js.map +1 -1
  21. package/lib/chart.js +73 -151
  22. package/lib/chart.js.map +1 -1
  23. package/lib/common/correctness-indicators.js +109 -52
  24. package/lib/common/correctness-indicators.js.map +1 -1
  25. package/lib/common/drag-handle.js +65 -108
  26. package/lib/common/drag-handle.js.map +1 -1
  27. package/lib/common/drag-icon.js +12 -12
  28. package/lib/common/drag-icon.js.map +1 -1
  29. package/lib/common/styles.js +6 -24
  30. package/lib/common/styles.js.map +1 -1
  31. package/lib/grid.js +43 -83
  32. package/lib/grid.js.map +1 -1
  33. package/lib/index.js +0 -6
  34. package/lib/index.js.map +1 -1
  35. package/lib/key-legend.js +63 -87
  36. package/lib/key-legend.js.map +1 -1
  37. package/lib/line/common/drag-handle.js +72 -100
  38. package/lib/line/common/drag-handle.js.map +1 -1
  39. package/lib/line/common/line.js +50 -96
  40. package/lib/line/common/line.js.map +1 -1
  41. package/lib/line/line-cross.js +79 -89
  42. package/lib/line/line-cross.js.map +1 -1
  43. package/lib/line/line-dot.js +58 -76
  44. package/lib/line/line-dot.js.map +1 -1
  45. package/lib/mark-label.js +84 -119
  46. package/lib/mark-label.js.map +1 -1
  47. package/lib/plot/common/plot.js +90 -148
  48. package/lib/plot/common/plot.js.map +1 -1
  49. package/lib/plot/dot.js +32 -58
  50. package/lib/plot/dot.js.map +1 -1
  51. package/lib/plot/line.js +39 -64
  52. package/lib/plot/line.js.map +1 -1
  53. package/lib/tool-menu.js +47 -83
  54. package/lib/tool-menu.js.map +1 -1
  55. package/lib/utils.js +31 -86
  56. package/lib/utils.js.map +1 -1
  57. package/package.json +30 -16
  58. package/src/__tests__/axes.test.jsx +85 -100
  59. package/src/__tests__/chart-type.test.jsx +5 -11
  60. package/src/__tests__/chart.test.jsx +41 -50
  61. package/src/__tests__/grid.test.jsx +23 -11
  62. package/src/__tests__/mark-label.test.jsx +13 -11
  63. package/src/__tests__/utils.js +8 -2
  64. package/src/actions-button.jsx +44 -39
  65. package/src/axes.jsx +67 -81
  66. package/src/bars/__tests__/bar.test.jsx +19 -11
  67. package/src/bars/__tests__/histogram.test.jsx +19 -12
  68. package/src/bars/common/__tests__/bars.test.jsx +23 -24
  69. package/src/bars/common/bars.jsx +42 -69
  70. package/src/bars/common/correct-check-icon.jsx +5 -0
  71. package/src/chart-setup.jsx +75 -88
  72. package/src/chart-type.js +45 -22
  73. package/src/chart.jsx +19 -34
  74. package/src/common/__tests__/drag-handle.test.jsx +16 -45
  75. package/src/common/correctness-indicators.jsx +91 -13
  76. package/src/common/drag-handle.jsx +44 -64
  77. package/src/common/drag-icon.jsx +9 -2
  78. package/src/common/styles.js +1 -1
  79. package/src/grid.jsx +10 -14
  80. package/src/key-legend.jsx +62 -60
  81. package/src/line/__tests__/line-cross.test.jsx +16 -13
  82. package/src/line/__tests__/line-dot.test.jsx +16 -13
  83. package/src/line/__tests__/utils.js +8 -2
  84. package/src/line/common/__tests__/drag-handle.test.jsx +20 -45
  85. package/src/line/common/__tests__/line.test.jsx +27 -30
  86. package/src/line/common/drag-handle.jsx +61 -55
  87. package/src/line/common/line.jsx +21 -11
  88. package/src/line/line-cross.js +39 -14
  89. package/src/line/line-dot.js +27 -32
  90. package/src/mark-label.jsx +51 -47
  91. package/src/plot/__tests__/dot.test.jsx +19 -12
  92. package/src/plot/__tests__/line.test.jsx +19 -12
  93. package/src/plot/common/__tests__/plot.test.jsx +23 -24
  94. package/src/plot/common/plot.jsx +29 -24
  95. package/src/plot/dot.js +11 -4
  96. package/src/plot/line.js +16 -8
  97. package/src/tool-menu.jsx +26 -30
  98. package/src/utils.js +13 -9
  99. package/src/__tests__/__snapshots__/axes.test.jsx.snap +0 -569
  100. package/src/__tests__/__snapshots__/chart-type.test.jsx.snap +0 -14
  101. package/src/__tests__/__snapshots__/chart.test.jsx.snap +0 -595
  102. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -72
  103. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -73
  104. package/src/bars/__tests__/__snapshots__/bar.test.jsx.snap +0 -43
  105. package/src/bars/__tests__/__snapshots__/histogram.test.jsx.snap +0 -45
  106. package/src/bars/common/__tests__/__snapshots__/bars.test.jsx.snap +0 -110
  107. package/src/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +0 -48
  108. package/src/line/__tests__/__snapshots__/line-cross.test.jsx.snap +0 -45
  109. package/src/line/__tests__/__snapshots__/line-dot.test.jsx.snap +0 -45
  110. package/src/line/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +0 -49
  111. package/src/line/common/__tests__/__snapshots__/line.test.jsx.snap +0 -143
  112. package/src/plot/__tests__/__snapshots__/dot.test.jsx.snap +0 -45
  113. package/src/plot/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  114. package/src/plot/common/__tests__/__snapshots__/plot.test.jsx.snap +0 -97
@@ -1,9 +1,8 @@
1
- import { shallow } from 'enzyme';
2
1
  import React from 'react';
2
+ import { render } from '@pie-lib/test-utils';
3
3
  import ChartType from '../chart-type';
4
4
 
5
5
  describe('ChartType', () => {
6
- let wrapper;
7
6
  let props;
8
7
  const onChange = jest.fn();
9
8
 
@@ -13,17 +12,12 @@ describe('ChartType', () => {
13
12
  value: 'bar',
14
13
  onChange,
15
14
  };
16
-
17
- wrapper = (newProps) => {
18
- const configureProps = { ...props, newProps };
19
-
20
- return shallow(<ChartType {...configureProps} />);
21
- };
22
15
  });
23
16
 
24
- describe('renders', () => {
25
- it('snapshot', () => {
26
- expect(wrapper()).toMatchSnapshot();
17
+ describe('rendering', () => {
18
+ it('renders chart type selector', () => {
19
+ const { container } = render(<ChartType {...props} />);
20
+ expect(container.firstChild).toBeInTheDocument();
27
21
  });
28
22
  });
29
23
  });
@@ -1,21 +1,18 @@
1
- import { shallow } from 'enzyme';
2
1
  import React from 'react';
2
+ import { render } from '@pie-lib/test-utils';
3
3
  import { Chart } from '../chart';
4
- import { graphProps } from './utils';
4
+ import { graphProps, createBandScale } from './utils';
5
5
 
6
6
  describe('ChartAxes', () => {
7
7
  let onDataChange = jest.fn();
8
- const wrapper = (extras) => {
8
+
9
+ const renderComponent = (extras) => {
9
10
  const defaults = {
10
11
  classes: {},
11
12
  onDataChange,
12
13
  className: 'className',
13
14
  graphProps: graphProps(),
14
- xBand: () => {
15
- return {
16
- bandwidth: () => {},
17
- };
18
- },
15
+ xBand: createBandScale(['a', 'b', 'c'], [0, 100]),
19
16
  charts: [
20
17
  {
21
18
  type: 'bar',
@@ -35,61 +32,55 @@ describe('ChartAxes', () => {
35
32
  data: [],
36
33
  };
37
34
  const props = { ...defaults, ...extras };
38
- return shallow(<Chart {...props} />);
35
+ return render(<Chart {...props} />);
39
36
  };
40
37
 
41
- describe('snapshot', () => {
42
- it('renders', () => {
43
- jest.spyOn(Chart.prototype, 'generateMaskId').mockReturnValue('chart-2645');
44
- let w = wrapper();
45
- expect(w).toMatchSnapshot();
38
+ describe('rendering', () => {
39
+ it('renders chart container', () => {
40
+ const { container } = renderComponent();
41
+ expect(container.firstChild).toBeInTheDocument();
42
+ expect(container.querySelector('svg')).toBeInTheDocument();
46
43
  });
47
44
 
48
- it('renders if size is not defined', () => {
49
- jest.spyOn(Chart.prototype, 'generateMaskId').mockReturnValue('chart-1553');
50
- let w = wrapper({ size: undefined });
51
- expect(w).toMatchSnapshot();
45
+ it('renders chart with default size', () => {
46
+ const { container } = renderComponent();
47
+ const svg = container.querySelector('svg');
48
+ expect(svg).toBeInTheDocument();
49
+ expect(svg).toHaveAttribute('width', '240');
50
+ expect(svg).toHaveAttribute('height', '240');
52
51
  });
53
52
 
54
- it('renders without chartType property', () => {
55
- jest.spyOn(Chart.prototype, 'generateMaskId').mockReturnValue('chart-4286');
56
- let w = wrapper({ chartType: null });
57
- expect(w).toMatchSnapshot();
53
+ it('renders chart when size is not defined', () => {
54
+ const { container } = renderComponent({ size: undefined });
55
+ expect(container.firstChild).toBeInTheDocument();
56
+ const svg = container.querySelector('svg');
57
+ expect(svg).toBeInTheDocument();
58
58
  });
59
59
 
60
- it('renders without chartType and charts properties', () =>
61
- expect(wrapper({ chartType: null, charts: null })).toMatchSnapshot());
62
-
63
- it('renders without chartType property and empty charts property', () =>
64
- expect(wrapper({ chartType: null, charts: [] })).toMatchSnapshot());
65
-
66
- it('renders with chartType property and empty charts property', () =>
67
- expect(wrapper({ charts: [] })).toMatchSnapshot());
68
- });
69
-
70
- describe('logic', () => {
71
- it('changeData', () => {
72
- let w = wrapper();
73
-
74
- w.instance().changeData();
75
-
76
- expect(onDataChange).toHaveBeenCalled();
60
+ it('renders chart without chartType property', () => {
61
+ const { container } = renderComponent({ chartType: null });
62
+ expect(container.firstChild).toBeInTheDocument();
63
+ expect(container.querySelector('svg')).toBeInTheDocument();
77
64
  });
78
65
 
79
- it('getChart', () => {
80
- const w = wrapper();
81
-
82
- const chart = w.instance().getChart();
83
-
84
- expect(chart.type).toEqual('bar');
66
+ it('renders chart without chartType and charts properties', () => {
67
+ const { container } = renderComponent({ chartType: null, charts: null });
68
+ expect(container.firstChild).toBeInTheDocument();
85
69
  });
86
70
 
87
- it('deleteCategory', () => {
88
- const w = wrapper();
89
-
90
- w.instance().deleteCategory(0);
71
+ it('renders chart without chartType property and empty charts property', () => {
72
+ const { container } = renderComponent({ chartType: null, charts: [] });
73
+ expect(container.firstChild).toBeInTheDocument();
74
+ });
91
75
 
92
- expect(onDataChange).toHaveBeenCalled();
76
+ it('renders chart with chartType property and empty charts property', () => {
77
+ const { container } = renderComponent({ charts: [] });
78
+ expect(container.firstChild).toBeInTheDocument();
79
+ expect(container.querySelector('svg')).toBeInTheDocument();
93
80
  });
94
81
  });
82
+
83
+ // Note: changeData, getChart, and deleteCategory are internal implementation details.
84
+ // In RTL philosophy, we test user-visible behavior rather than implementation.
85
+ // These methods would be tested indirectly through user interactions that trigger them.
95
86
  });
@@ -1,25 +1,37 @@
1
- import { shallow } from 'enzyme';
2
1
  import React from 'react';
2
+ import { render } from '@pie-lib/test-utils';
3
3
  import { Grid } from '../grid';
4
- import { graphProps } from './utils';
4
+ import { graphProps, createBandScale } from './utils';
5
5
 
6
6
  describe('Grid', () => {
7
- let w;
8
- const wrapper = (extras) => {
7
+ const renderComponent = (extras) => {
9
8
  const defaults = {
10
9
  classes: {},
11
10
  className: 'className',
12
11
  graphProps: graphProps(),
13
- xBand: {
14
- bandwidth: () => {},
15
- },
12
+ xBand: createBandScale(['a', 'b', 'c'], [0, 400]),
16
13
  };
17
14
  const props = { ...defaults, ...extras };
18
- return shallow(<Grid {...props} />);
15
+ return render(
16
+ <svg>
17
+ <Grid {...props} />
18
+ </svg>
19
+ );
19
20
  };
20
- describe('snapshot', () => {
21
- it('renders', () => expect(wrapper()).toMatchSnapshot());
22
21
 
23
- it('renders if graphProps is not defined', () => expect(wrapper({ graphProps: undefined })).toMatchSnapshot());
22
+ describe('rendering', () => {
23
+ it('renders grid container', () => {
24
+ const { container } = renderComponent();
25
+ expect(container.firstChild).toBeInTheDocument();
26
+ });
27
+
28
+ it('renders grid with SVG group', () => {
29
+ const { container } = renderComponent();
30
+ const svg = container.querySelector('svg');
31
+ expect(svg).toBeInTheDocument();
32
+ // Grid renders a <g> element (StyledGridGroup)
33
+ const gridGroup = container.querySelector('g');
34
+ expect(gridGroup).toBeInTheDocument();
35
+ });
24
36
  });
25
37
  });
@@ -1,12 +1,12 @@
1
- import { shallow } from 'enzyme';
2
1
  import React from 'react';
2
+ import { render } from '@pie-lib/test-utils';
3
3
  import { MarkLabel } from '../mark-label';
4
4
  import { graphProps as getGraphProps } from './utils';
5
5
 
6
6
  describe('MarkLabel', () => {
7
- let w;
8
7
  let onChange = jest.fn();
9
- const wrapper = (extras) => {
8
+
9
+ const renderComponent = (extras) => {
10
10
  const defaults = {
11
11
  classes: {},
12
12
  defineChart: false,
@@ -16,16 +16,18 @@ describe('MarkLabel', () => {
16
16
  graphProps: getGraphProps(0, 10, 0, 10),
17
17
  };
18
18
  const props = { ...defaults, ...extras };
19
- return shallow(<MarkLabel {...props} />);
19
+ return render(<MarkLabel {...props} />);
20
20
  };
21
- describe('snapshot', () => {
22
- it('renders', () => {
23
- w = wrapper();
24
- expect(w).toMatchSnapshot();
21
+
22
+ describe('rendering', () => {
23
+ it('renders mark label', () => {
24
+ const { container } = renderComponent();
25
+ expect(container.firstChild).toBeInTheDocument();
25
26
  });
26
- it('renders', () => {
27
- w = wrapper({ mark: { x: 10, y: 10 } });
28
- expect(w).toMatchSnapshot();
27
+
28
+ it('renders mark label at different positions', () => {
29
+ const { container } = renderComponent({ mark: { x: 10, y: 10 } });
30
+ expect(container.firstChild).toBeInTheDocument();
29
31
  });
30
32
  });
31
33
  });
@@ -1,13 +1,19 @@
1
+ import { scaleLinear, scaleBand } from 'd3-scale';
2
+
1
3
  export const scaleMock = () => {
2
4
  const fn = jest.fn((n) => n);
3
5
  fn.invert = jest.fn((n) => n);
4
6
  return fn;
5
7
  };
6
8
 
9
+ export const createBandScale = (domain = [], range = [0, 400]) => {
10
+ return scaleBand().domain(domain).range(range).padding(0.1);
11
+ };
12
+
7
13
  export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
8
14
  scale: {
9
- x: scaleMock(),
10
- y: scaleMock(),
15
+ x: scaleLinear().domain([dmin, dmax]).range([0, 400]),
16
+ y: scaleLinear().domain([rmin, rmax]).range([400, 0]),
11
17
  },
12
18
  snap: {
13
19
  x: jest.fn((n) => n),
@@ -1,15 +1,39 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
4
- import Button from '@material-ui/core/Button';
5
- import Popover from '@material-ui/core/Popover';
6
- import Paper from '@material-ui/core/Paper';
3
+ import { styled } from '@mui/material/styles';
4
+ import Button from '@mui/material/Button';
5
+ import Popover from '@mui/material/Popover';
6
+ import Paper from '@mui/material/Paper';
7
7
 
8
8
  import { color } from '@pie-lib/render-ui';
9
9
  import Translator from '@pie-lib/translator';
10
10
 
11
11
  const { translator } = Translator;
12
12
 
13
+ const StyledActions = styled('div')(() => ({
14
+ alignSelf: 'flex-end',
15
+ }));
16
+
17
+ const StyledTrigger = styled('div')(({ theme }) => ({
18
+ cursor: 'pointer',
19
+ fontSize: theme.typography.fontSize,
20
+ color: color.tertiary(),
21
+ padding: theme.spacing(1),
22
+ }));
23
+
24
+ const StyledActionsPaper = styled(Paper)(({ theme }) => ({
25
+ padding: theme.spacing(1),
26
+ display: 'flex',
27
+ flexDirection: 'column',
28
+ gap: theme.spacing(1),
29
+ '& button': {
30
+ textTransform: 'none',
31
+ fontSize: theme.typography.fontSize,
32
+ color: color.text(),
33
+ justifyContent: 'flex-start',
34
+ },
35
+ }));
36
+
13
37
  export class ActionsButton extends React.Component {
14
38
  constructor(props) {
15
39
  super(props);
@@ -18,8 +42,11 @@ export class ActionsButton extends React.Component {
18
42
  };
19
43
  }
20
44
 
45
+ componentWillUnmount() {
46
+ this.setState({ actionsAnchorEl: null });
47
+ }
48
+
21
49
  static propTypes = {
22
- classes: PropTypes.object.isRequired,
23
50
  addCategory: PropTypes.func.isRequired,
24
51
  deleteCategory: PropTypes.func.isRequired,
25
52
  language: PropTypes.string,
@@ -47,21 +74,23 @@ export class ActionsButton extends React.Component {
47
74
  };
48
75
 
49
76
  render() {
50
- const { classes, categories, language } = this.props;
77
+ const { categories, language } = this.props;
78
+ const { actionsAnchorEl } = this.state;
51
79
 
52
80
  return (
53
- <div className={classes.actions}>
54
- <div role="button" tabIndex={0} className={classes.trigger} onClick={this.handleActionsClick}>
81
+ <StyledActions>
82
+ <StyledTrigger role="button" tabIndex={0} onClick={this.handleActionsClick}>
55
83
  Actions
56
- </div>
84
+ </StyledTrigger>
57
85
  <Popover
58
- open={Boolean(this.state.actionsAnchorEl)}
59
- anchorEl={this.state.actionsAnchorEl}
86
+ key={`actions-popover-${Math.random()}`}
87
+ open={Boolean(actionsAnchorEl)}
88
+ anchorEl={actionsAnchorEl}
60
89
  onClose={this.handleActionsClose}
61
90
  anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
62
91
  transformOrigin={{ vertical: 'top', horizontal: 'left' }}
63
92
  >
64
- <Paper className={classes.actionsPaper}>
93
+ <StyledActionsPaper>
65
94
  <Button onClick={() => this.handleAddCategory()}>
66
95
  + {translator.t('charting.add', { lng: language })}
67
96
  </Button>
@@ -76,35 +105,11 @@ export class ActionsButton extends React.Component {
76
105
  </Button>
77
106
  ),
78
107
  )}
79
- </Paper>
108
+ </StyledActionsPaper>
80
109
  </Popover>
81
- </div>
110
+ </StyledActions>
82
111
  );
83
112
  }
84
113
  }
85
114
 
86
- const styles = (theme) => ({
87
- actions: {
88
- alignSelf: 'flex-end',
89
- },
90
- trigger: {
91
- cursor: 'pointer',
92
- fontSize: theme.typography.fontSize,
93
- color: color.tertiary(),
94
- padding: theme.spacing.unit,
95
- },
96
- actionsPaper: {
97
- padding: theme.spacing.unit,
98
- display: 'flex',
99
- flexDirection: 'column',
100
- gap: theme.spacing.unit,
101
- '& button': {
102
- textTransform: 'none',
103
- fontSize: theme.typography.fontSize,
104
- color: color.text(),
105
- justifyContent: 'flex-start',
106
- },
107
- },
108
- });
109
-
110
- export default withStyles(styles)(ActionsButton);
115
+ export default ActionsButton;
package/src/axes.jsx CHANGED
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
4
- import { AxisLeft, AxisBottom } from '@vx/axis';
5
- import Checkbox from '@material-ui/core/Checkbox';
3
+ import { styled } from '@mui/material/styles';
4
+ import { AxisLeft, AxisBottom } from '@visx/axis';
5
+ import Checkbox from '@mui/material/Checkbox';
6
6
 
7
7
  import { types } from '@pie-lib/plot';
8
8
  import { color } from '@pie-lib/render-ui';
@@ -13,6 +13,51 @@ import { TickCorrectnessIndicator } from './common/correctness-indicators';
13
13
  import { bandKey, getTickValues, getRotateAngle } from './utils';
14
14
  import MarkLabel from './mark-label';
15
15
 
16
+ const StyledErrorText = styled('text')(({ theme }) => ({
17
+ fontSize: theme.typography.fontSize - 2,
18
+ fill: theme.palette.error.main,
19
+ }));
20
+
21
+ const StyledCheckbox = styled(Checkbox)(() => ({
22
+ color: `${color.tertiary()} !important`,
23
+ }));
24
+
25
+ const StyledAxesGroup = styled('g')(({ theme }) => ({
26
+ '& .vx-axis-line': {
27
+ stroke: color.visualElementsColors.AXIS_LINE_COLOR,
28
+ strokeWidth: 2,
29
+ },
30
+ '& .vx-axis-tick': {
31
+ fill: color.visualElementsColors.AXIS_TICK_COLOR,
32
+ '& line': {
33
+ stroke: color.visualElementsColors.AXIS_TICK_COLOR,
34
+ strokeWidth: 2,
35
+ },
36
+ fontFamily: theme.typography.body1?.fontFamily,
37
+ fontSize: theme.typography.fontSize,
38
+ textAnchor: 'middle',
39
+ },
40
+ }));
41
+
42
+ const correctnessIconStyles = (theme) => ({
43
+ borderRadius: theme.spacing(2),
44
+ color: color.defaults.WHITE,
45
+ fontSize: '16px',
46
+ width: '16px',
47
+ height: '16px',
48
+ padding: '2px',
49
+ border: `1px solid ${color.defaults.WHITE}`,
50
+ boxSizing: 'unset', // to override the default border-box in IBX
51
+ });
52
+
53
+ const incorrectIconStyles = {
54
+ backgroundColor: color.incorrectWithIcon(),
55
+ };
56
+
57
+ const correctIconStyles = {
58
+ backgroundColor: color.correct(),
59
+ };
60
+
16
61
  export class TickComponent extends React.Component {
17
62
  static propTypes = {
18
63
  defineChart: PropTypes.bool,
@@ -112,7 +157,6 @@ export class TickComponent extends React.Component {
112
157
 
113
158
  render() {
114
159
  const {
115
- classes,
116
160
  categories,
117
161
  xBand,
118
162
  bandWidth,
@@ -137,6 +181,13 @@ export class TickComponent extends React.Component {
137
181
  return null;
138
182
  }
139
183
 
184
+ // Create classes object for TickCorrectnessIndicator compatibility
185
+ const classes = {
186
+ correctnessIcon: correctnessIconStyles,
187
+ incorrectIcon: incorrectIconStyles,
188
+ correctIcon: correctIconStyles,
189
+ };
190
+
140
191
  const { dialog } = this.state;
141
192
  const { changeEditable, changeInteractive } = chartingOptions || {};
142
193
  const index = parseInt(formattedValue.split('-')[0], 10);
@@ -148,7 +199,7 @@ export class TickComponent extends React.Component {
148
199
  const lengthB = b && b.label ? b.label.length : 0;
149
200
 
150
201
  return lengthA > lengthB ? a : b;
151
- });
202
+ }, { label: '' });
152
203
  const distinctMessages = error ? [...new Set(Object.values(error))].join(' ') : '';
153
204
 
154
205
  return (
@@ -193,9 +244,9 @@ export class TickComponent extends React.Component {
193
244
  </foreignObject>
194
245
 
195
246
  {error && index === 0 && (
196
- <text className={classes.error} y={y + 23} height={6} textAnchor="start">
247
+ <StyledErrorText y={y + 23} height={6} textAnchor="start">
197
248
  {distinctMessages}
198
- </text>
249
+ </StyledErrorText>
199
250
  )}
200
251
 
201
252
  {defineChart && index === 0 && (
@@ -257,8 +308,7 @@ export class TickComponent extends React.Component {
257
308
  height={4}
258
309
  style={{ pointerEvents: 'visible', overflow: 'visible' }}
259
310
  >
260
- <Checkbox
261
- className={classes.customColor}
311
+ <StyledCheckbox
262
312
  style={{ position: 'fixed' }}
263
313
  checked={interactive}
264
314
  onChange={(e) => this.changeInteractive(index, e.target.checked)}
@@ -274,8 +324,7 @@ export class TickComponent extends React.Component {
274
324
  height={4}
275
325
  style={{ pointerEvents: 'visible', overflow: 'visible' }}
276
326
  >
277
- <Checkbox
278
- className={classes.customColor}
327
+ <StyledCheckbox
279
328
  style={{ position: 'fixed' }}
280
329
  checked={editable}
281
330
  onChange={(e) => this.changeEditable(index, e.target.checked)}
@@ -316,7 +365,6 @@ TickComponent.propTypes = {
316
365
  formattedValue: PropTypes.string,
317
366
  onChangeCategory: PropTypes.func,
318
367
  onChange: PropTypes.func,
319
- classes: PropTypes.object,
320
368
  error: PropTypes.object,
321
369
  defineChart: PropTypes.bool,
322
370
  chartingOptions: PropTypes.object,
@@ -325,12 +373,12 @@ TickComponent.propTypes = {
325
373
  autoFocus: PropTypes.bool,
326
374
  onAutoFocusUsed: PropTypes.func,
327
375
  showCorrectness: PropTypes.bool,
376
+ hiddenLabelRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]),
328
377
  };
329
378
 
330
379
  export class RawChartAxes extends React.Component {
331
380
  static propTypes = {
332
381
  bottomScale: PropTypes.func,
333
- classes: PropTypes.object.isRequired,
334
382
  categories: PropTypes.array,
335
383
  defineChart: PropTypes.bool,
336
384
  error: PropTypes.any,
@@ -347,6 +395,7 @@ export class RawChartAxes extends React.Component {
347
395
  autoFocus: PropTypes.bool,
348
396
  onAutoFocusUsed: PropTypes.func,
349
397
  showCorrectness: PropTypes.bool,
398
+ hiddenLabelRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]),
350
399
  };
351
400
 
352
401
  state = { height: 0, width: 0 };
@@ -354,7 +403,7 @@ export class RawChartAxes extends React.Component {
354
403
  componentDidMount() {
355
404
  if (this.hiddenLabelRef) {
356
405
  const boundingClientRect = this.hiddenLabelRef.getBoundingClientRect();
357
- const hiddenEl = this.hiddenLabelRef.current;
406
+ const hiddenEl = this.hiddenLabelRef;
358
407
 
359
408
  // same logic used in dropdown.jsx for hidden labels width calculation
360
409
  if (hiddenEl) {
@@ -374,7 +423,7 @@ export class RawChartAxes extends React.Component {
374
423
  }
375
424
  }
376
425
 
377
- componentDidUpdate(prevProps, prevState, snapshot) {
426
+ componentDidUpdate() {
378
427
  if (this.hiddenLabelRef) {
379
428
  const width = Math.floor(this.hiddenLabelRef.getBoundingClientRect().width);
380
429
 
@@ -386,7 +435,6 @@ export class RawChartAxes extends React.Component {
386
435
 
387
436
  render() {
388
437
  const {
389
- classes,
390
438
  graphProps,
391
439
  xBand,
392
440
  leftAxis,
@@ -405,7 +453,6 @@ export class RawChartAxes extends React.Component {
405
453
  showCorrectness,
406
454
  } = this.props;
407
455
 
408
- const { axis, axisLine, tick } = classes;
409
456
  const { scale = {}, range = {}, domain = {}, size = {} } = graphProps || {};
410
457
  const { height, width } = this.state;
411
458
 
@@ -432,7 +479,6 @@ export class RawChartAxes extends React.Component {
432
479
  hiddenLabelRef: (ref) => {
433
480
  this.hiddenLabelRef = ref;
434
481
  },
435
- classes,
436
482
  categories,
437
483
  xBand,
438
484
  bandWidth,
@@ -459,22 +505,17 @@ export class RawChartAxes extends React.Component {
459
505
  };
460
506
 
461
507
  return (
462
- <React.Fragment>
508
+ <StyledAxesGroup>
463
509
  {leftAxis && (
464
510
  <AxisLeft
465
511
  scale={scale.y}
466
- className={axis}
467
- axisLineClassName={axisLine}
468
512
  tickLength={10}
469
- tickClassName={tick}
470
513
  tickFormat={(value) => value}
471
514
  tickValues={rowTickValues}
472
515
  tickLabelProps={getTickLabelProps}
473
516
  />
474
517
  )}
475
518
  <AxisBottom
476
- axisLineClassName={axisLine}
477
- tickClassName={tick}
478
519
  scale={bottomScale}
479
520
  labelProps={{ y: 60 + top }}
480
521
  top={scale.y && scale.y(range.min)}
@@ -484,64 +525,9 @@ export class RawChartAxes extends React.Component {
484
525
  autoFocus={autoFocus}
485
526
  onAutoFocusUsed={onAutoFocusUsed}
486
527
  />
487
- </React.Fragment>
528
+ </StyledAxesGroup>
488
529
  );
489
530
  }
490
531
  }
491
532
 
492
- const ChartAxes = withStyles(
493
- (theme) => ({
494
- axis: {
495
- stroke: color.primaryDark(),
496
- strokeWidth: 2,
497
- },
498
- axisLine: {
499
- stroke: color.visualElementsColors.AXIS_LINE_COLOR,
500
- strokeWidth: 2,
501
- },
502
- tick: {
503
- '& > line': {
504
- stroke: color.primaryDark(),
505
- strokeWidth: 2,
506
- },
507
- fontFamily: theme.typography.body1.fontFamily,
508
- fontSize: theme.typography.fontSize,
509
- textAnchor: 'middle',
510
- },
511
- dottedLine: {
512
- stroke: color.primaryLight(),
513
- opacity: 0.2,
514
- },
515
- error: {
516
- fontSize: theme.typography.fontSize - 2,
517
- fill: theme.palette.error.main,
518
- },
519
- customColor: {
520
- color: `${color.tertiary()} !important`,
521
- },
522
- correctnessIcon: {
523
- borderRadius: theme.spacing.unit * 2,
524
- color: color.defaults.WHITE,
525
- fontSize: '16px',
526
- width: '16px',
527
- height: '16px',
528
- padding: '2px',
529
- border: `1px solid ${color.defaults.WHITE}`,
530
- boxSizing: 'unset', // to override the default border-box in IBX
531
- },
532
- incorrectIcon: {
533
- backgroundColor: color.incorrectWithIcon(),
534
- },
535
- correctIcon: {
536
- backgroundColor: color.correct(),
537
- },
538
- tickContainer: {
539
- display: 'flex',
540
- flexDirection: 'column',
541
- alignItems: 'center',
542
- },
543
- }),
544
- { withTheme: true },
545
- )(RawChartAxes);
546
-
547
- export default ChartAxes;
533
+ export default RawChartAxes;