@nocobase/plugin-data-visualization 0.11.1-alpha.5 → 0.12.0-alpha.2
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/client.d.ts +2 -2
- package/client.js +1 -1
- package/dist/client/chart/antd/antd.d.ts +7 -0
- package/dist/client/chart/antd/index.d.ts +4 -0
- package/dist/client/chart/antd/statistic.d.ts +19 -0
- package/dist/client/chart/antd/table.d.ts +6 -0
- package/dist/client/chart/chart.d.ts +65 -0
- package/dist/client/chart/g2plot/bar.d.ts +16 -0
- package/dist/client/chart/g2plot/dualAxes.d.ts +20 -0
- package/dist/client/chart/g2plot/g2plot.d.ts +19 -0
- package/dist/client/chart/g2plot/index.d.ts +6 -0
- package/dist/client/chart/g2plot/pie.d.ts +17 -0
- package/dist/client/chart/library.d.ts +28 -0
- package/{lib → dist}/client/hooks.d.ts +22 -154
- package/{lib → dist}/client/index.d.ts +3 -1
- package/dist/client/index.js +67448 -0
- package/{lib → dist}/client/renderer/ChartRendererProvider.d.ts +1 -8
- package/{lib → dist}/client/renderer/index.d.ts +0 -2
- package/{lib → dist}/client/utils.d.ts +1 -1
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/en-US.js +26 -0
- package/dist/locale/fr-FR.js +5 -0
- package/dist/locale/ja-JP.js +5 -0
- package/dist/locale/pt-BR.js +26 -0
- package/dist/locale/ru-RU.js +5 -0
- package/dist/locale/tr-TR.js +5 -0
- package/dist/locale/zh-CN.js +74 -0
- package/dist/server/actions/formatter.js +41 -0
- package/{src/server/actions/query.ts → dist/server/actions/query.js} +75 -133
- package/dist/server/index.js +11 -0
- package/dist/server/plugin.js +42 -0
- package/package.json +23 -22
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/lib/client/Settings.js +0 -81
- package/lib/client/block/ChartBlock.js +0 -74
- package/lib/client/block/ChartBlockDesigner.js +0 -35
- package/lib/client/block/ChartBlockInitializer.js +0 -114
- package/lib/client/block/ChartConfigure.js +0 -499
- package/lib/client/block/formatters.js +0 -58
- package/lib/client/block/index.js +0 -49
- package/lib/client/block/schemas/configure.js +0 -517
- package/lib/client/block/transformers.js +0 -68
- package/lib/client/hooks.js +0 -275
- package/lib/client/index.js +0 -80
- package/lib/client/locale/index.js +0 -37
- package/lib/client/renderer/ChartLibrary.d.ts +0 -72
- package/lib/client/renderer/ChartLibrary.js +0 -146
- package/lib/client/renderer/ChartRenderer.js +0 -181
- package/lib/client/renderer/ChartRendererProvider.js +0 -105
- package/lib/client/renderer/index.js +0 -49
- package/lib/client/renderer/library/AntdLibrary.d.ts +0 -2
- package/lib/client/renderer/library/AntdLibrary.js +0 -123
- package/lib/client/renderer/library/G2PlotLibrary.d.ts +0 -2
- package/lib/client/renderer/library/G2PlotLibrary.js +0 -288
- package/lib/client/renderer/library/index.d.ts +0 -3
- package/lib/client/renderer/library/index.js +0 -15
- package/lib/client/utils.js +0 -137
- package/lib/index.js +0 -13
- package/lib/locale/en-US.js +0 -29
- package/lib/locale/fr-FR.js +0 -8
- package/lib/locale/ja-JP.js +0 -8
- package/lib/locale/pt-BR.js +0 -29
- package/lib/locale/ru-RU.js +0 -8
- package/lib/locale/tr-TR.js +0 -8
- package/lib/locale/zh-CN.js +0 -77
- package/lib/server/actions/formatter.js +0 -44
- package/lib/server/actions/query.js +0 -331
- package/lib/server/index.js +0 -13
- package/lib/server/plugin.js +0 -64
- package/src/client/Settings.tsx +0 -43
- package/src/client/__tests__/chart-configure.test.tsx +0 -14
- package/src/client/__tests__/chart-library.test.ts +0 -78
- package/src/client/__tests__/chart-renderer.test.tsx +0 -30
- package/src/client/__tests__/hooks.test.ts +0 -261
- package/src/client/block/ChartBlock.tsx +0 -24
- package/src/client/block/ChartBlockDesigner.tsx +0 -19
- package/src/client/block/ChartBlockInitializer.tsx +0 -82
- package/src/client/block/ChartConfigure.tsx +0 -446
- package/src/client/block/formatters.ts +0 -70
- package/src/client/block/index.ts +0 -4
- package/src/client/block/schemas/configure.ts +0 -504
- package/src/client/block/transformers.ts +0 -52
- package/src/client/hooks.ts +0 -239
- package/src/client/index.tsx +0 -47
- package/src/client/locale/index.ts +0 -18
- package/src/client/renderer/ChartLibrary.tsx +0 -183
- package/src/client/renderer/ChartRenderer.tsx +0 -129
- package/src/client/renderer/ChartRendererProvider.tsx +0 -123
- package/src/client/renderer/index.ts +0 -4
- package/src/client/renderer/library/AntdLibrary.tsx +0 -94
- package/src/client/renderer/library/G2PlotLibrary.tsx +0 -236
- package/src/client/renderer/library/index.tsx +0 -4
- package/src/client/utils.ts +0 -102
- package/src/index.ts +0 -1
- package/src/locale/en-US.ts +0 -23
- package/src/locale/fr-FR.ts +0 -1
- package/src/locale/ja-JP.ts +0 -1
- package/src/locale/pt-BR.ts +0 -23
- package/src/locale/ru-RU.ts +0 -1
- package/src/locale/tr-TR.ts +0 -1
- package/src/locale/zh-CN.ts +0 -72
- package/src/server/__tests__/api.test.ts +0 -102
- package/src/server/__tests__/formatter.test.ts +0 -49
- package/src/server/__tests__/query.test.ts +0 -220
- package/src/server/actions/formatter.ts +0 -49
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/index.ts +0 -1
- package/src/server/plugin.ts +0 -37
- /package/{lib → dist}/client/Settings.d.ts +0 -0
- /package/{lib → dist}/client/block/ChartBlock.d.ts +0 -0
- /package/{lib → dist}/client/block/ChartBlockDesigner.d.ts +0 -0
- /package/{lib → dist}/client/block/ChartBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/block/ChartConfigure.d.ts +0 -0
- /package/{lib → dist}/client/block/formatters.d.ts +0 -0
- /package/{lib → dist}/client/block/index.d.ts +0 -0
- /package/{lib → dist}/client/block/schemas/configure.d.ts +0 -0
- /package/{lib → dist}/client/block/transformers.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/renderer/ChartRenderer.d.ts +0 -0
- /package/{lib → dist}/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
- /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
- /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/actions/formatter.d.ts +0 -0
- /package/{lib → dist}/server/actions/query.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/css';
|
|
2
|
-
import { useFieldSchema } from '@formily/react';
|
|
3
|
-
import { MaybeCollectionProvider, useAPIClient, useRequest } from '@nocobase/client';
|
|
4
|
-
import React, { createContext } from 'react';
|
|
5
|
-
import { parseField } from '../utils';
|
|
6
|
-
|
|
7
|
-
export type MeasureProps = {
|
|
8
|
-
field: string | string[];
|
|
9
|
-
aggregation?: string;
|
|
10
|
-
alias?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type DimensionProps = {
|
|
14
|
-
field: string | string[];
|
|
15
|
-
alias?: string;
|
|
16
|
-
format?: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type TransformProps = {
|
|
20
|
-
field: string;
|
|
21
|
-
type: string;
|
|
22
|
-
format: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type QueryProps = Partial<{
|
|
26
|
-
measures: MeasureProps[];
|
|
27
|
-
dimensions: DimensionProps[];
|
|
28
|
-
orders: {
|
|
29
|
-
field: string;
|
|
30
|
-
order: 'asc' | 'desc';
|
|
31
|
-
}[];
|
|
32
|
-
filter: any;
|
|
33
|
-
limit: number;
|
|
34
|
-
sql: {
|
|
35
|
-
fields?: string;
|
|
36
|
-
clauses?: string;
|
|
37
|
-
};
|
|
38
|
-
}>;
|
|
39
|
-
|
|
40
|
-
export type ChartRendererProps = {
|
|
41
|
-
collection: string;
|
|
42
|
-
query?: QueryProps;
|
|
43
|
-
config?: {
|
|
44
|
-
chartType: string;
|
|
45
|
-
general: any;
|
|
46
|
-
advanced: any;
|
|
47
|
-
};
|
|
48
|
-
transform?: TransformProps[];
|
|
49
|
-
mode?: 'builder' | 'sql';
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const ChartRendererContext = createContext<{
|
|
53
|
-
collection: string;
|
|
54
|
-
config?: {
|
|
55
|
-
chartType: string;
|
|
56
|
-
general: any;
|
|
57
|
-
advanced: any;
|
|
58
|
-
};
|
|
59
|
-
transform?: TransformProps[];
|
|
60
|
-
service: any;
|
|
61
|
-
data?: any[];
|
|
62
|
-
}>({} as any);
|
|
63
|
-
|
|
64
|
-
export const ChartRendererProvider: React.FC<ChartRendererProps> = (props) => {
|
|
65
|
-
const { query, config, collection, transform } = props;
|
|
66
|
-
const schema = useFieldSchema();
|
|
67
|
-
const api = useAPIClient();
|
|
68
|
-
const service = useRequest(
|
|
69
|
-
(collection, query) =>
|
|
70
|
-
new Promise((resolve, reject) => {
|
|
71
|
-
if (!(collection && query?.measures?.length)) return resolve(undefined);
|
|
72
|
-
api
|
|
73
|
-
.request({
|
|
74
|
-
url: 'charts:query',
|
|
75
|
-
method: 'POST',
|
|
76
|
-
data: {
|
|
77
|
-
uid: schema?.['x-uid'],
|
|
78
|
-
collection,
|
|
79
|
-
...query,
|
|
80
|
-
dimensions: (query?.dimensions || []).map((item: DimensionProps) => {
|
|
81
|
-
const dimension = { ...item };
|
|
82
|
-
if (item.format && !item.alias) {
|
|
83
|
-
const { alias } = parseField(item.field);
|
|
84
|
-
dimension.alias = alias;
|
|
85
|
-
}
|
|
86
|
-
return dimension;
|
|
87
|
-
}),
|
|
88
|
-
measures: (query?.measures || []).map((item: MeasureProps) => {
|
|
89
|
-
const measure = { ...item };
|
|
90
|
-
if (item.aggregation && !item.alias) {
|
|
91
|
-
const { alias } = parseField(item.field);
|
|
92
|
-
measure.alias = alias;
|
|
93
|
-
}
|
|
94
|
-
return measure;
|
|
95
|
-
}),
|
|
96
|
-
},
|
|
97
|
-
})
|
|
98
|
-
.then((res) => {
|
|
99
|
-
resolve(res?.data?.data);
|
|
100
|
-
})
|
|
101
|
-
.catch(reject);
|
|
102
|
-
}),
|
|
103
|
-
{
|
|
104
|
-
defaultParams: [collection, query],
|
|
105
|
-
},
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<MaybeCollectionProvider collection={collection}>
|
|
110
|
-
<div
|
|
111
|
-
className={css`
|
|
112
|
-
.ant-card {
|
|
113
|
-
box-shadow: none;
|
|
114
|
-
}
|
|
115
|
-
`}
|
|
116
|
-
>
|
|
117
|
-
<ChartRendererContext.Provider value={{ collection, config, transform, service }}>
|
|
118
|
-
{props.children}
|
|
119
|
-
</ChartRendererContext.Provider>
|
|
120
|
-
</div>
|
|
121
|
-
</MaybeCollectionProvider>
|
|
122
|
-
);
|
|
123
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Statistic, Table } from 'antd';
|
|
2
|
-
import { lang } from '../../locale';
|
|
3
|
-
import { Charts, infer } from '../ChartLibrary';
|
|
4
|
-
|
|
5
|
-
export const AntdLibrary: Charts = {
|
|
6
|
-
statistic: {
|
|
7
|
-
name: lang('Statistic'),
|
|
8
|
-
component: Statistic,
|
|
9
|
-
schema: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {
|
|
12
|
-
field: {
|
|
13
|
-
title: lang('Field'),
|
|
14
|
-
type: 'string',
|
|
15
|
-
'x-decorator': 'FormItem',
|
|
16
|
-
'x-component': 'Select',
|
|
17
|
-
'x-reactions': '{{ useChartFields }}',
|
|
18
|
-
required: true,
|
|
19
|
-
},
|
|
20
|
-
title: {
|
|
21
|
-
title: lang('Title'),
|
|
22
|
-
type: 'string',
|
|
23
|
-
'x-decorator': 'FormItem',
|
|
24
|
-
'x-component': 'Input',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
init: (fields, { measures, dimensions }) => {
|
|
29
|
-
const { yField } = infer(fields, { measures, dimensions });
|
|
30
|
-
return {
|
|
31
|
-
general: {
|
|
32
|
-
field: yField?.value,
|
|
33
|
-
title: yField?.label,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
useProps: ({ data, fieldProps, general, advanced }) => {
|
|
38
|
-
const record = data[0] || {};
|
|
39
|
-
const field = general?.field;
|
|
40
|
-
const props = fieldProps[field];
|
|
41
|
-
return {
|
|
42
|
-
value: record[field],
|
|
43
|
-
formatter: props?.transformer,
|
|
44
|
-
...general,
|
|
45
|
-
...advanced,
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
reference: {
|
|
49
|
-
title: lang('Statistic'),
|
|
50
|
-
link: 'https://ant.design/components/statistic/',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
table: {
|
|
54
|
-
name: lang('Table'),
|
|
55
|
-
component: Table,
|
|
56
|
-
useProps: ({ data, fieldProps, general, advanced }) => {
|
|
57
|
-
const columns = data.length
|
|
58
|
-
? Object.keys(data[0]).map((item) => ({
|
|
59
|
-
title: fieldProps[item]?.label || item,
|
|
60
|
-
dataIndex: item,
|
|
61
|
-
key: item,
|
|
62
|
-
}))
|
|
63
|
-
: [];
|
|
64
|
-
const dataSource = data.map((item: any) => {
|
|
65
|
-
Object.keys(item).map((key: string) => {
|
|
66
|
-
const props = fieldProps[key];
|
|
67
|
-
if (props?.transformer) {
|
|
68
|
-
item[key] = props.transformer(item[key]);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return item;
|
|
72
|
-
});
|
|
73
|
-
const pageSize = advanced?.pagination?.pageSize || 10;
|
|
74
|
-
return {
|
|
75
|
-
bordered: true,
|
|
76
|
-
size: 'middle',
|
|
77
|
-
pagination:
|
|
78
|
-
dataSource.length < pageSize
|
|
79
|
-
? false
|
|
80
|
-
: {
|
|
81
|
-
pageSize,
|
|
82
|
-
},
|
|
83
|
-
dataSource,
|
|
84
|
-
columns,
|
|
85
|
-
...general,
|
|
86
|
-
...advanced,
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
reference: {
|
|
90
|
-
title: lang('Table'),
|
|
91
|
-
link: 'https://ant.design/components/table/',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { Area, Bar, Column, DualAxes, Line, Pie, Scatter } from '@ant-design/plots';
|
|
2
|
-
import { Charts, commonInit, infer, usePropsFunc } from '../ChartLibrary';
|
|
3
|
-
const init = commonInit;
|
|
4
|
-
|
|
5
|
-
const basicSchema = {
|
|
6
|
-
type: 'object',
|
|
7
|
-
properties: {
|
|
8
|
-
xField: {
|
|
9
|
-
title: '{{t("xField")}}',
|
|
10
|
-
type: 'string',
|
|
11
|
-
'x-decorator': 'FormItem',
|
|
12
|
-
'x-component': 'Select',
|
|
13
|
-
'x-reactions': '{{ useChartFields }}',
|
|
14
|
-
required: true,
|
|
15
|
-
},
|
|
16
|
-
yField: {
|
|
17
|
-
title: '{{t("yField")}}',
|
|
18
|
-
type: 'string',
|
|
19
|
-
'x-decorator': 'FormItem',
|
|
20
|
-
'x-component': 'Select',
|
|
21
|
-
'x-reactions': '{{ useChartFields }}',
|
|
22
|
-
required: true,
|
|
23
|
-
},
|
|
24
|
-
seriesField: {
|
|
25
|
-
title: '{{t("seriesField")}}',
|
|
26
|
-
type: 'string',
|
|
27
|
-
'x-decorator': 'FormItem',
|
|
28
|
-
'x-component': 'Select',
|
|
29
|
-
'x-reactions': '{{ useChartFields }}',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const useProps: usePropsFunc = ({ data, fieldProps, general, advanced }) => {
|
|
35
|
-
const meta = {};
|
|
36
|
-
Object.entries(fieldProps).forEach(([key, props]) => {
|
|
37
|
-
meta[key] = {
|
|
38
|
-
formatter: props.transformer,
|
|
39
|
-
alias: props.label,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
data,
|
|
44
|
-
meta,
|
|
45
|
-
animation: false,
|
|
46
|
-
...general,
|
|
47
|
-
...advanced,
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const G2PlotLibrary: Charts = {
|
|
52
|
-
line: {
|
|
53
|
-
name: 'Line Chart',
|
|
54
|
-
component: Line,
|
|
55
|
-
schema: basicSchema,
|
|
56
|
-
init,
|
|
57
|
-
useProps,
|
|
58
|
-
reference: {
|
|
59
|
-
title: 'Line Chart',
|
|
60
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/line',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
area: {
|
|
64
|
-
name: 'Area Chart',
|
|
65
|
-
component: Area,
|
|
66
|
-
schema: basicSchema,
|
|
67
|
-
init,
|
|
68
|
-
useProps,
|
|
69
|
-
reference: {
|
|
70
|
-
title: 'Area Chart',
|
|
71
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/area',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
column: {
|
|
75
|
-
name: 'Column Chart',
|
|
76
|
-
component: Column,
|
|
77
|
-
schema: basicSchema,
|
|
78
|
-
init,
|
|
79
|
-
useProps,
|
|
80
|
-
reference: {
|
|
81
|
-
title: 'Column Chart',
|
|
82
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/column',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
bar: {
|
|
86
|
-
name: 'Bar Chart',
|
|
87
|
-
component: Bar,
|
|
88
|
-
schema: basicSchema,
|
|
89
|
-
init: (fields, { measures, dimensions }) => {
|
|
90
|
-
const { xField, yField, seriesField } = infer(fields, { measures, dimensions });
|
|
91
|
-
return {
|
|
92
|
-
general: {
|
|
93
|
-
xField: yField?.value,
|
|
94
|
-
yField: xField?.value,
|
|
95
|
-
seriesField: seriesField?.value,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
useProps,
|
|
100
|
-
reference: {
|
|
101
|
-
title: 'Bar Chart',
|
|
102
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/bar',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
pie: {
|
|
106
|
-
name: 'Pie Chart',
|
|
107
|
-
component: Pie,
|
|
108
|
-
schema: {
|
|
109
|
-
type: 'object',
|
|
110
|
-
properties: {
|
|
111
|
-
angleField: {
|
|
112
|
-
title: '{{t("angleField")}}',
|
|
113
|
-
type: 'string',
|
|
114
|
-
'x-decorator': 'FormItem',
|
|
115
|
-
'x-component': 'Select',
|
|
116
|
-
'x-reactions': '{{ useChartFields }}',
|
|
117
|
-
required: true,
|
|
118
|
-
},
|
|
119
|
-
colorField: {
|
|
120
|
-
title: '{{t("colorField")}}',
|
|
121
|
-
type: 'string',
|
|
122
|
-
'x-decorator': 'FormItem',
|
|
123
|
-
'x-component': 'Select',
|
|
124
|
-
'x-reactions': '{{ useChartFields }}',
|
|
125
|
-
required: true,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
init: (fields, { measures, dimensions }) => {
|
|
130
|
-
const { xField, yField } = infer(fields, { measures, dimensions });
|
|
131
|
-
return {
|
|
132
|
-
general: {
|
|
133
|
-
colorField: xField?.value,
|
|
134
|
-
angleField: yField?.value,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
useProps,
|
|
139
|
-
reference: {
|
|
140
|
-
title: 'Pie Chart',
|
|
141
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/pie',
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
dualAxes: {
|
|
145
|
-
name: 'Dual Axes Chart',
|
|
146
|
-
component: DualAxes,
|
|
147
|
-
useProps: ({ data, fieldProps, general, advanced }) => {
|
|
148
|
-
return {
|
|
149
|
-
...useProps({ data, fieldProps, general, advanced }),
|
|
150
|
-
data: [data, data],
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
schema: {
|
|
154
|
-
type: 'object',
|
|
155
|
-
properties: {
|
|
156
|
-
xField: {
|
|
157
|
-
title: '{{t("xField")}}',
|
|
158
|
-
type: 'string',
|
|
159
|
-
'x-decorator': 'FormItem',
|
|
160
|
-
'x-component': 'Select',
|
|
161
|
-
'x-reactions': '{{ useChartFields }}',
|
|
162
|
-
required: true,
|
|
163
|
-
},
|
|
164
|
-
yField: {
|
|
165
|
-
title: '{{t("yField")}}',
|
|
166
|
-
type: 'array',
|
|
167
|
-
'x-decorator': 'FormItem',
|
|
168
|
-
'x-component': 'ArrayItems',
|
|
169
|
-
items: {
|
|
170
|
-
type: 'void',
|
|
171
|
-
'x-component': 'Space',
|
|
172
|
-
properties: {
|
|
173
|
-
sort: {
|
|
174
|
-
type: 'void',
|
|
175
|
-
'x-decorator': 'FormItem',
|
|
176
|
-
'x-component': 'ArrayItems.SortHandle',
|
|
177
|
-
},
|
|
178
|
-
input: {
|
|
179
|
-
type: 'string',
|
|
180
|
-
'x-decorator': 'FormItem',
|
|
181
|
-
'x-component': 'Select',
|
|
182
|
-
'x-reactions': '{{ useChartFields }}',
|
|
183
|
-
'x-component-props': {
|
|
184
|
-
style: {
|
|
185
|
-
minWidth: '200px',
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
required: true,
|
|
189
|
-
},
|
|
190
|
-
remove: {
|
|
191
|
-
type: 'void',
|
|
192
|
-
'x-decorator': 'FormItem',
|
|
193
|
-
'x-component': 'ArrayItems.Remove',
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
properties: {
|
|
198
|
-
add: {
|
|
199
|
-
type: 'void',
|
|
200
|
-
title: '{{t("Add")}}',
|
|
201
|
-
'x-component': 'ArrayItems.Addition',
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
init: (fields, { measures, dimensions }) => {
|
|
208
|
-
const { xField, yFields } = infer(fields, { measures, dimensions });
|
|
209
|
-
return {
|
|
210
|
-
general: {
|
|
211
|
-
xField: xField?.value,
|
|
212
|
-
yField: yFields?.map((f) => f.value).slice(0, 2) || [],
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
},
|
|
216
|
-
reference: {
|
|
217
|
-
title: 'Dual Axes Chart',
|
|
218
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/dual-axes',
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
// gauge: {
|
|
222
|
-
// name: 'Gauge Chart',
|
|
223
|
-
// component: Gauge,
|
|
224
|
-
// },
|
|
225
|
-
scatter: {
|
|
226
|
-
name: 'Scatter Chart',
|
|
227
|
-
component: Scatter,
|
|
228
|
-
schema: basicSchema,
|
|
229
|
-
init,
|
|
230
|
-
useProps,
|
|
231
|
-
reference: {
|
|
232
|
-
title: 'Scatter Chart',
|
|
233
|
-
link: 'https://g2plot.antv.antgroup.com/api/plots/scatter',
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
};
|
package/src/client/utils.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@formily/react';
|
|
2
|
-
import { uid } from '@formily/shared';
|
|
3
|
-
import { SelectedField } from './block';
|
|
4
|
-
import { FieldOption } from './hooks';
|
|
5
|
-
import { QueryProps } from './renderer';
|
|
6
|
-
|
|
7
|
-
export const createRendererSchema = (decoratorProps: any, componentProps = {}) => {
|
|
8
|
-
const { collection } = decoratorProps;
|
|
9
|
-
return {
|
|
10
|
-
type: 'void',
|
|
11
|
-
'x-decorator': 'ChartRendererProvider',
|
|
12
|
-
'x-decorator-props': decoratorProps,
|
|
13
|
-
'x-acl-action': `${collection}:list`,
|
|
14
|
-
'x-designer': 'ChartRenderer.Designer',
|
|
15
|
-
'x-component': 'CardItem',
|
|
16
|
-
'x-component-props': {
|
|
17
|
-
size: 'small',
|
|
18
|
-
},
|
|
19
|
-
'x-initializer': 'ChartInitializers',
|
|
20
|
-
properties: {
|
|
21
|
-
[uid()]: {
|
|
22
|
-
type: 'void',
|
|
23
|
-
'x-component': 'ChartRenderer',
|
|
24
|
-
'x-component-props': componentProps,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// For AssociationField, the format of field is [targetField, field]
|
|
31
|
-
export const parseField = (field: string | string[]) => {
|
|
32
|
-
let target: string;
|
|
33
|
-
let name: string;
|
|
34
|
-
if (!Array.isArray(field)) {
|
|
35
|
-
name = field;
|
|
36
|
-
} else if (field.length === 1) {
|
|
37
|
-
name = field[0];
|
|
38
|
-
} else if (field.length > 1) {
|
|
39
|
-
[target, name] = field;
|
|
40
|
-
}
|
|
41
|
-
return { target, name, alias: target ? `${target}.${name}` : name };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getField = (fields: FieldOption[], field: string | string[]) => {
|
|
45
|
-
const { target, name } = parseField(field);
|
|
46
|
-
if (!target) {
|
|
47
|
-
return fields.find((f) => f.name === name);
|
|
48
|
-
}
|
|
49
|
-
const targetField = fields.find((f) => f.name === target)?.targetFields?.find((f) => f.name === name);
|
|
50
|
-
return targetField;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const getSelectedFields = (fields: FieldOption[], query: QueryProps) => {
|
|
54
|
-
// When field alias is set, appends it to the field list
|
|
55
|
-
const process = (selectedFields: SelectedField[]) => {
|
|
56
|
-
return selectedFields.map((selectedField) => {
|
|
57
|
-
const fieldProps = getField(fields, selectedField.field);
|
|
58
|
-
return {
|
|
59
|
-
...fieldProps,
|
|
60
|
-
key: selectedField.alias || fieldProps?.key,
|
|
61
|
-
label: selectedField.alias || fieldProps?.label,
|
|
62
|
-
value: selectedField.alias || fieldProps?.value,
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
const measures = query.measures || [];
|
|
67
|
-
const dimensions = query.dimensions || [];
|
|
68
|
-
// unique
|
|
69
|
-
const map = new Map([...process(measures), ...process(dimensions)].map((item) => [item.value, item]));
|
|
70
|
-
const selectedFields = [...map.values()];
|
|
71
|
-
return selectedFields;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const processData = (fields: FieldOption[], data: any[], scope: any) => {
|
|
75
|
-
const parseEnum = (field: FieldOption, value: any) => {
|
|
76
|
-
const options = field.uiSchema?.enum as { value: string; label: string }[];
|
|
77
|
-
if (!options || !Array.isArray(options)) {
|
|
78
|
-
return value;
|
|
79
|
-
}
|
|
80
|
-
const option = options.find((option) => option.value === value);
|
|
81
|
-
return Schema.compile(option?.label || value, scope);
|
|
82
|
-
};
|
|
83
|
-
return data.map((record) => {
|
|
84
|
-
const processed = {};
|
|
85
|
-
Object.entries(record).forEach(([key, value]) => {
|
|
86
|
-
const field = getField(fields, key.split('.'));
|
|
87
|
-
if (!field) {
|
|
88
|
-
processed[key] = value;
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
switch (field.interface) {
|
|
92
|
-
case 'select':
|
|
93
|
-
case 'radioGroup':
|
|
94
|
-
processed[key] = parseEnum(field, value);
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
processed[key] = value;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return processed;
|
|
101
|
-
});
|
|
102
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './server';
|
package/src/locale/en-US.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
Edit: 'Edit',
|
|
3
|
-
Delete: 'Delete',
|
|
4
|
-
Cancel: 'Cancel',
|
|
5
|
-
Submit: 'Submit',
|
|
6
|
-
Actions: 'Actions',
|
|
7
|
-
Title: 'Title',
|
|
8
|
-
Enable: 'Enable',
|
|
9
|
-
'SAML manager': 'SAML manager',
|
|
10
|
-
'SAML Providers': 'SAML Providers',
|
|
11
|
-
'Redirect url': 'Redirect url',
|
|
12
|
-
'SP entity id': 'SP entity id',
|
|
13
|
-
'Add provider': 'Add',
|
|
14
|
-
'Edit provider': 'Edit',
|
|
15
|
-
'Client id': 'Client id',
|
|
16
|
-
'Entity id or issuer': 'Entity id or issuer',
|
|
17
|
-
'Login Url': 'Login Url',
|
|
18
|
-
'Public cert': 'Public cert',
|
|
19
|
-
'Delete provider': 'Delete',
|
|
20
|
-
'Are you sure you want to delete it?': 'Are you sure you want to delete it?',
|
|
21
|
-
'Sign in button name, which will be displayed on the sign in page':
|
|
22
|
-
'Sign in button name, which will be displayed on the sign in page',
|
|
23
|
-
};
|
package/src/locale/fr-FR.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|
package/src/locale/ja-JP.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|
package/src/locale/pt-BR.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
Edit: 'Editar',
|
|
3
|
-
Delete: 'Delete',
|
|
4
|
-
Cancel: 'Cancelar',
|
|
5
|
-
Submit: 'Enviar',
|
|
6
|
-
Actions: 'Ações',
|
|
7
|
-
Title: 'Titulo',
|
|
8
|
-
Enable: 'Ativo',
|
|
9
|
-
'SAML manager': 'Gerenciador SAML',
|
|
10
|
-
'SAML Providers': 'Provedores SAML',
|
|
11
|
-
'Redirect url': 'URL de redirecionamento',
|
|
12
|
-
'SP entity id': 'ID de entidade do provedor de serviço (SP)',
|
|
13
|
-
'Add provider': 'Adicionar',
|
|
14
|
-
'Edit provider': 'Editar',
|
|
15
|
-
'Client id': 'ID do cliente',
|
|
16
|
-
'Entity id or issuer': 'ID de entidade ou emissor',
|
|
17
|
-
'Login Url': 'URL de login',
|
|
18
|
-
'Public cert': 'Certificado público',
|
|
19
|
-
'Delete provider': 'Excluir',
|
|
20
|
-
'Are you sure you want to delete it?': 'Tem certeza de que deseja excluí-lo?',
|
|
21
|
-
'Sign in button name, which will be displayed on the sign in page':
|
|
22
|
-
'Nome do botão de login, que será exibido na página de login',
|
|
23
|
-
};
|
package/src/locale/ru-RU.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|
package/src/locale/tr-TR.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|