sea-chart 0.0.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/README.md +4 -0
- package/lib/assets/icons/area-chart.svg +10 -0
- package/lib/assets/icons/bar-chart.svg +12 -0
- package/lib/assets/icons/card.svg +22 -0
- package/lib/assets/icons/combination-chart.svg +17 -0
- package/lib/assets/icons/dtable-logo.svg +16 -0
- package/lib/assets/icons/facet-chart.svg +12 -0
- package/lib/assets/icons/gauge.svg +18 -0
- package/lib/assets/icons/heat-map.svg +14 -0
- package/lib/assets/icons/histogram.svg +12 -0
- package/lib/assets/icons/line-chart.svg +12 -0
- package/lib/assets/icons/map.svg +20 -0
- package/lib/assets/icons/pie-chart.svg +11 -0
- package/lib/assets/icons/rectangular-tree-diagram.svg +10 -0
- package/lib/assets/icons/scatter-chart.svg +15 -0
- package/lib/assets/icons/type-change.svg +17 -0
- package/lib/assets/img/area-chart.png +0 -0
- package/lib/assets/img/area-group-chart.png +0 -0
- package/lib/assets/img/bar-group.png +0 -0
- package/lib/assets/img/bar-stack.png +0 -0
- package/lib/assets/img/bar.png +0 -0
- package/lib/assets/img/combination-chart.png +0 -0
- package/lib/assets/img/compared-chart.png +0 -0
- package/lib/assets/img/completeness-chart.png +0 -0
- package/lib/assets/img/custom-bar.png +0 -0
- package/lib/assets/img/dashboard-chart.png +0 -0
- package/lib/assets/img/group-completeness-chart.png +0 -0
- package/lib/assets/img/group_line.png +0 -0
- package/lib/assets/img/heat-map.png +0 -0
- package/lib/assets/img/horizontal-bar.png +0 -0
- package/lib/assets/img/horizontal-group-bar.png +0 -0
- package/lib/assets/img/line.png +0 -0
- package/lib/assets/img/map-bubble.png +0 -0
- package/lib/assets/img/map.png +0 -0
- package/lib/assets/img/mirror.png +0 -0
- package/lib/assets/img/number-card.png +0 -0
- package/lib/assets/img/pie.png +0 -0
- package/lib/assets/img/pivot-table.png +0 -0
- package/lib/assets/img/ring.png +0 -0
- package/lib/assets/img/scatter.png +0 -0
- package/lib/assets/img/stacked-horizontal-bar.png +0 -0
- package/lib/assets/img/treemap.png +0 -0
- package/lib/assets/img/trend-chart.png +0 -0
- package/lib/assets/img/world-map-bubble.png +0 -0
- package/lib/assets/img/world-map.png +0 -0
- package/lib/components/collaborator/index.js +24 -0
- package/lib/components/formatter/area.js +162 -0
- package/lib/components/formatter/bar-group.js +160 -0
- package/lib/components/formatter/bar.js +150 -0
- package/lib/components/formatter/basic-number-card.js +138 -0
- package/lib/components/formatter/chart-component.js +266 -0
- package/lib/components/formatter/combination.js +407 -0
- package/lib/components/formatter/dashboard.js +182 -0
- package/lib/components/formatter/horizontal-bar-group.js +161 -0
- package/lib/components/formatter/horizontal-bar.js +152 -0
- package/lib/components/formatter/horizontal-component.js +91 -0
- package/lib/components/formatter/index.js +181 -0
- package/lib/components/formatter/line-group.js +157 -0
- package/lib/components/formatter/line.js +170 -0
- package/lib/components/formatter/pie.js +201 -0
- package/lib/components/formatter/ring.js +277 -0
- package/lib/components/formatter/table/index.css +103 -0
- package/lib/components/formatter/table/index.js +42 -0
- package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +145 -0
- package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +193 -0
- package/lib/components/formatter/table/pivot-table-display-name.js +249 -0
- package/lib/components/formatter/table/two-dimension-table.js +241 -0
- package/lib/components/formatter/treemap.js +213 -0
- package/lib/components/icon/index.css +5 -0
- package/lib/components/icon/index.js +22 -0
- package/lib/components/index.js +5 -0
- package/lib/components/loading/index.css +54 -0
- package/lib/components/loading/index.js +10 -0
- package/lib/components/number-input/index.js +31 -0
- package/lib/components/pixel-editor/index.css +29 -0
- package/lib/components/pixel-editor/index.js +42 -0
- package/lib/components/select-group/index.css +67 -0
- package/lib/components/select-group/index.js +63 -0
- package/lib/components/settings/advance-bar-settings/data-settings.js +120 -0
- package/lib/components/settings/advance-bar-settings/index.js +3 -0
- package/lib/components/settings/advance-bar-settings/style-settings.js +149 -0
- package/lib/components/settings/bar-settings/data-settings.js +137 -0
- package/lib/components/settings/bar-settings/index.js +3 -0
- package/lib/components/settings/bar-settings/style-settings.js +163 -0
- package/lib/components/settings/basic-number-card/data-settings.js +121 -0
- package/lib/components/settings/basic-number-card/index.js +3 -0
- package/lib/components/settings/basic-number-card/style-settings.js +42 -0
- package/lib/components/settings/combination-settings/data-settings.js +256 -0
- package/lib/components/settings/combination-settings/index.js +3 -0
- package/lib/components/settings/combination-settings/style-settings.js +183 -0
- package/lib/components/settings/dashboard-settings/data-settings.js +167 -0
- package/lib/components/settings/dashboard-settings/index.js +2 -0
- package/lib/components/settings/data-settings.js +67 -0
- package/lib/components/settings/horizontal-bar-settings/data-settings.js +45 -0
- package/lib/components/settings/horizontal-bar-settings/index.js +3 -0
- package/lib/components/settings/horizontal-bar-settings/style-settings.js +38 -0
- package/lib/components/settings/index.css +73 -0
- package/lib/components/settings/index.js +74 -0
- package/lib/components/settings/pie-settings/data-settings.js +123 -0
- package/lib/components/settings/pie-settings/index.js +3 -0
- package/lib/components/settings/pie-settings/style-settings.js +123 -0
- package/lib/components/settings/style-settings.js +100 -0
- package/lib/components/settings/table-settings/data-settings.js +488 -0
- package/lib/components/settings/table-settings/index.js +2 -0
- package/lib/components/settings/time-comparison-settings/data-settings.js +157 -0
- package/lib/components/settings/time-comparison-settings/index.js +3 -0
- package/lib/components/settings/time-comparison-settings/style-settings.js +191 -0
- package/lib/components/settings/widgets/basic-summary/index.css +12 -0
- package/lib/components/settings/widgets/basic-summary/index.js +173 -0
- package/lib/components/settings/widgets/common-data-settings.js +42 -0
- package/lib/components/settings/widgets/data-filter/index.css +17 -0
- package/lib/components/settings/widgets/data-filter/index.js +76 -0
- package/lib/components/settings/widgets/data-sort.js +38 -0
- package/lib/components/settings/widgets/date-summary-item.js +126 -0
- package/lib/components/settings/widgets/display-values-settings/index.css +13 -0
- package/lib/components/settings/widgets/display-values-settings/index.js +37 -0
- package/lib/components/settings/widgets/divider/index.css +4 -0
- package/lib/components/settings/widgets/divider/index.js +10 -0
- package/lib/components/settings/widgets/font-settings/font-size-settings.js +31 -0
- package/lib/components/settings/widgets/font-settings/font-weight-settings.js +46 -0
- package/lib/components/settings/widgets/font-settings/index.js +3 -0
- package/lib/components/settings/widgets/group-by.js +168 -0
- package/lib/components/settings/widgets/label-color.js +30 -0
- package/lib/components/settings/widgets/min-max-setting.js +64 -0
- package/lib/components/settings/widgets/mininum-slice-percent.js +72 -0
- package/lib/components/settings/widgets/numeric-summary-item.js +109 -0
- package/lib/components/settings/widgets/select-table/index.css +0 -0
- package/lib/components/settings/widgets/select-table/index.js +49 -0
- package/lib/components/settings/widgets/stack.js +58 -0
- package/lib/components/settings/widgets/statistic-type/index.css +31 -0
- package/lib/components/settings/widgets/statistic-type/index.js +54 -0
- package/lib/components/settings/widgets/summary-method-setting.js +80 -0
- package/lib/components/settings/widgets/summary-settings.js +394 -0
- package/lib/components/settings/widgets/switch/index.css +37 -0
- package/lib/components/settings/widgets/switch/index.js +21 -0
- package/lib/components/settings/widgets/text-horizontal-settings.js +23 -0
- package/lib/components/settings/widgets/time-picker.js +182 -0
- package/lib/components/settings/widgets/title-settings/index.js +58 -0
- package/lib/components/settings/widgets/title-settings/title-text.js +31 -0
- package/lib/components/settings/widgets/x-axios.js +0 -0
- package/lib/components/settings/widgets/y-axis-group-settings.js +399 -0
- package/lib/components/types-dialog/index.css +97 -0
- package/lib/components/types-dialog/index.js +127 -0
- package/lib/constants/geolocation.js +11 -0
- package/lib/constants/index.js +164 -0
- package/lib/constants/model.js +167 -0
- package/lib/constants/style.js +13 -0
- package/lib/constants/type-image.js +32 -0
- package/lib/constants/type.js +97 -0
- package/lib/context.js +49 -0
- package/lib/index.js +6 -0
- package/lib/intl.js +37 -0
- package/lib/layout/index.js +4 -0
- package/lib/layout/statistic/index.css +53 -0
- package/lib/layout/statistic/index.js +190 -0
- package/lib/layout/title/index.css +3 -0
- package/lib/layout/title/index.js +41 -0
- package/lib/locale/index.js +11 -0
- package/lib/locale/lang/de.js +141 -0
- package/lib/locale/lang/en.js +143 -0
- package/lib/locale/lang/es.js +141 -0
- package/lib/locale/lang/fr.js +141 -0
- package/lib/locale/lang/pt.js +141 -0
- package/lib/locale/lang/ru.js +141 -0
- package/lib/locale/lang/zh_CN.js +143 -0
- package/lib/model/area-group.js +51 -0
- package/lib/model/area.js +42 -0
- package/lib/model/bar-group.js +54 -0
- package/lib/model/bar-stack.js +51 -0
- package/lib/model/bar.js +48 -0
- package/lib/model/base-model.js +11 -0
- package/lib/model/basic-number-card.js +32 -0
- package/lib/model/combination.js +48 -0
- package/lib/model/compare-bar.js +49 -0
- package/lib/model/completeness-group.js +34 -0
- package/lib/model/completeness.js +28 -0
- package/lib/model/dashboard.js +26 -0
- package/lib/model/generic-model.js +235 -0
- package/lib/model/heat-map.js +33 -0
- package/lib/model/horizontal-bar.js +48 -0
- package/lib/model/horizontal-group-bar.js +53 -0
- package/lib/model/index.js +36 -0
- package/lib/model/line-group.js +54 -0
- package/lib/model/line.js +48 -0
- package/lib/model/map-bubble.js +37 -0
- package/lib/model/map.js +37 -0
- package/lib/model/mirror.js +36 -0
- package/lib/model/pie.js +36 -0
- package/lib/model/ring.js +36 -0
- package/lib/model/scatter.js +29 -0
- package/lib/model/stacked-horizontal-bar.js +42 -0
- package/lib/model/statistic.js +22 -0
- package/lib/model/table.js +33 -0
- package/lib/model/tree-map.js +30 -0
- package/lib/model/trend.js +34 -0
- package/lib/model/user.js +22 -0
- package/lib/model/world-map-bubble.js +36 -0
- package/lib/model/world-map.js +36 -0
- package/lib/utils/cell-format-utils.js +41 -0
- package/lib/utils/chart.js +6 -0
- package/lib/utils/collaborator-utils.js +40 -0
- package/lib/utils/column-utils.js +247 -0
- package/lib/utils/custom-g2.js +612 -0
- package/lib/utils/data-filter/filter-item-utils.js +80 -0
- package/lib/utils/data-filter/filters-utils.js +406 -0
- package/lib/utils/data-filter/index.js +3 -0
- package/lib/utils/date-translate.js +66 -0
- package/lib/utils/index.js +50 -0
- package/lib/utils/key-generator.js +13 -0
- package/lib/utils/object-utils.js +61 -0
- package/lib/utils/options-utils.js +61 -0
- package/lib/utils/statistic-column-2-sql-column-utils.js +499 -0
- package/lib/utils/statistic-utils.js +1685 -0
- package/package.json +160 -0
package/lib/context.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import { User } from './model';
|
|
4
|
+
var Context = /*#__PURE__*/function () {
|
|
5
|
+
function Context(eventBus, config) {
|
|
6
|
+
_classCallCheck(this, Context);
|
|
7
|
+
this.settings = config || {};
|
|
8
|
+
this.collaboratorsCache = {};
|
|
9
|
+
this.eventBus = eventBus || {};
|
|
10
|
+
}
|
|
11
|
+
_createClass(Context, [{
|
|
12
|
+
key: "getCollaboratorFromCache",
|
|
13
|
+
value: function getCollaboratorFromCache(email) {
|
|
14
|
+
return this.collaboratorsCache[email];
|
|
15
|
+
}
|
|
16
|
+
}, {
|
|
17
|
+
key: "getCollaboratorsFromCache",
|
|
18
|
+
value: function getCollaboratorsFromCache() {
|
|
19
|
+
var collaboratorsCache = this.collaboratorsCache;
|
|
20
|
+
return Object.values(collaboratorsCache).filter(function (item) {
|
|
21
|
+
return item.email !== 'anonymous';
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
key: "updateCollaboratorsCache",
|
|
26
|
+
value: function updateCollaboratorsCache(email, collaborator) {
|
|
27
|
+
this.collaboratorsCache[email] = collaborator instanceof User ? collaborator : new User(collaborator);
|
|
28
|
+
this.eventBus.dispatch && this.eventBus.dispatch('query-collaborator', email);
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "setSettings",
|
|
32
|
+
value: function setSettings() {
|
|
33
|
+
var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
34
|
+
this.settings = settings;
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "getSettings",
|
|
38
|
+
value: function getSettings() {
|
|
39
|
+
return this.settings;
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "getSetting",
|
|
43
|
+
value: function getSetting(key) {
|
|
44
|
+
return this.settings[key] || this.settings[key] === false ? this.settings[key] : '';
|
|
45
|
+
}
|
|
46
|
+
}]);
|
|
47
|
+
return Context;
|
|
48
|
+
}();
|
|
49
|
+
export default Context;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Statistic, { Settings, StyleSettings } from './layout';
|
|
2
|
+
import { StatisticsUtils } from './utils';
|
|
3
|
+
import { StatisticModel } from './model';
|
|
4
|
+
import { STATISTIC_TYPE } from './constants';
|
|
5
|
+
export default Statistic;
|
|
6
|
+
export { Settings, StyleSettings, StatisticsUtils, StatisticModel, STATISTIC_TYPE };
|
package/lib/intl.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import LOCALES from './locale';
|
|
4
|
+
var Intl = /*#__PURE__*/_createClass(function Intl(_ref) {
|
|
5
|
+
var _this = this;
|
|
6
|
+
var _ref$lang = _ref.lang,
|
|
7
|
+
_lang = _ref$lang === void 0 ? 'en' : _ref$lang;
|
|
8
|
+
_classCallCheck(this, Intl);
|
|
9
|
+
this.setLang = function () {
|
|
10
|
+
var lang = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'en';
|
|
11
|
+
var validLang = lang.toLowerCase();
|
|
12
|
+
if (validLang === _this.lang) return;
|
|
13
|
+
_this.lang = validLang;
|
|
14
|
+
_this.translation = LOCALES[_this.lang] || LOCALES['en'];
|
|
15
|
+
};
|
|
16
|
+
this.get = function (key) {
|
|
17
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18
|
+
if (typeof key !== 'string') return '';
|
|
19
|
+
var optionsKeys = Object.keys(options);
|
|
20
|
+
if (optionsKeys.length === 0) {
|
|
21
|
+
return _this.translation[key] || key;
|
|
22
|
+
}
|
|
23
|
+
if (key.indexOf('{') < 0) return key;
|
|
24
|
+
return key.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
|
|
25
|
+
if (match.charAt(0) === '\\') {
|
|
26
|
+
return match.slice(1);
|
|
27
|
+
}
|
|
28
|
+
return options[name] === null || options[name] === undefined ? '' : options[name];
|
|
29
|
+
}) || key;
|
|
30
|
+
};
|
|
31
|
+
this.lang = _lang.toLowerCase();
|
|
32
|
+
this.translation = LOCALES[this.lang];
|
|
33
|
+
});
|
|
34
|
+
var intl = new Intl({
|
|
35
|
+
lang: 'en'
|
|
36
|
+
});
|
|
37
|
+
export default intl;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.seastatistic-formatter {
|
|
2
|
+
height: 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.seastatistic-formatter-tip {
|
|
10
|
+
background-color: #F5F5F5;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.seastatistic-formatter.error {
|
|
15
|
+
color: red;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.seastatistic-formatter .seastatistic-formatter-container {
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.seastatistic-formatter .seastatistic-table-formatter-container {
|
|
27
|
+
overflow: scroll;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.seastatistic-formatter .seastatistic-container {
|
|
31
|
+
flex: 1;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.seastatistic-formatter .seastatistic-container.show-x-axis-label,
|
|
36
|
+
.seastatistic-formatter .seastatistic-container.show-horizontal-axis-label {
|
|
37
|
+
padding-bottom: 20px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.seastatistic-formatter .seastatistic-container.show-y-axis-label,
|
|
41
|
+
.seastatistic-formatter .seastatistic-container.show-y-axis-left-label,
|
|
42
|
+
.seastatistic-formatter .seastatistic-container.show-vertical-axis-label {
|
|
43
|
+
padding-left: 20px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.seastatistic-formatter .seastatistic-container.show-y-axis-right-label {
|
|
47
|
+
padding-right: 20px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.seastatistic-formatter .g2-html-annotation {
|
|
51
|
+
transform: translate(-50%, -50%);
|
|
52
|
+
width: fit-content;
|
|
53
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import shallowEqual from 'shallowequal';
|
|
8
|
+
import intl from '../../intl';
|
|
9
|
+
import { Formatter, Loading } from '../../components';
|
|
10
|
+
import { StatisticsUtils } from '../../utils';
|
|
11
|
+
import Context from '../../context';
|
|
12
|
+
import Title from '../title';
|
|
13
|
+
import './index.css';
|
|
14
|
+
var Statistic = /*#__PURE__*/function (_React$PureComponent) {
|
|
15
|
+
_inherits(Statistic, _React$PureComponent);
|
|
16
|
+
var _super = _createSuper(Statistic);
|
|
17
|
+
function Statistic(props) {
|
|
18
|
+
var _this;
|
|
19
|
+
_classCallCheck(this, Statistic);
|
|
20
|
+
_this = _super.call(this, props);
|
|
21
|
+
_this.callback = function (errorMessage, tipMessage, data) {
|
|
22
|
+
if (errorMessage) {
|
|
23
|
+
_this.setState({
|
|
24
|
+
errorMessage: errorMessage,
|
|
25
|
+
tipMessage: '',
|
|
26
|
+
data: null,
|
|
27
|
+
isCalculated: true
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (tipMessage) {
|
|
32
|
+
_this.setState({
|
|
33
|
+
errorMessage: '',
|
|
34
|
+
tipMessage: tipMessage,
|
|
35
|
+
data: null,
|
|
36
|
+
isCalculated: true
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!data) {
|
|
41
|
+
_this.setState({
|
|
42
|
+
errorMessage: '',
|
|
43
|
+
tipMessage: 'There_are_no_statistic_results_yet',
|
|
44
|
+
data: null,
|
|
45
|
+
isCalculated: true
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
_this.setState({
|
|
50
|
+
errorMessage: '',
|
|
51
|
+
tipMessage: '',
|
|
52
|
+
data: data,
|
|
53
|
+
isCalculated: true
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
_this.calculateStatistic = function () {
|
|
57
|
+
var isNeedRequestData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
58
|
+
var _this$props = _this.props,
|
|
59
|
+
tables = _this$props.tables,
|
|
60
|
+
statistic = _this$props.statistic,
|
|
61
|
+
queryDataAPI = _this$props.queryDataAPI,
|
|
62
|
+
isStatisticalData = _this$props.isStatisticalData;
|
|
63
|
+
var data = _this.state.data;
|
|
64
|
+
if (!isNeedRequestData) {
|
|
65
|
+
StatisticsUtils.calculateStaticStatistic(tables, statistic, data, _this.callback);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
StatisticsUtils.calculateStatistic(statistic, queryDataAPI, tables, _this.callback, isStatisticalData);
|
|
69
|
+
};
|
|
70
|
+
_this.state = {
|
|
71
|
+
isCalculated: false,
|
|
72
|
+
data: null,
|
|
73
|
+
errorMessage: '',
|
|
74
|
+
tipMessage: ''
|
|
75
|
+
};
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
_createClass(Statistic, [{
|
|
79
|
+
key: "componentDidMount",
|
|
80
|
+
value: function componentDidMount() {
|
|
81
|
+
var _window$seaStatistic, _window$seaStatistic2;
|
|
82
|
+
var _this$props2 = this.props,
|
|
83
|
+
queryUsersAPI = _this$props2.queryUsersAPI,
|
|
84
|
+
context = _this$props2.context,
|
|
85
|
+
config = _this$props2.config,
|
|
86
|
+
eventBus = _this$props2.eventBus;
|
|
87
|
+
if (!window.seaStatistic) {
|
|
88
|
+
window.seaStatistic = {};
|
|
89
|
+
}
|
|
90
|
+
if (!((_window$seaStatistic = window.seaStatistic) === null || _window$seaStatistic === void 0 ? void 0 : _window$seaStatistic.queryUsers)) {
|
|
91
|
+
window.seaStatistic.queryUsers = queryUsersAPI;
|
|
92
|
+
}
|
|
93
|
+
if (!((_window$seaStatistic2 = window.seaStatistic) === null || _window$seaStatistic2 === void 0 ? void 0 : _window$seaStatistic2.context)) {
|
|
94
|
+
var validContext = context || new Context(eventBus, config);
|
|
95
|
+
window.seaStatistic.context = validContext;
|
|
96
|
+
var lang = validContext.getSetting('lang') || 'zh-cn';
|
|
97
|
+
intl.setLang(lang);
|
|
98
|
+
}
|
|
99
|
+
this.calculateStatistic();
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
103
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
104
|
+
var _this2 = this;
|
|
105
|
+
var oldStatistic = this.props.statistic;
|
|
106
|
+
var statistic = nextProps.statistic;
|
|
107
|
+
if (shallowEqual(statistic, oldStatistic)) return;
|
|
108
|
+
this.setState({
|
|
109
|
+
isCalculated: false
|
|
110
|
+
}, function () {
|
|
111
|
+
if (StatisticsUtils.isStatisticTypeChange(statistic, oldStatistic)) {
|
|
112
|
+
_this2.calculateStatistic();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (StatisticsUtils.isStatisticStyleChange(statistic, oldStatistic)) {
|
|
116
|
+
_this2.setState({
|
|
117
|
+
isCalculated: true
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (StatisticsUtils.isStatisticSortChange(statistic, oldStatistic)) {
|
|
122
|
+
_this2.calculateStatistic(false);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
_this2.calculateStatistic();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "render",
|
|
130
|
+
value: function render() {
|
|
131
|
+
var _statistic$config;
|
|
132
|
+
var _this$props3 = this.props,
|
|
133
|
+
statistic = _this$props3.statistic,
|
|
134
|
+
className = _this$props3.className,
|
|
135
|
+
tables = _this$props3.tables,
|
|
136
|
+
canvasStyle = _this$props3.canvasStyle;
|
|
137
|
+
var _this$state = this.state,
|
|
138
|
+
data = _this$state.data,
|
|
139
|
+
isCalculated = _this$state.isCalculated,
|
|
140
|
+
errorMessage = _this$state.errorMessage,
|
|
141
|
+
tipMessage = _this$state.tipMessage;
|
|
142
|
+
var validClassName = classnames('seastatistic-formatter', className);
|
|
143
|
+
var tipBackgroundColorClassName = 'seastatistic-formatter-tip';
|
|
144
|
+
if (!isCalculated) {
|
|
145
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: classnames('loading', validClassName)
|
|
147
|
+
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
148
|
+
}
|
|
149
|
+
if (errorMessage) {
|
|
150
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
152
|
+
}, intl.get(errorMessage));
|
|
153
|
+
}
|
|
154
|
+
if (tipMessage) {
|
|
155
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
157
|
+
}, intl.get(tipMessage));
|
|
158
|
+
}
|
|
159
|
+
if (StatisticsUtils.imEmptyStatistic(data)) {
|
|
160
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
162
|
+
}, intl.get('There_are_no_statistic_results_yet'));
|
|
163
|
+
}
|
|
164
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
165
|
+
className: validClassName
|
|
166
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
167
|
+
className: classnames('seastatistic-formatter-container', "seastatistic-".concat(statistic === null || statistic === void 0 ? void 0 : (_statistic$config = statistic.config) === null || _statistic$config === void 0 ? void 0 : _statistic$config.type, "-formatter-container"))
|
|
168
|
+
}, /*#__PURE__*/React.createElement(Title, {
|
|
169
|
+
statistic: statistic
|
|
170
|
+
}), /*#__PURE__*/React.createElement(Formatter, {
|
|
171
|
+
statistic: statistic,
|
|
172
|
+
data: data,
|
|
173
|
+
tables: tables,
|
|
174
|
+
canvasStyle: canvasStyle
|
|
175
|
+
})));
|
|
176
|
+
}
|
|
177
|
+
}]);
|
|
178
|
+
return Statistic;
|
|
179
|
+
}(React.PureComponent);
|
|
180
|
+
Statistic.defaultProps = {
|
|
181
|
+
isStatisticalData: true,
|
|
182
|
+
canvasStyle: {},
|
|
183
|
+
tables: [],
|
|
184
|
+
statistic: {
|
|
185
|
+
id: '',
|
|
186
|
+
config: {},
|
|
187
|
+
style_config: {}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
export default Statistic;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { isNumber } from 'dtable-utils';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { HORIZONTAL_ALIGNS, HORIZONTAL_ALIGN, DEFAULT_STATISTIC_FONT_WEIGHT, DEFAULT_STATISTIC_TITLE_FONT_SIZE, STATISTIC_SUPPORT_FONT_WEIGHTS, SUPPORT_TITLE_CHART_TYPES } from '../../constants';
|
|
5
|
+
import './index.css';
|
|
6
|
+
var Title = function Title(_ref) {
|
|
7
|
+
var statistic = _ref.statistic,
|
|
8
|
+
className = _ref.className;
|
|
9
|
+
var getTitleStyle = useCallback(function () {
|
|
10
|
+
var style = {
|
|
11
|
+
fontSize: "".concat(DEFAULT_STATISTIC_TITLE_FONT_SIZE, "px"),
|
|
12
|
+
fontWeight: DEFAULT_STATISTIC_FONT_WEIGHT
|
|
13
|
+
};
|
|
14
|
+
if (!statistic || !statistic.style_config || !statistic.style_config.title) {
|
|
15
|
+
return style;
|
|
16
|
+
}
|
|
17
|
+
var _statistic$style_conf = statistic.style_config.title,
|
|
18
|
+
font_size = _statistic$style_conf.font_size,
|
|
19
|
+
font_weight = _statistic$style_conf.font_weight,
|
|
20
|
+
horizontal_align = _statistic$style_conf.horizontal_align;
|
|
21
|
+
if (isNumber(font_size)) {
|
|
22
|
+
style.fontSize = font_size < 0 ? 0 : "".concat(font_size, "px");
|
|
23
|
+
}
|
|
24
|
+
if (STATISTIC_SUPPORT_FONT_WEIGHTS.includes(font_weight)) {
|
|
25
|
+
style.fontWeight = font_weight;
|
|
26
|
+
}
|
|
27
|
+
style.textAlign = horizontal_align && HORIZONTAL_ALIGNS.includes(horizontal_align) ? horizontal_align : HORIZONTAL_ALIGN.LEFT;
|
|
28
|
+
return style;
|
|
29
|
+
}, [statistic]);
|
|
30
|
+
if (!statistic) return null;
|
|
31
|
+
var chartType = statistic.config.type;
|
|
32
|
+
var title = statistic.style_config && statistic.style_config.title;
|
|
33
|
+
var text = title && title.text;
|
|
34
|
+
if (!SUPPORT_TITLE_CHART_TYPES.includes(chartType) || !text) return null;
|
|
35
|
+
var style = getTitleStyle();
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: classnames('seastatistic-title', className),
|
|
38
|
+
style: style
|
|
39
|
+
}, text);
|
|
40
|
+
};
|
|
41
|
+
export default Title;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var de = {
|
|
3
|
+
'Empty': 'Empty',
|
|
4
|
+
'Amount': 'Amount',
|
|
5
|
+
'Counting': 'Count',
|
|
6
|
+
'Summarize_a_field': 'Summarize a field',
|
|
7
|
+
'By_day': 'By day',
|
|
8
|
+
'By_week': 'By week',
|
|
9
|
+
'By_month': 'By month',
|
|
10
|
+
'By_quarter': 'By quarter',
|
|
11
|
+
'By_year': 'By year',
|
|
12
|
+
'Sum': 'Sum',
|
|
13
|
+
"Avg": "Average",
|
|
14
|
+
"Mdn": "Median",
|
|
15
|
+
'Max': 'Max',
|
|
16
|
+
'Min': 'Min',
|
|
17
|
+
'Mean': 'Mean',
|
|
18
|
+
'Number_of_distinct_values': 'Number of distinct values',
|
|
19
|
+
'By_province': 'By province',
|
|
20
|
+
'By_city': 'By city',
|
|
21
|
+
'By_district': 'By district',
|
|
22
|
+
'Row_count': 'Row count',
|
|
23
|
+
'Left': 'Left',
|
|
24
|
+
'Right': 'Right',
|
|
25
|
+
'Center': 'Center',
|
|
26
|
+
'Top': 'Top',
|
|
27
|
+
'Bottom': 'Bottom',
|
|
28
|
+
'Others': 'Others',
|
|
29
|
+
'Total': 'Total',
|
|
30
|
+
'There_are_too_many_statistics_entries_to_display': 'here are too many statistics entries to display.',
|
|
31
|
+
'Data_settings': 'Data settings',
|
|
32
|
+
'Style_settings': 'Style settings',
|
|
33
|
+
'Include_empty': 'Include empty',
|
|
34
|
+
'X_axis': 'X axis',
|
|
35
|
+
'Y_axis': 'Y axis',
|
|
36
|
+
'Display_value': 'Display values on data points',
|
|
37
|
+
'Auto_range': 'Auto range',
|
|
38
|
+
'Select_a_column': 'Select a column',
|
|
39
|
+
"Summary_method": 'Summary method',
|
|
40
|
+
'Label': '',
|
|
41
|
+
'Y-axis(left side)': 'Y-axis (left side)',
|
|
42
|
+
'Y-axis(right side)': 'Y-axis (right side)',
|
|
43
|
+
'Display_title': 'Display title',
|
|
44
|
+
'Current_value_field': 'Current value field',
|
|
45
|
+
'Total_value_field': 'Total value field',
|
|
46
|
+
'Group_by': 'Group by',
|
|
47
|
+
'Display_legend': 'Display legend',
|
|
48
|
+
'Display_label': 'Display label',
|
|
49
|
+
'Label_position': 'Label position',
|
|
50
|
+
'Label_format': 'Label format',
|
|
51
|
+
'Label_font_size': 'Label font size',
|
|
52
|
+
"Count_the_number_of_records_in_each_group": "Count the number of records in each group",
|
|
53
|
+
"Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_a_field": "Compute the sum, maximum, minimum or mean value of records in each group by a field",
|
|
54
|
+
"Group_the_records_according_to_the_vertical_axis_and_count_the_records_in_each_group": "Group the records according to the vertical axis, and count the records in each group",
|
|
55
|
+
"Group_the_records_according_to_the_vertical_axis_and_compute_the_sum_maximum_or_minimum_of_records_in_each_group_by_a_field": "Group the records according to the vertical axis, and compute the sum, maximum, minimum or mean of records in each group by a field",
|
|
56
|
+
"Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_multiple_fields": "Compute the sum, maximum, minimum or mean value of records in each group by multiple fields",
|
|
57
|
+
"Count_the_records": "Group the records according to the X axis, and count the records in every group",
|
|
58
|
+
"Compute_sum_max_min": "Group the records according to the X axis, and compute the sum, maximum, minimum or mean by a field in the records",
|
|
59
|
+
'Summarize_multiple_fields': 'Summarize multiple fields',
|
|
60
|
+
'Add_new_field': 'Add new field',
|
|
61
|
+
'Row_grouping_field': 'Row grouping field',
|
|
62
|
+
'Column_grouping_field': 'Column grouping field',
|
|
63
|
+
'Date_range': 'Date range',
|
|
64
|
+
'Compare_to_date_range': 'Compare to date range',
|
|
65
|
+
'Display_increase': 'Display increase',
|
|
66
|
+
'Display_percentage_increase': 'Display percentage increase',
|
|
67
|
+
'Color': 'Color',
|
|
68
|
+
'Data_sort': 'Data sort',
|
|
69
|
+
'Not_sorted': 'Not sorted',
|
|
70
|
+
'Ascending': 'Ascending',
|
|
71
|
+
'Descending': 'Descending',
|
|
72
|
+
'Numeric_field': 'Numeric field',
|
|
73
|
+
'Summary_field': 'Summary field',
|
|
74
|
+
'No_column': 'No column',
|
|
75
|
+
'Display_mode': 'Display mode',
|
|
76
|
+
'Stack': 'Stack',
|
|
77
|
+
'Location_field': 'Location field',
|
|
78
|
+
'Time_field': 'Time field',
|
|
79
|
+
"Calculate_the_number_of_records_in_two_time_periods": "Calculate the number of records in two time periods",
|
|
80
|
+
"Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Use a field to calculate the sum maximum or minimum value of records in two time periods",
|
|
81
|
+
// 'Count_by_var': 'Count_by_var',
|
|
82
|
+
// 'Compute_sum_max_min_by_var': 'Compute_sum_max_min_by_var',
|
|
83
|
+
'No_options': 'No options',
|
|
84
|
+
'Text_horizontal_alignment': 'Text horizontal alignment',
|
|
85
|
+
'Please_input_date': 'Please input date',
|
|
86
|
+
'Filter': 'Filter',
|
|
87
|
+
'1 Filter': '1 filter',
|
|
88
|
+
'Filters': 'filters',
|
|
89
|
+
'Font_size': 'Font size',
|
|
90
|
+
'Table': 'Table',
|
|
91
|
+
'Chart_type': 'Chart type',
|
|
92
|
+
"Histogram": "Histogram",
|
|
93
|
+
"Basic_histogram": "Basic histogram",
|
|
94
|
+
"Grouped_histogram": "Grouped histogram",
|
|
95
|
+
"Stacked_histogram": "Stacked histogram",
|
|
96
|
+
"Time_comparison_histogram": "Time comparison histogram",
|
|
97
|
+
"Bar_chart": "Bar chart",
|
|
98
|
+
"Basic_bar_chart": "Basic bar chart",
|
|
99
|
+
"Grouped_bar_chart": "Grouped bar chart",
|
|
100
|
+
"Stacked_bar_chart": "Stacked bar chart",
|
|
101
|
+
"Completeness": "Completeness chart",
|
|
102
|
+
"Grouped_completeness": "Grouped completeness chart",
|
|
103
|
+
"Line_chart": "Line chart",
|
|
104
|
+
"Basic_line_chart": "Basic line chart",
|
|
105
|
+
"Grouped_line_chart": "Grouped line chart",
|
|
106
|
+
"Area": "Area",
|
|
107
|
+
"Grouped_area": "Grouped area",
|
|
108
|
+
"Pie_chart": "Pie chart",
|
|
109
|
+
"Basic_pie_chart": "Basic pie chart",
|
|
110
|
+
"Ring_chart": "Ring chart",
|
|
111
|
+
"Scatter": "Scatter chart",
|
|
112
|
+
"Combination": "Combination chart",
|
|
113
|
+
"Map": "Map",
|
|
114
|
+
"World_map": "World map",
|
|
115
|
+
"World_map_bubble": "World map(bubble)",
|
|
116
|
+
"Heat_map": "Heat map",
|
|
117
|
+
"Facet_chart": "Facet chart",
|
|
118
|
+
"Mirror_chart": "Mirror chart",
|
|
119
|
+
"Card": "Card",
|
|
120
|
+
"Basic_number_card": "Basic number card",
|
|
121
|
+
"Trend": "Trend chart",
|
|
122
|
+
"Gauge": "Gauge",
|
|
123
|
+
'Tree_map': 'Tree map',
|
|
124
|
+
'Pivot_table': 'Pivot table',
|
|
125
|
+
'Title': 'Title',
|
|
126
|
+
'Edit_type': 'Edit type',
|
|
127
|
+
'Cancel': 'Cancel',
|
|
128
|
+
'Submit': 'Submit',
|
|
129
|
+
'There_are_no_statistic_results_yet': 'There are no statistic results yet',
|
|
130
|
+
'Year': 'Year',
|
|
131
|
+
'Month': 'Month',
|
|
132
|
+
'Day': 'Day',
|
|
133
|
+
'Hour': 'Hour',
|
|
134
|
+
'Minute': 'Minute',
|
|
135
|
+
'Done': 'Done',
|
|
136
|
+
'Internal_server_error': 'Internal server error',
|
|
137
|
+
'Network_error': 'Network error',
|
|
138
|
+
'There_are_some_problems_with_the_filters': 'There are some problems with the filters.',
|
|
139
|
+
'Please_complete_the_chart_configuration_first': 'Please complete the chart configuration first'
|
|
140
|
+
};
|
|
141
|
+
export default de;
|