@easyv/charts 1.8.8 → 1.8.10

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.
@@ -295,8 +295,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
295
295
  window.appConfig.ASSETS_URL + headUrl, ") 0 0/100% 100%"),
296
296
  width: headWidth,
297
297
  height: headHeight,
298
- left: isVertical ? "100%" : "50%",
299
- top: isVertical ? "50%" : "0",
298
+ left: isVertical ? y < 0 ? "0%" : "100%" : "50%",
299
+ top: isVertical ? "50%" : y < 0 ? "100%" : "0%",
300
300
  zIndex: 1,
301
301
  transform: "translate(calc(-50% + ".concat(headTranslate.x, "px), calc(-50% + ").concat(headTranslate.y, "px))")
302
302
  }
@@ -328,7 +328,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
328
328
  opacity: fillType == "pattern" ? opacity : 1,
329
329
  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
330
  //@ts-ignore
331
- window.appConfig.ASSETS_URL + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill),
331
+ window.appConfig.ASSETS_URL + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill, y //是否小于0
332
+ ),
332
333
  borderRadius: style == "square" ? "0 0 0 0" : getBorderRadius({
333
334
  isVertical: isVertical,
334
335
  positive: y > 0,
@@ -65,6 +65,7 @@ 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,
68
69
  active = _ref.active,
69
70
  style = _ref.style,
70
71
  originData = _ref.originData,
@@ -592,7 +593,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
592
593
  indicatorWidth: indicatorWidth,
593
594
  triggerClick: onInteraction,
594
595
  setCtlTip: setCtlTip,
595
- isXRepeat: isXRepeat
596
+ isXRepeat: isXRepeat,
597
+ isTransverse: isTransverse
596
598
  }));
597
599
  }), series.map(function (_ref3, index) {
598
600
  var Component = _ref3.Component,
@@ -148,6 +148,24 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
148
148
  return parseFloat(getCanvasTextWidth(percentStr, percentFont.letterSpacing || 0, "".concat(percentFont.fontSize || 12, "px ").concat(percentFont.fontFamily || 'Arial')));
149
149
  })));
150
150
  var nameMaxWidth = ((_config$name = config.name) === null || _config$name === void 0 ? void 0 : _config$name.maxWidth) || 80;
151
+ var stylePieOrAxis = formatter ? _objectSpread(_objectSpread({
152
+ display: 'flex',
153
+ alignContent: alignment.split(" ")[0] == "center" && (alignment.split(" ")[1] == "left" || alignment.split(" ")[1] == "right") ? alignment.split(" ")[1] == "left" ? "flex-start" : "flex-end" : alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
154
+ flexDirection: "column",
155
+ position: 'absolute'
156
+ }, getPosition(position, _alignment, x, y)), {}, {
157
+ height: loop.show ? height : 'auto',
158
+ overflowY: loop.show ? 'scroll' : 'auto'
159
+ }) : _objectSpread(_objectSpread({
160
+ display: 'flex',
161
+ flexWrap: "wrap",
162
+ alignContent: alignment.split(" ")[0] == "center" && (alignment.split(" ")[1] == "left" || alignment.split(" ")[1] == "right") ? alignment.split(" ")[1] == "left" ? "flex-start" : "flex-end" : alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
163
+ flexDirection: "column",
164
+ position: 'absolute'
165
+ }, getPosition(position, _alignment, x, y)), {}, {
166
+ height: loop.show ? height : 'auto',
167
+ overflowY: loop.show ? 'scroll' : 'auto'
168
+ });
151
169
  return LegendType == "FixedWidth" ? /*#__PURE__*/_react["default"].createElement("div", {
152
170
  className: "__easyv-legend-wrapper",
153
171
  style: _objectSpread(_objectSpread({
@@ -201,16 +219,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
201
219
  })));
202
220
  }))) : /*#__PURE__*/_react["default"].createElement("div", {
203
221
  className: "__easyv-legend-wrapper",
204
- style: _objectSpread(_objectSpread({
205
- display: 'flex',
206
- flexWrap: "wrap",
207
- alignContent: alignment.split(" ")[0] == "center" && (alignment.split(" ")[1] == "left" || alignment.split(" ")[1] == "right") ? alignment.split(" ")[1] == "left" ? "flex-start" : "flex-end" : alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
208
- flexDirection: "column",
209
- position: 'absolute'
210
- }, getPosition(position, _alignment, x, y)), {}, {
211
- height: loop.show ? height : 'auto',
212
- overflowY: loop.show ? 'scroll' : 'auto'
213
- }),
222
+ style: stylePieOrAxis,
214
223
  ref: ref_container
215
224
  }, (0, _toConsumableArray2["default"])(Array(Math.ceil(series.length / gridTemplateColumns))).map(function (_, indexs) {
216
225
  return /*#__PURE__*/_react["default"].createElement("ul", {
@@ -531,8 +531,38 @@ var getCurrentStack = exports.getCurrentStack = function getCurrentStack(stack,
531
531
  return _type == stack.type && _stack == stack.stack && _yOrZ == stack.yOrZ && _s.includes(stack.name);
532
532
  });
533
533
  };
534
- var getBandBackground = exports.getBandBackground = function getBandBackground(pattern, fill) {
535
- if (!(pattern && pattern.path)) return (0, _utils.getColor)(fill);
534
+ var reverseGradientStops = function reverseGradientStops(gradient) {
535
+ var _gradient$linear;
536
+ if (gradient.type !== 'linear' || !((_gradient$linear = gradient.linear) !== null && _gradient$linear !== void 0 && _gradient$linear.stops)) {
537
+ return gradient;
538
+ }
539
+ var stops = gradient.linear.stops;
540
+ //先按 offset 排序(升序),确保输入是规范的
541
+ var sortedStops = (0, _toConsumableArray2["default"])(stops).sort(function (a, b) {
542
+ return a.offset - b.offset;
543
+ });
544
+
545
+ // 反转每个 stop 的 offset: newOffset = 100 - oldOffset
546
+ // 颜色保持不变,只是位置镜像翻转
547
+ var reversedStops = sortedStops.map(function (stop) {
548
+ return _objectSpread(_objectSpread({}, stop), {}, {
549
+ offset: 100 - stop.offset
550
+ });
551
+ });
552
+ //再按新的 offset 升序排序,确保输出结构正确
553
+ var finalStops = reversedStops.sort(function (a, b) {
554
+ return a.offset - b.offset;
555
+ });
556
+ return _objectSpread(_objectSpread({}, gradient), {}, {
557
+ linear: _objectSpread(_objectSpread({}, gradient.linear), {}, {
558
+ stops: finalStops
559
+ })
560
+ });
561
+ };
562
+ var getBandBackground = exports.getBandBackground = function getBandBackground(pattern, fill, y) {
563
+ if (!(pattern && pattern.path)) {
564
+ return (0, _utils.getColor)(y < 0 ? reverseGradientStops(fill) : fill); //小于0颜色翻转
565
+ }
536
566
  try {
537
567
  var _pattern$backgroundSi = pattern.backgroundSize,
538
568
  backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.8.8",
3
+ "version": "1.8.10",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -254,8 +254,8 @@ export default memo(
254
254
  }) 0 0/100% 100%`,
255
255
  width: headWidth,
256
256
  height: headHeight,
257
- left: isVertical ? "100%" : "50%",
258
- top: isVertical ? "50%" : "0",
257
+ left: isVertical ? (y<0?"0%":"100%") : "50%",
258
+ top: isVertical ? "50%" :(y<0?"100%":"0%"),
259
259
  zIndex: 1,
260
260
  transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
261
261
  }}
@@ -293,7 +293,8 @@ export default memo(
293
293
  ")"
294
294
  : getBandBackground(
295
295
  pattern,
296
- extent === flag ? highlightFill : fill
296
+ extent === flag ? highlightFill : fill,
297
+ y//是否小于0
297
298
  ),
298
299
  borderRadius:
299
300
  style == "square"
@@ -59,6 +59,7 @@ const Chart = memo(
59
59
  brush,
60
60
  control = null,
61
61
  },
62
+ isTransverse,
62
63
  active,
63
64
  style,
64
65
  originData,
@@ -567,6 +568,7 @@ const Chart = memo(
567
568
  triggerClick={onInteraction}
568
569
  setCtlTip={setCtlTip}
569
570
  isXRepeat={isXRepeat}
571
+ isTransverse={isTransverse}
570
572
  />
571
573
  )
572
574
  );
@@ -123,6 +123,24 @@ export default memo(
123
123
  );
124
124
  const nameMaxWidth = config.name?.maxWidth || 80;
125
125
 
126
+ const stylePieOrAxis=formatter?{
127
+ display:'flex',
128
+ alignContent:alignment.split(" ")[0]=="center"&&(alignment.split(" ")[1]=="left"||alignment.split(" ")[1]=="right")?alignment.split(" ")[1]=="left"?"flex-start":"flex-end":alignment.split(" ")[0]=="left"?"flex-start":alignment.split(" ")[0]=="center"?"center":"flex-end",
129
+ flexDirection:"column",
130
+ position: 'absolute',
131
+ ...getPosition(position, _alignment, x, y),
132
+ height: loop.show ? height : 'auto',
133
+ overflowY: loop.show ? 'scroll' : 'auto'
134
+ }:{
135
+ display:'flex',
136
+ flexWrap:"wrap",
137
+ alignContent:alignment.split(" ")[0]=="center"&&(alignment.split(" ")[1]=="left"||alignment.split(" ")[1]=="right")?alignment.split(" ")[1]=="left"?"flex-start":"flex-end":alignment.split(" ")[0]=="left"?"flex-start":alignment.split(" ")[0]=="center"?"center":"flex-end",
138
+ flexDirection: "column",
139
+ position: 'absolute',
140
+ ...getPosition(position, _alignment, x, y),
141
+ height: loop.show ? height : 'auto',
142
+ overflowY: loop.show ? 'scroll' : 'auto'
143
+ }
126
144
  return (
127
145
  LegendType=="FixedWidth"?
128
146
  <div
@@ -180,16 +198,7 @@ export default memo(
180
198
  </ul>
181
199
  </div>:<div
182
200
  className='__easyv-legend-wrapper'
183
- style={{
184
- display:'flex',
185
- flexWrap:"wrap",
186
- alignContent:alignment.split(" ")[0]=="center"&&(alignment.split(" ")[1]=="left"||alignment.split(" ")[1]=="right")?alignment.split(" ")[1]=="left"?"flex-start":"flex-end":alignment.split(" ")[0]=="left"?"flex-start":alignment.split(" ")[0]=="center"?"center":"flex-end",
187
- flexDirection: "column",
188
- position: 'absolute',
189
- ...getPosition(position, _alignment, x, y),
190
- height: loop.show ? height : 'auto',
191
- overflowY: loop.show ? 'scroll' : 'auto'
192
- }}
201
+ style={stylePieOrAxis}
193
202
  ref={ref_container}
194
203
  >
195
204
 
@@ -513,9 +513,35 @@ const getCurrentStack = (stack, stackMap) =>
513
513
  _yOrZ == stack.yOrZ &&
514
514
  _s.includes(stack.name)
515
515
  );
516
-
517
- const getBandBackground = (pattern, fill) => {
518
- if (!(pattern && pattern.path)) return getColor(fill);
516
+ const reverseGradientStops=(gradient)=>{
517
+ if (gradient.type !== 'linear' || !gradient.linear?.stops) {
518
+ return gradient;
519
+ }
520
+ const stops = gradient.linear.stops;
521
+ //先按 offset 排序(升序),确保输入是规范的
522
+ const sortedStops = [...stops].sort((a, b) => a.offset - b.offset);
523
+
524
+ // 反转每个 stop 的 offset: newOffset = 100 - oldOffset
525
+ // 颜色保持不变,只是位置镜像翻转
526
+ const reversedStops = sortedStops.map(stop => ({
527
+ ...stop,
528
+ offset: 100 - stop.offset
529
+ }));
530
+ //再按新的 offset 升序排序,确保输出结构正确
531
+ const finalStops = reversedStops.sort((a, b) => a.offset - b.offset);
532
+
533
+ return {
534
+ ...gradient,
535
+ linear: {
536
+ ...gradient.linear,
537
+ stops: finalStops
538
+ }
539
+ };
540
+ }
541
+ const getBandBackground = (pattern, fill,y) => {
542
+ if (!(pattern && pattern.path)){
543
+ return getColor(y<0?reverseGradientStops(fill):fill);//小于0颜色翻转
544
+ }
519
545
  try{
520
546
  const { backgroundSize = '100% 100%', ..._pattern } = pattern;
521
547
  return (