sea-chart 0.0.1-beta
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 +120 -0
- package/dist/assets/icons/area-chart.svg +10 -0
- package/dist/assets/icons/bar-chart.svg +12 -0
- package/dist/assets/icons/card.svg +22 -0
- package/dist/assets/icons/combination-chart.svg +17 -0
- package/dist/assets/icons/dtable-logo.svg +16 -0
- package/dist/assets/icons/facet-chart.svg +12 -0
- package/dist/assets/icons/gauge.svg +18 -0
- package/dist/assets/icons/heat-map.svg +14 -0
- package/dist/assets/icons/histogram.svg +12 -0
- package/dist/assets/icons/line-chart.svg +12 -0
- package/dist/assets/icons/map.svg +20 -0
- package/dist/assets/icons/pie-chart.svg +11 -0
- package/dist/assets/icons/rectangular-tree-diagram.svg +10 -0
- package/dist/assets/icons/scatter-chart.svg +15 -0
- package/dist/assets/icons/type-change.svg +17 -0
- package/dist/assets/img/area-chart.png +0 -0
- package/dist/assets/img/area-group-chart.png +0 -0
- package/dist/assets/img/bar-group.png +0 -0
- package/dist/assets/img/bar-stack.png +0 -0
- package/dist/assets/img/bar.png +0 -0
- package/dist/assets/img/combination-chart.png +0 -0
- package/dist/assets/img/compared-chart.png +0 -0
- package/dist/assets/img/completeness-chart.png +0 -0
- package/dist/assets/img/custom-bar.png +0 -0
- package/dist/assets/img/dashboard-chart.png +0 -0
- package/dist/assets/img/group-completeness-chart.png +0 -0
- package/dist/assets/img/group_line.png +0 -0
- package/dist/assets/img/heat-map.png +0 -0
- package/dist/assets/img/horizontal-bar.png +0 -0
- package/dist/assets/img/horizontal-group-bar.png +0 -0
- package/dist/assets/img/line.png +0 -0
- package/dist/assets/img/map-bubble.png +0 -0
- package/dist/assets/img/map.png +0 -0
- package/dist/assets/img/mirror.png +0 -0
- package/dist/assets/img/number-card.png +0 -0
- package/dist/assets/img/pie.png +0 -0
- package/dist/assets/img/pivot-table.png +0 -0
- package/dist/assets/img/ring.png +0 -0
- package/dist/assets/img/scatter.png +0 -0
- package/dist/assets/img/stacked-horizontal-bar.png +0 -0
- package/dist/assets/img/treemap.png +0 -0
- package/dist/assets/img/trend-chart.png +0 -0
- package/dist/assets/img/world-map-bubble.png +0 -0
- package/dist/assets/img/world-map.png +0 -0
- package/dist/components/collaborator/index.js +26 -0
- package/dist/components/icon/index.css +5 -0
- package/dist/components/icon/index.js +24 -0
- package/dist/components/index.js +8 -0
- package/dist/components/loading/index.css +54 -0
- package/dist/components/loading/index.js +12 -0
- package/dist/components/number-input/index.js +31 -0
- package/dist/components/pixel-editor/index.css +29 -0
- package/dist/components/pixel-editor/index.js +38 -0
- package/dist/components/select-group/index.css +67 -0
- package/dist/components/select-group/index.js +52 -0
- package/dist/components/types-dialog/index.css +97 -0
- package/dist/components/types-dialog/index.js +116 -0
- package/dist/constants/geolocation.js +11 -0
- package/dist/constants/index.js +184 -0
- package/dist/constants/model.js +187 -0
- package/dist/constants/style.js +15 -0
- package/dist/constants/type-image.js +59 -0
- package/dist/constants/type.js +124 -0
- package/dist/context.js +33 -0
- package/dist/editor/index.css +0 -0
- package/dist/editor/index.js +36 -0
- package/dist/index.js +6 -0
- package/dist/intl.js +37 -0
- package/dist/locale/index.js +18 -0
- package/dist/locale/lang/de.js +141 -0
- package/dist/locale/lang/en.js +143 -0
- package/dist/locale/lang/es.js +141 -0
- package/dist/locale/lang/fr.js +141 -0
- package/dist/locale/lang/pt.js +141 -0
- package/dist/locale/lang/ru.js +141 -0
- package/dist/locale/lang/zh_CN.js +143 -0
- package/dist/model/area-group.js +41 -0
- package/dist/model/area.js +32 -0
- package/dist/model/bar-group.js +44 -0
- package/dist/model/bar-stack.js +41 -0
- package/dist/model/bar.js +38 -0
- package/dist/model/base-model.js +9 -0
- package/dist/model/basic-number-card.js +22 -0
- package/dist/model/chart.js +23 -0
- package/dist/model/combination.js +38 -0
- package/dist/model/compare-bar.js +39 -0
- package/dist/model/completeness-group.js +24 -0
- package/dist/model/completeness.js +18 -0
- package/dist/model/dashboard.js +16 -0
- package/dist/model/generic-model.js +224 -0
- package/dist/model/heat-map.js +23 -0
- package/dist/model/horizontal-bar.js +38 -0
- package/dist/model/horizontal-group-bar.js +43 -0
- package/dist/model/index.js +63 -0
- package/dist/model/line-group.js +44 -0
- package/dist/model/line.js +38 -0
- package/dist/model/map-bubble.js +27 -0
- package/dist/model/map.js +27 -0
- package/dist/model/mirror.js +26 -0
- package/dist/model/pie.js +26 -0
- package/dist/model/ring.js +26 -0
- package/dist/model/scatter.js +19 -0
- package/dist/model/stacked-horizontal-bar.js +32 -0
- package/dist/model/table.js +23 -0
- package/dist/model/tree-map.js +20 -0
- package/dist/model/trend.js +24 -0
- package/dist/model/user.js +15 -0
- package/dist/model/world-map-bubble.js +26 -0
- package/dist/model/world-map.js +26 -0
- package/dist/settings/advance-bar-settings/data-settings.js +143 -0
- package/dist/settings/advance-bar-settings/index.js +3 -0
- package/dist/settings/advance-bar-settings/style-settings.js +161 -0
- package/dist/settings/bar-settings/data-settings.js +162 -0
- package/dist/settings/bar-settings/index.js +3 -0
- package/dist/settings/bar-settings/style-settings.js +179 -0
- package/dist/settings/basic-number-card/data-settings.js +126 -0
- package/dist/settings/basic-number-card/index.js +3 -0
- package/dist/settings/basic-number-card/style-settings.js +42 -0
- package/dist/settings/combination-settings/data-settings.js +279 -0
- package/dist/settings/combination-settings/index.js +3 -0
- package/dist/settings/combination-settings/style-settings.js +174 -0
- package/dist/settings/dashboard-settings/data-settings.js +179 -0
- package/dist/settings/dashboard-settings/index.js +2 -0
- package/dist/settings/data-settings.js +73 -0
- package/dist/settings/horizontal-bar-settings/data-settings.js +55 -0
- package/dist/settings/horizontal-bar-settings/index.js +3 -0
- package/dist/settings/horizontal-bar-settings/style-settings.js +46 -0
- package/dist/settings/index.css +85 -0
- package/dist/settings/index.js +76 -0
- package/dist/settings/pie-settings/data-settings.js +146 -0
- package/dist/settings/pie-settings/index.js +3 -0
- package/dist/settings/pie-settings/style-settings.js +141 -0
- package/dist/settings/style-settings.js +118 -0
- package/dist/settings/table-settings/data-settings.js +549 -0
- package/dist/settings/table-settings/index.js +2 -0
- package/dist/settings/time-comparison-settings/data-settings.js +172 -0
- package/dist/settings/time-comparison-settings/index.js +3 -0
- package/dist/settings/time-comparison-settings/style-settings.js +213 -0
- package/dist/settings/widgets/basic-summary/index.css +12 -0
- package/dist/settings/widgets/basic-summary/index.js +176 -0
- package/dist/settings/widgets/chart-type/index.css +31 -0
- package/dist/settings/widgets/chart-type/index.js +59 -0
- package/dist/settings/widgets/common-data-settings.js +48 -0
- package/dist/settings/widgets/data-filter/index.css +17 -0
- package/dist/settings/widgets/data-filter/index.js +89 -0
- package/dist/settings/widgets/data-sort.js +44 -0
- package/dist/settings/widgets/date-summary-item.js +111 -0
- package/dist/settings/widgets/display-values-settings/index.css +13 -0
- package/dist/settings/widgets/display-values-settings/index.js +42 -0
- package/dist/settings/widgets/divider/index.css +4 -0
- package/dist/settings/widgets/divider/index.js +12 -0
- package/dist/settings/widgets/font-settings/font-size-settings.js +33 -0
- package/dist/settings/widgets/font-settings/font-weight-settings.js +44 -0
- package/dist/settings/widgets/font-settings/index.js +3 -0
- package/dist/settings/widgets/group-by.js +160 -0
- package/dist/settings/widgets/label-color.js +30 -0
- package/dist/settings/widgets/min-max-setting.js +52 -0
- package/dist/settings/widgets/mininum-slice-percent.js +63 -0
- package/dist/settings/widgets/numeric-summary-item.js +90 -0
- package/dist/settings/widgets/select-table/index.css +0 -0
- package/dist/settings/widgets/select-table/index.js +38 -0
- package/dist/settings/widgets/stack.js +50 -0
- package/dist/settings/widgets/summary-method-setting.js +66 -0
- package/dist/settings/widgets/summary-settings.js +411 -0
- package/dist/settings/widgets/switch/index.css +37 -0
- package/dist/settings/widgets/switch/index.js +24 -0
- package/dist/settings/widgets/text-horizontal-settings.js +25 -0
- package/dist/settings/widgets/time-picker.js +173 -0
- package/dist/settings/widgets/title-settings/index.js +60 -0
- package/dist/settings/widgets/title-settings/title-text.js +25 -0
- package/dist/settings/widgets/x-axios.js +0 -0
- package/dist/settings/widgets/y-axis-group-settings.js +438 -0
- package/dist/utils/cell-format-utils.js +42 -0
- package/dist/utils/chart-data-sql.js +606 -0
- package/dist/utils/chart-utils.js +1800 -0
- package/dist/utils/chart.js +6 -0
- package/dist/utils/collaborator-utils.js +39 -0
- package/dist/utils/column-2-sql-column.js +551 -0
- package/dist/utils/column-utils.js +208 -0
- package/dist/utils/custom-g2.js +612 -0
- package/dist/utils/date-translate.js +66 -0
- package/dist/utils/index.js +48 -0
- package/dist/utils/key-generator.js +13 -0
- package/dist/utils/object-utils.js +45 -0
- package/dist/utils/options-utils.js +60 -0
- package/dist/view/index.css +53 -0
- package/dist/view/index.js +189 -0
- package/dist/view/title/index.css +3 -0
- package/dist/view/title/index.js +46 -0
- package/dist/view/wrapper/area.js +150 -0
- package/dist/view/wrapper/bar-group.js +148 -0
- package/dist/view/wrapper/bar.js +138 -0
- package/dist/view/wrapper/basic-number-card.js +127 -0
- package/dist/view/wrapper/chart-component.js +261 -0
- package/dist/view/wrapper/combination.js +399 -0
- package/dist/view/wrapper/dashboard.js +164 -0
- package/dist/view/wrapper/horizontal-bar-group.js +149 -0
- package/dist/view/wrapper/horizontal-bar.js +140 -0
- package/dist/view/wrapper/horizontal-component.js +78 -0
- package/dist/view/wrapper/index.js +200 -0
- package/dist/view/wrapper/line-group.js +145 -0
- package/dist/view/wrapper/line.js +157 -0
- package/dist/view/wrapper/pie.js +185 -0
- package/dist/view/wrapper/ring.js +264 -0
- package/dist/view/wrapper/table/index.css +103 -0
- package/dist/view/wrapper/table/index.js +31 -0
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +144 -0
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +198 -0
- package/dist/view/wrapper/table/pivot-table-display-name.js +247 -0
- package/dist/view/wrapper/table/two-dimension-table.js +249 -0
- package/dist/view/wrapper/treemap.js +186 -0
- package/package.json +151 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import ObjectUtils from './object-utils';
|
|
2
|
+
import chartColumn2SqlColumn, { summaryMethodColumn2SqlColumn } from './column-2-sql-column';
|
|
3
|
+
import ChartUtils from './chart-utils';
|
|
4
|
+
import { GENERIC_KEY_2_SIMILAR_KEYS } from '../constants';
|
|
5
|
+
import ChartDataSQL from './chart-data-sql';
|
|
6
|
+
export { generatorCommonOptions } from './options-utils';
|
|
7
|
+
export { getColumnOptions } from 'dtable-utils';
|
|
8
|
+
export { getClientFormulaDisplayString, getClientLinkDisplayString } from './cell-format-utils';
|
|
9
|
+
export { generateChartConfig } from './chart';
|
|
10
|
+
export { getKnownCollaboratorByEmail, getKnownCollaboratorsByEmails, generateDefaultUser } from './collaborator-utils';
|
|
11
|
+
export { getDateColumnFormat, isCheckboxColumn, getColumnByKey, getColumnByName, getColumnByType, getColumnByIndex, isNameColumn, isUrlColumn, getLinkColumns, calculateFormulaRows, handleCascadeColumn, isFrozen, findLastFrozenColumnIndex, isStatisticMapColumn, isStatisticWorldMapColumn, isStatisticMirrorColumn } from './column-utils';
|
|
12
|
+
export { generatorKey } from './key-generator';
|
|
13
|
+
export { translateCalendar } from './date-translate';
|
|
14
|
+
export const isBoolean = val => {
|
|
15
|
+
return typeof val === 'boolean';
|
|
16
|
+
};
|
|
17
|
+
export const getSimilarKeys = genericKey => {
|
|
18
|
+
const similarKeys = GENERIC_KEY_2_SIMILAR_KEYS[genericKey];
|
|
19
|
+
return similarKeys || [];
|
|
20
|
+
};
|
|
21
|
+
export const getChartConfigValueFromKeys = (keys, object) => {
|
|
22
|
+
// eslint-disable-next-line
|
|
23
|
+
const existKey = keys.find(key => ObjectUtils.hasOwnProperty(object, key));
|
|
24
|
+
return existKey ? object[existKey] : null;
|
|
25
|
+
};
|
|
26
|
+
export const getChartConfigValueByKey = (key, object) => {
|
|
27
|
+
const similarKeys = getSimilarKeys(key);
|
|
28
|
+
if (!Array.isArray(similarKeys) || similarKeys.length === 0) {
|
|
29
|
+
// get value by the given 'genericKey' directly when has no similar keys.
|
|
30
|
+
// eslint-disable-next-line
|
|
31
|
+
return ObjectUtils.hasOwnProperty(object, key) ? object[key] : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// try to get value from the similar keys
|
|
35
|
+
return getChartConfigValueFromKeys(similarKeys, object);
|
|
36
|
+
};
|
|
37
|
+
export const eventStopPropagation = event => {
|
|
38
|
+
if (!event) return;
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
event.preventDefault && event.preventDefault();
|
|
41
|
+
event.nativeEvent && event.nativeEvent.stopImmediatePropagation && event.nativeEvent.stopImmediatePropagation();
|
|
42
|
+
};
|
|
43
|
+
export const getEventClassName = e => {
|
|
44
|
+
// svg mouseEvent event.target.className is an object
|
|
45
|
+
if (!e || !e.target) return '';
|
|
46
|
+
return e.target.getAttribute('class') || '';
|
|
47
|
+
};
|
|
48
|
+
export { ObjectUtils, chartColumn2SqlColumn, summaryMethodColumn2SqlColumn, ChartUtils, ChartDataSQL };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const generatorBase64Code = function () {
|
|
2
|
+
let keyLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
3
|
+
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789';
|
|
4
|
+
let key = '';
|
|
5
|
+
for (let i = 0; i < keyLength; i++) {
|
|
6
|
+
key += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
7
|
+
}
|
|
8
|
+
return key;
|
|
9
|
+
};
|
|
10
|
+
export const generatorKey = function () {
|
|
11
|
+
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
12
|
+
return generatorBase64Code(length);
|
|
13
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class ObjectUtils {
|
|
2
|
+
static getDataType(data) {
|
|
3
|
+
let type = typeof data;
|
|
4
|
+
if (type !== 'object') {
|
|
5
|
+
return type;
|
|
6
|
+
}
|
|
7
|
+
return Object.prototype.toString.call(data).replace(/^\[object (\S+)\]$/, '$1');
|
|
8
|
+
}
|
|
9
|
+
static iterable(data) {
|
|
10
|
+
return ['Object', 'Array'].includes(this.getDataType(data));
|
|
11
|
+
}
|
|
12
|
+
static isObjectChanged(source, comparison) {
|
|
13
|
+
if (!this.iterable(source)) {
|
|
14
|
+
throw new Error("source should be a Object or Array , but got ".concat(this.getDataType(source)));
|
|
15
|
+
}
|
|
16
|
+
if (this.getDataType(source) !== this.getDataType(comparison)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const sourceKeys = Object.keys(source);
|
|
20
|
+
const comparisonKeys = Object.keys({
|
|
21
|
+
...source,
|
|
22
|
+
...comparison
|
|
23
|
+
});
|
|
24
|
+
if (sourceKeys.length !== comparisonKeys.length) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return comparisonKeys.some(key => {
|
|
28
|
+
if (this.iterable(source[key])) {
|
|
29
|
+
return this.isObjectChanged(source[key], comparison[key]);
|
|
30
|
+
} else {
|
|
31
|
+
return source[key] !== comparison[key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
static isSameObject(source, comparison) {
|
|
36
|
+
if (!source || !comparison) return false;
|
|
37
|
+
return !this.isObjectChanged(source, comparison);
|
|
38
|
+
}
|
|
39
|
+
static hasOwnProperty(obj, propertyKey) {
|
|
40
|
+
if (!obj || !propertyKey) return false;
|
|
41
|
+
// eslint-disable-next-line
|
|
42
|
+
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export default ObjectUtils;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
const generatorCommonOption = function () {
|
|
4
|
+
let option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5
|
+
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
6
|
+
let selectValue = arguments.length > 2 ? arguments[2] : undefined;
|
|
7
|
+
let type = Object.prototype.toString.call(option);
|
|
8
|
+
let validOption = option,
|
|
9
|
+
isSelectOption;
|
|
10
|
+
if (type !== '[object Object]') {
|
|
11
|
+
isSelectOption = option === selectValue;
|
|
12
|
+
validOption = {
|
|
13
|
+
name: String(option),
|
|
14
|
+
value: option
|
|
15
|
+
};
|
|
16
|
+
} else {
|
|
17
|
+
isSelectOption = option.name === selectValue;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
name,
|
|
21
|
+
displayName,
|
|
22
|
+
disabled,
|
|
23
|
+
type: optionType,
|
|
24
|
+
isDuplicate
|
|
25
|
+
} = validOption;
|
|
26
|
+
if (optionType === 'divide') {
|
|
27
|
+
return {
|
|
28
|
+
value: validOption,
|
|
29
|
+
key: "divide-".concat(index),
|
|
30
|
+
type: optionType,
|
|
31
|
+
name: '',
|
|
32
|
+
isDuplicate: false,
|
|
33
|
+
label: /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: "select-option-divide"
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
value: validOption,
|
|
40
|
+
key: "".concat(name, "-").concat(index),
|
|
41
|
+
type: optionType,
|
|
42
|
+
name,
|
|
43
|
+
isDuplicate,
|
|
44
|
+
label: /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: classnames('common-select-option', {
|
|
46
|
+
'disabled': disabled
|
|
47
|
+
})
|
|
48
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: "common-select-option-icon"
|
|
50
|
+
}, isSelectOption && /*#__PURE__*/React.createElement("i", {
|
|
51
|
+
className: "dtable-font dtable-icon-check-mark"
|
|
52
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "common-select-option-name"
|
|
54
|
+
}, displayName || name))
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export const generatorCommonOptions = (options, selectValue) => {
|
|
58
|
+
if (!Array.isArray(options)) return [];
|
|
59
|
+
return options.map((option, index) => generatorCommonOption(option, index, selectValue));
|
|
60
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.sea-chart-formatter {
|
|
2
|
+
height: 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sea-chart-formatter-tip {
|
|
10
|
+
background-color: #F5F5F5;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sea-chart-formatter.error {
|
|
15
|
+
color: red;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sea-chart-formatter .sea-chart-formatter-container {
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sea-chart-formatter .sea-chart-table-formatter-container {
|
|
27
|
+
overflow: scroll;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sea-chart-formatter .sea-chart-container {
|
|
31
|
+
flex: 1;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sea-chart-formatter .sea-chart-container.show-x-axis-label,
|
|
36
|
+
.sea-chart-formatter .sea-chart-container.show-horizontal-axis-label {
|
|
37
|
+
padding-bottom: 20px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sea-chart-formatter .sea-chart-container.show-y-axis-label,
|
|
41
|
+
.sea-chart-formatter .sea-chart-container.show-y-axis-left-label,
|
|
42
|
+
.sea-chart-formatter .sea-chart-container.show-vertical-axis-label {
|
|
43
|
+
padding-left: 20px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sea-chart-formatter .sea-chart-container.show-y-axis-right-label {
|
|
47
|
+
padding-right: 20px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sea-chart-formatter .g2-html-annotation {
|
|
51
|
+
transform: translate(-50%, -50%);
|
|
52
|
+
width: fit-content;
|
|
53
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import shallowEqual from 'shallowequal';
|
|
4
|
+
import intl from '../intl';
|
|
5
|
+
import { Loading } from '../components';
|
|
6
|
+
import { ChartUtils } from '../utils';
|
|
7
|
+
import Context from '../context';
|
|
8
|
+
import Title from './title';
|
|
9
|
+
import Wrapper from './wrapper';
|
|
10
|
+
import './index.css';
|
|
11
|
+
class View extends React.PureComponent {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
var _this;
|
|
14
|
+
super(props);
|
|
15
|
+
_this = this;
|
|
16
|
+
this.callback = (errorMessage, tipMessage, data) => {
|
|
17
|
+
if (errorMessage) {
|
|
18
|
+
this.setState({
|
|
19
|
+
errorMessage,
|
|
20
|
+
tipMessage: '',
|
|
21
|
+
data: null,
|
|
22
|
+
isCalculated: true
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (tipMessage) {
|
|
27
|
+
this.setState({
|
|
28
|
+
errorMessage: '',
|
|
29
|
+
tipMessage,
|
|
30
|
+
data: null,
|
|
31
|
+
isCalculated: true
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!data) {
|
|
36
|
+
this.setState({
|
|
37
|
+
errorMessage: '',
|
|
38
|
+
tipMessage: 'There_are_no_statistic_results_yet',
|
|
39
|
+
data: null,
|
|
40
|
+
isCalculated: true
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.setState({
|
|
45
|
+
errorMessage: '',
|
|
46
|
+
tipMessage: '',
|
|
47
|
+
data,
|
|
48
|
+
isCalculated: true
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
this.calculateStatistic = function () {
|
|
52
|
+
let isNeedRequestData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
53
|
+
const {
|
|
54
|
+
tables,
|
|
55
|
+
chart,
|
|
56
|
+
dataAPI,
|
|
57
|
+
isStatisticalData
|
|
58
|
+
} = _this.props;
|
|
59
|
+
const {
|
|
60
|
+
data
|
|
61
|
+
} = _this.state;
|
|
62
|
+
if (!isNeedRequestData) {
|
|
63
|
+
ChartUtils.calculateStaticChart(tables, chart, data, _this.callback);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
ChartUtils.calculateChart(chart, dataAPI, tables, _this.callback, isStatisticalData);
|
|
67
|
+
};
|
|
68
|
+
this.state = {
|
|
69
|
+
isCalculated: false,
|
|
70
|
+
data: null,
|
|
71
|
+
errorMessage: '',
|
|
72
|
+
tipMessage: ''
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
componentDidMount() {
|
|
76
|
+
var _window$seaChart, _window$seaChart2;
|
|
77
|
+
const {
|
|
78
|
+
usersAPI,
|
|
79
|
+
context,
|
|
80
|
+
config,
|
|
81
|
+
eventBus,
|
|
82
|
+
collaborators
|
|
83
|
+
} = this.props;
|
|
84
|
+
if (!window.seaChart) {
|
|
85
|
+
window.seaChart = {};
|
|
86
|
+
}
|
|
87
|
+
if (!((_window$seaChart = window.seaChart) === null || _window$seaChart === void 0 ? void 0 : _window$seaChart.queryUsers)) {
|
|
88
|
+
window.seaChart.queryUsers = usersAPI;
|
|
89
|
+
}
|
|
90
|
+
if (!((_window$seaChart2 = window.seaChart) === null || _window$seaChart2 === void 0 ? void 0 : _window$seaChart2.context)) {
|
|
91
|
+
const validContext = context || new Context(eventBus, config);
|
|
92
|
+
Array.isArray(collaborators) && collaborators.forEach(collaborator => {
|
|
93
|
+
validContext.onlyUpdateCollaboratorsCache && validContext.onlyUpdateCollaboratorsCache(collaborator.email, collaborator);
|
|
94
|
+
});
|
|
95
|
+
window.seaChart.context = validContext;
|
|
96
|
+
const lang = validContext.getSetting('lang') || 'zh-cn';
|
|
97
|
+
intl.setLang(lang);
|
|
98
|
+
}
|
|
99
|
+
this.calculateStatistic();
|
|
100
|
+
}
|
|
101
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
102
|
+
const {
|
|
103
|
+
chart: oldChart
|
|
104
|
+
} = this.props;
|
|
105
|
+
const {
|
|
106
|
+
chart
|
|
107
|
+
} = nextProps;
|
|
108
|
+
if (shallowEqual(chart, oldChart)) return;
|
|
109
|
+
this.setState({
|
|
110
|
+
isCalculated: false
|
|
111
|
+
}, () => {
|
|
112
|
+
if (ChartUtils.isChartTypeChange(chart, oldChart)) {
|
|
113
|
+
this.calculateStatistic();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (ChartUtils.isChartStyleChange(chart, oldChart)) {
|
|
117
|
+
this.setState({
|
|
118
|
+
isCalculated: true
|
|
119
|
+
});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (ChartUtils.isChartSortChange(chart, oldChart)) {
|
|
123
|
+
this.calculateStatistic(false);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.calculateStatistic();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
render() {
|
|
130
|
+
var _chart$config;
|
|
131
|
+
const {
|
|
132
|
+
chart,
|
|
133
|
+
className,
|
|
134
|
+
tables,
|
|
135
|
+
canvasStyle
|
|
136
|
+
} = this.props;
|
|
137
|
+
const {
|
|
138
|
+
data,
|
|
139
|
+
isCalculated,
|
|
140
|
+
errorMessage,
|
|
141
|
+
tipMessage
|
|
142
|
+
} = this.state;
|
|
143
|
+
const validClassName = classnames('sea-chart-formatter', className);
|
|
144
|
+
const tipBackgroundColorClassName = 'sea-chart-formatter-tip';
|
|
145
|
+
if (!isCalculated) {
|
|
146
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: classnames('loading', validClassName)
|
|
148
|
+
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
149
|
+
}
|
|
150
|
+
if (errorMessage) {
|
|
151
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
153
|
+
}, intl.get(errorMessage));
|
|
154
|
+
}
|
|
155
|
+
if (tipMessage) {
|
|
156
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
158
|
+
}, intl.get(tipMessage));
|
|
159
|
+
}
|
|
160
|
+
if (ChartUtils.imEmptyChartResult(data)) {
|
|
161
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
162
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
163
|
+
}, intl.get('There_are_no_statistic_results_yet'));
|
|
164
|
+
}
|
|
165
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
className: validClassName
|
|
167
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
168
|
+
className: classnames('sea-chart-formatter-container', "sea-chart-".concat(chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type, "-formatter-container"))
|
|
169
|
+
}, /*#__PURE__*/React.createElement(Title, {
|
|
170
|
+
chart: chart
|
|
171
|
+
}), /*#__PURE__*/React.createElement(Wrapper, {
|
|
172
|
+
chart: chart,
|
|
173
|
+
data: data,
|
|
174
|
+
tables: tables,
|
|
175
|
+
canvasStyle: canvasStyle
|
|
176
|
+
})));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
View.defaultProps = {
|
|
180
|
+
isStatisticalData: true,
|
|
181
|
+
canvasStyle: {},
|
|
182
|
+
tables: [],
|
|
183
|
+
chart: {
|
|
184
|
+
id: '',
|
|
185
|
+
config: {},
|
|
186
|
+
style_config: {}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
export default View;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { isNumber } from 'dtable-utils';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { HORIZONTAL_ALIGNS, HORIZONTAL_ALIGN, DEFAULT_CHART_FONT_WEIGHT, DEFAULT_CHART_TITLE_FONT_SIZE, CHART_SUPPORT_FONT_WEIGHTS, SUPPORT_TITLE_CHART_TYPES } from '../../constants';
|
|
5
|
+
import './index.css';
|
|
6
|
+
const Title = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
chart,
|
|
9
|
+
className
|
|
10
|
+
} = _ref;
|
|
11
|
+
const getTitleStyle = useCallback(() => {
|
|
12
|
+
let style = {
|
|
13
|
+
fontSize: "".concat(DEFAULT_CHART_TITLE_FONT_SIZE, "px"),
|
|
14
|
+
fontWeight: DEFAULT_CHART_FONT_WEIGHT
|
|
15
|
+
};
|
|
16
|
+
if (!chart || !chart.style_config || !chart.style_config.title) {
|
|
17
|
+
return style;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
font_size,
|
|
21
|
+
font_weight,
|
|
22
|
+
horizontal_align
|
|
23
|
+
} = chart.style_config.title;
|
|
24
|
+
if (isNumber(font_size)) {
|
|
25
|
+
style.fontSize = font_size < 0 ? 0 : "".concat(font_size, "px");
|
|
26
|
+
}
|
|
27
|
+
if (CHART_SUPPORT_FONT_WEIGHTS.includes(font_weight)) {
|
|
28
|
+
style.fontWeight = font_weight;
|
|
29
|
+
}
|
|
30
|
+
style.textAlign = horizontal_align && HORIZONTAL_ALIGNS.includes(horizontal_align) ? horizontal_align : HORIZONTAL_ALIGN.LEFT;
|
|
31
|
+
return style;
|
|
32
|
+
}, [chart]);
|
|
33
|
+
if (!chart) return null;
|
|
34
|
+
const {
|
|
35
|
+
type: chartType
|
|
36
|
+
} = chart.config;
|
|
37
|
+
const title = chart.style_config && chart.style_config.title;
|
|
38
|
+
const text = title && title.text;
|
|
39
|
+
if (!SUPPORT_TITLE_CHART_TYPES.includes(chartType) || !text) return null;
|
|
40
|
+
const style = getTitleStyle();
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: classnames('sea-chart-title', className),
|
|
43
|
+
style: style
|
|
44
|
+
}, text);
|
|
45
|
+
};
|
|
46
|
+
export default Title;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW } from '../../constants';
|
|
5
|
+
import intl from '../../intl';
|
|
6
|
+
import { ChartUtils } from '../../utils';
|
|
7
|
+
import ChartComponent from './chart-component';
|
|
8
|
+
class Area extends ChartComponent {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.createChart = () => {
|
|
12
|
+
const {
|
|
13
|
+
chart
|
|
14
|
+
} = this.props;
|
|
15
|
+
const {
|
|
16
|
+
y_axis_show_value
|
|
17
|
+
} = chart.config;
|
|
18
|
+
const appendPadding = [y_axis_show_value ? 17 : 0, 0, 0, 0];
|
|
19
|
+
this.initChart(this.container, {
|
|
20
|
+
appendPadding
|
|
21
|
+
});
|
|
22
|
+
this.chart.on('interval:click', e => {
|
|
23
|
+
this.props.toggleRecords(e.data.data);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.clearChart = () => {
|
|
27
|
+
this.chart.annotation().clear(true);
|
|
28
|
+
this.chart.clear(true);
|
|
29
|
+
};
|
|
30
|
+
this.drawChart = () => {
|
|
31
|
+
let {
|
|
32
|
+
result: data
|
|
33
|
+
} = this.props;
|
|
34
|
+
data = ChartUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
35
|
+
if (!Array.isArray(data)) return;
|
|
36
|
+
this.loadData(data);
|
|
37
|
+
this.draw(data);
|
|
38
|
+
this.chart.render();
|
|
39
|
+
};
|
|
40
|
+
this.draw = data => {
|
|
41
|
+
const {
|
|
42
|
+
chart,
|
|
43
|
+
summaryColumn,
|
|
44
|
+
theme
|
|
45
|
+
} = this.props;
|
|
46
|
+
const {
|
|
47
|
+
y_axis_summary_type,
|
|
48
|
+
y_axis_summary_method,
|
|
49
|
+
y_axis_label_color,
|
|
50
|
+
y_axis_show_value,
|
|
51
|
+
label_font_size
|
|
52
|
+
} = chart.config;
|
|
53
|
+
const chartBarColor = y_axis_label_color || '#2a67d1';
|
|
54
|
+
this.drawLabels(data);
|
|
55
|
+
|
|
56
|
+
// set Coord type
|
|
57
|
+
this.chart.coordinate('rect');
|
|
58
|
+
this.autoAdjustDataOptions(chart, data, summaryColumn);
|
|
59
|
+
this.chart.line().position('name*value').color(chartBarColor);
|
|
60
|
+
this.chart.point().label(y_axis_show_value ? 'value' : false, {
|
|
61
|
+
style: {
|
|
62
|
+
fontSize: ChartUtils.getLabelFontSize(label_font_size),
|
|
63
|
+
fill: '#6e6e6e'
|
|
64
|
+
}
|
|
65
|
+
}).position('name*value').color(chartBarColor).tooltip('name*value', (name, value) => {
|
|
66
|
+
return {
|
|
67
|
+
title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
|
|
68
|
+
value: ChartUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
69
|
+
name
|
|
70
|
+
};
|
|
71
|
+
}).shape('circle').style({
|
|
72
|
+
lineWidth: 1,
|
|
73
|
+
stroke: '#fff'
|
|
74
|
+
}).state({
|
|
75
|
+
active: {
|
|
76
|
+
style: {
|
|
77
|
+
stroke: null
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
this.chart.area().position('name*value').color(chartBarColor).tooltip('name*value', (name, value) => {
|
|
82
|
+
return {
|
|
83
|
+
name,
|
|
84
|
+
value: ChartUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
85
|
+
title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method])
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
this.chart.tooltip({
|
|
89
|
+
showTitle: true,
|
|
90
|
+
showMarkers: false,
|
|
91
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
92
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
93
|
+
domStyles: {
|
|
94
|
+
'g2-tooltip': {
|
|
95
|
+
borderRadius: '2px',
|
|
96
|
+
backgroundColor: '#fff',
|
|
97
|
+
padding: '10px'
|
|
98
|
+
},
|
|
99
|
+
'tooltip-item': {
|
|
100
|
+
marginTop: '5px'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
105
|
+
this.setValueLabel(theme);
|
|
106
|
+
this.chart.interaction('active-region');
|
|
107
|
+
};
|
|
108
|
+
this.chart = null;
|
|
109
|
+
}
|
|
110
|
+
componentDidMount() {
|
|
111
|
+
this.createChart();
|
|
112
|
+
this.drawChart();
|
|
113
|
+
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
114
|
+
}
|
|
115
|
+
componentDidUpdate(prevProps) {
|
|
116
|
+
if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
117
|
+
this.chart && this.chart.destroy();
|
|
118
|
+
this.createChart();
|
|
119
|
+
this.drawChart();
|
|
120
|
+
this.renderAxisLabel(prevProps.chart, prevProps.tables);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
componentWillUnmount() {
|
|
124
|
+
this.chart && this.chart.destroy();
|
|
125
|
+
}
|
|
126
|
+
render() {
|
|
127
|
+
const {
|
|
128
|
+
chart
|
|
129
|
+
} = this.props;
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: classnames('sea-chart-container w-100', {
|
|
132
|
+
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
133
|
+
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
134
|
+
}),
|
|
135
|
+
ref: ref => this.container = ref
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
Area.propTypes = {
|
|
140
|
+
canvasStyle: PropTypes.object,
|
|
141
|
+
chart: PropTypes.object,
|
|
142
|
+
groupbyColumn: PropTypes.object,
|
|
143
|
+
columnGroupbyColumn: PropTypes.object,
|
|
144
|
+
summaryColumn: PropTypes.object,
|
|
145
|
+
result: PropTypes.array,
|
|
146
|
+
tables: PropTypes.array,
|
|
147
|
+
theme: PropTypes.object,
|
|
148
|
+
toggleRecords: PropTypes.func
|
|
149
|
+
};
|
|
150
|
+
export default Area;
|