@advt-gpt-chart/package 3.2.1 → 3.2.4
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/Chart/ChartBase/constants.d.ts +8 -19
- package/dist/Chart/ChartBase/transformed.d.ts +1 -1
- package/dist/Chart/ChartBase/types.d.ts +2 -2
- package/dist/Chart/ChartCodeRender/type.d.ts +2 -2
- package/dist/Chart/ChartControllers/ChartDetailData/index.d.ts +1 -1
- package/dist/Chart/ChartControllers/index.d.ts +1 -1
- package/dist/Chart/ChartEvents/ChartContextMenu/utils.d.ts +1 -1
- package/dist/Chart/ChartEvents/DrillBy/DrillByChart.d.ts +1 -1
- package/dist/Chart/ChartWrapper/ChartHeader.d.ts +1 -1
- package/dist/Chart/ChartWrapper/ChartMenu.d.ts +1 -1
- package/dist/Chart/ChartWrapper/utils.d.ts +33 -5
- package/dist/Charts/Area/index.d.ts +1 -2
- package/dist/Charts/Bar/index.d.ts +1 -2
- package/dist/Charts/Composite/index.d.ts +1 -2
- package/dist/Charts/Composite/transform.d.ts +13 -0
- package/dist/Charts/Composite/types.d.ts +14 -23
- package/dist/Charts/Composite/util.d.ts +29 -9
- package/dist/Charts/Donut/index.d.ts +1 -2
- package/dist/Charts/Funnel/index.d.ts +1 -2
- package/dist/Charts/Gauge/index.d.ts +1 -2
- package/dist/Charts/Heatmap/index.d.ts +1 -2
- package/dist/Charts/Line/index.d.ts +1 -2
- package/dist/Charts/Pie/index.d.ts +1 -2
- package/dist/Charts/Radar/index.d.ts +1 -2
- package/dist/Charts/Rank/index.d.ts +1 -2
- package/dist/Charts/Scatter/index.d.ts +1 -2
- package/dist/Charts/common/cartesianCommon.d.ts +34 -0
- package/dist/Charts/common/createChart.d.ts +7 -0
- package/dist/Charts/common/hooks/useDashLine.d.ts +6 -3
- package/dist/Charts/common/index.d.ts +3 -0
- package/dist/Charts/common/polarCommon.d.ts +44 -0
- package/dist/{Chart → DataView}/DataSource/types.d.ts +1 -1
- package/dist/DataView/Dataset/DataView.d.ts +40 -0
- package/dist/DataView/Dataset/constants.d.ts +15 -0
- package/dist/DataView/Dataset/index.d.ts +9 -0
- package/dist/DataView/Dataset/transforms.d.ts +95 -0
- package/dist/{Chart → DataView}/Dataset/types.d.ts +1 -0
- package/dist/DataView/data-set/data-set.d.ts +39 -0
- package/dist/DataView/data-set/index.d.ts +3 -0
- package/dist/DataView/data-set/transforms/format-transform.d.ts +9 -0
- package/dist/DataView/data-set/transforms/index.d.ts +3 -0
- package/dist/DataView/data-set/transforms/multi-dimension-transform.d.ts +3 -0
- package/dist/DataView/data-set/transforms/multi-metric-transform.d.ts +3 -0
- package/dist/DataView/data-set/types.d.ts +55 -0
- package/dist/GPTVis/hooks/useChartStore.d.ts +2 -2
- package/dist/components/CustomTimeRange/types.d.ts +1 -1
- package/dist/components/CustomTimeRange/utils.d.ts +1 -1
- package/dist/index.es.js +34291 -34351
- package/dist/index.es.js.gz +0 -0
- package/dist/index.umd.js +753 -753
- package/dist/index.umd.js.gz +0 -0
- package/dist/types/chart.d.ts +12 -12
- package/dist/utils/useTools.d.ts +5 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/Chart/Dataset/useDataset.d.ts +0 -92
- package/dist/Charts/Composite/config.d.ts +0 -22
- package/dist/Charts/common/constants/index.d.ts +0 -0
- package/dist/Charts/common/tools/index.d.ts +0 -0
- /package/dist/{Chart → DataView}/DataSource/index.d.ts +0 -0
- /package/dist/{Chart → DataView}/DataSource/metricInsight.d.ts +0 -0
- /package/dist/{Chart → DataView}/DataSource/simpleJson.d.ts +0 -0
- /package/dist/{Chart → DataView}/DataSource/useChartDataQuery.d.ts +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数据转换工具函数
|
|
3
|
+
*
|
|
4
|
+
* 这些是纯工具函数,不依赖 DataView 类实例状态
|
|
5
|
+
*/
|
|
6
|
+
import { Dayjs } from 'dayjs';
|
|
7
|
+
import { ChartJson } from '../../Chart/ChartCodeRender/type';
|
|
8
|
+
import { ChartType } from '../../types/chart';
|
|
9
|
+
import { DataItem } from '../../types/chart';
|
|
10
|
+
import { TimeGrainType } from '../../utils/date';
|
|
11
|
+
import { Dataset, FieldInfoItem } from '../Dataset/types';
|
|
12
|
+
/**
|
|
13
|
+
* 过滤数据
|
|
14
|
+
* 根据 metrics 和 dimensions 过滤数据字段
|
|
15
|
+
*/
|
|
16
|
+
export declare const filterDataByFieldInfo: (data: Record<string, any>[], { metrics, dimensions }: {
|
|
17
|
+
metrics?: string[];
|
|
18
|
+
dimensions?: string[];
|
|
19
|
+
}) => Record<string, any>[];
|
|
20
|
+
/**
|
|
21
|
+
* Fold 转换
|
|
22
|
+
* 将宽数据转换为长数据
|
|
23
|
+
*/
|
|
24
|
+
export declare const transform2FoldData: (data: Record<string, any>[], dimensions?: string[], metrics?: string[]) => {
|
|
25
|
+
foldData: DataItem[];
|
|
26
|
+
foldKey?: string;
|
|
27
|
+
foldValue?: string;
|
|
28
|
+
isMetricFolded: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 设置字段角色
|
|
32
|
+
* 根据 metrics 和 dimensions 设置字段的 role
|
|
33
|
+
*/
|
|
34
|
+
export declare const setFieldItem: (item: FieldInfoItem, metrics?: any[], dimensions?: any[]) => FieldInfoItem;
|
|
35
|
+
/**
|
|
36
|
+
* 按维度合并数据
|
|
37
|
+
* 生成合并列名,用于数据分组
|
|
38
|
+
*/
|
|
39
|
+
export declare const mergeDataByDimensions: (data: Record<string, any>[], fieldInfo: FieldInfoItem[], type: ChartType, dimensions?: string[], metrics?: string[]) => {
|
|
40
|
+
data: DataItem[];
|
|
41
|
+
isColumnMegred?: boolean;
|
|
42
|
+
megreColumnName?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* 时间补点
|
|
46
|
+
* 根据时间范围和时间粒度补全缺失的数据点
|
|
47
|
+
*/
|
|
48
|
+
export declare const transform2FillData: (data: Record<string, any>[], { fieldInfo, dimensions, metrics, timeGrain, }: {
|
|
49
|
+
fieldInfo?: FieldInfoItem[];
|
|
50
|
+
dimensions?: string[];
|
|
51
|
+
metrics?: string[];
|
|
52
|
+
timeGrain?: TimeGrainType;
|
|
53
|
+
}) => Record<string, any>[];
|
|
54
|
+
/**
|
|
55
|
+
* 生成时间序列
|
|
56
|
+
* 根据时间范围和时间粒度生成时间序列
|
|
57
|
+
*/
|
|
58
|
+
export declare const generateTimeSeries: (startTime: any, endTime: any, timeGrain: any) => string[];
|
|
59
|
+
/**
|
|
60
|
+
* 填充数据
|
|
61
|
+
* 根据时间序列填充缺失的数据点
|
|
62
|
+
*/
|
|
63
|
+
export declare const filledDataByTimeSeries: (sortedData: Record<string, any>[] | undefined, timeSeries: string[], timeGrain: TimeGrainType, timeField: string, metrics?: string[]) => Record<string, any>[];
|
|
64
|
+
/**
|
|
65
|
+
* 获取时间间隔
|
|
66
|
+
* 根据时间粒度计算时间间隔(毫秒)
|
|
67
|
+
*/
|
|
68
|
+
export declare const getTimeGrainInterval: (timeGrain: string, sortedData: any[], timeField: string) => number;
|
|
69
|
+
/**
|
|
70
|
+
* 格式化时间到粒度
|
|
71
|
+
* 将时间值格式化为指定粒度的字符串
|
|
72
|
+
*/
|
|
73
|
+
export declare const formatTime2TimeGrain: (timeGrain: TimeGrainType, value: Dayjs | number) => string;
|
|
74
|
+
/**
|
|
75
|
+
* 获取字段信息
|
|
76
|
+
* 从数据中提取字段信息并设置角色
|
|
77
|
+
*/
|
|
78
|
+
export declare const getFileldInfo: (data: Record<string, any>[], { columns, metrics, dimensions, }: {
|
|
79
|
+
columns?: Record<string, any>[];
|
|
80
|
+
metrics?: string[];
|
|
81
|
+
dimensions?: string[];
|
|
82
|
+
}) => FieldInfoItem[];
|
|
83
|
+
/**
|
|
84
|
+
* 检查是否需要更新 DataSet
|
|
85
|
+
* 比较新旧数据,判断是否需要重新转换
|
|
86
|
+
*/
|
|
87
|
+
export declare const checkUptateDataSet: (preJson: ChartJson, newJson: ChartJson, dataset: Dataset) => {
|
|
88
|
+
dataset?: Dataset;
|
|
89
|
+
isShouldUpdate: boolean;
|
|
90
|
+
};
|
|
91
|
+
export declare const transform2FillAndMegreData: (data: any[] | undefined, fieldInfo: FieldInfoItem[] | undefined, chartJson: ChartJson) => {
|
|
92
|
+
data: DataItem[];
|
|
93
|
+
isColumnMegred?: boolean;
|
|
94
|
+
megreColumnName?: string;
|
|
95
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DataItem } from '../../types';
|
|
2
|
+
import { GenericDataType } from '../../utils/data';
|
|
3
|
+
import { multiDimensionTransform, multiMetricTransform } from './transforms';
|
|
4
|
+
import type { DataSetOptions, ProcessedItem, TransformOptions } from './types';
|
|
5
|
+
export declare class DataSet {
|
|
6
|
+
private data;
|
|
7
|
+
private options;
|
|
8
|
+
constructor(data: DataItem[], options?: DataSetOptions);
|
|
9
|
+
/**
|
|
10
|
+
* 获取字段类型
|
|
11
|
+
*/
|
|
12
|
+
getFieldType(fieldName: string): GenericDataType;
|
|
13
|
+
/**
|
|
14
|
+
* 获取轴类型
|
|
15
|
+
*/
|
|
16
|
+
getAxesType(fieldName: string): 'band' | 'linear';
|
|
17
|
+
/**
|
|
18
|
+
* 格式化单个值
|
|
19
|
+
*/
|
|
20
|
+
formatValue(fieldName: string, value: any, formatTimeStr?: string): any;
|
|
21
|
+
/**
|
|
22
|
+
* 创建 label 格式化方法
|
|
23
|
+
*/
|
|
24
|
+
createLabelFormatMethod(fieldName: string): (text: string | string[], datum: any) => any;
|
|
25
|
+
/**
|
|
26
|
+
* 创建 tooltip 格式化方法
|
|
27
|
+
*/
|
|
28
|
+
createTooltipFormatMethod(fieldName: string): (datum: any) => any;
|
|
29
|
+
format(dataFormat?: DataSetOptions['dataFormat']): DataSet;
|
|
30
|
+
transform(options: TransformOptions | ((data: DataItem[]) => DataItem[])): DataSet;
|
|
31
|
+
private applyDeriveTransform;
|
|
32
|
+
multiDimension(options: Parameters<typeof multiDimensionTransform>[1]): DataSet;
|
|
33
|
+
multiMetric(options: Parameters<typeof multiMetricTransform>[1]): DataSet;
|
|
34
|
+
filter(predicate: (item: DataItem) => boolean): DataSet;
|
|
35
|
+
sort(compareFn?: (a: DataItem, b: DataItem) => number): DataSet;
|
|
36
|
+
result(): ProcessedItem[];
|
|
37
|
+
getData(): DataItem[];
|
|
38
|
+
}
|
|
39
|
+
export default DataSet;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataItem } from '../../../types';
|
|
2
|
+
import type { ColumnInfo, FormatTransformOptions } from '../types';
|
|
3
|
+
export declare function formatNumber(value: number, config: any): string;
|
|
4
|
+
export declare function formatTime(value: any, timeGrain?: string): string;
|
|
5
|
+
export declare function isTimeFieldType(type: string): boolean;
|
|
6
|
+
export declare function formatTransform(data: DataItem[], options: FormatTransformOptions & {
|
|
7
|
+
timeGrain?: string;
|
|
8
|
+
columns?: ColumnInfo[];
|
|
9
|
+
}): DataItem[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DataItem } from "../../types";
|
|
2
|
+
export type FormatType = 'none' | 'number' | 'percentage_raw' | 'percentage_scaled' | 'date' | 'time';
|
|
3
|
+
export interface FormatConfig {
|
|
4
|
+
formatType: FormatType;
|
|
5
|
+
suffix?: string;
|
|
6
|
+
prefix?: string;
|
|
7
|
+
decimalPlaces?: number;
|
|
8
|
+
valueUnit?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface DataFormat {
|
|
11
|
+
[field: string]: FormatConfig;
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnInfo {
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DataSetOptions {
|
|
18
|
+
dataFormat?: DataFormat;
|
|
19
|
+
columns?: ColumnInfo[];
|
|
20
|
+
timeGrain?: string;
|
|
21
|
+
timeGrainFormat?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TransformOptions {
|
|
24
|
+
type: 'format' | 'multi-dimension' | 'multi-metric' | 'derive' | string;
|
|
25
|
+
options: any;
|
|
26
|
+
}
|
|
27
|
+
export interface MultiDimensionOptions {
|
|
28
|
+
dimensions: string[];
|
|
29
|
+
metrics: string[];
|
|
30
|
+
transformType: 'fold' | 'pivot';
|
|
31
|
+
key?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
export interface MultiMetricOptions {
|
|
36
|
+
groupBy: string[];
|
|
37
|
+
aggregations: AggregationConfig[];
|
|
38
|
+
}
|
|
39
|
+
export interface AggregationConfig {
|
|
40
|
+
field: string;
|
|
41
|
+
op: 'sum' | 'avg' | 'count' | 'max' | 'min' | string;
|
|
42
|
+
as: string;
|
|
43
|
+
}
|
|
44
|
+
export type ProcessedItem = DataItem & {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
};
|
|
47
|
+
export interface FormatTransformOptions {
|
|
48
|
+
dataFormat?: DataFormat;
|
|
49
|
+
timeGrain?: string;
|
|
50
|
+
columns?: ColumnInfo[];
|
|
51
|
+
}
|
|
52
|
+
export interface DeriveTransformOptions {
|
|
53
|
+
field: string;
|
|
54
|
+
formula: (item: DataItem) => any;
|
|
55
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ChartJson } from '../../Chart/ChartCodeRender/type';
|
|
2
2
|
import { ChartControllersState } from '../../Chart/ChartControllers';
|
|
3
|
-
import type { Dataset } from '../../
|
|
4
|
-
import { DataSourceQueryInfo } from '../../
|
|
3
|
+
import type { Dataset } from '../../DataView/Dataset/types';
|
|
4
|
+
import { DataSourceQueryInfo } from '../../DataView/DataSource/types';
|
|
5
5
|
import { BaseChartProps } from '../../types';
|
|
6
6
|
export interface ContextMenu {
|
|
7
7
|
visible: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
import { FilterItemType } from '../../Chart/ChartControllers/Filter/types';
|
|
3
3
|
import { OrderItemType } from '../../Chart/ChartControllers/Orders/types';
|
|
4
|
-
import { DataFormat } from '../../
|
|
4
|
+
import { DataFormat } from '../../DataView/Dataset/types';
|
|
5
5
|
import { TimeGrainType } from '../../utils';
|
|
6
6
|
export type CustomTimeRange = {
|
|
7
7
|
from?: Dayjs;
|