@advt-gpt-chart/package 3.2.1 → 3.2.3
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 +4 -4
- 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 +3 -2
- 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 +35414 -35547
- package/dist/index.es.js.gz +0 -0
- package/dist/index.umd.js +752 -752
- 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
|
@@ -4,7 +4,7 @@ import { AxesType } from './utils';
|
|
|
4
4
|
type CartesianOptions = {
|
|
5
5
|
xField: string;
|
|
6
6
|
yField: string;
|
|
7
|
-
|
|
7
|
+
isMetricFolded?: boolean;
|
|
8
8
|
};
|
|
9
9
|
type CartesianTooltipOptions = CartesianOptions & {
|
|
10
10
|
seriesField?: string;
|
|
@@ -18,23 +18,13 @@ type PolarTooltipOptions = {
|
|
|
18
18
|
categoryFieldType?: AxesType;
|
|
19
19
|
isMetricFolded?: boolean;
|
|
20
20
|
};
|
|
21
|
-
type CompositeAxisSpec = {
|
|
22
|
-
orient: 'left' | 'right' | 'bottom' | 'top';
|
|
23
|
-
seriesIndex?: number[];
|
|
24
|
-
seriesId?: string[];
|
|
25
|
-
type?: string;
|
|
26
|
-
label?: any;
|
|
27
|
-
grid?: any;
|
|
28
|
-
title?: any;
|
|
29
|
-
offset?: number;
|
|
30
|
-
min?: number;
|
|
31
|
-
max?: number;
|
|
32
|
-
[key: string]: any;
|
|
33
|
-
};
|
|
34
21
|
export type Tools = {
|
|
35
22
|
formatValue: (field: string, value: any) => any;
|
|
23
|
+
formatValueWithoutUnit: (field: string, value: any) => any;
|
|
36
24
|
getAxesType: (field: string) => 'band' | 'linear';
|
|
37
25
|
getFieldType: (fieldName: string, value?: any) => GenericDataType | undefined;
|
|
26
|
+
createLabelFormatMethod: (axesConfig: any, isMetricFolded?: boolean) => (val: any, datum: any) => any;
|
|
27
|
+
getUnit: (field: string) => string;
|
|
38
28
|
};
|
|
39
29
|
export declare const getPolarLegendSpec: (seriesField: string | boolean | undefined, categoryField: string, tools?: Tools) => {
|
|
40
30
|
visible: boolean;
|
|
@@ -51,18 +41,18 @@ export declare const getPolarTooltipSpec: ({ categoryField, valueField, seriesFi
|
|
|
51
41
|
value: (datum: any) => any;
|
|
52
42
|
};
|
|
53
43
|
content: {
|
|
54
|
-
key: () =>
|
|
44
|
+
key: (datum: any) => any;
|
|
55
45
|
value: (datum: any) => any;
|
|
56
|
-
}
|
|
46
|
+
};
|
|
57
47
|
};
|
|
58
48
|
dimension: {
|
|
59
49
|
title: {
|
|
60
50
|
value: (datum: any) => any;
|
|
61
51
|
};
|
|
62
52
|
content: {
|
|
63
|
-
key: () =>
|
|
53
|
+
key: (datum: any) => any;
|
|
64
54
|
value: (datum: any) => any;
|
|
65
|
-
}
|
|
55
|
+
};
|
|
66
56
|
};
|
|
67
57
|
};
|
|
68
58
|
export declare const getLineStyle: () => {
|
|
@@ -88,7 +78,6 @@ export declare const getLineStyle: () => {
|
|
|
88
78
|
};
|
|
89
79
|
};
|
|
90
80
|
export declare const getCartesianAxesSpec: (options: CartesianOptions, tools?: Tools) => ICartesianAxisSpec[];
|
|
91
|
-
export declare const getCompositeAxesSpec: (series: any[], yFields: string[], yAxesConfig?: any[], seriesIds?: string[]) => CompositeAxisSpec[];
|
|
92
81
|
export declare const getCartesianTootipSpec: ({ xField, yField, seriesField, isMetricFolded }: CartesianTooltipOptions, tools?: Tools) => {
|
|
93
82
|
mark: {
|
|
94
83
|
updateTitle: (prev: any) => any;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { IChartSpec } from '@visactor/vchart';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import type { ChartProps } from '../../Chart/ChartCodeRender/type';
|
|
4
|
+
import { Dataset, FieldInfoItem } from '../../DataView/Dataset/types';
|
|
5
|
+
import { DataSource } from '../../DataView/DataSource/types';
|
|
4
6
|
import { ContextMenu } from '../../GPTVis/hooks/useChartStore';
|
|
5
7
|
import { BaseChartProps, DataItem } from '../../types';
|
|
6
|
-
import { Dataset, FieldInfoItem } from '../Dataset/types';
|
|
7
|
-
import { DataSource } from '../DataSource/types';
|
|
8
8
|
/**
|
|
9
9
|
* 合并后的属性类型,包含上下文菜单回调
|
|
10
10
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import type { Components, ExtraProps } from 'react-markdown';
|
|
4
|
+
import { DataFormat, Dataset, FieldInfoItem } from '../../DataView/Dataset/types';
|
|
5
|
+
import { DataSource } from '../../DataView/DataSource/types';
|
|
4
6
|
import { ChartType, DataItem } from '../../types';
|
|
5
7
|
import { TimeGrainType } from '../../utils';
|
|
6
|
-
import { DataFormat, Dataset, FieldInfoItem } from '../Dataset/types';
|
|
7
|
-
import { DataSource } from '../DataSource/types';
|
|
8
8
|
export interface MetricItem {
|
|
9
9
|
id: string;
|
|
10
10
|
name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OptionType, TimeRange } from '../../components/CustomTimeRange/types';
|
|
2
|
+
import { DataSource } from '../../DataView/DataSource/types';
|
|
2
3
|
import { TimeGrainType } from '../../utils/date';
|
|
3
|
-
import { DataSource } from '../DataSource/types';
|
|
4
4
|
import { FilterItemType } from './Filter/types';
|
|
5
5
|
import { OrderItemType } from './Orders/types';
|
|
6
6
|
import { dimensionsOptionType } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldInfoItem } from '
|
|
1
|
+
import { FieldInfoItem } from '../../../DataView/Dataset/types';
|
|
2
2
|
export declare function getRightClickInfo(rightClickValue: any[], fieldInfo: FieldInfoItem[] | undefined, metricTime: {
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
@@ -9,7 +9,7 @@ export declare function isChartAdvisor(chartJson: ChartJson): boolean;
|
|
|
9
9
|
export declare function chartAdvisor(chartJson: ChartJson): Promise<{
|
|
10
10
|
type: any;
|
|
11
11
|
data: import("../..").DataItem[];
|
|
12
|
-
dataset?: import("
|
|
12
|
+
dataset?: import("../../DataView/Dataset/types").Dataset;
|
|
13
13
|
chartId?: string;
|
|
14
14
|
chartName?: string;
|
|
15
15
|
xField?: string;
|
|
@@ -18,10 +18,10 @@ export declare function chartAdvisor(chartJson: ChartJson): Promise<{
|
|
|
18
18
|
valField?: string;
|
|
19
19
|
dimensions?: string[];
|
|
20
20
|
metrics?: string[];
|
|
21
|
-
dataSource?: import("
|
|
22
|
-
columns?: import("
|
|
21
|
+
dataSource?: import("../../DataView/DataSource/types").DataSource;
|
|
22
|
+
columns?: import("../../DataView/Dataset/types").FieldInfoItem[];
|
|
23
23
|
timeGrain?: import("../../utils").TimeGrainType;
|
|
24
|
-
dataFormat?: import("
|
|
24
|
+
dataFormat?: import("../../DataView/Dataset/types").DataFormat;
|
|
25
25
|
hideChartHeader?: boolean;
|
|
26
26
|
series?: any[];
|
|
27
27
|
agent?: import("../ChartCodeRender/type").AgentConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CompositeSeries } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 将 series 配置转换为内部使用的 xField/yField 格式
|
|
4
|
+
* 支持 dimensions/metrics 和 xField/yField 两种方式
|
|
5
|
+
*
|
|
6
|
+
* 优先级:xField/yField > dimensions/metrics
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeSeriesField(series: CompositeSeries): {
|
|
9
|
+
xField: string;
|
|
10
|
+
yField: string;
|
|
11
|
+
dimensions: string[];
|
|
12
|
+
metrics: string[];
|
|
13
|
+
};
|
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
import type { BaseVChartConfig, BaseVChartProps, DataItem } from '../../types';
|
|
2
|
-
import { BarConfig } from '../Bar/types';
|
|
3
2
|
export type CompositeSeriesType = 'bar' | 'line' | 'area' | 'scatter';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
visible?: boolean;
|
|
10
|
-
text?: string;
|
|
11
|
-
};
|
|
12
|
-
label?: Record<string, any>;
|
|
13
|
-
type?: string;
|
|
14
|
-
min?: number;
|
|
15
|
-
max?: number;
|
|
16
|
-
grid?: {
|
|
17
|
-
visible?: boolean;
|
|
18
|
-
};
|
|
19
|
-
offset?: number;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
export type CompositeSeries = Omit<BarConfig, 'data' | 'chartName'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Composite 组合图的 series 配置
|
|
5
|
+
* 只包含数据相关的配置,格式化等全局配置在顶层
|
|
6
|
+
*/
|
|
7
|
+
export type CompositeSeries = {
|
|
23
8
|
type: CompositeSeriesType;
|
|
24
9
|
data?: DataItem[];
|
|
25
|
-
|
|
10
|
+
dimensions?: string[];
|
|
11
|
+
metrics?: string[];
|
|
12
|
+
xField?: string;
|
|
13
|
+
yField?: string;
|
|
26
14
|
};
|
|
27
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Composite 组合图配置
|
|
17
|
+
* 全局配置(dataFormat、columns、timeGrain 等)在顶层,与单图表保持一致
|
|
18
|
+
*/
|
|
19
|
+
export type CompositeConfig = BaseVChartConfig & {
|
|
28
20
|
series: CompositeSeries[];
|
|
29
|
-
yAxes?: YAxisConfig[];
|
|
30
21
|
};
|
|
31
22
|
export type CompositeProps = BaseVChartProps & Partial<CompositeConfig>;
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
+
import type { Tools } from '../../Chart/ChartBase/constants';
|
|
1
2
|
import { DataItem } from '../../types';
|
|
2
|
-
import { CompositeSeries } from './types';
|
|
3
|
+
import type { CompositeSeries } from './types';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* 构建多 Y 轴配置
|
|
6
|
+
* - 第 1 个系列:左轴
|
|
7
|
+
* - 第 2-5 个系列:右轴(带偏移)
|
|
8
|
+
* 注意:不包含 X 轴,X 轴由 getCartesianAxesSpec 生成
|
|
5
9
|
*/
|
|
6
|
-
export declare function
|
|
10
|
+
export declare function buildCompositeAxesSpec(series: CompositeSeries[], tools: Tools): any[];
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* 为 series 创建 label 格式化函数
|
|
13
|
+
* 使用顶层的 dataFormat 配置(与单图表保持一致)
|
|
9
14
|
*/
|
|
10
|
-
export declare function
|
|
15
|
+
export declare function createSeriesLabelFormatMethod(series: CompositeSeries, tools: Tools): (val: any) => any;
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
17
|
+
* 为数据添加 series 标识字段
|
|
13
18
|
*/
|
|
14
|
-
export declare function
|
|
19
|
+
export declare function addSeriesMetadata(data: DataItem[] | undefined, seriesType: string, seriesIndex: number): DataItem[];
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
21
|
+
* 构建 tooltip 配置
|
|
17
22
|
*/
|
|
18
|
-
export declare function
|
|
23
|
+
export declare function buildCompositeTooltip(series: CompositeSeries[], xField: string, tools: Tools): {
|
|
24
|
+
mark: {
|
|
25
|
+
updateTitle: (prev: any) => any;
|
|
26
|
+
content: {
|
|
27
|
+
key: (datum: any) => string;
|
|
28
|
+
value: (datum: any) => any;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
dimension: {
|
|
32
|
+
updateTitle: (prev: any) => any;
|
|
33
|
+
content: {
|
|
34
|
+
key: (datum: any) => string;
|
|
35
|
+
value: (datum: any) => any;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Tools } from '../../Chart/ChartBase/constants';
|
|
2
|
+
interface CartesianCommonOptions {
|
|
3
|
+
axesConfig: {
|
|
4
|
+
xField: string | string[];
|
|
5
|
+
yField: string;
|
|
6
|
+
seriesField?: string;
|
|
7
|
+
};
|
|
8
|
+
xField: string;
|
|
9
|
+
dataset?: any;
|
|
10
|
+
tools: Tools;
|
|
11
|
+
chartConfig?: any;
|
|
12
|
+
}
|
|
13
|
+
export declare function cartesianCommon(options: CartesianCommonOptions): {
|
|
14
|
+
legends: any;
|
|
15
|
+
axes: import("@visactor/vchart").ICartesianAxisSpec[];
|
|
16
|
+
tooltip: {
|
|
17
|
+
mark: {
|
|
18
|
+
updateTitle: (prev: any) => any;
|
|
19
|
+
content: {
|
|
20
|
+
key: (datum: any) => any;
|
|
21
|
+
value: (datum: any) => any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
dimension: {
|
|
25
|
+
updateTitle: (prev: any) => any;
|
|
26
|
+
content: {
|
|
27
|
+
key: (datum: any) => any;
|
|
28
|
+
value: (datum: any) => any;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
label: any;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Tools } from '../../Chart/ChartBase/constants';
|
|
2
|
+
import { ChartConfig } from '../../ConfigProvider/hooks';
|
|
3
|
+
import { Charts } from '../../types';
|
|
4
|
+
import { useChartConfigTools } from './hooks';
|
|
5
|
+
type SpecFactory<TConfig extends ChartConfig> = (props: TConfig, tools: Tools, chartConfig: ReturnType<typeof useChartConfigTools>) => any;
|
|
6
|
+
export declare function createChart<TConfig extends ChartConfig>(chartName: Charts, ChartComponent: any, createSpec: SpecFactory<TConfig>): (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -16,9 +16,10 @@ import type { DashSegment } from '../types';
|
|
|
16
16
|
* });
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare const useDashLine: ({ data, xField, getFieldType, dashSegments, }: {
|
|
19
|
+
export declare const useDashLine: ({ data, xField, yField, getFieldType, dashSegments, }: {
|
|
20
20
|
data: any[];
|
|
21
|
-
xField
|
|
21
|
+
xField: string;
|
|
22
|
+
yField: string;
|
|
22
23
|
getFieldType?: (fieldName: string, value?: any) => GenericDataType | undefined;
|
|
23
24
|
dashSegments?: DashSegment[];
|
|
24
25
|
}) => {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Tools } from '../../Chart/ChartBase/constants';
|
|
2
|
+
interface PolarCommonOptions {
|
|
3
|
+
axesConfig: {
|
|
4
|
+
nameField: string;
|
|
5
|
+
valField: string;
|
|
6
|
+
seriesField?: string;
|
|
7
|
+
};
|
|
8
|
+
dataset?: any;
|
|
9
|
+
tools: Tools;
|
|
10
|
+
chartConfig?: any;
|
|
11
|
+
showPercent?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function polarCommon(options: PolarCommonOptions): {
|
|
14
|
+
tooltip: {
|
|
15
|
+
mark: {
|
|
16
|
+
title: {
|
|
17
|
+
value: (datum: any) => any;
|
|
18
|
+
};
|
|
19
|
+
content: {
|
|
20
|
+
key: (datum: any) => any;
|
|
21
|
+
value: (datum: any) => any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
dimension: {
|
|
25
|
+
title: {
|
|
26
|
+
value: (datum: any) => any;
|
|
27
|
+
};
|
|
28
|
+
content: {
|
|
29
|
+
key: (datum: any) => any;
|
|
30
|
+
value: (datum: any) => any;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
legends: {
|
|
35
|
+
visible: boolean;
|
|
36
|
+
item: {
|
|
37
|
+
label: {
|
|
38
|
+
formatMethod: (val: any) => any;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
label: any;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { FilterItem } from '../../Chart/ChartControllers/Filter/types';
|
|
1
2
|
import { TimeRange } from '../../components/CustomTimeRange/types';
|
|
2
|
-
import { FilterItem } from '../ChartControllers/Filter/types';
|
|
3
3
|
import { FieldInfoItem } from '../Dataset/types';
|
|
4
4
|
export declare const DataSourceTypes: {
|
|
5
5
|
METRIC: string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataView - 数据视图层(精简版)
|
|
3
|
+
*
|
|
4
|
+
* 核心类,只保留核心业务逻辑
|
|
5
|
+
* 工具函数已提取到 transforms.ts
|
|
6
|
+
*/
|
|
7
|
+
import { ChartJson } from '../../Chart/ChartCodeRender/type';
|
|
8
|
+
import { Dataset, FieldInfoItem } from '../Dataset/types';
|
|
9
|
+
/**
|
|
10
|
+
* DataView 类
|
|
11
|
+
* 核心职责:状态管理 + 流程协调
|
|
12
|
+
*/
|
|
13
|
+
export declare class DataView {
|
|
14
|
+
private chartJson;
|
|
15
|
+
private fieldInfo;
|
|
16
|
+
private transformResult;
|
|
17
|
+
constructor(chartJson: ChartJson);
|
|
18
|
+
/**
|
|
19
|
+
* 转换数据(核心入口)
|
|
20
|
+
* 协调所有转换步骤
|
|
21
|
+
*/
|
|
22
|
+
transform(): Dataset;
|
|
23
|
+
/**
|
|
24
|
+
* 获取转换结果
|
|
25
|
+
*/
|
|
26
|
+
getResult(): Dataset;
|
|
27
|
+
/**
|
|
28
|
+
* 获取字段信息
|
|
29
|
+
*/
|
|
30
|
+
getFieldInfo(): FieldInfoItem[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 独立导出函数(保持与旧代码兼容)
|
|
34
|
+
*/
|
|
35
|
+
export declare const transform2Dataset: (chartJson: ChartJson) => Dataset;
|
|
36
|
+
export declare const checkUptateDataSet: (preJson: ChartJson, newJson: ChartJson, dataset: Dataset) => {
|
|
37
|
+
dataset?: Dataset;
|
|
38
|
+
isShouldUpdate: boolean;
|
|
39
|
+
};
|
|
40
|
+
export default DataView;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataView 常量
|
|
3
|
+
*/
|
|
4
|
+
export declare const SEPARATOR = ",";
|
|
5
|
+
export declare const FOLD_KEY_NAME = "fold-key";
|
|
6
|
+
export declare const MERGE_COLUMN_KEY_NAME = "megre-column-name";
|
|
7
|
+
/**
|
|
8
|
+
* 生成唯一键名
|
|
9
|
+
* 每次调用都会生成新的唯一键
|
|
10
|
+
*/
|
|
11
|
+
export declare const getKeys: () => {
|
|
12
|
+
keyId: string;
|
|
13
|
+
FOLD_KEY: string;
|
|
14
|
+
MERGE_COLUMN_NAME: string;
|
|
15
|
+
};
|
|
@@ -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
|
+
};
|