@pie-lib/charting 4.5.6 → 4.5.11-next.256
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.
- package/CHANGELOG.json +105 -0
- package/CHANGELOG.md +16 -20
- package/lib/axes.js +84 -36
- package/lib/axes.js.map +1 -1
- package/lib/bars/bar.js +17 -13
- package/lib/bars/bar.js.map +1 -1
- package/lib/bars/common/bars.js +27 -21
- package/lib/bars/common/bars.js.map +1 -1
- package/lib/bars/histogram.js +17 -13
- package/lib/bars/histogram.js.map +1 -1
- package/lib/chart.js +55 -37
- package/lib/chart.js.map +1 -1
- package/lib/common/drag-handle.js +24 -18
- package/lib/common/drag-handle.js.map +1 -1
- package/lib/common/styles.js +1 -1
- package/lib/grid.js +17 -13
- package/lib/grid.js.map +1 -1
- package/lib/line/common/drag-handle.js +20 -14
- package/lib/line/common/drag-handle.js.map +1 -1
- package/lib/line/common/line.js +38 -30
- package/lib/line/common/line.js.map +1 -1
- package/lib/line/line-cross.js +23 -17
- package/lib/line/line-cross.js.map +1 -1
- package/lib/line/line-dot.js +21 -15
- package/lib/line/line-dot.js.map +1 -1
- package/lib/mark-label.js +37 -11
- package/lib/mark-label.js.map +1 -1
- package/lib/plot/common/plot.js +27 -21
- package/lib/plot/common/plot.js.map +1 -1
- package/lib/plot/dot.js +18 -14
- package/lib/plot/dot.js.map +1 -1
- package/lib/plot/line.js +19 -15
- package/lib/plot/line.js.map +1 -1
- package/lib/tool-menu.js +19 -15
- package/lib/tool-menu.js.map +1 -1
- package/lib/utils.js +79 -26
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/axes.jsx +72 -29
- package/src/chart.jsx +31 -6
- package/src/line/common/line.jsx +1 -1
- package/src/mark-label.jsx +15 -4
- package/src/utils.js +75 -19
package/CHANGELOG.json
CHANGED
|
@@ -473,5 +473,110 @@
|
|
|
473
473
|
"committerDate": "2021-03-05 17:50:54 +0200",
|
|
474
474
|
"isTagged": true,
|
|
475
475
|
"tag": "@pie-lib/charting@4.5.6"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"type": "fix",
|
|
479
|
+
"scope": "charting",
|
|
480
|
+
"subject": "override style to remove grey background behind labels in IBX PD-29",
|
|
481
|
+
"merge": null,
|
|
482
|
+
"header": "fix(charting): override style to remove grey background behind labels in IBX PD-29",
|
|
483
|
+
"body": null,
|
|
484
|
+
"footer": null,
|
|
485
|
+
"notes": [],
|
|
486
|
+
"hash": "ee1a8823dcfc618303f675f7844fa4db9135f860",
|
|
487
|
+
"gitTags": " (origin/fix/PD-29/remove-grey-background-for-charting-labels-IBX)",
|
|
488
|
+
"committerDate": "2021-06-09 15:59:25 +0300",
|
|
489
|
+
"isTagged": true,
|
|
490
|
+
"tag": "@pie-lib/charting@4.5.10"
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"type": "fix",
|
|
494
|
+
"scope": "charting",
|
|
495
|
+
"subject": "rotate category labels according to their length PD-537",
|
|
496
|
+
"merge": null,
|
|
497
|
+
"header": "fix(charting): rotate category labels according to their length PD-537",
|
|
498
|
+
"body": null,
|
|
499
|
+
"footer": null,
|
|
500
|
+
"notes": [],
|
|
501
|
+
"hash": "a2f42fe77935fdaa72455e60605fe3560e7d3058",
|
|
502
|
+
"gitTags": "",
|
|
503
|
+
"committerDate": "2021-05-28 15:43:14 +0300",
|
|
504
|
+
"isTagged": true,
|
|
505
|
+
"tag": "@pie-lib/charting@4.5.10"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"type": "fix",
|
|
509
|
+
"scope": "charting",
|
|
510
|
+
"subject": "Updated categories filtration - PD-535",
|
|
511
|
+
"merge": null,
|
|
512
|
+
"header": "fix(charting): Updated categories filtration - PD-535",
|
|
513
|
+
"body": null,
|
|
514
|
+
"footer": null,
|
|
515
|
+
"notes": [],
|
|
516
|
+
"hash": "a41cc003b8954f3b09803df13839d976033b41d1",
|
|
517
|
+
"gitTags": " (origin/fix/PD-535)",
|
|
518
|
+
"committerDate": "2021-05-26 14:36:51 +0300",
|
|
519
|
+
"isTagged": true,
|
|
520
|
+
"tag": "@pie-lib/charting@4.5.10"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
"type": "fix",
|
|
524
|
+
"scope": "charting",
|
|
525
|
+
"subject": "Fixed the wrong horizontal position of a point on Line Dot - PD-31",
|
|
526
|
+
"merge": null,
|
|
527
|
+
"header": "fix(charting): Fixed the wrong horizontal position of a point on Line Dot - PD-31",
|
|
528
|
+
"body": null,
|
|
529
|
+
"footer": null,
|
|
530
|
+
"notes": [],
|
|
531
|
+
"hash": "7f5812060337865334b35f92ae568629cdd6297d",
|
|
532
|
+
"gitTags": " (origin/fix/PD-31)",
|
|
533
|
+
"committerDate": "2021-05-11 09:05:56 +0300",
|
|
534
|
+
"isTagged": true,
|
|
535
|
+
"tag": "@pie-lib/charting@4.5.10"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"type": "fix",
|
|
539
|
+
"scope": "charting",
|
|
540
|
+
"subject": "Displayed the entire rightmost category label when space available PD-531",
|
|
541
|
+
"merge": null,
|
|
542
|
+
"header": "fix(charting): Displayed the entire rightmost category label when space available PD-531",
|
|
543
|
+
"body": null,
|
|
544
|
+
"footer": null,
|
|
545
|
+
"notes": [],
|
|
546
|
+
"hash": "4c96415952e13e789f5b67cf99e6a17d957a06e7",
|
|
547
|
+
"gitTags": " (origin/fix/PD-531)",
|
|
548
|
+
"committerDate": "2021-09-10 14:19:05 +0300",
|
|
549
|
+
"isTagged": true,
|
|
550
|
+
"tag": "@pie-lib/charting@4.5.13"
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
"type": "fix",
|
|
554
|
+
"scope": "charting",
|
|
555
|
+
"subject": "Updated label font size",
|
|
556
|
+
"merge": null,
|
|
557
|
+
"header": "fix(charting): Updated label font size",
|
|
558
|
+
"body": null,
|
|
559
|
+
"footer": null,
|
|
560
|
+
"notes": [],
|
|
561
|
+
"hash": "d7905e0fd66c7a2254ace1b8ab4492de371816b1",
|
|
562
|
+
"gitTags": "",
|
|
563
|
+
"committerDate": "2021-03-26 13:31:22 +0200",
|
|
564
|
+
"isTagged": true,
|
|
565
|
+
"tag": "@pie-lib/charting@4.5.11"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"type": "fix",
|
|
569
|
+
"scope": "charting",
|
|
570
|
+
"subject": "calculate step and labelStep if they are not defined or if tickLabels are crowded PD-1016",
|
|
571
|
+
"merge": null,
|
|
572
|
+
"header": "fix(charting): calculate step and labelStep if they are not defined or if tickLabels are crowded PD-1016",
|
|
573
|
+
"body": null,
|
|
574
|
+
"footer": null,
|
|
575
|
+
"notes": [],
|
|
576
|
+
"hash": "d215ea002c64505edaa13cd55a8e98c5190f053c",
|
|
577
|
+
"gitTags": "",
|
|
578
|
+
"committerDate": "2021-03-19 19:13:17 +0200",
|
|
579
|
+
"isTagged": true,
|
|
580
|
+
"tag": "@pie-lib/charting@4.5.11"
|
|
476
581
|
}
|
|
477
582
|
]
|
package/CHANGELOG.md
CHANGED
|
@@ -3,51 +3,47 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [4.5.
|
|
6
|
+
## [4.5.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.8...@pie-lib/charting@4.5.10) (2021-06-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/charting
|
|
7
9
|
|
|
10
|
+
## [4.5.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.7...@pie-lib/charting@4.5.8) (2021-06-25)
|
|
8
11
|
|
|
9
12
|
### Bug Fixes
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
- **charting:** Fixed the wrong horizontal position of a point on Line Dot - PD-31 ([7f58120](https://github.com/pie-framework/pie-lib/commit/7f58120))
|
|
15
|
+
- **charting:** override style to remove grey background behind labels in IBX PD-29 ([ee1a882](https://github.com/pie-framework/pie-lib/commit/ee1a882))
|
|
16
|
+
- **charting:** rotate category labels according to their length PD-537 ([a2f42fe](https://github.com/pie-framework/pie-lib/commit/a2f42fe))
|
|
17
|
+
- **charting:** Updated categories filtration - PD-535 ([a41cc00](https://github.com/pie-framework/pie-lib/commit/a41cc00))
|
|
14
18
|
|
|
19
|
+
## [4.5.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.6...@pie-lib/charting@4.5.7) (2021-04-06)
|
|
15
20
|
|
|
21
|
+
**Note:** Version bump only for package @pie-lib/charting
|
|
22
|
+
|
|
23
|
+
## [4.5.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.5...@pie-lib/charting@4.5.6) (2021-04-02)
|
|
16
24
|
|
|
25
|
+
### Bug Fixes
|
|
17
26
|
|
|
27
|
+
- **charting:** align chart labels when they are rotated PD-921 ([1baf5b2](https://github.com/pie-framework/pie-lib/commit/1baf5b2))
|
|
28
|
+
- **charting:** enlarge the height of the draggable target PD-43 ([3d1b7e8](https://github.com/pie-framework/pie-lib/commit/3d1b7e8))
|
|
29
|
+
- **charting:** Increased labels size - PD-533 ([9d9095c](https://github.com/pie-framework/pie-lib/commit/9d9095c))
|
|
18
30
|
|
|
19
31
|
## [4.5.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.4...@pie-lib/charting@4.5.5) (2021-03-15)
|
|
20
32
|
|
|
21
33
|
**Note:** Version bump only for package @pie-lib/charting
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
35
|
## [4.5.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.3...@pie-lib/charting@4.5.4) (2021-02-15)
|
|
28
36
|
|
|
29
37
|
**Note:** Version bump only for package @pie-lib/charting
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
39
|
## [4.5.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.1...@pie-lib/charting@4.5.3) (2021-02-15)
|
|
36
40
|
|
|
37
41
|
**Note:** Version bump only for package @pie-lib/charting
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
43
|
## [4.5.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.5.0...@pie-lib/charting@4.5.1) (2020-10-26)
|
|
44
44
|
|
|
45
45
|
**Note:** Version bump only for package @pie-lib/charting
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
47
|
# [4.5.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/charting@4.4.0...@pie-lib/charting@4.5.0) (2020-10-26)
|
|
52
48
|
|
|
53
49
|
### Features
|
package/lib/axes.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports["default"] = exports.
|
|
8
|
+
exports["default"] = exports.TickComponent = exports.RawChartAxes = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
@@ -23,46 +25,50 @@ var _markLabel = _interopRequireDefault(require("./mark-label"));
|
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
29
|
+
|
|
30
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
31
|
|
|
28
|
-
function
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
33
|
|
|
30
|
-
function
|
|
34
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
31
35
|
|
|
32
|
-
function
|
|
36
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
33
37
|
|
|
34
|
-
function
|
|
38
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
35
39
|
|
|
36
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
+
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; }
|
|
37
41
|
|
|
38
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
42
|
+
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) { _defineProperty(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; }
|
|
39
43
|
|
|
40
44
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
45
|
|
|
42
46
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
47
|
|
|
44
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
48
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
45
49
|
|
|
46
|
-
function
|
|
50
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
51
|
|
|
48
|
-
function
|
|
52
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
53
|
+
|
|
54
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
55
|
+
|
|
56
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
49
57
|
|
|
50
58
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
59
|
|
|
52
|
-
function
|
|
60
|
+
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
61
|
|
|
54
|
-
function
|
|
62
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
63
|
|
|
56
64
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
65
|
|
|
58
|
-
var TickComponent =
|
|
59
|
-
/*#__PURE__*/
|
|
60
|
-
function (_React$Component) {
|
|
66
|
+
var TickComponent = /*#__PURE__*/function (_React$Component) {
|
|
61
67
|
_inherits(TickComponent, _React$Component);
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
var _getPrototypeOf2;
|
|
69
|
+
var _super = _createSuper(TickComponent);
|
|
65
70
|
|
|
71
|
+
function TickComponent() {
|
|
66
72
|
var _this;
|
|
67
73
|
|
|
68
74
|
_classCallCheck(this, TickComponent);
|
|
@@ -71,14 +77,14 @@ function (_React$Component) {
|
|
|
71
77
|
args[_key] = arguments[_key];
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
_this =
|
|
80
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
75
81
|
|
|
76
82
|
_defineProperty(_assertThisInitialized(_this), "changeCategory", function (index, newLabel) {
|
|
77
83
|
var _this$props = _this.props,
|
|
78
84
|
categories = _this$props.categories,
|
|
79
85
|
onChangeCategory = _this$props.onChangeCategory;
|
|
80
86
|
var category = categories[index];
|
|
81
|
-
onChangeCategory(index, _objectSpread({}, category, {
|
|
87
|
+
onChangeCategory(index, _objectSpread(_objectSpread({}, category), {}, {
|
|
82
88
|
label: newLabel
|
|
83
89
|
}));
|
|
84
90
|
});
|
|
@@ -131,7 +137,13 @@ function (_React$Component) {
|
|
|
131
137
|
var barX = xBand((0, _utils.bandKey)({
|
|
132
138
|
label: label
|
|
133
139
|
}, index));
|
|
134
|
-
|
|
140
|
+
var longestCategory = (categories || []).reduce(function (a, b) {
|
|
141
|
+
var lengthA = a && a.label ? a.label.length : 0;
|
|
142
|
+
var lengthB = b && b.label ? b.label.length : 0;
|
|
143
|
+
return lengthA > lengthB ? a : b;
|
|
144
|
+
});
|
|
145
|
+
var longestLabel = longestCategory && longestCategory.label || '';
|
|
146
|
+
return /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
135
147
|
x: bandWidth ? barX : x - barWidth / 2,
|
|
136
148
|
y: 6,
|
|
137
149
|
width: barWidth,
|
|
@@ -140,7 +152,17 @@ function (_React$Component) {
|
|
|
140
152
|
pointerEvents: 'none',
|
|
141
153
|
overflow: 'visible'
|
|
142
154
|
}
|
|
143
|
-
}, _react["default"].createElement(
|
|
155
|
+
}, index === 0 && /*#__PURE__*/_react["default"].createElement("div", {
|
|
156
|
+
id: "hiddenLabel",
|
|
157
|
+
style: {
|
|
158
|
+
position: 'absolute',
|
|
159
|
+
visibility: 'hidden',
|
|
160
|
+
wordBreak: 'break-word',
|
|
161
|
+
overflow: 'visible',
|
|
162
|
+
maxWidth: barWidth,
|
|
163
|
+
display: 'block'
|
|
164
|
+
}
|
|
165
|
+
}, longestLabel), /*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
|
|
144
166
|
inputRef: function inputRef(r) {
|
|
145
167
|
return _this2.input = r;
|
|
146
168
|
},
|
|
@@ -153,14 +175,14 @@ function (_React$Component) {
|
|
|
153
175
|
barWidth: barWidth,
|
|
154
176
|
rotate: rotate,
|
|
155
177
|
correctness: correctness
|
|
156
|
-
})), deletable && !correctness && _react["default"].createElement("line", {
|
|
178
|
+
})), deletable && !correctness && /*#__PURE__*/_react["default"].createElement("line", {
|
|
157
179
|
x1: x,
|
|
158
180
|
y1: 0,
|
|
159
181
|
x2: x,
|
|
160
182
|
y2: y + 4 + top,
|
|
161
183
|
className: classes.dottedLine,
|
|
162
184
|
strokeDasharray: "4 2"
|
|
163
|
-
}), deletable && !correctness && _react["default"].createElement("svg", {
|
|
185
|
+
}), deletable && !correctness && /*#__PURE__*/_react["default"].createElement("svg", {
|
|
164
186
|
xmlns: "http://www.w3.org/2000/svg",
|
|
165
187
|
x: x - 8,
|
|
166
188
|
y: y + 10 + top,
|
|
@@ -170,7 +192,7 @@ function (_React$Component) {
|
|
|
170
192
|
onClick: function onClick() {
|
|
171
193
|
return _this2.deleteCategory(index);
|
|
172
194
|
}
|
|
173
|
-
}, _react["default"].createElement("path", {
|
|
195
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
174
196
|
d: "M128 405.429C128 428.846 147.198 448 170.667 448h170.667C364.802 448 384 428.846 384 405.429V160H128v245.429zM416 96h-80l-26.785-32H202.786L176 96H96v32h320V96z"
|
|
175
197
|
})));
|
|
176
198
|
}
|
|
@@ -196,18 +218,38 @@ TickComponent.propTypes = {
|
|
|
196
218
|
classes: _propTypes["default"].object
|
|
197
219
|
};
|
|
198
220
|
|
|
199
|
-
var RawChartAxes =
|
|
200
|
-
/*#__PURE__*/
|
|
201
|
-
function (_React$Component2) {
|
|
221
|
+
var RawChartAxes = /*#__PURE__*/function (_React$Component2) {
|
|
202
222
|
_inherits(RawChartAxes, _React$Component2);
|
|
203
223
|
|
|
224
|
+
var _super2 = _createSuper(RawChartAxes);
|
|
225
|
+
|
|
204
226
|
function RawChartAxes() {
|
|
227
|
+
var _this3;
|
|
228
|
+
|
|
205
229
|
_classCallCheck(this, RawChartAxes);
|
|
206
230
|
|
|
207
|
-
|
|
231
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
232
|
+
args[_key2] = arguments[_key2];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
236
|
+
|
|
237
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
238
|
+
height: 0
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return _this3;
|
|
208
242
|
}
|
|
209
243
|
|
|
210
244
|
_createClass(RawChartAxes, [{
|
|
245
|
+
key: "componentDidMount",
|
|
246
|
+
value: function componentDidMount() {
|
|
247
|
+
var height = document.getElementById('hiddenLabel') ? document.getElementById('hiddenLabel').offsetHeight : 0;
|
|
248
|
+
this.setState({
|
|
249
|
+
height: height
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}, {
|
|
211
253
|
key: "render",
|
|
212
254
|
value: function render() {
|
|
213
255
|
var _this$props4 = this.props,
|
|
@@ -219,7 +261,8 @@ function (_React$Component2) {
|
|
|
219
261
|
onChangeCategory = _this$props4.onChangeCategory,
|
|
220
262
|
_this$props4$categori = _this$props4.categories,
|
|
221
263
|
categories = _this$props4$categori === void 0 ? [] : _this$props4$categori,
|
|
222
|
-
top = _this$props4.top
|
|
264
|
+
top = _this$props4.top,
|
|
265
|
+
theme = _this$props4.theme;
|
|
223
266
|
var axis = classes.axis,
|
|
224
267
|
axisLine = classes.axisLine,
|
|
225
268
|
tick = classes.tick,
|
|
@@ -235,14 +278,16 @@ function (_React$Component2) {
|
|
|
235
278
|
_ref2$size = _ref2.size,
|
|
236
279
|
size = _ref2$size === void 0 ? {} : _ref2$size;
|
|
237
280
|
|
|
281
|
+
var height = this.state.height;
|
|
238
282
|
var bottomScale = xBand && typeof xBand.rangeRound === 'function' && xBand.rangeRound([0, size.width]);
|
|
239
283
|
var bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth(); // for chartType "line", bandWidth will be 0, so we have to calculate it
|
|
240
284
|
|
|
241
285
|
var barWidth = bandWidth || scale.x && scale.x(domain.max) / categories.length;
|
|
242
|
-
var rowTickValues = (0, _utils.getTickValues)(_objectSpread({}, range, {
|
|
286
|
+
var rowTickValues = (0, _utils.getTickValues)(_objectSpread(_objectSpread({}, range), {}, {
|
|
243
287
|
step: range.labelStep
|
|
244
288
|
}));
|
|
245
|
-
var
|
|
289
|
+
var fontSize = theme && theme.typography ? theme.typography.fontSize : 14;
|
|
290
|
+
var rotate = (0, _utils.getRotateAngle)(fontSize, height);
|
|
246
291
|
|
|
247
292
|
var getTickLabelProps = function getTickLabelProps(value) {
|
|
248
293
|
return {
|
|
@@ -267,10 +312,10 @@ function (_React$Component2) {
|
|
|
267
312
|
y: props.y,
|
|
268
313
|
formattedValue: props.formattedValue
|
|
269
314
|
};
|
|
270
|
-
return _react["default"].createElement(TickComponent, properties);
|
|
315
|
+
return /*#__PURE__*/_react["default"].createElement(TickComponent, properties);
|
|
271
316
|
};
|
|
272
317
|
|
|
273
|
-
return _react["default"].createElement(_react["default"].Fragment, null, leftAxis && _react["default"].createElement(_axis.AxisLeft, {
|
|
318
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, leftAxis && /*#__PURE__*/_react["default"].createElement(_axis.AxisLeft, {
|
|
274
319
|
scale: scale.y,
|
|
275
320
|
className: axis,
|
|
276
321
|
axisLineClassName: axisLine,
|
|
@@ -283,7 +328,7 @@ function (_React$Component2) {
|
|
|
283
328
|
labelClassName: axisLabel,
|
|
284
329
|
tickValues: rowTickValues,
|
|
285
330
|
tickLabelProps: getTickLabelProps
|
|
286
|
-
}), _react["default"].createElement(_axis.AxisBottom, {
|
|
331
|
+
}), /*#__PURE__*/_react["default"].createElement(_axis.AxisBottom, {
|
|
287
332
|
axisLineClassName: axisLine,
|
|
288
333
|
labelClassName: axisLabel,
|
|
289
334
|
tickClassName: tick,
|
|
@@ -320,7 +365,8 @@ _defineProperty(RawChartAxes, "propTypes", {
|
|
|
320
365
|
leftAxis: _propTypes["default"].bool,
|
|
321
366
|
onChange: _propTypes["default"].func,
|
|
322
367
|
onChangeCategory: _propTypes["default"].func,
|
|
323
|
-
top: _propTypes["default"].number
|
|
368
|
+
top: _propTypes["default"].number,
|
|
369
|
+
theme: _propTypes["default"].object
|
|
324
370
|
});
|
|
325
371
|
|
|
326
372
|
var ChartAxes = (0, _styles.withStyles)(function (theme) {
|
|
@@ -353,6 +399,8 @@ var ChartAxes = (0, _styles.withStyles)(function (theme) {
|
|
|
353
399
|
opacity: 0.2
|
|
354
400
|
}
|
|
355
401
|
};
|
|
402
|
+
}, {
|
|
403
|
+
withTheme: true
|
|
356
404
|
})(RawChartAxes);
|
|
357
405
|
var _default = ChartAxes;
|
|
358
406
|
exports["default"] = _default;
|
package/lib/axes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axes.jsx"],"names":["TickComponent","index","newLabel","props","categories","onChangeCategory","category","label","onChange","slice","classes","xBand","bandWidth","barWidth","rotate","top","graphProps","x","y","formattedValue","parseInt","split","deletable","editable","interactive","correctness","barX","pointerEvents","overflow","r","input","changeCategory","dottedLine","deleteCategory","React","Component","propTypes","PropTypes","array","func","number","object","string","RawChartAxes","leftAxis","axis","axisLine","tick","axisLabel","scale","range","domain","size","bottomScale","rangeRound","width","bandwidth","max","length","rowTickValues","step","labelStep","getTickLabelProps","value","dy","dx","toLocaleString","getTickComponent","properties","min","textAnchor","count","isRequired","types","GraphPropsType","bool","ChartAxes","theme","fontFamily","typography","body1","fontSize","fill","color","secondary","stroke","primaryDark","strokeWidth","primaryLight","opacity"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,a;;;;;;;;;;;;;;;;;;qEACM,UAACC,KAAD,EAAQC,QAAR,EAAqB;AAAA,wBACK,MAAKC,KADV;AAAA,UAC5BC,UAD4B,eAC5BA,UAD4B;AAAA,UAChBC,gBADgB,eAChBA,gBADgB;AAEpC,UAAMC,QAAQ,GAAGF,UAAU,CAACH,KAAD,CAA3B;AAEAI,MAAAA,gBAAgB,CAACJ,KAAD,oBAAaK,QAAb;AAAuBC,QAAAA,KAAK,EAAEL;AAA9B,SAAhB;AACD,K;;qEAEgB,UAAAD,KAAK,EAAI;AAAA,yBACS,MAAKE,KADd;AAAA,UAChBC,UADgB,gBAChBA,UADgB;AAAA,UACJI,QADI,gBACJA,QADI;;AAGxB,UAAIP,KAAK,IAAI,CAAT,IAAcG,UAAU,CAACH,KAAD,CAA5B,EAAqC;AACnCO,QAAAA,QAAQ,8BAAKJ,UAAU,CAACK,KAAX,CAAiB,CAAjB,EAAoBR,KAApB,CAAL,sBAAoCG,UAAU,CAACK,KAAX,CAAiBR,KAAK,GAAG,CAAzB,CAApC,GAAR;AACD;AACF,K;;;;;;;6BAEQ;AAAA;;AAAA,yBAaH,KAAKE,KAbF;AAAA,UAELO,OAFK,gBAELA,OAFK;AAAA,UAGLN,UAHK,gBAGLA,UAHK;AAAA,UAILO,KAJK,gBAILA,KAJK;AAAA,UAKLC,SALK,gBAKLA,SALK;AAAA,UAMLC,QANK,gBAMLA,QANK;AAAA,UAOLC,MAPK,gBAOLA,MAPK;AAAA,UAQLC,GARK,gBAQLA,GARK;AAAA,UASLC,UATK,gBASLA,UATK;AAAA,UAULC,CAVK,gBAULA,CAVK;AAAA,UAWLC,CAXK,gBAWLA,CAXK;AAAA,UAYLC,cAZK,gBAYLA,cAZK;;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E;AACVqD,MAAAA,MAAM,EAAEF,gBAAMK,YAAN,EADE;AAEVC,MAAAA,OAAO,EAAE;AAFC;AAxByB,GAAL;AAAA,CAAhB,EA4Bd9C,YA5Bc,CAAlB;eA8BeiC,S","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\nimport { AxisLeft, AxisBottom } from '@vx/axis';\nimport { bandKey, getTickValues, getRotateAngle } from './utils';\nimport MarkLabel from './mark-label';\n\nexport class TickComponent extends React.Component {\n changeCategory = (index, newLabel) => {\n const { categories, onChangeCategory } = this.props;\n const category = categories[index];\n\n onChangeCategory(index, { ...category, label: newLabel });\n };\n\n deleteCategory = index => {\n const { categories, onChange } = this.props;\n\n if (index >= 0 && categories[index]) {\n onChange([...categories.slice(0, index), ...categories.slice(index + 1)]);\n }\n };\n\n render() {\n const {\n classes,\n categories,\n xBand,\n bandWidth,\n barWidth,\n rotate,\n top,\n graphProps,\n x,\n y,\n formattedValue\n } = this.props;\n\n if (!formattedValue) {\n return null;\n }\n\n const index = parseInt(formattedValue.split('-')[0], 10);\n const category = categories[index];\n const { deletable, editable, interactive, label, correctness } = category || {};\n const barX = xBand(bandKey({ label }, index));\n\n return (\n <g>\n <foreignObject\n x={bandWidth ? barX : x - barWidth / 2}\n y={6}\n width={barWidth}\n height={24}\n style={{ pointerEvents: 'none', overflow: 'visible' }}\n >\n <MarkLabel\n inputRef={r => (this.input = r)}\n disabled={!(editable && interactive)}\n mark={category}\n graphProps={graphProps}\n onChange={newLabel => this.changeCategory(index, newLabel)}\n barWidth={barWidth}\n rotate={rotate}\n correctness={correctness}\n />\n </foreignObject>\n {deletable && !correctness && (\n <line\n x1={x}\n y1={0}\n x2={x}\n y2={y + 4 + top}\n className={classes.dottedLine}\n strokeDasharray=\"4 2\"\n />\n )}\n {deletable && !correctness && (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n x={x - 8}\n y={y + 10 + top}\n width={16}\n height={16}\n viewBox=\"0 0 512 512\"\n onClick={() => this.deleteCategory(index)}\n >\n <path d=\"M128 405.429C128 428.846 147.198 448 170.667 448h170.667C364.802 448 384 428.846 384 405.429V160H128v245.429zM416 96h-80l-26.785-32H202.786L176 96H96v32h320V96z\" />\n </svg>\n )}\n </g>\n );\n }\n}\n\nTickComponent.propTypes = {\n categories: PropTypes.array,\n xBand: PropTypes.func,\n bandWidth: PropTypes.number,\n barWidth: PropTypes.number,\n rotate: PropTypes.number,\n top: PropTypes.number,\n x: PropTypes.number,\n y: PropTypes.number,\n graphProps: PropTypes.object,\n formattedValue: PropTypes.string,\n onChangeCategory: PropTypes.func,\n onChange: PropTypes.func,\n classes: PropTypes.object\n};\n\nexport class RawChartAxes extends React.Component {\n static propTypes = {\n bottomScale: PropTypes.func,\n classes: PropTypes.object.isRequired,\n categories: PropTypes.array,\n graphProps: types.GraphPropsType.isRequired,\n xBand: PropTypes.func,\n leftAxis: PropTypes.bool,\n onChange: PropTypes.func,\n onChangeCategory: PropTypes.func,\n top: PropTypes.number\n };\n\n render() {\n const {\n classes,\n graphProps,\n xBand,\n leftAxis,\n onChange,\n onChangeCategory,\n categories = [],\n top\n } = this.props;\n const { axis, axisLine, tick, axisLabel } = classes;\n const { scale = {}, range = {}, domain = {}, size = {} } = graphProps || {};\n const bottomScale =\n xBand && typeof xBand.rangeRound === 'function' && xBand.rangeRound([0, size.width]);\n const bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth();\n // for chartType \"line\", bandWidth will be 0, so we have to calculate it\n const barWidth = bandWidth || (scale.x && scale.x(domain.max) / categories.length);\n const rowTickValues = getTickValues({ ...range, step: range.labelStep });\n const rotate = getRotateAngle(barWidth);\n\n const getTickLabelProps = value => ({\n dy: 4,\n dx: -10 - (value.toLocaleString().length || 1) * 5\n });\n\n const getTickComponent = props => {\n const properties = {\n classes,\n categories,\n xBand,\n bandWidth,\n barWidth,\n rotate,\n top,\n onChangeCategory,\n onChange,\n graphProps,\n x: props.x,\n y: props.y,\n formattedValue: props.formattedValue\n };\n\n return <TickComponent {...properties} />;\n };\n\n return (\n <React.Fragment>\n {leftAxis && (\n <AxisLeft\n scale={scale.y}\n className={axis}\n axisLineClassName={axisLine}\n tickLength={10}\n tickClassName={tick}\n tickFormat={value => value}\n label={range.label}\n labelClassName={axisLabel}\n tickValues={rowTickValues}\n tickLabelProps={getTickLabelProps}\n />\n )}\n <AxisBottom\n axisLineClassName={axisLine}\n labelClassName={axisLabel}\n tickClassName={tick}\n scale={bottomScale}\n label={domain.label}\n labelProps={{ y: 60 + top }}\n top={scale.y && scale.y(range.min)}\n textLabelProps={() => ({ textAnchor: 'middle' })}\n tickFormat={count => count}\n tickComponent={getTickComponent}\n />\n </React.Fragment>\n );\n }\n}\n\nconst ChartAxes = withStyles(theme => ({\n axisLabel: {\n fontFamily: theme.typography.body1.fontFamily,\n fontSize: theme.typography.fontSize,\n fill: color.secondary()\n },\n axis: {\n stroke: color.primaryDark(),\n strokeWidth: 2\n },\n axisLine: {\n stroke: color.primaryDark(),\n strokeWidth: 2\n },\n tick: {\n '& > line': {\n stroke: color.primaryDark(),\n strokeWidth: 2\n },\n fill: color.primaryDark(),\n fontFamily: theme.typography.body1.fontFamily,\n fontSize: theme.typography.fontSize,\n textAnchor: 'middle'\n },\n dottedLine: {\n stroke: color.primaryLight(),\n opacity: 0.2\n }\n}))(RawChartAxes);\n\nexport default ChartAxes;\n"],"file":"axes.js"}
|
|
1
|
+
{"version":3,"sources":["../src/axes.jsx"],"names":["TickComponent","index","newLabel","props","categories","onChangeCategory","category","label","onChange","slice","classes","xBand","bandWidth","barWidth","rotate","top","graphProps","x","y","formattedValue","parseInt","split","deletable","editable","interactive","correctness","barX","longestCategory","reduce","a","b","lengthA","length","lengthB","longestLabel","pointerEvents","overflow","position","visibility","wordBreak","maxWidth","display","r","input","changeCategory","dottedLine","deleteCategory","React","Component","propTypes","PropTypes","array","func","number","object","string","RawChartAxes","height","document","getElementById","offsetHeight","setState","leftAxis","theme","axis","axisLine","tick","axisLabel","scale","range","domain","size","state","bottomScale","rangeRound","width","bandwidth","max","rowTickValues","step","labelStep","fontSize","typography","getTickLabelProps","value","dy","dx","toLocaleString","getTickComponent","properties","min","textAnchor","count","isRequired","types","GraphPropsType","bool","ChartAxes","fontFamily","body1","fill","color","secondary","stroke","primaryDark","strokeWidth","primaryLight","opacity","withTheme"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,a;;;;;;;;;;;;;;;;qEACM,UAACC,KAAD,EAAQC,QAAR,EAAqB;AACpC,wBAAyC,MAAKC,KAA9C;AAAA,UAAQC,UAAR,eAAQA,UAAR;AAAA,UAAoBC,gBAApB,eAAoBA,gBAApB;AACA,UAAMC,QAAQ,GAAGF,UAAU,CAACH,KAAD,CAA3B;AAEAI,MAAAA,gBAAgB,CAACJ,KAAD,kCAAaK,QAAb;AAAuBC,QAAAA,KAAK,EAAEL;AAA9B,SAAhB;AACD,K;;qEAEgB,UAAAD,KAAK,EAAI;AACxB,yBAAiC,MAAKE,KAAtC;AAAA,UAAQC,UAAR,gBAAQA,UAAR;AAAA,UAAoBI,QAApB,gBAAoBA,QAApB;;AAEA,UAAIP,KAAK,IAAI,CAAT,IAAcG,UAAU,CAACH,KAAD,CAA5B,EAAqC;AACnCO,QAAAA,QAAQ,8BAAKJ,UAAU,CAACK,KAAX,CAAiB,CAAjB,EAAoBR,KAApB,CAAL,sBAAoCG,UAAU,CAACK,KAAX,CAAiBR,KAAK,GAAG,CAAzB,CAApC,GAAR;AACD;AACF,K;;;;;;;WAED,kBAAS;AAAA;;AACP,yBAYI,KAAKE,KAZT;AAAA,UACEO,OADF,gBACEA,OADF;AAAA,UAEEN,UAFF,gBAEEA,UAFF;AAAA,UAGEO,KAHF,gBAGEA,KAHF;AAAA,UAIEC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E;AACJ,kBAAY;AACVqC,QAAAA,MAAM,EAAEF,gBAAMG,WAAN,EADE;AAEVC,QAAAA,WAAW,EAAE;AAFH,OADR;AAKJL,MAAAA,IAAI,EAAEC,gBAAMG,WAAN,EALF;AAMJN,MAAAA,UAAU,EAAEnC,KAAK,CAACmB,UAAN,CAAiBiB,KAAjB,CAAuBD,UAN/B;AAOJjB,MAAAA,QAAQ,EAAElB,KAAK,CAACmB,UAAN,CAAiBD,QAPvB;AAQJU,MAAAA,UAAU,EAAE;AARR,KAdE;AAwBR9C,IAAAA,UAAU,EAAE;AACV0D,MAAAA,MAAM,EAAEF,gBAAMK,YAAN,EADE;AAEVC,MAAAA,OAAO,EAAE;AAFC;AAxBJ,GAAL;AAAA,CADW,EA8BhB;AAAEC,EAAAA,SAAS,EAAE;AAAb,CA9BgB,EA+BhBpD,YA/BgB,CAAlB;eAiCeyC,S","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\nimport { AxisLeft, AxisBottom } from '@vx/axis';\nimport { bandKey, getTickValues, getRotateAngle } from './utils';\nimport MarkLabel from './mark-label';\n\nexport class TickComponent extends React.Component {\n changeCategory = (index, newLabel) => {\n const { categories, onChangeCategory } = this.props;\n const category = categories[index];\n\n onChangeCategory(index, { ...category, label: newLabel });\n };\n\n deleteCategory = index => {\n const { categories, onChange } = this.props;\n\n if (index >= 0 && categories[index]) {\n onChange([...categories.slice(0, index), ...categories.slice(index + 1)]);\n }\n };\n\n render() {\n const {\n classes,\n categories,\n xBand,\n bandWidth,\n barWidth,\n rotate,\n top,\n graphProps,\n x,\n y,\n formattedValue\n } = this.props;\n\n if (!formattedValue) {\n return null;\n }\n\n const index = parseInt(formattedValue.split('-')[0], 10);\n const category = categories[index];\n const { deletable, editable, interactive, label, correctness } = category || {};\n const barX = xBand(bandKey({ label }, index));\n const longestCategory = (categories || []).reduce((a, b) => {\n const lengthA = a && a.label ? a.label.length : 0;\n const lengthB = b && b.label ? b.label.length : 0;\n\n return lengthA > lengthB ? a : b;\n });\n\n const longestLabel = (longestCategory && longestCategory.label) || '';\n\n return (\n <g>\n <foreignObject\n x={bandWidth ? barX : x - barWidth / 2}\n y={6}\n width={barWidth}\n height={24}\n style={{ pointerEvents: 'none', overflow: 'visible' }}\n >\n {index === 0 && (\n <div\n id=\"hiddenLabel\"\n style={{\n position: 'absolute',\n visibility: 'hidden',\n wordBreak: 'break-word',\n overflow: 'visible',\n maxWidth: barWidth,\n display: 'block'\n }}\n >\n {longestLabel}\n </div>\n )}\n <MarkLabel\n inputRef={r => (this.input = r)}\n disabled={!(editable && interactive)}\n mark={category}\n graphProps={graphProps}\n onChange={newLabel => this.changeCategory(index, newLabel)}\n barWidth={barWidth}\n rotate={rotate}\n correctness={correctness}\n />\n </foreignObject>\n {deletable && !correctness && (\n <line\n x1={x}\n y1={0}\n x2={x}\n y2={y + 4 + top}\n className={classes.dottedLine}\n strokeDasharray=\"4 2\"\n />\n )}\n {deletable && !correctness && (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n x={x - 8}\n y={y + 10 + top}\n width={16}\n height={16}\n viewBox=\"0 0 512 512\"\n onClick={() => this.deleteCategory(index)}\n >\n <path d=\"M128 405.429C128 428.846 147.198 448 170.667 448h170.667C364.802 448 384 428.846 384 405.429V160H128v245.429zM416 96h-80l-26.785-32H202.786L176 96H96v32h320V96z\" />\n </svg>\n )}\n </g>\n );\n }\n}\n\nTickComponent.propTypes = {\n categories: PropTypes.array,\n xBand: PropTypes.func,\n bandWidth: PropTypes.number,\n barWidth: PropTypes.number,\n rotate: PropTypes.number,\n top: PropTypes.number,\n x: PropTypes.number,\n y: PropTypes.number,\n graphProps: PropTypes.object,\n formattedValue: PropTypes.string,\n onChangeCategory: PropTypes.func,\n onChange: PropTypes.func,\n classes: PropTypes.object\n};\n\nexport class RawChartAxes extends React.Component {\n static propTypes = {\n bottomScale: PropTypes.func,\n classes: PropTypes.object.isRequired,\n categories: PropTypes.array,\n graphProps: types.GraphPropsType.isRequired,\n xBand: PropTypes.func,\n leftAxis: PropTypes.bool,\n onChange: PropTypes.func,\n onChangeCategory: PropTypes.func,\n top: PropTypes.number,\n theme: PropTypes.object\n };\n\n state = { height: 0 };\n\n componentDidMount() {\n const height = document.getElementById('hiddenLabel')\n ? document.getElementById('hiddenLabel').offsetHeight\n : 0;\n\n this.setState({ height });\n }\n\n render() {\n const {\n classes,\n graphProps,\n xBand,\n leftAxis,\n onChange,\n onChangeCategory,\n categories = [],\n top,\n theme\n } = this.props;\n\n const { axis, axisLine, tick, axisLabel } = classes;\n const { scale = {}, range = {}, domain = {}, size = {} } = graphProps || {};\n const { height } = this.state;\n\n const bottomScale =\n xBand && typeof xBand.rangeRound === 'function' && xBand.rangeRound([0, size.width]);\n const bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth();\n // for chartType \"line\", bandWidth will be 0, so we have to calculate it\n const barWidth = bandWidth || (scale.x && scale.x(domain.max) / categories.length);\n\n const rowTickValues = getTickValues({ ...range, step: range.labelStep });\n const fontSize = theme && theme.typography ? theme.typography.fontSize : 14;\n const rotate = getRotateAngle(fontSize, height);\n\n const getTickLabelProps = value => ({\n dy: 4,\n dx: -10 - (value.toLocaleString().length || 1) * 5\n });\n\n const getTickComponent = props => {\n const properties = {\n classes,\n categories,\n xBand,\n bandWidth,\n barWidth,\n rotate,\n top,\n onChangeCategory,\n onChange,\n graphProps,\n x: props.x,\n y: props.y,\n formattedValue: props.formattedValue\n };\n\n return <TickComponent {...properties} />;\n };\n\n return (\n <React.Fragment>\n {leftAxis && (\n <AxisLeft\n scale={scale.y}\n className={axis}\n axisLineClassName={axisLine}\n tickLength={10}\n tickClassName={tick}\n tickFormat={value => value}\n label={range.label}\n labelClassName={axisLabel}\n tickValues={rowTickValues}\n tickLabelProps={getTickLabelProps}\n />\n )}\n <AxisBottom\n axisLineClassName={axisLine}\n labelClassName={axisLabel}\n tickClassName={tick}\n scale={bottomScale}\n label={domain.label}\n labelProps={{ y: 60 + top }}\n top={scale.y && scale.y(range.min)}\n textLabelProps={() => ({ textAnchor: 'middle' })}\n tickFormat={count => count}\n tickComponent={getTickComponent}\n />\n </React.Fragment>\n );\n }\n}\n\nconst ChartAxes = withStyles(\n theme => ({\n axisLabel: {\n fontFamily: theme.typography.body1.fontFamily,\n fontSize: theme.typography.fontSize,\n fill: color.secondary()\n },\n axis: {\n stroke: color.primaryDark(),\n strokeWidth: 2\n },\n axisLine: {\n stroke: color.primaryDark(),\n strokeWidth: 2\n },\n tick: {\n '& > line': {\n stroke: color.primaryDark(),\n strokeWidth: 2\n },\n fill: color.primaryDark(),\n fontFamily: theme.typography.body1.fontFamily,\n fontSize: theme.typography.fontSize,\n textAnchor: 'middle'\n },\n dottedLine: {\n stroke: color.primaryLight(),\n opacity: 0.2\n }\n }),\n { withTheme: true }\n)(RawChartAxes);\n\nexport default ChartAxes;\n"],"file":"axes.js"}
|
package/lib/bars/bar.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -17,37 +19,39 @@ var _bars = _interopRequireDefault(require("./common/bars"));
|
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
21
|
-
|
|
22
22
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
23
|
|
|
24
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
25
|
|
|
26
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
27
27
|
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
37
37
|
|
|
38
|
-
function
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
+
|
|
40
|
+
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; } }
|
|
41
|
+
|
|
42
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
43
|
|
|
40
44
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
41
45
|
|
|
42
|
-
var Bar =
|
|
43
|
-
/*#__PURE__*/
|
|
44
|
-
function (_React$Component) {
|
|
46
|
+
var Bar = /*#__PURE__*/function (_React$Component) {
|
|
45
47
|
_inherits(Bar, _React$Component);
|
|
46
48
|
|
|
49
|
+
var _super = _createSuper(Bar);
|
|
50
|
+
|
|
47
51
|
function Bar() {
|
|
48
52
|
_classCallCheck(this, Bar);
|
|
49
53
|
|
|
50
|
-
return
|
|
54
|
+
return _super.apply(this, arguments);
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
_createClass(Bar, [{
|
|
@@ -64,7 +68,7 @@ function (_React$Component) {
|
|
|
64
68
|
size = _ref$size === void 0 ? {} : _ref$size;
|
|
65
69
|
|
|
66
70
|
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'bar');
|
|
67
|
-
return _react["default"].createElement(_bars["default"], _extends({}, props, {
|
|
71
|
+
return /*#__PURE__*/_react["default"].createElement(_bars["default"], _extends({}, props, {
|
|
68
72
|
xBand: xBand
|
|
69
73
|
}));
|
|
70
74
|
}
|
package/lib/bars/bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bars/bar.js"],"names":["Bar","props","data","graphProps","scale","size","xBand","x","width","React","Component","PropTypes","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/bars/bar.js"],"names":["Bar","props","data","graphProps","scale","size","xBand","x","width","React","Component","PropTypes","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,G;;;;;;;;;;;;;WAOX,kBAAS;AACP,UAAMC,KAAK,GAAG,KAAKA,KAAnB;AACA,UAAQC,IAAR,GAA6BD,KAA7B,CAAQC,IAAR;AAAA,UAAcC,UAAd,GAA6BF,KAA7B,CAAcE,UAAd;;AACA,iBAAkCA,UAAU,IAAI,EAAhD;AAAA,4BAAQC,KAAR;AAAA,UAAQA,KAAR,2BAAgB,EAAhB;AAAA,2BAAoBC,IAApB;AAAA,UAAoBA,IAApB,0BAA2B,EAA3B;;AACA,UAAMC,KAAK,GAAG,wBAAYF,KAAK,CAACG,CAAlB,EAAqBL,IAArB,EAA2BG,IAAI,CAACG,KAAhC,EAAuC,KAAvC,CAAd;AAEA,0BAAO,gCAAC,gBAAD,eAAUP,KAAV;AAAiB,QAAA,KAAK,EAAEK;AAAxB,SAAP;AACD;;;;EAdsBG,kBAAMC,S;;;;gBAAlBV,G,eACQ;AACjBE,EAAAA,IAAI,EAAES,sBAAUC,KADC;AAEjBC,EAAAA,QAAQ,EAAEF,sBAAUG,IAFH;AAGjBX,EAAAA,UAAU,EAAEY,YAAMC,cAAN,CAAqBC;AAHhB,C;;eAgBN;AAAA,SAAO;AACpBC,IAAAA,IAAI,EAAE,KADc;AAEpBR,IAAAA,SAAS,EAAEV,GAFS;AAGpBmB,IAAAA,IAAI,EAAE;AAHc,GAAP;AAAA,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { dataToXBand } from '../utils';\nimport Bars from './common/bars';\n\nexport class Bar extends React.Component {\n static propTypes = {\n data: PropTypes.array,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType.isRequired\n };\n\n render() {\n const props = this.props;\n const { data, graphProps } = props;\n const { scale = {}, size = {} } = graphProps || {};\n const xBand = dataToXBand(scale.x, data, size.width, 'bar');\n\n return <Bars {...props} xBand={xBand} />;\n }\n}\n\nexport default () => ({\n type: 'bar',\n Component: Bar,\n name: 'Bar'\n});\n"],"file":"bar.js"}
|