@publishfx/publish-chart 2.1.29 → 2.1.31

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.
@@ -294,21 +294,24 @@ function fillMissingIndicator(baseItems, safeTitle, isCompare, isGroup = false)
294
294
  name: indicatorId,
295
295
  value: '-',
296
296
  x: safeTitle,
297
- color: color
297
+ color: color,
298
+ dataType: 'manual'
298
299
  });
299
300
  if (!baseItems.find((item)=>item.indicatorId === indicatorId && item.name === indicatorId + '_compare')) baseItems.push({
300
301
  indicatorId: indicatorId,
301
302
  name: indicatorId + '_compare',
302
303
  tipType: 'compareline',
303
304
  value: '-',
304
- x: safeTitle
305
+ x: safeTitle,
306
+ dataType: 'manual'
305
307
  });
306
308
  if (!baseItems.find((item)=>item.indicatorId === indicatorId && item.name === indicatorId + '_change')) baseItems.push({
307
309
  indicatorId: indicatorId,
308
310
  name: indicatorId + '_change',
309
311
  isChange: true,
310
312
  value: '-',
311
- x: safeTitle
313
+ x: safeTitle,
314
+ dataType: 'manual'
312
315
  });
313
316
  }
314
317
  });
@@ -34,7 +34,7 @@ function renderG2BarChart(container, options) {
34
34
  key: 'main'
35
35
  });
36
36
  if (!CLOSE_HIGHLIGHT_DEBUG) applyHighlightDate(view, x, data, highlightDate, isHighlight);
37
- const minLabelWidth = data.some((d)=>d.groupName.length < 3) ? 30 : 90;
37
+ const minLabelWidth = data.some((d)=>d.groupName.length < 3) ? 30 : isHorizontal ? 30 : 90;
38
38
  const interval = view.interval().encode('x', x).encode('y', y).encode('color', 'groupType').transform({
39
39
  type: 'dodgeX',
40
40
  padding: isHorizontal ? 0.2 : 0
@@ -9,6 +9,7 @@ type Item = {
9
9
  percent?: string | number;
10
10
  hidden?: boolean;
11
11
  isCombine?: boolean;
12
+ dataType?: string;
12
13
  };
13
14
  interface Props {
14
15
  isGroupBar?: boolean;
@@ -3,8 +3,9 @@ import { memo } from "react";
3
3
  import { CompareChange } from "@publishfx/publish-components";
4
4
  import { getIndicatorCompareName } from "../../../utils/indicatorHelpers.js";
5
5
  const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap, formatter, auxiliaryLineData })=>{
6
- let auxiIndicatorId = '';
7
- let combineIndicatorId = '';
6
+ let auxiIndicatorId = "";
7
+ let combineIndicatorId = "";
8
+ let changeValue = null;
8
9
  const uniqueColors = [];
9
10
  return /*#__PURE__*/ jsxs("div", {
10
11
  style: {
@@ -14,7 +15,7 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
14
15
  /*#__PURE__*/ jsx("div", {
15
16
  children: title
16
17
  }),
17
- items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent, hidden, isCombine }, index)=>{
18
+ items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent, hidden, isCombine, dataType }, index)=>{
18
19
  if (isCombine) combineIndicatorId = indicatorId ?? "";
19
20
  let isFirst = false;
20
21
  if (0 === index) auxiIndicatorId = indicatorId ?? "";
@@ -22,6 +23,9 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
22
23
  isFirst = true;
23
24
  uniqueColors.push(color);
24
25
  }
26
+ if (null !== changeValue && combineIndicatorId === auxiIndicatorId && "manual" === dataType && isChange) value = changeValue ?? '';
27
+ if (isChange) changeValue = value ?? '';
28
+ if (combineIndicatorId === auxiIndicatorId && "-" === value && "manual" === dataType && !isChange) return null;
25
29
  return !hidden && /*#__PURE__*/ jsxs("div", {
26
30
  style: {
27
31
  display: "flex",
@@ -42,7 +46,7 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
42
46
  borderRadius: "50%"
43
47
  }
44
48
  }),
45
- isChange ? "相比变化" : compareTime ? `${getIndicatorCompareName(safeIndicatorMap, indicatorId ?? '')}(${compareTime})` : isGroupBar ? name : `${getIndicatorCompareName(safeIndicatorMap, indicatorId ?? '')}`,
49
+ isChange ? "相比变化" : compareTime ? `${getIndicatorCompareName(safeIndicatorMap, indicatorId ?? "")}(${compareTime})` : isGroupBar ? name : `${getIndicatorCompareName(safeIndicatorMap, indicatorId ?? "")}`,
46
50
  ":"
47
51
  ]
48
52
  }),
@@ -81,7 +85,7 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
81
85
  ]
82
86
  }),
83
87
  /*#__PURE__*/ jsx("div", {
84
- children: 'right' === axis ? formatter.formatIndicator(value, safeIndicatorMap[combineIndicatorId ?? ''] ?? {}) : formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ''] ?? {})
88
+ children: "right" === axis ? formatter.formatIndicator(value, safeIndicatorMap[combineIndicatorId ?? ""] ?? {}) : formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ""] ?? {})
85
89
  })
86
90
  ]
87
91
  }, index))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@publishfx/publish-chart",
3
- "version": "2.1.29",
3
+ "version": "2.1.31",
4
4
  "description": "A React chart component library for the Publish platform, including BarChart, LineChart, BarLineChart and other visualization components",
5
5
  "type": "module",
6
6
  "keywords": [