@nocobase/plugin-charts 0.9.1-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 +4 -0
- package/client.js +30 -0
- package/lib/client/ChartBlockEngine.d.ts +27 -0
- package/lib/client/ChartBlockEngine.js +201 -0
- package/lib/client/ChartBlockEngineDesigner.d.ts +3 -0
- package/lib/client/ChartBlockEngineDesigner.js +348 -0
- package/lib/client/ChartBlockInitializer.d.ts +3 -0
- package/lib/client/ChartBlockInitializer.js +324 -0
- package/lib/client/ChartQueryBlockInitializer.d.ts +9 -0
- package/lib/client/ChartQueryBlockInitializer.js +230 -0
- package/lib/client/ChartQueryMetadataProvider.d.ts +10 -0
- package/lib/client/ChartQueryMetadataProvider.js +118 -0
- package/lib/client/DataSetPreviewTable.d.ts +5 -0
- package/lib/client/DataSetPreviewTable.js +127 -0
- package/lib/client/Icons.d.ts +1 -0
- package/lib/client/Icons.js +226 -0
- package/lib/client/chartRenderComponents/index.d.ts +2 -0
- package/lib/client/chartRenderComponents/index.js +26 -0
- package/lib/client/hooks/index.d.ts +4 -0
- package/lib/client/hooks/index.js +52 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +161 -0
- package/lib/client/locale/en-US.d.ts +23 -0
- package/lib/client/locale/en-US.js +29 -0
- package/lib/client/locale/index.d.ts +3 -0
- package/lib/client/locale/index.js +46 -0
- package/lib/client/locale/ja-JP.d.ts +2 -0
- package/lib/client/locale/ja-JP.js +8 -0
- package/lib/client/locale/ru-RU.d.ts +2 -0
- package/lib/client/locale/ru-RU.js +8 -0
- package/lib/client/locale/tr-TR.d.ts +2 -0
- package/lib/client/locale/tr-TR.js +8 -0
- package/lib/client/locale/zh-CN.d.ts +61 -0
- package/lib/client/locale/zh-CN.js +67 -0
- package/lib/client/select/CustomSelect.d.ts +11 -0
- package/lib/client/select/CustomSelect.js +193 -0
- package/lib/client/select/ReadPretty.d.ts +2 -0
- package/lib/client/select/ReadPretty.js +102 -0
- package/lib/client/select/index.d.ts +2 -0
- package/lib/client/select/index.js +31 -0
- package/lib/client/select/shared.d.ts +7 -0
- package/lib/client/select/shared.js +86 -0
- package/lib/client/settings/AddNewQuery.d.ts +2 -0
- package/lib/client/settings/AddNewQuery.js +321 -0
- package/lib/client/settings/ConfigureFields.d.ts +1 -0
- package/lib/client/settings/ConfigureFields.js +51 -0
- package/lib/client/settings/QueriesTable.d.ts +1 -0
- package/lib/client/settings/QueriesTable.js +108 -0
- package/lib/client/settings/queryTypes.d.ts +5 -0
- package/lib/client/settings/queryTypes.js +85 -0
- package/lib/client/settings/schemas/chartsQueries.d.ts +8 -0
- package/lib/client/settings/schemas/chartsQueries.js +378 -0
- package/lib/client/templates/AreaTemplate.d.ts +65 -0
- package/lib/client/templates/AreaTemplate.js +86 -0
- package/lib/client/templates/BarTemplate.d.ts +80 -0
- package/lib/client/templates/BarTemplate.js +103 -0
- package/lib/client/templates/ColumnTemplate.d.ts +80 -0
- package/lib/client/templates/ColumnTemplate.js +103 -0
- package/lib/client/templates/FunnelTemplate.d.ts +66 -0
- package/lib/client/templates/FunnelTemplate.js +87 -0
- package/lib/client/templates/LineTemplate.d.ts +67 -0
- package/lib/client/templates/LineTemplate.js +92 -0
- package/lib/client/templates/PieTemplate.d.ts +71 -0
- package/lib/client/templates/PieTemplate.js +92 -0
- package/lib/client/templates/RadarTemplate.d.ts +71 -0
- package/lib/client/templates/RadarTemplate.js +93 -0
- package/lib/client/templates/ScatterTemplate.d.ts +91 -0
- package/lib/client/templates/ScatterTemplate.js +112 -0
- package/lib/client/templates/TableTemplate.d.ts +28 -0
- package/lib/client/templates/TableTemplate.js +54 -0
- package/lib/client/templates/index.d.ts +1 -0
- package/lib/client/templates/index.js +33 -0
- package/lib/client/utils.d.ts +3 -0
- package/lib/client/utils.js +66 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +15 -0
- package/lib/server/actions/chartsQueries.d.ts +3 -0
- package/lib/server/actions/chartsQueries.js +104 -0
- package/lib/server/actions/index.d.ts +1 -0
- package/lib/server/actions/index.js +1 -0
- package/lib/server/collections/chartsQueries.d.ts +2 -0
- package/lib/server/collections/chartsQueries.js +36 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +15 -0
- package/lib/server/plugin.d.ts +14 -0
- package/lib/server/plugin.js +142 -0
- package/lib/server/query.d.ts +12 -0
- package/lib/server/query.js +91 -0
- package/lib/server/shared/index.d.ts +2 -0
- package/lib/server/shared/index.js +8 -0
- package/package.json +14 -0
- package/server.d.ts +4 -0
- package/server.js +30 -0
- package/src/client/ChartBlockEngine.tsx +120 -0
- package/src/client/ChartBlockEngineDesigner.tsx +238 -0
- package/src/client/ChartBlockInitializer.tsx +216 -0
- package/src/client/ChartQueryBlockInitializer.tsx +136 -0
- package/src/client/ChartQueryMetadataProvider.tsx +62 -0
- package/src/client/DataSetPreviewTable.tsx +73 -0
- package/src/client/Icons.tsx +99 -0
- package/src/client/chartRenderComponents/index.ts +7 -0
- package/src/client/hooks/index.ts +19 -0
- package/src/client/index.tsx +101 -0
- package/src/client/locale/en-US.ts +23 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +1 -0
- package/src/client/locale/ru-RU.ts +1 -0
- package/src/client/locale/tr-TR.ts +1 -0
- package/src/client/locale/zh-CN.ts +63 -0
- package/src/client/select/CustomSelect.tsx +127 -0
- package/src/client/select/ReadPretty.tsx +36 -0
- package/src/client/select/index.md +38 -0
- package/src/client/select/index.ts +2 -0
- package/src/client/select/shared.ts +36 -0
- package/src/client/settings/AddNewQuery.tsx +161 -0
- package/src/client/settings/ConfigureFields.tsx +18 -0
- package/src/client/settings/QueriesTable.tsx +26 -0
- package/src/client/settings/queryTypes.ts +64 -0
- package/src/client/settings/schemas/chartsQueries.ts +319 -0
- package/src/client/templates/AreaTemplate.tsx +64 -0
- package/src/client/templates/BarTemplate.tsx +80 -0
- package/src/client/templates/ColumnTemplate.tsx +81 -0
- package/src/client/templates/FunnelTemplate.tsx +65 -0
- package/src/client/templates/LineTemplate.tsx +72 -0
- package/src/client/templates/PieTemplate.tsx +68 -0
- package/src/client/templates/RadarTemplate.tsx +71 -0
- package/src/client/templates/ScatterTemplate.tsx +90 -0
- package/src/client/templates/TableTemplate.tsx +48 -0
- package/src/client/templates/index.ts +21 -0
- package/src/client/utils.ts +39 -0
- package/src/index.ts +1 -0
- package/src/server/actions/chartsQueries.ts +44 -0
- package/src/server/actions/index.ts +0 -0
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/chartsQueries.ts +24 -0
- package/src/server/index.ts +1 -0
- package/src/server/plugin.ts +61 -0
- package/src/server/query.ts +39 -0
- package/src/server/shared/index.ts +2 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { ISchema } from '@formily/react';
|
|
2
|
+
import { uid } from '@formily/shared';
|
|
3
|
+
import {
|
|
4
|
+
useActionContext,
|
|
5
|
+
useRecord,
|
|
6
|
+
useRequest,
|
|
7
|
+
useResourceActionContext,
|
|
8
|
+
useResourceContext
|
|
9
|
+
} from '@nocobase/client';
|
|
10
|
+
import { useChartQueryMetadataContext } from '../../ChartQueryMetadataProvider';
|
|
11
|
+
|
|
12
|
+
const collection = {
|
|
13
|
+
name: 'chartsQueries',
|
|
14
|
+
fields: [
|
|
15
|
+
{
|
|
16
|
+
type: 'integer',
|
|
17
|
+
name: 'title',
|
|
18
|
+
interface: 'input',
|
|
19
|
+
uiSchema: {
|
|
20
|
+
title: '{{t("Title",{ns:"charts"})}}',
|
|
21
|
+
type: 'string',
|
|
22
|
+
'x-component': 'Input',
|
|
23
|
+
required: true,
|
|
24
|
+
} as ISchema,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'string',
|
|
28
|
+
name: 'type',
|
|
29
|
+
interface: 'select',
|
|
30
|
+
uiSchema: {
|
|
31
|
+
title: '{{t("Type",{ns:"charts"})}}',
|
|
32
|
+
type: 'string',
|
|
33
|
+
'x-component': 'Select',
|
|
34
|
+
required: true,
|
|
35
|
+
enum: [
|
|
36
|
+
{ label: '{{t("API")}}', value: 'api' },
|
|
37
|
+
{ label: '{{t("SQL")}}', value: 'sql' },
|
|
38
|
+
{ label: '{{t("JSON")}}', value: 'json' },
|
|
39
|
+
],
|
|
40
|
+
} as ISchema,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const useDestroyQueryItemAction = () => {
|
|
46
|
+
const ctx = useChartQueryMetadataContext();
|
|
47
|
+
const { refresh } = useResourceActionContext();
|
|
48
|
+
const { resource, targetKey } = useResourceContext();
|
|
49
|
+
const { [targetKey]: filterByTk } = useRecord();
|
|
50
|
+
return {
|
|
51
|
+
async run() {
|
|
52
|
+
await resource.destroy({ filterByTk });
|
|
53
|
+
refresh();
|
|
54
|
+
ctx.refresh();
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const useDestroyAllSelectedQueriesAction = () => {
|
|
60
|
+
const ctx = useChartQueryMetadataContext();
|
|
61
|
+
const { state, setState, refresh } = useResourceActionContext();
|
|
62
|
+
const { resource, targetKey } = useResourceContext();
|
|
63
|
+
return {
|
|
64
|
+
async run() {
|
|
65
|
+
await resource.destroy({
|
|
66
|
+
filterByTk: state?.selectedRowKeys || [],
|
|
67
|
+
});
|
|
68
|
+
setState?.({ selectedRowKeys: [] });
|
|
69
|
+
refresh();
|
|
70
|
+
ctx.refresh();
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const chartsQueriesSchema: ISchema = {
|
|
76
|
+
type: 'object',
|
|
77
|
+
properties: {
|
|
78
|
+
[uid()]: {
|
|
79
|
+
type: 'void',
|
|
80
|
+
'x-decorator': 'ResourceActionProvider',
|
|
81
|
+
'x-decorator-props': {
|
|
82
|
+
collection,
|
|
83
|
+
resourceName: 'chartsQueries',
|
|
84
|
+
request: {
|
|
85
|
+
resource: 'chartsQueries',
|
|
86
|
+
action: 'list',
|
|
87
|
+
params: {
|
|
88
|
+
pageSize: 50,
|
|
89
|
+
sort: ['-id'],
|
|
90
|
+
appends: [],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
'x-component': 'CollectionProvider',
|
|
95
|
+
'x-component-props': {
|
|
96
|
+
collection,
|
|
97
|
+
},
|
|
98
|
+
properties: {
|
|
99
|
+
actions: {
|
|
100
|
+
type: 'void',
|
|
101
|
+
'x-component': 'ActionBar',
|
|
102
|
+
'x-component-props': {
|
|
103
|
+
style: {
|
|
104
|
+
marginBottom: 16,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
properties: {
|
|
108
|
+
delete: {
|
|
109
|
+
type: 'void',
|
|
110
|
+
title: '{{ t("Delete") }}',
|
|
111
|
+
'x-component': 'Action',
|
|
112
|
+
'x-component-props': {
|
|
113
|
+
useAction: '{{ useDestroyAllSelectedQueriesAction }}',
|
|
114
|
+
confirm: {
|
|
115
|
+
title: '{{t("Delete queries",{ns:"charts"})}}',
|
|
116
|
+
content: "{{t('Are you sure you want to delete it?')}}",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
create: {
|
|
121
|
+
type: 'void',
|
|
122
|
+
title: '{{t("Add query")}}',
|
|
123
|
+
'x-component': 'AddNewQuery',
|
|
124
|
+
'x-component-props': {
|
|
125
|
+
type: 'primary',
|
|
126
|
+
},
|
|
127
|
+
properties: {
|
|
128
|
+
drawer: {
|
|
129
|
+
type: 'void',
|
|
130
|
+
'x-component': 'Action.Drawer',
|
|
131
|
+
'x-decorator': 'Form',
|
|
132
|
+
'x-decorator-props': {
|
|
133
|
+
useValues(options) {
|
|
134
|
+
const ctx = useActionContext();
|
|
135
|
+
return useRequest(
|
|
136
|
+
() =>
|
|
137
|
+
Promise.resolve({
|
|
138
|
+
data: {
|
|
139
|
+
name: `s_${uid()}`,
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
{ ...options, refreshDeps: [ctx.visible] },
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
title: '{{t("Add query",{ns:"charts"})}}',
|
|
147
|
+
properties: {
|
|
148
|
+
title: {
|
|
149
|
+
'x-component': 'CollectionField',
|
|
150
|
+
'x-decorator': 'FormItem',
|
|
151
|
+
},
|
|
152
|
+
type: {
|
|
153
|
+
'x-component': 'CollectionField',
|
|
154
|
+
'x-decorator': 'FormItem',
|
|
155
|
+
},
|
|
156
|
+
footer: {
|
|
157
|
+
type: 'void',
|
|
158
|
+
'x-component': 'Action.Drawer.Footer',
|
|
159
|
+
properties: {
|
|
160
|
+
cancel: {
|
|
161
|
+
title: '{{t("Cancel",{ns:"charts"})}}',
|
|
162
|
+
'x-component': 'Action',
|
|
163
|
+
'x-component-props': {
|
|
164
|
+
useAction: '{{ cm.useCancelAction }}',
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
submit: {
|
|
168
|
+
title: '{{t("Submit",{ns:"charts"})}}',
|
|
169
|
+
'x-component': 'Action',
|
|
170
|
+
'x-component-props': {
|
|
171
|
+
type: 'primary',
|
|
172
|
+
useAction: '{{ cm.useCreateAction }}',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
table: {
|
|
184
|
+
type: 'void',
|
|
185
|
+
'x-uid': 'input',
|
|
186
|
+
'x-component': 'Table.Void',
|
|
187
|
+
'x-component-props': {
|
|
188
|
+
rowKey: 'id',
|
|
189
|
+
rowSelection: {
|
|
190
|
+
type: 'checkbox',
|
|
191
|
+
},
|
|
192
|
+
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
|
193
|
+
},
|
|
194
|
+
properties: {
|
|
195
|
+
title: {
|
|
196
|
+
type: 'void',
|
|
197
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
198
|
+
'x-component': 'Table.Column',
|
|
199
|
+
properties: {
|
|
200
|
+
title: {
|
|
201
|
+
type: 'number',
|
|
202
|
+
'x-component': 'CollectionField',
|
|
203
|
+
'x-read-pretty': true,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
type: {
|
|
208
|
+
type: 'void',
|
|
209
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
210
|
+
'x-component': 'Table.Column',
|
|
211
|
+
properties: {
|
|
212
|
+
type: {
|
|
213
|
+
type: 'string',
|
|
214
|
+
'x-component': 'CollectionField',
|
|
215
|
+
'x-read-pretty': true,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
actions: {
|
|
220
|
+
type: 'void',
|
|
221
|
+
title: '{{t("Actions")}}',
|
|
222
|
+
'x-component': 'Table.Column',
|
|
223
|
+
properties: {
|
|
224
|
+
actions: {
|
|
225
|
+
type: 'void',
|
|
226
|
+
'x-component': 'Space',
|
|
227
|
+
'x-component-props': {
|
|
228
|
+
split: '|',
|
|
229
|
+
},
|
|
230
|
+
properties: {
|
|
231
|
+
fields: {
|
|
232
|
+
type: 'void',
|
|
233
|
+
title: '{{t("Configure fields")}}',
|
|
234
|
+
'x-component': 'Action.Link',
|
|
235
|
+
'x-component-props': {
|
|
236
|
+
type: 'primary',
|
|
237
|
+
},
|
|
238
|
+
properties: {
|
|
239
|
+
drawer: {
|
|
240
|
+
type: 'void',
|
|
241
|
+
'x-component': 'Action.Drawer',
|
|
242
|
+
title: '{{t("Configure fields")}}',
|
|
243
|
+
properties: {
|
|
244
|
+
configure: {
|
|
245
|
+
type: 'void',
|
|
246
|
+
'x-component': 'ConfigureFields',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
update: {
|
|
253
|
+
type: 'void',
|
|
254
|
+
title: '{{t("Edit")}}',
|
|
255
|
+
'x-component': 'EditQuery',
|
|
256
|
+
'x-component-props': {
|
|
257
|
+
type: 'primary',
|
|
258
|
+
},
|
|
259
|
+
properties: {
|
|
260
|
+
drawer: {
|
|
261
|
+
type: 'void',
|
|
262
|
+
'x-component': 'Action.Drawer',
|
|
263
|
+
'x-decorator': 'Form',
|
|
264
|
+
'x-decorator-props': {
|
|
265
|
+
useValues: '{{ cm.useValuesFromRecord }}',
|
|
266
|
+
},
|
|
267
|
+
title: '{{t("Edit")}}',
|
|
268
|
+
properties: {
|
|
269
|
+
title: {
|
|
270
|
+
'x-component': 'CollectionField',
|
|
271
|
+
'x-decorator': 'FormItem',
|
|
272
|
+
},
|
|
273
|
+
footer: {
|
|
274
|
+
type: 'void',
|
|
275
|
+
'x-component': 'Action.Drawer.Footer',
|
|
276
|
+
properties: {
|
|
277
|
+
cancel: {
|
|
278
|
+
title: '{{t("Cancel",{ns:"charts"})}}',
|
|
279
|
+
'x-component': 'Action',
|
|
280
|
+
'x-component-props': {
|
|
281
|
+
useAction: '{{ cm.useCancelAction }}',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
submit: {
|
|
285
|
+
title: '{{t("Submit",{ns:"charts"})}}',
|
|
286
|
+
'x-component': 'Action',
|
|
287
|
+
'x-component-props': {
|
|
288
|
+
type: 'primary',
|
|
289
|
+
useAction: '{{ cm.useUpdateAction }}',
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
delete: {
|
|
299
|
+
type: 'void',
|
|
300
|
+
title: '{{ t("Delete") }}',
|
|
301
|
+
'x-component': 'Action.Link',
|
|
302
|
+
'x-component-props': {
|
|
303
|
+
confirm: {
|
|
304
|
+
title: '{{t("Delete query",{ns:"charts"})}}',
|
|
305
|
+
content: "{{t('Are you sure you want to delete it?')}}",
|
|
306
|
+
},
|
|
307
|
+
useAction: '{{ useDestroyQueryItemAction }}',
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
|
|
3
|
+
const chartConfig = {
|
|
4
|
+
yField: '{{metric}}',
|
|
5
|
+
xField: '{{dimension}}',
|
|
6
|
+
seriesField: '{{category}}',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const areaTemplate = {
|
|
10
|
+
description: '1 「time」or 「Ordered Noun」 field,1 「Numerical」 field,1 「Unordered Noun」 field (optional)',
|
|
11
|
+
type: 'Area',
|
|
12
|
+
title: 'Area',
|
|
13
|
+
iconId: 'icon-area',
|
|
14
|
+
group: 2,
|
|
15
|
+
renderComponent: 'G2Plot',
|
|
16
|
+
defaultChartOptions: chartConfig,
|
|
17
|
+
configurableProperties: {
|
|
18
|
+
type: 'void',
|
|
19
|
+
properties: {
|
|
20
|
+
dimension: {
|
|
21
|
+
required: true,
|
|
22
|
+
type: 'string',
|
|
23
|
+
title: '{{t("Category axis / Dimension",{ns:"charts"})}}',
|
|
24
|
+
'x-decorator': 'FormItem',
|
|
25
|
+
'x-component': 'Select',
|
|
26
|
+
enum: '{{dataSource}}',
|
|
27
|
+
},
|
|
28
|
+
metric: {
|
|
29
|
+
required: true,
|
|
30
|
+
type: 'string',
|
|
31
|
+
title: '{{t("Value axis / Metrics",{ns:"charts"})}}',
|
|
32
|
+
'x-decorator': 'FormItem',
|
|
33
|
+
'x-component': 'Select',
|
|
34
|
+
enum: '{{dataSource}}',
|
|
35
|
+
},
|
|
36
|
+
category: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
|
|
39
|
+
'x-decorator': 'FormItem',
|
|
40
|
+
'x-component': 'Select',
|
|
41
|
+
enum: '{{dataSource}}',
|
|
42
|
+
},
|
|
43
|
+
jsonConfig: {
|
|
44
|
+
type: 'void',
|
|
45
|
+
'x-component': 'div',
|
|
46
|
+
properties: {
|
|
47
|
+
template: {
|
|
48
|
+
required: true,
|
|
49
|
+
title: '{{t("JSON config",{ns:"charts"})}}',
|
|
50
|
+
type: 'string',
|
|
51
|
+
default: JSON5.stringify(chartConfig, null, 2),
|
|
52
|
+
'x-decorator': 'FormItem',
|
|
53
|
+
'x-component': 'Input.TextArea',
|
|
54
|
+
'x-component-props': {
|
|
55
|
+
autoSize: { minRows: 8, maxRows: 16 },
|
|
56
|
+
},
|
|
57
|
+
description: '{{jsonConfigDesc("Area | G2Plot","https://g2plot.antv.antgroup.com/api/plots/area")}}',
|
|
58
|
+
'x-validator': { json5: true },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
|
|
3
|
+
const chartConfig = {
|
|
4
|
+
appendPadding: 10,
|
|
5
|
+
isGroup: true,
|
|
6
|
+
yField: '{{dimension}}',
|
|
7
|
+
xField: '{{metric}}',
|
|
8
|
+
seriesField: '{{category}}',
|
|
9
|
+
label: {
|
|
10
|
+
// 可手动配置 label 数据标签位置
|
|
11
|
+
position: 'middle', // 'top', 'bottom', 'middle',
|
|
12
|
+
// 配置样式
|
|
13
|
+
style: {
|
|
14
|
+
fill: '#FFFFFF',
|
|
15
|
+
opacity: 0.6,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
xAxis: {
|
|
19
|
+
label: {
|
|
20
|
+
autoHide: true,
|
|
21
|
+
autoRotate: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const barTemplate = {
|
|
26
|
+
description: '1 「time」 or 「ordered noun」 field, 1 「value」 field, 0~ 1 「unordered noun」',
|
|
27
|
+
type: 'Bar',
|
|
28
|
+
title: 'Bar',
|
|
29
|
+
iconId: 'icon-bar',
|
|
30
|
+
group: 2,
|
|
31
|
+
renderComponent: 'G2Plot',
|
|
32
|
+
defaultChartOptions: chartConfig,
|
|
33
|
+
configurableProperties: {
|
|
34
|
+
type: 'void',
|
|
35
|
+
properties: {
|
|
36
|
+
dimension: {
|
|
37
|
+
required: true,
|
|
38
|
+
type: 'string',
|
|
39
|
+
title: '{{t("Category axis / Dimension",{ns:"charts"})}}',
|
|
40
|
+
'x-decorator': 'FormItem',
|
|
41
|
+
'x-component': 'Select',
|
|
42
|
+
enum: '{{dataSource}}',
|
|
43
|
+
},
|
|
44
|
+
metric: {
|
|
45
|
+
required: true,
|
|
46
|
+
type: 'string',
|
|
47
|
+
title: '{{t("Value axis / Metrics",{ns:"charts"})}}',
|
|
48
|
+
'x-decorator': 'FormItem',
|
|
49
|
+
'x-component': 'Select',
|
|
50
|
+
enum: '{{dataSource}}',
|
|
51
|
+
},
|
|
52
|
+
category: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
|
|
55
|
+
'x-decorator': 'FormItem',
|
|
56
|
+
'x-component': 'Select',
|
|
57
|
+
enum: '{{dataSource}}',
|
|
58
|
+
},
|
|
59
|
+
jsonConfig: {
|
|
60
|
+
type: 'void',
|
|
61
|
+
'x-component': 'div',
|
|
62
|
+
properties: {
|
|
63
|
+
template: {
|
|
64
|
+
required: true,
|
|
65
|
+
title: '{{t("JSON config",{ns:"charts"})}}',
|
|
66
|
+
type: 'string',
|
|
67
|
+
default: JSON5.stringify(chartConfig, null, 2),
|
|
68
|
+
'x-decorator': 'FormItem',
|
|
69
|
+
'x-component': 'Input.TextArea',
|
|
70
|
+
'x-component-props': {
|
|
71
|
+
autoSize: { minRows: 8, maxRows: 16 },
|
|
72
|
+
},
|
|
73
|
+
description: '{{jsonConfigDesc("Bar | G2Plot","https://g2plot.antv.antgroup.com/api/plots/bar")}}',
|
|
74
|
+
'x-validator': { json5: true },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
|
|
3
|
+
const chartConfig = {
|
|
4
|
+
appendPadding: 10,
|
|
5
|
+
isGroup: true,
|
|
6
|
+
yField: '{{metric}}',
|
|
7
|
+
xField: '{{dimension}}',
|
|
8
|
+
seriesField: '{{category}}',
|
|
9
|
+
label: {
|
|
10
|
+
// 可手动配置 label 数据标签位置
|
|
11
|
+
position: 'middle', // 'top', 'bottom', 'middle',
|
|
12
|
+
// 配置样式
|
|
13
|
+
style: {
|
|
14
|
+
fill: '#FFFFFF',
|
|
15
|
+
opacity: 0.6,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
xAxis: {
|
|
19
|
+
label: {
|
|
20
|
+
autoHide: true,
|
|
21
|
+
autoRotate: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const columnTemplate = {
|
|
27
|
+
description: '1 「time」 or 「ordered noun」 field, 1 「value」 field, 0 to 1 「unordered noun」',
|
|
28
|
+
type: 'Column',
|
|
29
|
+
title: 'Column',
|
|
30
|
+
iconId: 'icon-column',
|
|
31
|
+
group: 2,
|
|
32
|
+
renderComponent: 'G2Plot',
|
|
33
|
+
defaultChartOptions: chartConfig,
|
|
34
|
+
configurableProperties: {
|
|
35
|
+
type: 'void',
|
|
36
|
+
properties: {
|
|
37
|
+
dimension: {
|
|
38
|
+
required: true,
|
|
39
|
+
type: 'string',
|
|
40
|
+
title: '{{t("Category axis / Dimension",{ns:"charts"})}}',
|
|
41
|
+
'x-decorator': 'FormItem',
|
|
42
|
+
'x-component': 'Select',
|
|
43
|
+
enum: '{{dataSource}}',
|
|
44
|
+
},
|
|
45
|
+
metric: {
|
|
46
|
+
required: true,
|
|
47
|
+
type: 'string',
|
|
48
|
+
title: '{{t("Value axis / Metrics",{ns:"charts"})}}',
|
|
49
|
+
'x-decorator': 'FormItem',
|
|
50
|
+
'x-component': 'Select',
|
|
51
|
+
enum: '{{dataSource}}',
|
|
52
|
+
},
|
|
53
|
+
category: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
|
|
56
|
+
'x-decorator': 'FormItem',
|
|
57
|
+
'x-component': 'Select',
|
|
58
|
+
enum: '{{dataSource}}',
|
|
59
|
+
},
|
|
60
|
+
jsonConfig: {
|
|
61
|
+
type: 'void',
|
|
62
|
+
'x-component': 'div',
|
|
63
|
+
properties: {
|
|
64
|
+
template: {
|
|
65
|
+
required: true,
|
|
66
|
+
title: '{{t("JSON config",{ns:"charts"})}}',
|
|
67
|
+
type: 'string',
|
|
68
|
+
default: JSON5.stringify(chartConfig, null, 2),
|
|
69
|
+
'x-decorator': 'FormItem',
|
|
70
|
+
'x-component': 'Input.TextArea',
|
|
71
|
+
'x-component-props': {
|
|
72
|
+
autoSize: { minRows: 8, maxRows: 16 },
|
|
73
|
+
},
|
|
74
|
+
description: '{{jsonConfigDesc("Column | G2Plot","https://g2plot.antv.antgroup.com/api/plots/column")}}',
|
|
75
|
+
'x-validator': { json5: true },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
|
|
3
|
+
const chartConfig = {
|
|
4
|
+
xField: '{{dimension}}',
|
|
5
|
+
yField: '{{metric}}',
|
|
6
|
+
seriesField: '{{category}}',
|
|
7
|
+
legend: false,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const funnelTemplate = {
|
|
11
|
+
description: '1 「Unordered Noun」 field, 1 「Numeric」 field',
|
|
12
|
+
type: 'Funnel',
|
|
13
|
+
title: 'Funnel',
|
|
14
|
+
iconId: 'icon-funnel',
|
|
15
|
+
group: 1,
|
|
16
|
+
renderComponent: 'G2Plot',
|
|
17
|
+
defaultChartOptions: chartConfig,
|
|
18
|
+
configurableProperties: {
|
|
19
|
+
type: 'void',
|
|
20
|
+
properties: {
|
|
21
|
+
dimension: {
|
|
22
|
+
required: true,
|
|
23
|
+
type: 'string',
|
|
24
|
+
title: '{{t("Sector label / Dimensional",{ns:"charts"})}}',
|
|
25
|
+
'x-decorator': 'FormItem',
|
|
26
|
+
'x-component': 'Select',
|
|
27
|
+
enum: '{{dataSource}}',
|
|
28
|
+
},
|
|
29
|
+
metric: {
|
|
30
|
+
required: true,
|
|
31
|
+
type: 'string',
|
|
32
|
+
title: '{{t("Funnel Layer Width/Metrics",{ns:"charts"})}}',
|
|
33
|
+
'x-decorator': 'FormItem',
|
|
34
|
+
'x-component': 'Select',
|
|
35
|
+
enum: '{{dataSource}}',
|
|
36
|
+
},
|
|
37
|
+
category: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
|
|
40
|
+
'x-decorator': 'FormItem',
|
|
41
|
+
'x-component': 'Select',
|
|
42
|
+
enum: '{{dataSource}}',
|
|
43
|
+
},
|
|
44
|
+
jsonConfig: {
|
|
45
|
+
type: 'void',
|
|
46
|
+
'x-component': 'div',
|
|
47
|
+
properties: {
|
|
48
|
+
template: {
|
|
49
|
+
required: true,
|
|
50
|
+
title: '{{t("JSON config",{ns:"charts"})}}',
|
|
51
|
+
type: 'string',
|
|
52
|
+
default: JSON5.stringify(chartConfig, null, 2),
|
|
53
|
+
'x-decorator': 'FormItem',
|
|
54
|
+
'x-component': 'Input.TextArea',
|
|
55
|
+
'x-component-props': {
|
|
56
|
+
autoSize: { minRows: 8, maxRows: 16 },
|
|
57
|
+
},
|
|
58
|
+
description: '{{jsonConfigDesc("Funnel | G2Plot","https://g2plot.antv.antgroup.com/api/plots/funnel")}}',
|
|
59
|
+
'x-validator': { json5: true },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
|
|
3
|
+
const chartConfig = {
|
|
4
|
+
yField: '{{metric}}',
|
|
5
|
+
xField: '{{dimension}}',
|
|
6
|
+
seriesField: '{{category}}',
|
|
7
|
+
xAxis: {
|
|
8
|
+
//type: 'time',
|
|
9
|
+
},
|
|
10
|
+
yAxis: {
|
|
11
|
+
// label: {
|
|
12
|
+
// formatter: '{{(v) => `${v}`.replace(/\d{1,3}(?=(\d{3})+$)/g, (s) => `${s},`)}}',
|
|
13
|
+
// },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const lineTemplate = {
|
|
18
|
+
description: '1 「Time」 or 「Order Noun」 field, 1 「Value」 field',
|
|
19
|
+
type: 'Line',
|
|
20
|
+
title: 'Line',
|
|
21
|
+
iconId: 'icon-line',
|
|
22
|
+
group: 2,
|
|
23
|
+
renderComponent: 'G2Plot',
|
|
24
|
+
defaultChartOptions: chartConfig,
|
|
25
|
+
configurableProperties: {
|
|
26
|
+
type: 'void',
|
|
27
|
+
properties: {
|
|
28
|
+
dimension: {
|
|
29
|
+
required: true,
|
|
30
|
+
type: 'string',
|
|
31
|
+
title: '{{t("Category axis / Dimension",{ns:"charts"})}}',
|
|
32
|
+
'x-decorator': 'FormItem',
|
|
33
|
+
'x-component': 'Select',
|
|
34
|
+
enum: '{{dataSource}}',
|
|
35
|
+
},
|
|
36
|
+
metric: {
|
|
37
|
+
required: true,
|
|
38
|
+
type: 'string',
|
|
39
|
+
title: '{{t("Value axis / Metrics",{ns:"charts"})}}',
|
|
40
|
+
'x-decorator': 'FormItem',
|
|
41
|
+
'x-component': 'Select',
|
|
42
|
+
enum: '{{dataSource}}',
|
|
43
|
+
},
|
|
44
|
+
category: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
|
|
47
|
+
'x-decorator': 'FormItem',
|
|
48
|
+
'x-component': 'Select',
|
|
49
|
+
enum: '{{dataSource}}',
|
|
50
|
+
},
|
|
51
|
+
jsonConfig: {
|
|
52
|
+
type: 'void',
|
|
53
|
+
'x-component': 'div',
|
|
54
|
+
properties: {
|
|
55
|
+
template: {
|
|
56
|
+
required: true,
|
|
57
|
+
title: '{{t("JSON config",{ns:"charts"})}}',
|
|
58
|
+
type: 'string',
|
|
59
|
+
default: JSON5.stringify(chartConfig, null, 2),
|
|
60
|
+
'x-decorator': 'FormItem',
|
|
61
|
+
'x-component': 'Input.TextArea',
|
|
62
|
+
'x-component-props': {
|
|
63
|
+
autoSize: { minRows: 8, maxRows: 16 },
|
|
64
|
+
},
|
|
65
|
+
description: '{{jsonConfigDesc("Line | G2Plot","https://g2plot.antv.antgroup.com/api/plots/line")}}',
|
|
66
|
+
'x-validator': { json5: true },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|