@pie-lib/charting 5.4.1-next.0 → 5.4.2-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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/axes.js.map +1 -1
  3. package/lib/bars/bar.js.map +1 -1
  4. package/lib/bars/common/bars.js.map +1 -1
  5. package/lib/bars/histogram.js.map +1 -1
  6. package/lib/chart-setup.js.map +1 -1
  7. package/lib/chart-type.js.map +1 -1
  8. package/lib/chart.js.map +1 -1
  9. package/lib/common/drag-handle.js.map +1 -1
  10. package/lib/common/styles.js.map +1 -1
  11. package/lib/grid.js.map +1 -1
  12. package/lib/line/common/drag-handle.js.map +1 -1
  13. package/lib/line/common/line.js.map +1 -1
  14. package/lib/line/line-cross.js.map +1 -1
  15. package/lib/line/line-dot.js.map +1 -1
  16. package/lib/mark-label.js.map +1 -1
  17. package/lib/plot/common/plot.js.map +1 -1
  18. package/lib/plot/dot.js.map +1 -1
  19. package/lib/plot/line.js.map +1 -1
  20. package/lib/tool-menu.js.map +1 -1
  21. package/lib/utils.js.map +1 -1
  22. package/package.json +3 -3
  23. package/src/axes.jsx +44 -60
  24. package/src/bars/bar.js +2 -2
  25. package/src/bars/common/bars.jsx +11 -26
  26. package/src/bars/histogram.js +2 -2
  27. package/src/chart-setup.jsx +31 -37
  28. package/src/chart-type.js +5 -10
  29. package/src/chart.jsx +35 -53
  30. package/src/common/drag-handle.jsx +16 -36
  31. package/src/common/styles.js +3 -3
  32. package/src/grid.jsx +3 -3
  33. package/src/line/common/drag-handle.jsx +10 -10
  34. package/src/line/common/line.jsx +17 -19
  35. package/src/line/line-cross.js +18 -15
  36. package/src/line/line-dot.js +4 -4
  37. package/src/mark-label.jsx +16 -21
  38. package/src/plot/common/plot.jsx +15 -25
  39. package/src/plot/dot.js +5 -13
  40. package/src/plot/line.js +16 -10
  41. package/src/tool-menu.jsx +13 -13
  42. package/src/utils.js +14 -14
@@ -7,7 +7,7 @@ import { types } from '@pie-lib/plot';
7
7
  import { correct, incorrect, disabled } from './common/styles';
8
8
  import { color } from '@pie-lib/render-ui';
9
9
 
10
- const styles = theme => ({
10
+ const styles = (theme) => ({
11
11
  input: {
12
12
  float: 'right',
13
13
  fontFamily: theme.typography.fontFamily,
@@ -19,15 +19,15 @@ const styles = theme => ({
19
19
  '&.incorrect': incorrect('color'),
20
20
  '&.disabled': {
21
21
  ...disabled('color'),
22
- backgroundColor: 'transparent !important'
23
- }
24
- }
22
+ backgroundColor: 'transparent !important',
23
+ },
24
+ },
25
25
  });
26
26
 
27
- export const MarkLabel = props => {
27
+ export const MarkLabel = (props) => {
28
28
  // eslint-disable-next-line no-unused-vars
29
29
  const [input, setInput] = useState(null);
30
- const _ref = useCallback(node => setInput(node), null);
30
+ const _ref = useCallback((node) => setInput(node), null);
31
31
 
32
32
  const {
33
33
  mark,
@@ -38,17 +38,17 @@ export const MarkLabel = props => {
38
38
  rotate,
39
39
  correctness,
40
40
  autoFocus,
41
- error
41
+ error,
42
42
  } = props;
43
43
  const [label, setLabel] = useState(mark.label);
44
- const onChange = e => setLabel(e.target.value);
45
- const onChangeProp = e => props.onChange(e.target.value);
44
+ const onChange = (e) => setLabel(e.target.value);
45
+ const onChangeProp = (e) => props.onChange(e.target.value);
46
46
  let extraStyle = {};
47
47
 
48
48
  if (rotate) {
49
49
  extraStyle = {
50
50
  width: 'unset',
51
- textAlign: 'left'
51
+ textAlign: 'left',
52
52
  };
53
53
  }
54
54
 
@@ -60,17 +60,12 @@ export const MarkLabel = props => {
60
60
  return (
61
61
  <AutosizeInput
62
62
  autoFocus={autoFocus}
63
- inputRef={r => {
63
+ inputRef={(r) => {
64
64
  _ref(r);
65
65
  externalInputRef(r);
66
66
  }}
67
67
  disabled={disabled}
68
- inputClassName={cn(
69
- classes.input,
70
- correctness && correctness.label,
71
- disabled && 'disabled',
72
- error && 'error'
73
- )}
68
+ inputClassName={cn(classes.input, correctness && correctness.label, disabled && 'disabled', error && 'error')}
74
69
  inputStyle={{
75
70
  minWidth: barWidth,
76
71
  textAlign: 'center',
@@ -78,7 +73,7 @@ export const MarkLabel = props => {
78
73
  boxSizing: 'border-box',
79
74
  paddingLeft: 0,
80
75
  paddingRight: 0,
81
- ...extraStyle
76
+ ...extraStyle,
82
77
  }}
83
78
  value={label}
84
79
  style={{
@@ -88,7 +83,7 @@ export const MarkLabel = props => {
88
83
  left: 0,
89
84
  minWidth: barWidth,
90
85
  transformOrigin: 'left',
91
- transform: `rotate(${rotate}deg)`
86
+ transform: `rotate(${rotate}deg)`,
92
87
  }}
93
88
  onChange={onChange}
94
89
  onBlur={onChangeProp}
@@ -107,8 +102,8 @@ MarkLabel.propTypes = {
107
102
  rotate: PropTypes.number,
108
103
  correctness: PropTypes.shape({
109
104
  value: PropTypes.string,
110
- label: PropTypes.string
111
- })
105
+ label: PropTypes.string,
106
+ }),
112
107
  };
113
108
 
114
109
  export default withStyles(styles)(MarkLabel);
@@ -24,18 +24,18 @@ export class RawPlot extends React.Component {
24
24
  interactive: PropTypes.bool,
25
25
  correctness: PropTypes.shape({
26
26
  value: PropTypes.string,
27
- label: PropTypes.string
28
- })
27
+ label: PropTypes.string,
28
+ }),
29
29
  };
30
30
 
31
31
  constructor(props) {
32
32
  super(props);
33
33
  this.state = {
34
- dragValue: undefined
34
+ dragValue: undefined,
35
35
  };
36
36
  }
37
37
 
38
- setDragValue = dragValue => this.setState({ dragValue });
38
+ setDragValue = (dragValue) => this.setState({ dragValue });
39
39
 
40
40
  dragStop = () => {
41
41
  const { label, onChangeCategory } = this.props;
@@ -56,17 +56,7 @@ export class RawPlot extends React.Component {
56
56
  };
57
57
 
58
58
  render() {
59
- const {
60
- graphProps,
61
- value,
62
- label,
63
- classes,
64
- xBand,
65
- index,
66
- CustomBarElement,
67
- interactive,
68
- correctness
69
- } = this.props;
59
+ const { graphProps, value, label, classes, xBand, index, CustomBarElement, interactive, correctness } = this.props;
70
60
 
71
61
  const { scale, range, size } = graphProps;
72
62
  const { max } = range || {};
@@ -91,7 +81,7 @@ export class RawPlot extends React.Component {
91
81
 
92
82
  return (
93
83
  <React.Fragment>
94
- {values.map(index =>
84
+ {values.map((index) =>
95
85
  CustomBarElement({
96
86
  index,
97
87
  pointDiameter,
@@ -101,15 +91,15 @@ export class RawPlot extends React.Component {
101
91
  label,
102
92
  value,
103
93
  classes,
104
- scale
105
- })
94
+ scale,
95
+ }),
106
96
  )}
107
97
  <Component
108
98
  x={barX}
109
99
  y={v}
110
100
  interactive={interactive}
111
101
  width={barWidth}
112
- onDrag={v => this.dragValue(value, v)}
102
+ onDrag={(v) => this.dragValue(value, v)}
113
103
  onDragStop={this.dragStop}
114
104
  graphProps={graphProps}
115
105
  correctness={correctness}
@@ -119,17 +109,17 @@ export class RawPlot extends React.Component {
119
109
  }
120
110
  }
121
111
 
122
- const Bar = withStyles(theme => ({
112
+ const Bar = withStyles((theme) => ({
123
113
  dot: {
124
114
  fill: color.primaryLight(),
125
115
  '&.correct': correct('stroke'),
126
- '&.incorrect': incorrect('stroke')
116
+ '&.incorrect': incorrect('stroke'),
127
117
  },
128
118
  line: {
129
119
  stroke: color.primaryLight(),
130
120
  '&.correct': correct('stroke'),
131
- '&.incorrect': incorrect('stroke')
132
- }
121
+ '&.incorrect': incorrect('stroke'),
122
+ },
133
123
  }))(RawPlot);
134
124
 
135
125
  export class Plot extends React.Component {
@@ -139,7 +129,7 @@ export class Plot extends React.Component {
139
129
  xBand: PropTypes.func,
140
130
  graphProps: types.GraphPropsType.isRequired,
141
131
  defineChart: PropTypes.bool,
142
- CustomBarElement: PropTypes.func
132
+ CustomBarElement: PropTypes.func,
143
133
  };
144
134
 
145
135
  render() {
@@ -155,7 +145,7 @@ export class Plot extends React.Component {
155
145
  xBand={xBand}
156
146
  index={index}
157
147
  key={`bar-${d.label}-${d.value}-${index}`}
158
- onChangeCategory={category => onChangeCategory(index, category)}
148
+ onChangeCategory={(category) => onChangeCategory(index, category)}
159
149
  graphProps={graphProps}
160
150
  CustomBarElement={CustomBarElement}
161
151
  correctness={d.correctness}
package/src/plot/dot.js CHANGED
@@ -5,22 +5,14 @@ import { dataToXBand } from '../utils';
5
5
  import Plot from './common/plot';
6
6
  import { Circle } from '@vx/shape';
7
7
 
8
- const CustomBarElement = props => {
8
+ const CustomBarElement = (props) => {
9
9
  const { index, pointDiameter, barX, barWidth, pointHeight, label, value, classes, scale } = props;
10
10
 
11
11
  const r = pointDiameter / 2;
12
12
  const cx = barX + (barWidth - pointDiameter) / 2 + r;
13
13
  const cy = scale.y(index) - (pointHeight - pointDiameter) / 2 - r;
14
14
 
15
- return (
16
- <Circle
17
- key={`point-${label}-${value}-${index}`}
18
- className={classes.dot}
19
- cx={cx}
20
- cy={cy}
21
- r={r}
22
- />
23
- );
15
+ return <Circle key={`point-${label}-${value}-${index}`} className={classes.dot} cx={cx} cy={cy} r={r} />;
24
16
  };
25
17
 
26
18
  CustomBarElement.propTypes = {
@@ -32,14 +24,14 @@ CustomBarElement.propTypes = {
32
24
  value: PropTypes.number,
33
25
  label: PropTypes.string,
34
26
  classes: PropTypes.object,
35
- scale: PropTypes.object
27
+ scale: PropTypes.object,
36
28
  };
37
29
 
38
30
  export class DotPlot extends React.Component {
39
31
  static propTypes = {
40
32
  data: PropTypes.array,
41
33
  onChange: PropTypes.func,
42
- graphProps: types.GraphPropsType.isRequired
34
+ graphProps: types.GraphPropsType.isRequired,
43
35
  };
44
36
 
45
37
  render() {
@@ -55,5 +47,5 @@ export class DotPlot extends React.Component {
55
47
  export default () => ({
56
48
  type: 'dotPlot',
57
49
  Component: DotPlot,
58
- name: 'Dot Plot'
50
+ name: 'Dot Plot',
59
51
  });
package/src/plot/line.js CHANGED
@@ -6,7 +6,7 @@ import Plot from './common/plot';
6
6
  import { LinePath } from '@vx/shape';
7
7
  import { Group } from '@vx/group';
8
8
 
9
- const CustomBarElement = props => {
9
+ const CustomBarElement = (props) => {
10
10
  const { index, pointDiameter, barX, barWidth, pointHeight, label, value, classes, scale } = props;
11
11
 
12
12
  const x = barX + (barWidth - pointDiameter) / 2;
@@ -15,19 +15,25 @@ const CustomBarElement = props => {
15
15
  return (
16
16
  <Group>
17
17
  <LinePath
18
- data={[{ x, y }, { x: x + pointDiameter, y: y - pointDiameter }]}
18
+ data={[
19
+ { x, y },
20
+ { x: x + pointDiameter, y: y - pointDiameter },
21
+ ]}
19
22
  key={`point-${label}-${value}-${index}-1`}
20
23
  className={classes.line}
21
- x={d => d.x}
22
- y={d => d.y}
24
+ x={(d) => d.x}
25
+ y={(d) => d.y}
23
26
  strokeWidth={pointDiameter / 5}
24
27
  />
25
28
  <LinePath
26
- data={[{ x, y: y - pointDiameter }, { x: x + pointDiameter, y }]}
29
+ data={[
30
+ { x, y: y - pointDiameter },
31
+ { x: x + pointDiameter, y },
32
+ ]}
27
33
  key={`point-${label}-${value}-${index}-2`}
28
34
  className={classes.line}
29
- x={d => d.x}
30
- y={d => d.y}
35
+ x={(d) => d.x}
36
+ y={(d) => d.y}
31
37
  strokeWidth={pointDiameter / 5}
32
38
  />
33
39
  </Group>
@@ -43,14 +49,14 @@ CustomBarElement.propTypes = {
43
49
  value: PropTypes.number,
44
50
  label: PropTypes.string,
45
51
  classes: PropTypes.object,
46
- scale: PropTypes.object
52
+ scale: PropTypes.object,
47
53
  };
48
54
 
49
55
  export class LinePlot extends React.Component {
50
56
  static propTypes = {
51
57
  data: PropTypes.array,
52
58
  onChange: PropTypes.func,
53
- graphProps: types.GraphPropsType.isRequired
59
+ graphProps: types.GraphPropsType.isRequired,
54
60
  };
55
61
 
56
62
  render() {
@@ -66,5 +72,5 @@ export class LinePlot extends React.Component {
66
72
  export default () => ({
67
73
  type: 'linePlot',
68
74
  Component: LinePlot,
69
- name: 'Line Plot'
75
+ name: 'Line Plot',
70
76
  });
package/src/tool-menu.jsx CHANGED
@@ -7,37 +7,37 @@ import { withStyles } from '@material-ui/core/styles';
7
7
  import cn from 'classnames';
8
8
  import Button from '@material-ui/core/Button';
9
9
 
10
- const buttonStyles = theme => ({
10
+ const buttonStyles = (theme) => ({
11
11
  root: {
12
12
  backgroundColor: color.background(),
13
13
  color: color.text(),
14
14
  border: `1px solid ${color.secondary()}`,
15
15
  '&:hover': {
16
- backgroundColor: color.secondaryLight()
16
+ backgroundColor: color.secondaryLight(),
17
17
  },
18
- fontSize: theme.typography.fontSize
18
+ fontSize: theme.typography.fontSize,
19
19
  },
20
20
  selected: {
21
21
  backgroundColor: color.background(),
22
22
  '& span': {
23
- color: color.primaryDark()
24
- }
23
+ color: color.primaryDark(),
24
+ },
25
25
  },
26
26
  notSelected: {
27
27
  '& span': {
28
- color: color.primary()
28
+ color: color.primary(),
29
29
  },
30
- backgroundColor: color.background()
30
+ backgroundColor: color.background(),
31
31
  },
32
32
  disabled: {
33
33
  '& span': {
34
- color: color.primary()
34
+ color: color.primary(),
35
35
  },
36
- backgroundColor: color.disabled()
37
- }
36
+ backgroundColor: color.disabled(),
37
+ },
38
38
  });
39
39
 
40
- export const MiniButton = withStyles(buttonStyles)(props => {
40
+ export const MiniButton = withStyles(buttonStyles)((props) => {
41
41
  const { disabled, classes, className, selected, value, onClick } = props;
42
42
  return (
43
43
  <Button
@@ -61,14 +61,14 @@ MiniButton.propTypes = {
61
61
  disabledClassName: PropTypes.string,
62
62
  selected: PropTypes.bool,
63
63
  value: PropTypes.string,
64
- onClick: PropTypes.func
64
+ onClick: PropTypes.func,
65
65
  };
66
66
 
67
67
  export class ToolMenu extends React.Component {
68
68
  static propTypes = {
69
69
  className: PropTypes.string,
70
70
  addCategory: PropTypes.func,
71
- disabled: PropTypes.bool
71
+ disabled: PropTypes.bool,
72
72
  };
73
73
 
74
74
  static defaultProps = {};
package/src/utils.js CHANGED
@@ -15,25 +15,25 @@ export const dataToXBand = (scaleX, data, width, type) => {
15
15
  return scaleBand({
16
16
  rangeRound: [0, width],
17
17
  domain: data && data.map(bandKey),
18
- padding: 0.2
18
+ padding: 0.2,
19
19
  });
20
20
  case 'histogram':
21
21
  return scaleBand({
22
22
  rangeRound: [0, width],
23
23
  domain: data && data.map(bandKey),
24
- padding: 0
24
+ padding: 0,
25
25
  });
26
26
  case 'lineCross':
27
27
  case 'lineDot':
28
28
  return scalePoint({
29
29
  domain: data && data.map(bandKey),
30
- rangeRound: [0, width]
30
+ rangeRound: [0, width],
31
31
  });
32
32
  default:
33
33
  return scaleBand({
34
34
  range: [0, width],
35
35
  domain: data && data.map(bandKey),
36
- padding: 0
36
+ padding: 0,
37
37
  });
38
38
  }
39
39
  };
@@ -83,15 +83,15 @@ export const getDomainAndRangeByChartType = (domain, range, chartType) => {
83
83
  step: 1,
84
84
  labelStep: 1,
85
85
  min: 0,
86
- max: 1
86
+ max: 1,
87
87
  },
88
88
  range: {
89
89
  ...range,
90
90
  min: intMin,
91
91
  max: intMin === intMax ? intMin + 1 : intMax,
92
92
  labelStep,
93
- step: 1
94
- }
93
+ step: 1,
94
+ },
95
95
  };
96
96
  }
97
97
  default:
@@ -101,13 +101,13 @@ export const getDomainAndRangeByChartType = (domain, range, chartType) => {
101
101
  step: 1,
102
102
  labelStep: 1,
103
103
  min: 0,
104
- max: 1
104
+ max: 1,
105
105
  },
106
106
  range: {
107
107
  ...range,
108
108
  labelStep,
109
- step
110
- }
109
+ step,
110
+ },
111
111
  };
112
112
  }
113
113
  };
@@ -119,20 +119,20 @@ export const getGridLinesAndAxisByChartType = (range, chartType) => {
119
119
  return {
120
120
  verticalLines: undefined,
121
121
  horizontalLines: getTickValues(range),
122
- leftAxis: true
122
+ leftAxis: true,
123
123
  };
124
124
  case 'dotPlot':
125
125
  case 'linePlot':
126
126
  return {
127
127
  verticalLines: [],
128
128
  horizontalLines: [],
129
- leftAxis: false
129
+ leftAxis: false,
130
130
  };
131
131
  default:
132
132
  return {
133
133
  verticalLines: [],
134
134
  horizontalLines: getTickValues(range),
135
- leftAxis: true
135
+ leftAxis: true,
136
136
  };
137
137
  }
138
138
  };
@@ -145,7 +145,7 @@ export const getRotateAngle = (fontSize, height) => {
145
145
  return 0;
146
146
  };
147
147
 
148
- export const getTopPadding = barWidth => {
148
+ export const getTopPadding = (barWidth) => {
149
149
  if (barWidth < 30) {
150
150
  return 50;
151
151
  }