@easyv/charts 1.4.9 → 1.4.11

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.
@@ -162,7 +162,8 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
162
162
  key: i,
163
163
  style: {
164
164
  overflow: "visible",
165
- position: "relative"
165
+ position: "relative",
166
+ cursor: "pointer"
166
167
  }
167
168
  }, attr, {
168
169
  onClick: triggerClick,
@@ -84,7 +84,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
84
84
  triggerOnRelative = _useContext.triggerOnRelative,
85
85
  onEmit = _useContext.onEmit;
86
86
 
87
- var svg = /*#__PURE__*/(0, _react.createRef)();
87
+ var svg = (0, _react.useRef)();
88
88
  var axes = (0, _hooks.useAxes)({
89
89
  axes: axesConfig,
90
90
  context: context
@@ -100,6 +100,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
100
100
  width: chartWidth,
101
101
  height: chartHeight,
102
102
  axisX: axisX,
103
+ isHover: isHover,
103
104
  config: tooltipConfig
104
105
  }),
105
106
  tooltipX = _useTooltip.x,
@@ -172,13 +173,14 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
172
173
  }));
173
174
  }), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
174
175
  style: isVertical ? {
175
- width: xLineRange + marginRight,
176
+ width: xLineRange + marginRight + marginLeft,
176
177
  height: yLineRange,
177
- transform: "translateX(".concat(-marginRight, "px)")
178
+ transform: "translateX(".concat(-marginLeft, "px)")
178
179
  } : {
179
180
  width: xLineRange,
180
- height: yLineRange + marginTop,
181
- transform: "translateY(".concat(-marginTop, "px)") // paddingTop:marginTop
181
+ height: yLineRange + marginTop + marginBottom,
182
+ transform: "translateY(".concat(-marginTop, "px)") // overflow:'visible'
183
+ // paddingTop:marginTop
182
184
 
183
185
  }
184
186
  }, /*#__PURE__*/_react["default"].createElement("svg", {
@@ -107,6 +107,9 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
107
107
  return /*#__PURE__*/React.createElement("g", {
108
108
  key: i,
109
109
  onClick: triggerClick,
110
+ style: {
111
+ cursor: "pointer"
112
+ },
110
113
  "data-data": JSON.stringify(data)
111
114
  }, showIcon && !isNaN(attr.y) && /*#__PURE__*/React.createElement(Icon, {
112
115
  cx: attr.x,
@@ -147,6 +147,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
147
147
  style: (0, _utils.getFontStyle)(value)
148
148
  }, showY, showSuffix && /*#__PURE__*/React.createElement("span", {
149
149
  style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(suffiixFont)), {}, {
150
+ display: "inline-block",
150
151
  transform: (0, _utils.getTranslate3d)(suffixTranslate)
151
152
  })
152
153
  }, tmp.get(s))));
@@ -115,7 +115,7 @@ var _default = function _default(_ref) {
115
115
  carousel = item.carousel,
116
116
  config = item.config; //计算真正需要的tickCount,如果domain区间太小,不能完全按照count来,需要减少count数
117
117
 
118
- var tickCount = getTickCount(domain, count, decimal);
118
+ var tickCount = type == "ordinal" ? count : getTickCount(domain, count, decimal);
119
119
  var direction = orientation === 'top' || orientation === 'bottom' ? 'horizontal' : orientation === 'left' || orientation === 'right' ? 'vertical' : '';
120
120
  var length = direction === 'horizontal' ? width : direction === 'vertical' ? height : 0;
121
121
 
@@ -34,6 +34,7 @@ var _default = function _default(_ref) {
34
34
  width = _ref.width,
35
35
  height = _ref.height,
36
36
  axisX = _ref.axisX,
37
+ isHover = _ref.isHover,
37
38
  _ref$config = _ref.config;
38
39
  _ref$config = _ref$config === void 0 ? {} : _ref$config;
39
40
  var auto = _ref$config.auto,
@@ -81,13 +82,16 @@ var _default = function _default(_ref) {
81
82
  return tick == _name;
82
83
  }));
83
84
  } else {
84
- setCurrentIndex(null);
85
+ // 鼠标划出后,如果开启了自动轮播,就不需要让提示框消失了
86
+ if (!auto) {
87
+ setCurrentIndex(null);
88
+ }
85
89
  }
86
90
  }
87
- }, [svg, marginLeft, axisX]);
91
+ }, [svg, marginLeft, axisX, auto]);
88
92
  (0, _react.useEffect)(function () {
89
- var on = auto && tickLength;
90
- if (!!on) setCurrentIndex(0);
93
+ var on = auto && tickLength && !isHover; // if (!!on) setCurrentIndex(0);
94
+
91
95
  var intervalHandler = on ? setInterval(function () {
92
96
  setCurrentIndex(function (index) {
93
97
  var tmp = index == null ? 0 : index;
@@ -103,7 +107,7 @@ var _default = function _default(_ref) {
103
107
  return function () {
104
108
  intervalHandler && clearInterval(intervalHandler);
105
109
  };
106
- }, [auto, tickLength, interval]);
110
+ }, [auto, tickLength, interval, isHover]);
107
111
  var name = currentIndex === null ? null : axisX.allTicks[currentIndex];
108
112
  return {
109
113
  name: name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -139,7 +139,8 @@ export default memo(
139
139
  key={i}
140
140
  style={{
141
141
  overflow:"visible",
142
- position:"relative"
142
+ position:"relative",
143
+ cursor:"pointer"
143
144
  }}
144
145
  {...attr}
145
146
  onClick={triggerClick}
@@ -5,7 +5,7 @@ import React, {
5
5
  memo,
6
6
  useMemo,
7
7
  useState,
8
- createRef,
8
+ useRef,
9
9
  useContext,
10
10
  useCallback,
11
11
  } from 'react';
@@ -68,7 +68,7 @@ const Chart = memo(
68
68
  triggerOnRelative,
69
69
  onEmit,
70
70
  } = useContext(chartContext);
71
- const svg = createRef();
71
+ const svg = useRef();
72
72
  const axes = useAxes({ axes: axesConfig, context });
73
73
  const axisX = useCarouselAxisX(axes.get('x'), animation, isHover);
74
74
  const xLineRange = width-marginLeft-marginRight;
@@ -85,6 +85,7 @@ const Chart = memo(
85
85
  width: chartWidth,
86
86
  height: chartHeight,
87
87
  axisX,
88
+ isHover,
88
89
  config: tooltipConfig,
89
90
  });
90
91
  const tooltipData = useMemo(
@@ -157,13 +158,14 @@ const Chart = memo(
157
158
  })}
158
159
  {showTooltip && <Indicator {...indicator} {...indicatorAttr} />}
159
160
  <foreignObject style={isVertical?{
160
- width:xLineRange+marginRight,
161
+ width:xLineRange+marginRight+marginLeft,
161
162
  height:yLineRange,
162
- transform:`translateX(${-marginRight}px)`,
163
+ transform:`translateX(${-marginLeft}px)`,
163
164
  }:{
164
165
  width:xLineRange,
165
- height:yLineRange+marginTop,
166
+ height:yLineRange+marginTop+marginBottom,
166
167
  transform:`translateY(${-marginTop}px)`,
168
+ // overflow:'visible'
167
169
  // paddingTop:marginTop
168
170
  }}>
169
171
  <svg width="100%" height="100%" style={{overflow:"visible",transform:isVertical?`translateX(${marginRight}px)`:`translateY(${marginTop}px)`}}>
@@ -87,6 +87,7 @@ export default memo(
87
87
  <g
88
88
  key={i}
89
89
  onClick={triggerClick}
90
+ style={{cursor:"pointer"}}
90
91
  data-data={JSON.stringify(data)}
91
92
  >
92
93
  {showIcon && !isNaN(attr.y) && (
@@ -61,7 +61,6 @@ export default memo(
61
61
  tipHeight,
62
62
  translateTip,
63
63
  ]);
64
-
65
64
  return (
66
65
  <div
67
66
  className='__easyv-tooltip'
@@ -151,6 +150,7 @@ export default memo(
151
150
  <span
152
151
  style={{
153
152
  ...getFontStyle(suffiixFont),
153
+ display:"inline-block",
154
154
  transform: getTranslate3d(suffixTranslate),
155
155
  }}
156
156
  >
@@ -78,9 +78,8 @@ export default ({ axes, context: { width, height } }) => {
78
78
  carousel,
79
79
  config,
80
80
  } = item;
81
-
82
81
  //计算真正需要的tickCount,如果domain区间太小,不能完全按照count来,需要减少count数
83
- const tickCount = getTickCount(domain,count,decimal);
82
+ const tickCount = type=="ordinal"?count:getTickCount(domain,count,decimal);
84
83
  const direction =
85
84
  orientation === 'top' || orientation === 'bottom'
86
85
  ? 'horizontal'
@@ -20,6 +20,7 @@ type Props = {
20
20
  width: number;
21
21
  height: number;
22
22
  axisX: AxisX;
23
+ isHover:boolean,
23
24
  config: { auto?: boolean; interval?: number; manual?: boolean };
24
25
  };
25
26
 
@@ -30,10 +31,10 @@ export default ({
30
31
  width,
31
32
  height,
32
33
  axisX,
34
+ isHover,
33
35
  config: { auto, interval = 0, manual } = {},
34
36
  }: Props) => {
35
37
  const [currentIndex, setCurrentIndex] = useState<number | null>(null);
36
-
37
38
  const tickLength = axisX.allTicks.length;
38
39
  const setIndex = useCallback(
39
40
  (e) => {
@@ -62,15 +63,18 @@ export default ({
62
63
  );
63
64
  setCurrentIndex(allTicks.findIndex((tick: string) => tick == name));
64
65
  } else {
65
- setCurrentIndex(null);
66
+ // 鼠标划出后,如果开启了自动轮播,就不需要让提示框消失了
67
+ if(!auto){
68
+ setCurrentIndex(null);
69
+ }
66
70
  }
67
71
  }
68
72
  },
69
- [svg, marginLeft, axisX]
73
+ [svg, marginLeft, axisX, auto]
70
74
  );
71
75
  useEffect(() => {
72
- const on = auto && tickLength;
73
- if (!!on) setCurrentIndex(0);
76
+ const on = auto && tickLength && !isHover;
77
+ // if (!!on) setCurrentIndex(0);
74
78
  const intervalHandler = on
75
79
  ? setInterval(() => {
76
80
  setCurrentIndex((index) => {
@@ -86,7 +90,7 @@ export default ({
86
90
  return () => {
87
91
  intervalHandler && clearInterval(intervalHandler);
88
92
  };
89
- }, [auto, tickLength, interval]);
93
+ }, [auto, tickLength, interval, isHover]);
90
94
  const name = currentIndex === null ? null : axisX.allTicks[currentIndex];
91
95
  return {
92
96
  name,