@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,188 @@
1
+ import { lines } from "@antv/g-pattern";
2
+ import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyScaleYLinear, createChart, getMainView } from "./g2Helpers.js";
3
+ const Y_AXIS_FIELD = 'groupValue';
4
+ function renderG2GroupBarChart(container, options) {
5
+ const { data, x, y, maxY, timeRange: _timeRange, themeColors, indicators: _indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], isDataTag = false, isLegend = true, isHorizontal = false, isHighlight = true, isCompare: _isCompare = false, legend, formatLabel, height = 300, tooltipRender, auxiliaryLineData = [], onNodeListChange, legendItems = [], indicatorId } = options;
6
+ const chart = createChart({
7
+ container,
8
+ height,
9
+ autoFit: true
10
+ });
11
+ chart.options({
12
+ marginBottom: 0,
13
+ paddingBottom: 0,
14
+ insetBottom: 0
15
+ });
16
+ console.log('isLegend:', legend, isLegend);
17
+ const view = getMainView(chart);
18
+ view.attr('marginBottom', isLegend ? 0 : 16);
19
+ if (isHorizontal) view.coordinate({
20
+ transform: [
21
+ {
22
+ type: 'transpose'
23
+ }
24
+ ]
25
+ });
26
+ console.log(legendItems, 'legendItems');
27
+ view.data(data);
28
+ applyScaleYLinear(view, {
29
+ field: 'y',
30
+ domainMin: 0,
31
+ domainMax: maxY,
32
+ nice: true,
33
+ clamp: true
34
+ });
35
+ if (isHighlight) applyHighlightDate(view, x, data, highlightDate);
36
+ const interval = view.interval().encode('x', x).encode('y', y).encode('color', 'groupType').transform({
37
+ type: 'stackY',
38
+ reverse: true
39
+ }).style({
40
+ columnWidthRatio: 0.5,
41
+ fill: (datum)=>{
42
+ const groupType = String(datum.groupType ?? '');
43
+ const index = legendItems.findIndex((item)=>item.id === groupType);
44
+ if (groupType.includes('_compare')) return {
45
+ image: lines({
46
+ backgroundColor: '#fff',
47
+ backgroundOpacity: 0.65,
48
+ stroke: '#6aa1ff',
49
+ lineWidth: 3,
50
+ spacing: 3
51
+ }),
52
+ repetition: 'repeat',
53
+ transform: 'rotate(-30deg)'
54
+ };
55
+ return themeColors[index % themeColors.length] ?? themeColors[0] ?? "#5B8FF9";
56
+ }
57
+ });
58
+ applyAxisX(view, {
59
+ title: false,
60
+ grid: false
61
+ });
62
+ applyAxisY(view, {
63
+ title: false,
64
+ grid: true,
65
+ gridLineDash: [
66
+ 0,
67
+ 0
68
+ ],
69
+ labelFormatter: formatAxis
70
+ });
71
+ view.legend(false);
72
+ interval.tooltip({
73
+ items: [
74
+ (datum)=>{
75
+ const groupType = String(datum.groupType ?? '');
76
+ const index = legendItems.findIndex((item)=>item.id === groupType);
77
+ return {
78
+ value: datum[Y_AXIS_FIELD],
79
+ name: datum['groupType'],
80
+ indicatorId,
81
+ channel: Y_AXIS_FIELD,
82
+ color: themeColors[index % themeColors.length] ?? themeColors[0] ?? "#5B8FF9",
83
+ percent: `${(100 * Number(datum.percent)).toFixed(2)}%`
84
+ };
85
+ }
86
+ ].filter(Boolean)
87
+ });
88
+ if (tooltipRender) interval.interaction('tooltip', {
89
+ shared: true,
90
+ render: (_event, payload)=>{
91
+ const { title, items } = payload;
92
+ const lastIsChange = items.filter((item)=>item.isChange);
93
+ let safeItems = items;
94
+ if (lastIsChange.length > 0) safeItems = [
95
+ ...items.filter((item)=>!item.isChange),
96
+ lastIsChange[lastIsChange.length - 1]
97
+ ];
98
+ return tooltipRender(title, safeItems ?? []) ?? null;
99
+ }
100
+ });
101
+ else view.interaction('tooltip', true);
102
+ applyAuxiliaryLineY(view, auxiliaryLineData);
103
+ const nodeList = [];
104
+ console.log('nodeList data:', data);
105
+ data.forEach((item)=>{
106
+ view.shape().data([
107
+ {
108
+ [x]: item[x],
109
+ [y]: 0
110
+ }
111
+ ]).encode('x', x).encode('y', y).tooltip(false).style({
112
+ render: ({ x: px, y: py }, context)=>{
113
+ const { document } = context;
114
+ const g = document.createElement('g', {});
115
+ const { paddingLeft = 24, marginLeft = 12 } = context?.coordinate?.options || {};
116
+ const adjustLeft = paddingLeft + marginLeft;
117
+ if (item.nodeInfos?.info?.length > 0 || item.nodeInfos?.infosCompare?.length > 0) {
118
+ nodeList.push({
119
+ pointP: {
120
+ x: px + adjustLeft,
121
+ y: py
122
+ },
123
+ pointData: item.nodeInfos || {},
124
+ color: item.color
125
+ });
126
+ const c1 = document.createElement('circle', {
127
+ style: {
128
+ cx: px,
129
+ cy: py,
130
+ r: 2,
131
+ fill: 'white'
132
+ }
133
+ });
134
+ const c2 = document.createElement('circle', {
135
+ style: {
136
+ cx: px,
137
+ cy: py,
138
+ r: 5,
139
+ fill: item.color
140
+ }
141
+ });
142
+ g.appendChild(c2);
143
+ g.appendChild(c1);
144
+ }
145
+ return g;
146
+ }
147
+ });
148
+ });
149
+ if (isDataTag && formatLabel) {
150
+ const groupedByX = data.reduce((acc, item)=>{
151
+ const key = item[x];
152
+ if (!acc[key]) acc[key] = [];
153
+ acc[key].push(item);
154
+ return acc;
155
+ }, {});
156
+ const lastItemsInEachStack = new Set();
157
+ Object.values(groupedByX).forEach((group)=>{
158
+ group.sort((a, b)=>a[y] - b[y]);
159
+ const lastItem = group[group.length - 1];
160
+ lastItemsInEachStack.add(lastItem);
161
+ });
162
+ interval.label({
163
+ text: (d)=>{
164
+ if (lastItemsInEachStack.has(d)) return formatLabel(d);
165
+ return '';
166
+ },
167
+ position: isHorizontal ? 'right' : 'top',
168
+ offset: 0,
169
+ dy: isHorizontal ? 0 : -18,
170
+ dx: isHorizontal ? 5 : 0,
171
+ textAlign: isHorizontal ? 'left' : 'center',
172
+ transform: [
173
+ {
174
+ type: 'exceedAdjust'
175
+ }
176
+ ]
177
+ });
178
+ }
179
+ chart.render();
180
+ let hasEmittedNodeList = false;
181
+ chart.on('afterrender', ()=>{
182
+ if (hasEmittedNodeList) return;
183
+ if (onNodeListChange) onNodeListChange(nodeList);
184
+ hasEmittedNodeList = true;
185
+ });
186
+ return chart;
187
+ }
188
+ export { renderG2GroupBarChart };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * G2 折线图函数式 API
3
+ * 复用 g2Helpers 的 createChart、scale、axis、legend、auxiliary、getColorByGroupType
4
+ */
5
+ import { type AuxiliaryLineItem } from './g2Helpers';
6
+ import { ChartTimeRange } from '../../../core/ChartTypes';
7
+ export interface RenderG2LineChartOptions {
8
+ /** 已转换后的数据(含 groupValue,groupType 可能带 _compare) */
9
+ data: any[];
10
+ /** X 轴字段,如 groupName */
11
+ x: string;
12
+ /** 主指标 key,用于取色与图例 */
13
+ y: string;
14
+ /** Y 轴最小值,用于 scale domainMin(不传则用 0) */
15
+ minY?: number;
16
+ /** Y 轴最大值,用于 scale domainMax */
17
+ maxY: number;
18
+ /** 时间范围 */
19
+ timeRange?: ChartTimeRange;
20
+ /** Y 轴刻度数量,默认 5 */
21
+ yTickCount?: number;
22
+ /** 为 true 时设置 minLimit/maxLimit,使刻度在 [minY, maxY] 上均匀且恰好为 yTickCount 个(类 linear-strict) */
23
+ useStrictTicks?: boolean;
24
+ /** 主题色数组 */
25
+ themeColors: string[];
26
+ /** 多指标 id 列表,用于按顺序取色 */
27
+ indicators?: string[];
28
+ /** 指标名映射,图例文案 indicatorMap[id]?.indicatorName */
29
+ indicatorMap?: Record<string, {
30
+ indicatorName?: string;
31
+ }>;
32
+ /** Y 轴刻度格式化 */
33
+ formatAxis?: (val: any) => string;
34
+ /** 高亮日期,用于 x 轴 gridFilter */
35
+ highlightDate?: string[];
36
+ /** 辅助线 */
37
+ auxiliaryLineData?: AuxiliaryLineItem[];
38
+ /** 是否显示数据标签 */
39
+ isDataTag?: boolean;
40
+ /** 是否显示图例 */
41
+ isLegend?: boolean;
42
+ /** 是否启用图例高亮 */
43
+ isHighlight?: boolean;
44
+ /** 数据标签格式化:formatLabel(datum) */
45
+ formatLabel?: (datum: any) => string;
46
+ /** 图表高度 */
47
+ height?: number;
48
+ /** 图例宽度(像素,position 为 bottom 时生效) */
49
+ legendLength?: number;
50
+ /** 图例区域高度(像素,可选) */
51
+ legendSize?: number;
52
+ /** Tooltip 自定义渲染:返回挂载的 DOM,由调用方(如 React)注入 */
53
+ tooltipRender?: (title: string, items: Array<{
54
+ color?: string;
55
+ name: string;
56
+ value: any;
57
+ isChange?: boolean;
58
+ compareTime?: string;
59
+ }>) => HTMLElement | null;
60
+ /** 将计算出的节点信息传递给外层(用于渲染 NodePopover 等) */
61
+ onNodeListChange?: (nodes: Array<{
62
+ pointP: {
63
+ x: number;
64
+ y: number;
65
+ };
66
+ pointData: any;
67
+ color: string;
68
+ }>) => void;
69
+ /** 图表首次渲染完成后回调,用于 NodeDetail 获取绘图区宽高与偏移 */
70
+ onChartRender?: (chartProps: {
71
+ layout: any;
72
+ }) => void;
73
+ }
74
+ /**
75
+ * 在容器上渲染 G2 折线图(当期线 + 对比线 + 坐标轴 + 图例 + 辅助线),返回 Chart 实例便于 destroy/更新
76
+ */
77
+ export declare function renderG2LineChart(container: HTMLElement, options: RenderG2LineChartOptions): any;
@@ -0,0 +1,208 @@
1
+ import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyScaleYLinear, createChart, getColorByGroupType, getMainView } from "./g2Helpers.js";
2
+ const Y_AXIS_FIELD = 'groupValue';
3
+ function renderG2LineChart(container, options) {
4
+ const { data, 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
+ const colorOpts = {
7
+ themeColors,
8
+ primaryKey: y,
9
+ indicators
10
+ };
11
+ const chart = createChart({
12
+ container,
13
+ height,
14
+ autoFit: true
15
+ });
16
+ chart.options({
17
+ marginBottom: 0,
18
+ paddingBottom: 0,
19
+ insetBottom: 0
20
+ });
21
+ const view = getMainView(chart);
22
+ view.attr('marginBottom', isLegend ? 0 : 16);
23
+ view.data(data);
24
+ const domainMin = minY ?? 0;
25
+ applyScaleYLinear(view, {
26
+ field: 'y',
27
+ domainMin,
28
+ domainMax: maxY,
29
+ nice: true,
30
+ clamp: true
31
+ });
32
+ console.log('g2linets:', x, Y_AXIS_FIELD, data);
33
+ const line = view.line().data(data.filter((item)=>!item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').style({
34
+ lineWidth: 2,
35
+ stroke: (_datum, index)=>themeColors[index] ?? themeColors[0]
36
+ });
37
+ const compareLine = view.line().data(data.filter((item)=>item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').style({
38
+ lineDash: [
39
+ 4,
40
+ 4
41
+ ],
42
+ lineWidth: 2,
43
+ stroke: (_datum, index)=>themeColors[index] ?? themeColors[0]
44
+ });
45
+ applyAxisX(view, {
46
+ title: false,
47
+ grid: true,
48
+ gridStroke: '#333',
49
+ gridLineWidth: 50,
50
+ gridLineDash: [
51
+ 1000
52
+ ],
53
+ gridFilter: highlightDate.length > 0 && isHighlight ? (val)=>highlightDate.includes(val?.label) : ()=>false
54
+ });
55
+ applyAxisY(view, {
56
+ title: false,
57
+ grid: true,
58
+ gridStrokeOpacity: 0.2,
59
+ gridLineDash: [
60
+ 0,
61
+ 0
62
+ ],
63
+ labelFormatter: formatAxis
64
+ });
65
+ line.tooltip({
66
+ items: [
67
+ (datum)=>({
68
+ value: datum[Y_AXIS_FIELD],
69
+ name: datum['groupType'],
70
+ indicatorId: datum['groupType'],
71
+ channel: Y_AXIS_FIELD,
72
+ color: getColorByGroupType(datum['groupType'], colorOpts) || 'transparent'
73
+ })
74
+ ]
75
+ });
76
+ const hasCompareData = data.some((item)=>item.groupType.includes('_compare'));
77
+ console.log('hasCompareData:', hasCompareData, data);
78
+ if (hasCompareData) compareLine.tooltip({
79
+ items: [
80
+ (datum)=>({
81
+ value: datum[Y_AXIS_FIELD],
82
+ compareTime: datum?.compareTime,
83
+ name: datum['groupType'],
84
+ indicatorId: datum['groupType'].replace('_compare', ''),
85
+ channel: Y_AXIS_FIELD,
86
+ color: getColorByGroupType(datum['groupType'], colorOpts) || 'transparent'
87
+ }),
88
+ (datum)=>({
89
+ name: datum['groupType'].replace('_compare', '_change'),
90
+ indicatorId: datum['groupType'].replace('_compare', ''),
91
+ value: datum?.change,
92
+ isChange: true,
93
+ color: 'transparent'
94
+ })
95
+ ]
96
+ });
97
+ if (tooltipRender) line.interaction('tooltip', {
98
+ shared: true,
99
+ crosshairsY: true,
100
+ marker: false,
101
+ render: (_event, payload)=>{
102
+ const { title, items } = payload;
103
+ console.log('tooltipRender:', title, items, indicators);
104
+ if (indicators.length) {
105
+ const groupedItems = indicators.map((indicator)=>items.filter((i)=>i.indicatorId === String(indicator)));
106
+ console.log(groupedItems.flat(), 'tooltip groupedItems');
107
+ const sortedItems = groupedItems.map((group)=>[
108
+ group.filter((i)=>i.name === i.indicatorId),
109
+ group.filter((i)=>i.compareTime),
110
+ group.filter((i)=>i.name.includes('_change'))
111
+ ].filter(Boolean).flat()).flat();
112
+ console.log(sortedItems, 'tooltip sortedItems');
113
+ const formatItems = sortedItems.map((item)=>({
114
+ ...item,
115
+ color: getColorByGroupType(item?.indicatorId, colorOpts)
116
+ }));
117
+ return tooltipRender(title, formatItems ?? []) ?? null;
118
+ }
119
+ {
120
+ const newItems = items.map((item)=>({
121
+ ...item,
122
+ color: getColorByGroupType(item?.indicatorId, colorOpts)
123
+ }));
124
+ return tooltipRender(title, newItems ?? []) ?? null;
125
+ }
126
+ }
127
+ });
128
+ view.legend(false);
129
+ applyAuxiliaryLineY(view, auxiliaryLineData);
130
+ const nodeList = [];
131
+ console.log('nodeList data:', data);
132
+ data.forEach((item)=>{
133
+ view.shape().data([
134
+ {
135
+ [x]: item[x],
136
+ [y]: 0
137
+ }
138
+ ]).encode('x', x).encode('y', y).tooltip(false).style({
139
+ render: ({ x: px, y: py }, context)=>{
140
+ const { document } = context;
141
+ const g = document.createElement('g', {});
142
+ const { paddingLeft = 24, marginLeft = 12 } = context?.coordinate?.options || {};
143
+ const adjustLeft = paddingLeft + marginLeft;
144
+ if (item.nodeInfos?.info?.length > 0 || item.nodeInfos?.infosCompare?.length > 0) {
145
+ nodeList.push({
146
+ pointP: {
147
+ x: px + adjustLeft,
148
+ y: py
149
+ },
150
+ pointData: item.nodeInfos || {},
151
+ color: item.color
152
+ });
153
+ const c1 = document.createElement('circle', {
154
+ style: {
155
+ cx: px,
156
+ cy: py,
157
+ r: 2,
158
+ fill: 'white'
159
+ }
160
+ });
161
+ const c2 = document.createElement('circle', {
162
+ style: {
163
+ cx: px,
164
+ cy: py,
165
+ r: 5,
166
+ fill: item.color
167
+ }
168
+ });
169
+ g.appendChild(c2);
170
+ g.appendChild(c1);
171
+ }
172
+ return g;
173
+ }
174
+ });
175
+ });
176
+ if (isDataTag && formatLabel) {
177
+ line.label({
178
+ dy: -10,
179
+ dx: -10,
180
+ offset: 0,
181
+ text: (d)=>formatLabel(d)
182
+ });
183
+ compareLine.label({
184
+ dy: -10,
185
+ dx: -10,
186
+ offset: 0,
187
+ text: (d)=>formatLabel(d)
188
+ });
189
+ view.labelTransform([
190
+ {
191
+ type: 'overlapDodgeY'
192
+ }
193
+ ]);
194
+ }
195
+ chart.render();
196
+ let hasEmittedNodeList = false;
197
+ chart.on('afterrender', ()=>{
198
+ if (hasEmittedNodeList) return;
199
+ if (onNodeListChange) onNodeListChange(nodeList);
200
+ const viewLayout = chart.getContext()?.views?.[0]?.layout;
201
+ if (onChartRender && viewLayout) onChartRender({
202
+ layout: viewLayout
203
+ });
204
+ hasEmittedNodeList = true;
205
+ });
206
+ return chart;
207
+ }
208
+ export { renderG2LineChart };
@@ -0,0 +1,23 @@
1
+ type Item = {
2
+ color?: string;
3
+ name?: string;
4
+ value?: string | number;
5
+ isChange?: undefined | boolean;
6
+ compareTime?: undefined | string;
7
+ indicatorId?: string;
8
+ percent?: string | number;
9
+ };
10
+ interface Props {
11
+ isGroupBar?: boolean;
12
+ title: string;
13
+ items: Item[];
14
+ safeIndicatorMap: any;
15
+ formatter: any;
16
+ safeLegend: string;
17
+ auxiliaryLineData: undefined | {
18
+ name: string;
19
+ value: string | number;
20
+ }[];
21
+ }
22
+ declare const _default: import("react").NamedExoticComponent<Props>;
23
+ export default _default;
@@ -0,0 +1,93 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { CompareChange } from "@publishfx/publish-components";
4
+ import { getIndicatorCompareName } from "../../../utils/indicatorHelpers.js";
5
+ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap, formatter, safeLegend, auxiliaryLineData })=>{
6
+ let auxiIndicatorId = "";
7
+ const uniqueColors = [];
8
+ return /*#__PURE__*/ jsxs("div", {
9
+ style: {
10
+ padding: "0"
11
+ },
12
+ children: [
13
+ /*#__PURE__*/ jsx("div", {
14
+ children: title
15
+ }),
16
+ items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent }, index)=>{
17
+ let isFirst = false;
18
+ if (0 === index) auxiIndicatorId = indicatorId ?? "";
19
+ if (color && !uniqueColors.includes(color)) {
20
+ isFirst = true;
21
+ uniqueColors.push(color);
22
+ }
23
+ return /*#__PURE__*/ jsxs("div", {
24
+ style: {
25
+ display: "flex",
26
+ justifyContent: "space-between",
27
+ lineHeight: "12px",
28
+ marginTop: index ? "10px" : "5px"
29
+ },
30
+ children: [
31
+ /*#__PURE__*/ jsxs("div", {
32
+ children: [
33
+ /*#__PURE__*/ jsx("span", {
34
+ style: {
35
+ display: "inline-block",
36
+ width: "8px",
37
+ height: "8px",
38
+ marginRight: "5px",
39
+ backgroundColor: isFirst ? color : "transparent",
40
+ borderRadius: "50%"
41
+ }
42
+ }),
43
+ isChange ? "相比变化" : compareTime ? `${getIndicatorCompareName(safeIndicatorMap, indicatorId ?? '')}(${compareTime})` : isGroupBar ? name : `${getIndicatorCompareName(safeIndicatorMap, indicatorId ?? '')}`,
44
+ ":"
45
+ ]
46
+ }),
47
+ /*#__PURE__*/ jsxs("div", {
48
+ style: {
49
+ paddingLeft: "10px",
50
+ fontWeight: "bold"
51
+ },
52
+ children: [
53
+ isChange ? /*#__PURE__*/ jsx(CompareChange, {
54
+ value: value ?? 0,
55
+ fontSize: 12
56
+ }) : formatter.formatIndicator(value, safeIndicatorMap[indicatorId ?? ""] ?? {}),
57
+ percent && `(${percent})`
58
+ ]
59
+ })
60
+ ]
61
+ }, index);
62
+ }),
63
+ auxiliaryLineData?.map(({ name, value }, index)=>{
64
+ console.log("auxiliaryLineData:", name, value, safeLegend);
65
+ return /*#__PURE__*/ jsxs("div", {
66
+ style: {
67
+ display: "flex",
68
+ justifyContent: "space-between",
69
+ lineHeight: "12px",
70
+ marginTop: "10px",
71
+ marginLeft: "13px"
72
+ },
73
+ children: [
74
+ /*#__PURE__*/ jsxs("div", {
75
+ style: {
76
+ marginRight: "8px"
77
+ },
78
+ children: [
79
+ name,
80
+ ":"
81
+ ]
82
+ }),
83
+ /*#__PURE__*/ jsx("div", {
84
+ children: formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ""] ?? {})
85
+ })
86
+ ]
87
+ }, index);
88
+ })
89
+ ]
90
+ });
91
+ };
92
+ const shared_G2CompareTooltip = /*#__PURE__*/ memo(G2CompareTooltip);
93
+ export { shared_G2CompareTooltip as default };
@@ -0,0 +1 @@
1
+ export default function useG2TooltipContainer(): import("react").MutableRefObject<HTMLDivElement | null>;
@@ -0,0 +1,16 @@
1
+ import { useEffect, useRef } from "react";
2
+ import react_dom from "react-dom";
3
+ function useG2TooltipContainer() {
4
+ const ref = useRef(null);
5
+ useEffect(()=>{
6
+ ref.current = document.createElement('div');
7
+ return ()=>{
8
+ if (ref.current) {
9
+ react_dom.unmountComponentAtNode(ref.current);
10
+ ref.current = null;
11
+ }
12
+ };
13
+ }, []);
14
+ return ref;
15
+ }
16
+ export { useG2TooltipContainer as default };
@@ -12,7 +12,7 @@ const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>{
12
12
  width: chartWidth,
13
13
  lineHeight: '14px',
14
14
  cursor: 'pointer',
15
- position: 'absolute',
15
+ position: 'relative',
16
16
  bottom: -20,
17
17
  left: chartOffset
18
18
  },
@@ -17,6 +17,7 @@ type NodePopoverProps = {
17
17
  x: number;
18
18
  y: number;
19
19
  };
20
+ style?: React.CSSProperties;
20
21
  };
21
22
  export declare const NodePopover: React.FC<NodePopoverProps>;
22
23
  export {};
@@ -2,7 +2,7 @@ import { Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { Popover } from "@arco-design/web-react";
4
4
  import { NodePopoverContent } from "./NodePopoverContent.js";
5
- const NodePopover = ({ pointData, pointP })=>{
5
+ const NodePopover = ({ style, pointData, pointP })=>{
6
6
  const [nodeInfos, setNodeInfos] = useState([]);
7
7
  useEffect(()=>{
8
8
  setNodeInfos([
@@ -32,7 +32,8 @@ const NodePopover = ({ pointData, pointP })=>{
32
32
  left: pointP.x - 10,
33
33
  zIndex: 999,
34
34
  width: 20,
35
- height: 20
35
+ height: 20,
36
+ ...style
36
37
  }
37
38
  })
38
39
  })
@@ -43,6 +43,10 @@ export interface ChartComponentConfig {
43
43
  isClickable?: boolean;
44
44
  isHorizontal?: boolean;
45
45
  isHighlight?: boolean;
46
+ innerRadius?: number;
47
+ outerRadius?: number;
48
+ minLabelPercentage?: number;
49
+ showOnlyLegend?: boolean;
46
50
  }
47
51
  /**
48
52
  * 辅助线数据
package/dist/index.d.ts CHANGED
@@ -21,9 +21,14 @@ export { default as GroupLineCompare } from './components/composite/GroupLineCom
21
21
  export { default as MultipleLine } from './components/composite/MultipleLine';
22
22
  export { default as MultipleCompareLine } from './components/composite/MultipleCompareLine';
23
23
  export { default as G2BarChart } from './components/g2/base/G2BarChart';
24
+ export { default as G2GroupBarChart } from './components/g2/base/G2GroupBarChart';
24
25
  export { default as G2LineChart } from './components/g2/base/G2LineChart';
26
+ export { default as G2CombineChart } from './components/g2/base/G2CombineChart';
27
+ export { default as G2PieChart } from './components/g2/base/G2PieChart';
25
28
  export { default as G2GaugeChart } from './components/g2/base/G2GaugeChart';
26
29
  export type { G2GaugeChartProps } from './components/g2/base/G2GaugeChart';
30
+ export { default as G2IndicatorCardChart } from './components/g2/base/G2IndicatorCardChart';
31
+ export type { IndicatorCardChartProps } from './components/g2/base/G2IndicatorCardChart';
27
32
  export { createLazyComponent, createLazyComponents } from './utils/lazyHelpers';
28
33
  export { TypeAdapter } from './adapters/TypeAdapter';
29
34
  export { DataAdapter } from './adapters/DataAdapter';