@easyv/charts 1.3.21 → 1.3.23
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/Legend.js +12 -3
- package/lib/components/Marquee.js +5 -6
- package/lib/components/TextOverflow.js +5 -3
- package/lib/hooks/useAxes.js +1 -1
- package/package.json +1 -1
- package/src/components/Legend.js +8 -7
- package/src/components/Marquee.js +7 -7
- package/src/components/TextOverflow.js +6 -7
- package/src/hooks/useAxes.js +1 -1
package/lib/components/Legend.js
CHANGED
|
@@ -19,6 +19,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _utils = require("../utils");
|
|
21
21
|
|
|
22
|
+
var _TextOverflow = _interopRequireDefault(require("./TextOverflow"));
|
|
23
|
+
|
|
22
24
|
var _excluded = ["italic", "bold"];
|
|
23
25
|
|
|
24
26
|
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); }
|
|
@@ -42,6 +44,9 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
42
44
|
_ref$config$order = _ref$config.order,
|
|
43
45
|
order = _ref$config$order === void 0 ? '' : _ref$config$order,
|
|
44
46
|
interactive = _ref$config.interactive,
|
|
47
|
+
maxWidth = _ref$config.maxWidth,
|
|
48
|
+
textOverflow = _ref$config.textOverflow,
|
|
49
|
+
speed = _ref$config.speed,
|
|
45
50
|
_ref$config$layout = _ref$config.layout,
|
|
46
51
|
_ref$config$layout$al = _ref$config$layout.alignment,
|
|
47
52
|
alignment = _ref$config$layout$al === void 0 ? 'right center' : _ref$config$layout$al,
|
|
@@ -123,12 +128,16 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
123
128
|
}
|
|
124
129
|
}, formatter ? formatter(series, config) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
125
130
|
style: _icon
|
|
126
|
-
}), /*#__PURE__*/_react["default"].createElement("
|
|
131
|
+
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
132
|
+
type: textOverflow,
|
|
133
|
+
value: displayName || name,
|
|
127
134
|
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
135
|
+
width: maxWidth,
|
|
128
136
|
fontStyle: italic ? 'italic' : 'normal',
|
|
129
137
|
fontWeight: bold ? 'bold' : 'normal'
|
|
130
|
-
})
|
|
131
|
-
|
|
138
|
+
}),
|
|
139
|
+
speed: speed
|
|
140
|
+
})));
|
|
132
141
|
})));
|
|
133
142
|
});
|
|
134
143
|
|
|
@@ -21,12 +21,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
21
|
* 文字跑马灯组件
|
|
22
22
|
* eg: <Marquee value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
|
|
23
23
|
*/
|
|
24
|
-
var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
24
|
+
var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
25
25
|
var value = props.value,
|
|
26
26
|
style = props.style,
|
|
27
27
|
_props$speed = props.speed,
|
|
28
28
|
speed = _props$speed === void 0 ? 5 : _props$speed;
|
|
29
|
-
var dom = (0, _react.useRef)(null);
|
|
30
29
|
var target = (0, _react.useRef)(null);
|
|
31
30
|
var observe = (0, _react.useRef)(null);
|
|
32
31
|
var speed_ = (0, _react.useRef)(0); //这里必须用一个ref绑定speed,否则animation中获取不到最新的speed
|
|
@@ -73,7 +72,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
}, {
|
|
76
|
-
root:
|
|
75
|
+
root: ref.current,
|
|
77
76
|
rootMargin: "0px 0px 0px 0px",
|
|
78
77
|
threshold: new Array(101).fill(0).map(function (d, i) {
|
|
79
78
|
return i / 100;
|
|
@@ -98,7 +97,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
98
97
|
overflow: "hidden",
|
|
99
98
|
justifyContent: overflow ? "start" : style.justifyContent || ""
|
|
100
99
|
}),
|
|
101
|
-
ref:
|
|
100
|
+
ref: ref
|
|
102
101
|
}, textList.map(function (item, i) {
|
|
103
102
|
return /*#__PURE__*/React.createElement("span", {
|
|
104
103
|
key: i,
|
|
@@ -106,8 +105,8 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
106
105
|
style: {
|
|
107
106
|
display: i == 1 && !overflow ? "none" : "inline"
|
|
108
107
|
}
|
|
109
|
-
}, item, "\xA0");
|
|
108
|
+
}, item, overflow && /*#__PURE__*/React.createElement("span", null, "\xA0"));
|
|
110
109
|
}));
|
|
111
|
-
});
|
|
110
|
+
}));
|
|
112
111
|
|
|
113
112
|
exports["default"] = _default;
|
|
@@ -21,7 +21,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
21
|
* 文本溢出组件
|
|
22
22
|
* eg: <TextOverflow type={溢出形式} value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
|
|
23
23
|
*/
|
|
24
|
-
var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
24
|
+
var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
25
25
|
var type = props.type,
|
|
26
26
|
value = props.value,
|
|
27
27
|
style = props.style,
|
|
@@ -55,11 +55,13 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
55
55
|
return type == 'marquee' ? /*#__PURE__*/React.createElement(_Marquee["default"], {
|
|
56
56
|
value: value,
|
|
57
57
|
speed: speed,
|
|
58
|
-
style: styles
|
|
58
|
+
style: styles,
|
|
59
|
+
ref: ref
|
|
59
60
|
}) : /*#__PURE__*/React.createElement("div", {
|
|
60
61
|
style: styles,
|
|
62
|
+
ref: ref,
|
|
61
63
|
title: value || null
|
|
62
64
|
}, " ", value);
|
|
63
|
-
});
|
|
65
|
+
}));
|
|
64
66
|
|
|
65
67
|
exports["default"] = _default;
|
package/lib/hooks/useAxes.js
CHANGED
|
@@ -145,7 +145,7 @@ var _default = function _default(_ref) {
|
|
|
145
145
|
if (type == 'linear' && config.on) {
|
|
146
146
|
var zeroPosition = scaler(0);
|
|
147
147
|
|
|
148
|
-
if (zeroPosition !== range[0]) {
|
|
148
|
+
if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
|
|
149
149
|
if (direction === 'horizontal') {
|
|
150
150
|
xAxisPositions.push({
|
|
151
151
|
x: zeroPosition,
|
package/package.json
CHANGED
package/src/components/Legend.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React, { memo, useCallback } from 'react';
|
|
5
5
|
import { getIcon, sortPie } from '../utils';
|
|
6
|
+
import TextOverflow from './TextOverflow';
|
|
6
7
|
|
|
7
8
|
const defaultFont = {
|
|
8
9
|
fontStyle: 'normal',
|
|
@@ -17,6 +18,9 @@ export default memo(
|
|
|
17
18
|
show,
|
|
18
19
|
order = '',
|
|
19
20
|
interactive,
|
|
21
|
+
maxWidth,
|
|
22
|
+
textOverflow,
|
|
23
|
+
speed,
|
|
20
24
|
layout: {
|
|
21
25
|
alignment = 'right center',
|
|
22
26
|
gridTemplateColumns,
|
|
@@ -45,7 +49,6 @@ export default memo(
|
|
|
45
49
|
);
|
|
46
50
|
|
|
47
51
|
//木然判断数据都为零时做的,此处并不严谨,待想到好方法在进一步解决
|
|
48
|
-
|
|
49
52
|
if (judge == 0) {
|
|
50
53
|
_series.forEach((d) => {
|
|
51
54
|
d.percent=0
|
|
@@ -91,15 +94,13 @@ export default memo(
|
|
|
91
94
|
) : (
|
|
92
95
|
<>
|
|
93
96
|
<span style={_icon} />
|
|
94
|
-
<
|
|
95
|
-
style={{
|
|
97
|
+
<TextOverflow type={textOverflow} value={displayName || name} style={{
|
|
96
98
|
...font,
|
|
99
|
+
width:maxWidth,
|
|
97
100
|
fontStyle: italic ? 'italic' : 'normal',
|
|
98
101
|
fontWeight: bold ? 'bold' : 'normal',
|
|
99
|
-
}}
|
|
100
|
-
|
|
101
|
-
{displayName || name}
|
|
102
|
-
</span>
|
|
102
|
+
}} speed={speed}></TextOverflow>
|
|
103
|
+
|
|
103
104
|
</>
|
|
104
105
|
)}
|
|
105
106
|
</li>
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { useEffect, memo, useRef, useState,
|
|
1
|
+
import { useEffect, memo, useRef, useState, forwardRef } from "react";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 文字跑马灯组件
|
|
5
5
|
* eg: <Marquee value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export default memo((props) => {
|
|
8
|
+
export default memo(forwardRef((props, ref) => {
|
|
9
9
|
const {
|
|
10
10
|
value, // 文本
|
|
11
11
|
style, // 样式
|
|
12
12
|
speed = 5, // 动画速度
|
|
13
13
|
} = props;
|
|
14
14
|
|
|
15
|
-
const dom = useRef(null);
|
|
16
15
|
const target = useRef(null);
|
|
17
16
|
const observe = useRef(null);
|
|
18
17
|
const speed_ = useRef(0); //这里必须用一个ref绑定speed,否则animation中获取不到最新的speed
|
|
@@ -54,7 +53,7 @@ export default memo((props) => {
|
|
|
54
53
|
}
|
|
55
54
|
},
|
|
56
55
|
{
|
|
57
|
-
root:
|
|
56
|
+
root: ref.current,
|
|
58
57
|
rootMargin: "0px 0px 0px 0px",
|
|
59
58
|
threshold: new Array(101).fill(0).map((d, i) => i / 100), //这里设置了[0-1]之间所有的阈值,保证每一帧的变化都能被观察到
|
|
60
59
|
}
|
|
@@ -79,7 +78,7 @@ export default memo((props) => {
|
|
|
79
78
|
overflow: "hidden",
|
|
80
79
|
justifyContent: overflow ? "start" : style.justifyContent || "",
|
|
81
80
|
}}
|
|
82
|
-
ref={
|
|
81
|
+
ref={ref}
|
|
83
82
|
>
|
|
84
83
|
{textList.map((item, i) => {
|
|
85
84
|
return (
|
|
@@ -88,10 +87,11 @@ export default memo((props) => {
|
|
|
88
87
|
ref={i == 0 ? target : null}
|
|
89
88
|
style={{ display: i == 1 && !overflow ? "none" : "inline" }}
|
|
90
89
|
>
|
|
91
|
-
{item}
|
|
90
|
+
{item}
|
|
91
|
+
{overflow && <span> </span>}
|
|
92
92
|
</span>
|
|
93
93
|
);
|
|
94
94
|
})}
|
|
95
95
|
</div>
|
|
96
96
|
);
|
|
97
|
-
});
|
|
97
|
+
}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
1
|
+
import { memo, forwardRef } from 'react';
|
|
2
2
|
import Marquee from './Marquee'
|
|
3
3
|
/**
|
|
4
4
|
* 文本溢出组件
|
|
5
5
|
* eg: <TextOverflow type={溢出形式} value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export default memo((props) => {
|
|
8
|
+
export default memo(forwardRef((props, ref) => {
|
|
9
9
|
const {
|
|
10
10
|
type, //形式:跑马灯marquee /省略号 ellipsis/换行 break-word
|
|
11
11
|
value, // 文本
|
|
@@ -33,19 +33,18 @@ export default memo((props) => {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
|
|
37
36
|
const styles = {
|
|
38
37
|
...getTextOverflow(type),
|
|
39
38
|
...style
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
|
|
43
41
|
return type == 'marquee' ? (
|
|
44
42
|
<Marquee
|
|
45
43
|
value={value}
|
|
46
44
|
speed={speed}
|
|
47
|
-
style={styles}
|
|
45
|
+
style={styles}
|
|
46
|
+
ref={ref} />
|
|
48
47
|
) : (
|
|
49
|
-
<div style={styles} title={value || null}> {value}</div>
|
|
48
|
+
<div style={styles} ref={ref} title={value || null}> {value}</div>
|
|
50
49
|
);
|
|
51
|
-
});
|
|
50
|
+
}));
|
package/src/hooks/useAxes.js
CHANGED
|
@@ -141,7 +141,7 @@ export default ({ axes, context: { width, height } }) => {
|
|
|
141
141
|
|
|
142
142
|
if (type == 'linear' && config.on) {
|
|
143
143
|
const zeroPosition = scaler(0);
|
|
144
|
-
if (zeroPosition !== range[0]) {
|
|
144
|
+
if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
|
|
145
145
|
if (direction === 'horizontal') {
|
|
146
146
|
xAxisPositions.push({
|
|
147
147
|
x: zeroPosition,
|