@easyv/charts 1.2.10 → 1.2.14

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.
@@ -49,7 +49,6 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
49
49
  yScaler = _ref.yAxis.scaler,
50
50
  data = _ref.data;
51
51
  if (!data.value) return null;
52
- console.log(orientation, 'orientation');
53
52
  var x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
54
53
  x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
55
54
  y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
@@ -46,11 +46,12 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
46
46
  series = _ref$config.series,
47
47
  tooltip = _ref$config.tooltip,
48
48
  _ref$config$baseLine = _ref$config.baseLine,
49
- baseLineOri = _ref$config$baseLine.orientation,
50
- _ref$config$baseLine$ = _ref$config$baseLine.config,
51
- baseLineConfig = _ref$config$baseLine$ === void 0 ? {} : _ref$config$baseLine$,
52
- _ref$config$baseLine$2 = _ref$config$baseLine.data,
53
- baseLineData = _ref$config$baseLine$2 === void 0 ? [] : _ref$config$baseLine$2,
49
+ _ref$config$baseLine$ = _ref$config$baseLine.orientation,
50
+ baseLineOri = _ref$config$baseLine$ === void 0 ? '' : _ref$config$baseLine$,
51
+ _ref$config$baseLine$2 = _ref$config$baseLine.config,
52
+ baseLineConfig = _ref$config$baseLine$2 === void 0 ? {} : _ref$config$baseLine$2,
53
+ _ref$config$baseLine$3 = _ref$config$baseLine.data,
54
+ baseLineData = _ref$config$baseLine$3 === void 0 ? [] : _ref$config$baseLine$3,
54
55
  _ref$config$tooltip = _ref$config.tooltip;
55
56
  _ref$config$tooltip = _ref$config$tooltip === void 0 ? {} : _ref$config$tooltip;
56
57
  var _ref$config$tooltip$c = _ref$config$tooltip.config,
@@ -233,7 +233,12 @@ ConicalGradient.prototype = {
233
233
  b1 = currentColor.b;
234
234
  a1 = currentColor.a;
235
235
  if (!a1 && a1 !== 0) a1 = 1;
236
- nextColor = colors[currentColorIndex];
236
+ nextColor = colors[currentColorIndex] || {
237
+ r: 0,
238
+ g: 0,
239
+ b: 0,
240
+ a: 1
241
+ };
237
242
  r2 = nextColor.r;
238
243
  g2 = nextColor.g;
239
244
  b2 = nextColor.b;
@@ -28,33 +28,26 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
28
28
  speed = _props$speed === void 0 ? 5 : _props$speed;
29
29
  var dom = (0, _react.useRef)(null);
30
30
  var content = (0, _react.useRef)(null);
31
- var duration = (0, _react.useRef)(1); //dom和content盒子对象,避免speed变化时重新获取盒子对象
32
31
 
33
- var domRect = (0, _react.useRef)(null);
34
- var contentRect = (0, _react.useRef)(null);
35
-
36
- var _useState = (0, _react.useState)([value]),
32
+ var _useState = (0, _react.useState)(false),
37
33
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
38
- textList = _useState2[0],
39
- setTextList = _useState2[1]; //文本变化时,需要重新计算dom和content的宽高
40
-
41
-
42
- (0, _react.useEffect)(function () {
43
- var dom_ = dom.current;
44
- domRect.current = dom_.getBoundingClientRect();
45
- var content_ = content.current;
46
- contentRect.current = content_.getBoundingClientRect();
47
-
48
- if (domRect.current.width < contentRect.current.width) {
49
- setTextList([value, value]);
50
- }
51
- }, [value]); //value和speed变化时,直接更新duration
34
+ fresh = _useState2[0],
35
+ setFresh = _useState2[1];
52
36
 
37
+ var textList = (0, _react.useRef)([value]);
38
+ var duration = (0, _react.useRef)(10 / speed);
53
39
  (0, _react.useEffect)(function () {
54
- if (domRect.current.width < contentRect.current.width) {
55
- duration.current = contentRect.current.width / domRect.current.width / speed * 10;
40
+ if (dom.current && content.current) {
41
+ var domRectWidth = dom.current.getBoundingClientRect().width;
42
+ var contentRectWidth = content.current.getBoundingClientRect().width;
43
+
44
+ if (domRectWidth < contentRectWidth) {
45
+ textList.current = [value, value];
46
+ duration.current = contentRectWidth / domRectWidth / speed * 10;
47
+ setFresh(!fresh);
48
+ }
56
49
  }
57
- }, [speed]); //在head标签中注入keyframes动画
50
+ }, [value, speed]); //在head标签中注入keyframes动画
58
51
 
59
52
  (0, _react.useEffect)(function () {
60
53
  var md_marquee = document.getElementById('md_marquee'); //先查找是否已经存在md_marquee
@@ -71,19 +64,21 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
71
64
  document.getElementsByTagName('head')[0].appendChild(_style);
72
65
  }
73
66
  }, []);
67
+ var overflow = textList.current.length == 2;
74
68
  return /*#__PURE__*/React.createElement("span", {
75
69
  style: _objectSpread(_objectSpread({
76
70
  width: '100%'
77
71
  }, style), {}, {
78
72
  display: 'flex',
79
73
  whiteSpace: 'nowrap',
80
- overflow: 'hidden'
74
+ overflow: 'hidden',
75
+ justifyContent: overflow ? "start" : style.justifyContent || ""
81
76
  }),
82
77
  ref: dom
83
- }, textList.map(function (item, itemIndex) {
78
+ }, textList.current.map(function (item, itemIndex) {
84
79
  return /*#__PURE__*/React.createElement("span", {
85
80
  key: itemIndex,
86
- style: textList.length == 2 ? {
81
+ style: overflow ? {
87
82
  //如果文本数量为2,则需要滚动
88
83
  animationName: 'md_marquee',
89
84
  animationTimingFunction: 'linear',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.2.10",
3
+ "version": "1.2.14",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -38,7 +38,6 @@ export default memo(
38
38
  data
39
39
  }) => {
40
40
  if (!data.value) return null;
41
- console.log(orientation, 'orientation')
42
41
  const x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
43
42
  x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
44
43
  y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
@@ -43,7 +43,7 @@ const Chart = memo(
43
43
  series,
44
44
  tooltip,
45
45
  baseLine: {
46
- orientation:baseLineOri,
46
+ orientation:baseLineOri='',
47
47
  config: baseLineConfig = {},
48
48
  data: baseLineData = []
49
49
  },
@@ -217,7 +217,7 @@ ConicalGradient.prototype = {
217
217
  a1 = currentColor.a;
218
218
  if (!a1 && a1 !== 0) a1 = 1;
219
219
 
220
- nextColor = colors[currentColorIndex];
220
+ nextColor = colors[currentColorIndex] || {r:0,g:0,b:0,a:1};
221
221
  r2 = nextColor.r;
222
222
  g2 = nextColor.g;
223
223
  b2 = nextColor.b;
@@ -1,4 +1,4 @@
1
- import { useState, useEffect, memo, useRef } from 'react';
1
+ import { useEffect, memo, useRef, useState } from 'react';
2
2
 
3
3
  /**
4
4
  * 文字跑马灯组件
@@ -14,30 +14,23 @@ export default memo((props) => {
14
14
 
15
15
  const dom = useRef(null);
16
16
  const content = useRef(null);
17
- const duration = useRef(1);
18
- //dom和content盒子对象,避免speed变化时重新获取盒子对象
19
- const domRect = useRef(null);
20
- const contentRect = useRef(null);
21
17
 
22
- const [textList, setTextList] = useState([value]);
18
+ const [fresh,setFresh] = useState(false);
19
+ let textList = useRef([value]);
20
+ let duration = useRef(10/speed);
23
21
 
24
- //文本变化时,需要重新计算dom和content的宽高
25
22
  useEffect(() => {
26
- const dom_ = dom.current;
27
- domRect.current = dom_.getBoundingClientRect();
28
- let content_ = content.current;
29
- contentRect.current = content_.getBoundingClientRect();
30
- if (domRect.current.width < contentRect.current.width) {
31
- setTextList([value, value]);
23
+ if(dom.current && content.current){
24
+ let domRectWidth = dom.current.getBoundingClientRect().width;
25
+ let contentRectWidth = content.current.getBoundingClientRect().width;
26
+ if (domRectWidth < contentRectWidth) {
27
+ textList.current = [value,value];
28
+ duration.current = contentRectWidth / domRectWidth / speed * 10;
29
+ setFresh(!fresh);
30
+ }
32
31
  }
33
- }, [value]);
34
- //value和speed变化时,直接更新duration
35
- useEffect(() => {
36
- if (domRect.current.width < contentRect.current.width) {
37
- duration.current =
38
- (contentRect.current.width / domRect.current.width / speed) * 10;
39
- }
40
- }, [speed]);
32
+ }, [value,speed]);
33
+
41
34
  //在head标签中注入keyframes动画
42
35
  useEffect(() => {
43
36
  let md_marquee = document.getElementById('md_marquee'); //先查找是否已经存在md_marquee
@@ -56,6 +49,7 @@ export default memo((props) => {
56
49
  document.getElementsByTagName('head')[0].appendChild(style);
57
50
  }
58
51
  }, []);
52
+ let overflow = textList.current.length==2;
59
53
  return (
60
54
  <span
61
55
  style={{
@@ -64,15 +58,16 @@ export default memo((props) => {
64
58
  display: 'flex',
65
59
  whiteSpace: 'nowrap',
66
60
  overflow: 'hidden',
61
+ justifyContent:overflow?"start":(style.justifyContent || "")
67
62
  }}
68
63
  ref={dom}
69
64
  >
70
- {textList.map((item, itemIndex) => {
65
+ {textList.current.map((item, itemIndex) => {
71
66
  return (
72
67
  <span
73
68
  key={itemIndex}
74
69
  style={
75
- textList.length == 2
70
+ overflow
76
71
  ? {
77
72
  //如果文本数量为2,则需要滚动
78
73
  animationName: 'md_marquee',