@nocobase/plugin-data-visualization 0.10.1-alpha.1 → 0.11.0-alpha.1
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/lib/client/Settings.js +13 -13
- package/lib/client/block/ChartConfigure.d.ts +2 -2
- package/lib/client/block/ChartConfigure.js +37 -37
- package/lib/client/block/transformers.js +18 -19
- package/lib/client/hooks.d.ts +1 -1
- package/lib/client/index.d.ts +5 -3
- package/lib/client/index.js +11 -1
- package/lib/client/renderer/ChartLibrary.d.ts +4 -4
- package/lib/client/renderer/ChartLibrary.js +1 -1
- package/lib/client/renderer/ChartRenderer.js +1 -1
- package/lib/client/renderer/ChartRendererProvider.d.ts +5 -5
- package/lib/client/renderer/ChartRendererProvider.js +17 -1
- package/lib/client/renderer/library/AntdLibrary.js +1 -1
- package/lib/server/actions/query.d.ts +4 -4
- package/package.json +28 -16
- package/src/client/Settings.tsx +2 -2
- package/src/client/__tests__/hooks.test.ts +3 -2
- package/src/client/block/ChartConfigure.tsx +5 -5
- package/src/client/block/transformers.ts +1 -1
- package/src/client/index.tsx +8 -2
- package/src/client/renderer/ChartRendererProvider.tsx +13 -1
package/lib/client/Settings.js
CHANGED
|
@@ -11,23 +11,23 @@ function _icons() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data = require("@
|
|
16
|
-
|
|
14
|
+
function _antdV() {
|
|
15
|
+
const data = require("@formily/antd-v5");
|
|
16
|
+
_antdV = function _antdV() {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const data = require("@
|
|
23
|
-
|
|
21
|
+
function _client() {
|
|
22
|
+
const data = require("@nocobase/client");
|
|
23
|
+
_client = function _client() {
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function _antd() {
|
|
29
29
|
const data = require("antd");
|
|
30
|
-
|
|
30
|
+
_antd = function _antd() {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
@@ -60,21 +60,21 @@ const Settings = () => {
|
|
|
60
60
|
const list = Object.entries(libraries).map(([library, {
|
|
61
61
|
enabled
|
|
62
62
|
}]) => {
|
|
63
|
-
return _react().default.createElement(
|
|
63
|
+
return _react().default.createElement(_antd().Button, {
|
|
64
64
|
key: library,
|
|
65
65
|
icon: enabled ? _react().default.createElement(_icons().CheckOutlined, null) : '',
|
|
66
|
-
className: (0, _classnames().default)((0,
|
|
66
|
+
className: (0, _classnames().default)((0, _client().css)`
|
|
67
67
|
margin: 8px 8px 8px 0;
|
|
68
|
-
`, enabled ? (0,
|
|
68
|
+
`, enabled ? (0, _client().css)`
|
|
69
69
|
color: #40a9ff;
|
|
70
70
|
border-color: #40a9ff;
|
|
71
71
|
` : ''),
|
|
72
72
|
onClick: () => toggle(library)
|
|
73
73
|
}, library);
|
|
74
74
|
});
|
|
75
|
-
return _react().default.createElement(
|
|
75
|
+
return _react().default.createElement(_antd().Card, null, _react().default.createElement(_antdV().Form, {
|
|
76
76
|
layout: "vertical"
|
|
77
|
-
}, _react().default.createElement(
|
|
77
|
+
}, _react().default.createElement(_antdV().FormItem, {
|
|
78
78
|
label: t('Enabled Chart Library')
|
|
79
79
|
}, list)));
|
|
80
80
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ISchema } from '@formily/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type ChartConfigCurrent = {
|
|
4
4
|
schema: ISchema;
|
|
5
5
|
field: any;
|
|
6
6
|
collection: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type SelectedField = {
|
|
9
9
|
field: string | string[];
|
|
10
10
|
alias?: string;
|
|
11
11
|
};
|
|
@@ -11,9 +11,9 @@ function _icons() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data = require("@formily/antd");
|
|
16
|
-
|
|
14
|
+
function _antdV() {
|
|
15
|
+
const data = require("@formily/antd-v5");
|
|
16
|
+
_antdV = function _antdV() {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
@@ -39,9 +39,9 @@ function _client() {
|
|
|
39
39
|
};
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function _antd() {
|
|
43
43
|
const data = require("antd");
|
|
44
|
-
|
|
44
|
+
_antd = function _antd() {
|
|
45
45
|
return data;
|
|
46
46
|
};
|
|
47
47
|
return data;
|
|
@@ -87,8 +87,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
87
87
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
88
88
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
89
89
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
90
|
-
const Paragraph =
|
|
91
|
-
Text =
|
|
90
|
+
const Paragraph = _antd().Typography.Paragraph,
|
|
91
|
+
Text = _antd().Typography.Text;
|
|
92
92
|
const ChartConfigContext = (0, _react2().createContext)({
|
|
93
93
|
visible: true
|
|
94
94
|
});
|
|
@@ -186,7 +186,7 @@ const ChartConfigure = props => {
|
|
|
186
186
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
187
187
|
loading = _React$useState6[0],
|
|
188
188
|
setLoading = _React$useState6[1];
|
|
189
|
-
return _react2().default.createElement(
|
|
189
|
+
return _react2().default.createElement(_antd().Button, {
|
|
190
190
|
type: "link",
|
|
191
191
|
loading: loading,
|
|
192
192
|
icon: _react2().default.createElement(_icons().RightSquareOutlined, null),
|
|
@@ -216,7 +216,7 @@ const ChartConfigure = props => {
|
|
|
216
216
|
};
|
|
217
217
|
const queryRef = (0, _react2().useRef)(null);
|
|
218
218
|
const configRef = (0, _react2().useRef)(null);
|
|
219
|
-
return _react2().default.createElement(
|
|
219
|
+
return _react2().default.createElement(_antd().Modal, {
|
|
220
220
|
title: t('Configure chart'),
|
|
221
221
|
open: visible,
|
|
222
222
|
onOk: () => {
|
|
@@ -250,7 +250,7 @@ const ChartConfigure = props => {
|
|
|
250
250
|
});
|
|
251
251
|
},
|
|
252
252
|
onCancel: () => {
|
|
253
|
-
|
|
253
|
+
_antd().Modal.confirm({
|
|
254
254
|
title: t('Are you sure to cancel?'),
|
|
255
255
|
content: t('You changes are not saved. If you click OK, your changes will be lost.'),
|
|
256
256
|
okButtonProps: {
|
|
@@ -267,20 +267,20 @@ const ChartConfigure = props => {
|
|
|
267
267
|
bodyStyle: {
|
|
268
268
|
background: 'rgba(128, 128, 128, 0.08)'
|
|
269
269
|
}
|
|
270
|
-
}, _react2().default.createElement(
|
|
270
|
+
}, _react2().default.createElement(_antdV().Form, {
|
|
271
271
|
layout: "vertical",
|
|
272
272
|
form: form
|
|
273
|
-
}, _react2().default.createElement(
|
|
273
|
+
}, _react2().default.createElement(_antd().Row, {
|
|
274
274
|
gutter: 8
|
|
275
|
-
}, _react2().default.createElement(
|
|
275
|
+
}, _react2().default.createElement(_antd().Col, {
|
|
276
276
|
span: 7
|
|
277
|
-
}, _react2().default.createElement(
|
|
277
|
+
}, _react2().default.createElement(_antd().Card, {
|
|
278
278
|
style: {
|
|
279
279
|
height: 'calc(100vh - 300px)',
|
|
280
280
|
overflow: 'scroll'
|
|
281
281
|
},
|
|
282
282
|
ref: queryRef
|
|
283
|
-
}, _react2().default.createElement(
|
|
283
|
+
}, _react2().default.createElement(_antd().Tabs, {
|
|
284
284
|
tabBarExtraContent: _react2().default.createElement(RunButton, null),
|
|
285
285
|
items: [{
|
|
286
286
|
label: t('Query'),
|
|
@@ -291,15 +291,15 @@ const ChartConfigure = props => {
|
|
|
291
291
|
key: 'data',
|
|
292
292
|
children: _react2().default.createElement(ChartConfigure.Data, null)
|
|
293
293
|
}]
|
|
294
|
-
}))), _react2().default.createElement(
|
|
294
|
+
}))), _react2().default.createElement(_antd().Col, {
|
|
295
295
|
span: 6
|
|
296
|
-
}, _react2().default.createElement(
|
|
296
|
+
}, _react2().default.createElement(_antd().Card, {
|
|
297
297
|
style: {
|
|
298
298
|
height: 'calc(100vh - 300px)',
|
|
299
299
|
overflow: 'scroll'
|
|
300
300
|
},
|
|
301
301
|
ref: configRef
|
|
302
|
-
}, _react2().default.createElement(
|
|
302
|
+
}, _react2().default.createElement(_antd().Tabs, {
|
|
303
303
|
items: [{
|
|
304
304
|
label: t('Chart'),
|
|
305
305
|
key: 'chart',
|
|
@@ -309,9 +309,9 @@ const ChartConfigure = props => {
|
|
|
309
309
|
key: 'transform',
|
|
310
310
|
children: _react2().default.createElement(ChartConfigure.Transform, null)
|
|
311
311
|
}]
|
|
312
|
-
}))), _react2().default.createElement(
|
|
312
|
+
}))), _react2().default.createElement(_antd().Col, {
|
|
313
313
|
span: 11
|
|
314
|
-
}, _react2().default.createElement(
|
|
314
|
+
}, _react2().default.createElement(_antd().Card, null, _react2().default.createElement(ChartConfigure.Renderer, {
|
|
315
315
|
runQuery: runQuery
|
|
316
316
|
}))))));
|
|
317
317
|
};
|
|
@@ -355,7 +355,7 @@ ChartConfigure.Query = function Query() {
|
|
|
355
355
|
t: lang
|
|
356
356
|
});
|
|
357
357
|
const filterOptions = (0, _client().useCollectionFilterOptions)(collection);
|
|
358
|
-
const formCollapse =
|
|
358
|
+
const formCollapse = _antdV().FormCollapse.createFormCollapse(['measures', 'dimensions', 'filter', 'sort']);
|
|
359
359
|
const onCollectionChange = value => {
|
|
360
360
|
const schema = current.schema,
|
|
361
361
|
field = current.field;
|
|
@@ -392,17 +392,17 @@ ChartConfigure.Query = function Query() {
|
|
|
392
392
|
useOrderReaction: (0, _hooks.useOrderReaction)(compiledFieldOptions, fields)
|
|
393
393
|
},
|
|
394
394
|
components: {
|
|
395
|
-
ArrayItems:
|
|
396
|
-
Editable:
|
|
397
|
-
FormCollapse:
|
|
398
|
-
Card:
|
|
399
|
-
Switch:
|
|
395
|
+
ArrayItems: _antdV().ArrayItems,
|
|
396
|
+
Editable: _antdV().Editable,
|
|
397
|
+
FormCollapse: _antdV().FormCollapse,
|
|
398
|
+
Card: _antd().Card,
|
|
399
|
+
Switch: _antdV().Switch,
|
|
400
400
|
Select: _client().Select,
|
|
401
401
|
Input: _client().Input,
|
|
402
402
|
InputNumber: _client().InputNumber,
|
|
403
|
-
FormItem:
|
|
403
|
+
FormItem: _antdV().FormItem,
|
|
404
404
|
Radio: _client().Radio,
|
|
405
|
-
Space:
|
|
405
|
+
Space: _antd().Space,
|
|
406
406
|
Filter: _client().Filter,
|
|
407
407
|
DatePicker: _client().DatePicker,
|
|
408
408
|
Text,
|
|
@@ -444,12 +444,12 @@ ChartConfigure.Config = function Config() {
|
|
|
444
444
|
getReference
|
|
445
445
|
},
|
|
446
446
|
components: {
|
|
447
|
-
Card:
|
|
447
|
+
Card: _antd().Card,
|
|
448
448
|
Select: _client().Select,
|
|
449
449
|
Input: _client().Input,
|
|
450
|
-
FormItem:
|
|
451
|
-
ArrayItems:
|
|
452
|
-
Space:
|
|
450
|
+
FormItem: _antdV().FormItem,
|
|
451
|
+
ArrayItems: _antdV().ArrayItems,
|
|
452
|
+
Space: _antd().Space,
|
|
453
453
|
AutoComplete: _client().AutoComplete
|
|
454
454
|
}
|
|
455
455
|
});
|
|
@@ -465,9 +465,9 @@ ChartConfigure.Transform = function Transform() {
|
|
|
465
465
|
schema: _configure.transformSchema,
|
|
466
466
|
components: {
|
|
467
467
|
Select: _client().Select,
|
|
468
|
-
FormItem:
|
|
469
|
-
ArrayItems:
|
|
470
|
-
Space:
|
|
468
|
+
FormItem: _antdV().FormItem,
|
|
469
|
+
ArrayItems: _antdV().ArrayItems,
|
|
470
|
+
Space: _antd().Space
|
|
471
471
|
},
|
|
472
472
|
scope: {
|
|
473
473
|
useChartFields: getChartFields,
|
|
@@ -481,7 +481,7 @@ ChartConfigure.Data = function Data() {
|
|
|
481
481
|
const _useContext4 = (0, _react2().useContext)(ChartConfigContext),
|
|
482
482
|
data = _useContext4.data;
|
|
483
483
|
const fields = (0, _hooks.useFieldsWithAssociation)();
|
|
484
|
-
return Array.isArray(data) ? _react2().default.createElement(
|
|
484
|
+
return Array.isArray(data) ? _react2().default.createElement(_antd().Table, {
|
|
485
485
|
dataSource: data,
|
|
486
486
|
columns: Object.keys(data[0] || {}).map(col => {
|
|
487
487
|
const field = (0, _utils.getField)(fields, col.split('.'));
|
|
@@ -492,7 +492,7 @@ ChartConfigure.Data = function Data() {
|
|
|
492
492
|
};
|
|
493
493
|
}),
|
|
494
494
|
size: "small"
|
|
495
|
-
}) : _react2().default.createElement(
|
|
495
|
+
}) : _react2().default.createElement(_antd().Alert, {
|
|
496
496
|
message: "Error",
|
|
497
497
|
type: "error",
|
|
498
498
|
description: data,
|
|
@@ -4,35 +4,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data =
|
|
9
|
-
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/utils/client");
|
|
9
|
+
_client = function _client() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
14
|
const transformers = {
|
|
16
15
|
datetime: {
|
|
17
|
-
YYYY: val => (0,
|
|
18
|
-
MM: val => (0,
|
|
19
|
-
DD: val => (0,
|
|
20
|
-
'YYYY-MM': val => (0,
|
|
21
|
-
'YYYY-MM-DD': val => (0,
|
|
22
|
-
'YYYY-MM-DD hh:mm': val => (0,
|
|
23
|
-
'YYYY-MM-DD hh:mm:ss': val => (0,
|
|
16
|
+
YYYY: val => (0, _client().dayjs)(val).format('YYYY'),
|
|
17
|
+
MM: val => (0, _client().dayjs)(val).format('MM'),
|
|
18
|
+
DD: val => (0, _client().dayjs)(val).format('DD'),
|
|
19
|
+
'YYYY-MM': val => (0, _client().dayjs)(val).format('YYYY-MM'),
|
|
20
|
+
'YYYY-MM-DD': val => (0, _client().dayjs)(val).format('YYYY-MM-DD'),
|
|
21
|
+
'YYYY-MM-DD hh:mm': val => (0, _client().dayjs)(val).format('YYYY-MM-DD hh:mm'),
|
|
22
|
+
'YYYY-MM-DD hh:mm:ss': val => (0, _client().dayjs)(val).format('YYYY-MM-DD hh:mm:ss')
|
|
24
23
|
},
|
|
25
24
|
date: {
|
|
26
|
-
YYYY: val => (0,
|
|
27
|
-
MM: val => (0,
|
|
28
|
-
DD: val => (0,
|
|
29
|
-
'YYYY-MM': val => (0,
|
|
30
|
-
'YYYY-MM-DD': val => (0,
|
|
25
|
+
YYYY: val => (0, _client().dayjs)(val).format('YYYY'),
|
|
26
|
+
MM: val => (0, _client().dayjs)(val).format('MM'),
|
|
27
|
+
DD: val => (0, _client().dayjs)(val).format('DD'),
|
|
28
|
+
'YYYY-MM': val => (0, _client().dayjs)(val).format('YYYY-MM'),
|
|
29
|
+
'YYYY-MM-DD': val => (0, _client().dayjs)(val).format('YYYY-MM-DD')
|
|
31
30
|
},
|
|
32
31
|
time: {
|
|
33
|
-
'hh:mm:ss': val => (0,
|
|
34
|
-
'hh:mm': val => (0,
|
|
35
|
-
hh: val => (0,
|
|
32
|
+
'hh:mm:ss': val => (0, _client().dayjs)(val).format('hh:mm:ss'),
|
|
33
|
+
'hh:mm': val => (0, _client().dayjs)(val).format('hh:mm'),
|
|
34
|
+
hh: val => (0, _client().dayjs)(val).format('hh')
|
|
36
35
|
},
|
|
37
36
|
number: {
|
|
38
37
|
Percent: val => new Intl.NumberFormat('en-US', {
|
package/lib/client/hooks.d.ts
CHANGED
package/lib/client/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
2
|
import { ChartLibraryProvider } from './renderer/ChartLibrary';
|
|
3
|
-
declare
|
|
4
|
-
|
|
3
|
+
declare class DataVisualizationPlugin extends Plugin {
|
|
4
|
+
load(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export default DataVisualizationPlugin;
|
|
5
7
|
export { ChartLibraryProvider };
|
package/lib/client/index.js
CHANGED
|
@@ -30,6 +30,8 @@ var _renderer = require("./renderer");
|
|
|
30
30
|
var _ChartLibrary = require("./renderer/ChartLibrary");
|
|
31
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
34
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
33
35
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
36
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
37
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -66,5 +68,13 @@ const Chart = props => {
|
|
|
66
68
|
charts: _renderer.InternalLibrary
|
|
67
69
|
}, props.children)));
|
|
68
70
|
};
|
|
69
|
-
|
|
71
|
+
class DataVisualizationPlugin extends _client().Plugin {
|
|
72
|
+
load() {
|
|
73
|
+
var _this = this;
|
|
74
|
+
return _asyncToGenerator(function* () {
|
|
75
|
+
_this.app.addProvider(Chart);
|
|
76
|
+
})();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var _default = DataVisualizationPlugin;
|
|
70
80
|
exports.default = _default;
|
|
@@ -6,7 +6,7 @@ import { QueryProps } from './ChartRendererProvider';
|
|
|
6
6
|
* @params {usePropsFunc} useProps - Accept the information that the chart component needs to render,
|
|
7
7
|
* process it and return the props of the chart component.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type usePropsFunc = (props: {
|
|
10
10
|
data: any[];
|
|
11
11
|
fieldProps: {
|
|
12
12
|
[field: string]: FieldOption & {
|
|
@@ -16,7 +16,7 @@ export declare type usePropsFunc = (props: {
|
|
|
16
16
|
general: any;
|
|
17
17
|
advanced: any;
|
|
18
18
|
}) => any;
|
|
19
|
-
export
|
|
19
|
+
export type ChartProps = {
|
|
20
20
|
name: string;
|
|
21
21
|
component: React.FC<any>;
|
|
22
22
|
schema?: ISchema;
|
|
@@ -33,10 +33,10 @@ export declare type ChartProps = {
|
|
|
33
33
|
link: string;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type Charts = {
|
|
37
37
|
[type: string]: ChartProps;
|
|
38
38
|
};
|
|
39
|
-
export
|
|
39
|
+
export type ChartLibraries = {
|
|
40
40
|
[library: string]: {
|
|
41
41
|
enabled: boolean;
|
|
42
42
|
charts: Charts;
|
|
@@ -83,7 +83,7 @@ const infer = (fields, {
|
|
|
83
83
|
alias = _parseField.alias;
|
|
84
84
|
return fields.find(f => f.value === alias);
|
|
85
85
|
};
|
|
86
|
-
if (measures
|
|
86
|
+
if (measures !== null && measures !== void 0 && measures.length) {
|
|
87
87
|
yField = getField(fields, measures[0]);
|
|
88
88
|
yFields = measures.map(m => getField(fields, m));
|
|
89
89
|
}
|
|
@@ -142,7 +142,7 @@ const ChartRenderer = props => {
|
|
|
142
142
|
const run = /*#__PURE__*/function () {
|
|
143
143
|
var _ref = _asyncToGenerator(function* (query) {
|
|
144
144
|
var _query$measures;
|
|
145
|
-
if (query
|
|
145
|
+
if (query !== null && query !== void 0 && (_query$measures = query.measures) !== null && _query$measures !== void 0 && _query$measures.length // || (query?.sql?.fields && query?.sql?.clauses)
|
|
146
146
|
) {
|
|
147
147
|
yield runAsync(query);
|
|
148
148
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type MeasureProps = {
|
|
3
3
|
field: string | string[];
|
|
4
4
|
aggregation?: string;
|
|
5
5
|
alias?: string;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type DimensionProps = {
|
|
8
8
|
field: string | string[];
|
|
9
9
|
alias?: string;
|
|
10
10
|
format?: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type TransformProps = {
|
|
13
13
|
field: string;
|
|
14
14
|
type: string;
|
|
15
15
|
format: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type QueryProps = Partial<{
|
|
18
18
|
measures: MeasureProps[];
|
|
19
19
|
dimensions: DimensionProps[];
|
|
20
20
|
orders: {
|
|
@@ -28,7 +28,7 @@ export declare type QueryProps = Partial<{
|
|
|
28
28
|
clauses?: string;
|
|
29
29
|
};
|
|
30
30
|
}>;
|
|
31
|
-
export
|
|
31
|
+
export type ChartRendererProps = {
|
|
32
32
|
collection: string;
|
|
33
33
|
query?: QueryProps;
|
|
34
34
|
config?: {
|
|
@@ -4,6 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ChartRendererProvider = exports.ChartRendererContext = void 0;
|
|
7
|
+
function _css() {
|
|
8
|
+
const data = require("@emotion/css");
|
|
9
|
+
_css = function _css() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
7
14
|
function _client() {
|
|
8
15
|
const data = require("@nocobase/client");
|
|
9
16
|
_client = function _client() {
|
|
@@ -31,8 +38,17 @@ const ChartRendererProvider = props => {
|
|
|
31
38
|
const collection = props.collection;
|
|
32
39
|
return _react().default.createElement(_client().MaybeCollectionProvider, {
|
|
33
40
|
collection: collection
|
|
41
|
+
}, _react().default.createElement("div", {
|
|
42
|
+
className: (0, _css().css)`
|
|
43
|
+
.ant-card {
|
|
44
|
+
box-shadow: none;
|
|
45
|
+
}
|
|
46
|
+
.ant-card-body {
|
|
47
|
+
padding: 0;
|
|
48
|
+
}
|
|
49
|
+
`
|
|
34
50
|
}, _react().default.createElement(ChartRendererContext.Provider, {
|
|
35
51
|
value: _objectSpread({}, props)
|
|
36
|
-
}, props.children));
|
|
52
|
+
}, props.children)));
|
|
37
53
|
};
|
|
38
54
|
exports.ChartRendererProvider = ChartRendererProvider;
|
|
@@ -97,7 +97,7 @@ const AntdLibrary = {
|
|
|
97
97
|
const dataSource = data.map(item => {
|
|
98
98
|
Object.keys(item).map(key => {
|
|
99
99
|
const props = fieldProps[key];
|
|
100
|
-
if (props
|
|
100
|
+
if (props !== null && props !== void 0 && props.transformer) {
|
|
101
101
|
item[key] = props.transformer(item[key]);
|
|
102
102
|
}
|
|
103
103
|
});
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Context, Next } from '@nocobase/actions';
|
|
2
2
|
import { Cache } from '@nocobase/cache';
|
|
3
|
-
|
|
3
|
+
type MeasureProps = {
|
|
4
4
|
field: string | string[];
|
|
5
5
|
type?: string;
|
|
6
6
|
aggregation?: string;
|
|
7
7
|
alias?: string;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type DimensionProps = {
|
|
10
10
|
field: string | string[];
|
|
11
11
|
type?: string;
|
|
12
12
|
alias?: string;
|
|
13
13
|
format?: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
type OrderProps = {
|
|
16
16
|
field: string | string[];
|
|
17
17
|
alias?: string;
|
|
18
18
|
order?: 'asc' | 'desc';
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type QueryParams = Partial<{
|
|
21
21
|
uid: string;
|
|
22
22
|
collection: string;
|
|
23
23
|
measures: MeasureProps[];
|
package/package.json
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-data-visualization",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"main": "lib/server/index.js",
|
|
5
|
-
"devDependencies": {
|
|
6
|
-
"@nocobase/actions": "0.10.1-alpha.1",
|
|
7
|
-
"@nocobase/cache": "0.10.1-alpha.1",
|
|
8
|
-
"@nocobase/server": "0.10.1-alpha.1",
|
|
9
|
-
"@nocobase/test": "0.10.1-alpha.1",
|
|
10
|
-
"@testing-library/react": "^14.0.0",
|
|
11
|
-
"lodash": "^4.17.21"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"@ant-design/plots": "^1.2.5",
|
|
15
|
-
"dayjs": "^1.11.7",
|
|
16
|
-
"react-error-boundary": "^4.0.4"
|
|
17
|
-
},
|
|
3
|
+
"version": "0.11.0-alpha.1",
|
|
18
4
|
"displayName": "Data Visualization",
|
|
19
5
|
"displayName.zh-CN": "数据可视化",
|
|
20
6
|
"description": "Provides business intelligence and data visualization features",
|
|
21
7
|
"description.zh-CN": "提供BI面板和数据可视化功能",
|
|
22
|
-
"
|
|
8
|
+
"main": "lib/server/index.js",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@ant-design/plots": "^1.2.5",
|
|
11
|
+
"classnames": "^2.3.1",
|
|
12
|
+
"react-error-boundary": "^4.0.10"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@ant-design/icons": "^5.1.4",
|
|
16
|
+
"@formily/antd-v5": "1.1.0-beta.4",
|
|
17
|
+
"@formily/core": "2.2.26",
|
|
18
|
+
"@formily/react": "2.2.26",
|
|
19
|
+
"@formily/shared": "2.2.26",
|
|
20
|
+
"@nocobase/actions": "0.11.0-alpha.1",
|
|
21
|
+
"@nocobase/cache": "0.11.0-alpha.1",
|
|
22
|
+
"@nocobase/client": "0.11.0-alpha.1",
|
|
23
|
+
"@nocobase/database": "0.11.0-alpha.1",
|
|
24
|
+
"@nocobase/server": "0.11.0-alpha.1",
|
|
25
|
+
"@nocobase/test": "0.11.0-alpha.1",
|
|
26
|
+
"@nocobase/utils": "0.11.0-alpha.1",
|
|
27
|
+
"@testing-library/react": "^12.1.5",
|
|
28
|
+
"antd": "^5.6.4",
|
|
29
|
+
"lodash": "^4.17.21",
|
|
30
|
+
"react": "^18.2.0",
|
|
31
|
+
"react-i18next": "^11.15.1",
|
|
32
|
+
"vitest": "^0.33.0"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
|
|
23
35
|
}
|
package/src/client/Settings.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CheckOutlined } from '@ant-design/icons';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Form, FormItem } from '@formily/antd-v5';
|
|
3
|
+
import { css } from '@nocobase/client';
|
|
4
4
|
import { Button, Card } from 'antd';
|
|
5
5
|
import cls from 'classnames';
|
|
6
6
|
import React, { useContext } from 'react';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as client from '@nocobase/client';
|
|
2
|
-
import { renderHook } from '@testing-library/react';
|
|
2
|
+
// import { renderHook } from '@testing-library/react';
|
|
3
3
|
import { vi } from 'vitest';
|
|
4
4
|
import formatters from '../block/formatters';
|
|
5
5
|
import transformers from '../block/transformers';
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
useTransformers,
|
|
14
14
|
} from '../hooks';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// TODO: 为了暂时解决很多 Warning 的问题把 `@testing-library/react` 降级到了 12.x 所以不支持 `renderHook`,等到再次升级到 14.x 时再把 skip 去掉
|
|
17
|
+
describe.skip('hooks', () => {
|
|
17
18
|
beforeEach(() => {
|
|
18
19
|
vi.spyOn(client, 'useCollectionManager').mockReturnValue({
|
|
19
20
|
getCollectionFields: (name: string) =>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { RightSquareOutlined } from '@ant-design/icons';
|
|
2
|
-
import { ArrayItems, Editable, Form, FormCollapse, FormItem, Switch } from '@formily/antd';
|
|
3
|
-
import {
|
|
2
|
+
import { ArrayItems, Editable, Form, FormCollapse, FormItem, Switch } from '@formily/antd-v5';
|
|
3
|
+
import { Form as FormType, ObjectField, createForm, onFieldChange, onFormInit } from '@formily/core';
|
|
4
4
|
import { FormConsumer, ISchema, Schema } from '@formily/react';
|
|
5
5
|
import {
|
|
6
6
|
AutoComplete,
|
|
7
7
|
Cascader,
|
|
8
8
|
DatePicker,
|
|
9
9
|
Filter,
|
|
10
|
-
gridRowColWrap,
|
|
11
10
|
Input,
|
|
12
11
|
InputNumber,
|
|
13
12
|
Radio,
|
|
14
13
|
SchemaComponent,
|
|
15
14
|
Select,
|
|
15
|
+
gridRowColWrap,
|
|
16
16
|
useCollectionFieldsOptions,
|
|
17
17
|
useCollectionFilterOptions,
|
|
18
18
|
useDesignable,
|
|
@@ -24,15 +24,15 @@ import { useTranslation } from 'react-i18next';
|
|
|
24
24
|
import {
|
|
25
25
|
useChartFields,
|
|
26
26
|
useCollectionOptions,
|
|
27
|
-
useFieldsWithAssociation,
|
|
28
27
|
useFieldTypes,
|
|
28
|
+
useFieldsWithAssociation,
|
|
29
29
|
useFormatters,
|
|
30
30
|
useOrderFieldsOptions,
|
|
31
31
|
useOrderReaction,
|
|
32
32
|
useTransformers,
|
|
33
33
|
} from '../hooks';
|
|
34
34
|
import { useChartsTranslation } from '../locale';
|
|
35
|
-
import { ChartRenderer, ChartRendererProvider,
|
|
35
|
+
import { ChartRenderer, ChartRendererProvider, useChartTypes, useCharts } from '../renderer';
|
|
36
36
|
import { createRendererSchema, getField, getSelectedFields } from '../utils';
|
|
37
37
|
import { getConfigSchema, querySchema, transformSchema } from './schemas/configure';
|
|
38
38
|
const { Paragraph, Text } = Typography;
|
package/src/client/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
|
|
1
|
+
import { Plugin, SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { ChartInitializers, ChartV2Block, ChartV2BlockDesigner, ChartV2BlockInitializer } from './block';
|
|
4
4
|
import { useChartsTranslation } from './locale';
|
|
@@ -37,5 +37,11 @@ const Chart: React.FC = (props) => {
|
|
|
37
37
|
);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
class DataVisualizationPlugin extends Plugin {
|
|
41
|
+
async load() {
|
|
42
|
+
this.app.addProvider(Chart);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default DataVisualizationPlugin;
|
|
41
47
|
export { ChartLibraryProvider };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
1
2
|
import { MaybeCollectionProvider } from '@nocobase/client';
|
|
2
3
|
import React, { createContext } from 'react';
|
|
3
4
|
|
|
@@ -52,7 +53,18 @@ export const ChartRendererProvider: React.FC<ChartRendererProps> = (props) => {
|
|
|
52
53
|
const { collection } = props;
|
|
53
54
|
return (
|
|
54
55
|
<MaybeCollectionProvider collection={collection}>
|
|
55
|
-
<
|
|
56
|
+
<div
|
|
57
|
+
className={css`
|
|
58
|
+
.ant-card {
|
|
59
|
+
box-shadow: none;
|
|
60
|
+
}
|
|
61
|
+
.ant-card-body {
|
|
62
|
+
padding: 0;
|
|
63
|
+
}
|
|
64
|
+
`}
|
|
65
|
+
>
|
|
66
|
+
<ChartRendererContext.Provider value={{ ...props }}>{props.children}</ChartRendererContext.Provider>
|
|
67
|
+
</div>
|
|
56
68
|
</MaybeCollectionProvider>
|
|
57
69
|
);
|
|
58
70
|
};
|