@advt-gpt-chart/package 2.1.1 → 2.1.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.
Files changed (34) hide show
  1. package/README.md +55 -55
  2. package/dist/Chart/ChartBase/constants.d.ts +8 -24
  3. package/dist/Chart/ChartBase/transformed.d.ts +1 -0
  4. package/dist/Chart/ChartCodeRender/type.d.ts +2 -1
  5. package/dist/Chart/ChartControllers/DataFormat/DataFormat.d.ts +6 -0
  6. package/dist/Chart/ChartControllers/DataFormat/styles.d.ts +3 -0
  7. package/dist/Chart/ChartControllers/DataFormat/types.d.ts +0 -0
  8. package/dist/Chart/ChartControllers/DataFormat/utils.d.ts +12 -0
  9. package/dist/Chart/ChartControllers/TimeRange/types.d.ts +2 -0
  10. package/dist/Chart/ChartControllers/utils.d.ts +14 -0
  11. package/dist/Chart/ChartWrapper/ChartHeader.d.ts +3 -1
  12. package/dist/Chart/ChartWrapper/ChartMenu.d.ts +2 -0
  13. package/dist/Chart/ChartWrapper/ChartWrapper.d.ts +1 -1
  14. package/dist/Chart/ChartWrapper/contants.d.ts +4 -0
  15. package/dist/Chart/ChartWrapper/style.d.ts +4 -5
  16. package/dist/Chart/ChartWrapper/utils.d.ts +2 -0
  17. package/dist/Chart/DataSource/useChartDataQuery.d.ts +1 -1
  18. package/dist/Chart/Dataset/types.d.ts +9 -0
  19. package/dist/Chart/Dataset/useDataset.d.ts +12 -4
  20. package/dist/Charts/Indicator/styles.d.ts +6 -2
  21. package/dist/GPTVis/hooks/useChartStore.d.ts +6 -2
  22. package/dist/index.es.js +131166 -108979
  23. package/dist/index.es.js.gz +0 -0
  24. package/dist/index.umd.js +1560 -978
  25. package/dist/index.umd.js.gz +0 -0
  26. package/dist/locale/en-US.d.ts +14 -0
  27. package/dist/locale/zh-CN.d.ts +14 -0
  28. package/dist/locale/zh-TW.d.ts +14 -0
  29. package/dist/services/index.d.ts +1 -1
  30. package/dist/types/chart.d.ts +25 -0
  31. package/dist/utils/downloadAsImage.d.ts +1 -1
  32. package/dist/utils/useTools.d.ts +4 -3
  33. package/dist/version.d.ts +1 -1
  34. package/package.json +6 -4
package/README.md CHANGED
@@ -1,55 +1,55 @@
1
- # advt-gpt-chart 可视化组件库
2
-
3
- ## 特性
4
-
5
- - 📊 支持13+图表类型(折线图/柱状图/饼图/雷达图等)
6
- - 🎨 内置Light/Dark双主题体系
7
- - 📝 Markdown协议直接渲染图表
8
- <!-- - 🌐 国际化多语言支持 -->
9
- - 🛠 完善的TypeScript类型定义
10
-
11
- # 安装依赖
12
-
13
- ```bash
14
- npm install @advt-gpt-chart/package
15
- pnpm install @advt-gpt-chart/package
16
- ```
17
-
18
- # 使用
19
- ```tsx
20
- import { ConfigProvider, Line, GPTVis } from '@advt-gpt-chart/package';
21
-
22
- function App() {
23
-
24
- const markdownContent = `
25
- 以下是为你绘制的一个饼图
26
- \`\`\`vis-chart
27
- {
28
- "type": "pie",
29
- "data": [
30
- { "category": "分类一", "value": 27 },
31
- { "category": "分类二", "value": 25 },
32
- { "category": "分类三", "value": 18 },
33
- { "category": "分类四", "value": 15 },
34
- { "category": "分类五", "value": 10 },
35
- { "category": "其他", "value": 5 }
36
- ],
37
- "nameField": "category",
38
- "valField": "value"
39
- }
40
- \`\`\`
41
- `;
42
-
43
- return (
44
- <ConfigProvider theme="dark">
45
- {/* 直接使用图表组件 */}
46
- <Line data={[...]} />
47
-
48
- {/* 通过Markdown渲染 */}
49
- <GPTVis>
50
- {markdownContent}
51
- </GPTVis>
52
- </ConfigProvider>
53
- );
54
- }
55
- ```
1
+ # advt-gpt-chart 可视化组件库
2
+
3
+ ## 特性
4
+
5
+ - 📊 支持13+图表类型(折线图/柱状图/饼图/雷达图等)
6
+ - 🎨 内置Light/Dark双主题体系
7
+ - 📝 Markdown协议直接渲染图表
8
+ <!-- - 🌐 国际化多语言支持 -->
9
+ - 🛠 完善的TypeScript类型定义
10
+
11
+ # 安装依赖
12
+
13
+ ```bash
14
+ npm install @advt-gpt-chart/package
15
+ pnpm install @advt-gpt-chart/package
16
+ ```
17
+
18
+ # 使用
19
+ ```tsx
20
+ import { ConfigProvider, Line, GPTVis } from '@advt-gpt-chart/package';
21
+
22
+ function App() {
23
+
24
+ const markdownContent = `
25
+ 以下是为你绘制的一个饼图
26
+ \`\`\`vis-chart
27
+ {
28
+ "type": "pie",
29
+ "data": [
30
+ { "category": "分类一", "value": 27 },
31
+ { "category": "分类二", "value": 25 },
32
+ { "category": "分类三", "value": 18 },
33
+ { "category": "分类四", "value": 15 },
34
+ { "category": "分类五", "value": 10 },
35
+ { "category": "其他", "value": 5 }
36
+ ],
37
+ "nameField": "category",
38
+ "valField": "value"
39
+ }
40
+ \`\`\`
41
+ `;
42
+
43
+ return (
44
+ <ConfigProvider theme="dark">
45
+ {/* 直接使用图表组件 */}
46
+ <Line data={[...]} />
47
+
48
+ {/* 通过Markdown渲染 */}
49
+ <GPTVis>
50
+ {markdownContent}
51
+ </GPTVis>
52
+ </ConfigProvider>
53
+ );
54
+ }
55
+ ```
@@ -23,7 +23,7 @@ export declare const getPolarLegendSpec: (seriesField: string | boolean | undefi
23
23
  };
24
24
  };
25
25
  export declare const getCartesianLegend: (xField?: string, seriesField?: string | boolean) => any;
26
- export declare const getPolarTooltipSpec: ({ categoryField, valueField, seriesField, showPercent, }: PolarTooltipOptions) => {
26
+ export declare const getPolarTooltipSpec: ({ categoryField, valueField, seriesField, showPercent }: PolarTooltipOptions) => {
27
27
  mark: {
28
28
  title: {
29
29
  value: (datum: any) => any;
@@ -43,18 +43,6 @@ export declare const getPolarTooltipSpec: ({ categoryField, valueField, seriesFi
43
43
  } | undefined;
44
44
  };
45
45
  };
46
- export declare const getDefaultTooltip: (seriesField: string | boolean | undefined) => {
47
- mark: {
48
- title: {
49
- visible: boolean;
50
- };
51
- };
52
- dimension: {
53
- title: {
54
- visible: boolean;
55
- };
56
- };
57
- };
58
46
  export declare const getLineStyle: () => {
59
47
  line: {
60
48
  style: {
@@ -78,24 +66,20 @@ export declare const getLineStyle: () => {
78
66
  };
79
67
  };
80
68
  export declare const getCartesianAxesSpec: (options: CartesianOptions) => ICartesianAxisSpec[];
81
- export declare const getCartesianTootipSpec: ({ xField, yField, seriesField, }: CartesianTooltipOptions) => {
69
+ export declare const getCartesianTootipSpec: ({ xField, yField, seriesField }: CartesianTooltipOptions) => {
82
70
  mark: {
83
- title: {
84
- value: (datum: any) => any;
85
- };
71
+ updateTitle: (prev: any) => any;
86
72
  content: {
87
- key: (datum: any) => string | undefined;
73
+ key: (datum: any) => any;
88
74
  value: (datum: any) => any;
89
- } | undefined;
75
+ };
90
76
  };
91
77
  dimension: {
92
- title: {
93
- value: (datum: any) => any;
94
- };
78
+ updateTitle: (prev: any) => any;
95
79
  content: {
96
- key: (datum: any) => string | undefined;
80
+ key: (datum: any) => any;
97
81
  value: (datum: any) => any;
98
- } | undefined;
82
+ };
99
83
  };
100
84
  };
101
85
  export {};
@@ -9,6 +9,7 @@ export interface AxesConfig {
9
9
  xField: string | string[];
10
10
  yField: string;
11
11
  seriesField?: string;
12
+ isMetricFolded?: boolean;
12
13
  }
13
14
  export interface PolarParams {
14
15
  nameField: string;
@@ -3,7 +3,7 @@ import type { FC } from 'react';
3
3
  import type { Components, ExtraProps } from 'react-markdown';
4
4
  import { ChartType, DataItem } from '../../types';
5
5
  import { TimeGrainType } from '../../utils';
6
- import { FieldInfoItem } from '../Dataset/types';
6
+ import { DataFormat, FieldInfoItem } from '../Dataset/types';
7
7
  import { DataSource } from '../DataSource/types';
8
8
  export type WithChartCodeOptions = {
9
9
  /**
@@ -46,6 +46,7 @@ export interface ChartJson {
46
46
  dataSource?: DataSource;
47
47
  columns?: FieldInfoItem[];
48
48
  timeGrain?: TimeGrainType;
49
+ dataFormat?: DataFormat;
49
50
  }
50
51
  /**
51
52
  * 图表组件字典
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ popoverOpen?: boolean;
3
+ onCancel: () => void;
4
+ }
5
+ export declare const DataFormatModal: ({ popoverOpen, onCancel }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const StyleFormatModal: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
2
+ theme?: string;
3
+ }>> & string;
@@ -0,0 +1,12 @@
1
+ export declare const formatTypeInitOptions: ({
2
+ key: string;
3
+ label: string;
4
+ value: string;
5
+ desc?: undefined;
6
+ } | {
7
+ key: string;
8
+ label: string;
9
+ value: string;
10
+ desc: string;
11
+ })[];
12
+ export declare function getUnit(valueUnit: string, unit: string): string;
@@ -1,5 +1,6 @@
1
1
  import { Dayjs } from 'dayjs';
2
2
  import { TimeGrainType } from '../../../utils';
3
+ import { DataFormat } from '../../Dataset/types';
3
4
  import { FilterItemType } from '../Filter/types';
4
5
  export type CustomTimeRange = {
5
6
  from?: Dayjs;
@@ -42,6 +43,7 @@ export type QueryData = {
42
43
  dimensions?: OptionType[];
43
44
  filters?: FilterItemType[];
44
45
  timeGrain?: TimeGrainType;
46
+ dataFormat?: DataFormat;
45
47
  };
46
48
  export interface TableData {
47
49
  columns: Array<{
@@ -9,8 +9,22 @@ export declare function handleMetricInfo(metricInfo: any, chartJson: ChartJson,
9
9
  }[];
10
10
  matchedDimensions: any;
11
11
  dimOptions: any;
12
+ dataFormat: {
13
+ [x: string]: {
14
+ formatType: any;
15
+ decimalPlaces: any;
16
+ suffix: string;
17
+ };
18
+ } | null;
12
19
  } | null;
13
20
  export declare function handleDeaultSelectedDisabledOptions(dimensionId: string, derivationMethod: any): {
14
21
  defaultSelected: boolean;
15
22
  defaultDisabled: boolean;
16
23
  };
24
+ export declare const getDataFormat: (metricName: string, info: any) => {
25
+ [x: string]: {
26
+ formatType: any;
27
+ decimalPlaces: any;
28
+ suffix: string;
29
+ };
30
+ } | null;
@@ -1,5 +1,7 @@
1
1
  export interface ChartHeaderProps {
2
+ isFullScreen?: boolean;
2
3
  theme?: string;
4
+ setFullScreen: (fullscreen: boolean) => void;
3
5
  }
4
- declare function ChartHeader({ theme }: ChartHeaderProps): import("react/jsx-runtime").JSX.Element;
6
+ declare function ChartHeader({ theme, isFullScreen, setFullScreen }: ChartHeaderProps): import("react/jsx-runtime").JSX.Element;
5
7
  export { ChartHeader };
@@ -0,0 +1,2 @@
1
+ declare const ChartMenu: () => import("react/jsx-runtime").JSX.Element;
2
+ export default ChartMenu;
@@ -5,5 +5,5 @@ export interface ChartContainerProps {
5
5
  className?: string;
6
6
  chartStyle?: React.CSSProperties;
7
7
  }
8
- declare const _default: React.MemoExoticComponent<({ className, chartStyle, components, }: ChartContainerProps) => import("react/jsx-runtime").JSX.Element>;
8
+ declare const _default: React.MemoExoticComponent<({ className, chartStyle, components }: ChartContainerProps) => import("react/jsx-runtime").JSX.Element>;
9
9
  export default _default;
@@ -0,0 +1,4 @@
1
+ export declare const chartMenuOptions: {
2
+ key: string;
3
+ label: string;
4
+ }[];
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
- export declare const StyleChart: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
1
+ export declare const StyleChart: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
3
2
  theme: string;
4
- style?: React.CSSProperties;
3
+ style?: any;
5
4
  }>> & string;
6
- export declare const StyleChartHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
5
+ export declare const StyleChartHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
7
6
  theme?: string;
8
7
  }>> & string;
9
- export declare const GlobalDropdownStyle: React.NamedExoticComponent<import("styled-components").ExecutionProps & object>;
8
+ export declare const GlobalDropdownStyle: import("react").NamedExoticComponent<import("styled-components").ExecutionProps & object>;
@@ -20,4 +20,6 @@ export declare function chartAdvisor(chartJson: ChartJson): Promise<{
20
20
  dataSource?: import("../DataSource/types").DataSource;
21
21
  columns?: import("../Dataset/types").FieldInfoItem[];
22
22
  timeGrain?: import("../../utils").TimeGrainType;
23
+ dataFormat?: import("../Dataset/types").DataFormat;
23
24
  }>;
25
+ export declare function exportToExcel(data: any[], fileName: string): void;
@@ -10,6 +10,6 @@ type DrillByQueryData = QueryChartData & {
10
10
  };
11
11
  export declare const useChartDataQuery: (dataSourceType: DataSourceType) => {
12
12
  queryChartDataFromDatasource: (queryData: QueryData, isInit?: Boolean) => Promise<void>;
13
- queryDrillByChartData: ({ queryData, setDrillLoading, setDrillError, }: DrillByQueryData) => Promise<void>;
13
+ queryDrillByChartData: ({ queryData, setDrillLoading, setDrillError }: DrillByQueryData) => Promise<void>;
14
14
  };
15
15
  export {};
@@ -21,3 +21,12 @@ export type FieldInfoItem = {
21
21
  type?: FieldDataType | VFieldDataType | string;
22
22
  role?: string;
23
23
  };
24
+ export interface MetricFormat {
25
+ formatType: string;
26
+ decimalPlaces?: number;
27
+ prefix?: string;
28
+ suffix?: string;
29
+ }
30
+ export type DataFormat = {
31
+ [metricName: string]: MetricFormat;
32
+ };
@@ -34,8 +34,8 @@ export declare const transform2Dataset: (chartJson: ChartJson) => {
34
34
  }[];
35
35
  foldData: Record<string, any>[];
36
36
  isMetricFolded: boolean;
37
- foldKey: string;
38
- foldValue: string;
37
+ foldKey: string | undefined;
38
+ foldValue: string | undefined;
39
39
  isColumnMegred: boolean;
40
40
  megreColumnName: string | undefined;
41
41
  };
@@ -51,6 +51,11 @@ export declare const transform2FoldData: (data: Record<string, any>[], dimension
51
51
  foldKey: string;
52
52
  foldValue: string;
53
53
  isMetricFolded: boolean;
54
+ } | {
55
+ foldData: Record<string, any>[];
56
+ isMetricFolded: boolean;
57
+ foldKey?: undefined;
58
+ foldValue?: undefined;
54
59
  };
55
60
  export declare const transform2FillAndMegreData: (data: any[] | undefined, fieldInfo: FieldInfoItem[] | undefined, chartJson: ChartJson) => {
56
61
  data: {
@@ -77,8 +82,11 @@ export declare const generateTimeSeries: (startTime: any, endTime: any, timeGrai
77
82
  export declare const filledDataByTimeSeries: (sortedData: Record<string, any>[] | undefined, timeSeries: string[], timeGrain: TimeGrainType, timeField: string, metrics?: string[]) => Record<string, any>[];
78
83
  export declare const getTimeGrainInterval: (timeGrain: string, sortedData: any[], timeField: string) => number;
79
84
  export declare function formatTime2TimeGrain(timeGrain: TimeGrainType, value: Dayjs | number): string;
80
- export declare const uptateDataSet: (preJson: ChartJson, newJson: ChartJson, dataset: Dataset) => {
85
+ export declare const checkUptateDataSet: (preJson: ChartJson, newJson: ChartJson, dataset: Dataset) => {
81
86
  dataset: Dataset;
82
- isChanged: boolean;
87
+ isShouldUpdate: boolean;
88
+ } | {
89
+ isShouldUpdate: boolean;
90
+ dataset?: undefined;
83
91
  };
84
92
  export {};
@@ -3,7 +3,11 @@ interface StyleProps {
3
3
  fontSize?: number;
4
4
  }
5
5
  export declare const IndicatorStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyleProps>> & string;
6
- export declare const CardStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>, "ref"> & {
6
+ export declare const CardStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & {
7
+ children?: React.ReactNode | undefined;
8
+ } & import("react").RefAttributes<HTMLElement>, "ref"> & {
7
9
  ref?: ((instance: HTMLElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLElement> | null | undefined;
8
- }, StyleProps>> & string & Omit<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, keyof import("react").Component<any, {}, any>>;
10
+ }, StyleProps>> & string & Omit<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & {
11
+ children?: React.ReactNode | undefined;
12
+ } & import("react").RefAttributes<HTMLElement>>, keyof import("react").Component<any, {}, any>>;
9
13
  export {};
@@ -23,12 +23,15 @@ export interface QueryError {
23
23
  title: string;
24
24
  message: string;
25
25
  }
26
+ export interface ChartControllersConfig extends ChartControllersState {
27
+ dataFormat?: any;
28
+ }
26
29
  export interface VizChartState {
27
30
  theme: string;
28
31
  chartLoading?: boolean;
29
32
  chartJson: ChartJson;
30
33
  dataset: Dataset;
31
- controllerConfig: ChartControllersState;
34
+ controllerConfig: ChartControllersConfig;
32
35
  contextMenu: ContextMenu;
33
36
  drillBy: DrillBy;
34
37
  dataSourceQueryInfo: DataSourceQueryInfo;
@@ -36,8 +39,9 @@ export interface VizChartState {
36
39
  setTheme: (theme: string) => void;
37
40
  setLoading: (loading: boolean) => void;
38
41
  setChartJson: (chartJson: ChartJson) => void;
42
+ updateChartJson: (key: keyof ChartJson, newObj: any) => void;
39
43
  setDataset: (dataset: Dataset) => void;
40
- setControllerConfig: (controller: ChartControllersState) => void;
44
+ setControllerConfig: (controller: ChartControllersConfig) => void;
41
45
  setContextMenu: (contextMenu: ContextMenu) => void;
42
46
  setChartDrillBy: (drillBy: DrillBy) => void;
43
47
  setDataSourceQueryInfo: (dataSourceQueryInfo: DataSourceQueryInfo) => void;