@easyv/charts 1.2.5 → 1.2.8
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/lib/components/AnimateData.js +11 -7
- package/lib/components/Axis.js +8 -4
- package/lib/components/Band.js +8 -4
- package/lib/components/BaseLine.js +85 -0
- package/lib/components/Brush.js +2 -2
- package/lib/components/Carousel.js +13 -6
- package/lib/components/CartesianChart.js +29 -7
- package/lib/components/Chart.js +9 -6
- package/lib/components/ChartContainer.js +8 -4
- package/lib/components/ConicalGradient.js +6 -2
- package/lib/components/ExtentData.js +7 -4
- package/lib/components/FilterData.js +7 -4
- package/lib/components/Label.js +2 -2
- package/lib/components/Legend.js +11 -5
- package/lib/components/Line.js +49 -37
- package/lib/components/Mapping.js +8 -5
- package/lib/components/Marquee.js +2 -2
- package/lib/components/PieChart.js +21 -13
- package/lib/components/StackData.js +7 -4
- package/lib/components/StereoBar.js +8 -4
- package/lib/components/TextOverflow.js +2 -2
- package/lib/components/Tooltip.js +2 -2
- package/lib/components/index.js +55 -47
- package/lib/formatter/legend.js +2 -2
- package/lib/hooks/index.js +14 -14
- package/lib/hooks/useAnimateData.js +2 -2
- package/lib/hooks/useAxes.js +2 -2
- package/lib/hooks/useCarouselAxisX.js +2 -2
- package/lib/hooks/useExtentData.js +3 -2
- package/lib/hooks/useFilterData.js +3 -3
- package/lib/hooks/useStackData.js +5 -3
- package/lib/index.js +6 -2
- package/lib/utils/index.js +29 -6
- package/package.json +1 -1
- package/src/components/BaseLine.js +83 -0
- package/src/components/CartesianChart.js +25 -5
- package/src/components/Line.js +2 -1
- package/src/components/PieChart.js +4 -15
- package/src/components/index.js +2 -0
- package/src/utils/index.js +25 -6
package/lib/hooks/index.js
CHANGED
|
@@ -5,46 +5,46 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "useAnimateData", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
|
-
return
|
|
11
|
+
return _useAnimateData["default"];
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "useAxes", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function get() {
|
|
17
|
-
return
|
|
17
|
+
return _useAxes["default"];
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
Object.defineProperty(exports, "
|
|
20
|
+
Object.defineProperty(exports, "useCarouselAxisX", {
|
|
21
21
|
enumerable: true,
|
|
22
22
|
get: function get() {
|
|
23
|
-
return
|
|
23
|
+
return _useCarouselAxisX["default"];
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
Object.defineProperty(exports, "
|
|
26
|
+
Object.defineProperty(exports, "useExtentData", {
|
|
27
27
|
enumerable: true,
|
|
28
28
|
get: function get() {
|
|
29
|
-
return
|
|
29
|
+
return _useExtentData["default"];
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
Object.defineProperty(exports, "
|
|
32
|
+
Object.defineProperty(exports, "useFilterData", {
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function get() {
|
|
35
|
-
return
|
|
35
|
+
return _useFilterData["default"];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
Object.defineProperty(exports, "
|
|
38
|
+
Object.defineProperty(exports, "useStackData", {
|
|
39
39
|
enumerable: true,
|
|
40
40
|
get: function get() {
|
|
41
|
-
return
|
|
41
|
+
return _useStackData["default"];
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
Object.defineProperty(exports, "
|
|
44
|
+
Object.defineProperty(exports, "useTooltip", {
|
|
45
45
|
enumerable: true,
|
|
46
46
|
get: function get() {
|
|
47
|
-
return
|
|
47
|
+
return _useTooltip["default"];
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -15,9 +15,9 @@ var _react = require("react");
|
|
|
15
15
|
|
|
16
16
|
var _popmotion = require("popmotion");
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
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; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
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; }
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* 图表数据动画
|
package/lib/hooks/useAxes.js
CHANGED
|
@@ -17,9 +17,9 @@ var _utils = require("../utils");
|
|
|
17
17
|
|
|
18
18
|
var _utils2 = require("@easyv/utils/lib/common/utils");
|
|
19
19
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
20
|
+
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; }
|
|
21
21
|
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
22
|
+
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; }
|
|
23
23
|
|
|
24
24
|
var scales = {
|
|
25
25
|
linear: _d3Scale.scaleLinear,
|
|
@@ -17,9 +17,9 @@ var _react = require("react");
|
|
|
17
17
|
|
|
18
18
|
var _popmotion = require("popmotion");
|
|
19
19
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
20
|
+
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; }
|
|
21
21
|
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
22
|
+
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; }
|
|
23
23
|
|
|
24
24
|
var initialState = {
|
|
25
25
|
currentIndex: null,
|
|
@@ -19,9 +19,9 @@ var _d3v = require("d3v7");
|
|
|
19
19
|
|
|
20
20
|
var _utils = require("../utils");
|
|
21
21
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
22
|
+
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; }
|
|
23
23
|
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
24
|
+
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; }
|
|
25
25
|
|
|
26
26
|
var stackData = function stackData(data, series) {
|
|
27
27
|
var dataMap = (0, _d3v.group)(data, function (d) {
|
|
@@ -125,5 +125,6 @@ var getDomain = function getDomain(_ref2, _ref3) {
|
|
|
125
125
|
|
|
126
126
|
var min = _ref3.min,
|
|
127
127
|
max = _ref3.max;
|
|
128
|
+
console.log([min !== '' ? +min : min1, max !== '' ? +max : max1]);
|
|
128
129
|
return [min !== '' ? +min : min1, max !== '' ? +max : max1];
|
|
129
130
|
};
|
|
@@ -13,11 +13,11 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
|
|
14
14
|
var _react = require("react");
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
+
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; }
|
|
17
17
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
18
|
+
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; }
|
|
19
19
|
|
|
20
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
20
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
21
21
|
|
|
22
22
|
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); }
|
|
23
23
|
|
|
@@ -19,15 +19,17 @@ var _d3v = require("d3v7");
|
|
|
19
19
|
|
|
20
20
|
var _utils = require("../utils");
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
var _excluded = ["name"];
|
|
23
23
|
|
|
24
|
-
function
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
25
27
|
|
|
26
28
|
var getSeriesMap = function getSeriesMap(series) {
|
|
27
29
|
var seriesMap = new Map();
|
|
28
30
|
series.forEach(function (_ref) {
|
|
29
31
|
var name = _ref.name,
|
|
30
|
-
rest = (0, _objectWithoutProperties2["default"])(_ref,
|
|
32
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
31
33
|
seriesMap.set(name, _objectSpread(_objectSpread({}, rest), {}, {
|
|
32
34
|
name: name,
|
|
33
35
|
data: []
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -82,4 +82,8 @@ Object.keys(_utils3).forEach(function (key) {
|
|
|
82
82
|
return _utils3[key];
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
88
|
+
|
|
89
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/utils/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.band = band;
|
|
9
|
-
exports.
|
|
9
|
+
exports.sortPie = exports.seriesYOrZ = exports.resetStacks = exports.reduceConfig = exports.isValidHttpUrl = exports.identity = exports.getTranslate3d = exports.getTranslate2d = exports.getTicksOfAxis = exports.getTickCoord = exports.getStacks = exports.getMousePos = exports.getMargin = exports.getIcon = exports.getGridCoord = exports.getFontStyle = exports.getDomPath = exports.getDataWithPercent = exports.getCurrentStack = exports.getColorList = exports.getChildren = exports.getBreakWord = exports.getBandwidth = exports.getBandSeriesStepAndWidth = exports.getBandBackground = exports.filterChildren = exports.dateFormat = exports.dataYOrZ = void 0;
|
|
10
10
|
|
|
11
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
12
|
|
|
@@ -26,9 +26,12 @@ var _server = require("react-dom/server");
|
|
|
26
26
|
|
|
27
27
|
var _svgPoints = require("svg-points");
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
var _excluded = ["backgroundSize"],
|
|
30
|
+
_excluded2 = ["vote", "value"];
|
|
30
31
|
|
|
31
|
-
function
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
32
35
|
|
|
33
36
|
var defaultSize = 10;
|
|
34
37
|
var defaultBackground = '#000000';
|
|
@@ -590,7 +593,7 @@ var getBandBackground = function getBandBackground(pattern, fill) {
|
|
|
590
593
|
|
|
591
594
|
var _pattern$backgroundSi = pattern.backgroundSize,
|
|
592
595
|
backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
|
|
593
|
-
_pattern = (0, _objectWithoutProperties2["default"])(pattern,
|
|
596
|
+
_pattern = (0, _objectWithoutProperties2["default"])(pattern, _excluded);
|
|
594
597
|
|
|
595
598
|
return 'center top / ' + backgroundSize + ' url("data:image/svg+xml,' + encodeURIComponent((0, _server.renderToStaticMarkup)( /*#__PURE__*/React.createElement(SvgBackground, {
|
|
596
599
|
fill: fill,
|
|
@@ -814,7 +817,7 @@ var getDataWithPercent = function getDataWithPercent() {
|
|
|
814
817
|
var tmp = votesPerQuota.map(function (_ref28, index) {
|
|
815
818
|
var vote = _ref28.vote,
|
|
816
819
|
value = _ref28.value,
|
|
817
|
-
data = (0, _objectWithoutProperties2["default"])(_ref28,
|
|
820
|
+
data = (0, _objectWithoutProperties2["default"])(_ref28, _excluded2);
|
|
818
821
|
|
|
819
822
|
var obj = _objectSpread(_objectSpread({}, data), {}, {
|
|
820
823
|
value: value,
|
|
@@ -830,4 +833,24 @@ var getDataWithPercent = function getDataWithPercent() {
|
|
|
830
833
|
return tmp;
|
|
831
834
|
};
|
|
832
835
|
|
|
833
|
-
exports.getDataWithPercent = getDataWithPercent;
|
|
836
|
+
exports.getDataWithPercent = getDataWithPercent;
|
|
837
|
+
var excludeTypes = ['array', 'object', 'group', 'modal', 'colors'];
|
|
838
|
+
|
|
839
|
+
var reduceConfig = function reduceConfig() {
|
|
840
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
841
|
+
|
|
842
|
+
if (!Array.isArray(config)) {
|
|
843
|
+
return config;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var output = {};
|
|
847
|
+
|
|
848
|
+
for (var i = 0, len = config.length; i < len; i++) {
|
|
849
|
+
var type = config[i]._type;
|
|
850
|
+
output[config[i]._name] = type && !excludeTypes.includes(type) ? config[i]._value : reduceConfig(config[i]._value);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return output;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
exports.reduceConfig = reduceConfig;
|
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 参考线
|
|
3
|
+
*/
|
|
4
|
+
import React, { memo } from 'react';
|
|
5
|
+
import { getFontStyle } from '../utils';
|
|
6
|
+
|
|
7
|
+
export default memo(
|
|
8
|
+
({
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
baseLineOri: orientation,
|
|
12
|
+
config: {
|
|
13
|
+
dataStyle: {
|
|
14
|
+
data: {
|
|
15
|
+
show: dataShow,
|
|
16
|
+
dataStyle,
|
|
17
|
+
translate: dataTranslate
|
|
18
|
+
},
|
|
19
|
+
label: {
|
|
20
|
+
label,
|
|
21
|
+
show: labelShow,
|
|
22
|
+
textStyle,
|
|
23
|
+
translate: labelTranslate,
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
line: {
|
|
27
|
+
color,
|
|
28
|
+
lineType,
|
|
29
|
+
lineWidth,
|
|
30
|
+
margin: {
|
|
31
|
+
marginLeft,
|
|
32
|
+
marginRight
|
|
33
|
+
},
|
|
34
|
+
strokeDasharray,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
yAxis: { scaler: yScaler },
|
|
38
|
+
data
|
|
39
|
+
}) => {
|
|
40
|
+
if (!data.value) return null;
|
|
41
|
+
console.log(orientation, 'orientation')
|
|
42
|
+
const x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
|
|
43
|
+
x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
|
|
44
|
+
y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
|
|
45
|
+
y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<g className='__easyv-baseLine' >
|
|
49
|
+
<line
|
|
50
|
+
x1={x1}
|
|
51
|
+
x2={x2}
|
|
52
|
+
y1={y1}
|
|
53
|
+
y2={y2}
|
|
54
|
+
stroke={color}
|
|
55
|
+
fill='none'
|
|
56
|
+
strokeDasharray={lineType === 'dash' ? strokeDasharray : null}
|
|
57
|
+
strokeWidth={lineWidth}
|
|
58
|
+
/>
|
|
59
|
+
</g>
|
|
60
|
+
{labelShow &&
|
|
61
|
+
<foreignObject
|
|
62
|
+
width={100}
|
|
63
|
+
height={100}
|
|
64
|
+
x={x2 + labelTranslate.x}
|
|
65
|
+
y={y2 - textStyle.fontSize + labelTranslate.y}>
|
|
66
|
+
<div>
|
|
67
|
+
<span style={{ ...getFontStyle(textStyle) }}>{label}</span>
|
|
68
|
+
</div>
|
|
69
|
+
</foreignObject>}
|
|
70
|
+
{dataShow &&
|
|
71
|
+
<foreignObject
|
|
72
|
+
width={100}
|
|
73
|
+
height={100}
|
|
74
|
+
x={x2 + dataTranslate.x}
|
|
75
|
+
y={y2 + dataTranslate.y}>
|
|
76
|
+
<div>
|
|
77
|
+
<span style={{ ...getFontStyle(dataStyle) }}>{data.value}</span>
|
|
78
|
+
</div>
|
|
79
|
+
</foreignObject>}
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
Brush,
|
|
25
25
|
Label,
|
|
26
26
|
Mapping,
|
|
27
|
+
BaseLine
|
|
27
28
|
} from '.';
|
|
28
29
|
|
|
29
30
|
const Chart = memo(
|
|
@@ -41,6 +42,11 @@ const Chart = memo(
|
|
|
41
42
|
},
|
|
42
43
|
series,
|
|
43
44
|
tooltip,
|
|
45
|
+
baseLine: {
|
|
46
|
+
orientation:baseLineOri,
|
|
47
|
+
config: baseLineConfig = {},
|
|
48
|
+
data: baseLineData = []
|
|
49
|
+
},
|
|
44
50
|
tooltip: {
|
|
45
51
|
config: tooltipConfig = {},
|
|
46
52
|
config: { auto, manual, indicator = {} } = {},
|
|
@@ -49,7 +55,7 @@ const Chart = memo(
|
|
|
49
55
|
},
|
|
50
56
|
style,
|
|
51
57
|
data,
|
|
52
|
-
filterData
|
|
58
|
+
filterData
|
|
53
59
|
}) => {
|
|
54
60
|
const context = useContext(chartContext);
|
|
55
61
|
const {
|
|
@@ -95,10 +101,10 @@ const Chart = memo(
|
|
|
95
101
|
const indicatorAttr = isVertical
|
|
96
102
|
? { width: chartWidth, height: indicatorWidth, y: position }
|
|
97
103
|
: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
height: chartHeight,
|
|
105
|
+
width: indicatorWidth,
|
|
106
|
+
x: position,
|
|
107
|
+
};
|
|
102
108
|
|
|
103
109
|
const onInteraction = useCallback(
|
|
104
110
|
(e) => {
|
|
@@ -167,6 +173,20 @@ const Chart = memo(
|
|
|
167
173
|
)
|
|
168
174
|
);
|
|
169
175
|
})}
|
|
176
|
+
{baseLineData && baseLineData.length > 0 && baseLineData.map((item, index) => {
|
|
177
|
+
const { line: { yOrZ } } = baseLineConfig[index];
|
|
178
|
+
const yAxis = axes.get(yOrZ);
|
|
179
|
+
return (
|
|
180
|
+
yAxis && (<BaseLine
|
|
181
|
+
height={height}
|
|
182
|
+
width={width}
|
|
183
|
+
key={index}
|
|
184
|
+
config={baseLineConfig[index]}
|
|
185
|
+
baseLineOri={baseLineOri}
|
|
186
|
+
yAxis={yAxis}
|
|
187
|
+
data={item} />)
|
|
188
|
+
)
|
|
189
|
+
})}
|
|
170
190
|
</ChartContainer>
|
|
171
191
|
<Legend {...legend} filterData={filterData} series={series} />
|
|
172
192
|
{showTooltip && (
|
package/src/components/Line.js
CHANGED
|
@@ -38,7 +38,8 @@ const Area = ({
|
|
|
38
38
|
const areaGen = d3Area()
|
|
39
39
|
.x(({ data: { x } }) => xScaler(x))
|
|
40
40
|
.y1(({ data: { y } }) => yScaler(y))
|
|
41
|
-
.y0(height)
|
|
41
|
+
// .y0(height)
|
|
42
|
+
.y0(({})=>yScaler(0))
|
|
42
43
|
.defined(defined);
|
|
43
44
|
curve && areaGen.curve(curveCatmullRom.alpha(tension));
|
|
44
45
|
curve && areaGen.curve(curveMonotoneX);
|
|
@@ -469,18 +469,7 @@ const Component = memo(
|
|
|
469
469
|
strokeWidth={outerDecorate.width}
|
|
470
470
|
/>
|
|
471
471
|
{_arcs.map(
|
|
472
|
-
(
|
|
473
|
-
{
|
|
474
|
-
id,
|
|
475
|
-
value,
|
|
476
|
-
series,
|
|
477
|
-
arc,
|
|
478
|
-
innerRadius,
|
|
479
|
-
outerRadius,
|
|
480
|
-
index: dataIndex,
|
|
481
|
-
},
|
|
482
|
-
index
|
|
483
|
-
) => {
|
|
472
|
+
({ id, value, series, arc, innerRadius, outerRadius }, index) => {
|
|
484
473
|
const arcWidth = outerRadius - innerRadius;
|
|
485
474
|
const path = arc
|
|
486
475
|
.innerRadius(centerRadius)
|
|
@@ -498,7 +487,7 @@ const Component = memo(
|
|
|
498
487
|
strokeDashoffset: dashLength,
|
|
499
488
|
animationDelay: `${index * 2000}ms`,
|
|
500
489
|
}}
|
|
501
|
-
data-index={
|
|
490
|
+
data-index={index}
|
|
502
491
|
onClick={onClick}
|
|
503
492
|
onMouseEnter={onMouseEnter}
|
|
504
493
|
onMouseLeave={onMouseLeave}
|
|
@@ -605,7 +594,7 @@ const Component = memo(
|
|
|
605
594
|
return (
|
|
606
595
|
<Fragment key={index}>
|
|
607
596
|
<path
|
|
608
|
-
data-index={
|
|
597
|
+
data-index={index}
|
|
609
598
|
onClick={onClick}
|
|
610
599
|
onMouseEnter={onMouseEnter}
|
|
611
600
|
onMouseLeave={onMouseLeave}
|
|
@@ -619,7 +608,7 @@ const Component = memo(
|
|
|
619
608
|
//装饰物2,产生于每个弧的外部
|
|
620
609
|
decorate2 && decorate2.show && (
|
|
621
610
|
<path
|
|
622
|
-
data-index={
|
|
611
|
+
data-index={index}
|
|
623
612
|
onClick={onClick}
|
|
624
613
|
onMouseEnter={onMouseEnter}
|
|
625
614
|
onMouseLeave={onMouseLeave}
|
package/src/components/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import ConicalGradient from './ConicalGradient';
|
|
|
22
22
|
import CartesianChart from './CartesianChart';
|
|
23
23
|
import PieChart from './PieChart';
|
|
24
24
|
import TextOverflow from './TextOverflow';
|
|
25
|
+
import BaseLine from './BaseLine';
|
|
25
26
|
|
|
26
27
|
const Area = Line;
|
|
27
28
|
export {
|
|
@@ -50,4 +51,5 @@ export {
|
|
|
50
51
|
TextOverflow,
|
|
51
52
|
Chart,
|
|
52
53
|
ConicalGradient,
|
|
54
|
+
BaseLine,
|
|
53
55
|
};
|
package/src/utils/index.js
CHANGED
|
@@ -86,16 +86,16 @@ const getIcon = (type, icon) => {
|
|
|
86
86
|
case 'line':
|
|
87
87
|
return icon
|
|
88
88
|
? {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
...defaultLineIcon,
|
|
90
|
+
...icon,
|
|
91
|
+
}
|
|
92
92
|
: defaultLineIcon;
|
|
93
93
|
default:
|
|
94
94
|
return icon
|
|
95
95
|
? {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
...defaultIcon,
|
|
97
|
+
...icon,
|
|
98
|
+
}
|
|
99
99
|
: defaultIcon;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
@@ -663,6 +663,24 @@ const getDataWithPercent = (data = [], precision = 0) => {
|
|
|
663
663
|
return tmp;
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
+
|
|
667
|
+
const excludeTypes = ['array', 'object', 'group', 'modal', 'colors'];
|
|
668
|
+
const reduceConfig = (config = []) => {
|
|
669
|
+
if (!Array.isArray(config)) {
|
|
670
|
+
return config;
|
|
671
|
+
}
|
|
672
|
+
let output = {};
|
|
673
|
+
for (let i = 0, len = config.length; i < len; i++) {
|
|
674
|
+
let type = config[i]._type;
|
|
675
|
+
|
|
676
|
+
output[config[i]._name] =
|
|
677
|
+
type && !excludeTypes.includes(type)
|
|
678
|
+
? config[i]._value
|
|
679
|
+
: reduceConfig(config[i]._value);
|
|
680
|
+
}
|
|
681
|
+
return output;
|
|
682
|
+
}
|
|
683
|
+
|
|
666
684
|
export {
|
|
667
685
|
dateFormat,
|
|
668
686
|
getBreakWord,
|
|
@@ -692,4 +710,5 @@ export {
|
|
|
692
710
|
getDomPath,
|
|
693
711
|
sortPie,
|
|
694
712
|
getDataWithPercent,
|
|
713
|
+
reduceConfig,
|
|
695
714
|
};
|