@pie-lib/charting 5.32.8-next.2 → 5.34.0-mui-update.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 (77) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/actions-button.js +49 -88
  3. package/lib/actions-button.js.map +1 -1
  4. package/lib/axes.js +175 -233
  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 +55 -126
  9. package/lib/bars/common/bars.js.map +1 -1
  10. package/lib/bars/common/correct-check-icon.js +1 -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 +110 -184
  15. package/lib/chart-setup.js.map +1 -1
  16. package/lib/chart-type.js +29 -38
  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 +74 -146
  21. package/lib/chart.js.map +1 -1
  22. package/lib/common/correctness-indicators.js +74 -52
  23. package/lib/common/correctness-indicators.js.map +1 -1
  24. package/lib/common/drag-handle.js +67 -105
  25. package/lib/common/drag-handle.js.map +1 -1
  26. package/lib/common/drag-icon.js +6 -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 +44 -81
  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 +69 -100
  37. package/lib/line/common/drag-handle.js.map +1 -1
  38. package/lib/line/common/line.js +44 -92
  39. package/lib/line/common/line.js.map +1 -1
  40. package/lib/line/line-cross.js +77 -87
  41. package/lib/line/line-cross.js.map +1 -1
  42. package/lib/line/line-dot.js +66 -78
  43. package/lib/line/line-dot.js.map +1 -1
  44. package/lib/mark-label.js +75 -117
  45. package/lib/mark-label.js.map +1 -1
  46. package/lib/plot/common/plot.js +76 -144
  47. package/lib/plot/common/plot.js.map +1 -1
  48. package/lib/plot/dot.js +31 -57
  49. package/lib/plot/dot.js.map +1 -1
  50. package/lib/plot/line.js +37 -62
  51. package/lib/plot/line.js.map +1 -1
  52. package/lib/tool-menu.js +48 -80
  53. package/lib/tool-menu.js.map +1 -1
  54. package/lib/utils.js +20 -77
  55. package/lib/utils.js.map +1 -1
  56. package/package.json +12 -9
  57. package/src/actions-button.jsx +36 -37
  58. package/src/axes.jsx +80 -75
  59. package/src/bars/common/bars.jsx +8 -23
  60. package/src/chart-setup.jsx +68 -78
  61. package/src/chart-type.js +26 -21
  62. package/src/chart.jsx +8 -20
  63. package/src/common/correctness-indicators.jsx +51 -13
  64. package/src/common/drag-handle.jsx +44 -59
  65. package/src/common/drag-icon.jsx +2 -2
  66. package/src/common/styles.js +1 -1
  67. package/src/grid.jsx +9 -13
  68. package/src/key-legend.jsx +62 -60
  69. package/src/line/common/drag-handle.jsx +57 -55
  70. package/src/line/common/line.jsx +17 -8
  71. package/src/line/line-cross.js +37 -12
  72. package/src/line/line-dot.js +30 -11
  73. package/src/mark-label.jsx +43 -44
  74. package/src/plot/common/plot.jsx +17 -22
  75. package/src/plot/dot.js +10 -3
  76. package/src/plot/line.js +14 -6
  77. package/src/tool-menu.jsx +20 -23
package/lib/axes.js CHANGED
@@ -1,92 +1,131 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = exports.TickComponent = exports.RawChartAxes = void 0;
9
-
10
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
13
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
24
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
15
  var _react = _interopRequireDefault(require("react"));
27
-
28
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
17
+ var _styles = require("@mui/material/styles");
32
18
  var _axis = require("@vx/axis");
33
-
34
- var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
35
-
19
+ var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
36
20
  var _plot = require("@pie-lib/plot");
37
-
38
21
  var _renderUi = require("@pie-lib/render-ui");
39
-
40
22
  var _configUi = require("@pie-lib/config-ui");
41
-
42
23
  var _mathRendering = require("@pie-lib/math-rendering");
43
-
44
24
  var _correctnessIndicators = require("./common/correctness-indicators");
45
-
46
25
  var _utils = require("./utils");
47
-
48
26
  var _markLabel = _interopRequireDefault(require("./mark-label"));
27
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
30
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
31
+ var StyledErrorText = (0, _styles.styled)('text')(function (_ref) {
32
+ var theme = _ref.theme;
33
+ return {
34
+ fontSize: theme.typography.fontSize - 2,
35
+ fill: theme.palette.error.main
36
+ };
37
+ });
38
+ var StyledCheckbox = (0, _styles.styled)(_Checkbox["default"])(function () {
39
+ return {
40
+ color: "".concat(_renderUi.color.tertiary(), " !important")
41
+ };
42
+ });
49
43
 
50
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
51
-
52
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
53
-
54
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
55
-
56
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
57
-
58
- var TickComponent = /*#__PURE__*/function (_React$Component) {
59
- (0, _inherits2["default"])(TickComponent, _React$Component);
60
-
61
- var _super = _createSuper(TickComponent);
44
+ // TODO: check if this styling works as intended once MUI migration is done
45
+ // Styled components for axis elements
46
+ var StyledAxisLeft = (0, _styles.styled)(_axis.AxisLeft)(function () {
47
+ return {
48
+ stroke: _renderUi.color.primaryDark(),
49
+ strokeWidth: 2,
50
+ '& .vx-axis-line': {
51
+ stroke: _renderUi.color.visualElementsColors.AXIS_LINE_COLOR,
52
+ strokeWidth: 2
53
+ },
54
+ '& .vx-axis-tick': {
55
+ '& > line': {
56
+ stroke: _renderUi.color.primaryDark(),
57
+ strokeWidth: 2
58
+ }
59
+ }
60
+ };
61
+ });
62
+ var StyledAxisBottom = (0, _styles.styled)(_axis.AxisBottom)(function (_ref2) {
63
+ var _theme$typography$bod;
64
+ var theme = _ref2.theme;
65
+ return {
66
+ stroke: _renderUi.color.primaryDark(),
67
+ strokeWidth: 2,
68
+ '& .vx-axis-line': {
69
+ stroke: _renderUi.color.visualElementsColors.AXIS_LINE_COLOR,
70
+ strokeWidth: 2
71
+ },
72
+ '& .vx-axis-tick': {
73
+ '& > line': {
74
+ stroke: _renderUi.color.primaryDark(),
75
+ strokeWidth: 2
76
+ },
77
+ fontFamily: (_theme$typography$bod = theme.typography.body1) === null || _theme$typography$bod === void 0 ? void 0 : _theme$typography$bod.fontFamily,
78
+ fontSize: theme.typography.fontSize,
79
+ textAnchor: 'middle'
80
+ }
81
+ };
82
+ });
62
83
 
84
+ // Styled components for correctness indicators
85
+ var correctnessIconStyles = function correctnessIconStyles(theme) {
86
+ return {
87
+ borderRadius: theme.spacing(2),
88
+ color: _renderUi.color.defaults.WHITE,
89
+ fontSize: '16px',
90
+ width: '16px',
91
+ height: '16px',
92
+ padding: '2px',
93
+ border: "1px solid ".concat(_renderUi.color.defaults.WHITE),
94
+ boxSizing: 'unset' // to override the default border-box in IBX
95
+ };
96
+ };
97
+ var incorrectIconStyles = {
98
+ backgroundColor: _renderUi.color.incorrectWithIcon()
99
+ };
100
+ var correctIconStyles = {
101
+ backgroundColor: _renderUi.color.correct()
102
+ };
103
+ var TickComponent = exports.TickComponent = /*#__PURE__*/function (_React$Component) {
63
104
  function TickComponent(props) {
64
105
  var _this;
65
-
66
106
  (0, _classCallCheck2["default"])(this, TickComponent);
67
- _this = _super.call(this, props);
68
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAlertDialog", function (open, callback) {
107
+ _this = _callSuper(this, TickComponent, [props]);
108
+ (0, _defineProperty2["default"])(_this, "handleAlertDialog", function (open, callback) {
69
109
  return _this.setState({
70
110
  dialog: {
71
111
  open: open
72
112
  }
73
113
  }, callback);
74
114
  });
75
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeCategory", function (index, newLabel) {
115
+ (0, _defineProperty2["default"])(_this, "changeCategory", function (index, newLabel) {
76
116
  var _this$props = _this.props,
77
- categories = _this$props.categories,
78
- onChangeCategory = _this$props.onChangeCategory;
117
+ categories = _this$props.categories,
118
+ onChangeCategory = _this$props.onChangeCategory;
79
119
  var category = categories[index];
80
120
  onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
81
121
  label: newLabel
82
122
  }));
83
123
  });
84
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeInteractive", function (index, value) {
124
+ (0, _defineProperty2["default"])(_this, "changeInteractive", function (index, value) {
85
125
  var _this$props2 = _this.props,
86
- categories = _this$props2.categories,
87
- onChangeCategory = _this$props2.onChangeCategory;
126
+ categories = _this$props2.categories,
127
+ onChangeCategory = _this$props2.onChangeCategory;
88
128
  var category = categories[index];
89
-
90
129
  if (!value) {
91
130
  _this.setState({
92
131
  dialog: {
@@ -109,12 +148,11 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
109
148
  }));
110
149
  }
111
150
  });
112
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeEditable", function (index, value) {
151
+ (0, _defineProperty2["default"])(_this, "changeEditable", function (index, value) {
113
152
  var _this$props3 = _this.props,
114
- categories = _this$props3.categories,
115
- onChangeCategory = _this$props3.onChangeCategory;
153
+ categories = _this$props3.categories,
154
+ onChangeCategory = _this$props3.onChangeCategory;
116
155
  var category = categories[index];
117
-
118
156
  if (!value) {
119
157
  _this.setState({
120
158
  dialog: {
@@ -137,26 +175,21 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
137
175
  }));
138
176
  }
139
177
  });
140
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "splitText", function (text, maxChar) {
178
+ (0, _defineProperty2["default"])(_this, "splitText", function (text, maxChar) {
141
179
  var chunks = [];
142
-
143
180
  while ((text || '').length > 0) {
144
181
  var indexToSplit = void 0;
145
-
146
182
  if (text.length > maxChar) {
147
183
  indexToSplit = text.lastIndexOf(' ', maxChar);
148
-
149
184
  if (indexToSplit === -1) {
150
185
  indexToSplit = maxChar;
151
186
  }
152
187
  } else {
153
188
  indexToSplit = text.length;
154
189
  }
155
-
156
190
  chunks.push(text.substring(0, indexToSplit));
157
191
  text = text.substring(indexToSplit).trim();
158
192
  }
159
-
160
193
  return chunks;
161
194
  });
162
195
  _this.state = {
@@ -166,8 +199,8 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
166
199
  };
167
200
  return _this;
168
201
  }
169
-
170
- (0, _createClass2["default"])(TickComponent, [{
202
+ (0, _inherits2["default"])(TickComponent, _React$Component);
203
+ return (0, _createClass2["default"])(TickComponent, [{
171
204
  key: "componentDidUpdate",
172
205
  value: function componentDidUpdate(prevProps) {
173
206
  if (this.props.autoFocus && !prevProps.autoFocus) {
@@ -178,47 +211,46 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
178
211
  key: "render",
179
212
  value: function render() {
180
213
  var _this2 = this;
181
-
182
214
  var _this$props4 = this.props,
183
- classes = _this$props4.classes,
184
- categories = _this$props4.categories,
185
- xBand = _this$props4.xBand,
186
- bandWidth = _this$props4.bandWidth,
187
- barWidth = _this$props4.barWidth,
188
- rotate = _this$props4.rotate,
189
- top = _this$props4.top,
190
- graphProps = _this$props4.graphProps,
191
- defineChart = _this$props4.defineChart,
192
- chartingOptions = _this$props4.chartingOptions,
193
- x = _this$props4.x,
194
- y = _this$props4.y,
195
- formattedValue = _this$props4.formattedValue,
196
- changeInteractiveEnabled = _this$props4.changeInteractiveEnabled,
197
- changeEditableEnabled = _this$props4.changeEditableEnabled,
198
- error = _this$props4.error,
199
- autoFocus = _this$props4.autoFocus,
200
- hiddenLabelRef = _this$props4.hiddenLabelRef,
201
- showCorrectness = _this$props4.showCorrectness;
202
-
215
+ categories = _this$props4.categories,
216
+ xBand = _this$props4.xBand,
217
+ bandWidth = _this$props4.bandWidth,
218
+ barWidth = _this$props4.barWidth,
219
+ rotate = _this$props4.rotate,
220
+ top = _this$props4.top,
221
+ graphProps = _this$props4.graphProps,
222
+ defineChart = _this$props4.defineChart,
223
+ chartingOptions = _this$props4.chartingOptions,
224
+ x = _this$props4.x,
225
+ y = _this$props4.y,
226
+ formattedValue = _this$props4.formattedValue,
227
+ changeInteractiveEnabled = _this$props4.changeInteractiveEnabled,
228
+ changeEditableEnabled = _this$props4.changeEditableEnabled,
229
+ error = _this$props4.error,
230
+ autoFocus = _this$props4.autoFocus,
231
+ hiddenLabelRef = _this$props4.hiddenLabelRef,
232
+ showCorrectness = _this$props4.showCorrectness;
203
233
  if (!formattedValue) {
204
234
  return null;
205
235
  }
206
236
 
237
+ // Create classes object for TickCorrectnessIndicator compatibility
238
+ var classes = {
239
+ correctnessIcon: correctnessIconStyles,
240
+ incorrectIcon: incorrectIconStyles,
241
+ correctIcon: correctIconStyles
242
+ };
207
243
  var dialog = this.state.dialog;
208
-
209
- var _ref = chartingOptions || {},
210
- changeEditable = _ref.changeEditable,
211
- changeInteractive = _ref.changeInteractive;
212
-
244
+ var _ref3 = chartingOptions || {},
245
+ changeEditable = _ref3.changeEditable,
246
+ changeInteractive = _ref3.changeInteractive;
213
247
  var index = parseInt(formattedValue.split('-')[0], 10);
214
248
  var category = categories[index];
215
-
216
- var _ref2 = category || {},
217
- editable = _ref2.editable,
218
- interactive = _ref2.interactive,
219
- label = _ref2.label,
220
- correctness = _ref2.correctness;
221
-
249
+ var _ref4 = category || {},
250
+ editable = _ref4.editable,
251
+ interactive = _ref4.interactive,
252
+ label = _ref4.label,
253
+ correctness = _ref4.correctness;
222
254
  var barX = xBand((0, _utils.bandKey)({
223
255
  label: label
224
256
  }, index));
@@ -265,8 +297,7 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
265
297
  interactive: interactive,
266
298
  classes: classes
267
299
  })
268
- })), error && index === 0 && /*#__PURE__*/_react["default"].createElement("text", {
269
- className: classes.error,
300
+ })), error && index === 0 && /*#__PURE__*/_react["default"].createElement(StyledErrorText, {
270
301
  y: y + 23,
271
302
  height: 6,
272
303
  textAnchor: "start"
@@ -318,8 +349,7 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
318
349
  pointerEvents: 'visible',
319
350
  overflow: 'visible'
320
351
  }
321
- }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
322
- className: classes.customColor,
352
+ }, /*#__PURE__*/_react["default"].createElement(StyledCheckbox, {
323
353
  style: {
324
354
  position: 'fixed'
325
355
  },
@@ -336,8 +366,7 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
336
366
  pointerEvents: 'visible',
337
367
  overflow: 'visible'
338
368
  }
339
- }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
340
- className: classes.customColor,
369
+ }, /*#__PURE__*/_react["default"].createElement(StyledCheckbox, {
341
370
  style: {
342
371
  position: 'fixed'
343
372
  },
@@ -363,10 +392,7 @@ var TickComponent = /*#__PURE__*/function (_React$Component) {
363
392
  })));
364
393
  }
365
394
  }]);
366
- return TickComponent;
367
395
  }(_react["default"].Component);
368
-
369
- exports.TickComponent = TickComponent;
370
396
  (0, _defineProperty2["default"])(TickComponent, "propTypes", {
371
397
  defineChart: _propTypes["default"].bool,
372
398
  error: _propTypes["default"].any
@@ -384,7 +410,6 @@ TickComponent.propTypes = {
384
410
  formattedValue: _propTypes["default"].string,
385
411
  onChangeCategory: _propTypes["default"].func,
386
412
  onChange: _propTypes["default"].func,
387
- classes: _propTypes["default"].object,
388
413
  error: _propTypes["default"].object,
389
414
  defineChart: _propTypes["default"].bool,
390
415
  chartingOptions: _propTypes["default"].object,
@@ -394,45 +419,36 @@ TickComponent.propTypes = {
394
419
  onAutoFocusUsed: _propTypes["default"].func,
395
420
  showCorrectness: _propTypes["default"].bool
396
421
  };
397
-
398
- var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
399
- (0, _inherits2["default"])(RawChartAxes, _React$Component2);
400
-
401
- var _super2 = _createSuper(RawChartAxes);
402
-
422
+ var RawChartAxes = exports.RawChartAxes = /*#__PURE__*/function (_React$Component2) {
403
423
  function RawChartAxes() {
404
424
  var _this3;
405
-
406
425
  (0, _classCallCheck2["default"])(this, RawChartAxes);
407
-
408
426
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
409
427
  args[_key] = arguments[_key];
410
428
  }
411
-
412
- _this3 = _super2.call.apply(_super2, [this].concat(args));
413
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "state", {
429
+ _this3 = _callSuper(this, RawChartAxes, [].concat(args));
430
+ (0, _defineProperty2["default"])(_this3, "state", {
414
431
  height: 0,
415
432
  width: 0
416
433
  });
417
434
  return _this3;
418
435
  }
419
-
420
- (0, _createClass2["default"])(RawChartAxes, [{
436
+ (0, _inherits2["default"])(RawChartAxes, _React$Component2);
437
+ return (0, _createClass2["default"])(RawChartAxes, [{
421
438
  key: "componentDidMount",
422
439
  value: function componentDidMount() {
423
440
  if (this.hiddenLabelRef) {
424
441
  var boundingClientRect = this.hiddenLabelRef.getBoundingClientRect();
425
- var hiddenEl = this.hiddenLabelRef.current; // same logic used in dropdown.jsx for hidden labels width calculation
442
+ var hiddenEl = this.hiddenLabelRef.current;
426
443
 
444
+ // same logic used in dropdown.jsx for hidden labels width calculation
427
445
  if (hiddenEl) {
428
446
  var containsLatex = hiddenEl.querySelector('[data-latex], [data-raw]');
429
447
  var hasMathJax = hiddenEl.querySelector('mjx-container');
430
448
  var mathHandled = hiddenEl.querySelector('[data-math-handled="true"]');
431
-
432
449
  if (containsLatex && (!mathHandled || !hasMathJax)) {
433
450
  (0, _mathRendering.renderMath)(this.hiddenLabelRef);
434
451
  }
435
-
436
452
  this.setState({
437
453
  height: Math.floor(boundingClientRect.height),
438
454
  width: Math.floor(boundingClientRect.width)
@@ -445,7 +461,6 @@ var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
445
461
  value: function componentDidUpdate(prevProps, prevState, snapshot) {
446
462
  if (this.hiddenLabelRef) {
447
463
  var width = Math.floor(this.hiddenLabelRef.getBoundingClientRect().width);
448
-
449
464
  if (width !== this.state.width) {
450
465
  this.setState({
451
466
  width: width
@@ -457,69 +472,59 @@ var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
457
472
  key: "render",
458
473
  value: function render() {
459
474
  var _this4 = this;
460
-
461
475
  var _this$props5 = this.props,
462
- classes = _this$props5.classes,
463
- graphProps = _this$props5.graphProps,
464
- xBand = _this$props5.xBand,
465
- leftAxis = _this$props5.leftAxis,
466
- onChange = _this$props5.onChange,
467
- onChangeCategory = _this$props5.onChangeCategory,
468
- _this$props5$categori = _this$props5.categories,
469
- categories = _this$props5$categori === void 0 ? [] : _this$props5$categori,
470
- top = _this$props5.top,
471
- defineChart = _this$props5.defineChart,
472
- chartingOptions = _this$props5.chartingOptions,
473
- changeInteractiveEnabled = _this$props5.changeInteractiveEnabled,
474
- changeEditableEnabled = _this$props5.changeEditableEnabled,
475
- theme = _this$props5.theme,
476
- autoFocus = _this$props5.autoFocus,
477
- onAutoFocusUsed = _this$props5.onAutoFocusUsed,
478
- error = _this$props5.error,
479
- showCorrectness = _this$props5.showCorrectness;
480
- var axis = classes.axis,
481
- axisLine = classes.axisLine,
482
- tick = classes.tick;
483
-
484
- var _ref3 = graphProps || {},
485
- _ref3$scale = _ref3.scale,
486
- scale = _ref3$scale === void 0 ? {} : _ref3$scale,
487
- _ref3$range = _ref3.range,
488
- range = _ref3$range === void 0 ? {} : _ref3$range,
489
- _ref3$domain = _ref3.domain,
490
- domain = _ref3$domain === void 0 ? {} : _ref3$domain,
491
- _ref3$size = _ref3.size,
492
- size = _ref3$size === void 0 ? {} : _ref3$size;
493
-
476
+ graphProps = _this$props5.graphProps,
477
+ xBand = _this$props5.xBand,
478
+ leftAxis = _this$props5.leftAxis,
479
+ onChange = _this$props5.onChange,
480
+ onChangeCategory = _this$props5.onChangeCategory,
481
+ _this$props5$categori = _this$props5.categories,
482
+ categories = _this$props5$categori === void 0 ? [] : _this$props5$categori,
483
+ top = _this$props5.top,
484
+ defineChart = _this$props5.defineChart,
485
+ chartingOptions = _this$props5.chartingOptions,
486
+ changeInteractiveEnabled = _this$props5.changeInteractiveEnabled,
487
+ changeEditableEnabled = _this$props5.changeEditableEnabled,
488
+ theme = _this$props5.theme,
489
+ autoFocus = _this$props5.autoFocus,
490
+ onAutoFocusUsed = _this$props5.onAutoFocusUsed,
491
+ error = _this$props5.error,
492
+ showCorrectness = _this$props5.showCorrectness;
493
+ var _ref5 = graphProps || {},
494
+ _ref5$scale = _ref5.scale,
495
+ scale = _ref5$scale === void 0 ? {} : _ref5$scale,
496
+ _ref5$range = _ref5.range,
497
+ range = _ref5$range === void 0 ? {} : _ref5$range,
498
+ _ref5$domain = _ref5.domain,
499
+ domain = _ref5$domain === void 0 ? {} : _ref5$domain,
500
+ _ref5$size = _ref5.size,
501
+ size = _ref5$size === void 0 ? {} : _ref5$size;
494
502
  var _this$state = this.state,
495
- height = _this$state.height,
496
- width = _this$state.width;
503
+ height = _this$state.height,
504
+ width = _this$state.width;
497
505
  var bottomScale = xBand && typeof xBand.rangeRound === 'function' && xBand.rangeRound([0, size.width]);
498
- var bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth(); // for chartType "line", bandWidth will be 0, so we have to calculate it
499
-
506
+ var bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth();
507
+ // for chartType "line", bandWidth will be 0, so we have to calculate it
500
508
  var barWidth = bandWidth || scale.x && scale.x(domain.max) / categories.length;
501
509
  var rowTickValues = (0, _utils.getTickValues)(_objectSpread(_objectSpread({}, range), {}, {
502
510
  step: range.labelStep
503
511
  }));
504
- var fontSize = theme && theme.typography ? theme.typography.fontSize : 14; // this mostly applies for labels that are not editable
505
-
506
- var rotateBecauseOfHeight = (0, _utils.getRotateAngle)(fontSize, height); // this applies for labels that are editable
507
-
512
+ var fontSize = theme && theme.typography ? theme.typography.fontSize : 14;
513
+ // this mostly applies for labels that are not editable
514
+ var rotateBecauseOfHeight = (0, _utils.getRotateAngle)(fontSize, height);
515
+ // this applies for labels that are editable
508
516
  var rotateBecauseOfWidth = width > barWidth ? 25 : 0;
509
-
510
517
  var getTickLabelProps = function getTickLabelProps(value) {
511
518
  return {
512
519
  dy: 4,
513
520
  dx: -10 - (value.toLocaleString().length || 1) * 5
514
521
  };
515
522
  };
516
-
517
523
  var getTickComponent = function getTickComponent(props) {
518
524
  var properties = {
519
525
  hiddenLabelRef: function hiddenLabelRef(ref) {
520
526
  _this4.hiddenLabelRef = ref;
521
527
  },
522
- classes: classes,
523
528
  categories: categories,
524
529
  xBand: xBand,
525
530
  bandWidth: bandWidth,
@@ -543,21 +548,15 @@ var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
543
548
  };
544
549
  return /*#__PURE__*/_react["default"].createElement(TickComponent, properties);
545
550
  };
546
-
547
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, leftAxis && /*#__PURE__*/_react["default"].createElement(_axis.AxisLeft, {
551
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, leftAxis && /*#__PURE__*/_react["default"].createElement(StyledAxisLeft, {
548
552
  scale: scale.y,
549
- className: axis,
550
- axisLineClassName: axisLine,
551
553
  tickLength: 10,
552
- tickClassName: tick,
553
554
  tickFormat: function tickFormat(value) {
554
555
  return value;
555
556
  },
556
557
  tickValues: rowTickValues,
557
558
  tickLabelProps: getTickLabelProps
558
- }), /*#__PURE__*/_react["default"].createElement(_axis.AxisBottom, {
559
- axisLineClassName: axisLine,
560
- tickClassName: tick,
559
+ }), /*#__PURE__*/_react["default"].createElement(StyledAxisBottom, {
561
560
  scale: bottomScale,
562
561
  labelProps: {
563
562
  y: 60 + top
@@ -577,13 +576,9 @@ var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
577
576
  }));
578
577
  }
579
578
  }]);
580
- return RawChartAxes;
581
579
  }(_react["default"].Component);
582
-
583
- exports.RawChartAxes = RawChartAxes;
584
580
  (0, _defineProperty2["default"])(RawChartAxes, "propTypes", {
585
581
  bottomScale: _propTypes["default"].func,
586
- classes: _propTypes["default"].object.isRequired,
587
582
  categories: _propTypes["default"].array,
588
583
  defineChart: _propTypes["default"].bool,
589
584
  error: _propTypes["default"].any,
@@ -601,62 +596,9 @@ exports.RawChartAxes = RawChartAxes;
601
596
  onAutoFocusUsed: _propTypes["default"].func,
602
597
  showCorrectness: _propTypes["default"].bool
603
598
  });
604
- var ChartAxes = (0, _styles.withStyles)(function (theme) {
605
- return {
606
- axis: {
607
- stroke: _renderUi.color.primaryDark(),
608
- strokeWidth: 2
609
- },
610
- axisLine: {
611
- stroke: _renderUi.color.visualElementsColors.AXIS_LINE_COLOR,
612
- strokeWidth: 2
613
- },
614
- tick: {
615
- '& > line': {
616
- stroke: _renderUi.color.primaryDark(),
617
- strokeWidth: 2
618
- },
619
- fontFamily: theme.typography.body1.fontFamily,
620
- fontSize: theme.typography.fontSize,
621
- textAnchor: 'middle'
622
- },
623
- dottedLine: {
624
- stroke: _renderUi.color.primaryLight(),
625
- opacity: 0.2
626
- },
627
- error: {
628
- fontSize: theme.typography.fontSize - 2,
629
- fill: theme.palette.error.main
630
- },
631
- customColor: {
632
- color: "".concat(_renderUi.color.tertiary(), " !important")
633
- },
634
- correctnessIcon: {
635
- borderRadius: theme.spacing.unit * 2,
636
- color: _renderUi.color.defaults.WHITE,
637
- fontSize: '16px',
638
- width: '16px',
639
- height: '16px',
640
- padding: '2px',
641
- border: "1px solid ".concat(_renderUi.color.defaults.WHITE),
642
- boxSizing: 'unset' // to override the default border-box in IBX
643
-
644
- },
645
- incorrectIcon: {
646
- backgroundColor: _renderUi.color.incorrectWithIcon()
647
- },
648
- correctIcon: {
649
- backgroundColor: _renderUi.color.correct()
650
- },
651
- tickContainer: {
652
- display: 'flex',
653
- flexDirection: 'column',
654
- alignItems: 'center'
655
- }
656
- };
657
- }, {
658
- withTheme: true
659
- })(RawChartAxes);
660
- var _default = ChartAxes;
661
- exports["default"] = _default;
599
+ var ChartAxes = (0, _styles.styled)(RawChartAxes)(function (_ref6) {
600
+ var theme = _ref6.theme;
601
+ return {};
602
+ });
603
+ var _default = exports["default"] = ChartAxes;
662
604
  //# sourceMappingURL=axes.js.map