@publishfx/publish-chart 1.3.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 (66) hide show
  1. package/README.md +143 -0
  2. package/dist/adapters/DataAdapter.d.ts +33 -0
  3. package/dist/adapters/DataAdapter.js +75 -0
  4. package/dist/adapters/TypeAdapter.d.ts +40 -0
  5. package/dist/adapters/TypeAdapter.js +26 -0
  6. package/dist/components/base/BarChart.d.ts +7 -0
  7. package/dist/components/base/BarChart.js +362 -0
  8. package/dist/components/base/BarChart.lazy.d.ts +5 -0
  9. package/dist/components/base/BarChart.lazy.js +2 -0
  10. package/dist/components/base/LineChart.d.ts +7 -0
  11. package/dist/components/base/LineChart.js +321 -0
  12. package/dist/components/base/LineChart.lazy.d.ts +5 -0
  13. package/dist/components/base/LineChart.lazy.js +2 -0
  14. package/dist/components/composite/BarLineAdapter.d.ts +22 -0
  15. package/dist/components/composite/BarLineAdapter.js +61 -0
  16. package/dist/components/composite/BarLineAdapter.lazy.d.ts +5 -0
  17. package/dist/components/composite/BarLineAdapter.lazy.js +2 -0
  18. package/dist/components/composite/BarLineChart.d.ts +7 -0
  19. package/dist/components/composite/BarLineChart.js +255 -0
  20. package/dist/components/composite/BarLineChart.lazy.d.ts +5 -0
  21. package/dist/components/composite/BarLineChart.lazy.js +2 -0
  22. package/dist/components/composite/BarLineCompareWeekend.d.ts +10 -0
  23. package/dist/components/composite/BarLineCompareWeekend.js +502 -0
  24. package/dist/components/composite/GroupBarLine.d.ts +11 -0
  25. package/dist/components/composite/GroupBarLine.js +546 -0
  26. package/dist/components/composite/GroupBarLine.lazy.d.ts +5 -0
  27. package/dist/components/composite/GroupBarLine.lazy.js +2 -0
  28. package/dist/components/composite/GroupCompare.d.ts +10 -0
  29. package/dist/components/composite/GroupCompare.js +620 -0
  30. package/dist/components/shared/AuxiliaryLine.d.ts +8 -0
  31. package/dist/components/shared/AuxiliaryLine.js +64 -0
  32. package/dist/components/shared/NodeDetail.d.ts +9 -0
  33. package/dist/components/shared/NodeDetail.js +110 -0
  34. package/dist/components/shared/NodeGeom.d.ts +23 -0
  35. package/dist/components/shared/NodeGeom.js +35 -0
  36. package/dist/components/shared/NodePopover.d.ts +22 -0
  37. package/dist/components/shared/NodePopover.js +41 -0
  38. package/dist/components/shared/NodePopoverContent.d.ts +15 -0
  39. package/dist/components/shared/NodePopoverContent.js +85 -0
  40. package/dist/components/shared/XAxisBackground.d.ts +31 -0
  41. package/dist/components/shared/XAxisBackground.js +93 -0
  42. package/dist/core/ChartConfig.d.ts +48 -0
  43. package/dist/core/ChartConfig.js +152 -0
  44. package/dist/core/ChartContext.d.ts +49 -0
  45. package/dist/core/ChartContext.js +31 -0
  46. package/dist/core/ChartTypes.d.ts +119 -0
  47. package/dist/core/ChartTypes.js +0 -0
  48. package/dist/index.d.ts +29 -0
  49. package/dist/index.js +21 -0
  50. package/dist/services/DataTransformService.d.ts +22 -0
  51. package/dist/services/DataTransformService.js +29 -0
  52. package/dist/services/FormatterService.d.ts +24 -0
  53. package/dist/services/FormatterService.js +22 -0
  54. package/dist/utils/__tests__/formatters.test.d.ts +1 -0
  55. package/dist/utils/__tests__/formatters.test.js +333 -0
  56. package/dist/utils/chartHelpers.d.ts +52 -0
  57. package/dist/utils/chartHelpers.js +112 -0
  58. package/dist/utils/dataTransform.d.ts +12 -0
  59. package/dist/utils/dataTransform.js +64 -0
  60. package/dist/utils/formatters.d.ts +37 -0
  61. package/dist/utils/formatters.js +127 -0
  62. package/dist/utils/indicatorHelpers.d.ts +16 -0
  63. package/dist/utils/indicatorHelpers.js +15 -0
  64. package/dist/utils/lazyHelpers.d.ts +29 -0
  65. package/dist/utils/lazyHelpers.js +15 -0
  66. package/package.json +68 -0
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # @moonton/publish-chart
2
+
3
+ 基于新架构设计的 React 图表组件库,支持离线分析模块使用的所有图表类型。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @moonton/publish-chart
9
+ # 或
10
+ pnpm add @moonton/publish-chart
11
+ ```
12
+
13
+ ## 特性
14
+
15
+ - 🎨 **丰富的图表类型**:柱状图、折线图、组合图等
16
+ - 🏗️ **新架构设计**:依赖注入、服务化、配置驱动
17
+ - 🔧 **类型安全**:完整的 TypeScript 支持
18
+ - 📦 **按需引入**:独立的包,不影响其他组件
19
+ - 🎯 **易于扩展**:清晰的架构,易于添加新图表类型
20
+
21
+ ## 快速开始
22
+
23
+ ### 1. 设置 ChartProvider
24
+
25
+ #### 完整配置(推荐)
26
+
27
+ ```tsx
28
+ import {
29
+ ChartProvider,
30
+ defaultChartConfig,
31
+ createFormatterService,
32
+ createDataTransformService
33
+ } from '@moonton/publish-chart';
34
+
35
+ const chartServices = {
36
+ formatter: createFormatterService(),
37
+ dataTransform: createDataTransformService(),
38
+ config: {
39
+ ...defaultChartConfig,
40
+ indicatorMap: {
41
+ // 指标映射表
42
+ },
43
+ },
44
+ };
45
+
46
+ <ChartProvider value={chartServices}>
47
+ <YourApp />
48
+ </ChartProvider>
49
+ ```
50
+
51
+ #### 仅定义业务组件(其他使用默认值)
52
+
53
+ 如果你只需要自定义业务组件,其他服务使用库的默认配置,可以这样:
54
+
55
+ ```tsx
56
+ import { ChartProvider } from '@moonton/publish-chart';
57
+
58
+ // 只定义 businessComponents,其他使用默认值
59
+ const chartServices = {
60
+ businessComponents: {
61
+ NodeDetail: YourNodeDetailComponent,
62
+ NodeGeom: YourNodeGeomComponent,
63
+ },
64
+ };
65
+
66
+ <ChartProvider value={chartServices}>
67
+ <YourApp />
68
+ </ChartProvider>
69
+ ```
70
+
71
+ > **注意**:`ChartProvider` 支持部分覆盖,未提供的字段(`formatter`、`dataTransform`、`config`)会自动使用默认值。
72
+
73
+ ### 2. 使用图表组件
74
+
75
+ ```tsx
76
+ import { BarChart, LineChart, BarLineChart } from '@moonton/publish-chart';
77
+
78
+ <BarChart
79
+ data={data}
80
+ x="groupName"
81
+ y="indicatorValue"
82
+ height={300}
83
+ />
84
+ ```
85
+
86
+ ## 组件列表
87
+
88
+ ### 基础组件
89
+ - `BarChart` - 基础柱状图
90
+ - `LineChart` - 基础折线图
91
+
92
+ ### 组合组件
93
+ - `BarLineChart` - 柱状折线组合图
94
+ - `GroupBarLine` - 分组柱状折线组合图
95
+ - `BarLineAdapter` - 数据适配器组件
96
+
97
+ ### 共享组件
98
+ - `AuxiliaryLine` - 辅助线组件
99
+ - `XAxisBackground` - X轴背景高亮组件
100
+
101
+ ## 架构设计
102
+
103
+ ### 核心特性
104
+
105
+ 1. **依赖注入架构**:通过 Context 注入服务,解耦组件和业务逻辑
106
+ 2. **类型适配器**:独立的类型定义,通过适配器转换业务类型
107
+ 3. **服务化架构**:将业务逻辑提取为服务,便于测试和复用
108
+ 4. **配置驱动**:统一的配置管理,支持自定义
109
+
110
+ ### 目录结构
111
+
112
+ ```
113
+ src/
114
+ ├── core/ # 核心功能
115
+ │ ├── ChartContext.tsx # 图表上下文
116
+ │ ├── ChartConfig.ts # 配置管理
117
+ │ └── ChartTypes.ts # 类型定义
118
+ ├── adapters/ # 适配器层
119
+ │ ├── DataAdapter.ts # 数据适配器
120
+ │ └── TypeAdapter.ts # 类型适配器
121
+ ├── services/ # 服务层
122
+ │ ├── FormatterService.ts # 格式化服务
123
+ │ └── DataTransformService.ts # 数据转换服务
124
+ ├── components/ # 组件层
125
+ │ ├── base/ # 基础组件
126
+ │ ├── composite/ # 组合组件
127
+ │ └── shared/ # 共享组件
128
+ └── utils/ # 工具函数
129
+ ```
130
+
131
+ ## 文档
132
+
133
+ 详细文档请参考:
134
+ - [使用指南](./docs/usage.md)
135
+ - [API 文档](./docs/api.md)
136
+ - [迁移指南](./docs/migration.md)
137
+
138
+ ## 许可证
139
+
140
+ ISC
141
+
142
+
143
+
@@ -0,0 +1,33 @@
1
+ export interface TransformConfig {
2
+ type: 'bar' | 'line' | 'barLine' | 'groupCompare';
3
+ x?: string;
4
+ y?: string;
5
+ z?: string;
6
+ isDescend?: boolean;
7
+ isHorizontal?: boolean;
8
+ }
9
+ /**
10
+ * 数据适配器类
11
+ */
12
+ export declare class DataAdapter {
13
+ /**
14
+ * 统一的数据转换接口
15
+ */
16
+ static transform(data: any[], transformType: TransformConfig['type'], config: TransformConfig): any[];
17
+ /**
18
+ * 柱状图数据转换
19
+ */
20
+ private static transformForBar;
21
+ /**
22
+ * 折线图数据转换
23
+ */
24
+ private static transformForLine;
25
+ /**
26
+ * 柱状折线组合图数据转换
27
+ */
28
+ private static transformForBarLine;
29
+ /**
30
+ * 分组对比图数据转换
31
+ */
32
+ private static transformForGroupCompare;
33
+ }
@@ -0,0 +1,75 @@
1
+ import lib from "@antv/data-set/lib";
2
+ class DataAdapter {
3
+ static transform(data, transformType, config) {
4
+ if (!data || 0 === data.length) return [];
5
+ switch(transformType){
6
+ case 'bar':
7
+ return this.transformForBar(data, config);
8
+ case 'line':
9
+ return this.transformForLine(data, config);
10
+ case 'barLine':
11
+ return this.transformForBarLine(data, config);
12
+ case 'groupCompare':
13
+ return this.transformForGroupCompare(data, config);
14
+ default:
15
+ return data;
16
+ }
17
+ }
18
+ static transformForBar(data, config) {
19
+ const ds = new lib();
20
+ const dv = ds.createView().source(data);
21
+ if (config.y) {
22
+ dv.transform({
23
+ type: 'map',
24
+ callback: (row)=>{
25
+ row[config.y] = '' !== row[config.y] ? +row[config.y] : '-';
26
+ return row;
27
+ }
28
+ });
29
+ if (config.isDescend) dv.transform({
30
+ type: 'sort',
31
+ callback: (a, b)=>{
32
+ if ('-' === a[config.y]) return config.isHorizontal ? -1 : 1;
33
+ if ('-' === b[config.y]) return config.isHorizontal ? 1 : -1;
34
+ return config.isHorizontal ? a[config.y] - b[config.y] : b[config.y] - a[config.y];
35
+ }
36
+ });
37
+ }
38
+ return dv.rows;
39
+ }
40
+ static transformForLine(data, config) {
41
+ const ds = new lib();
42
+ const dv = ds.createView().source(data);
43
+ if (config.y) dv.transform({
44
+ type: 'map',
45
+ callback: (row)=>{
46
+ row[config.y] = '' !== row[config.y] ? +row[config.y] : '-';
47
+ return row;
48
+ }
49
+ });
50
+ return dv.rows;
51
+ }
52
+ static transformForBarLine(data, config) {
53
+ const ds = new lib();
54
+ const dv = ds.createView().source(data);
55
+ if (config.y) dv.transform({
56
+ type: 'map',
57
+ callback: (row)=>{
58
+ row[config.y] = '' !== row[config.y] ? +row[config.y] : '-';
59
+ return row;
60
+ }
61
+ });
62
+ if (config.z) dv.transform({
63
+ type: 'map',
64
+ callback: (row)=>{
65
+ row[config.z] = '' !== row[config.z] ? +row[config.z] : '-';
66
+ return row;
67
+ }
68
+ });
69
+ return dv.rows;
70
+ }
71
+ static transformForGroupCompare(data, _config) {
72
+ return data;
73
+ }
74
+ }
75
+ export { DataAdapter };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 类型适配器
3
+ * 将业务类型转换为组件库类型
4
+ */
5
+ import type { IndicatorInfo, ChartTimeRange } from '../core/ChartTypes';
6
+ /**
7
+ * 业务类型定义(示例,实际使用时从业务项目导入)
8
+ */
9
+ export interface BusinessUniqueIndicatorInfo {
10
+ indicatorID?: number;
11
+ indicatorName?: string;
12
+ indicatorFrom?: string;
13
+ indicatorFormat?: {
14
+ indicatorUnit?: number;
15
+ indicatorDecimal?: number;
16
+ };
17
+ [key: string]: any;
18
+ }
19
+ export interface BusinessTimeRange {
20
+ startTime?: string;
21
+ endTime?: string;
22
+ compareStartTime?: string;
23
+ compareEndTime?: string;
24
+ timeType?: number;
25
+ compareType?: number;
26
+ [key: string]: any;
27
+ }
28
+ /**
29
+ * 类型适配器类
30
+ */
31
+ export declare class TypeAdapter {
32
+ /**
33
+ * 适配指标映射表
34
+ */
35
+ static adaptIndicatorMap(businessIndicatorMap: Record<string, BusinessUniqueIndicatorInfo>): Record<string, IndicatorInfo>;
36
+ /**
37
+ * 适配时间范围
38
+ */
39
+ static adaptTimeRange(businessTimeRange: BusinessTimeRange): ChartTimeRange;
40
+ }
@@ -0,0 +1,26 @@
1
+ class TypeAdapter {
2
+ static adaptIndicatorMap(businessIndicatorMap) {
3
+ if (!businessIndicatorMap) return {};
4
+ return Object.entries(businessIndicatorMap).reduce((acc, [key, value])=>{
5
+ acc[key] = {
6
+ indicatorID: value.indicatorID,
7
+ indicatorName: value.indicatorName,
8
+ indicatorFrom: value.indicatorFrom,
9
+ indicatorFormat: value.indicatorFormat
10
+ };
11
+ return acc;
12
+ }, {});
13
+ }
14
+ static adaptTimeRange(businessTimeRange) {
15
+ if (!businessTimeRange) return {};
16
+ return {
17
+ startTime: businessTimeRange.startTime,
18
+ endTime: businessTimeRange.endTime,
19
+ compareStartTime: businessTimeRange.compareStartTime,
20
+ compareEndTime: businessTimeRange.compareEndTime,
21
+ timeType: businessTimeRange.timeType,
22
+ compareType: businessTimeRange.compareType
23
+ };
24
+ }
25
+ }
26
+ export { TypeAdapter };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 基础柱状图组件
3
+ */
4
+ import React from "react";
5
+ import type { BaseChartProps } from "../../core/ChartTypes";
6
+ declare const _default: React.NamedExoticComponent<BaseChartProps>;
7
+ export default _default;
@@ -0,0 +1,362 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { memo, useCallback, useEffect, useMemo, useState } from "react";
3
+ import { Axis, Chart, Coordinate, Interval, Tooltip, View } from "bizcharts";
4
+ import { useChartContext } from "../../core/ChartContext.js";
5
+ import { mergeChartConfig } from "../../core/ChartConfig.js";
6
+ import { calculateBarWidth, getAxisFormat, getAxisHorPaddingByText, getChartKey, truncateText } from "../../utils/chartHelpers.js";
7
+ import AuxiliaryLine from "../shared/AuxiliaryLine.js";
8
+ import XAxisBackground from "../shared/XAxisBackground.js";
9
+ import { NodeGeom } from "../shared/NodeGeom.js";
10
+ import { NodeDetail } from "../shared/NodeDetail.js";
11
+ import { DataAdapter } from "../../adapters/DataAdapter.js";
12
+ const BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartClick, legend = "", config, nodeSetting = {
13
+ showType: 0,
14
+ type: []
15
+ }, auxiliaryLineData, highlightDate = [] })=>{
16
+ const { formatter, dataTransform, config: contextConfig } = useChartContext();
17
+ const mergedConfig = useMemo(()=>mergeChartConfig(contextConfig, {}), [
18
+ contextConfig
19
+ ]);
20
+ const safeIndicatorMap = indicatorMap || contextConfig.indicatorMap || {};
21
+ const safeLegend = legend || y;
22
+ const chartConfig = config || {};
23
+ const { isDataTag = false, isDescend = false, isHorizontal = false, isHighlight = true } = chartConfig;
24
+ const transformedData = useMemo(()=>{
25
+ const result = DataAdapter.transform(data, "bar", {
26
+ type: "bar",
27
+ x,
28
+ y,
29
+ isDescend,
30
+ isHorizontal
31
+ });
32
+ return result.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap));
33
+ }, [
34
+ data,
35
+ x,
36
+ y,
37
+ isDescend,
38
+ isHorizontal,
39
+ dataTransform,
40
+ contextConfig.nodeMap
41
+ ]);
42
+ const [chartInsWidth, setChartInsWidth] = useState(0);
43
+ const [axisHorPadding, setAxisHorPadding] = useState(0);
44
+ const [chartWidth, setChartWidth] = useState(0);
45
+ const [chartOffset, setChartOffset] = useState(0);
46
+ const [padding, setPadding] = useState([
47
+ 10,
48
+ 0
49
+ ]);
50
+ const [pointP, setPointP] = useState({
51
+ x: 0,
52
+ y: 0
53
+ });
54
+ const [pointData, setPointData] = useState({
55
+ info: [],
56
+ infosCompare: []
57
+ });
58
+ const [mainBarSize, setMainBarSize] = useState(void 0);
59
+ const maxY = useMemo(()=>{
60
+ const values = transformedData.filter((item)=>"-" !== item[y] && void 0 !== item[y] && null !== item[y]).map((item)=>Number(item[y]));
61
+ const maxData = Math.max(...values.length > 0 ? values : [
62
+ 0
63
+ ]);
64
+ const maxAuxiliary = auxiliaryLineData?.length ? Math.max(...auxiliaryLineData.map((item)=>item.value)) : 0;
65
+ return Math.max(maxData, maxAuxiliary);
66
+ }, [
67
+ transformedData,
68
+ y,
69
+ auxiliaryLineData
70
+ ]);
71
+ useEffect(()=>{
72
+ if (nodeSetting?.showType === 2 && chartWidth / transformedData.length > 30) if (transformedData.some((item)=>item?.nodeLen > 2)) setPadding([
73
+ 10,
74
+ 10,
75
+ 40,
76
+ 0
77
+ ]);
78
+ else transformedData.some((item)=>item?.nodeLen === 2) ? setPadding([
79
+ 10,
80
+ 10,
81
+ 24,
82
+ 0
83
+ ]) : setPadding([
84
+ 20,
85
+ 10,
86
+ 10,
87
+ 0
88
+ ]);
89
+ else setPadding([
90
+ 20,
91
+ 10,
92
+ 10,
93
+ 0
94
+ ]);
95
+ }, [
96
+ chartWidth,
97
+ transformedData
98
+ ]);
99
+ useEffect(()=>{
100
+ maxY > Math.max(...transformedData.filter((item)=>"-" !== item[y]).map((item)=>item[y])) ? setPadding((pre)=>[
101
+ isHorizontal ? 20 : 25,
102
+ isHorizontal ? isDataTag ? 50 : mergedConfig.layout.horBarPaddingRight ?? 50 : pre[1] ?? 0,
103
+ pre[2] ?? 0,
104
+ pre[3] ?? 0
105
+ ]) : setPadding((pre)=>[
106
+ pre[0] ?? 0,
107
+ isHorizontal && isDataTag ? 50 : mergedConfig.layout.barPaddingRight ?? 10,
108
+ pre[2] ?? 0,
109
+ pre[3] ?? 0
110
+ ]);
111
+ }, [
112
+ maxY,
113
+ transformedData,
114
+ y,
115
+ isHorizontal,
116
+ isDataTag,
117
+ mergedConfig
118
+ ]);
119
+ const filterFn = useMemo(()=>(item)=>highlightDate?.includes(item.groupName) ?? false, [
120
+ highlightDate
121
+ ]);
122
+ const formatAxis = useCallback((val)=>{
123
+ setAxisHorPadding(getAxisHorPaddingByText(val, safeIndicatorMap, safeLegend) - 22);
124
+ return getAxisFormat(val, safeIndicatorMap, safeLegend);
125
+ }, [
126
+ safeIndicatorMap,
127
+ safeLegend
128
+ ]);
129
+ return /*#__PURE__*/ jsx("div", {
130
+ style: {
131
+ position: "relative"
132
+ },
133
+ children: /*#__PURE__*/ jsxs(Chart, {
134
+ className: "publish-chart",
135
+ scale: {
136
+ [y]: {
137
+ type: "linear",
138
+ max: maxY,
139
+ nice: true
140
+ }
141
+ },
142
+ height: height,
143
+ data: transformedData,
144
+ ...mergedConfig.baseChartConfig,
145
+ onGetG2Instance: (c)=>{
146
+ if (c) setChartInsWidth(c.width);
147
+ },
148
+ onClick: (e, chart)=>{
149
+ const value = chart.getTooltipItems({
150
+ x: e.x,
151
+ y: e.y
152
+ });
153
+ onChartClick && onChartClick(value[0]);
154
+ },
155
+ appendPadding: padding,
156
+ onPointMouseover: (e)=>{
157
+ console.log("onPointMouseover", nodeSetting.showType, typeof nodeSetting.showType);
158
+ if (1 === nodeSetting.showType) try {
159
+ if (e?.data) {
160
+ setPointP({
161
+ x: e.data.x ?? 0,
162
+ y: e.data.y ?? 0
163
+ });
164
+ const nodeInfos = e.data?.data?.nodeInfos;
165
+ setPointData(nodeInfos || {
166
+ info: [],
167
+ infosCompare: []
168
+ });
169
+ }
170
+ } catch (error) {
171
+ console.warn("Failed to handle point mouseover:", error);
172
+ setPointP({
173
+ x: 0,
174
+ y: 0
175
+ });
176
+ setPointData({
177
+ info: [],
178
+ infosCompare: []
179
+ });
180
+ }
181
+ },
182
+ onAfterrender: (_e, chart)=>{
183
+ if (2 === nodeSetting.showType) {
184
+ setChartWidth(chart.coordinateBBox.width);
185
+ setChartOffset(chart.coordinateBBox.x);
186
+ }
187
+ const estimatedBarWidth = calculateBarWidth(chart, transformedData, x, 0.5);
188
+ if (void 0 !== estimatedBarWidth) setMainBarSize(estimatedBarWidth);
189
+ },
190
+ children: [
191
+ /*#__PURE__*/ jsx(XAxisBackground, {
192
+ x: x,
193
+ data: transformedData,
194
+ isHighlight: isHighlight,
195
+ filterFn: filterFn,
196
+ dataLength: transformedData.length,
197
+ mainBarSize: mainBarSize,
198
+ isHorizontal: isHorizontal
199
+ }),
200
+ /*#__PURE__*/ jsx(Coordinate, {
201
+ transpose: isHorizontal
202
+ }),
203
+ /*#__PURE__*/ jsx(Interval, {
204
+ position: `${x}*${y}`,
205
+ style: {
206
+ cursor: "pointer"
207
+ },
208
+ label: [
209
+ y,
210
+ (v)=>{
211
+ const content = isDataTag ? formatter.formatIndicator(v, safeIndicatorMap[safeLegend]) : void 0;
212
+ return {
213
+ content: content || "",
214
+ offset: isHorizontal ? 5 : 10
215
+ };
216
+ }
217
+ ]
218
+ }),
219
+ /*#__PURE__*/ jsx(Tooltip, {
220
+ shared: true,
221
+ showCrosshairs: true,
222
+ children: (title, items)=>/*#__PURE__*/ jsxs("div", {
223
+ style: {
224
+ padding: "10px 0"
225
+ },
226
+ children: [
227
+ title,
228
+ items && /*#__PURE__*/ jsxs(Fragment, {
229
+ children: [
230
+ /*#__PURE__*/ jsx("div", {
231
+ style: {
232
+ marginTop: "10px"
233
+ },
234
+ children: items.map((it, index)=>/*#__PURE__*/ jsxs("div", {
235
+ style: {
236
+ display: "flex",
237
+ justifyContent: "space-between"
238
+ },
239
+ children: [
240
+ /*#__PURE__*/ jsxs("span", {
241
+ children: [
242
+ /*#__PURE__*/ jsx("span", {
243
+ style: {
244
+ width: "8px",
245
+ height: "8px",
246
+ backgroundColor: it.color,
247
+ display: "inline-block",
248
+ borderRadius: "50%",
249
+ marginRight: "8px"
250
+ }
251
+ }),
252
+ safeIndicatorMap[safeLegend]?.indicatorName || "",
253
+ ":"
254
+ ]
255
+ }),
256
+ /*#__PURE__*/ jsx("span", {
257
+ style: {
258
+ fontWeight: "bold",
259
+ paddingLeft: "10px"
260
+ },
261
+ children: formatter.formatIndicator(it.value, safeIndicatorMap[safeLegend])
262
+ })
263
+ ]
264
+ }, index))
265
+ }),
266
+ auxiliaryLineData && auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsxs("div", {
267
+ style: {
268
+ marginLeft: "16px",
269
+ marginTop: "10px",
270
+ display: "flex",
271
+ justifyContent: "space-between"
272
+ },
273
+ children: [
274
+ /*#__PURE__*/ jsxs("div", {
275
+ style: {
276
+ marginRight: "8px"
277
+ },
278
+ children: [
279
+ item.name,
280
+ ":"
281
+ ]
282
+ }),
283
+ /*#__PURE__*/ jsx("div", {
284
+ children: formatter.formatIndicator(item.value, safeIndicatorMap[safeLegend])
285
+ })
286
+ ]
287
+ }, index))
288
+ ]
289
+ })
290
+ ]
291
+ })
292
+ }),
293
+ auxiliaryLineData && auxiliaryLineData.length > 0 && /*#__PURE__*/ jsxs(View, {
294
+ data: transformedData,
295
+ scale: {
296
+ [y]: {
297
+ type: "linear",
298
+ max: maxY,
299
+ nice: true
300
+ }
301
+ },
302
+ padding: [
303
+ 0,
304
+ 0,
305
+ 0,
306
+ isHorizontal ? 0 : -axisHorPadding
307
+ ],
308
+ children: [
309
+ /*#__PURE__*/ jsx(Axis, {
310
+ name: y,
311
+ visible: false
312
+ }),
313
+ /*#__PURE__*/ jsx(Axis, {
314
+ name: x,
315
+ visible: false
316
+ }),
317
+ /*#__PURE__*/ jsx(Interval, {
318
+ position: `${x}*${y}`,
319
+ visible: false
320
+ }),
321
+ auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsx(AuxiliaryLine, {
322
+ name: item.name,
323
+ value: item.value,
324
+ isHorizontal: isHorizontal
325
+ }, index))
326
+ ]
327
+ }, `${axisHorPadding}${isHorizontal}`),
328
+ /*#__PURE__*/ jsx(Axis, {
329
+ name: y,
330
+ label: {
331
+ formatter: formatAxis
332
+ }
333
+ }),
334
+ /*#__PURE__*/ jsx(Axis, {
335
+ name: x,
336
+ label: {
337
+ autoEllipsis: true,
338
+ formatter: (text)=>isHorizontal ? truncateText(text, chartInsWidth / 5) : text
339
+ }
340
+ }),
341
+ transformedData.some((item)=>item?.nodeInfos?.info?.length > 0 || item?.nodeInfos?.infosCompare?.length > 0) && /*#__PURE__*/ jsxs(Fragment, {
342
+ children: [
343
+ 1 === nodeSetting.showType && NodeGeom && /*#__PURE__*/ jsx(NodeGeom, {
344
+ pointData: pointData,
345
+ pointP: pointP
346
+ }),
347
+ 2 === nodeSetting.showType && NodeDetail && (0 === chartOffset || chartOffset) && /*#__PURE__*/ jsx(NodeDetail, {
348
+ chartWidth: chartWidth,
349
+ chartOffset: chartOffset,
350
+ dvRows: transformedData
351
+ })
352
+ ]
353
+ })
354
+ ]
355
+ }, getChartKey({
356
+ chartConfig,
357
+ nodeSetting
358
+ }))
359
+ });
360
+ };
361
+ const base_BarChart = /*#__PURE__*/ memo(BarChart);
362
+ export { base_BarChart as default };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BarChart Lazy Loading 入口
3
+ * 提供默认导出,支持 lazy() 直接使用
4
+ */
5
+ export { default } from './BarChart';