@easyv/charts 1.9.10 → 1.9.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.
@@ -522,10 +522,14 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
522
522
  onMouseEnter: function onMouseEnter() {
523
523
  setIsHover(true);
524
524
  },
525
- onMouseMove: !control ? setIndex : null,
525
+ onMouseMove: function onMouseMove(e) {
526
+ setIndex(e);
527
+ setIndex;
528
+ },
526
529
  onMouseLeave: function onMouseLeave(e) {
527
530
  setIsHover(false);
528
531
  setIndex(e);
532
+ // setIndex
529
533
  },
530
534
  ref: svg
531
535
  }, background && /*#__PURE__*/_react["default"].createElement("foreignObject", {
@@ -569,7 +573,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
569
573
  key: index
570
574
  }));
571
575
  }), showTooltip && !control && zIndex == "bottom" && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, {
572
- manual: manual,
576
+ manual: true,
573
577
  auto: auto
574
578
  }, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
575
579
  style: {
@@ -598,7 +602,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
598
602
  xName: item.tick,
599
603
  setCtlTip: setCtlTip,
600
604
  ctlIndicatorList: ctlIndicatorList,
601
- manual: manual
605
+ manual: true
602
606
  }));
603
607
  })), series.map(function (_ref2, index) {
604
608
  var Component = _ref2.Component,
@@ -666,6 +670,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
666
670
  series: series,
667
671
  width: width,
668
672
  height: height,
673
+ auto: auto,
669
674
  manual: manual
670
675
  }))), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
671
676
  var yOrZ = baseLineConfig[index].line.yOrZ;
@@ -713,6 +718,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
713
718
  series: series,
714
719
  width: width,
715
720
  height: height,
721
+ auto: auto,
716
722
  manual: manual
717
723
  })), brush && /*#__PURE__*/_react["default"].createElement(_.Brush, {
718
724
  config: brush,
@@ -49,6 +49,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
49
49
  isVertical = _ref.isVertical,
50
50
  width = _ref.width,
51
51
  height = _ref.height,
52
+ auto = _ref.auto,
52
53
  manual = _ref.manual;
53
54
  var tipPosition = (0, _react.useMemo)(function () {
54
55
  var translate3d = isVertical ? _objectSpread(_objectSpread({}, translateTip), {}, {
@@ -66,15 +67,15 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
66
67
  }
67
68
  return (0, _utils.getTranslate3d)(translate3d);
68
69
  }, [width, height, marginLeft, marginTop, position, tipWidth, tipHeight, translateTip]);
69
- return manual ? /*#__PURE__*/React.createElement("div", {
70
+ return manual || auto ? /*#__PURE__*/React.createElement("div", {
70
71
  className: "__easyv-tooltip",
71
72
  style: _objectSpread({
72
- pointerEvents: 'none',
73
+ pointerEvents: "none",
73
74
  transform: tipPosition,
74
75
  width: tipWidth,
75
76
  minHeight: tipHeight,
76
77
  padding: (0, _utils.getMargin)(margin),
77
- background: bgType == "image" ? image ? '50% 50% / 100% 100% no-repeat url(' + window.appConfig.ASSETS_URL + image + ')' : "transparent" : bgColor
78
+ background: bgType == "image" ? image ? "50% 50% / 100% 100% no-repeat url(" + window.appConfig.ASSETS_URL + image + ")" : "transparent" : bgColor
78
79
  }, (0, _utils.getFontStyle)(font))
79
80
  }, formatter ? formatter({
80
81
  series: series,
@@ -88,11 +89,11 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
88
89
  }
89
90
  }) : /*#__PURE__*/React.createElement("div", {
90
91
  style: {
91
- display: 'flex',
92
- flexDirection: 'column',
93
- justifyContent: 'space-between',
92
+ display: "flex",
93
+ flexDirection: "column",
94
+ justifyContent: "space-between",
94
95
  gap: gap,
95
- height: '100%'
96
+ height: "100%"
96
97
  }
97
98
  }, /*#__PURE__*/React.createElement("div", {
98
99
  style: _objectSpread({
@@ -122,27 +123,27 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
122
123
  suffixTranslate = suffix.translate;
123
124
  var tmp = new Map();
124
125
  Object.values(content).forEach(function (item) {
125
- tmp.set(item['suffix'].name, item['suffix'].suffix);
126
+ tmp.set(item["suffix"].name, item["suffix"].suffix);
126
127
  });
127
128
  var _icon = (0, _utils.getIcon)(type, icon);
128
129
  return /*#__PURE__*/React.createElement("dd", {
129
130
  style: {
130
- display: 'flex',
131
- justifyContent: 'space-between',
132
- lineHeight: lineHeight + 'px'
131
+ display: "flex",
132
+ justifyContent: "space-between",
133
+ lineHeight: lineHeight + "px"
133
134
  },
134
135
  key: index
135
136
  }, /*#__PURE__*/React.createElement("span", {
136
137
  style: {
137
- border: '1px solid red',
138
- display: 'flex',
139
- alignItems: 'center',
138
+ border: "1px solid red",
139
+ display: "flex",
140
+ alignItems: "center",
140
141
  gap: icon.iconGap
141
142
  }
142
143
  }, /*#__PURE__*/React.createElement("span", {
143
144
  style: _objectSpread(_objectSpread({}, _icon), {}, {
144
- width: iconSize + 'px',
145
- height: iconSize + 'px'
145
+ width: iconSize + "px",
146
+ height: iconSize + "px"
146
147
  })
147
148
  }), /*#__PURE__*/React.createElement("span", {
148
149
  style: (0, _utils.getFontStyle)(name)
@@ -79,6 +79,7 @@ var _default = exports["default"] = function _default(_ref) {
79
79
  }, [svg, marginLeft, axisX, auto]);
80
80
  (0, _react.useEffect)(function () {
81
81
  var on = auto && tickLength && !isHover && active;
82
+ if (!auto) setIndex(-1); //不开启自动轮播,提示框等隐藏
82
83
  // if (!!on) setCurrentIndex(0);
83
84
  var intervalHandler = on ? setInterval(function () {
84
85
  setCurrentIndex(function (index) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.9.10",
3
+ "version": "1.9.11",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -508,10 +508,14 @@ const Chart = memo(
508
508
  onMouseEnter={() => {
509
509
  setIsHover(true);
510
510
  }}
511
- onMouseMove={!control ? setIndex : null}
511
+ onMouseMove={(e) => {
512
+ setIndex(e);
513
+ setIndex;
514
+ }}
512
515
  onMouseLeave={(e) => {
513
516
  setIsHover(false);
514
517
  setIndex(e);
518
+ // setIndex
515
519
  }}
516
520
  ref={svg}
517
521
  >
@@ -562,7 +566,7 @@ const Chart = memo(
562
566
  {showTooltip && !control && zIndex == "bottom" && (
563
567
  <Indicator
564
568
  {...indicator}
565
- manual={manual}
569
+ manual={true}
566
570
  auto={auto}
567
571
  {...indicatorAttr}
568
572
  />
@@ -607,7 +611,7 @@ const Chart = memo(
607
611
  xName={item.tick}
608
612
  setCtlTip={setCtlTip}
609
613
  ctlIndicatorList={ctlIndicatorList}
610
- manual={manual}
614
+ manual={true}
611
615
  />
612
616
  );
613
617
  })}
@@ -701,6 +705,7 @@ const Chart = memo(
701
705
  series={series}
702
706
  width={width}
703
707
  height={height}
708
+ auto={auto}
704
709
  manual={manual}
705
710
  />
706
711
  )}
@@ -771,6 +776,7 @@ const Chart = memo(
771
776
  series={series}
772
777
  width={width}
773
778
  height={height}
779
+ auto={auto}
774
780
  manual={manual}
775
781
  />
776
782
  )}
@@ -91,7 +91,7 @@ export default memo(
91
91
  (fieldName) => (e) => {
92
92
  const { dataset } = e.currentTarget;
93
93
  const { name } = dataset;
94
- filterData && interactive && filterData(fieldName||name);
94
+ filterData && interactive && filterData(fieldName || name);
95
95
  pieClick && pieClick(e);
96
96
  },
97
97
  [interactive, filterData, pieClick]
@@ -168,7 +168,7 @@ export default memo(
168
168
  overflowY: loop.show ? "scroll" : "auto",
169
169
  }
170
170
  : {
171
- width:"100%",
171
+ width: "100%",
172
172
  display: "flex",
173
173
  flexWrap: "wrap",
174
174
  alignContent:
@@ -211,7 +211,15 @@ export default memo(
211
211
  }}
212
212
  >
213
213
  {_series.map((series, i) => {
214
- const { type, name, displayName,fieldName, icon, selected, index } = series;
214
+ const {
215
+ type,
216
+ name,
217
+ displayName,
218
+ fieldName,
219
+ icon,
220
+ selected,
221
+ index,
222
+ } = series;
215
223
  const _icon = getIcon(type, icon, series?.config?.line?.type);
216
224
  return (
217
225
  <li
@@ -281,8 +289,15 @@ export default memo(
281
289
  >
282
290
  {_series.map((series, i) => {
283
291
  if (Math.floor(i / gridTemplateColumns) == indexs) {
284
- const { type, name, displayName,fieldName, icon, selected, index } =
285
- series;
292
+ const {
293
+ type,
294
+ name,
295
+ displayName,
296
+ fieldName,
297
+ icon,
298
+ selected,
299
+ index,
300
+ } = series;
286
301
  const _icon = getIcon(type, icon, series?.config?.line?.type);
287
302
  return (
288
303
  <li
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * 提示框
3
3
  */
4
- import { memo, useMemo } from 'react';
5
- import { getFontStyle, getMargin, getTranslate3d } from '../utils';
6
- import { getIcon } from '../utils';
4
+ import { memo, useMemo } from "react";
5
+ import { getFontStyle, getMargin, getTranslate3d } from "../utils";
6
+ import { getIcon } from "../utils";
7
7
  export default memo(
8
8
  ({
9
9
  x: position,
@@ -18,7 +18,15 @@ export default memo(
18
18
  xAxis,
19
19
  xAxis: { background, gap, align, font, translate: translateXAxis },
20
20
  data: dataConfig,
21
- data: { lineHeight, gap:dataGap, iconSize, background:dataBg, name, value, suffix },
21
+ data: {
22
+ lineHeight,
23
+ gap: dataGap,
24
+ iconSize,
25
+ background: dataBg,
26
+ name,
27
+ value,
28
+ suffix,
29
+ },
22
30
  },
23
31
  bgType,
24
32
  bgColor,
@@ -32,18 +40,19 @@ export default memo(
32
40
  isVertical,
33
41
  width,
34
42
  height,
35
- manual
43
+ auto,
44
+ manual,
36
45
  }) => {
37
46
  const tipPosition = useMemo(() => {
38
47
  const translate3d = isVertical
39
48
  ? {
40
- ...translateTip,
41
- y: translateTip.y + position + marginTop,
42
- }
49
+ ...translateTip,
50
+ y: translateTip.y + position + marginTop,
51
+ }
43
52
  : {
44
- ...translateTip,
45
- x: translateTip.x + position + marginLeft,
46
- };
53
+ ...translateTip,
54
+ x: translateTip.x + position + marginLeft,
55
+ };
47
56
  if (!isVertical && translate3d.x + tipWidth > width) {
48
57
  const newPositon = position + marginLeft - tipWidth - translateTip.x;
49
58
  translate3d.x = newPositon >= 0 ? newPositon : 0;
@@ -63,21 +72,24 @@ export default memo(
63
72
  tipHeight,
64
73
  translateTip,
65
74
  ]);
66
- return (
67
- manual?<div
68
- className='__easyv-tooltip'
75
+ return manual || auto ? (
76
+ <div
77
+ className="__easyv-tooltip"
69
78
  style={{
70
- pointerEvents: 'none',
79
+ pointerEvents: "none",
71
80
  transform: tipPosition,
72
81
  width: tipWidth,
73
82
  minHeight: tipHeight,
74
83
  padding: getMargin(margin),
75
- background: bgType=="image"?image
76
- ? '50% 50% / 100% 100% no-repeat url(' +
77
- window.appConfig.ASSETS_URL +
78
- image +
79
- ')'
80
- : "transparent":bgColor,
84
+ background:
85
+ bgType == "image"
86
+ ? image
87
+ ? "50% 50% / 100% 100% no-repeat url(" +
88
+ window.appConfig.ASSETS_URL +
89
+ image +
90
+ ")"
91
+ : "transparent"
92
+ : bgColor,
81
93
  ...getFontStyle(font),
82
94
  }}
83
95
  >
@@ -90,29 +102,37 @@ export default memo(
90
102
  ) : (
91
103
  <div
92
104
  style={{
93
- display: 'flex',
94
- flexDirection: 'column',
95
- justifyContent: 'space-between',
105
+ display: "flex",
106
+ flexDirection: "column",
107
+ justifyContent: "space-between",
96
108
  gap,
97
- height: '100%',
109
+ height: "100%",
98
110
  }}
99
111
  >
100
112
  <div
101
113
  style={{
102
114
  textAlign: align,
103
115
  transform: getTranslate3d(translateXAxis),
104
- background:background?`url(${window.appConfig.ASSETS_URL+background}) 0 0/100% 100%`:"transparent",
116
+ background: background
117
+ ? `url(${
118
+ window.appConfig.ASSETS_URL + background
119
+ }) 0 0/100% 100%`
120
+ : "transparent",
105
121
  ...font,
106
122
  }}
107
123
  >
108
124
  {x}
109
125
  </div>
110
- <div style={{
111
- display:"flex",
112
- flexFlow:"column nowrap",
113
- gap:dataGap,
114
- background:dataBg?`url(${window.appConfig.ASSETS_URL+dataBg}) 0 0/100% 100%`:"transparent"
115
- }}>
126
+ <div
127
+ style={{
128
+ display: "flex",
129
+ flexFlow: "column nowrap",
130
+ gap: dataGap,
131
+ background: dataBg
132
+ ? `url(${window.appConfig.ASSETS_URL + dataBg}) 0 0/100% 100%`
133
+ : "transparent",
134
+ }}
135
+ >
116
136
  {data.map(({ showY, s }, index) => {
117
137
  const { type, icon, displayName } = series.find(
118
138
  (series) => series.name == s
@@ -125,31 +145,31 @@ export default memo(
125
145
  } = suffix;
126
146
  const tmp = new Map();
127
147
  Object.values(content).forEach((item) => {
128
- tmp.set(item['suffix'].name, item['suffix'].suffix);
148
+ tmp.set(item["suffix"].name, item["suffix"].suffix);
129
149
  });
130
150
  const _icon = getIcon(type, icon);
131
151
  return (
132
152
  <dd
133
153
  style={{
134
- display: 'flex',
135
- justifyContent: 'space-between',
136
- lineHeight: lineHeight + 'px',
154
+ display: "flex",
155
+ justifyContent: "space-between",
156
+ lineHeight: lineHeight + "px",
137
157
  }}
138
158
  key={index}
139
159
  >
140
160
  <span
141
161
  style={{
142
- border: '1px solid red',
143
- display: 'flex',
144
- alignItems: 'center',
162
+ border: "1px solid red",
163
+ display: "flex",
164
+ alignItems: "center",
145
165
  gap: icon.iconGap,
146
166
  }}
147
167
  >
148
168
  <span
149
169
  style={{
150
170
  ..._icon,
151
- width: iconSize + 'px',
152
- height: iconSize + 'px',
171
+ width: iconSize + "px",
172
+ height: iconSize + "px",
153
173
  }}
154
174
  />
155
175
  <span style={getFontStyle(name)}>{displayName || s}</span>
@@ -160,7 +180,7 @@ export default memo(
160
180
  <span
161
181
  style={{
162
182
  ...getFontStyle(suffiixFont),
163
- display:"inline-block",
183
+ display: "inline-block",
164
184
  transform: getTranslate3d(suffixTranslate),
165
185
  }}
166
186
  >
@@ -172,10 +192,11 @@ export default memo(
172
192
  );
173
193
  })}
174
194
  </div>
175
-
176
195
  </div>
177
196
  )}
178
- </div>:""
197
+ </div>
198
+ ) : (
199
+ ""
179
200
  );
180
201
  }
181
202
  );
@@ -13,19 +13,13 @@ const initialState = {
13
13
  * @returns {Map} 返回经过改变后的x轴,主要是ticks和scaler的range发生了改变
14
14
  */
15
15
 
16
- export default (
17
- axis,
18
- config,
19
- isHover,
20
- controlInfo,
21
- active
22
- ) => {
16
+ export default (axis, config, isHover, controlInfo, active) => {
23
17
  const { show, interval, duration, hover } = config;
24
18
  const { isC, cPercent } = controlInfo;
25
19
  const time = duration + interval;
26
20
 
27
21
  const {
28
- tickCount:count,
22
+ tickCount: count,
29
23
  allTicks,
30
24
  scaler,
31
25
  start,
@@ -35,11 +29,11 @@ export default (
35
29
  lengthWithoutPaddingOuter,
36
30
  } = axis;
37
31
  const tickLength = ticks.length;
38
- const tickCount = isC?allTicks.length:count;
32
+ const tickCount = isC ? allTicks.length : count;
39
33
 
40
- const scale = isC?cPercent:1;
41
- const _start = start/scale;
42
- const _end = end/scale;
34
+ const scale = isC ? cPercent : 1;
35
+ const _start = start / scale;
36
+ const _end = end / scale;
43
37
 
44
38
  const [state, setState] = useState({
45
39
  scaler,
@@ -60,7 +54,13 @@ export default (
60
54
  }, [show, time, tickCount, tickLength]);
61
55
  useEffect(() => {
62
56
  let handler;
63
- if (!(hover && isHover) && show && time && tickLength > tickCount && active) {
57
+ if (
58
+ !(hover && isHover) &&
59
+ show &&
60
+ time &&
61
+ tickLength > tickCount &&
62
+ active
63
+ ) {
64
64
  handler = setInterval(() => {
65
65
  setStatus(({ currentIndex }) => {
66
66
  const tmp = +currentIndex + 1;
@@ -163,7 +163,7 @@ export default (
163
163
  return {
164
164
  ...axis,
165
165
  ...state,
166
- controlEnd: _end
166
+ controlEnd: _end,
167
167
  };
168
168
  };
169
169
 
@@ -23,7 +23,7 @@ type Props = {
23
23
  axisX: any;
24
24
  isHover: boolean;
25
25
  config: { auto?: boolean; interval?: number; manual?: boolean };
26
- active:boolean
26
+ active: boolean;
27
27
  };
28
28
 
29
29
  export default ({
@@ -35,7 +35,7 @@ export default ({
35
35
  axisX,
36
36
  isHover,
37
37
  config: { auto, interval = 0, manual } = {},
38
- active
38
+ active,
39
39
  }: Props) => {
40
40
  const [currentIndex, setCurrentIndex] = useState<number>(-1);
41
41
  const tickLength = axisX.allTicks.length;
@@ -77,6 +77,7 @@ export default ({
77
77
  );
78
78
  useEffect(() => {
79
79
  const on = auto && tickLength && !isHover && active;
80
+ if (!auto) setIndex(-1); //不开启自动轮播,提示框等隐藏
80
81
  // if (!!on) setCurrentIndex(0);
81
82
  const intervalHandler = on
82
83
  ? setInterval(() => {