@nocobase/plugin-data-visualization 0.14.0-alpha.6 → 0.14.0-alpha.8

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.
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const DataVisualization: React.FC;
@@ -1,6 +1,7 @@
1
+ export type Transformer = (val: any, locale?: string) => string | number;
1
2
  declare const transformers: {
2
3
  [key: string]: {
3
- [key: string]: (val: any, locale?: string) => string | number;
4
+ [key: string]: Transformer;
4
5
  };
5
6
  };
6
7
  export default transformers;
@@ -1,17 +1,7 @@
1
1
  import { AntdChart } from './antd';
2
- import { FieldOption } from '../../hooks';
3
- import { QueryProps } from '../../renderer';
4
- import { RenderProps } from '../chart';
2
+ import { ChartType, RenderProps } from '../chart';
5
3
  export declare class Statistic extends AntdChart {
6
4
  constructor();
7
- init(fields: FieldOption[], { measures, dimensions, }: {
8
- measures?: QueryProps['measures'];
9
- dimensions?: QueryProps['dimensions'];
10
- }): {
11
- general: {
12
- field: string;
13
- title: string;
14
- };
15
- };
5
+ init: ChartType['init'];
16
6
  getProps({ data, fieldProps, general, advanced }: RenderProps): any;
17
7
  }
@@ -2,14 +2,16 @@ import React from 'react';
2
2
  import { FieldOption } from '../hooks';
3
3
  import { QueryProps } from '../renderer';
4
4
  import { ISchema } from '@formily/react';
5
- import { AnySchemaProperties, ConfigProps } from './configs';
5
+ import { AnySchemaProperties, Config } from './configs';
6
+ import { Transformer } from '../block/transformers';
6
7
  export type RenderProps = {
7
- data: any[];
8
+ data: Record<string, any>[];
8
9
  general: any;
9
10
  advanced: any;
10
11
  fieldProps: {
11
- [field: string]: FieldOption & {
12
- transformer: (val: any) => string;
12
+ [field: string]: {
13
+ label: string;
14
+ transformer: Transformer;
13
15
  };
14
16
  };
15
17
  };
@@ -18,15 +20,6 @@ export interface ChartType {
18
20
  title: string;
19
21
  component: React.FC<any>;
20
22
  schema: ISchema;
21
- infer: (fields: FieldOption[], { measures, dimensions, }: {
22
- measures?: QueryProps['measures'];
23
- dimensions?: QueryProps['dimensions'];
24
- }) => {
25
- xField: FieldOption;
26
- yField: FieldOption;
27
- seriesField: FieldOption;
28
- yFields: FieldOption[];
29
- };
30
23
  init?: (fields: FieldOption[], query: {
31
24
  measures?: QueryProps['measures'];
32
25
  dimensions?: QueryProps['dimensions'];
@@ -34,32 +27,23 @@ export interface ChartType {
34
27
  general?: any;
35
28
  advanced?: any;
36
29
  };
37
- /**
38
- * getProps
39
- * Accept the information that the chart component needs to render,
40
- * process it and return the props of the chart component.
41
- */
42
- getProps: (props: RenderProps) => any;
30
+ render: (props: RenderProps) => React.FC<any>;
43
31
  getReference?: () => {
44
32
  title: string;
45
33
  link: string;
46
34
  };
47
- render: (props: RenderProps) => React.FC<any>;
48
35
  }
49
- type Config = ((ConfigProps & {
50
- property?: string;
51
- }) | string)[];
52
36
  export type ChartProps = {
53
37
  name: string;
54
38
  title: string;
55
39
  component: React.FC<any>;
56
- config?: Config;
40
+ config?: Config[];
57
41
  };
58
42
  export declare class Chart implements ChartType {
59
43
  name: string;
60
44
  title: string;
61
45
  component: React.FC<any>;
62
- config: Config;
46
+ config: Config[];
63
47
  configs: Map<string, Function>;
64
48
  constructor({ name, title, component, config }: ChartProps);
65
49
  get schema(): {
@@ -81,7 +65,11 @@ export declare class Chart implements ChartType {
81
65
  seriesField: FieldOption;
82
66
  yFields: FieldOption[];
83
67
  };
84
- getProps(props: RenderProps): RenderProps;
68
+ /**
69
+ * getProps
70
+ * Accept the information that the chart component needs to render,
71
+ * process it and return the props of the chart component.
72
+ */
73
+ getProps(props: RenderProps): any;
85
74
  render({ data, general, advanced, fieldProps }: RenderProps): () => React.FunctionComponentElement<any>;
86
75
  }
87
- export {};
@@ -7,6 +7,9 @@ export type FieldConfigProps = Partial<{
7
7
  }>;
8
8
  export type AnySchemaProperties = SchemaProperties<any, any, any, any, any, any, any, any>;
9
9
  export type ConfigProps = FieldConfigProps | AnySchemaProperties | (() => AnySchemaProperties);
10
+ export type Config = (ConfigProps & {
11
+ property?: string;
12
+ }) | string;
10
13
  declare const _default: {
11
14
  field: ({ name, title, required, defaultValue }: Partial<{
12
15
  name: string;
@@ -38,5 +41,38 @@ declare const _default: {
38
41
  default: any;
39
42
  };
40
43
  };
44
+ xField: (props: FieldConfigProps) => {
45
+ [x: string]: {
46
+ title: string;
47
+ type: string;
48
+ 'x-decorator': string;
49
+ 'x-component': string;
50
+ 'x-reactions': string;
51
+ required: boolean;
52
+ default: any;
53
+ };
54
+ };
55
+ yField: (props: FieldConfigProps) => {
56
+ [x: string]: {
57
+ title: string;
58
+ type: string;
59
+ 'x-decorator': string;
60
+ 'x-component': string;
61
+ 'x-reactions': string;
62
+ required: boolean;
63
+ default: any;
64
+ };
65
+ };
66
+ seriesField: (props: FieldConfigProps) => {
67
+ [x: string]: {
68
+ title: string;
69
+ type: string;
70
+ 'x-decorator': string;
71
+ 'x-component': string;
72
+ 'x-reactions': string;
73
+ required: boolean;
74
+ default: any;
75
+ };
76
+ };
41
77
  };
42
78
  export default _default;
@@ -1,16 +1,6 @@
1
- import { FieldOption } from '../../hooks';
2
- import { QueryProps } from '../../renderer';
3
1
  import { G2PlotChart } from './g2plot';
2
+ import { ChartType } from '../chart';
4
3
  export declare class Bar extends G2PlotChart {
5
4
  constructor();
6
- init(fields: FieldOption[], { measures, dimensions, }: {
7
- measures?: QueryProps['measures'];
8
- dimensions?: QueryProps['dimensions'];
9
- }): {
10
- general: {
11
- xField: string;
12
- yField: string;
13
- seriesField: string;
14
- };
15
- };
5
+ init: ChartType['init'];
16
6
  }
@@ -1,38 +1,5 @@
1
1
  import { FieldConfigProps } from '../configs';
2
2
  declare const _default: {
3
- xField: (props: FieldConfigProps) => {
4
- [x: string]: {
5
- title: string;
6
- type: string;
7
- 'x-decorator': string;
8
- 'x-component': string;
9
- 'x-reactions': string;
10
- required: boolean;
11
- default: any;
12
- };
13
- };
14
- yField: (props: FieldConfigProps) => {
15
- [x: string]: {
16
- title: string;
17
- type: string;
18
- 'x-decorator': string;
19
- 'x-component': string;
20
- 'x-reactions': string;
21
- required: boolean;
22
- default: any;
23
- };
24
- };
25
- seriesField: (props: FieldConfigProps) => {
26
- [x: string]: {
27
- title: string;
28
- type: string;
29
- 'x-decorator': string;
30
- 'x-component': string;
31
- 'x-reactions': string;
32
- required: boolean;
33
- default: any;
34
- };
35
- };
36
3
  isStack: (props: FieldConfigProps) => {
37
4
  [x: string]: {
38
5
  'x-content': string;
@@ -1,18 +1,8 @@
1
1
  import { G2PlotChart } from './g2plot';
2
- import { RenderProps } from '../chart';
2
+ import { ChartType, RenderProps } from '../chart';
3
3
  import React from 'react';
4
- import { FieldOption } from '../../hooks';
5
- import { QueryProps } from '../../renderer';
6
4
  export declare class DualAxes extends G2PlotChart {
7
5
  constructor();
8
- init(fields: FieldOption[], { measures, dimensions, }: {
9
- measures?: QueryProps['measures'];
10
- dimensions?: QueryProps['dimensions'];
11
- }): {
12
- general: {
13
- xField: string;
14
- yField: string[];
15
- };
16
- };
6
+ init: ChartType['init'];
17
7
  render({ data, general, advanced, fieldProps }: RenderProps): () => React.FunctionComponentElement<any>;
18
8
  }
@@ -1,15 +1,7 @@
1
- import { Chart, ChartProps, RenderProps } from '../chart';
2
- import { FieldOption } from '../../hooks';
3
- import { QueryProps } from '../../renderer';
1
+ import { Chart, ChartProps, ChartType, RenderProps } from '../chart';
4
2
  export declare class G2PlotChart extends Chart {
5
3
  constructor({ name, title, component, config }: ChartProps);
6
- init(fields: FieldOption[], { measures, dimensions, }: {
7
- measures?: QueryProps['measures'];
8
- dimensions?: QueryProps['dimensions'];
9
- }): {
10
- general?: any;
11
- advanced?: any;
12
- };
4
+ init: ChartType['init'];
13
5
  getProps({ data, general, advanced, fieldProps }: RenderProps): any;
14
6
  getReference(): {
15
7
  title: string;
@@ -1,6 +1,3 @@
1
- import { Bar } from './bar';
2
- import { Pie } from './pie';
3
- import { DualAxes } from './dualAxes';
4
1
  import { G2PlotChart } from './g2plot';
5
- declare const _default: (G2PlotChart | Bar | Pie | DualAxes)[];
2
+ declare const _default: G2PlotChart[];
6
3
  export default _default;
@@ -1,15 +1,6 @@
1
1
  import { G2PlotChart } from './g2plot';
2
- import { FieldOption } from '../../hooks';
3
- import { QueryProps } from '../../renderer';
2
+ import { ChartType } from '../chart';
4
3
  export declare class Pie extends G2PlotChart {
5
4
  constructor();
6
- init(fields: FieldOption[], { measures, dimensions, }: {
7
- measures?: QueryProps['measures'];
8
- dimensions?: QueryProps['dimensions'];
9
- }): {
10
- general: {
11
- colorField: string;
12
- angleField: string;
13
- };
14
- };
5
+ init: ChartType['init'];
15
6
  }
@@ -0,0 +1,32 @@
1
+ import { ChartType } from './chart';
2
+ export declare class ChartGroup {
3
+ charts: Map<string, ChartType[]>;
4
+ setGroup(name: string, charts: ChartType[]): void;
5
+ addGroup(name: string, charts: ChartType[]): void;
6
+ add(group: string, chart: ChartType): void;
7
+ getChartTypes(): {
8
+ label: string;
9
+ children: {
10
+ key: string;
11
+ label: string;
12
+ value: string;
13
+ }[];
14
+ }[];
15
+ getCharts(): {
16
+ [key: string]: ChartType;
17
+ };
18
+ getChart(type: string): ChartType;
19
+ }
20
+ export declare const useChartTypes: () => {
21
+ label: string;
22
+ children: {
23
+ key: string;
24
+ label: string;
25
+ value: string;
26
+ }[];
27
+ }[];
28
+ export declare const useDefaultChartType: () => string;
29
+ export declare const useCharts: () => {
30
+ [key: string]: ChartType;
31
+ };
32
+ export declare const useChart: (type: string) => ChartType;
@@ -1,9 +1,12 @@
1
1
  import { Plugin } from '@nocobase/client';
2
- import { ChartLibraryProvider } from './chart/library';
2
+ import { ChartGroup } from './chart/group';
3
3
  declare class DataVisualizationPlugin extends Plugin {
4
+ charts: ChartGroup;
4
5
  load(): Promise<void>;
5
6
  }
6
7
  export default DataVisualizationPlugin;
7
- export { ChartLibraryProvider };
8
8
  export { Chart } from './chart/chart';
9
- export type { ChartType } from './chart/chart';
9
+ export type { ChartType, RenderProps, ChartProps } from './chart/chart';
10
+ export type { FieldOption } from './hooks';
11
+ export type { QueryProps } from './renderer';
12
+ export { ChartConfigContext } from './configure/ChartConfigure';