sea-chart 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -1
- package/dist/api/index.js +101 -0
- package/{lib → dist}/components/collaborator/index.js +8 -6
- package/{lib → dist}/components/icon/index.css +1 -1
- package/{lib → dist}/components/icon/index.js +7 -5
- package/dist/components/index.js +8 -0
- package/{lib → dist}/components/loading/index.js +4 -2
- package/dist/components/number-input/index.js +31 -0
- package/{lib → dist}/components/pixel-editor/index.css +4 -4
- package/{lib → dist}/components/pixel-editor/index.js +11 -15
- package/{lib → dist}/components/select-group/index.css +10 -10
- 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 +117 -0
- package/{lib → dist}/constants/geolocation.js +3 -3
- package/dist/constants/index.js +184 -0
- package/{lib → dist}/constants/model.js +25 -5
- 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 +83 -0
- package/dist/editor/index.js +41 -0
- package/dist/index.js +9 -0
- package/dist/intl.js +37 -0
- package/dist/locale/index.js +18 -0
- package/{lib → dist}/locale/lang/de.js +1 -1
- package/{lib → dist}/locale/lang/en.js +1 -1
- package/{lib → dist}/locale/lang/es.js +1 -1
- package/{lib → dist}/locale/lang/fr.js +1 -1
- package/{lib → dist}/locale/lang/pt.js +1 -1
- package/{lib → dist}/locale/lang/ru.js +1 -1
- package/{lib → dist}/locale/lang/zh_CN.js +1 -1
- 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/{lib/components → dist}/settings/advance-bar-settings/data-settings.js +68 -45
- package/dist/settings/advance-bar-settings/style-settings.js +161 -0
- package/{lib/components → dist}/settings/bar-settings/data-settings.js +76 -51
- 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/style-settings.js +42 -0
- package/dist/settings/combination-settings/data-settings.js +279 -0
- package/dist/settings/combination-settings/style-settings.js +174 -0
- package/dist/settings/dashboard-settings/data-settings.js +179 -0
- package/{lib/components → dist}/settings/data-settings.js +28 -22
- package/dist/settings/horizontal-bar-settings/data-settings.js +55 -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/{lib/components → dist}/settings/pie-settings/data-settings.js +67 -44
- package/{lib/components → dist}/settings/pie-settings/style-settings.js +67 -49
- package/dist/settings/style-settings.js +118 -0
- package/{lib/components → dist}/settings/table-settings/data-settings.js +269 -208
- package/{lib/components → dist}/settings/time-comparison-settings/data-settings.js +82 -67
- 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/{lib/components/settings/widgets/statistic-type → dist/settings/widgets/chart-type}/index.css +5 -5
- package/dist/settings/widgets/chart-type/index.js +59 -0
- package/{lib/components → dist}/settings/widgets/common-data-settings.js +24 -18
- package/dist/settings/widgets/data-filter/index.css +17 -0
- package/{lib/components → dist}/settings/widgets/data-filter/index.js +51 -37
- 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/{lib/components → dist}/settings/widgets/display-values-settings/index.js +19 -14
- package/{lib/components → dist}/settings/widgets/divider/index.css +1 -1
- package/dist/settings/widgets/divider/index.js +12 -0
- package/{lib/components → dist}/settings/widgets/font-settings/font-size-settings.js +14 -12
- package/{lib/components → dist}/settings/widgets/font-settings/font-weight-settings.js +14 -16
- package/dist/settings/widgets/group-by.js +160 -0
- package/{lib/components → dist}/settings/widgets/label-color.js +10 -10
- 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.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/{lib/components → dist}/settings/widgets/switch/index.js +11 -8
- package/{lib/components → dist}/settings/widgets/text-horizontal-settings.js +12 -10
- package/dist/settings/widgets/time-picker.js +174 -0
- package/{lib/components → dist}/settings/widgets/title-settings/index.js +15 -13
- 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 +1803 -0
- package/dist/utils/chart.js +6 -0
- package/dist/utils/collaborator-manager.js +24 -0
- package/dist/utils/collaborator-utils.js +40 -0
- package/dist/utils/column-2-sql-column.js +551 -0
- package/dist/utils/column-utils.js +208 -0
- package/{lib → dist}/utils/custom-g2.js +11 -11
- package/{lib → dist}/utils/date-translate.js +11 -11
- package/dist/utils/index.js +48 -0
- package/dist/utils/key-generator.js +13 -0
- package/dist/utils/object-utils.js +45 -0
- package/{lib → dist}/utils/options-utils.js +17 -18
- package/dist/view/index.css +53 -0
- package/dist/view/index.js +169 -0
- package/{lib/layout → dist/view}/title/index.css +1 -1
- 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/{lib/components/formatter → dist/view/wrapper}/index.js +90 -71
- 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/{lib/components/formatter → dist/view/wrapper}/table/index.css +18 -18
- 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 +248 -0
- package/dist/view/wrapper/table/two-dimension-table.js +249 -0
- package/dist/view/wrapper/treemap.js +186 -0
- package/package.json +91 -100
- package/lib/components/formatter/area.js +0 -162
- package/lib/components/formatter/bar-group.js +0 -160
- package/lib/components/formatter/bar.js +0 -150
- package/lib/components/formatter/basic-number-card.js +0 -138
- package/lib/components/formatter/chart-component.js +0 -266
- package/lib/components/formatter/combination.js +0 -407
- package/lib/components/formatter/dashboard.js +0 -182
- package/lib/components/formatter/horizontal-bar-group.js +0 -161
- package/lib/components/formatter/horizontal-bar.js +0 -152
- package/lib/components/formatter/horizontal-component.js +0 -91
- package/lib/components/formatter/line-group.js +0 -157
- package/lib/components/formatter/line.js +0 -170
- package/lib/components/formatter/pie.js +0 -201
- package/lib/components/formatter/ring.js +0 -277
- package/lib/components/formatter/table/index.js +0 -42
- package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +0 -145
- package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +0 -193
- package/lib/components/formatter/table/pivot-table-display-name.js +0 -249
- package/lib/components/formatter/table/two-dimension-table.js +0 -241
- package/lib/components/formatter/treemap.js +0 -213
- package/lib/components/index.js +0 -5
- package/lib/components/number-input/index.js +0 -31
- package/lib/components/select-group/index.js +0 -63
- package/lib/components/settings/advance-bar-settings/style-settings.js +0 -149
- package/lib/components/settings/bar-settings/style-settings.js +0 -163
- package/lib/components/settings/basic-number-card/data-settings.js +0 -121
- package/lib/components/settings/basic-number-card/style-settings.js +0 -42
- package/lib/components/settings/combination-settings/data-settings.js +0 -256
- package/lib/components/settings/combination-settings/style-settings.js +0 -183
- package/lib/components/settings/dashboard-settings/data-settings.js +0 -167
- package/lib/components/settings/horizontal-bar-settings/data-settings.js +0 -45
- package/lib/components/settings/horizontal-bar-settings/style-settings.js +0 -38
- package/lib/components/settings/index.css +0 -73
- package/lib/components/settings/index.js +0 -74
- package/lib/components/settings/style-settings.js +0 -100
- package/lib/components/settings/time-comparison-settings/style-settings.js +0 -191
- package/lib/components/settings/widgets/basic-summary/index.css +0 -12
- package/lib/components/settings/widgets/basic-summary/index.js +0 -173
- package/lib/components/settings/widgets/data-filter/index.css +0 -17
- package/lib/components/settings/widgets/data-sort.js +0 -38
- package/lib/components/settings/widgets/date-summary-item.js +0 -126
- package/lib/components/settings/widgets/display-values-settings/index.css +0 -13
- package/lib/components/settings/widgets/divider/index.js +0 -10
- package/lib/components/settings/widgets/group-by.js +0 -168
- package/lib/components/settings/widgets/min-max-setting.js +0 -64
- package/lib/components/settings/widgets/mininum-slice-percent.js +0 -72
- package/lib/components/settings/widgets/numeric-summary-item.js +0 -109
- package/lib/components/settings/widgets/select-table/index.js +0 -49
- package/lib/components/settings/widgets/stack.js +0 -58
- package/lib/components/settings/widgets/statistic-type/index.js +0 -54
- package/lib/components/settings/widgets/summary-method-setting.js +0 -80
- package/lib/components/settings/widgets/summary-settings.js +0 -394
- package/lib/components/settings/widgets/switch/index.css +0 -37
- package/lib/components/settings/widgets/time-picker.js +0 -182
- package/lib/components/settings/widgets/title-settings/title-text.js +0 -31
- package/lib/components/settings/widgets/y-axis-group-settings.js +0 -399
- package/lib/components/types-dialog/index.css +0 -97
- package/lib/components/types-dialog/index.js +0 -127
- package/lib/constants/index.js +0 -164
- package/lib/constants/style.js +0 -13
- package/lib/constants/type-image.js +0 -32
- package/lib/constants/type.js +0 -97
- package/lib/context.js +0 -49
- package/lib/index.js +0 -6
- package/lib/intl.js +0 -37
- package/lib/layout/index.js +0 -4
- package/lib/layout/statistic/index.css +0 -53
- package/lib/layout/statistic/index.js +0 -190
- package/lib/layout/title/index.js +0 -41
- package/lib/locale/index.js +0 -11
- package/lib/model/area-group.js +0 -51
- package/lib/model/area.js +0 -42
- package/lib/model/bar-group.js +0 -54
- package/lib/model/bar-stack.js +0 -51
- package/lib/model/bar.js +0 -48
- package/lib/model/base-model.js +0 -11
- package/lib/model/basic-number-card.js +0 -32
- package/lib/model/combination.js +0 -48
- package/lib/model/compare-bar.js +0 -49
- package/lib/model/completeness-group.js +0 -34
- package/lib/model/completeness.js +0 -28
- package/lib/model/dashboard.js +0 -26
- package/lib/model/generic-model.js +0 -235
- package/lib/model/heat-map.js +0 -33
- package/lib/model/horizontal-bar.js +0 -48
- package/lib/model/horizontal-group-bar.js +0 -53
- package/lib/model/index.js +0 -36
- package/lib/model/line-group.js +0 -54
- package/lib/model/line.js +0 -48
- package/lib/model/map-bubble.js +0 -37
- package/lib/model/map.js +0 -37
- package/lib/model/mirror.js +0 -36
- package/lib/model/pie.js +0 -36
- package/lib/model/ring.js +0 -36
- package/lib/model/scatter.js +0 -29
- package/lib/model/stacked-horizontal-bar.js +0 -42
- package/lib/model/statistic.js +0 -22
- package/lib/model/table.js +0 -33
- package/lib/model/tree-map.js +0 -30
- package/lib/model/trend.js +0 -34
- package/lib/model/user.js +0 -22
- package/lib/model/world-map-bubble.js +0 -36
- package/lib/model/world-map.js +0 -36
- package/lib/utils/cell-format-utils.js +0 -41
- package/lib/utils/chart.js +0 -6
- package/lib/utils/collaborator-utils.js +0 -40
- package/lib/utils/column-utils.js +0 -247
- package/lib/utils/data-filter/filter-item-utils.js +0 -80
- package/lib/utils/data-filter/filters-utils.js +0 -406
- package/lib/utils/data-filter/index.js +0 -3
- package/lib/utils/index.js +0 -50
- package/lib/utils/key-generator.js +0 -13
- package/lib/utils/object-utils.js +0 -61
- package/lib/utils/statistic-column-2-sql-column-utils.js +0 -499
- package/lib/utils/statistic-utils.js +0 -1685
- /package/{lib → dist}/assets/icons/area-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/bar-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/card.svg +0 -0
- /package/{lib → dist}/assets/icons/combination-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/dtable-logo.svg +0 -0
- /package/{lib → dist}/assets/icons/facet-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/gauge.svg +0 -0
- /package/{lib → dist}/assets/icons/heat-map.svg +0 -0
- /package/{lib → dist}/assets/icons/histogram.svg +0 -0
- /package/{lib → dist}/assets/icons/line-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/map.svg +0 -0
- /package/{lib → dist}/assets/icons/pie-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/rectangular-tree-diagram.svg +0 -0
- /package/{lib → dist}/assets/icons/scatter-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/type-change.svg +0 -0
- /package/{lib → dist}/assets/img/area-chart.png +0 -0
- /package/{lib → dist}/assets/img/area-group-chart.png +0 -0
- /package/{lib → dist}/assets/img/bar-group.png +0 -0
- /package/{lib → dist}/assets/img/bar-stack.png +0 -0
- /package/{lib → dist}/assets/img/bar.png +0 -0
- /package/{lib → dist}/assets/img/combination-chart.png +0 -0
- /package/{lib → dist}/assets/img/compared-chart.png +0 -0
- /package/{lib → dist}/assets/img/completeness-chart.png +0 -0
- /package/{lib → dist}/assets/img/custom-bar.png +0 -0
- /package/{lib → dist}/assets/img/dashboard-chart.png +0 -0
- /package/{lib → dist}/assets/img/group-completeness-chart.png +0 -0
- /package/{lib → dist}/assets/img/group_line.png +0 -0
- /package/{lib → dist}/assets/img/heat-map.png +0 -0
- /package/{lib → dist}/assets/img/horizontal-bar.png +0 -0
- /package/{lib → dist}/assets/img/horizontal-group-bar.png +0 -0
- /package/{lib → dist}/assets/img/line.png +0 -0
- /package/{lib → dist}/assets/img/map-bubble.png +0 -0
- /package/{lib → dist}/assets/img/map.png +0 -0
- /package/{lib → dist}/assets/img/mirror.png +0 -0
- /package/{lib → dist}/assets/img/number-card.png +0 -0
- /package/{lib → dist}/assets/img/pie.png +0 -0
- /package/{lib → dist}/assets/img/pivot-table.png +0 -0
- /package/{lib → dist}/assets/img/ring.png +0 -0
- /package/{lib → dist}/assets/img/scatter.png +0 -0
- /package/{lib → dist}/assets/img/stacked-horizontal-bar.png +0 -0
- /package/{lib → dist}/assets/img/treemap.png +0 -0
- /package/{lib → dist}/assets/img/trend-chart.png +0 -0
- /package/{lib → dist}/assets/img/world-map-bubble.png +0 -0
- /package/{lib → dist}/assets/img/world-map.png +0 -0
- /package/{lib → dist}/components/loading/index.css +0 -0
- /package/{lib/components/settings/widgets/select-table → dist/editor}/index.css +0 -0
- /package/{lib/components → dist}/settings/advance-bar-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/bar-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/basic-number-card/index.js +0 -0
- /package/{lib/components → dist}/settings/combination-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/dashboard-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/horizontal-bar-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/pie-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/table-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/time-comparison-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/widgets/font-settings/index.js +0 -0
- /package/{lib/components/settings/widgets/x-axios.js → dist/settings/widgets/select-table/index.css} +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { CellType, DEFAULT_DATE_FORMAT, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE } from 'dtable-utils';
|
|
2
|
+
import { MIRROR_COLUMN_LIST } from '../constants';
|
|
3
|
+
export const getDateColumnFormat = column => {
|
|
4
|
+
const format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
|
|
5
|
+
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
6
|
+
return format;
|
|
7
|
+
};
|
|
8
|
+
export const isCheckboxColumn = column => {
|
|
9
|
+
let {
|
|
10
|
+
type,
|
|
11
|
+
data
|
|
12
|
+
} = column;
|
|
13
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
14
|
+
const {
|
|
15
|
+
result_type,
|
|
16
|
+
array_type
|
|
17
|
+
} = data || {};
|
|
18
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
19
|
+
return array_type === CellType.CHECKBOX;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return type === CellType.CHECKBOX;
|
|
24
|
+
};
|
|
25
|
+
export const getColumnByKey = (columnKey, columns) => {
|
|
26
|
+
if (!columnKey || !Array.isArray(columns)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return columns.find(column => column.key === columnKey);
|
|
30
|
+
};
|
|
31
|
+
export const getColumnByName = (columnName, columns) => {
|
|
32
|
+
if (!columnName || !Array.isArray(columns)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return columns.find(column => column.name === columnName);
|
|
36
|
+
};
|
|
37
|
+
export const getColumnByType = (columnType, columns) => {
|
|
38
|
+
if (!columnType || !Array.isArray(columns)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return columns.find(column => column.type === columnType);
|
|
42
|
+
};
|
|
43
|
+
export const getColumnByIndex = (index, columns) => {
|
|
44
|
+
if (Array.isArray(columns)) {
|
|
45
|
+
return columns[index];
|
|
46
|
+
}
|
|
47
|
+
if (typeof Immutable !== 'undefined') {
|
|
48
|
+
return columns.get(index);
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
export const isNameColumn = column => {
|
|
53
|
+
return column.key === '0000';
|
|
54
|
+
};
|
|
55
|
+
export const isUrlColumn = column => {
|
|
56
|
+
let {
|
|
57
|
+
type,
|
|
58
|
+
data
|
|
59
|
+
} = column;
|
|
60
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
61
|
+
const {
|
|
62
|
+
result_type,
|
|
63
|
+
array_type
|
|
64
|
+
} = data || {};
|
|
65
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
66
|
+
return array_type === CellType.URL;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return type === CellType.URL;
|
|
71
|
+
};
|
|
72
|
+
export const getLinkColumns = columns => {
|
|
73
|
+
if (!columns) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
return columns.filter(column => column.type === CellType.LINK && column.data);
|
|
77
|
+
};
|
|
78
|
+
export const calculateFormulaRows = (rows, columns) => {
|
|
79
|
+
const COMPUTED_COLUMN_TYPES = [CellType.FORMULA, CellType.LINK_FORMULA, CellType.LINK];
|
|
80
|
+
const formulaColumns = columns.filter(column => COMPUTED_COLUMN_TYPES.includes(column.type));
|
|
81
|
+
let formula_rows = {};
|
|
82
|
+
if (formulaColumns.length > 0) {
|
|
83
|
+
rows.forEach(row => {
|
|
84
|
+
let formulaRow = {};
|
|
85
|
+
formulaColumns.forEach(column => formulaRow[column.key] = row[column.key]);
|
|
86
|
+
formula_rows[row._id] = formulaRow;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return formula_rows;
|
|
90
|
+
};
|
|
91
|
+
export const handleCascadeColumn = function (optionValue, columnKey, columns, row) {
|
|
92
|
+
let updated = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
93
|
+
let processedColumns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new Set();
|
|
94
|
+
// This column has already been processed, avoid circular dependency.
|
|
95
|
+
if (!Array.isArray(columns) || processedColumns.has(columnKey)) {
|
|
96
|
+
return updated;
|
|
97
|
+
}
|
|
98
|
+
processedColumns.add(columnKey);
|
|
99
|
+
const singleSelectColumns = columns.filter(column => column.type === CellType.SINGLE_SELECT);
|
|
100
|
+
for (let i = 0; i < singleSelectColumns.length; i++) {
|
|
101
|
+
const singleSelectColumn = singleSelectColumns[i];
|
|
102
|
+
const {
|
|
103
|
+
data: {
|
|
104
|
+
cascade_column_key,
|
|
105
|
+
cascade_settings
|
|
106
|
+
}
|
|
107
|
+
} = singleSelectColumn;
|
|
108
|
+
if (cascade_column_key === columnKey) {
|
|
109
|
+
const {
|
|
110
|
+
key: childColumnKey
|
|
111
|
+
} = singleSelectColumn;
|
|
112
|
+
const childColumnOptions = cascade_settings[optionValue];
|
|
113
|
+
const childColumnCellValue = row[childColumnKey];
|
|
114
|
+
const cellValueInOptions = childColumnOptions && childColumnOptions.includes(childColumnCellValue);
|
|
115
|
+
if (!cellValueInOptions) {
|
|
116
|
+
updated[childColumnKey] = '';
|
|
117
|
+
handleCascadeColumn('', childColumnKey, columns, row, updated, processedColumns);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return updated;
|
|
122
|
+
};
|
|
123
|
+
export const isFrozen = column => {
|
|
124
|
+
if (!column) return false;
|
|
125
|
+
return column.frozen === true;
|
|
126
|
+
};
|
|
127
|
+
export const findLastFrozenColumnIndex = columns => {
|
|
128
|
+
for (let i = 0; i < columns.length; i++) {
|
|
129
|
+
if (isFrozen(columns[i])) {
|
|
130
|
+
return i;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return -1;
|
|
134
|
+
};
|
|
135
|
+
export const isStatisticMapColumn = column => {
|
|
136
|
+
if (!column) return false;
|
|
137
|
+
const {
|
|
138
|
+
type,
|
|
139
|
+
data
|
|
140
|
+
} = column;
|
|
141
|
+
if (type === CellType.GEOLOCATION) {
|
|
142
|
+
const {
|
|
143
|
+
geo_format
|
|
144
|
+
} = data || {};
|
|
145
|
+
if (geo_format === 'lng_lat' || geo_format === 'country_region') {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
151
|
+
const {
|
|
152
|
+
result_type,
|
|
153
|
+
array_type,
|
|
154
|
+
array_data
|
|
155
|
+
} = data || {};
|
|
156
|
+
if (result_type !== FORMULA_RESULT_TYPE.ARRAY || array_type !== CellType.GEOLOCATION) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const {
|
|
160
|
+
geo_format
|
|
161
|
+
} = array_data || {};
|
|
162
|
+
if (geo_format === 'lng_lat' || geo_format === 'country_region') {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
};
|
|
169
|
+
export const isStatisticWorldMapColumn = column => {
|
|
170
|
+
if (!column) return false;
|
|
171
|
+
const {
|
|
172
|
+
type,
|
|
173
|
+
data
|
|
174
|
+
} = column;
|
|
175
|
+
if (type === CellType.TEXT) return true;
|
|
176
|
+
if (type === CellType.GEOLOCATION) {
|
|
177
|
+
const {
|
|
178
|
+
geo_format
|
|
179
|
+
} = data || {};
|
|
180
|
+
if (geo_format === 'country_region') {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
185
|
+
const {
|
|
186
|
+
data
|
|
187
|
+
} = column;
|
|
188
|
+
const {
|
|
189
|
+
result_type,
|
|
190
|
+
array_type,
|
|
191
|
+
array_data
|
|
192
|
+
} = data || {};
|
|
193
|
+
if (result_type !== FORMULA_RESULT_TYPE.ARRAY || array_type !== CellType.GEOLOCATION) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
const {
|
|
197
|
+
geo_format
|
|
198
|
+
} = array_data || {};
|
|
199
|
+
if (geo_format === 'country_region') {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
};
|
|
205
|
+
export const isStatisticMirrorColumn = column => {
|
|
206
|
+
if (!column) return false;
|
|
207
|
+
return MIRROR_COLUMN_LIST.includes(column.type);
|
|
208
|
+
};
|
|
@@ -347,7 +347,7 @@ registerInteraction('element-range-highlight', {
|
|
|
347
347
|
}],
|
|
348
348
|
start: [{
|
|
349
349
|
trigger: 'plot:mousedown',
|
|
350
|
-
isEnable: function
|
|
350
|
+
isEnable: function (context) {
|
|
351
351
|
return !context.isInShape('mask');
|
|
352
352
|
},
|
|
353
353
|
action: ['rect-mask:start', 'rect-mask:show']
|
|
@@ -373,7 +373,7 @@ registerInteraction('element-range-highlight', {
|
|
|
373
373
|
action: ['rect-mask:moveEnd']
|
|
374
374
|
}, {
|
|
375
375
|
trigger: 'document:mouseup',
|
|
376
|
-
isEnable: function
|
|
376
|
+
isEnable: function (context) {
|
|
377
377
|
return !context.isInPlot();
|
|
378
378
|
},
|
|
379
379
|
action: ['element-range-highlight:clear', 'rect-mask:end', 'rect-mask:hide']
|
|
@@ -577,13 +577,13 @@ function isWheelDown(event) {
|
|
|
577
577
|
registerInteraction('view-zoom', {
|
|
578
578
|
start: [{
|
|
579
579
|
trigger: 'plot:mousewheel',
|
|
580
|
-
isEnable: function
|
|
580
|
+
isEnable: function (context) {
|
|
581
581
|
return isWheelDown(context.event);
|
|
582
582
|
},
|
|
583
583
|
action: 'scale-zoom:zoomOut'
|
|
584
584
|
}, {
|
|
585
585
|
trigger: 'plot:mousewheel',
|
|
586
|
-
isEnable: function
|
|
586
|
+
isEnable: function (context) {
|
|
587
587
|
return !isWheelDown(context.event);
|
|
588
588
|
},
|
|
589
589
|
action: 'scale-zoom:zoomIn'
|
|
@@ -602,11 +602,11 @@ registerInteraction('sibling-tooltip', {
|
|
|
602
602
|
export * from '@antv/g2/esm/core';
|
|
603
603
|
|
|
604
604
|
// 一些工具方法导出
|
|
605
|
-
export
|
|
606
|
-
translate
|
|
607
|
-
rotate
|
|
608
|
-
zoom
|
|
609
|
-
transform
|
|
610
|
-
getAngle
|
|
611
|
-
polarToCartesian
|
|
605
|
+
export const Util = {
|
|
606
|
+
translate,
|
|
607
|
+
rotate,
|
|
608
|
+
zoom,
|
|
609
|
+
transform,
|
|
610
|
+
getAngle,
|
|
611
|
+
polarToCartesian
|
|
612
612
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import intl from '../intl';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
3
|
+
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
4
|
+
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
5
|
+
const frFR = require('@seafile/seafile-calendar/lib/locale/fr_FR');
|
|
6
|
+
const deDE = require('@seafile/seafile-calendar/lib/locale/de_DE');
|
|
7
|
+
const esES = require('@seafile/seafile-calendar/lib/locale/es_ES');
|
|
8
|
+
const plPL = require('@seafile/seafile-calendar/lib/locale/pl_PL');
|
|
9
|
+
const csCZ = require('@seafile/seafile-calendar/lib/locale/cs_CZ');
|
|
10
|
+
const ruRU = require('@seafile/seafile-calendar/lib/locale/ru_RU');
|
|
11
11
|
function translateCalendar(lang) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const locale = lang ? lang : 'en';
|
|
13
|
+
let language;
|
|
14
14
|
switch (locale) {
|
|
15
15
|
case 'zh-cn':
|
|
16
16
|
language = zhCN;
|
|
@@ -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;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
9
|
isSelectOption;
|
|
10
10
|
if (type !== '[object Object]') {
|
|
11
11
|
isSelectOption = option === selectValue;
|
|
@@ -16,12 +16,13 @@ var generatorCommonOption = function generatorCommonOption() {
|
|
|
16
16
|
} else {
|
|
17
17
|
isSelectOption = option.name === selectValue;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
name
|
|
21
|
-
displayName
|
|
22
|
-
disabled
|
|
23
|
-
optionType
|
|
24
|
-
isDuplicate
|
|
19
|
+
const {
|
|
20
|
+
name,
|
|
21
|
+
displayName,
|
|
22
|
+
disabled,
|
|
23
|
+
type: optionType,
|
|
24
|
+
isDuplicate
|
|
25
|
+
} = validOption;
|
|
25
26
|
if (optionType === 'divide') {
|
|
26
27
|
return {
|
|
27
28
|
value: validOption,
|
|
@@ -38,8 +39,8 @@ var generatorCommonOption = function generatorCommonOption() {
|
|
|
38
39
|
value: validOption,
|
|
39
40
|
key: "".concat(name, "-").concat(index),
|
|
40
41
|
type: optionType,
|
|
41
|
-
name
|
|
42
|
-
isDuplicate
|
|
42
|
+
name,
|
|
43
|
+
isDuplicate,
|
|
43
44
|
label: /*#__PURE__*/React.createElement("div", {
|
|
44
45
|
className: classnames('common-select-option', {
|
|
45
46
|
'disabled': disabled
|
|
@@ -53,9 +54,7 @@ var generatorCommonOption = function generatorCommonOption() {
|
|
|
53
54
|
}, displayName || name))
|
|
54
55
|
};
|
|
55
56
|
};
|
|
56
|
-
export
|
|
57
|
+
export const generatorCommonOptions = (options, selectValue) => {
|
|
57
58
|
if (!Array.isArray(options)) return [];
|
|
58
|
-
return options.map(
|
|
59
|
-
return generatorCommonOption(option, index, selectValue);
|
|
60
|
-
});
|
|
59
|
+
return options.map((option, index) => generatorCommonOption(option, index, selectValue));
|
|
61
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,169 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import shallowEqual from 'shallowequal';
|
|
4
|
+
import context from '../context';
|
|
5
|
+
import intl from '../intl';
|
|
6
|
+
import { Loading } from '../components';
|
|
7
|
+
import { ChartUtils } from '../utils';
|
|
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
|
+
isStatisticalData
|
|
57
|
+
} = _this.props;
|
|
58
|
+
const {
|
|
59
|
+
data
|
|
60
|
+
} = _this.state;
|
|
61
|
+
if (!isNeedRequestData) {
|
|
62
|
+
ChartUtils.calculateStaticChart(tables, chart, data, _this.callback);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
ChartUtils.calculateChart(chart, tables, _this.callback, isStatisticalData);
|
|
66
|
+
};
|
|
67
|
+
this.state = {
|
|
68
|
+
isCalculated: false,
|
|
69
|
+
data: null,
|
|
70
|
+
errorMessage: '',
|
|
71
|
+
tipMessage: ''
|
|
72
|
+
};
|
|
73
|
+
console.log(props);
|
|
74
|
+
context.init(props);
|
|
75
|
+
}
|
|
76
|
+
componentDidMount() {
|
|
77
|
+
const lang = context.getSetting('lang') || 'zh-cn';
|
|
78
|
+
intl.setLang(lang);
|
|
79
|
+
this.calculateStatistic();
|
|
80
|
+
}
|
|
81
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
82
|
+
const {
|
|
83
|
+
chart: oldChart
|
|
84
|
+
} = this.props;
|
|
85
|
+
const {
|
|
86
|
+
chart
|
|
87
|
+
} = nextProps;
|
|
88
|
+
if (shallowEqual(chart, oldChart)) return;
|
|
89
|
+
this.setState({
|
|
90
|
+
isCalculated: false
|
|
91
|
+
}, () => {
|
|
92
|
+
if (ChartUtils.isChartTypeChange(chart, oldChart)) {
|
|
93
|
+
this.calculateStatistic();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (ChartUtils.isChartStyleChange(chart, oldChart)) {
|
|
97
|
+
this.setState({
|
|
98
|
+
isCalculated: true
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (ChartUtils.isChartSortChange(chart, oldChart)) {
|
|
103
|
+
this.calculateStatistic(false);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.calculateStatistic();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
render() {
|
|
110
|
+
var _chart$config;
|
|
111
|
+
const {
|
|
112
|
+
chart,
|
|
113
|
+
className,
|
|
114
|
+
tables,
|
|
115
|
+
canvasStyle
|
|
116
|
+
} = this.props;
|
|
117
|
+
const {
|
|
118
|
+
data,
|
|
119
|
+
isCalculated,
|
|
120
|
+
errorMessage,
|
|
121
|
+
tipMessage
|
|
122
|
+
} = this.state;
|
|
123
|
+
const validClassName = classnames('sea-chart-formatter', className);
|
|
124
|
+
const tipBackgroundColorClassName = 'sea-chart-formatter-tip';
|
|
125
|
+
if (!isCalculated) {
|
|
126
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
className: classnames('loading', validClassName)
|
|
128
|
+
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
129
|
+
}
|
|
130
|
+
if (errorMessage) {
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
133
|
+
}, intl.get(errorMessage));
|
|
134
|
+
}
|
|
135
|
+
if (tipMessage) {
|
|
136
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
138
|
+
}, intl.get(tipMessage));
|
|
139
|
+
}
|
|
140
|
+
if (ChartUtils.imEmptyChartResult(data)) {
|
|
141
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
142
|
+
className: classnames('error', validClassName, tipBackgroundColorClassName)
|
|
143
|
+
}, intl.get('There_are_no_statistic_results_yet'));
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: validClassName
|
|
147
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
148
|
+
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"))
|
|
149
|
+
}, /*#__PURE__*/React.createElement(Title, {
|
|
150
|
+
chart: chart
|
|
151
|
+
}), /*#__PURE__*/React.createElement(Wrapper, {
|
|
152
|
+
chart: chart,
|
|
153
|
+
data: data,
|
|
154
|
+
tables: tables,
|
|
155
|
+
canvasStyle: canvasStyle
|
|
156
|
+
})));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
View.defaultProps = {
|
|
160
|
+
isStatisticalData: true,
|
|
161
|
+
canvasStyle: {},
|
|
162
|
+
tables: [],
|
|
163
|
+
chart: {
|
|
164
|
+
id: '',
|
|
165
|
+
config: {},
|
|
166
|
+
style_config: {}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
export default View;
|