@pie-lib/charting 5.21.0 → 5.23.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 (57) hide show
  1. package/CHANGELOG.md +6 -10
  2. package/lib/actions-button.js +174 -0
  3. package/lib/actions-button.js.map +1 -0
  4. package/lib/axes.js +614 -0
  5. package/lib/axes.js.map +1 -0
  6. package/lib/bars/bar.js +86 -0
  7. package/lib/bars/bar.js.map +1 -0
  8. package/lib/bars/common/bars.js +299 -0
  9. package/lib/bars/common/bars.js.map +1 -0
  10. package/lib/bars/histogram.js +87 -0
  11. package/lib/bars/histogram.js.map +1 -0
  12. package/lib/chart-setup.js +458 -0
  13. package/lib/chart-setup.js.map +1 -0
  14. package/lib/chart-type.js +71 -0
  15. package/lib/chart-type.js.map +1 -0
  16. package/lib/chart-types.js +31 -0
  17. package/lib/chart-types.js.map +1 -0
  18. package/lib/chart.js +447 -0
  19. package/lib/chart.js.map +1 -0
  20. package/lib/common/drag-handle.js +175 -0
  21. package/lib/common/drag-handle.js.map +1 -0
  22. package/lib/common/drag-icon.js +52 -0
  23. package/lib/common/drag-icon.js.map +1 -0
  24. package/lib/common/styles.js +40 -0
  25. package/lib/common/styles.js.map +1 -0
  26. package/lib/grid.js +141 -0
  27. package/lib/grid.js.map +1 -0
  28. package/lib/index.js +48 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/key-legend.js +111 -0
  31. package/lib/key-legend.js.map +1 -0
  32. package/lib/line/common/drag-handle.js +151 -0
  33. package/lib/line/common/drag-handle.js.map +1 -0
  34. package/lib/line/common/line.js +257 -0
  35. package/lib/line/common/line.js.map +1 -0
  36. package/lib/line/line-cross.js +203 -0
  37. package/lib/line/line-cross.js.map +1 -0
  38. package/lib/line/line-dot.js +156 -0
  39. package/lib/line/line-dot.js.map +1 -0
  40. package/lib/mark-label.js +260 -0
  41. package/lib/mark-label.js.map +1 -0
  42. package/lib/plot/common/plot.js +281 -0
  43. package/lib/plot/common/plot.js.map +1 -0
  44. package/lib/plot/dot.js +123 -0
  45. package/lib/plot/dot.js.map +1 -0
  46. package/lib/plot/line.js +152 -0
  47. package/lib/plot/line.js.map +1 -0
  48. package/lib/tool-menu.js +142 -0
  49. package/lib/tool-menu.js.map +1 -0
  50. package/lib/utils.js +244 -0
  51. package/lib/utils.js.map +1 -0
  52. package/package.json +5 -5
  53. package/src/chart-types.js +2 -2
  54. package/src/line/common/__tests__/drag-handle.test.jsx +2 -2
  55. package/src/plot/common/__tests__/plot.test.jsx +1 -1
  56. package/src/plot/dot.js +1 -1
  57. package/src/plot/line.js +1 -1
package/lib/axes.js ADDED
@@ -0,0 +1,614 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.TickComponent = exports.RawChartAxes = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ 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
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _react = _interopRequireDefault(require("react"));
27
+
28
+ var _propTypes = _interopRequireDefault(require("prop-types"));
29
+
30
+ var _styles = require("@material-ui/core/styles");
31
+
32
+ var _plot = require("@pie-lib/plot");
33
+
34
+ var _renderUi = require("@pie-lib/render-ui");
35
+
36
+ var _configUi = require("@pie-lib/config-ui");
37
+
38
+ var _axis = require("@vx/axis");
39
+
40
+ var _utils = require("./utils");
41
+
42
+ var _markLabel = _interopRequireDefault(require("./mark-label"));
43
+
44
+ var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
45
+
46
+ 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; }
47
+
48
+ 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; }
49
+
50
+ 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); }; }
51
+
52
+ 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; } }
53
+
54
+ var TickComponent = /*#__PURE__*/function (_React$Component) {
55
+ (0, _inherits2["default"])(TickComponent, _React$Component);
56
+
57
+ var _super = _createSuper(TickComponent);
58
+
59
+ function TickComponent(props) {
60
+ var _this;
61
+
62
+ (0, _classCallCheck2["default"])(this, TickComponent);
63
+ _this = _super.call(this, props);
64
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAlertDialog", function (open, callback) {
65
+ return _this.setState({
66
+ dialog: {
67
+ open: open
68
+ }
69
+ }, callback);
70
+ });
71
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeCategory", function (index, newLabel) {
72
+ var _this$props = _this.props,
73
+ categories = _this$props.categories,
74
+ onChangeCategory = _this$props.onChangeCategory;
75
+ var category = categories[index];
76
+ onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
77
+ label: newLabel
78
+ }));
79
+ });
80
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeInteractive", function (index, value) {
81
+ var _this$props2 = _this.props,
82
+ categories = _this$props2.categories,
83
+ onChangeCategory = _this$props2.onChangeCategory;
84
+ var category = categories[index];
85
+
86
+ if (!value) {
87
+ _this.setState({
88
+ dialog: {
89
+ open: true,
90
+ title: 'Warning',
91
+ text: 'This will remove the correct answer value that has been defined for this category.',
92
+ onConfirm: function onConfirm() {
93
+ return _this.handleAlertDialog(false, onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
94
+ interactive: !category.interactive
95
+ })));
96
+ },
97
+ onClose: function onClose() {
98
+ return _this.handleAlertDialog(false);
99
+ }
100
+ }
101
+ });
102
+ } else {
103
+ onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
104
+ interactive: !category.interactive
105
+ }));
106
+ }
107
+ });
108
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeEditable", function (index, value) {
109
+ var _this$props3 = _this.props,
110
+ categories = _this$props3.categories,
111
+ onChangeCategory = _this$props3.onChangeCategory;
112
+ var category = categories[index];
113
+
114
+ if (!value) {
115
+ _this.setState({
116
+ dialog: {
117
+ open: true,
118
+ title: 'Warning',
119
+ text: 'This will remove the correct answer category name that has been defined for this category.',
120
+ onConfirm: function onConfirm() {
121
+ return _this.handleAlertDialog(false, onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
122
+ editable: !category.editable || false
123
+ })));
124
+ },
125
+ onClose: function onClose() {
126
+ return _this.handleAlertDialog(false);
127
+ }
128
+ }
129
+ });
130
+ } else {
131
+ onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
132
+ editable: !category.editable || false
133
+ }));
134
+ }
135
+ });
136
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "splitText", function (text, maxChar) {
137
+ var chunks = [];
138
+
139
+ while ((text || '').length > 0) {
140
+ var indexToSplit = void 0;
141
+
142
+ if (text.length > maxChar) {
143
+ indexToSplit = text.lastIndexOf(' ', maxChar);
144
+
145
+ if (indexToSplit === -1) {
146
+ indexToSplit = maxChar;
147
+ }
148
+ } else {
149
+ indexToSplit = text.length;
150
+ }
151
+
152
+ chunks.push(text.substring(0, indexToSplit));
153
+ text = text.substring(indexToSplit).trim();
154
+ }
155
+
156
+ return chunks;
157
+ });
158
+ _this.state = {
159
+ dialog: {
160
+ open: false
161
+ }
162
+ };
163
+ return _this;
164
+ }
165
+
166
+ (0, _createClass2["default"])(TickComponent, [{
167
+ key: "componentDidUpdate",
168
+ value: function componentDidUpdate(prevProps) {
169
+ if (this.props.autoFocus && !prevProps.autoFocus) {
170
+ this.props.onAutoFocusUsed();
171
+ }
172
+ }
173
+ }, {
174
+ key: "render",
175
+ value: function render() {
176
+ var _this2 = this;
177
+
178
+ var _this$props4 = this.props,
179
+ classes = _this$props4.classes,
180
+ categories = _this$props4.categories,
181
+ xBand = _this$props4.xBand,
182
+ bandWidth = _this$props4.bandWidth,
183
+ barWidth = _this$props4.barWidth,
184
+ rotate = _this$props4.rotate,
185
+ top = _this$props4.top,
186
+ graphProps = _this$props4.graphProps,
187
+ defineChart = _this$props4.defineChart,
188
+ chartingOptions = _this$props4.chartingOptions,
189
+ x = _this$props4.x,
190
+ y = _this$props4.y,
191
+ formattedValue = _this$props4.formattedValue,
192
+ changeInteractiveEnabled = _this$props4.changeInteractiveEnabled,
193
+ changeEditableEnabled = _this$props4.changeEditableEnabled,
194
+ error = _this$props4.error,
195
+ autoFocus = _this$props4.autoFocus,
196
+ hiddenLabelRef = _this$props4.hiddenLabelRef;
197
+
198
+ if (!formattedValue) {
199
+ return null;
200
+ }
201
+
202
+ var dialog = this.state.dialog;
203
+
204
+ var _ref = chartingOptions || {},
205
+ changeEditable = _ref.changeEditable,
206
+ changeInteractive = _ref.changeInteractive;
207
+
208
+ var index = parseInt(formattedValue.split('-')[0], 10);
209
+ var category = categories[index];
210
+
211
+ var _ref2 = category || {},
212
+ editable = _ref2.editable,
213
+ interactive = _ref2.interactive,
214
+ label = _ref2.label,
215
+ correctness = _ref2.correctness;
216
+
217
+ var barX = xBand((0, _utils.bandKey)({
218
+ label: label
219
+ }, index));
220
+ var longestCategory = (categories || []).reduce(function (a, b) {
221
+ var lengthA = a && a.label ? a.label.length : 0;
222
+ var lengthB = b && b.label ? b.label.length : 0;
223
+ return lengthA > lengthB ? a : b;
224
+ });
225
+ var distinctMessages = error ? (0, _toConsumableArray2["default"])(new Set(Object.values(error))).join(' ') : '';
226
+ return /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("foreignObject", {
227
+ x: bandWidth ? barX : x - barWidth / 2,
228
+ y: 6,
229
+ width: barWidth,
230
+ height: 4,
231
+ style: {
232
+ pointerEvents: 'none',
233
+ overflow: 'visible'
234
+ }
235
+ }, index === 0 && /*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
236
+ isHiddenLabel: true,
237
+ inputRef: hiddenLabelRef,
238
+ disabled: true,
239
+ mark: longestCategory,
240
+ graphProps: graphProps,
241
+ barWidth: barWidth
242
+ }), /*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
243
+ autoFocus: defineChart && autoFocus,
244
+ inputRef: function inputRef(r) {
245
+ return _this2.input = r;
246
+ },
247
+ disabled: !defineChart && !editable,
248
+ mark: category,
249
+ graphProps: graphProps,
250
+ onChange: function onChange(newLabel) {
251
+ return _this2.changeCategory(index, newLabel);
252
+ },
253
+ barWidth: barWidth,
254
+ rotate: rotate,
255
+ correctness: correctness,
256
+ error: error && error[index],
257
+ limitCharacters: true
258
+ })), error && index === 0 && /*#__PURE__*/_react["default"].createElement("text", {
259
+ className: classes.error,
260
+ y: y + 23,
261
+ height: 6,
262
+ textAnchor: "start"
263
+ }, distinctMessages), defineChart && index === 0 && /*#__PURE__*/_react["default"].createElement("svg", {
264
+ x: -55,
265
+ style: {
266
+ overflow: 'visible'
267
+ }
268
+ }, changeInteractiveEnabled && /*#__PURE__*/_react["default"].createElement("text", {
269
+ y: y + 90 + top,
270
+ width: barWidth,
271
+ height: 4,
272
+ style: {
273
+ position: 'absolute',
274
+ pointerEvents: 'none',
275
+ wordBreak: 'break-word',
276
+ maxWidth: barWidth,
277
+ display: 'inline-block'
278
+ }
279
+ }, this.splitText(changeInteractive === null || changeInteractive === void 0 ? void 0 : changeInteractive.authoringLabel, 20).map(function (word, index) {
280
+ return /*#__PURE__*/_react["default"].createElement("tspan", {
281
+ key: index,
282
+ x: "0",
283
+ dy: "".concat(index > 0 ? '1.2em' : '.6em')
284
+ }, word);
285
+ })), changeEditableEnabled && /*#__PURE__*/_react["default"].createElement("text", {
286
+ y: y + 145 + top,
287
+ width: barWidth,
288
+ height: 4,
289
+ style: {
290
+ position: 'absolute',
291
+ pointerEvents: 'none',
292
+ wordBreak: 'break-word',
293
+ maxWidth: barWidth,
294
+ display: 'inline-block'
295
+ }
296
+ }, this.splitText(changeEditable === null || changeEditable === void 0 ? void 0 : changeEditable.authoringLabel, 20).map(function (word, index) {
297
+ return /*#__PURE__*/_react["default"].createElement("tspan", {
298
+ key: index,
299
+ x: "0",
300
+ dy: "".concat(index > 0 ? '1.2em' : '.6em')
301
+ }, word);
302
+ }))), defineChart && changeInteractiveEnabled && /*#__PURE__*/_react["default"].createElement("foreignObject", {
303
+ x: x - 24,
304
+ y: y + 80 + top,
305
+ width: barWidth,
306
+ height: 4,
307
+ style: {
308
+ pointerEvents: 'visible',
309
+ overflow: 'visible'
310
+ }
311
+ }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
312
+ className: classes.customColor,
313
+ style: {
314
+ position: 'fixed'
315
+ },
316
+ checked: interactive,
317
+ onChange: function onChange(e) {
318
+ return _this2.changeInteractive(index, e.target.checked);
319
+ }
320
+ })), defineChart && changeEditableEnabled && /*#__PURE__*/_react["default"].createElement("foreignObject", {
321
+ x: x - 24,
322
+ y: y + 130 + top,
323
+ width: barWidth,
324
+ height: 4,
325
+ style: {
326
+ pointerEvents: 'visible',
327
+ overflow: 'visible'
328
+ }
329
+ }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
330
+ className: classes.customColor,
331
+ style: {
332
+ position: 'fixed'
333
+ },
334
+ checked: editable,
335
+ onChange: function onChange(e) {
336
+ return _this2.changeEditable(index, e.target.checked);
337
+ }
338
+ })), /*#__PURE__*/_react["default"].createElement("foreignObject", {
339
+ x: x - 24,
340
+ y: y + 100 + top,
341
+ width: barWidth,
342
+ height: 4,
343
+ style: {
344
+ pointerEvents: 'visible',
345
+ overflow: 'visible'
346
+ }
347
+ }, /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
348
+ open: dialog.open,
349
+ title: dialog.title,
350
+ text: dialog.text,
351
+ onClose: dialog.onClose,
352
+ onConfirm: dialog.onConfirm
353
+ })));
354
+ }
355
+ }]);
356
+ return TickComponent;
357
+ }(_react["default"].Component);
358
+
359
+ exports.TickComponent = TickComponent;
360
+ (0, _defineProperty2["default"])(TickComponent, "propTypes", {
361
+ defineChart: _propTypes["default"].bool,
362
+ error: _propTypes["default"].any
363
+ });
364
+ TickComponent.propTypes = {
365
+ categories: _propTypes["default"].array,
366
+ xBand: _propTypes["default"].func,
367
+ bandWidth: _propTypes["default"].number,
368
+ barWidth: _propTypes["default"].number,
369
+ rotate: _propTypes["default"].number,
370
+ top: _propTypes["default"].number,
371
+ x: _propTypes["default"].number,
372
+ y: _propTypes["default"].number,
373
+ graphProps: _propTypes["default"].object,
374
+ formattedValue: _propTypes["default"].string,
375
+ onChangeCategory: _propTypes["default"].func,
376
+ onChange: _propTypes["default"].func,
377
+ classes: _propTypes["default"].object,
378
+ error: _propTypes["default"].object,
379
+ defineChart: _propTypes["default"].bool,
380
+ chartingOptions: _propTypes["default"].object,
381
+ changeInteractiveEnabled: _propTypes["default"].bool,
382
+ changeEditableEnabled: _propTypes["default"].bool,
383
+ autoFocus: _propTypes["default"].bool,
384
+ onAutoFocusUsed: _propTypes["default"].func
385
+ };
386
+
387
+ var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
388
+ (0, _inherits2["default"])(RawChartAxes, _React$Component2);
389
+
390
+ var _super2 = _createSuper(RawChartAxes);
391
+
392
+ function RawChartAxes() {
393
+ var _this3;
394
+
395
+ (0, _classCallCheck2["default"])(this, RawChartAxes);
396
+
397
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
398
+ args[_key] = arguments[_key];
399
+ }
400
+
401
+ _this3 = _super2.call.apply(_super2, [this].concat(args));
402
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "state", {
403
+ height: 0,
404
+ width: 0
405
+ });
406
+ return _this3;
407
+ }
408
+
409
+ (0, _createClass2["default"])(RawChartAxes, [{
410
+ key: "componentDidMount",
411
+ value: function componentDidMount() {
412
+ if (this.hiddenLabelRef) {
413
+ var boundingClientRect = this.hiddenLabelRef.getBoundingClientRect();
414
+ this.setState({
415
+ height: Math.floor(boundingClientRect.height),
416
+ width: Math.floor(boundingClientRect.width)
417
+ });
418
+ }
419
+ }
420
+ }, {
421
+ key: "componentDidUpdate",
422
+ value: function componentDidUpdate(prevProps, prevState, snapshot) {
423
+ if (this.hiddenLabelRef) {
424
+ var width = Math.floor(this.hiddenLabelRef.getBoundingClientRect().width);
425
+
426
+ if (width !== this.state.width) {
427
+ this.setState({
428
+ width: width
429
+ });
430
+ }
431
+ }
432
+ }
433
+ }, {
434
+ key: "render",
435
+ value: function render() {
436
+ var _this4 = this;
437
+
438
+ var _this$props5 = this.props,
439
+ classes = _this$props5.classes,
440
+ graphProps = _this$props5.graphProps,
441
+ xBand = _this$props5.xBand,
442
+ leftAxis = _this$props5.leftAxis,
443
+ onChange = _this$props5.onChange,
444
+ onChangeCategory = _this$props5.onChangeCategory,
445
+ _this$props5$categori = _this$props5.categories,
446
+ categories = _this$props5$categori === void 0 ? [] : _this$props5$categori,
447
+ top = _this$props5.top,
448
+ defineChart = _this$props5.defineChart,
449
+ chartingOptions = _this$props5.chartingOptions,
450
+ changeInteractiveEnabled = _this$props5.changeInteractiveEnabled,
451
+ changeEditableEnabled = _this$props5.changeEditableEnabled,
452
+ theme = _this$props5.theme,
453
+ autoFocus = _this$props5.autoFocus,
454
+ onAutoFocusUsed = _this$props5.onAutoFocusUsed,
455
+ error = _this$props5.error;
456
+ var axis = classes.axis,
457
+ axisLine = classes.axisLine,
458
+ tick = classes.tick;
459
+
460
+ var _ref3 = graphProps || {},
461
+ _ref3$scale = _ref3.scale,
462
+ scale = _ref3$scale === void 0 ? {} : _ref3$scale,
463
+ _ref3$range = _ref3.range,
464
+ range = _ref3$range === void 0 ? {} : _ref3$range,
465
+ _ref3$domain = _ref3.domain,
466
+ domain = _ref3$domain === void 0 ? {} : _ref3$domain,
467
+ _ref3$size = _ref3.size,
468
+ size = _ref3$size === void 0 ? {} : _ref3$size;
469
+
470
+ var _this$state = this.state,
471
+ height = _this$state.height,
472
+ width = _this$state.width;
473
+ var bottomScale = xBand && typeof xBand.rangeRound === 'function' && xBand.rangeRound([0, size.width]);
474
+ var bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth(); // for chartType "line", bandWidth will be 0, so we have to calculate it
475
+
476
+ var barWidth = bandWidth || scale.x && scale.x(domain.max) / categories.length;
477
+ var rowTickValues = (0, _utils.getTickValues)(_objectSpread(_objectSpread({}, range), {}, {
478
+ step: range.labelStep
479
+ }));
480
+ var fontSize = theme && theme.typography ? theme.typography.fontSize : 14; // this mostly applies for labels that are not editable
481
+
482
+ var rotateBecauseOfHeight = (0, _utils.getRotateAngle)(fontSize, height); // this applies for labels that are editable
483
+
484
+ var rotateBecauseOfWidth = width > barWidth ? 25 : 0;
485
+
486
+ var getTickLabelProps = function getTickLabelProps(value) {
487
+ return {
488
+ dy: 4,
489
+ dx: -10 - (value.toLocaleString().length || 1) * 5
490
+ };
491
+ };
492
+
493
+ var getTickComponent = function getTickComponent(props) {
494
+ var properties = {
495
+ hiddenLabelRef: function hiddenLabelRef(ref) {
496
+ _this4.hiddenLabelRef = ref;
497
+ },
498
+ classes: classes,
499
+ categories: categories,
500
+ xBand: xBand,
501
+ bandWidth: bandWidth,
502
+ barWidth: barWidth,
503
+ rotate: rotateBecauseOfHeight || rotateBecauseOfWidth,
504
+ top: top,
505
+ defineChart: defineChart,
506
+ chartingOptions: chartingOptions,
507
+ autoFocus: autoFocus,
508
+ onAutoFocusUsed: onAutoFocusUsed,
509
+ error: error,
510
+ onChangeCategory: onChangeCategory,
511
+ changeInteractiveEnabled: changeInteractiveEnabled,
512
+ changeEditableEnabled: changeEditableEnabled,
513
+ onChange: onChange,
514
+ graphProps: graphProps,
515
+ x: props.x,
516
+ y: props.y,
517
+ formattedValue: props.formattedValue
518
+ };
519
+ return /*#__PURE__*/_react["default"].createElement(TickComponent, properties);
520
+ };
521
+
522
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, leftAxis && /*#__PURE__*/_react["default"].createElement(_axis.AxisLeft, {
523
+ scale: scale.y,
524
+ className: axis,
525
+ axisLineClassName: axisLine,
526
+ tickLength: 10,
527
+ tickClassName: tick,
528
+ tickFormat: function tickFormat(value) {
529
+ return value;
530
+ },
531
+ tickValues: rowTickValues,
532
+ tickLabelProps: getTickLabelProps
533
+ }), /*#__PURE__*/_react["default"].createElement(_axis.AxisBottom, {
534
+ axisLineClassName: axisLine,
535
+ tickClassName: tick,
536
+ scale: bottomScale,
537
+ labelProps: {
538
+ y: 60 + top
539
+ },
540
+ top: scale.y && scale.y(range.min),
541
+ textLabelProps: function textLabelProps() {
542
+ return {
543
+ textAnchor: 'middle'
544
+ };
545
+ },
546
+ tickFormat: function tickFormat(count) {
547
+ return count;
548
+ },
549
+ tickComponent: getTickComponent,
550
+ autoFocus: autoFocus,
551
+ onAutoFocusUsed: onAutoFocusUsed
552
+ }));
553
+ }
554
+ }]);
555
+ return RawChartAxes;
556
+ }(_react["default"].Component);
557
+
558
+ exports.RawChartAxes = RawChartAxes;
559
+ (0, _defineProperty2["default"])(RawChartAxes, "propTypes", {
560
+ bottomScale: _propTypes["default"].func,
561
+ classes: _propTypes["default"].object.isRequired,
562
+ categories: _propTypes["default"].array,
563
+ defineChart: _propTypes["default"].bool,
564
+ error: _propTypes["default"].any,
565
+ graphProps: _plot.types.GraphPropsType.isRequired,
566
+ xBand: _propTypes["default"].func,
567
+ leftAxis: _propTypes["default"].bool,
568
+ onChange: _propTypes["default"].func,
569
+ onChangeCategory: _propTypes["default"].func,
570
+ top: _propTypes["default"].number,
571
+ theme: _propTypes["default"].object,
572
+ chartingOptions: _propTypes["default"].object,
573
+ changeInteractiveEnabled: _propTypes["default"].bool,
574
+ changeEditableEnabled: _propTypes["default"].bool,
575
+ autoFocus: _propTypes["default"].bool,
576
+ onAutoFocusUsed: _propTypes["default"].func
577
+ });
578
+ var ChartAxes = (0, _styles.withStyles)(function (theme) {
579
+ return {
580
+ axis: {
581
+ stroke: _renderUi.color.primaryDark(),
582
+ strokeWidth: 2
583
+ },
584
+ axisLine: {
585
+ stroke: _renderUi.color.visualElementsColors.AXIS_LINE_COLOR,
586
+ strokeWidth: 2
587
+ },
588
+ tick: {
589
+ '& > line': {
590
+ stroke: _renderUi.color.primaryDark(),
591
+ strokeWidth: 2
592
+ },
593
+ fontFamily: theme.typography.body1.fontFamily,
594
+ fontSize: theme.typography.fontSize,
595
+ textAnchor: 'middle'
596
+ },
597
+ dottedLine: {
598
+ stroke: _renderUi.color.primaryLight(),
599
+ opacity: 0.2
600
+ },
601
+ error: {
602
+ fontSize: theme.typography.fontSize - 2,
603
+ fill: theme.palette.error.main
604
+ },
605
+ customColor: {
606
+ color: "".concat(_renderUi.color.tertiary(), " !important")
607
+ }
608
+ };
609
+ }, {
610
+ withTheme: true
611
+ })(RawChartAxes);
612
+ var _default = ChartAxes;
613
+ exports["default"] = _default;
614
+ //# sourceMappingURL=axes.js.map