@easyv/charts 1.5.1 → 1.5.3

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.
@@ -22,7 +22,7 @@ var _react = _interopRequireWildcard(require("react"));
22
22
  var _d3v = require("d3v7");
23
23
 
24
24
  var _excluded = ["animation"],
25
- _excluded2 = ["config", "data"];
25
+ _excluded2 = ["config", "data", "active"];
26
26
 
27
27
  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); }
28
28
 
@@ -60,6 +60,7 @@ var _default = function _default(Component) {
60
60
  config = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
61
61
  _ref$data = _ref.data,
62
62
  data = _ref$data === void 0 ? [] : _ref$data,
63
+ active = _ref.active,
63
64
  rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
64
65
  var dataLength = data.length;
65
66
 
@@ -103,11 +104,11 @@ var _default = function _default(Component) {
103
104
  }
104
105
  }, [animationOn, interval, dataLength]);
105
106
  (0, _react.useEffect)(function () {
106
- carousel && carousel();
107
+ active && carousel && carousel();
107
108
  return function () {
108
109
  timer.current && timer.current.stop();
109
110
  };
110
- }, [carousel]);
111
+ }, [carousel, active]);
111
112
  var onEvent = (0, _react.useCallback)(function (_ref3) {
112
113
  var currentIndex = _ref3.currentIndex,
113
114
  type = _ref3.type;
@@ -269,13 +269,16 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
269
269
  (0, _react.useLayoutEffect)(function () {
270
270
  var controlEnd = axisX.controlEnd,
271
271
  start = axisX.start;
272
- controlEl.current.style.transform = "translate(".concat(cBarX, "px,0)"); //计算出当前位移的百分比
273
272
 
274
- var percent = cBarX / (cWidth - cBarWidth);
275
- var translateX = -(controlEnd + start / cPercent - chartWidth) * percent;
276
- curControlPercent.current = percent;
277
- seriesEl.current.style.transform = "translate(".concat(translateX, "px,").concat(marginTop, "px)");
278
- axisElList.current[2].style.transform = "translate(".concat(translateX, "px,", 0, "px)");
273
+ if (controlEl.current) {
274
+ controlEl.current.style.transform = "translate(".concat(cBarX, "px,0)"); //计算出当前位移的百分比
275
+
276
+ var percent = cBarX / (cWidth - cBarWidth);
277
+ var translateX = -(controlEnd + start / cPercent - chartWidth) * percent;
278
+ curControlPercent.current = percent;
279
+ seriesEl.current.style.transform = "translate(".concat(translateX, "px,").concat(marginTop, "px)");
280
+ axisElList.current[2].style.transform = "translate(".concat(translateX, "px,", 0, "px)");
281
+ }
279
282
  }, [controlInfo]); //控制条轮播动画
280
283
 
281
284
  (0, _react.useEffect)(function () {
@@ -159,7 +159,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
159
159
  }, type == 'pie' ? /*#__PURE__*/_react["default"].createElement(_.PieChart, (0, _extends2["default"])({
160
160
  id: id,
161
161
  config: config,
162
- data: data
162
+ data: data,
163
+ active: active
163
164
  }, props)) : /*#__PURE__*/_react["default"].createElement(_.CartesianChart, (0, _extends2["default"])({
164
165
  id: id,
165
166
  config: config,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -36,6 +36,7 @@ export default (Component: ComponentType<any>) =>
36
36
  ({
37
37
  config: { animation, ...config },
38
38
  data = [],
39
+ active,
39
40
  ...rest
40
41
  }: {
41
42
  data: DataType[];
@@ -77,11 +78,11 @@ export default (Component: ComponentType<any>) =>
77
78
  }, [animationOn, interval, dataLength]);
78
79
 
79
80
  useEffect(() => {
80
- carousel && carousel();
81
+ active && carousel && carousel();
81
82
  return () => {
82
83
  timer.current && timer.current.stop();
83
84
  };
84
- }, [carousel]);
85
+ }, [carousel, active]);
85
86
  interface Event{
86
87
  currentIndex:number,
87
88
  type:string
@@ -232,14 +232,16 @@ const Chart = memo(
232
232
  //cBarX变化后,修改图表的偏移值
233
233
  useLayoutEffect(()=>{
234
234
  const { controlEnd, start } = axisX;
235
- controlEl.current.style.transform = `translate(${cBarX}px,0)`;
236
- //计算出当前位移的百分比
237
- const percent = cBarX / (cWidth - cBarWidth);
238
- const translateX = -(controlEnd + start/cPercent - chartWidth) * percent;
239
- curControlPercent.current = percent;
240
- seriesEl.current.style.transform = `translate(${translateX}px,${marginTop}px)`;
241
- axisElList.current[2].style.transform = `translate(${translateX}px,${0}px)`;
242
- },[controlInfo]);
235
+ if(controlEl.current){
236
+ controlEl.current.style.transform = `translate(${cBarX}px,0)`;
237
+ //计算出当前位移的百分比
238
+ const percent = cBarX / (cWidth - cBarWidth);
239
+ const translateX = -(controlEnd + start/cPercent - chartWidth) * percent;
240
+ curControlPercent.current = percent;
241
+ seriesEl.current.style.transform = `translate(${translateX}px,${marginTop}px)`;
242
+ axisElList.current[2].style.transform = `translate(${translateX}px,${0}px)`;
243
+ }
244
+ },[controlInfo]);
243
245
  //控制条轮播动画
244
246
  useEffect(() => {
245
247
  if (controlEl.current && control) {
@@ -90,6 +90,8 @@ const Chart = memo(
90
90
  [id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit]
91
91
  );
92
92
 
93
+
94
+
93
95
  useEffect(()=>{
94
96
  const activeHandler=(e)=>{
95
97
  const { dynamicData = true } = e;
@@ -121,7 +123,7 @@ const Chart = memo(
121
123
  return (
122
124
  <chartContext.Provider value={context}>
123
125
  {type == 'pie' ? (
124
- <PieChart id={id} config={config} data={data} {...props} />
126
+ <PieChart id={id} config={config} data={data} active={active} {...props} />
125
127
  ) : (
126
128
  <CartesianChart id={id} config={config} data={data} active={active} {...props} />
127
129
  )}