@ant-design/agentic-ui 2.0.6 → 2.0.10
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.
- package/dist/Bubble/style.js +4 -2
- package/dist/MarkdownEditor/editor/Editor.js +3 -2
- package/dist/MarkdownEditor/editor/components/LazyElement/index.d.ts +32 -0
- package/dist/MarkdownEditor/editor/components/LazyElement/index.js +15 -4
- package/dist/MarkdownEditor/types.d.ts +34 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.d.ts +0 -33
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +15 -16
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.d.ts +4 -45
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +107 -146
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +100 -67
- package/dist/MarkdownInputField/AttachmentButton/index.d.ts +25 -1
- package/dist/MarkdownInputField/AttachmentButton/index.js +28 -11
- package/dist/MarkdownInputField/AttachmentButton/types.d.ts +15 -0
- package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +265 -199
- package/dist/MarkdownInputField/FileMapView/style.js +1 -0
- package/dist/MarkdownInputField/FileUploadManager/index.js +19 -6
- package/dist/MarkdownInputField/MarkdownInputField.js +4 -0
- package/dist/plugins/chart/AreaChart/index.d.ts +95 -0
- package/dist/plugins/chart/AreaChart/index.js +10 -0
- package/dist/plugins/chart/BarChart/index.d.ts +47 -0
- package/dist/plugins/chart/DonutChart/index.d.ts +28 -0
- package/dist/plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +58 -0
- package/dist/plugins/chart/const.d.ts +25 -0
- package/dist/plugins/chart/const.js +10 -0
- package/dist/plugins/chart/index.d.ts +14 -0
- package/dist/plugins/chart/utils.d.ts +197 -32
- package/package.json +1 -1
|
@@ -2,26 +2,94 @@ import React from 'react';
|
|
|
2
2
|
import { ChartContainerProps } from '../components';
|
|
3
3
|
import { StatisticConfigType } from '../hooks/useChartStatistic';
|
|
4
4
|
import { ChartDataItem } from '../utils';
|
|
5
|
+
/**
|
|
6
|
+
* 面积图数据项类型
|
|
7
|
+
*
|
|
8
|
+
* 继承自 ChartDataItem,用于面积图的数据表示。
|
|
9
|
+
*
|
|
10
|
+
* @typedef {ChartDataItem} AreaChartDataItem
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
5
13
|
export type AreaChartDataItem = ChartDataItem;
|
|
14
|
+
/**
|
|
15
|
+
* 面积图配置项接口
|
|
16
|
+
*
|
|
17
|
+
* 定义了面积图的配置选项,包括数据集、主题、图例、网格等设置。
|
|
18
|
+
*
|
|
19
|
+
* @interface AreaChartConfigItem
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const config: AreaChartConfigItem = {
|
|
25
|
+
* datasets: [data1, data2],
|
|
26
|
+
* theme: 'light',
|
|
27
|
+
* showLegend: true,
|
|
28
|
+
* legendPosition: 'top',
|
|
29
|
+
* showGrid: true,
|
|
30
|
+
* xAxisLabel: '时间',
|
|
31
|
+
* yAxisLabel: '数值'
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
6
35
|
export interface AreaChartConfigItem {
|
|
36
|
+
/** 数据集数组 */
|
|
7
37
|
datasets: Array<(string | {
|
|
8
38
|
x: number;
|
|
9
39
|
y: number;
|
|
10
40
|
})[]>;
|
|
41
|
+
/** 图表主题 */
|
|
11
42
|
theme?: 'light' | 'dark';
|
|
43
|
+
/** 是否显示图例 */
|
|
12
44
|
showLegend?: boolean;
|
|
45
|
+
/** 图例位置 */
|
|
13
46
|
legendPosition?: 'top' | 'left' | 'bottom' | 'right';
|
|
47
|
+
/** 图例水平对齐方式 */
|
|
14
48
|
legendAlign?: 'start' | 'center' | 'end';
|
|
49
|
+
/** 是否显示网格线 */
|
|
15
50
|
showGrid?: boolean;
|
|
51
|
+
/** X轴标签 */
|
|
16
52
|
xAxisLabel?: string;
|
|
53
|
+
/** Y轴标签 */
|
|
17
54
|
yAxisLabel?: string;
|
|
55
|
+
/** X轴最小值 */
|
|
18
56
|
xAxisMin?: number;
|
|
57
|
+
/** X轴最大值 */
|
|
19
58
|
xAxisMax?: number;
|
|
59
|
+
/** Y轴最小值 */
|
|
20
60
|
yAxisMin?: number;
|
|
61
|
+
/** Y轴最大值 */
|
|
21
62
|
yAxisMax?: number;
|
|
63
|
+
/** X轴步长 */
|
|
22
64
|
xAxisStep?: number;
|
|
65
|
+
/** Y轴步长 */
|
|
23
66
|
yAxisStep?: number;
|
|
24
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* 面积图组件属性接口
|
|
70
|
+
*
|
|
71
|
+
* 定义了面积图组件的所有属性,继承自 ChartContainerProps。
|
|
72
|
+
* 支持数据配置、样式设置、交互功能等。
|
|
73
|
+
*
|
|
74
|
+
* @interface AreaChartProps
|
|
75
|
+
* @extends ChartContainerProps
|
|
76
|
+
* @since 1.0.0
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const props: AreaChartProps = {
|
|
81
|
+
* title: '销售趋势',
|
|
82
|
+
* data: [
|
|
83
|
+
* { x: '2024-01', y: 100, type: '产品A' },
|
|
84
|
+
* { x: '2024-02', y: 150, type: '产品A' }
|
|
85
|
+
* ],
|
|
86
|
+
* width: 800,
|
|
87
|
+
* height: 400,
|
|
88
|
+
* showLegend: true,
|
|
89
|
+
* showGrid: true
|
|
90
|
+
* };
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
25
93
|
export interface AreaChartProps extends ChartContainerProps {
|
|
26
94
|
/** 图表标题 */
|
|
27
95
|
title?: string;
|
|
@@ -62,5 +130,32 @@ export interface AreaChartProps extends ChartContainerProps {
|
|
|
62
130
|
/** ChartStatistic组件配置:object表示单个配置,array表示多个配置 */
|
|
63
131
|
statistic?: StatisticConfigType;
|
|
64
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* 面积图组件
|
|
135
|
+
*
|
|
136
|
+
* 基于 Chart.js 和 react-chartjs-2 实现的面积图组件。
|
|
137
|
+
* 支持数据可视化、交互、配置、统计等功能。
|
|
138
|
+
*
|
|
139
|
+
* @component
|
|
140
|
+
* @param {AreaChartProps} props - 组件属性
|
|
141
|
+
* @returns {React.ReactElement} 面积图组件
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* <AreaChart
|
|
146
|
+
* title="销售趋势"
|
|
147
|
+
* data={[
|
|
148
|
+
* { x: '2024-01', y: 100, type: '产品A' },
|
|
149
|
+
* { x: '2024-02', y: 150, type: '产品A' }
|
|
150
|
+
* ]}
|
|
151
|
+
* width={800}
|
|
152
|
+
* height={400}
|
|
153
|
+
* showLegend={true}
|
|
154
|
+
* showGrid={true}
|
|
155
|
+
* />
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @since 1.0.0
|
|
159
|
+
*/
|
|
65
160
|
declare const AreaChart: React.FC<AreaChartProps>;
|
|
66
161
|
export default AreaChart;
|
|
@@ -57,15 +57,25 @@ ChartJS.register(
|
|
|
57
57
|
);
|
|
58
58
|
var defaultColors = [
|
|
59
59
|
"#1677ff",
|
|
60
|
+
// 蓝色
|
|
60
61
|
"#8954FC",
|
|
62
|
+
// 紫色
|
|
61
63
|
"#15e7e4",
|
|
64
|
+
// 青色
|
|
62
65
|
"#F45BB5",
|
|
66
|
+
// 粉色
|
|
63
67
|
"#00A6FF",
|
|
68
|
+
// 天蓝色
|
|
64
69
|
"#33E59B",
|
|
70
|
+
// 绿色
|
|
65
71
|
"#D666E4",
|
|
72
|
+
// 紫红色
|
|
66
73
|
"#6151FF",
|
|
74
|
+
// 靛蓝色
|
|
67
75
|
"#BF3C93",
|
|
76
|
+
// 深粉色
|
|
68
77
|
"#005EE0"
|
|
78
|
+
// 深蓝色
|
|
69
79
|
];
|
|
70
80
|
var hexToRgba = (hex, alpha) => {
|
|
71
81
|
const sanitized = hex.replace("#", "");
|
|
@@ -3,26 +3,73 @@ import React from 'react';
|
|
|
3
3
|
import { ChartContainerProps } from '../components';
|
|
4
4
|
import { StatisticConfigType } from '../hooks/useChartStatistic';
|
|
5
5
|
import { ChartDataItem } from '../utils';
|
|
6
|
+
/**
|
|
7
|
+
* 柱状图数据项类型
|
|
8
|
+
*
|
|
9
|
+
* 继承自 ChartDataItem,用于柱状图的数据表示。
|
|
10
|
+
*
|
|
11
|
+
* @typedef {ChartDataItem} BarChartDataItem
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
*/
|
|
6
14
|
export type BarChartDataItem = ChartDataItem;
|
|
15
|
+
/**
|
|
16
|
+
* 柱状图配置项接口
|
|
17
|
+
*
|
|
18
|
+
* 定义了柱状图的配置选项,包括数据集、主题、图例、网格等设置。
|
|
19
|
+
*
|
|
20
|
+
* @interface BarChartConfigItem
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const config: BarChartConfigItem = {
|
|
26
|
+
* datasets: [data1, data2],
|
|
27
|
+
* theme: 'light',
|
|
28
|
+
* showLegend: true,
|
|
29
|
+
* legendPosition: 'top',
|
|
30
|
+
* showGrid: true,
|
|
31
|
+
* xAxisLabel: '类别',
|
|
32
|
+
* yAxisLabel: '数值',
|
|
33
|
+
* stacked: false,
|
|
34
|
+
* indexAxis: 'x'
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
7
38
|
export interface BarChartConfigItem {
|
|
39
|
+
/** 数据集数组 */
|
|
8
40
|
datasets: Array<(string | {
|
|
9
41
|
x: number;
|
|
10
42
|
y: number;
|
|
11
43
|
})[]>;
|
|
44
|
+
/** 图表主题 */
|
|
12
45
|
theme?: 'light' | 'dark';
|
|
46
|
+
/** 是否显示图例 */
|
|
13
47
|
showLegend?: boolean;
|
|
48
|
+
/** 图例位置 */
|
|
14
49
|
legendPosition?: 'top' | 'left' | 'bottom' | 'right';
|
|
50
|
+
/** 图例水平对齐方式 */
|
|
15
51
|
legendAlign?: 'start' | 'center' | 'end';
|
|
52
|
+
/** 是否显示网格线 */
|
|
16
53
|
showGrid?: boolean;
|
|
54
|
+
/** X轴标签 */
|
|
17
55
|
xAxisLabel?: string;
|
|
56
|
+
/** Y轴标签 */
|
|
18
57
|
yAxisLabel?: string;
|
|
58
|
+
/** X轴最小值 */
|
|
19
59
|
xAxisMin?: number;
|
|
60
|
+
/** X轴最大值 */
|
|
20
61
|
xAxisMax?: number;
|
|
62
|
+
/** Y轴最小值 */
|
|
21
63
|
yAxisMin?: number;
|
|
64
|
+
/** Y轴最大值 */
|
|
22
65
|
yAxisMax?: number;
|
|
66
|
+
/** X轴步长 */
|
|
23
67
|
xAxisStep?: number;
|
|
68
|
+
/** Y轴步长 */
|
|
24
69
|
yAxisStep?: number;
|
|
70
|
+
/** 是否堆叠显示 */
|
|
25
71
|
stacked?: boolean;
|
|
72
|
+
/** 索引轴方向 */
|
|
26
73
|
indexAxis?: 'x' | 'y';
|
|
27
74
|
}
|
|
28
75
|
export interface BarChartProps extends ChartContainerProps {
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DonutChartProps } from './types';
|
|
3
3
|
export type { DonutChartConfig, DonutChartData, DonutChartProps, } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 环形图组件
|
|
6
|
+
*
|
|
7
|
+
* 基于 Chart.js 和 react-chartjs-2 实现的环形图(甜甜圈图)组件。
|
|
8
|
+
* 支持饼图和环形图两种样式,提供数据可视化、交互、配置、统计等功能。
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
* @param {DonutChartProps} props - 组件属性
|
|
12
|
+
* @returns {React.ReactElement} 环形图组件
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <DonutChart
|
|
17
|
+
* title="销售占比"
|
|
18
|
+
* data={[
|
|
19
|
+
* { label: '产品A', value: 30 },
|
|
20
|
+
* { label: '产品B', value: 50 },
|
|
21
|
+
* { label: '产品C', value: 20 }
|
|
22
|
+
* ]}
|
|
23
|
+
* configs={[{ chartStyle: 'donut', showLegend: true }]}
|
|
24
|
+
* width={400}
|
|
25
|
+
* height={400}
|
|
26
|
+
* showToolbar={true}
|
|
27
|
+
* />
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @since 1.0.0
|
|
31
|
+
*/
|
|
4
32
|
declare const DonutChart: React.FC<DonutChartProps>;
|
|
5
33
|
export default DonutChart;
|
|
@@ -1,12 +1,70 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview 图表工具栏组件文件
|
|
4
|
+
*
|
|
5
|
+
* 该文件提供了图表工具栏组件的实现,用于显示图表标题、数据时间、下载按钮等。
|
|
6
|
+
*
|
|
7
|
+
* @author md-editor
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
* @since 2024
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* 图表工具栏属性接口
|
|
13
|
+
*
|
|
14
|
+
* 定义了图表工具栏组件的所有属性。
|
|
15
|
+
*
|
|
16
|
+
* @interface ChartToolBarProps
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const props: ChartToolBarProps = {
|
|
22
|
+
* title: '销售数据',
|
|
23
|
+
* dataTime: '2024-01-01 00:00:00',
|
|
24
|
+
* theme: 'light',
|
|
25
|
+
* onDownload: () => console.log('下载图表'),
|
|
26
|
+
* extra: <Button>自定义按钮</Button>
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
2
30
|
export interface ChartToolBarProps {
|
|
31
|
+
/** 图表标题 */
|
|
3
32
|
title?: string;
|
|
33
|
+
/** 数据时间 */
|
|
4
34
|
dataTime?: string;
|
|
35
|
+
/** 自定义CSS类名 */
|
|
5
36
|
className?: string;
|
|
37
|
+
/** 图表主题 */
|
|
6
38
|
theme?: 'light' | 'dark';
|
|
39
|
+
/** 下载回调函数 */
|
|
7
40
|
onDownload?: () => void;
|
|
41
|
+
/** 额外内容 */
|
|
8
42
|
extra?: React.ReactNode;
|
|
43
|
+
/** 过滤器内容 */
|
|
9
44
|
filter?: React.ReactNode;
|
|
10
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* 图表工具栏组件
|
|
48
|
+
*
|
|
49
|
+
* 用于显示图表标题、数据时间、下载按钮等工具栏内容。
|
|
50
|
+
* 支持主题切换、自定义内容、下载功能等。
|
|
51
|
+
*
|
|
52
|
+
* @component
|
|
53
|
+
* @param {ChartToolBarProps} props - 组件属性
|
|
54
|
+
* @returns {React.ReactElement | null} 图表工具栏组件,当没有标题和额外内容时返回 null
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <ChartToolBar
|
|
59
|
+
* title="销售数据"
|
|
60
|
+
* dataTime="2024-01-01 00:00:00"
|
|
61
|
+
* theme="light"
|
|
62
|
+
* onDownload={() => console.log('下载图表')}
|
|
63
|
+
* extra={<Button>自定义按钮</Button>}
|
|
64
|
+
* />
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
*/
|
|
11
69
|
declare const ChartToolBar: React.FC<ChartToolBarProps>;
|
|
12
70
|
export default ChartToolBar;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 图表插件常量定义文件
|
|
3
|
+
*
|
|
4
|
+
* 该文件定义了图表插件中使用的各种常量,包括默认颜色列表等。
|
|
5
|
+
*
|
|
6
|
+
* @author md-editor
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @since 2024
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 默认颜色列表
|
|
12
|
+
*
|
|
13
|
+
* 用于图表数据系列的颜色配置,提供10种预定义的颜色。
|
|
14
|
+
* 这些颜色经过精心挑选,确保在图表中具有良好的视觉效果和对比度。
|
|
15
|
+
*
|
|
16
|
+
* @constant
|
|
17
|
+
* @type {string[]}
|
|
18
|
+
* @default
|
|
19
|
+
* @example
|
|
20
|
+
* // 使用默认颜色列表
|
|
21
|
+
* const colors = defaultColorList;
|
|
22
|
+
* console.log(colors[0]); // '#1677ff'
|
|
23
|
+
*
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
*/
|
|
1
26
|
export declare const defaultColorList: string[];
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
// src/plugins/chart/const.ts
|
|
2
2
|
var defaultColorList = [
|
|
3
3
|
"#1677ff",
|
|
4
|
+
// 蓝色
|
|
4
5
|
"#15e7e4",
|
|
6
|
+
// 青色
|
|
5
7
|
"#8954FC",
|
|
8
|
+
// 紫色
|
|
6
9
|
"#F45BB5",
|
|
10
|
+
// 粉色
|
|
7
11
|
"#00A6FF",
|
|
12
|
+
// 天蓝色
|
|
8
13
|
"#33E59B",
|
|
14
|
+
// 绿色
|
|
9
15
|
"#D666E4",
|
|
16
|
+
// 紫红色
|
|
10
17
|
"#6151FF",
|
|
18
|
+
// 靛蓝色
|
|
11
19
|
"#BF3C93",
|
|
20
|
+
// 深粉色
|
|
12
21
|
"#005EE0"
|
|
22
|
+
// 深蓝色
|
|
13
23
|
];
|
|
14
24
|
export {
|
|
15
25
|
defaultColorList
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RenderElementProps } from 'slate-react';
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview 图表插件主入口文件
|
|
5
|
+
*
|
|
6
|
+
* 该文件提供了完整的图表功能,包括:
|
|
7
|
+
* - 多种图表类型的组件(饼图、柱状图、折线图、面积图等)
|
|
8
|
+
* - 图表渲染和配置功能
|
|
9
|
+
* - 数据处理和格式化工具
|
|
10
|
+
* - 图表属性工具栏
|
|
11
|
+
* - 图表标记和容器组件
|
|
12
|
+
*
|
|
13
|
+
* @author md-editor
|
|
14
|
+
* @version 1.0.0
|
|
15
|
+
* @since 2024
|
|
16
|
+
*/
|
|
3
17
|
export { ChartAttrToolBar } from './ChartAttrToolBar';
|
|
4
18
|
export * from './ChartMark';
|
|
5
19
|
export { ChartRender } from './ChartRender';
|
|
@@ -7,6 +7,38 @@
|
|
|
7
7
|
* 如果输入值为空或格式化过程中发生错误,则返回原始值。
|
|
8
8
|
*/
|
|
9
9
|
export declare const stringFormatNumber: (value: string | number) => string | number;
|
|
10
|
+
/**
|
|
11
|
+
* 防抖函数
|
|
12
|
+
*
|
|
13
|
+
* 创建一个防抖函数,该函数会在调用后等待指定的延迟时间,
|
|
14
|
+
* 如果在延迟时间内再次调用,则重新开始计时。
|
|
15
|
+
* 常用于限制函数调用频率,如搜索输入、窗口调整等场景。
|
|
16
|
+
*
|
|
17
|
+
* @param {Function} func - 要防抖的函数
|
|
18
|
+
* @param {number} delay - 延迟时间(毫秒)
|
|
19
|
+
* @returns {Function} 防抖后的函数,包含以下方法:
|
|
20
|
+
* - `flush()`: 立即执行函数并清除定时器
|
|
21
|
+
* - `cancel()`: 取消延迟执行
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const debouncedSearch = debounce((query: string) => {
|
|
26
|
+
* console.log('搜索:', query);
|
|
27
|
+
* }, 300);
|
|
28
|
+
*
|
|
29
|
+
* // 调用防抖函数
|
|
30
|
+
* debouncedSearch('hello');
|
|
31
|
+
* debouncedSearch('world'); // 只有这个会执行
|
|
32
|
+
*
|
|
33
|
+
* // 立即执行
|
|
34
|
+
* debouncedSearch.flush();
|
|
35
|
+
*
|
|
36
|
+
* // 取消执行
|
|
37
|
+
* debouncedSearch.cancel();
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*/
|
|
10
42
|
export declare function debounce(func: {
|
|
11
43
|
(): void;
|
|
12
44
|
apply?: any;
|
|
@@ -16,68 +48,201 @@ export declare function debounce(func: {
|
|
|
16
48
|
cancel(): void;
|
|
17
49
|
};
|
|
18
50
|
/**
|
|
19
|
-
*
|
|
51
|
+
* 图表数据项接口
|
|
52
|
+
*
|
|
53
|
+
* 定义了图表中单个数据项的结构,用于统一各种图表类型的数据格式。
|
|
54
|
+
* 支持多种图表类型的数据表示,包括分类、类型、坐标等信息。
|
|
55
|
+
*
|
|
56
|
+
* @interface ChartDataItem
|
|
57
|
+
* @since 1.0.0
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const dataItem: ChartDataItem = {
|
|
62
|
+
* x: '2024-01',
|
|
63
|
+
* y: 100,
|
|
64
|
+
* category: '销售',
|
|
65
|
+
* type: '产品A',
|
|
66
|
+
* xtitle: '月份',
|
|
67
|
+
* ytitle: '销售额',
|
|
68
|
+
* filterLabel: 'Q1'
|
|
69
|
+
* };
|
|
70
|
+
* ```
|
|
20
71
|
*/
|
|
21
72
|
export interface ChartDataItem {
|
|
22
|
-
/**
|
|
73
|
+
/** 数据类别,用于数据分组和筛选 */
|
|
23
74
|
category?: string;
|
|
24
|
-
/**
|
|
75
|
+
/** 数据类型,用于区分不同的数据系列 */
|
|
25
76
|
type?: string;
|
|
26
|
-
/** X
|
|
77
|
+
/** X轴值,可以是数字或字符串 */
|
|
27
78
|
x: number | string;
|
|
28
|
-
/** Y
|
|
79
|
+
/** Y轴值,可以是数字或字符串 */
|
|
29
80
|
y: number | string;
|
|
30
|
-
/** X
|
|
81
|
+
/** X轴标题,用于显示轴标签 */
|
|
31
82
|
xtitle?: string;
|
|
32
|
-
/** Y
|
|
83
|
+
/** Y轴标题,用于显示轴标签 */
|
|
33
84
|
ytitle?: string;
|
|
34
|
-
/**
|
|
85
|
+
/** 筛选标签,用于数据筛选和过滤 */
|
|
35
86
|
filterLabel?: string;
|
|
36
87
|
}
|
|
37
88
|
/**
|
|
38
|
-
* 归一化
|
|
39
|
-
*
|
|
40
|
-
*
|
|
89
|
+
* 归一化 X 轴值
|
|
90
|
+
*
|
|
91
|
+
* 将字符串数字转换为数字类型,避免重复标签问题。
|
|
92
|
+
* 如果输入已经是数字,直接返回;如果是字符串,尝试转换为数字。
|
|
93
|
+
* 转换失败时返回原始值。
|
|
94
|
+
*
|
|
95
|
+
* @param {number | string} value - 原始 X 轴值
|
|
96
|
+
* @returns {number | string} 归一化后的值
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* normalizeXValue(123); // 123
|
|
101
|
+
* normalizeXValue('456'); // 456
|
|
102
|
+
* normalizeXValue('abc'); // 'abc'
|
|
103
|
+
* normalizeXValue(''); // ''
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @since 1.0.0
|
|
41
107
|
*/
|
|
42
108
|
export declare const normalizeXValue: (value: number | string) => number | string;
|
|
43
109
|
/**
|
|
44
|
-
* 比较两个
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
110
|
+
* 比较两个 X 轴值的大小
|
|
111
|
+
*
|
|
112
|
+
* 用于对 X 轴值进行排序,支持数字和字符串的混合比较。
|
|
113
|
+
* 比较规则:
|
|
114
|
+
* 1. 数字优先于字符串
|
|
115
|
+
* 2. 数字按数值大小比较
|
|
116
|
+
* 3. 字符串按字典序比较
|
|
117
|
+
*
|
|
118
|
+
* @param {number | string} a - 第一个值
|
|
119
|
+
* @param {number | string} b - 第二个值
|
|
120
|
+
* @returns {number} 比较结果:负数表示 a < b,0 表示 a = b,正数表示 a > b
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* compareXValues(1, 2); // -1
|
|
125
|
+
* compareXValues('a', 'b'); // -1
|
|
126
|
+
* compareXValues(1, 'a'); // -1 (数字优先)
|
|
127
|
+
* compareXValues('a', 1); // 1 (数字优先)
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @since 1.0.0
|
|
48
131
|
*/
|
|
49
132
|
export declare const compareXValues: (a: number | string, b: number | string) => number;
|
|
50
133
|
/**
|
|
51
|
-
* 检查两个
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
134
|
+
* 检查两个 X 轴值是否相等
|
|
135
|
+
*
|
|
136
|
+
* 比较两个 X 轴值是否相等,支持数字和字符串的混合比较。
|
|
137
|
+
* 先对值进行归一化处理,然后进行比较。
|
|
138
|
+
*
|
|
139
|
+
* @param {number | string} a - 第一个值
|
|
140
|
+
* @param {number | string} b - 第二个值
|
|
141
|
+
* @returns {boolean} 是否相等
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* isXValueEqual(1, 1); // true
|
|
146
|
+
* isXValueEqual('1', 1); // true
|
|
147
|
+
* isXValueEqual('a', 'a'); // true
|
|
148
|
+
* isXValueEqual(1, 2); // false
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @since 1.0.0
|
|
55
152
|
*/
|
|
56
153
|
export declare const isXValueEqual: (a: number | string, b: number | string) => boolean;
|
|
57
154
|
/**
|
|
58
|
-
* 从数据中提取并排序
|
|
59
|
-
*
|
|
60
|
-
*
|
|
155
|
+
* 从数据中提取并排序 X 轴值
|
|
156
|
+
*
|
|
157
|
+
* 从图表数据数组中提取所有唯一的 X 轴值,并进行排序。
|
|
158
|
+
* 先对值进行归一化处理,然后去重并排序。
|
|
159
|
+
*
|
|
160
|
+
* @param {ChartDataItem[]} data - 图表数据数组
|
|
161
|
+
* @returns {Array<number | string>} 排序后的唯一 X 轴值数组
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const data = [
|
|
166
|
+
* { x: '2024-01', y: 100 },
|
|
167
|
+
* { x: '2024-02', y: 200 },
|
|
168
|
+
* { x: '2024-01', y: 150 }, // 重复值
|
|
169
|
+
* { x: 3, y: 300 }
|
|
170
|
+
* ];
|
|
171
|
+
* const sortedValues = extractAndSortXValues(data);
|
|
172
|
+
* // ['2024-01', '2024-02', 3]
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @since 1.0.0
|
|
61
176
|
*/
|
|
62
177
|
export declare const extractAndSortXValues: (data: ChartDataItem[]) => Array<number | string>;
|
|
63
178
|
/**
|
|
64
|
-
* 根据
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
179
|
+
* 根据 X 轴值查找对应的数据点
|
|
180
|
+
*
|
|
181
|
+
* 在数据数组中查找指定 X 轴值对应的数据点。
|
|
182
|
+
* 可以指定数据类型进行精确匹配。
|
|
183
|
+
*
|
|
184
|
+
* @param {ChartDataItem[]} data - 数据数组
|
|
185
|
+
* @param {number | string} xValue - X 轴值
|
|
186
|
+
* @param {string} [type] - 数据类型,可选
|
|
187
|
+
* @returns {ChartDataItem | undefined} 匹配的数据点,如果未找到返回 undefined
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* const data = [
|
|
192
|
+
* { x: '2024-01', y: 100, type: 'A' },
|
|
193
|
+
* { x: '2024-01', y: 200, type: 'B' },
|
|
194
|
+
* { x: '2024-02', y: 300, type: 'A' }
|
|
195
|
+
* ];
|
|
196
|
+
*
|
|
197
|
+
* // 查找所有类型
|
|
198
|
+
* findDataPointByXValue(data, '2024-01'); // 第一个匹配项
|
|
199
|
+
*
|
|
200
|
+
* // 查找指定类型
|
|
201
|
+
* findDataPointByXValue(data, '2024-01', 'B'); // { x: '2024-01', y: 200, type: 'B' }
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @since 1.0.0
|
|
69
205
|
*/
|
|
70
206
|
export declare const findDataPointByXValue: (data: ChartDataItem[], xValue: number | string, type?: string) => ChartDataItem | undefined;
|
|
71
207
|
/**
|
|
72
208
|
* 将值转换为数字
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
209
|
+
*
|
|
210
|
+
* 安全地将任意值转换为数字类型,转换失败时返回默认值。
|
|
211
|
+
* 如果输入已经是有效的数字,直接返回;否则尝试转换。
|
|
212
|
+
*
|
|
213
|
+
* @param {any} val - 要转换的值
|
|
214
|
+
* @param {number} fallback - 转换失败时的默认值
|
|
215
|
+
* @returns {number} 转换后的数字
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* toNumber('123', 0); // 123
|
|
220
|
+
* toNumber(456, 0); // 456
|
|
221
|
+
* toNumber('abc', 0); // 0
|
|
222
|
+
* toNumber(null, 100); // 100
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @since 1.0.0
|
|
76
226
|
*/
|
|
77
227
|
export declare const toNumber: (val: any, fallback: number) => number;
|
|
78
228
|
/**
|
|
79
229
|
* 检查值是否不为空
|
|
80
|
-
*
|
|
81
|
-
*
|
|
230
|
+
*
|
|
231
|
+
* 检查值是否不为 null 和 undefined。
|
|
232
|
+
* 用于数据验证和条件判断。
|
|
233
|
+
*
|
|
234
|
+
* @param {any} val - 要检查的值
|
|
235
|
+
* @returns {boolean} 是否不为空
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* isNotEmpty('hello'); // true
|
|
240
|
+
* isNotEmpty(0); // true
|
|
241
|
+
* isNotEmpty(''); // true
|
|
242
|
+
* isNotEmpty(null); // false
|
|
243
|
+
* isNotEmpty(undefined); // false
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @since 1.0.0
|
|
82
247
|
*/
|
|
83
248
|
export declare const isNotEmpty: (val: any) => boolean;
|