@easyv/charts 1.8.10 → 1.8.12

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.
@@ -13,8 +13,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _d3v = require("d3v7");
15
15
  var _utils = require("../utils");
16
- var _excluded = ["pattern", "seriesIntervalWidth", "paddingInner", "highlight"],
17
- _excluded2 = ["bgAttr"];
16
+ var _excluded = ["show", "extent"],
17
+ _excluded2 = ["pattern", "seriesIntervalWidth", "paddingInner", "highlight"],
18
+ _excluded3 = ["bgAttr"];
18
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
20
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -103,8 +104,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
103
104
  _ref3$config$highligh = _ref3$config.highlight,
104
105
  showHighlight = _ref3$config$highligh.show,
105
106
  extent = _ref3$config$highligh.extent,
106
- highlightFill = _ref3$config$highligh.fill,
107
- other = (0, _objectWithoutProperties2["default"])(_ref3$config, _excluded),
107
+ highlightStyle = (0, _objectWithoutProperties2["default"])(_ref3$config$highligh, _excluded),
108
+ other = (0, _objectWithoutProperties2["default"])(_ref3$config, _excluded2),
108
109
  curXLabel = _ref3.curXLabel,
109
110
  selectStyle = _ref3.selectStyle,
110
111
  _ref3$bandLength = _ref3.bandLength,
@@ -136,6 +137,10 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
136
137
  });
137
138
  }
138
139
  }
140
+ var highlightConfig = other;
141
+ if (highlightStyle) {
142
+ highlightConfig = _objectSpread(_objectSpread({}, other), highlightStyle);
143
+ }
139
144
  var step = isControlChart ? controlStep : normalStep;
140
145
  var xScaler = isControlChart ? controlDragScaler : normalScaler;
141
146
  var _getSeriesInfo = (0, _utils.getSeriesInfo)({
@@ -176,7 +181,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
176
181
  y1 = yScaler(isVertical ? end : start);
177
182
  y2 = yScaler(isVertical ? start : end);
178
183
  }
179
- var _ref5 = x == curXLabel ? selectConfig : other,
184
+ var _ref5 = x == curXLabel ? selectConfig : flag ? highlightConfig : other,
180
185
  style = _ref5.style,
181
186
  fillType = _ref5.fillType,
182
187
  _ref5$fillMode = _ref5.fillMode,
@@ -227,7 +232,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
227
232
  seriesWidth: seriesWidth
228
233
  }),
229
234
  bgAttr = _getAttr.bgAttr,
230
- attr = (0, _objectWithoutProperties2["default"])(_getAttr, _excluded2);
235
+ attr = (0, _objectWithoutProperties2["default"])(_getAttr, _excluded3);
231
236
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
232
237
  key: i
233
238
  }, /*#__PURE__*/_react["default"].createElement("foreignObject", (0, _extends2["default"])({
@@ -328,7 +333,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
328
333
  opacity: fillType == "pattern" ? opacity : 1,
329
334
  background: fillType == "pattern" ? "".concat(isVertical ? y < 0 ? "100%" : "0%" : "50%", " ").concat(isVertical ? "50%" : y < 0 ? "0%" : "100%", " / ").concat(fillMode == "tile" ? size.width + "px " + size.height + "px" : "100% 100%", " repeat ") + "url(" +
330
335
  //@ts-ignore
331
- window.appConfig.ASSETS_URL + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill, y //是否小于0
336
+ window.appConfig.ASSETS_URL + url + ")" : (0, _utils.getBandBackground)(pattern, fill, y //是否小于0
332
337
  ),
333
338
  borderRadius: style == "square" ? "0 0 0 0" : getBorderRadius({
334
339
  isVertical: isVertical,
@@ -65,7 +65,6 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
65
65
  brush = _ref$config.brush,
66
66
  _ref$config$control = _ref$config.control,
67
67
  control = _ref$config$control === void 0 ? null : _ref$config$control,
68
- isTransverse = _ref.isTransverse,
69
68
  active = _ref.active,
70
69
  style = _ref.style,
71
70
  originData = _ref.originData,
@@ -593,8 +592,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
593
592
  indicatorWidth: indicatorWidth,
594
593
  triggerClick: onInteraction,
595
594
  setCtlTip: setCtlTip,
596
- isXRepeat: isXRepeat,
597
- isTransverse: isTransverse
595
+ isXRepeat: isXRepeat
598
596
  }));
599
597
  }), series.map(function (_ref3, index) {
600
598
  var Component = _ref3.Component,
@@ -6,18 +6,43 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _react = require("react");
13
+ var _d3v = require("d3v7");
13
14
  var _utils = require("../utils");
14
15
  var _context = require("../context");
15
- var _excluded = ["seriesIntervalWidth", "paddingInner", "showType"];
16
- /**
16
+ var _excluded = ["show", "extent"],
17
+ _excluded2 = ["seriesIntervalWidth", "paddingInner", "showType", "highlight"];
18
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
17
20
  * 轴类图表标签
18
21
  */
19
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
+ var getHighlightData = function getHighlightData(data, extent) {
23
+ switch (extent) {
24
+ case "min":
25
+ var minData = (0, _d3v.min)(data, function (d) {
26
+ return d.data.y;
27
+ });
28
+ return data.map(function (item) {
29
+ return _objectSpread(_objectSpread({}, item), {}, {
30
+ flag: minData == item.data.y ? "min" : ""
31
+ });
32
+ });
33
+ case "max":
34
+ var maxData = (0, _d3v.max)(data, function (d) {
35
+ return d.data.y;
36
+ });
37
+ return data.map(function (item) {
38
+ return _objectSpread(_objectSpread({}, item), {}, {
39
+ flag: maxData == item.data.y ? "max" : ""
40
+ });
41
+ });
42
+ default:
43
+ return data;
44
+ }
45
+ };
21
46
  var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref) {
22
47
  var _ref$config = _ref.config,
23
48
  _ref$config$seriesInt = _ref$config.seriesIntervalWidth,
@@ -26,7 +51,11 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
26
51
  paddingOuter = _ref$config$paddingIn === void 0 ? 0 : _ref$config$paddingIn,
27
52
  _ref$config$showType = _ref$config.showType,
28
53
  seriesType = _ref$config$showType === void 0 ? 'bar' : _ref$config$showType,
29
- other = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
54
+ _ref$config$highlight = _ref$config.highlight,
55
+ showHighlight = _ref$config$highlight.show,
56
+ extent = _ref$config$highlight.extent,
57
+ highlightStyle = (0, _objectWithoutProperties2["default"])(_ref$config$highlight, _excluded),
58
+ other = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded2),
30
59
  config = _ref.config,
31
60
  curXLabel = _ref.curXLabel,
32
61
  selectStyle = _ref.selectStyle,
@@ -61,6 +90,12 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
61
90
  }
62
91
  }
63
92
  }
93
+ var highlightConfig = other;
94
+ if (highlightStyle) {
95
+ highlightConfig = _objectSpread(_objectSpread({}, other), {}, {
96
+ label: highlightStyle.numlabel
97
+ });
98
+ }
64
99
  var lineType = config.hasOwnProperty("line"); // 堆叠处理
65
100
 
66
101
  if (!data.length) return null;
@@ -76,11 +111,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
76
111
  seriesStep = _getSeriesInfo.seriesStep,
77
112
  seriesWidth = _getSeriesInfo.seriesWidth,
78
113
  seriesStart = _getSeriesInfo.seriesStart;
114
+ var _data = showHighlight ? getHighlightData(data, extent) : data;
79
115
  var isVertical = direction === "vertical";
80
116
  return /*#__PURE__*/React.createElement("g", {
81
117
  className: "__easyv-label"
82
- }, data.map(function (_ref2, i) {
83
- var index = _ref2.index,
118
+ }, _data.map(function (_ref2, i) {
119
+ var flag = _ref2.flag,
120
+ index = _ref2.index,
84
121
  _ref2$bound = (0, _slicedToArray2["default"])(_ref2.bound, 2),
85
122
  start = _ref2$bound[0],
86
123
  end = _ref2$bound[1],
@@ -91,7 +128,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
91
128
  showY = _ref2$data.showY,
92
129
  s = _ref2$data.s;
93
130
  var y1, y2;
94
- var _ref3 = x == curXLabel ? selectConfig : other,
131
+ var _ref3 = x == curXLabel ? selectConfig : flag ? highlightConfig : other,
95
132
  icon = _ref3.icon,
96
133
  label = _ref3.label;
97
134
  var showIcon = icon && icon.show;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.8.10",
3
+ "version": "1.8.12",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -92,7 +92,7 @@ export default memo(
92
92
  pattern = {},
93
93
  seriesIntervalWidth: paddingInner = 0,
94
94
  paddingInner: paddingOuter = 0,
95
- highlight: { show: showHighlight, extent, fill: highlightFill },
95
+ highlight: { show: showHighlight, extent, ...highlightStyle },
96
96
  ...other
97
97
  },
98
98
  curXLabel,
@@ -111,6 +111,10 @@ export default memo(
111
111
  selectConfig = { ...barStyle, headDecorate };
112
112
  }
113
113
  }
114
+ let highlightConfig = other;
115
+ if(highlightStyle){
116
+ highlightConfig = { ...other, ...highlightStyle };
117
+ }
114
118
  const step = isControlChart?controlStep:normalStep;
115
119
  const xScaler = isControlChart?controlDragScaler:normalScaler;
116
120
  const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
@@ -159,7 +163,7 @@ export default memo(
159
163
  border,
160
164
  opacity,
161
165
  headDecorate
162
- } = x==curXLabel?selectConfig:other;
166
+ } = x==curXLabel?selectConfig:flag?highlightConfig:other;
163
167
  const { borderColor:{
164
168
  type="pure", pure="transparent", linear
165
169
  }, borderWidth=0 } = border || {};
@@ -293,7 +297,7 @@ export default memo(
293
297
  ")"
294
298
  : getBandBackground(
295
299
  pattern,
296
- extent === flag ? highlightFill : fill,
300
+ fill,
297
301
  y//是否小于0
298
302
  ),
299
303
  borderRadius:
@@ -59,7 +59,6 @@ const Chart = memo(
59
59
  brush,
60
60
  control = null,
61
61
  },
62
- isTransverse,
63
62
  active,
64
63
  style,
65
64
  originData,
@@ -568,7 +567,6 @@ const Chart = memo(
568
567
  triggerClick={onInteraction}
569
568
  setCtlTip={setCtlTip}
570
569
  isXRepeat={isXRepeat}
571
- isTransverse={isTransverse}
572
570
  />
573
571
  )
574
572
  );
@@ -2,15 +2,36 @@
2
2
  * 轴类图表标签
3
3
  */
4
4
  import { memo, useContext } from "react";
5
+ import { min, max } from "d3v7";
5
6
  import { getTranslate2d, getSeriesInfo, getFontStyle, formatFont } from "../utils";
6
7
  import { chartContext } from "../context";
7
8
 
9
+ const getHighlightData = (data, extent) => {
10
+ switch (extent) {
11
+ case "min":
12
+ const minData = min(data, (d) => d.data.y);
13
+ return data.map((item) => ({
14
+ ...item,
15
+ flag: minData == item.data.y ? "min" : "",
16
+ }));
17
+ case "max":
18
+ const maxData = max(data, (d) => d.data.y);
19
+ return data.map((item) => ({
20
+ ...item,
21
+ flag: maxData == item.data.y ? "max" : "",
22
+ }));
23
+ default:
24
+ return data;
25
+ }
26
+ };
27
+
8
28
  export default memo(
9
29
  ({
10
30
  config: {
11
31
  seriesIntervalWidth: paddingInner = 0,
12
32
  paddingInner: paddingOuter = 0,
13
33
  showType:seriesType = 'bar',
34
+ highlight: { show: showHighlight, extent, ...highlightStyle },
14
35
  ...other
15
36
  },
16
37
  config,
@@ -33,6 +54,10 @@ export default memo(
33
54
  }
34
55
  }
35
56
  }
57
+ let highlightConfig = other;
58
+ if(highlightStyle){
59
+ highlightConfig = { ...other, label:highlightStyle.numlabel };
60
+ }
36
61
  const lineType = config.hasOwnProperty("line"); // 堆叠处理
37
62
 
38
63
  if (!data.length) return null;
@@ -44,17 +69,18 @@ export default memo(
44
69
  paddingInner,
45
70
  paddingOuter,
46
71
  });
72
+ const _data = showHighlight ? getHighlightData(data, extent) : data;
47
73
  const isVertical = direction === "vertical";
48
74
 
49
75
  return (
50
76
  <g className="__easyv-label">
51
- {data.map(
77
+ {_data.map(
52
78
  (
53
- { index, bound: [start, end], data, data: { x, y, showY, s } },
79
+ { flag, index, bound: [start, end], data, data: { x, y, showY, s } },
54
80
  i
55
81
  ) => {
56
82
  let y1, y2;
57
- const { icon, label } = x==curXLabel?selectConfig:other;
83
+ const { icon, label } = x==curXLabel?selectConfig:flag?highlightConfig:other;
58
84
  const showIcon = icon && icon.show;
59
85
  const showLabel = label && label.show;
60
86
  const { position:_position="outerStart", reverse=true } = label || {};