@publishfx/publish-chart 2.0.2 → 2.1.0

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +6 -6
  3. package/dist/adapters/DataAdapter.d.ts +7 -3
  4. package/dist/adapters/DataAdapter.js +61 -0
  5. package/dist/components/g2/base/G2BarChart.d.ts +4 -3
  6. package/dist/components/g2/base/G2BarChart.js +194 -53
  7. package/dist/components/g2/base/G2BarLegend.d.ts +17 -0
  8. package/dist/components/g2/base/G2BarLegend.js +196 -0
  9. package/dist/components/g2/base/G2CombineChart.d.ts +9 -0
  10. package/dist/components/g2/base/G2CombineChart.js +305 -0
  11. package/dist/components/g2/base/G2GaugeChart.js +3 -1
  12. package/dist/components/g2/base/G2GroupBarChart.d.ts +9 -0
  13. package/dist/components/g2/base/G2GroupBarChart.js +227 -0
  14. package/dist/components/g2/base/G2IndicatorCardChart.d.ts +43 -0
  15. package/dist/components/g2/base/G2IndicatorCardChart.js +156 -0
  16. package/dist/components/g2/base/G2LineChart.d.ts +4 -3
  17. package/dist/components/g2/base/G2LineChart.js +207 -104
  18. package/dist/components/g2/base/G2PieChart.d.ts +9 -0
  19. package/dist/components/g2/base/G2PieChart.js +189 -0
  20. package/dist/components/g2/base/g2Helpers.d.ts +293 -0
  21. package/dist/components/g2/base/g2Helpers.js +167 -0
  22. package/dist/components/g2/base/g2bar.d.ts +64 -0
  23. package/dist/components/g2/base/g2bar.js +191 -0
  24. package/dist/components/g2/base/g2combine.d.ts +71 -0
  25. package/dist/components/g2/base/g2combine.js +322 -0
  26. package/dist/components/g2/base/g2groupbar.d.ts +69 -0
  27. package/dist/components/g2/base/g2groupbar.js +188 -0
  28. package/dist/components/g2/base/g2line.d.ts +77 -0
  29. package/dist/components/g2/base/g2line.js +208 -0
  30. package/dist/components/g2/shared/G2CompareTooltip.d.ts +23 -0
  31. package/dist/components/g2/shared/G2CompareTooltip.js +93 -0
  32. package/dist/components/g2/shared/useG2TooltipContainer.d.ts +1 -0
  33. package/dist/components/g2/shared/useG2TooltipContainer.js +16 -0
  34. package/dist/components/shared/NodeDetail.js +1 -1
  35. package/dist/components/shared/NodePopover.d.ts +1 -0
  36. package/dist/components/shared/NodePopover.js +3 -2
  37. package/dist/core/ChartTypes.d.ts +4 -0
  38. package/dist/index.d.ts +5 -0
  39. package/dist/index.js +5 -1
  40. package/dist/utils/chartHelpers.d.ts +1 -1
  41. package/dist/utils/chartHelpers.js +2 -2
  42. package/package.json +15 -13
@@ -0,0 +1,196 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { Tooltip } from "@arco-design/web-react";
4
+ const G2BarLegend = ({ items, activeIds, onChange, pageSize: pageSizeProp, maxLabelChars = 8, style })=>{
5
+ console.log("G2BarLegend items:", items, activeIds);
6
+ const [page, setPage] = useState(1);
7
+ const [autoPageSize, setAutoPageSize] = useState(pageSizeProp || items.length || 1);
8
+ const containerRef = useRef(null);
9
+ useEffect(()=>{
10
+ if (pageSizeProp) return void setAutoPageSize(pageSizeProp);
11
+ const computePageSize = ()=>{
12
+ const container = containerRef.current;
13
+ if (!container || !items.length) return void setAutoPageSize(items.length || 1);
14
+ const width = container.offsetWidth || 0;
15
+ if (!width) return void setAutoPageSize(items.length || 1);
16
+ const pagerReserveWidth = 80;
17
+ const availableWidth = Math.max(0, width - pagerReserveWidth);
18
+ const estimatedItemWidths = items.map((item)=>{
19
+ const labelLength = item.label ? item.label.length : 0;
20
+ console.log("computePageSize: estimatedItemWidths:", item.label, labelLength);
21
+ const visibleChars = labelLength;
22
+ return 16 + 8 * visibleChars;
23
+ });
24
+ const avgItemWidth = estimatedItemWidths.reduce((sum, w)=>sum + w, 0) / estimatedItemWidths.length;
25
+ if (!avgItemWidth || !isFinite(avgItemWidth)) return void setAutoPageSize(items.length || 1);
26
+ const computed = Math.max(1, Math.floor(availableWidth / avgItemWidth));
27
+ console.log("computePageSize: computed:", computed, availableWidth, avgItemWidth, estimatedItemWidths);
28
+ setAutoPageSize(computed);
29
+ setPage((p)=>Math.min(p, Math.max(1, Math.ceil(items.length / computed))));
30
+ };
31
+ computePageSize();
32
+ window.addEventListener("resize", computePageSize);
33
+ return ()=>{
34
+ window.removeEventListener("resize", computePageSize);
35
+ };
36
+ }, [
37
+ items,
38
+ pageSizeProp,
39
+ maxLabelChars
40
+ ]);
41
+ const total = items.length;
42
+ const pageCount = Math.max(1, Math.ceil(total / autoPageSize));
43
+ const visibleItems = useMemo(()=>{
44
+ const start = (page - 1) * autoPageSize;
45
+ const end = start + autoPageSize;
46
+ return items.slice(start, end);
47
+ }, [
48
+ items,
49
+ page,
50
+ autoPageSize
51
+ ]);
52
+ const handleToggle = (id)=>{
53
+ const isActive = activeIds.includes(id);
54
+ const nextSet = new Set(isActive ? activeIds.filter((x)=>x !== id) : [
55
+ ...activeIds,
56
+ id
57
+ ]);
58
+ const next = items.map((item)=>item.id).filter((itemId)=>nextSet.has(itemId));
59
+ onChange(next);
60
+ };
61
+ const handlePrev = ()=>{
62
+ setPage((p)=>p > 1 ? p - 1 : p);
63
+ };
64
+ const handleNext = ()=>{
65
+ setPage((p)=>p < pageCount ? p + 1 : p);
66
+ };
67
+ return /*#__PURE__*/ jsxs("div", {
68
+ ref: containerRef,
69
+ style: {
70
+ display: "flex",
71
+ alignItems: "center",
72
+ justifyContent: "center",
73
+ gap: 8,
74
+ fontSize: 12,
75
+ color: "#4e5969",
76
+ ...style
77
+ },
78
+ children: [
79
+ /*#__PURE__*/ jsx("div", {
80
+ style: {
81
+ display: "flex",
82
+ flexWrap: "nowrap",
83
+ gap: 8,
84
+ maxWidth: "100%",
85
+ overflow: "hidden"
86
+ },
87
+ children: visibleItems.map((item)=>{
88
+ const isActive = activeIds.includes(item.id);
89
+ const baseColor = item.isCompare ? items.find((i)=>!i.isCompare)?.color : item.color;
90
+ const displayLabel = item.label;
91
+ const compareBg = `repeating-linear-gradient(-45deg,${baseColor} 0,${baseColor} 2px,#ffffff 2px, #ffffff 4px)`;
92
+ let marker = null;
93
+ marker = "square" === item.symbol ? /*#__PURE__*/ jsx("span", {
94
+ style: {
95
+ width: 10,
96
+ height: 10,
97
+ background: item.isCompare ? compareBg : item.color,
98
+ marginRight: 4
99
+ }
100
+ }) : "line" === item.symbol ? /*#__PURE__*/ jsx("span", {
101
+ style: {
102
+ width: 10,
103
+ height: 1,
104
+ borderBottom: item.isCompare ? `2px dotted ${item.color}` : `2px solid ${item.color}`,
105
+ marginRight: 4
106
+ }
107
+ }) : /*#__PURE__*/ jsx("span", {
108
+ style: {
109
+ width: 10,
110
+ height: 10,
111
+ borderRadius: "50%",
112
+ marginRight: 4,
113
+ boxSizing: "border-box",
114
+ background: item.isCompare ? compareBg : item.color
115
+ }
116
+ });
117
+ return /*#__PURE__*/ jsxs("div", {
118
+ onClick: ()=>handleToggle(item.id),
119
+ style: {
120
+ display: "inline-flex",
121
+ alignItems: "center",
122
+ padding: "2px 6px",
123
+ borderRadius: 4,
124
+ cursor: "pointer",
125
+ userSelect: "none",
126
+ opacity: isActive ? 1 : 0.5
127
+ },
128
+ children: [
129
+ marker,
130
+ /*#__PURE__*/ jsx(Tooltip, {
131
+ content: item.label,
132
+ disabled: true,
133
+ children: /*#__PURE__*/ jsx("span", {
134
+ style: {
135
+ overflow: "hidden",
136
+ textOverflow: "ellipsis",
137
+ whiteSpace: "nowrap"
138
+ },
139
+ children: displayLabel
140
+ })
141
+ })
142
+ ]
143
+ }, item.id);
144
+ })
145
+ }),
146
+ pageCount > 1 && /*#__PURE__*/ jsxs("div", {
147
+ style: {
148
+ display: "inline-flex",
149
+ alignItems: "center",
150
+ gap: 4,
151
+ marginLeft: 8,
152
+ whiteSpace: "nowrap"
153
+ },
154
+ children: [
155
+ /*#__PURE__*/ jsx("button", {
156
+ type: "button",
157
+ onClick: handlePrev,
158
+ disabled: 1 === page,
159
+ style: {
160
+ border: "1px solid #d0d4db",
161
+ backgroundColor: "#fff",
162
+ borderRadius: 2,
163
+ padding: "0 4px",
164
+ cursor: 1 === page ? "not-allowed" : "pointer"
165
+ },
166
+ children: "<"
167
+ }),
168
+ /*#__PURE__*/ jsxs("span", {
169
+ style: {
170
+ fontSize: 12
171
+ },
172
+ children: [
173
+ page,
174
+ "/",
175
+ pageCount
176
+ ]
177
+ }),
178
+ /*#__PURE__*/ jsx("button", {
179
+ type: "button",
180
+ onClick: handleNext,
181
+ disabled: page === pageCount,
182
+ style: {
183
+ border: "1px solid #d0d4db",
184
+ backgroundColor: "#fff",
185
+ borderRadius: 2,
186
+ padding: "0 4px",
187
+ cursor: page === pageCount ? "not-allowed" : "pointer"
188
+ },
189
+ children: ">"
190
+ })
191
+ ]
192
+ })
193
+ ]
194
+ });
195
+ };
196
+ export { G2BarLegend };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * G2@5 柱状+折线组合图组件
3
+ * 基于 G2LineChart / G2BarChart 架构:x 为分类轴,y 为柱状图数值,z 为折线图数值
4
+ * 支持双 Y 轴(柱左、线右)或共轴,数据标签、图例、Tooltip
5
+ */
6
+ import React from "react";
7
+ import type { BaseChartProps } from "../../../core/ChartTypes";
8
+ declare const G2CombineChart: React.FC<BaseChartProps>;
9
+ export default G2CombineChart;
@@ -0,0 +1,305 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import react_dom from "react-dom";
4
+ import { useChartContext } from "../../../core/ChartContext.js";
5
+ import { getAxisFormat } from "../../../utils/chartHelpers.js";
6
+ import { DataAdapter } from "../../../adapters/DataAdapter.js";
7
+ import { NodePopover } from "../../shared/NodePopover.js";
8
+ import { NodeDetail } from "../../shared/NodeDetail.js";
9
+ import G2CompareTooltip from "../shared/G2CompareTooltip.js";
10
+ import useG2TooltipContainer from "../shared/useG2TooltipContainer.js";
11
+ import { getIndicatorCompareName } from "../../../utils/indicatorHelpers.js";
12
+ import { renderG2CombineChart } from "./g2combine.js";
13
+ import { G2BarLegend } from "./G2BarLegend.js";
14
+ const transformDataToGroupBarLineFormat = (data, x = "groupName", y = "", indicators)=>{
15
+ if (!data || 0 === data.length) return [];
16
+ return data.map((item)=>{
17
+ const indicatorData = item?.indicatorData || {};
18
+ const baseKeys = indicators && indicators.length ? indicators : Object.keys(indicatorData).filter((key)=>!key.endsWith("_compare") && !key.endsWith("_change") && !key.endsWith("_compare_time"));
19
+ return baseKeys.flatMap((key, index)=>{
20
+ const indicatorValue = indicatorData[key];
21
+ const compareKey = `${key}_compare`;
22
+ const changeKey = `${key}_change`;
23
+ const compareTimeKey = `${key}_compare_time`;
24
+ const compareValue = indicatorData[compareKey];
25
+ const changeValue = indicatorData[changeKey];
26
+ const compareTimeValue = indicatorData[compareTimeKey];
27
+ const isCombineFlag = indicators && indicators.length ? 0 !== index : key !== y;
28
+ const commonBase = {
29
+ groupName: item[x],
30
+ percent: 1,
31
+ nodeInfos: item.nodeInfos
32
+ };
33
+ const rows = [];
34
+ rows.push({
35
+ ...commonBase,
36
+ groupType: key,
37
+ groupValue: indicatorValue,
38
+ isCombine: isCombineFlag,
39
+ total: indicatorValue,
40
+ change: changeValue
41
+ });
42
+ if (null != compareValue) rows.push({
43
+ ...commonBase,
44
+ groupType: compareKey,
45
+ groupValue: compareValue,
46
+ isCombine: isCombineFlag,
47
+ total: compareValue,
48
+ change: changeValue,
49
+ compareTime: compareTimeValue
50
+ });
51
+ return rows;
52
+ });
53
+ }).flat();
54
+ };
55
+ const lineColors = [
56
+ "#FE765E",
57
+ "#945FB9",
58
+ "#FF99C3"
59
+ ];
60
+ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap, onChartClick, legend = "", config, nodeSetting = {
61
+ showType: 0,
62
+ type: []
63
+ }, indicators = [], auxiliaryLineData, highlightDate, timeRange })=>{
64
+ const { formatter, dataTransform, config: contextConfig } = useChartContext();
65
+ const tooltipContainerRef = useG2TooltipContainer();
66
+ console.log("G2CombineChart props:", data, x, y, z, indicatorMap, indicators, legend, config, nodeSetting);
67
+ const themeColors = contextConfig?.theme?.colors || [];
68
+ const safeIndicatorMap = indicatorMap || contextConfig.indicatorMap || {};
69
+ const safeLegend = "groupType" !== legend ? legend || y : y;
70
+ const safeZ = z;
71
+ const safeY = "groupValue";
72
+ const isCompare = timeRange?.compareStartTime !== "";
73
+ const chartConfig = config || {};
74
+ const { isDataTag = false, isLegend = true } = chartConfig;
75
+ const [xyList, setXYList] = useState([]);
76
+ const [activeIds, setActiveIds] = useState([]);
77
+ const [legendItems, setLegendItems] = useState([]);
78
+ const transformedData = useMemo(()=>{
79
+ if (!legend) {
80
+ let result = transformDataToGroupBarLineFormat(data, x, y, indicators);
81
+ data = result;
82
+ }
83
+ console.log("G2CombineChart transformedData2:", data);
84
+ const result = DataAdapter.transform(data, "barLine", {
85
+ type: "barLine",
86
+ x,
87
+ y: safeY,
88
+ z
89
+ });
90
+ return result.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap));
91
+ }, [
92
+ data,
93
+ x,
94
+ safeY,
95
+ z,
96
+ dataTransform,
97
+ contextConfig.nodeMap
98
+ ]);
99
+ console.log("G2CombineChart transformedData:", transformedData);
100
+ const { maxY } = useMemo(()=>{
101
+ const yValues = transformedData.filter((item)=>"-" !== item[safeY] && void 0 !== item[safeY] && null !== item[safeY]).map((item)=>Number(item[safeY]) || 0);
102
+ return {
103
+ maxY: yValues.length > 0 ? Math.max(...yValues) : 0
104
+ };
105
+ }, [
106
+ transformedData,
107
+ safeY
108
+ ]);
109
+ const formatAxis = useCallback((val)=>getAxisFormat(val, safeIndicatorMap, safeLegend), [
110
+ safeIndicatorMap,
111
+ safeLegend
112
+ ]);
113
+ const formatLineAxis = useCallback((val)=>getAxisFormat(val, safeIndicatorMap, safeZ), [
114
+ safeIndicatorMap,
115
+ safeZ
116
+ ]);
117
+ useEffect(()=>{
118
+ if (!transformedData.length) {
119
+ setLegendItems([]);
120
+ setActiveIds([]);
121
+ return;
122
+ }
123
+ const groupTypes = Array.from(new Set(transformedData.map((d)=>d.groupType.replace("_compare", "") + "_" + d.isCombine).filter((v)=>null != v)));
124
+ const items = groupTypes.map((id, index)=>{
125
+ const colorIndex = index;
126
+ const indicatorId = id.split("_")[0];
127
+ const color = 0 === colorIndex ? themeColors[colorIndex] : lineColors[colorIndex - 1];
128
+ return {
129
+ id,
130
+ label: getIndicatorCompareName(safeIndicatorMap, String(indicatorId)) + (String(indicatorId).includes("_compare") ? `(对比时间:${timeRange?.compareStartTime}~${timeRange?.compareEndTime})` : ""),
131
+ color,
132
+ isCompare: String(indicatorId).includes("_compare"),
133
+ symbol: 0 === colorIndex ? "square" : "line"
134
+ };
135
+ });
136
+ setLegendItems(items);
137
+ if (!activeIds.length) setActiveIds(items.map((i)=>i.id));
138
+ }, [
139
+ transformedData,
140
+ safeIndicatorMap,
141
+ themeColors,
142
+ activeIds.length
143
+ ]);
144
+ const filteredData = useMemo(()=>{
145
+ if (!activeIds.length) return transformedData;
146
+ return transformedData.filter((d)=>d.groupType ? activeIds.includes(String(d.groupType.replace("_compare", "") + "_" + d.isCombine)) : true);
147
+ }, [
148
+ transformedData,
149
+ activeIds
150
+ ]);
151
+ const canvasMarginBottom = legendItems.length > 1 ? 2 === nodeSetting.showType ? 32 : 16 : 0;
152
+ const containerRef = useRef(null);
153
+ const chartRef = useRef(null);
154
+ const [viewWidth, setViewWidth] = useState(0);
155
+ const [viewOffset, setViewOffset] = useState(0);
156
+ useEffect(()=>{
157
+ if (!containerRef.current || !transformedData.length || !y) return;
158
+ if (!z) return;
159
+ if (chartRef.current) {
160
+ chartRef.current.destroy();
161
+ chartRef.current = null;
162
+ }
163
+ console.log("canvasMarginBottom:", canvasMarginBottom);
164
+ const chart = renderG2CombineChart(containerRef.current, {
165
+ data: filteredData,
166
+ x,
167
+ y: safeY,
168
+ z,
169
+ maxY,
170
+ themeColors,
171
+ indicatorMap: safeIndicatorMap,
172
+ formatAxis,
173
+ formatLineAxis,
174
+ isDataTag,
175
+ isLegend: false,
176
+ isCompare,
177
+ height: height - canvasMarginBottom,
178
+ formatLabel: isDataTag ? (d)=>{
179
+ const indicatorId = d.groupType.split("_")[0];
180
+ return "-" === formatter.formatIndicator(d.groupValue, safeIndicatorMap[indicatorId]) ? "" : formatter.formatIndicator(d.groupValue, safeIndicatorMap[indicatorId]);
181
+ } : void 0,
182
+ indicators,
183
+ tooltipRender: (title, items)=>{
184
+ const container = tooltipContainerRef.current;
185
+ if (!container) return null;
186
+ let safeItems = items.map((i)=>({
187
+ ...i,
188
+ color: i.color ?? themeColors[0] ?? "#5B8FF9"
189
+ }));
190
+ console.log("safeItems:", safeItems);
191
+ react_dom.render(/*#__PURE__*/ jsx(G2CompareTooltip, {
192
+ title: title,
193
+ items: safeItems,
194
+ safeIndicatorMap: safeIndicatorMap,
195
+ formatter: formatter,
196
+ safeLegend: safeLegend,
197
+ auxiliaryLineData: auxiliaryLineData
198
+ }), container);
199
+ return container;
200
+ },
201
+ highlightDate: highlightDate ?? [],
202
+ timeRange,
203
+ onNodeListChange: (nodes)=>{
204
+ setXYList(nodes);
205
+ },
206
+ onChartRender: (chartProps)=>{
207
+ const layout = chartProps?.layout;
208
+ if (layout) {
209
+ setViewWidth(layout.innerWidth ?? 0);
210
+ setViewOffset((layout.paddingLeft ?? 0) + (layout.marginLeft ?? 0));
211
+ }
212
+ },
213
+ lineColors
214
+ });
215
+ chartRef.current = chart;
216
+ if (onChartClick) chart.on("element:click", (e)=>{
217
+ const datum = e.data?.data;
218
+ if (datum) onChartClick(datum);
219
+ });
220
+ return ()=>{
221
+ if (chartRef.current) {
222
+ chartRef.current.off("element:click");
223
+ chartRef.current.destroy();
224
+ chartRef.current = null;
225
+ }
226
+ };
227
+ }, [
228
+ filteredData,
229
+ height,
230
+ x,
231
+ y,
232
+ z,
233
+ maxY,
234
+ isDataTag,
235
+ isLegend,
236
+ themeColors,
237
+ safeIndicatorMap,
238
+ formatter,
239
+ formatAxis,
240
+ onChartClick
241
+ ]);
242
+ if (!z) return /*#__PURE__*/ jsx("div", {
243
+ style: {
244
+ width: "100%",
245
+ color: "#86909c",
246
+ padding: 16
247
+ },
248
+ children: "请传入 z 作为折线指标字段,以展示柱状+折线组合图。"
249
+ });
250
+ return /*#__PURE__*/ jsxs("div", {
251
+ style: {
252
+ width: "100%",
253
+ position: "relative"
254
+ },
255
+ children: [
256
+ isLegend && legendItems.length > 1 && 2 === nodeSetting.showType && /*#__PURE__*/ jsx(G2BarLegend, {
257
+ items: legendItems,
258
+ activeIds: activeIds,
259
+ onChange: setActiveIds,
260
+ style: {
261
+ marginBottom: 8
262
+ }
263
+ }),
264
+ /*#__PURE__*/ jsx("div", {
265
+ ref: containerRef,
266
+ style: {
267
+ width: "100%",
268
+ height: `${height - canvasMarginBottom}px`
269
+ }
270
+ }),
271
+ isLegend && legendItems.length > 1 && 2 !== nodeSetting.showType && /*#__PURE__*/ jsx(G2BarLegend, {
272
+ items: legendItems,
273
+ activeIds: activeIds,
274
+ onChange: setActiveIds,
275
+ style: {
276
+ marginBottom: 8
277
+ }
278
+ }),
279
+ 2 !== nodeSetting.showType ? /*#__PURE__*/ jsx("div", {
280
+ children: xyList?.map((item, index)=>/*#__PURE__*/ jsx(NodePopover, {
281
+ style: {
282
+ position: "absolute",
283
+ top: item.pointP?.y + 10,
284
+ left: item.pointP?.x,
285
+ width: 12,
286
+ height: 12,
287
+ borderRadius: "50%",
288
+ transform: "translate(-50%, 0%)",
289
+ background: item?.color,
290
+ zIndex: 999
291
+ },
292
+ pointP: item.pointP,
293
+ pointData: item.pointData
294
+ }, index))
295
+ }) : /*#__PURE__*/ jsx(NodeDetail, {
296
+ chartWidth: viewWidth,
297
+ chartOffset: viewOffset,
298
+ dvRows: transformedData.filter((item)=>!item.isCombine),
299
+ ratio: isCompare ? 2 : 1
300
+ })
301
+ ]
302
+ });
303
+ };
304
+ const base_G2CombineChart = G2CombineChart;
305
+ export { base_G2CombineChart as default };
@@ -219,7 +219,9 @@ const G2GaugeChart = (props)=>{
219
219
  const valueText = document.createElementNS('http://www.w3.org/2000/svg', 'text');
220
220
  valueText.setAttribute('x', String(textCenterX));
221
221
  valueText.setAttribute('y', String(valueTextY));
222
- valueText.setAttribute('fill', colors[0] || '#9596d9');
222
+ const thresholdIndex = thresholdValues.findIndex((threshold)=>value <= threshold);
223
+ const thresholdColor = thresholdColorArray[thresholdIndex] || '#9596d9';
224
+ valueText.setAttribute('fill', thresholdColor);
223
225
  valueText.setAttribute('font-size', String(valueFontSize));
224
226
  valueText.setAttribute('font-weight', 'bold');
225
227
  valueText.setAttribute('text-anchor', 'middle');
@@ -0,0 +1,9 @@
1
+ /**
2
+ * G2@5 堆积图组件
3
+ * 绘制逻辑复用 g2bar.renderG2BarChart,数据与 React 层(Context、Tooltip)在此组件内处理
4
+ * 支持单指标柱状、横向/纵向、升序/降序、数据标签、图例、辅助线
5
+ */
6
+ import React from "react";
7
+ import type { BaseChartProps } from "../../../core/ChartTypes";
8
+ declare const G2GroupBarChart: React.FC<BaseChartProps>;
9
+ export default G2GroupBarChart;