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,160 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { Label, FormGroup } from 'reactstrap';
|
|
4
|
+
import DTableSelect from "dtable-ui-component/lib/DTableSelect";
|
|
5
|
+
import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
6
|
+
import { CHART_SUPPORT_COLUMNS, DATE_GRANULATES, GEOLOCATION_GRANULATES, CHART_SUMMARY_SHOW, GEOLOCATION_FORMAT_MAP } from '../../constants';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
class GroupBy extends Component {
|
|
9
|
+
constructor(_props) {
|
|
10
|
+
super(_props);
|
|
11
|
+
this.generatorGranulatesOptions = granulates => {
|
|
12
|
+
return granulates.map(item => {
|
|
13
|
+
return {
|
|
14
|
+
value: item,
|
|
15
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
16
|
+
className: "select-module select-module-name ml-0"
|
|
17
|
+
}, intl.get(CHART_SUMMARY_SHOW[item]))
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
this.initOptions = props => {
|
|
22
|
+
const {
|
|
23
|
+
tables,
|
|
24
|
+
selectedTableId
|
|
25
|
+
} = props;
|
|
26
|
+
this.selectedTable = getTableById(tables, selectedTableId);
|
|
27
|
+
const columns = this.selectedTable && Array.isArray(this.selectedTable.columns) ? this.selectedTable.columns : [];
|
|
28
|
+
this.validColumns = this.getAvailableColumns(columns);
|
|
29
|
+
this.columnOptions = this.getColumnOptions(this.validColumns);
|
|
30
|
+
};
|
|
31
|
+
this.initGeolocationOptions = props => {
|
|
32
|
+
const {
|
|
33
|
+
selectedColumnKey
|
|
34
|
+
} = props;
|
|
35
|
+
if (!selectedColumnKey) {
|
|
36
|
+
this.geolocationGranulatesOptions = [];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const groupbyColumn = getTableColumnByKey(this.selectedTable, selectedColumnKey);
|
|
40
|
+
if (!groupbyColumn) {
|
|
41
|
+
this.geolocationGranulatesOptions = [];
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const {
|
|
45
|
+
geo_format
|
|
46
|
+
} = groupbyColumn.data || {};
|
|
47
|
+
if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE) {
|
|
48
|
+
this.geolocationGranulatesOptions = this.generatorGranulatesOptions(GEOLOCATION_GRANULATES.filter(item => item === GEOLOCATION_FORMAT_MAP.PROVINCE));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE_CITY) {
|
|
52
|
+
this.geolocationGranulatesOptions = this.generatorGranulatesOptions(GEOLOCATION_GRANULATES.filter(item => item === 'district'));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (geo_format === GEOLOCATION_FORMAT_MAP.COUNTRY_REGION || geo_format === GEOLOCATION_FORMAT_MAP.LNG_LAT) {
|
|
56
|
+
this.geolocationGranulatesOptions = [];
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.geolocationGranulatesOptions = this.generatorGranulatesOptions(GEOLOCATION_GRANULATES);
|
|
60
|
+
};
|
|
61
|
+
this.getAvailableColumns = columns => {
|
|
62
|
+
if (!columns || !Array.isArray(columns)) return [];
|
|
63
|
+
return columns.filter(column => CHART_SUPPORT_COLUMNS.includes(column.type));
|
|
64
|
+
};
|
|
65
|
+
this.getColumnOptions = columns => {
|
|
66
|
+
return columns.map(column => {
|
|
67
|
+
return {
|
|
68
|
+
value: column,
|
|
69
|
+
label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
className: "sea-chart-column-icon"
|
|
71
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
72
|
+
className: COLUMNS_ICON_CONFIG[column.type]
|
|
73
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
74
|
+
className: 'select-module select-module-name ml-0'
|
|
75
|
+
}, column.name))
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
this.renderSelector = () => {
|
|
80
|
+
const {
|
|
81
|
+
selectedColumnKey
|
|
82
|
+
} = this.props;
|
|
83
|
+
const selectedOption = selectedColumnKey ? this.columnOptions.find(option => option.value.key === selectedColumnKey) : null;
|
|
84
|
+
return /*#__PURE__*/React.createElement(DTableSelect, {
|
|
85
|
+
value: selectedOption,
|
|
86
|
+
classNamePrefix: "select-column",
|
|
87
|
+
options: this.columnOptions,
|
|
88
|
+
onChange: this.props.onGroupByChange,
|
|
89
|
+
noOptionsMessage: () => {
|
|
90
|
+
return /*#__PURE__*/React.createElement("span", null, intl.get('No_column'));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
this.renderGroupbyDateGranulates = () => {
|
|
95
|
+
const {
|
|
96
|
+
selectedDateGranularity
|
|
97
|
+
} = this.props;
|
|
98
|
+
const selectedOption = this.dateGranulatesOptions.find(option => option.value === selectedDateGranularity);
|
|
99
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: "sea-chart-parameter-item mt-4"
|
|
101
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
102
|
+
value: selectedOption,
|
|
103
|
+
options: this.dateGranulatesOptions,
|
|
104
|
+
onChange: this.props.onGroupbyDateGranularityChange
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
this.renderGroupbyGeolocationGranulates = () => {
|
|
108
|
+
const {
|
|
109
|
+
selectedGeolocationGranularity
|
|
110
|
+
} = this.props;
|
|
111
|
+
const selectedOption = this.geolocationGranulatesOptions.find(option => option.value === selectedGeolocationGranularity);
|
|
112
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: "sea-chart-parameter-item mt-4"
|
|
114
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
115
|
+
value: selectedOption,
|
|
116
|
+
options: this.geolocationGranulatesOptions,
|
|
117
|
+
onChange: this.props.onGroupbyGeolocationGranularityChange
|
|
118
|
+
}));
|
|
119
|
+
};
|
|
120
|
+
this.renderGroupBy = () => {
|
|
121
|
+
const {
|
|
122
|
+
selectedColumnKey
|
|
123
|
+
} = this.props;
|
|
124
|
+
if (!selectedColumnKey) return null;
|
|
125
|
+
const groupbyColumn = getTableColumnByKey(this.selectedTable, selectedColumnKey);
|
|
126
|
+
if (!groupbyColumn) return null;
|
|
127
|
+
const {
|
|
128
|
+
type: groupbyColumnType
|
|
129
|
+
} = groupbyColumn;
|
|
130
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && this.renderGroupbyDateGranulates(), groupbyColumnType === CellType.GEOLOCATION && this.geolocationGranulatesOptions.length > 0 && this.renderGroupbyGeolocationGranulates());
|
|
131
|
+
};
|
|
132
|
+
this.dateGranulatesOptions = this.generatorGranulatesOptions(DATE_GRANULATES);
|
|
133
|
+
this.initOptions(_props);
|
|
134
|
+
this.initGeolocationOptions(_props);
|
|
135
|
+
}
|
|
136
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
137
|
+
const {
|
|
138
|
+
selectedTableId,
|
|
139
|
+
selectedColumnKey
|
|
140
|
+
} = nextProps;
|
|
141
|
+
if (selectedTableId !== this.props.selectedTableId) {
|
|
142
|
+
this.initOptions(nextProps);
|
|
143
|
+
}
|
|
144
|
+
if (selectedColumnKey !== this.props.selectedColumnKey) {
|
|
145
|
+
this.initGeolocationOptions(nextProps);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
const {
|
|
150
|
+
label,
|
|
151
|
+
className
|
|
152
|
+
} = this.props;
|
|
153
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
154
|
+
className: classnames('sea-chart-setting-item table-setting', {
|
|
155
|
+
[className]: className
|
|
156
|
+
})
|
|
157
|
+
}, /*#__PURE__*/React.createElement(Label, null, label), this.renderSelector(), this.renderGroupBy());
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export default GroupBy;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormGroup, Label } from 'reactstrap';
|
|
3
|
-
import { LABEL_COLORS } from '
|
|
4
|
-
import intl from '
|
|
3
|
+
import { LABEL_COLORS } from '../../constants';
|
|
4
|
+
import intl from '../../intl';
|
|
5
5
|
function LabelColor(props) {
|
|
6
|
-
|
|
6
|
+
const {
|
|
7
|
+
labelColor
|
|
8
|
+
} = props;
|
|
7
9
|
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
8
|
-
className: "
|
|
10
|
+
className: "sea-chart-parameter-item"
|
|
9
11
|
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Color')), /*#__PURE__*/React.createElement("div", {
|
|
10
12
|
className: "d-flex align-items-center justify-content-between"
|
|
11
|
-
}, LABEL_COLORS.map(
|
|
13
|
+
}, LABEL_COLORS.map((item, index) => {
|
|
12
14
|
return /*#__PURE__*/React.createElement("div", {
|
|
13
15
|
key: "y-axis-label-color-".concat(index)
|
|
14
16
|
}, /*#__PURE__*/React.createElement("div", {
|
|
15
17
|
className: "colorinput"
|
|
16
18
|
}, /*#__PURE__*/React.createElement("span", {
|
|
17
|
-
className: "colorinput-color
|
|
18
|
-
onClick:
|
|
19
|
-
return props.onChange(event, item);
|
|
20
|
-
},
|
|
19
|
+
className: "colorinput-color -colorinput d-flex justify-content-center align-items-center",
|
|
20
|
+
onClick: event => props.onChange(event, item),
|
|
21
21
|
style: {
|
|
22
22
|
backgroundColor: item,
|
|
23
23
|
borderColor: item
|
|
24
24
|
}
|
|
25
25
|
}, item === (labelColor || LABEL_COLORS[0]) && /*#__PURE__*/React.createElement("i", {
|
|
26
|
-
className: "dtable-font dtable-icon-check-mark
|
|
26
|
+
className: "dtable-font dtable-icon-check-mark -check-mark"
|
|
27
27
|
}))));
|
|
28
28
|
})));
|
|
29
29
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { FormGroup, Label, Input } from 'reactstrap';
|
|
3
|
+
import intl from '../../intl';
|
|
4
|
+
class MinMaxSetting extends Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.onMinChange = e => {
|
|
8
|
+
const min = e.target.value;
|
|
9
|
+
this.setState({
|
|
10
|
+
min
|
|
11
|
+
}, () => {
|
|
12
|
+
this.props.onMinChange(min);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
this.onMaxChange = e => {
|
|
16
|
+
const max = e.target.value;
|
|
17
|
+
this.setState({
|
|
18
|
+
max
|
|
19
|
+
}, () => {
|
|
20
|
+
this.props.onMaxChange(max);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
this.state = {
|
|
24
|
+
min: props.min,
|
|
25
|
+
max: props.max
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
const {
|
|
30
|
+
min,
|
|
31
|
+
max
|
|
32
|
+
} = this.state;
|
|
33
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
|
|
34
|
+
className: "mb-2"
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Label, {
|
|
36
|
+
for: "min"
|
|
37
|
+
}, intl.get('Min')), /*#__PURE__*/React.createElement(Input, {
|
|
38
|
+
id: "min",
|
|
39
|
+
type: "number",
|
|
40
|
+
value: min,
|
|
41
|
+
onChange: this.onMinChange
|
|
42
|
+
})), /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
|
|
43
|
+
for: "max"
|
|
44
|
+
}, intl.get('Max')), /*#__PURE__*/React.createElement(Input, {
|
|
45
|
+
id: "max",
|
|
46
|
+
type: "number",
|
|
47
|
+
value: max,
|
|
48
|
+
onChange: this.onMaxChange
|
|
49
|
+
})));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export default MinMaxSetting;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { FormGroup, Label } from 'reactstrap';
|
|
3
|
+
import { NumberInput } from '../../components/';
|
|
4
|
+
import intl from '../../intl';
|
|
5
|
+
class MiniNumSlicePercent extends Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.replaceNumberNotAllowInput = value => {
|
|
9
|
+
if (!value) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
value = value.replace(/。/g, '.');
|
|
13
|
+
value = value.replace(/-/g, '');
|
|
14
|
+
return value.replace(/[^.-\d,]/g, '');
|
|
15
|
+
};
|
|
16
|
+
this.onKeyDown = event => {
|
|
17
|
+
if (event.keyCode === 13) {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
event.target.blur();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
this.onPercentChange = event => {
|
|
23
|
+
const value = this.replaceNumberNotAllowInput(event.target.value);
|
|
24
|
+
if (value === this.state.value) return;
|
|
25
|
+
this.setState({
|
|
26
|
+
value
|
|
27
|
+
}, () => {
|
|
28
|
+
this.onCommit();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
this.onBlur = () => {
|
|
32
|
+
this.onCommit();
|
|
33
|
+
};
|
|
34
|
+
this.onCommit = () => {
|
|
35
|
+
const {
|
|
36
|
+
value
|
|
37
|
+
} = this.state;
|
|
38
|
+
if (value === this.props.value) return;
|
|
39
|
+
const validValue = value || value === 0 ? Number(value) : 1.5;
|
|
40
|
+
this.props.onChange(validValue);
|
|
41
|
+
};
|
|
42
|
+
this.state = {
|
|
43
|
+
value: props.value
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
const {
|
|
48
|
+
value
|
|
49
|
+
} = this.props;
|
|
50
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
51
|
+
className: "sea-chart-parameter-item"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Minimum_slice_percent')), /*#__PURE__*/React.createElement(NumberInput, {
|
|
53
|
+
value: value,
|
|
54
|
+
onChange: this.onPercentChange,
|
|
55
|
+
step: 0.1,
|
|
56
|
+
min: 0,
|
|
57
|
+
max: 100,
|
|
58
|
+
onBlur: this.onBlur,
|
|
59
|
+
onKeyDown: this.onKeyDown
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export default MiniNumSlicePercent;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import DTableSelect from "dtable-ui-component/lib/DTableSelect";
|
|
3
|
+
import { FormGroup, Label } from 'reactstrap';
|
|
4
|
+
import shallowEqual from 'shallowequal';
|
|
5
|
+
import { CHART_TYPE, CHART_SUMMARY_CALCULATION_METHOD, CHART_SUMMARY_SHOW, CHART_DATE_SUMMARY_CALCULATION_METHOD } from '../../constants';
|
|
6
|
+
import { ChartUtils } from '../../utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
class NumericSummaryItem extends Component {
|
|
9
|
+
constructor(_props) {
|
|
10
|
+
super(_props);
|
|
11
|
+
this.initSummaryMethodOptions = props => {
|
|
12
|
+
const {
|
|
13
|
+
value,
|
|
14
|
+
numericColumnOptions
|
|
15
|
+
} = props;
|
|
16
|
+
const selectedOption = numericColumnOptions.find(item => item.value.key === value.column_key);
|
|
17
|
+
const summaryMethodOptions = selectedOption && ChartUtils.isDateSummaryColumn(selectedOption.value) ? CHART_DATE_SUMMARY_CALCULATION_METHOD : CHART_SUMMARY_CALCULATION_METHOD;
|
|
18
|
+
this.summaryMethodOptions = summaryMethodOptions.map(item => {
|
|
19
|
+
return {
|
|
20
|
+
value: item,
|
|
21
|
+
label: intl.get(CHART_SUMMARY_SHOW[item])
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
this.onToggleExpand = () => {
|
|
26
|
+
this.setState({
|
|
27
|
+
isExpand: !this.state.isExpand
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
this.state = {
|
|
31
|
+
isExpand: true
|
|
32
|
+
};
|
|
33
|
+
this.initSummaryMethodOptions(_props);
|
|
34
|
+
}
|
|
35
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
36
|
+
if (!shallowEqual(this.props.value, nextProps.value)) {
|
|
37
|
+
this.initSummaryMethodOptions(nextProps);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
const {
|
|
42
|
+
index,
|
|
43
|
+
chart,
|
|
44
|
+
value,
|
|
45
|
+
numericColumnOptions
|
|
46
|
+
} = this.props;
|
|
47
|
+
const {
|
|
48
|
+
type
|
|
49
|
+
} = chart.config;
|
|
50
|
+
const {
|
|
51
|
+
column_key,
|
|
52
|
+
summary_method
|
|
53
|
+
} = value;
|
|
54
|
+
const selectedColumnOption = numericColumnOptions.find(option => option.value.key === column_key);
|
|
55
|
+
const selectedSummaryMethodOption = this.summaryMethodOptions.find(option => option.value === summary_method);
|
|
56
|
+
const {
|
|
57
|
+
isExpand
|
|
58
|
+
} = this.state;
|
|
59
|
+
const isFirst = index === 0;
|
|
60
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
61
|
+
className: "sea-chart-parameter-item"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Label, {
|
|
63
|
+
className: "numeric-summary-item d-flex align-items-center justify-content-between w-100"
|
|
64
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", {
|
|
65
|
+
onClick: this.onToggleExpand,
|
|
66
|
+
className: "numeric-summary-item-icon dtable-font mr-2 ".concat(isExpand ? 'dtable-icon-drop-down' : 'dtable-icon-right-slide')
|
|
67
|
+
}), /*#__PURE__*/React.createElement("span", null, (type === CHART_TYPE.TABLE ? intl.get('Summary_field') : intl.get('Numeric_field')) + ' ' + (1 + index))), !isFirst && /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "delete-numeric-summary-item-content close d-flex align-items-center justify-content-center",
|
|
69
|
+
onClick: () => this.props.onDelete(index)
|
|
70
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
71
|
+
className: "dtable-font dtable-icon-fork-number delete-icon"
|
|
72
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: "pl-4 ".concat(isExpand ? 'expanded-numeric-summary-content' : 'collapsed-numeric-summary-content d-none')
|
|
74
|
+
}, /*#__PURE__*/React.createElement(FormGroup, {
|
|
75
|
+
className: "sea-chart-parameter-item numeric-column"
|
|
76
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
77
|
+
value: selectedColumnOption,
|
|
78
|
+
placeholder: intl.get('Select_a_column'),
|
|
79
|
+
onChange: option => this.props.onColumnOptionChange(option, index),
|
|
80
|
+
options: numericColumnOptions
|
|
81
|
+
})), /*#__PURE__*/React.createElement(FormGroup, {
|
|
82
|
+
className: "sea-chart-parameter-item summary-method"
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
84
|
+
value: selectedSummaryMethodOption,
|
|
85
|
+
onChange: option => this.props.onSummaryMethodChange(option, index),
|
|
86
|
+
options: this.summaryMethodOptions
|
|
87
|
+
}))));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export default NumericSummaryItem;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Label, FormGroup } from 'reactstrap';
|
|
3
|
+
import DTableSelect from "dtable-ui-component/lib/DTableSelect";
|
|
4
|
+
import intl from '../../../intl';
|
|
5
|
+
class SelectTable extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.renderSelector = () => {
|
|
9
|
+
const {
|
|
10
|
+
selectedTableId
|
|
11
|
+
} = this.props;
|
|
12
|
+
const selectedOption = selectedTableId ? this.tableOptions.find(option => option.value === selectedTableId) : null;
|
|
13
|
+
return /*#__PURE__*/React.createElement(DTableSelect, {
|
|
14
|
+
menuPortalTarget: '#wrapper',
|
|
15
|
+
value: selectedOption,
|
|
16
|
+
options: this.tableOptions,
|
|
17
|
+
onChange: this.props.onSettingUpdate
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const {
|
|
21
|
+
tables
|
|
22
|
+
} = props;
|
|
23
|
+
this.tableOptions = Array.isArray(tables) ? tables.map(table => {
|
|
24
|
+
const value = table._id;
|
|
25
|
+
const label = table['name'];
|
|
26
|
+
return {
|
|
27
|
+
value,
|
|
28
|
+
label
|
|
29
|
+
};
|
|
30
|
+
}) : [];
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
34
|
+
className: "sea-chart-setting-item table-setting"
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Table')), this.renderSelector());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default SelectTable;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { Label, FormGroup } from 'reactstrap';
|
|
3
|
+
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
4
|
+
import Switch from './switch';
|
|
5
|
+
import { eventStopPropagation } from '../../utils';
|
|
6
|
+
import intl from '../../intl';
|
|
7
|
+
class Stack extends Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.onUseStackChange = event => {
|
|
11
|
+
eventStopPropagation(event);
|
|
12
|
+
const {
|
|
13
|
+
chart
|
|
14
|
+
} = this.props;
|
|
15
|
+
const {
|
|
16
|
+
config
|
|
17
|
+
} = chart;
|
|
18
|
+
const {
|
|
19
|
+
y_axis_use_stack
|
|
20
|
+
} = config;
|
|
21
|
+
this.props.onChange({
|
|
22
|
+
y_axis_use_stack: !y_axis_use_stack
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
const {
|
|
28
|
+
chart,
|
|
29
|
+
tables,
|
|
30
|
+
selectedTableId
|
|
31
|
+
} = this.props;
|
|
32
|
+
const {
|
|
33
|
+
y_axis_use_stack,
|
|
34
|
+
column_groupby_column_key
|
|
35
|
+
} = chart.config;
|
|
36
|
+
if (!column_groupby_column_key) return null;
|
|
37
|
+
const selectedTable = getTableById(tables, selectedTableId);
|
|
38
|
+
if (!selectedTable) return null;
|
|
39
|
+
const columnGroupbyColumn = getTableColumnByKey(selectedTable, column_groupby_column_key);
|
|
40
|
+
if (!columnGroupbyColumn) return null;
|
|
41
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
42
|
+
className: "sea-chart-parameter-item"
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Display_mode')), /*#__PURE__*/React.createElement(Switch, {
|
|
44
|
+
checked: y_axis_use_stack || false,
|
|
45
|
+
placeholder: intl.get('Stack'),
|
|
46
|
+
onChange: this.onUseStackChange
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export default Stack;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import DTableSelect from "dtable-ui-component/lib/DTableSelect";
|
|
3
|
+
import { FormGroup, Label } from 'reactstrap';
|
|
4
|
+
import shallowEqual from 'shallowequal';
|
|
5
|
+
import { CHART_TYPE, CHART_SUMMARY_CALCULATION_METHOD, CHART_SUMMARY_SHOW, CHART_DATE_SUMMARY_CALCULATION_METHOD } from '../../constants';
|
|
6
|
+
import { ChartUtils } from '../../utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
class SummaryMethodSettings extends Component {
|
|
9
|
+
constructor(_props) {
|
|
10
|
+
super(_props);
|
|
11
|
+
this.initSummaryMethodOptions = props => {
|
|
12
|
+
const {
|
|
13
|
+
value,
|
|
14
|
+
numericColumnOptions
|
|
15
|
+
} = props;
|
|
16
|
+
const selectedOption = numericColumnOptions.find(item => item.value.key === value.column_key);
|
|
17
|
+
const summaryMethodOptions = selectedOption && ChartUtils.isDateSummaryColumn(selectedOption.value) ? CHART_DATE_SUMMARY_CALCULATION_METHOD : CHART_SUMMARY_CALCULATION_METHOD;
|
|
18
|
+
this.summaryMethodOptions = summaryMethodOptions.map(item => {
|
|
19
|
+
return {
|
|
20
|
+
value: item,
|
|
21
|
+
label: intl.get(CHART_SUMMARY_SHOW[item])
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
this.state = {
|
|
26
|
+
isExpand: true
|
|
27
|
+
};
|
|
28
|
+
this.initSummaryMethodOptions(_props);
|
|
29
|
+
}
|
|
30
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
31
|
+
if (!shallowEqual(this.props.value, nextProps.value)) {
|
|
32
|
+
this.initSummaryMethodOptions(nextProps);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const {
|
|
37
|
+
chart,
|
|
38
|
+
value,
|
|
39
|
+
numericColumnOptions
|
|
40
|
+
} = this.props;
|
|
41
|
+
const {
|
|
42
|
+
type
|
|
43
|
+
} = chart.config;
|
|
44
|
+
const {
|
|
45
|
+
column_key,
|
|
46
|
+
summary_method
|
|
47
|
+
} = value;
|
|
48
|
+
const selectedColumnOption = numericColumnOptions.find(option => option.value.key === column_key);
|
|
49
|
+
const selectedSummaryMethodOption = this.summaryMethodOptions.find(option => option.value === summary_method);
|
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
|
|
51
|
+
className: "chart-parameter-item"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Label, null, type === CHART_TYPE.TABLE ? intl.get('Summary_field') : intl.get('Numeric_field')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
53
|
+
value: selectedColumnOption,
|
|
54
|
+
placeholder: intl.get('Select_a_column'),
|
|
55
|
+
onChange: this.props.onColumnOptionChange,
|
|
56
|
+
options: numericColumnOptions
|
|
57
|
+
})), /*#__PURE__*/React.createElement(FormGroup, {
|
|
58
|
+
className: "chart-parameter-item"
|
|
59
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
60
|
+
value: selectedSummaryMethodOption,
|
|
61
|
+
onChange: this.props.onSummaryMethodChange,
|
|
62
|
+
options: this.summaryMethodOptions
|
|
63
|
+
})));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export default SummaryMethodSettings;
|