@publishfx/publish-chart 2.1.14 → 2.1.15

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.
@@ -115,6 +115,7 @@ class DataAdapter {
115
115
  static transformForBarLine(data, config) {
116
116
  const ds = new lib();
117
117
  const dv = ds.createView().source(data);
118
+ const allKeys = new Set(dv.rows.map((item)=>item[config.x || 'x']));
118
119
  const tdv = ds.createView().source(data);
119
120
  const combinedv = ds.createView().source(data);
120
121
  if (config.y && config.x) {
@@ -144,14 +145,6 @@ class DataAdapter {
144
145
  return row.isCombine;
145
146
  }
146
147
  });
147
- console.log('tdv:', tdv.rows);
148
- tdv.transform({
149
- type: 'filter',
150
- callback (row) {
151
- return !row[config.y] || '-' !== row[config.y];
152
- }
153
- });
154
- console.log('tdv:', tdv.rows);
155
148
  if (config.isDescend) tdv.transform({
156
149
  type: 'sort',
157
150
  callback (a, b) {
@@ -159,20 +152,19 @@ class DataAdapter {
159
152
  }
160
153
  });
161
154
  const xKey = config.x ?? 'x';
162
- const sortData = tdv.rows.map((item)=>item[xKey]);
163
155
  combinedv.rows.sort((a, b)=>{
164
- const aIndex = sortData.indexOf(a[xKey]);
165
- const bIndex = sortData.indexOf(b[xKey]);
156
+ const aIndex = allKeys.has(a[xKey]) ? Array.from(allKeys).indexOf(a[xKey]) : -1;
157
+ const bIndex = allKeys.has(b[xKey]) ? Array.from(allKeys).indexOf(b[xKey]) : -1;
166
158
  if (-1 === aIndex) return 1;
167
159
  if (-1 === bIndex) return -1;
168
160
  return aIndex - bIndex;
169
161
  });
170
162
  }
171
- console.log('leftData:', tdv.rows, 'rightData:', combinedv.rows);
172
163
  return {
173
164
  transformedData: dv.rows,
174
165
  leftData: tdv.rows,
175
- rightData: combinedv.rows
166
+ rightData: combinedv.rows,
167
+ xKey: Array.from(allKeys)
176
168
  };
177
169
  }
178
170
  static transformForGroupCompare(data, _config) {
@@ -154,7 +154,6 @@ const BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartCli
154
154
  },
155
155
  appendPadding: padding,
156
156
  onPointMouseover: (e)=>{
157
- console.log("onPointMouseover", nodeSetting.showType, typeof nodeSetting.showType);
158
157
  if (1 === nodeSetting.showType) try {
159
158
  if (e?.data) {
160
159
  setPointP({
@@ -168,7 +167,6 @@ const BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartCli
168
167
  });
169
168
  }
170
169
  } catch (error) {
171
- console.warn("Failed to handle point mouseover:", error);
172
170
  setPointP({
173
171
  x: 0,
174
172
  y: 0
@@ -448,9 +448,7 @@ const BarLineCompareWeekend = ({ height = 310, data, x = '', y = '', z = '', ind
448
448
  const mapValue = legendMapRef.current[key];
449
449
  return false !== mapValue;
450
450
  });
451
- } catch (error) {
452
- console.warn('Failed to apply filter:', error);
453
- }
451
+ } catch (error) {}
454
452
  };
455
453
  if (chart && chart.geometries) {
456
454
  const mainChartGeometries = chart.geometries || [];
@@ -26,8 +26,6 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
26
26
  const BAR_PADDING_RIGHT = mergedConfig.layout.barPaddingRight || 10;
27
27
  const HOR_BAR_PADDING_RIGHT = mergedConfig.layout.horBarPaddingRight || 50;
28
28
  const { isDescend = false, isLegend = true, isHorizontal = false, isDataTag = false, isHighlight = true } = config || {};
29
- console.log('isLegend', isLegend);
30
- console.log('config', config);
31
29
  const [chartInsWidth, setChartInsWidth] = useState(0);
32
30
  const [mainBarSize, setMainBarSize] = useState(void 0);
33
31
  const [backgroundHeight, setBackgroundHeight] = useState(1000);
@@ -16,7 +16,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
16
16
  showType: 0,
17
17
  type: []
18
18
  }, auxiliaryLineData, highlightDate = [], indicators = [], timeRange })=>{
19
- console.log("props data:", data, nodeSetting, "x:", x, "y:", y, "legend:", legend, "indicators:", indicators, timeRange);
20
19
  const { formatter, dataTransform, config: contextConfig } = useChartContext();
21
20
  const tooltipContainerRef = useG2TooltipContainer();
22
21
  const themeColors = contextConfig?.theme?.colors || [];
@@ -27,7 +26,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
27
26
  const chartConfig = config || {};
28
27
  const { isDataTag = false, isDescend = false, isHorizontal = false, isLegend = true, isHighlight = true } = chartConfig;
29
28
  const transformedData = useMemo(()=>{
30
- console.log("transformedData: bar ---", legend, data, indicators);
31
29
  if (!legend) {
32
30
  let result = transformIndicatorList(indicators, data);
33
31
  data = result[y] || [];
@@ -49,7 +47,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
49
47
  dataTransform,
50
48
  contextConfig.nodeMap
51
49
  ]);
52
- console.log("transformedData: bar final", transformedData);
53
50
  const nodeData = transformedData.filter((item)=>item.nodeInfos?.info?.length > 0 || item.nodeInfos?.infosCompare?.length > 0);
54
51
  const maxY = useMemo(()=>{
55
52
  const values = transformedData.filter((item)=>"-" !== item[safeY] && void 0 !== item[safeY] && null !== item[safeY]).map((item)=>Number(item[safeY]) || 0);
@@ -71,6 +68,7 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
71
68
  const [legendItems, setLegendItems] = useState([]);
72
69
  const containerRef = useRef(null);
73
70
  const chartRef = useRef(null);
71
+ const currentTooltipTitleRef = useRef(null);
74
72
  const [viewWidth, setViewWidth] = useState(0);
75
73
  const [viewOffset, setViewOffset] = useState(0);
76
74
  useEffect(()=>{
@@ -131,6 +129,7 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
131
129
  } : void 0,
132
130
  height: height - canvasMarginBottom,
133
131
  tooltipRender: (title, items)=>{
132
+ currentTooltipTitleRef.current = title;
134
133
  const container = tooltipContainerRef.current;
135
134
  if (!container) return null;
136
135
  let safeItems = items.map((i)=>({
@@ -150,27 +149,24 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
150
149
  },
151
150
  auxiliaryLineData: auxiliaryLineData ?? [],
152
151
  onNodeListChange: (nodes)=>{
153
- console.log("g2bar node list:", nodes);
154
152
  setXYList(nodes);
155
153
  },
156
154
  timeRange,
157
155
  onChartRender: (chartProps)=>{
158
- console.log("chartProps:", chartProps);
159
156
  setViewWidth(chartProps.layout.innerWidth);
160
157
  setViewOffset(chartProps.layout.paddingLeft + chartProps.layout.marginLeft);
161
158
  }
162
159
  });
163
160
  chartRef.current = chart;
164
- if (onChartClick) chart.on("element:click", (e)=>{
165
- console.log('e:', e);
166
- const datum = e.data?.data;
167
- if (datum) onChartClick({
168
- title: datum[x]
161
+ if (onChartClick) chart.on("plot:click", (_e)=>{
162
+ const tooltipTitle = currentTooltipTitleRef.current;
163
+ if (null != tooltipTitle) onChartClick({
164
+ title: tooltipTitle
169
165
  });
170
166
  });
171
167
  return ()=>{
172
168
  if (chartRef.current) {
173
- chartRef.current.off("element:click");
169
+ chartRef.current.off("plot:click");
174
170
  chartRef.current.destroy();
175
171
  chartRef.current = null;
176
172
  }
@@ -195,7 +191,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
195
191
  auxiliaryLineData,
196
192
  onChartClick
197
193
  ]);
198
- console.log("xyList:", xyList);
199
194
  return /*#__PURE__*/ jsxs("div", {
200
195
  style: {
201
196
  width: "100%",
@@ -2,7 +2,6 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Tooltip } from "@arco-design/web-react";
4
4
  const G2BarLegend = ({ items, activeIds, onChange, pageSize: pageSizeProp, maxLabelChars = 8, style })=>{
5
- console.log("G2BarLegend items:", items, activeIds);
6
5
  const [page, setPage] = useState(1);
7
6
  const [autoPageSize, setAutoPageSize] = useState(pageSizeProp || items.length || 1);
8
7
  const containerRef = useRef(null);
@@ -54,9 +54,9 @@ const transformDataToGroupBarLineFormat = (data, x = "groupName", y = "", indica
54
54
  }).flat();
55
55
  };
56
56
  const lineColors = [
57
- '#FA8C16',
58
- '#7CB305',
59
- '#5CDBD3'
57
+ "#FA8C16",
58
+ "#7CB305",
59
+ "#5CDBD3"
60
60
  ];
61
61
  const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap, onChartClick, legend = "", config, nodeSetting = {
62
62
  showType: 0,
@@ -68,7 +68,6 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
68
68
  const [isOldData, setIsOldData] = useState(false);
69
69
  const currentTooltipTitleRef = useRef(null);
70
70
  isGroupRef.current = isGroup;
71
- console.log("G2CombineChart props:", data, x, y, z, indicators, legend, config, nodeSetting);
72
71
  const themeColors = contextConfig?.theme?.colors || [];
73
72
  const safeIndicatorMap = indicatorMap || contextConfig.indicatorMap || {};
74
73
  const safeLegend = legend || "groupType";
@@ -80,16 +79,13 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
80
79
  const [xyList, setXYList] = useState([]);
81
80
  const [activeIds, setActiveIds] = useState([]);
82
81
  const [legendItems, setLegendItems] = useState([]);
83
- const { transformedData, leftData, rightData } = useMemo(()=>{
84
- console.log("G2CombineChart left useMemo: legend:", legend, data, x, y, z, indicators);
82
+ const { transformedData, leftData, rightData, xKey } = useMemo(()=>{
85
83
  if (!legend) {
86
84
  let result = transformDataToGroupBarLineFormat(data, x, y, indicators);
87
85
  data = result;
88
86
  setIsOldData(true);
89
- console.log('tdv data:', data);
90
87
  }
91
- console.log("G2CombineChart renderG2CombineChart transformedData2:", data);
92
- const { transformedData, leftData, rightData } = DataAdapter.transform(data, "barLine", {
88
+ const { transformedData, leftData, rightData, xKey } = DataAdapter.transform(data, "barLine", {
93
89
  type: "barLine",
94
90
  x,
95
91
  y: safeY,
@@ -101,7 +97,8 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
101
97
  return {
102
98
  transformedData: transformedData.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap)),
103
99
  leftData: leftData.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap)),
104
- rightData: rightData.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap))
100
+ rightData: rightData.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap)),
101
+ xKey: xKey
105
102
  };
106
103
  }, [
107
104
  data,
@@ -112,7 +109,6 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
112
109
  contextConfig.nodeMap,
113
110
  isDescend
114
111
  ]);
115
- console.log("G2CombineChart transformedData:", transformedData, leftData, rightData);
116
112
  const nodeData = transformedData.filter((item)=>item.nodeInfos?.info?.length > 0 || item.nodeInfos?.infosCompare?.length > 0);
117
113
  const { maxY } = useMemo(()=>{
118
114
  const key = isGroupRef.current ? "total" : safeY;
@@ -129,7 +125,7 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
129
125
  y
130
126
  ]);
131
127
  const formatLineAxis = useCallback((val)=>{
132
- const indicatorId = indicators?.length > 2 ? '' : safeZ;
128
+ const indicatorId = indicators?.length > 2 ? "" : safeZ;
133
129
  return getAxisFormat(val, safeIndicatorMap, indicatorId);
134
130
  }, [
135
131
  safeIndicatorMap,
@@ -176,10 +172,30 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
176
172
  const filterLeftData = useMemo(()=>{
177
173
  if (!activeIds.length) return leftData;
178
174
  const result = leftData.filter((d)=>d.groupType ? activeIds.includes(String(d.groupType.replace("_compare", "") + "_" + d.isCombine)) : true);
179
- if (isGroupRef.current) result.forEach((item)=>{
180
- item.total = result.filter((d)=>d.groupName === item.groupName).reduce((acc, d)=>acc + ('' === d.groupValue ? 0 : d.groupValue), 0);
181
- });
182
- return result;
175
+ if (!isGroupRef.current) return result;
176
+ {
177
+ const groupTypes = Array.from(new Set(result.map((d)=>d.groupType)));
178
+ let groupResult = [];
179
+ groupTypes.forEach((groupType)=>{
180
+ const groupData = leftData.filter((d)=>d.groupType === groupType);
181
+ xKey.forEach((key)=>{
182
+ if (!result.filter((d)=>d.groupType === groupType).some((d)=>d.groupName === key)) groupData.push({
183
+ groupName: key,
184
+ isCombine: false,
185
+ groupType: groupType,
186
+ groupValue: "",
187
+ total: 0,
188
+ percent: ""
189
+ });
190
+ });
191
+ groupData.sort((a, b)=>xKey.indexOf(a.groupName) - xKey.indexOf(b.groupName));
192
+ groupResult = groupResult.concat(groupData);
193
+ });
194
+ groupResult.forEach((item)=>{
195
+ item.total = result.filter((d)=>d.groupName === item.groupName).reduce((acc, d)=>acc + ("" === d.groupValue ? 0 : d.groupValue), 0);
196
+ });
197
+ return groupResult;
198
+ }
183
199
  }, [
184
200
  leftData,
185
201
  activeIds
@@ -191,6 +207,18 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
191
207
  rightData,
192
208
  activeIds
193
209
  ]);
210
+ const maxLeft = useMemo(()=>filterLeftData.reduce((max, item)=>{
211
+ const key = isGroupRef.current ? "total" : safeY;
212
+ if (String(item[key]).includes("-") || void 0 === item[key] || null === item[key] || "" === item[key]) return max;
213
+ return Math.max(max, item[key]);
214
+ }, 0), [
215
+ filterLeftData,
216
+ isGroupRef,
217
+ safeY
218
+ ]);
219
+ const maxRight = useMemo(()=>filterRightData.reduce((max, item)=>Math.max(max, item.groupValue), 0), [
220
+ filterRightData
221
+ ]);
194
222
  const filteredData = useMemo(()=>[
195
223
  ...filterLeftData,
196
224
  ...filterRightData
@@ -210,7 +238,6 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
210
238
  chartRef.current.destroy();
211
239
  chartRef.current = null;
212
240
  }
213
- console.log("canvasMarginBottom:", canvasMarginBottom);
214
241
  const chart = renderG2CombineChart(containerRef.current, {
215
242
  data: filteredData,
216
243
  nodeData,
@@ -218,6 +245,8 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
218
245
  y: safeY,
219
246
  z,
220
247
  maxY,
248
+ maxLeft,
249
+ maxRight,
221
250
  themeColors,
222
251
  indicatorMap: safeIndicatorMap,
223
252
  formatAxis,
@@ -278,12 +307,9 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
278
307
  chartRef.current = chart;
279
308
  if (onChartClick) chart.on("plot:click", (_e)=>{
280
309
  const tooltipTitle = currentTooltipTitleRef.current;
281
- if (null != tooltipTitle) {
282
- console.log('使用 tooltip title 触发下钻:', tooltipTitle);
283
- onChartClick({
284
- title: tooltipTitle
285
- });
286
- }
310
+ if (null != tooltipTitle) onChartClick({
311
+ title: tooltipTitle
312
+ });
287
313
  });
288
314
  return ()=>{
289
315
  if (chartRef.current) {
@@ -315,7 +341,6 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
315
341
  rightData,
316
342
  isOldData
317
343
  ]);
318
- console.log("G2BarLegend items: combie", legendItems, activeIds);
319
344
  return /*#__PURE__*/ jsxs("div", {
320
345
  style: {
321
346
  width: "100%",
@@ -262,10 +262,7 @@ const G2GaugeChart = (props)=>{
262
262
  if (tooltip.formatter) try {
263
263
  tooltipValue = tooltip.formatter(value);
264
264
  } catch (error) {
265
- if ("development" === process.env.NODE_ENV) console.warn("[G2GaugeChart] tooltip.formatter 函数执行出错,使用降级值", {
266
- error,
267
- value
268
- });
265
+ process.env.NODE_ENV;
269
266
  tooltipValue = value.toLocaleString();
270
267
  }
271
268
  else tooltipValue = value.toLocaleString();
@@ -14,7 +14,6 @@ const G2GroupBarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onC
14
14
  showType: 0,
15
15
  type: []
16
16
  }, auxiliaryLineData, highlightDate = [], indicators = [], timeRange })=>{
17
- console.log("props data:", data, nodeSetting, "x:", x, "y:", y, "legend:", legend, "indicators:", indicators, timeRange, config);
18
17
  const { formatter, dataTransform, config: contextConfig } = useChartContext();
19
18
  const tooltipContainerRef = useG2TooltipContainer();
20
19
  const themeColors = contextConfig?.theme?.colors || [];
@@ -24,7 +23,6 @@ const G2GroupBarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onC
24
23
  const chartConfig = config || {};
25
24
  const { isDataTag = false, isDescend = false, isHorizontal = false, isLegend = true, isHighlight = true } = chartConfig;
26
25
  const transformedData = useMemo(()=>{
27
- console.log("transformedData: bar ---", legend, data, indicators);
28
26
  if (!legend) {
29
27
  let result = transformIndicatorList(indicators, data);
30
28
  data = result[y] || [];
@@ -46,7 +44,6 @@ const G2GroupBarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onC
46
44
  dataTransform,
47
45
  contextConfig.nodeMap
48
46
  ]);
49
- console.log("transformedData: bar final", transformedData);
50
47
  const maxY = useMemo(()=>{
51
48
  const values = transformedData.filter((item)=>"-" !== item['total'] && void 0 !== item['total'] && null !== item['total']).map((item)=>Number(item['total']) || 0);
52
49
  const dataMax = values.length > 0 ? Math.max(...values) : 0;
@@ -143,7 +140,6 @@ const G2GroupBarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onC
143
140
  },
144
141
  auxiliaryLineData: auxiliaryLineData ?? [],
145
142
  onNodeListChange: (nodes)=>{
146
- console.log("g2bar node list:", nodes, nodes[0], nodes[1]);
147
143
  setXYList(nodes);
148
144
  },
149
145
  timeRange,
@@ -75,13 +75,9 @@ const G2IndicatorCardChart = ({ data, height, x = '', y = '', legend = '', indic
75
75
  });
76
76
  const view = chart.view();
77
77
  view.data(transformedData);
78
- if (scale && scale.groupValue) {
79
- console.log(transformedData, 'transformedData');
80
- console.log(scale.groupValue, 'scale.groupValue');
81
- view.scale({
82
- y: scale.groupValue
83
- });
84
- }
78
+ if (scale && scale.groupValue) view.scale({
79
+ y: scale.groupValue
80
+ });
85
81
  if (lineStyle.area) view.area().encode('x', x || 'groupName').encode('y', 'groupValue').encode('shape', lineStyle.shape || 'smooth').style({
86
82
  fill: lineColor,
87
83
  fillOpacity: 0.2
@@ -17,7 +17,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
17
17
  showType: 0,
18
18
  type: []
19
19
  }, auxiliaryLineData, highlightDate, indicators = [] })=>{
20
- console.log("props data: G2LineChart", data, nodeSetting, config, "x, y, z", x, y, z, "highlightDate:", highlightDate, "indicators:", indicators);
21
20
  const { formatter, dataTransform, config: contextConfig } = useChartContext();
22
21
  const tooltipContainerRef = useG2TooltipContainer();
23
22
  const themeColors = contextConfig?.theme?.colors || [];
@@ -54,7 +53,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
54
53
  contextConfig.nodeMap
55
54
  ]);
56
55
  const nodeData = transformedData.filter((item)=>item.nodeInfos?.info?.length > 0 || item.nodeInfos?.infosCompare?.length > 0);
57
- console.log("nodeData:", nodeData);
58
56
  const { minY, maxY } = useMemo(()=>{
59
57
  const dataValues = transformedData.filter((item)=>"-" !== item[safeY] && void 0 !== item[safeY] && null !== item[safeY]).map((item)=>Number(item[safeY]));
60
58
  const compareValues = transformedData.filter((item)=>"-" !== item["subGroupValue"] && null != item["subGroupValue"]).map((item)=>Number(item["subGroupValue"]));
@@ -130,7 +128,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
130
128
  chartRef.current.destroy();
131
129
  chartRef.current = null;
132
130
  }
133
- console.log("G2LineChart", x, y, minY, maxY);
134
131
  const chart = renderG2LineChart(containerRef.current, {
135
132
  data: filteredData,
136
133
  nodeData,
@@ -161,7 +158,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
161
158
  ...i,
162
159
  color: i.color ?? themeColors[0] ?? "#5B8FF9"
163
160
  }));
164
- console.log("safeItems:", safeItems);
165
161
  react_dom.render(/*#__PURE__*/ jsx(G2CompareTooltip, {
166
162
  title: title,
167
163
  items: safeItems,
@@ -175,7 +171,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
175
171
  legendSize: 12,
176
172
  useStrictTicks: true,
177
173
  onNodeListChange: (nodes)=>{
178
- console.log("setXYList:", nodes);
179
174
  setXYList(nodes);
180
175
  },
181
176
  onChartRender: (chartProps)=>{
@@ -190,16 +185,11 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
190
185
  if (onChartClick) {
191
186
  chart.on("plot:click", (_e)=>{
192
187
  const tooltipTitle = currentTooltipTitleRef.current;
193
- if (null != tooltipTitle) {
194
- console.log("使用 tooltip title 触发下钻:", tooltipTitle);
195
- onChartClick({
196
- title: tooltipTitle
197
- });
198
- }
199
- });
200
- chart.on("plot:pointerenter:", (event)=>{
201
- console.log("plot:pointerenter:", event);
188
+ if (null != tooltipTitle) onChartClick({
189
+ title: tooltipTitle
190
+ });
202
191
  });
192
+ chart.on("plot:pointerenter:", (event)=>{});
203
193
  }
204
194
  return ()=>{
205
195
  if (chartRef.current) {
@@ -227,7 +217,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
227
217
  auxiliaryLineData,
228
218
  themeColors
229
219
  ]);
230
- console.log("legendItems:", legendItems);
231
220
  return /*#__PURE__*/ jsxs("div", {
232
221
  style: {
233
222
  width: "100%",
@@ -61,7 +61,6 @@ function applyAxisX(mark, options = {}) {
61
61
  const needSampling = dataCount > 0 && containerWidth > 0;
62
62
  const interval = needSampling ? calcAxisInterval(dataCount, containerWidth, maxLabelChars, fontSize) : 1;
63
63
  const axisFilter = needSampling && interval > 1 ? (type)=>createAxisFilter(type, interval, dataCount) : null;
64
- console.log('axisFilter:', interval);
65
64
  mark.axis('x', {
66
65
  title,
67
66
  grid,
@@ -82,6 +81,12 @@ function applyAxisX(mark, options = {}) {
82
81
  },
83
82
  labelAlign: 'horizontal',
84
83
  labelDx: (_datum, _index, _data)=>0,
84
+ labelRender: (datum)=>{
85
+ let left = '0%';
86
+ if (datum.value > 0.9) left = '-13%';
87
+ else if (datum.value < 0.1) left = '10%';
88
+ return `<div style="transform: translateX(${left});">${datum.label}</div>`;
89
+ },
85
90
  labelOpacity: 0.6,
86
91
  ...axisFilter && {
87
92
  tickFilter: axisFilter('tick'),
@@ -148,10 +153,9 @@ function applyLegendColor(view, options = {}) {
148
153
  }
149
154
  function applyAuxiliaryLineY(view, lines, options = {}) {
150
155
  if (!lines?.length) return;
151
- console.log('applyAuxiliaryLineY:', lines);
152
156
  const { stroke = '#F4664A', strokeOpacity = 1, labelMaxLength = 5 } = options;
153
157
  lines.forEach((auxLine)=>{
154
- view.lineY().encode('y', auxLine.value).style('stroke', stroke).style('strokeOpacity', strokeOpacity).style('lineWidth', 1).style('shadowColor', 'transparent').scale('y', {
158
+ view.lineY().encode('y', auxLine.value).style('stroke', stroke).style('strokeOpacity', strokeOpacity).style('lineWidth', 1).style('shadowColor', 'transparent').animate(false).scale('y', {
155
159
  key: auxLine?.axis === 'right' ? 'line' : 'main'
156
160
  }).axis('x', false).label({
157
161
  dx: 0,
@@ -176,7 +180,7 @@ function applyHighlightDate(view, x, data, highlightDate, isHighlight) {
176
180
  [x]: item,
177
181
  ['highlight']: highlightDate.includes(item) ? 100 : 0
178
182
  }));
179
- const highlightInterval = view.interval().data(highlightData).encode('x', x).encode('y', 'highlight').scale('y', {
183
+ const highlightInterval = view.interval().data(highlightData).encode('x', x).encode('y', 'highlight').animate(false).scale('y', {
180
184
  type: 'linear',
181
185
  domainMin: 0,
182
186
  domainMax: 100,
@@ -187,7 +191,7 @@ function applyHighlightDate(view, x, data, highlightDate, isHighlight) {
187
191
  fill: '#cccccc',
188
192
  fillOpacity: isHighlight ? 0.3 : 0
189
193
  });
190
- view.line().data(highlightData).encode('x', x).encode('y', 'highlight').scale('y', {
194
+ view.line().data(highlightData).encode('x', x).encode('y', 'highlight').animate(false).scale('y', {
191
195
  type: 'linear',
192
196
  domainMin: 0,
193
197
  domainMax: 100,
@@ -272,7 +276,6 @@ function fillMissingIndicator(baseItems, safeTitle, isCompare, isGroup = false)
272
276
  id,
273
277
  0
274
278
  ]));
275
- console.log('baseItems:', baseItems);
276
279
  if (isCompare && !isGroup) {
277
280
  baseItems.forEach((item)=>{
278
281
  if (item.indicatorId) indicatorIdSet.set(item.indicatorId, (indicatorIdSet.get(item.indicatorId) ?? 0) + 1);
@@ -311,7 +314,6 @@ function fillMissingIndicator(baseItems, safeTitle, isCompare, isGroup = false)
311
314
  };
312
315
  return item;
313
316
  }).sort(intervalSort);
314
- console.log('safeItems:', safeItems);
315
317
  return safeItems;
316
318
  }
317
319
  export { adjustDomainMax, applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyLegendColor, applyNodeData, applyScaleYLinear, createChart, fillMissingIndicator, getColorByGroupType, getMainView, intervalSort, sortByIndicators };
@@ -20,7 +20,6 @@ function renderG2BarChart(container, options) {
20
20
  paddingBottom: 0,
21
21
  insetBottom: 0
22
22
  });
23
- console.log('isLegend:', legend, isLegend);
24
23
  const view = getMainView(chart);
25
24
  view.attr('marginLeft', 0).attr('marginRight', 0).attr('marginBottom', isLegend ? 0 : 16);
26
25
  if (isHorizontal) view.coordinate({
@@ -37,11 +36,10 @@ function renderG2BarChart(container, options) {
37
36
  key: 'main'
38
37
  });
39
38
  if (!CLOSE_HIGHLIGHT_DEBUG) applyHighlightDate(view, x, data, highlightDate, isHighlight);
40
- console.log('g2bar data:', data, y);
41
39
  const interval = view.interval().encode('x', x).encode('y', y).encode('color', 'groupType').transform({
42
40
  type: 'dodgeX',
43
41
  padding: isHorizontal ? 0.2 : 0
44
- });
42
+ }).animate(false);
45
43
  interval.style({
46
44
  columnWidthRatio: 0.6,
47
45
  insetLeft: (_d, index, _data, _column)=>{
@@ -145,7 +143,6 @@ function renderG2BarChart(container, options) {
145
143
  bounding: tooltipBounding
146
144
  });
147
145
  applyAuxiliaryLineY(view, auxiliaryLineData);
148
- console.log('nodeList data:', data);
149
146
  if (!CLOSE_NODE_DEBUG) {
150
147
  const nodeList = applyNodeData(view, nodeData, x, y);
151
148
  onNodeListChange?.(nodeList);
@@ -170,7 +167,6 @@ function renderG2BarChart(container, options) {
170
167
  let hasEmittedNodeList = false;
171
168
  chart.on('afterrender', (_e)=>{
172
169
  if (hasEmittedNodeList) return;
173
- console.log('chart.coordinateBBox:', chart.getContext(), view.getCoordinate());
174
170
  const views = chart.getContext()?.views;
175
171
  const viewCoordinate = views?.[0]?.layout;
176
172
  if (onChartRender && viewCoordinate) onChartRender({
@@ -18,6 +18,10 @@ export interface RenderG2CombineChartOptions {
18
18
  z: string;
19
19
  /** 柱状图 Y 轴最大值 */
20
20
  maxY: number;
21
+ /** 柱状图 Y 轴最大值 */
22
+ maxLeft: number;
23
+ /** 折线图 Y 轴最大值 */
24
+ maxRight: number;
21
25
  /** 高亮日期,用于 x 轴 gridFilter */
22
26
  highlightDate?: string[];
23
27
  /** 主题色数组 */
@@ -5,7 +5,7 @@ const Y_AXIS_FIELD = 'groupValue';
5
5
  const BAR_Y_FIELD = 'barValue';
6
6
  const LINE_Y_FIELD = 'lineValue';
7
7
  function renderG2CombineChart(container, options) {
8
- const { data, nodeData, x, y, z: _z, maxY, themeColors, indicatorMap: _indicatorMap, formatAxis, formatLineAxis, isDataTag = true, isCombineDataTag = true, isLegend: _isLegend = false, isCompare = false, formatLabel, highlightDate = [], height = 300, isHighlight = true, isClickable = false, indicators = [], tooltipRender, auxiliaryLineData = [], onNodeListChange, lineColors, onChartRender, isGroup, legendItems = [], indicatorId, isTooltipContent = false } = options;
8
+ const { data, nodeData, x, z: _z, maxLeft, maxRight, themeColors, indicatorMap: _indicatorMap, formatAxis, formatLineAxis, isDataTag = true, isCombineDataTag = true, isLegend: _isLegend = false, isCompare = false, formatLabel, highlightDate = [], height = 300, isHighlight = true, isClickable = false, indicators = [], tooltipRender, auxiliaryLineData = [], onNodeListChange, lineColors, onChartRender, isGroup, legendItems = [], indicatorId, isTooltipContent = false } = options;
9
9
  const chart = createChart({
10
10
  container,
11
11
  height,
@@ -14,11 +14,11 @@ function renderG2CombineChart(container, options) {
14
14
  chart.options({
15
15
  marginBottom: 0,
16
16
  paddingBottom: 0,
17
- insetBottom: 0
17
+ insetBottom: 0,
18
+ animate: null
18
19
  });
19
20
  const view = getMainView(chart);
20
- view.attr('insetLeft', 0).attr('insetRight', 0).attr('marginLeft', 0).attr('marginRight', 0).attr('marginBottom', 0);
21
- console.log('renderG2CombineChart data:', data, 'maxY:', maxY, x, y, 'indicators:', indicators);
21
+ view.attr('insetLeft', 0).attr('insetRight', 0).attr('marginLeft', 0).attr('marginRight', 0).attr('marginBottom', 0).attr('animate', false).animate(false);
22
22
  view.data(data);
23
23
  const xValueCount = new Set(data.map((d)=>d[x])).size;
24
24
  applyAxisX(view, {
@@ -28,27 +28,17 @@ function renderG2CombineChart(container, options) {
28
28
  containerWidth: container.clientWidth
29
29
  });
30
30
  const barColor = themeColors[0] ?? "#5B8FF9";
31
- console.log('tooltip: themeColors:', themeColors[0], barColor, isGroup);
32
- console.log('renderG2CombineChart highlightDate:', highlightDate, isHighlight);
33
31
  applyHighlightDate(view, x, data, highlightDate, isHighlight);
34
32
  const intervalData = data.filter((item)=>!item.isCombine).map((item)=>({
35
33
  ...item,
36
34
  [BAR_Y_FIELD]: item[Y_AXIS_FIELD]
37
35
  }));
38
- console.log('renderG2CombineChart interval data:', intervalData);
39
- const intervalMaxY = intervalData.reduce((max, item)=>{
40
- const key = isGroup ? "total" : BAR_Y_FIELD;
41
- console.log('tdv item:', key, item[key], intervalData);
42
- if ('-' === item[key] || void 0 === item[key] || null === item[key] || '' === item[key]) return max;
43
- return Math.max(max, item[key]);
44
- }, 0);
45
- console.log('tdv:', intervalMaxY);
46
36
  const auxLeftValues = auxiliaryLineData?.length ? auxiliaryLineData.filter((item)=>'left' === item.axis).map((item)=>item.value) : [];
47
37
  const maxAuxLeft = auxLeftValues.length ? Math.max(...auxLeftValues) : 0;
48
38
  const auxRightValues = auxiliaryLineData?.length ? auxiliaryLineData.filter((item)=>'right' === item.axis).map((item)=>item.value) : [];
49
39
  const maxAuxRight = auxRightValues.length ? Math.max(...auxRightValues) : 0;
50
- const finalIntervalMax = Math.max(intervalMaxY, maxAuxLeft);
51
- const interval = view.interval().data(intervalData).encode("x", x).encode("y", BAR_Y_FIELD).encode("color", "groupType").transform(isGroup ? {
40
+ const finalIntervalMax = Math.max(maxLeft, maxAuxLeft);
41
+ const interval = view.interval().data(intervalData).encode("x", x).encode("y", BAR_Y_FIELD).encode("color", "groupType").animate(false).transform(isGroup ? {
52
42
  type: 'stackY',
53
43
  reverse: true
54
44
  } : {
@@ -109,13 +99,11 @@ function renderG2CombineChart(container, options) {
109
99
  labelFormatter: formatAxis,
110
100
  labelOpacity: 0.6
111
101
  });
112
- console.log('tooltip:', barColor, isCompare);
113
102
  interval.tooltip({
114
103
  items: isGroup ? [
115
104
  (datum)=>{
116
105
  const groupType = String(datum.groupType ?? '');
117
106
  const index = legendItems.findIndex((item)=>item.id === `${groupType}_${datum.isCombine}`);
118
- console.log(datum);
119
107
  return {
120
108
  value: datum[Y_AXIS_FIELD],
121
109
  name: datum['groupType'],
@@ -162,24 +150,12 @@ function renderG2CombineChart(container, options) {
162
150
  ...item,
163
151
  [LINE_Y_FIELD]: item[Y_AXIS_FIELD]
164
152
  }));
165
- console.log('renderG2CombineChart: line data:', data);
166
153
  const compareLineData = data.filter((item)=>item.isCombine && item.groupType.includes('_compare')).filter((item)=>'' !== item[Y_AXIS_FIELD]).map((item)=>({
167
154
  ...item,
168
155
  [LINE_Y_FIELD]: item[Y_AXIS_FIELD]
169
156
  }));
170
- console.log('compareLineData:', compareLineData);
171
- const lineMaxY = lineData.reduce((max, item)=>{
172
- if ('-' === item[LINE_Y_FIELD] || void 0 === item[LINE_Y_FIELD] || null === item[LINE_Y_FIELD] || '' === item[LINE_Y_FIELD]) return max;
173
- return Math.max(max, item[LINE_Y_FIELD]);
174
- }, 0);
175
- const compareLineMaxY = compareLineData.reduce((max, item)=>{
176
- if ('-' === item[LINE_Y_FIELD] || void 0 === item[LINE_Y_FIELD] || null === item[LINE_Y_FIELD] || '' === item[LINE_Y_FIELD]) return max;
177
- return Math.max(max, item[LINE_Y_FIELD]);
178
- }, 0);
179
- const lineFinalMaxY = Math.max(lineMaxY, compareLineMaxY) || 1;
180
- const finalLineMax = Math.max(lineFinalMaxY, maxAuxRight);
181
- console.log('lineData:', lineData);
182
- const line = view.line().data(lineData).encode("x", x).encode("y", LINE_Y_FIELD).encode('color', 'groupType').style({
157
+ const finalLineMax = Math.max(maxRight, maxAuxRight);
158
+ const line = view.line().data(lineData).encode("x", x).encode("y", LINE_Y_FIELD).encode('color', 'groupType').animate(false).style({
183
159
  lineWidth: 2,
184
160
  stroke: (datum)=>{
185
161
  const currentDatum = datum[0];
@@ -217,7 +193,7 @@ function renderG2CombineChart(container, options) {
217
193
  position: 'right',
218
194
  title: false,
219
195
  grid: true,
220
- gridStrokeOpacity: 0 === intervalMaxY ? 0.2 : 0,
196
+ gridStrokeOpacity: 0 === maxAuxLeft ? 0.2 : 0,
221
197
  gridLineWidth: 1,
222
198
  gridLineDash: [
223
199
  0,
@@ -227,8 +203,7 @@ function renderG2CombineChart(container, options) {
227
203
  labelFormatter: formatLineAxis,
228
204
  labelOpacity: 0.6
229
205
  });
230
- console.log('renderG2CombineChart: compare line data:', compareLineData);
231
- const compareLine = view.line().data(compareLineData).encode('x', x).encode('y', LINE_Y_FIELD).encode('color', 'groupType').style({
206
+ const compareLine = view.line().data(compareLineData).encode('x', x).encode('y', LINE_Y_FIELD).encode('color', 'groupType').animate(false).style({
232
207
  lineDash: [
233
208
  4,
234
209
  4
@@ -288,7 +263,6 @@ function renderG2CombineChart(container, options) {
288
263
  } : {},
289
264
  render: (event, payload)=>{
290
265
  const { title, items } = payload;
291
- console.log('tooltipRender:', title, items, isCompare);
292
266
  let safeTitle = title.replace(/,.*$/, '');
293
267
  const baseItems = items.filter((item)=>item.hasOwnProperty('isCombine') && !item.isCombine);
294
268
  const safeItems = fillMissingIndicator(baseItems, safeTitle, isCompare, isGroup);
@@ -13,7 +13,6 @@ function renderG2GroupBarChart(container, options) {
13
13
  paddingBottom: 0,
14
14
  insetBottom: 0
15
15
  });
16
- console.log('isLegend:', legend, isLegend);
17
16
  const view = getMainView(chart);
18
17
  view.attr('marginBottom', isLegend ? 0 : 16);
19
18
  if (isHorizontal) view.coordinate({
@@ -23,7 +22,6 @@ function renderG2GroupBarChart(container, options) {
23
22
  }
24
23
  ]
25
24
  });
26
- console.log(legendItems, 'legendItems');
27
25
  view.data(data);
28
26
  applyScaleYLinear(view, {
29
27
  field: 'y',
@@ -124,7 +122,6 @@ function renderG2GroupBarChart(container, options) {
124
122
  }
125
123
  applyAuxiliaryLineY(view, auxiliaryLineData);
126
124
  const nodeList = [];
127
- console.log('nodeList data:', data);
128
125
  data.forEach((item)=>{
129
126
  view.shape().data([
130
127
  {
@@ -2,7 +2,6 @@ import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyN
2
2
  const Y_AXIS_FIELD = 'groupValue';
3
3
  function renderG2LineChart(container, options) {
4
4
  const { data, nodeData, x, y, minY, maxY, timeRange: _timeRange, themeColors, indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], auxiliaryLineData = [], isDataTag = false, isLegend = true, isHighlight = true, formatLabel, height = 300, legendLength: _legendLength, legendSize: _legendSize, tooltipRender, onNodeListChange, onChartRender } = options;
5
- console.log('g2line data:', data, x, y);
6
5
  const colorOpts = {
7
6
  themeColors,
8
7
  primaryKey: y,
@@ -28,12 +27,11 @@ function renderG2LineChart(container, options) {
28
27
  key: 'main'
29
28
  });
30
29
  applyHighlightDate(view, x, data, highlightDate, isHighlight);
31
- console.log('g2linets:', x, Y_AXIS_FIELD, data, indicators);
32
- const line = view.line().data(data.filter((item)=>!item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').style({
30
+ const line = view.line().data(data.filter((item)=>!item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').animate(false).style({
33
31
  lineWidth: 2,
34
32
  stroke: (datum)=>getColorByGroupType(datum[0]?.groupType ?? '', colorOpts)
35
33
  });
36
- const compareLine = view.line().data(data.filter((item)=>item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').style({
34
+ const compareLine = view.line().data(data.filter((item)=>item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').animate(false).style({
37
35
  lineDash: [
38
36
  4,
39
37
  4
@@ -62,7 +60,6 @@ function renderG2LineChart(container, options) {
62
60
  ]
63
61
  });
64
62
  const hasCompareData = data.some((item)=>item.groupType.includes('_compare'));
65
- console.log('hasCompareData:', hasCompareData, data);
66
63
  if (hasCompareData) compareLine.tooltip({
67
64
  items: [
68
65
  (datum)=>({
@@ -95,16 +92,13 @@ function renderG2LineChart(container, options) {
95
92
  bounding: tooltipBounding,
96
93
  render: (_event, payload)=>{
97
94
  const { title, items } = payload;
98
- console.log('tooltipRender:', title, items, indicators);
99
95
  if (indicators.length) {
100
96
  const groupedItems = indicators.map((indicator)=>items.filter((i)=>i.indicatorId === String(indicator)));
101
- console.log(groupedItems.flat(), 'tooltip groupedItems');
102
97
  const sortedItems = groupedItems.map((group)=>[
103
98
  group.filter((i)=>i.name === i.indicatorId),
104
99
  group.filter((i)=>i.compareTime),
105
100
  group.filter((i)=>i.name.includes('_change'))
106
101
  ].filter(Boolean).flat()).flat();
107
- console.log(sortedItems, 'tooltip sortedItems');
108
102
  const formatItems = sortedItems.map((item)=>({
109
103
  ...item,
110
104
  color: getColorByGroupType(item?.indicatorId, colorOpts)
@@ -7,47 +7,20 @@ function isValidColor(color) {
7
7
  return "" !== s.color;
8
8
  }
9
9
  function validateAndNormalizeProps(props) {
10
- const isDev = "development" === process.env.NODE_ENV;
10
+ process.env.NODE_ENV;
11
11
  let { min = 0, max } = props;
12
- if ("number" != typeof max || !isFinite(max)) {
13
- if (isDev) console.warn("[G2GaugeChart] max 必须是有效的数字,使用默认值 100", {
14
- max
15
- });
16
- max = 100;
17
- }
18
- if ("number" != typeof min || !isFinite(min)) {
19
- if (isDev) console.warn("[G2GaugeChart] min 必须是有效的数字,使用默认值 0", {
20
- min
21
- });
22
- min = 0;
23
- }
12
+ if ("number" != typeof max || !isFinite(max)) max = 100;
13
+ if ("number" != typeof min || !isFinite(min)) min = 0;
24
14
  if (min >= max) {
25
- if (isDev) console.warn(`[G2GaugeChart] min (${min}) 必须小于 max (${max}),自动调整为 max - 1`, {
26
- min,
27
- max
28
- });
29
15
  min = max - 1;
30
16
  if (min < 0) {
31
17
  min = 0;
32
18
  max = 100;
33
- if (isDev) console.warn("[G2GaugeChart] min 和 max 都无效,使用默认值 min=0, max=100");
34
19
  }
35
20
  }
36
21
  let { value } = props;
37
- if ("number" != typeof value || !isFinite(value)) {
38
- if (isDev) console.warn(`[G2GaugeChart] value 必须是有效的数字,使用默认值 (min + max) / 2`, {
39
- value
40
- });
41
- value = (min + max) / 2;
42
- }
43
- const originalValue = value;
22
+ if ("number" != typeof value || !isFinite(value)) value = (min + max) / 2;
44
23
  value = Math.min(Math.max(value, min), max);
45
- if (originalValue !== value && isDev) console.warn(`[G2GaugeChart] value (${originalValue}) 超出范围 [${min}, ${max}],已限制为 ${value}`, {
46
- originalValue,
47
- min,
48
- max,
49
- clampedValue: value
50
- });
51
24
  let thresholds = [];
52
25
  const defaultColors = [
53
26
  '#9596d9',
@@ -68,33 +41,18 @@ function validateAndNormalizeProps(props) {
68
41
  let colors = [];
69
42
  if (props.thresholds && Array.isArray(props.thresholds) && props.thresholds.length > 0 && "object" == typeof props.thresholds[0]) colors = props.thresholds.map((t)=>t.color).filter((c)=>!!c && isValidColor(c));
70
43
  if (0 === colors.length && props.thresholdColors) colors = props.thresholdColors.filter((c)=>isValidColor(c));
71
- if (0 === colors.length) {
72
- colors = [
73
- ...defaultColors
74
- ];
75
- if (isDev) console.warn("[G2GaugeChart] 未提供有效的颜色,使用默认颜色", {
76
- colors
77
- });
78
- }
44
+ if (0 === colors.length) colors = [
45
+ ...defaultColors
46
+ ];
79
47
  while(colors.length < thresholds.length){
80
48
  const lastColor = colors[colors.length - 1];
81
49
  colors.push(lastColor || defaultColors[0]);
82
50
  }
83
51
  let height = props.height ?? 300;
84
- if ("number" != typeof height || !isFinite(height) || height <= 0) {
85
- if (isDev) console.warn(`[G2GaugeChart] height 必须是大于 0 的数字,使用默认值 300`, {
86
- height: props.height
87
- });
88
- height = 300;
89
- }
52
+ if ("number" != typeof height || !isFinite(height) || height <= 0) height = 300;
90
53
  height = Math.min(Math.max(height, 100), 2000);
91
54
  let pointerColor = props.pointerColor ?? "#c5c5c5";
92
- if (!isValidColor(pointerColor)) {
93
- if (isDev) console.warn(`[G2GaugeChart] pointerColor 无效,使用默认值 #c5c5c5`, {
94
- pointerColor: props.pointerColor
95
- });
96
- pointerColor = "#c5c5c5";
97
- }
55
+ if (!isValidColor(pointerColor)) pointerColor = "#c5c5c5";
98
56
  const formatter = props.formatter;
99
57
  const tickFormatter = props.tickFormatter;
100
58
  return {
@@ -116,11 +74,7 @@ function safeFormat(formatter, value, percent, fallback) {
116
74
  try {
117
75
  return formatter(value, percent);
118
76
  } catch (error) {
119
- if ("development" === process.env.NODE_ENV) console.warn("[G2GaugeChart] formatter 函数执行出错,使用降级值", {
120
- error,
121
- value,
122
- percent
123
- });
77
+ process.env.NODE_ENV;
124
78
  return fallback;
125
79
  }
126
80
  }
@@ -129,10 +83,7 @@ function safeTickFormat(tickFormatter, value, fallback) {
129
83
  try {
130
84
  return tickFormatter(value);
131
85
  } catch (error) {
132
- if ("development" === process.env.NODE_ENV) console.warn("[G2GaugeChart] tickFormatter 函数执行出错,使用降级值", {
133
- error,
134
- value
135
- });
86
+ process.env.NODE_ENV;
136
87
  return fallback;
137
88
  }
138
89
  }
@@ -1,3 +1,4 @@
1
+ import type { AuxiliaryLineData } from "../../../core/ChartTypes";
1
2
  type Item = {
2
3
  color?: string;
3
4
  name?: string;
@@ -7,6 +8,7 @@ type Item = {
7
8
  indicatorId?: string;
8
9
  percent?: string | number;
9
10
  hidden?: boolean;
11
+ isCombine?: boolean;
10
12
  };
11
13
  interface Props {
12
14
  isGroupBar?: boolean;
@@ -15,10 +17,7 @@ interface Props {
15
17
  safeIndicatorMap: any;
16
18
  formatter: any;
17
19
  safeLegend: string;
18
- auxiliaryLineData: undefined | {
19
- name: string;
20
- value: string | number;
21
- }[];
20
+ auxiliaryLineData?: AuxiliaryLineData[];
22
21
  }
23
22
  declare const _default: import("react").NamedExoticComponent<Props>;
24
23
  export default _default;
@@ -3,8 +3,8 @@ 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, safeLegend, auxiliaryLineData })=>{
6
- let auxiIndicatorId = "";
7
- console.log('G2CompareTooltip:', items);
6
+ let auxiIndicatorId = '';
7
+ let combineIndicatorId = '';
8
8
  const uniqueColors = [];
9
9
  return /*#__PURE__*/ jsxs("div", {
10
10
  style: {
@@ -14,7 +14,8 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
14
14
  /*#__PURE__*/ jsx("div", {
15
15
  children: title
16
16
  }),
17
- items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent, hidden }, index)=>{
17
+ items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent, hidden, isCombine }, index)=>{
18
+ if (isCombine) combineIndicatorId = indicatorId ?? "";
18
19
  let isFirst = false;
19
20
  if (0 === index) auxiIndicatorId = indicatorId ?? "";
20
21
  if (color && !uniqueColors.includes(color)) {
@@ -61,9 +62,7 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
61
62
  ]
62
63
  }, index);
63
64
  }),
64
- auxiliaryLineData?.map(({ name, value }, index)=>{
65
- console.log("auxiliaryLineData:", name, value, safeLegend);
66
- return /*#__PURE__*/ jsxs("div", {
65
+ auxiliaryLineData?.map(({ name, value, axis }, index)=>/*#__PURE__*/ jsxs("div", {
67
66
  style: {
68
67
  display: "flex",
69
68
  justifyContent: "space-between",
@@ -82,11 +81,10 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
82
81
  ]
83
82
  }),
84
83
  /*#__PURE__*/ jsx("div", {
85
- children: formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ""] ?? {})
84
+ children: 'right' === axis ? formatter.formatIndicator(value, safeIndicatorMap[combineIndicatorId ?? ''] ?? {}) : formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ''] ?? {})
86
85
  })
87
86
  ]
88
- }, index);
89
- })
87
+ }, index))
90
88
  ]
91
89
  });
92
90
  };
@@ -3,9 +3,7 @@ import "react";
3
3
  import { Popover } from "@arco-design/web-react";
4
4
  import { nodeMap } from "../../core/ChartConfig.js";
5
5
  import { NodePopoverContent } from "./NodePopoverContent.js";
6
- const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>{
7
- console.log(dvRows, 'dvRows');
8
- return /*#__PURE__*/ jsx("div", {
6
+ const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>/*#__PURE__*/ jsx("div", {
9
7
  style: {
10
8
  display: 'flex',
11
9
  justifyContent: 'space-around',
@@ -106,5 +104,4 @@ const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>{
106
104
  });
107
105
  })
108
106
  });
109
- };
110
107
  export { NodeDetail };
@@ -16,9 +16,7 @@ const calculateBarWidth = (chart, data, xField, widthRatio = 0.5)=>{
16
16
  const estimatedBarWidth = xValueWidth * widthRatio;
17
17
  return estimatedBarWidth;
18
18
  }
19
- } catch (error) {
20
- console.error('计算主图柱状图宽度失败', error);
21
- }
19
+ } catch (error) {}
22
20
  };
23
21
  const getAxisHorPaddingByText = (value, indicatorMap, y)=>7 * getAxisFormat(value, indicatorMap, y).length + 26;
24
22
  const getAxisFormat = (val, indicatorMap, y)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@publishfx/publish-chart",
3
- "version": "2.1.14",
3
+ "version": "2.1.15",
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": [