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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import React, { useCallback } from 'react';
|
|
3
2
|
import { FormGroup, Label } from 'reactstrap';
|
|
4
3
|
import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
|
|
@@ -8,23 +7,30 @@ import GroupBy from '../widgets/group-by';
|
|
|
8
7
|
import Switch from '../widgets/switch';
|
|
9
8
|
import BasicSummary from '../widgets/basic-summary';
|
|
10
9
|
import TimePicker from '../widgets/time-picker';
|
|
11
|
-
import { eventStopPropagation } from '
|
|
12
|
-
import {
|
|
13
|
-
import intl from '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onChange
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
import { eventStopPropagation } from '../../utils';
|
|
11
|
+
import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
|
|
12
|
+
import intl from '../../intl';
|
|
13
|
+
const DataSettings = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
chart,
|
|
16
|
+
tables,
|
|
17
|
+
onChange
|
|
18
|
+
} = _ref;
|
|
19
|
+
const onXAxisColumnChange = useCallback(option => {
|
|
20
|
+
const {
|
|
21
|
+
config
|
|
22
|
+
} = chart;
|
|
23
|
+
const {
|
|
24
|
+
x_axis_column_key
|
|
25
|
+
} = config;
|
|
26
|
+
const column = option.value;
|
|
27
|
+
const {
|
|
28
|
+
key: newXAxisColumnKey,
|
|
29
|
+
type
|
|
30
|
+
} = column;
|
|
31
|
+
const validValue = newXAxisColumnKey === 'Groupby_null' ? null : newXAxisColumnKey;
|
|
26
32
|
if (x_axis_column_key === validValue) return;
|
|
27
|
-
|
|
33
|
+
let update = {
|
|
28
34
|
x_axis_column_key: validValue
|
|
29
35
|
};
|
|
30
36
|
if (!validValue) {
|
|
@@ -32,11 +38,12 @@ var DataSettings = function DataSettings(_ref) {
|
|
|
32
38
|
update['x_axis_geolocation_granularity'] = null;
|
|
33
39
|
} else {
|
|
34
40
|
if (DATE_COLUMN_OPTIONS.includes(type)) {
|
|
35
|
-
update['x_axis_date_granularity'] =
|
|
41
|
+
update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
|
|
36
42
|
update['x_axis_geolocation_granularity'] = null;
|
|
37
43
|
} else if (type === CellType.GEOLOCATION) {
|
|
38
|
-
|
|
39
|
-
geo_format
|
|
44
|
+
const {
|
|
45
|
+
geo_format
|
|
46
|
+
} = column.data || {};
|
|
40
47
|
if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE) {
|
|
41
48
|
update['x_axis_geolocation_granularity'] = GEOLOCATION_FORMAT_MAP.PROVINCE;
|
|
42
49
|
} else if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE_CITY) {
|
|
@@ -50,53 +57,69 @@ var DataSettings = function DataSettings(_ref) {
|
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
onChange && onChange(update);
|
|
53
|
-
}, [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
}, [chart, onChange]);
|
|
61
|
+
const onGroupbyDateGranularityChange = useCallback(option => {
|
|
62
|
+
const {
|
|
63
|
+
config
|
|
64
|
+
} = chart;
|
|
65
|
+
const {
|
|
66
|
+
x_axis_date_granularity
|
|
67
|
+
} = config;
|
|
68
|
+
const value = option.value;
|
|
58
69
|
if (value === x_axis_date_granularity) return;
|
|
59
70
|
onChange && onChange({
|
|
60
71
|
x_axis_date_granularity: value
|
|
61
72
|
});
|
|
62
|
-
}, [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
}, [chart, onChange]);
|
|
74
|
+
const onGroupbyGeolocationGranularityChange = useCallback(option => {
|
|
75
|
+
const {
|
|
76
|
+
config
|
|
77
|
+
} = chart;
|
|
78
|
+
const {
|
|
79
|
+
x_axis_geolocation_granularity
|
|
80
|
+
} = config;
|
|
81
|
+
const value = option.value;
|
|
67
82
|
if (value === x_axis_geolocation_granularity) return;
|
|
68
83
|
onChange && onChange({
|
|
69
84
|
x_axis_geolocation_granularity: value
|
|
70
85
|
});
|
|
71
|
-
}, [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
}, [chart, onChange]);
|
|
87
|
+
const onDateChange = useCallback((key, value) => {
|
|
88
|
+
const {
|
|
89
|
+
config
|
|
90
|
+
} = chart;
|
|
91
|
+
const oldValue = config[key];
|
|
75
92
|
if (value === oldValue) return;
|
|
76
|
-
onChange && onChange(
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
onChange && onChange({
|
|
94
|
+
[key]: value
|
|
95
|
+
});
|
|
96
|
+
}, [chart, onChange]);
|
|
97
|
+
const onDisplayIncreaseChange = useCallback(event => {
|
|
79
98
|
eventStopPropagation(event);
|
|
80
|
-
|
|
81
|
-
|
|
99
|
+
const {
|
|
100
|
+
config
|
|
101
|
+
} = chart;
|
|
102
|
+
const {
|
|
103
|
+
display_increase
|
|
104
|
+
} = config;
|
|
82
105
|
onChange && onChange({
|
|
83
106
|
display_increase: !display_increase
|
|
84
107
|
});
|
|
85
|
-
}, [
|
|
86
|
-
|
|
87
|
-
table_id
|
|
88
|
-
x_axis_column_key
|
|
89
|
-
x_axis_date_granularity
|
|
90
|
-
x_axis_geolocation_granularity
|
|
91
|
-
x_axis_date_range_start
|
|
92
|
-
x_axis_date_range_end
|
|
93
|
-
x_axis_compared_date_range_start
|
|
94
|
-
x_axis_compared_date_range_end
|
|
95
|
-
display_increase
|
|
108
|
+
}, [chart, onChange]);
|
|
109
|
+
const {
|
|
110
|
+
table_id,
|
|
111
|
+
x_axis_column_key,
|
|
112
|
+
x_axis_date_granularity,
|
|
113
|
+
x_axis_geolocation_granularity,
|
|
114
|
+
x_axis_date_range_start,
|
|
115
|
+
x_axis_date_range_end,
|
|
116
|
+
x_axis_compared_date_range_start,
|
|
117
|
+
x_axis_compared_date_range_end,
|
|
118
|
+
display_increase
|
|
119
|
+
} = chart.config;
|
|
96
120
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CommonDataSettings, {
|
|
97
|
-
|
|
121
|
+
chart: chart,
|
|
98
122
|
tables: tables,
|
|
99
|
-
FilterSettings: FilterSettings,
|
|
100
123
|
onChange: onChange
|
|
101
124
|
}), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(GroupBy, {
|
|
102
125
|
tables: tables,
|
|
@@ -110,41 +133,33 @@ var DataSettings = function DataSettings(_ref) {
|
|
|
110
133
|
onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
|
|
111
134
|
onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
|
|
112
135
|
}), /*#__PURE__*/React.createElement(FormGroup, {
|
|
113
|
-
className: "
|
|
136
|
+
className: "sea-chart-parameter-item"
|
|
114
137
|
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Date_range')), /*#__PURE__*/React.createElement("div", {
|
|
115
138
|
className: "time-input-container"
|
|
116
139
|
}, /*#__PURE__*/React.createElement(TimePicker, {
|
|
117
|
-
onChange:
|
|
118
|
-
return onDateChange('x_axis_date_range_start', value);
|
|
119
|
-
},
|
|
140
|
+
onChange: value => onDateChange('x_axis_date_range_start', value),
|
|
120
141
|
value: x_axis_date_range_start
|
|
121
142
|
}), /*#__PURE__*/React.createElement("div", {
|
|
122
143
|
className: "concat"
|
|
123
144
|
}, ' - '), /*#__PURE__*/React.createElement(TimePicker, {
|
|
124
|
-
onChange:
|
|
125
|
-
return onDateChange('x_axis_date_range_end', value);
|
|
126
|
-
},
|
|
145
|
+
onChange: value => onDateChange('x_axis_date_range_end', value),
|
|
127
146
|
value: x_axis_date_range_end
|
|
128
147
|
}))), /*#__PURE__*/React.createElement(FormGroup, {
|
|
129
|
-
className: "
|
|
148
|
+
className: "sea-chart-parameter-item"
|
|
130
149
|
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Compare_to_date_range')), /*#__PURE__*/React.createElement("div", {
|
|
131
150
|
className: "time-input-container"
|
|
132
151
|
}, /*#__PURE__*/React.createElement(TimePicker, {
|
|
133
|
-
onChange:
|
|
134
|
-
return onDateChange('x_axis_compared_date_range_start', value);
|
|
135
|
-
},
|
|
152
|
+
onChange: value => onDateChange('x_axis_compared_date_range_start', value),
|
|
136
153
|
value: x_axis_compared_date_range_start
|
|
137
154
|
}), /*#__PURE__*/React.createElement("div", {
|
|
138
155
|
className: "concat"
|
|
139
156
|
}, ' - '), /*#__PURE__*/React.createElement(TimePicker, {
|
|
140
|
-
onChange:
|
|
141
|
-
return onDateChange('x_axis_compared_date_range_end', value);
|
|
142
|
-
},
|
|
157
|
+
onChange: value => onDateChange('x_axis_compared_date_range_end', value),
|
|
143
158
|
value: x_axis_compared_date_range_end
|
|
144
159
|
}))), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(BasicSummary, {
|
|
145
160
|
className: "selected-y-axis",
|
|
146
161
|
label: intl.get('Y_axis'),
|
|
147
|
-
|
|
162
|
+
chart: chart,
|
|
148
163
|
selectedTableId: table_id,
|
|
149
164
|
tables: tables,
|
|
150
165
|
onChange: onChange
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { Label, FormGroup } from 'reactstrap';
|
|
3
|
+
import DTableSelect from "dtable-ui-component/lib/DTableSelect";
|
|
4
|
+
import Switch from '../widgets/switch';
|
|
5
|
+
import Divider from '../widgets/divider';
|
|
6
|
+
import MinMaxSetting from '../widgets/min-max-setting';
|
|
7
|
+
import { eventStopPropagation } from '../../utils';
|
|
8
|
+
import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW, LABEL_COLORS } from '../../constants';
|
|
9
|
+
import intl from '../../intl';
|
|
10
|
+
const StyleSettings = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
chart,
|
|
13
|
+
onChange
|
|
14
|
+
} = _ref;
|
|
15
|
+
const xAxisLabelOptions = useMemo(() => {
|
|
16
|
+
return X_LABEL_POSITIONS.map(item => {
|
|
17
|
+
return {
|
|
18
|
+
value: item,
|
|
19
|
+
label: intl.get(LABEL_POSITION_TYPE_SHOW[item])
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
23
|
+
const yAxisLabelOptions = useMemo(() => {
|
|
24
|
+
return Y_LABEL_POSITIONS.map(item => {
|
|
25
|
+
return {
|
|
26
|
+
value: item,
|
|
27
|
+
label: intl.get(LABEL_POSITION_TYPE_SHOW[item])
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
const onAxisLabelShowChange = useCallback((event, labelKey) => {
|
|
32
|
+
eventStopPropagation(event);
|
|
33
|
+
const {
|
|
34
|
+
config
|
|
35
|
+
} = chart;
|
|
36
|
+
const value = config[labelKey];
|
|
37
|
+
onChange && onChange({
|
|
38
|
+
[labelKey]: !value
|
|
39
|
+
});
|
|
40
|
+
}, [chart, onChange]);
|
|
41
|
+
const onAxisLabelPositionChange = useCallback((option, positionKey) => {
|
|
42
|
+
const position = option.value;
|
|
43
|
+
const {
|
|
44
|
+
config
|
|
45
|
+
} = chart;
|
|
46
|
+
const oldValue = config[positionKey];
|
|
47
|
+
if (position === oldValue) return;
|
|
48
|
+
onChange && onChange({
|
|
49
|
+
[positionKey]: position
|
|
50
|
+
});
|
|
51
|
+
}, [chart, onChange]);
|
|
52
|
+
const onYAxisAutoRangeChange = useCallback(event => {
|
|
53
|
+
eventStopPropagation(event);
|
|
54
|
+
const {
|
|
55
|
+
config
|
|
56
|
+
} = chart;
|
|
57
|
+
const {
|
|
58
|
+
y_axis_auto_range
|
|
59
|
+
} = config;
|
|
60
|
+
onChange && onChange({
|
|
61
|
+
y_axis_auto_range: !y_axis_auto_range
|
|
62
|
+
});
|
|
63
|
+
}, [chart, onChange]);
|
|
64
|
+
const onYAxisMinChange = useCallback(min => {
|
|
65
|
+
const newMin = parseInt(min);
|
|
66
|
+
if (Number.isNaN(newMin)) return;
|
|
67
|
+
const {
|
|
68
|
+
config
|
|
69
|
+
} = chart;
|
|
70
|
+
const {
|
|
71
|
+
y_axis_min
|
|
72
|
+
} = config;
|
|
73
|
+
if (y_axis_min === newMin) return;
|
|
74
|
+
onChange && onChange({
|
|
75
|
+
y_axis_min: newMin
|
|
76
|
+
});
|
|
77
|
+
}, [chart, onChange]);
|
|
78
|
+
const onYAxisMaxChange = useCallback(max => {
|
|
79
|
+
const newMax = parseInt(max);
|
|
80
|
+
if (Number.isNaN(newMax)) return;
|
|
81
|
+
const {
|
|
82
|
+
config
|
|
83
|
+
} = chart;
|
|
84
|
+
const {
|
|
85
|
+
y_axis_max
|
|
86
|
+
} = config;
|
|
87
|
+
if (y_axis_max === newMax) return;
|
|
88
|
+
onChange && onChange({
|
|
89
|
+
y_axis_max: newMax
|
|
90
|
+
});
|
|
91
|
+
}, [chart, onChange]);
|
|
92
|
+
const onDisplayValueChange = useCallback(event => {
|
|
93
|
+
eventStopPropagation(event);
|
|
94
|
+
const {
|
|
95
|
+
config
|
|
96
|
+
} = chart;
|
|
97
|
+
const {
|
|
98
|
+
y_axis_show_value
|
|
99
|
+
} = config;
|
|
100
|
+
onChange && onChange({
|
|
101
|
+
y_axis_show_value: !y_axis_show_value
|
|
102
|
+
});
|
|
103
|
+
}, [chart, onChange]);
|
|
104
|
+
const onDisplayPercentageIncreaseChange = useCallback(event => {
|
|
105
|
+
eventStopPropagation(event);
|
|
106
|
+
const {
|
|
107
|
+
config
|
|
108
|
+
} = chart;
|
|
109
|
+
const {
|
|
110
|
+
display_increase_percentage
|
|
111
|
+
} = config;
|
|
112
|
+
onChange && onChange({
|
|
113
|
+
display_increase_percentage: !display_increase_percentage
|
|
114
|
+
});
|
|
115
|
+
}, [chart, onChange]);
|
|
116
|
+
const onIncreaseDisplayColorChang = useCallback((event, value) => {
|
|
117
|
+
eventStopPropagation(event);
|
|
118
|
+
const {
|
|
119
|
+
config
|
|
120
|
+
} = chart;
|
|
121
|
+
const {
|
|
122
|
+
increase_display_color
|
|
123
|
+
} = config;
|
|
124
|
+
if (increase_display_color === value) return;
|
|
125
|
+
onChange && onChange({
|
|
126
|
+
increase_display_color: value
|
|
127
|
+
});
|
|
128
|
+
}, [chart, onChange]);
|
|
129
|
+
const {
|
|
130
|
+
config
|
|
131
|
+
} = chart;
|
|
132
|
+
const {
|
|
133
|
+
x_axis_show_label,
|
|
134
|
+
x_axis_label_position,
|
|
135
|
+
y_axis_show_label,
|
|
136
|
+
y_axis_label_position,
|
|
137
|
+
y_axis_auto_range = true,
|
|
138
|
+
y_axis_min,
|
|
139
|
+
y_axis_max,
|
|
140
|
+
y_axis_show_value,
|
|
141
|
+
display_increase,
|
|
142
|
+
display_increase_percentage,
|
|
143
|
+
increase_display_color
|
|
144
|
+
} = config;
|
|
145
|
+
const xAxisLabelPosition = xAxisLabelOptions.find(option => option.value === x_axis_label_position) || xAxisLabelOptions[0];
|
|
146
|
+
const yAxisLabelPosition = yAxisLabelOptions.find(option => option.value === y_axis_label_position) || yAxisLabelOptions[0];
|
|
147
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
|
|
148
|
+
className: "sea-chart-parameter-item"
|
|
149
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('X_axis')), /*#__PURE__*/React.createElement(Switch, {
|
|
150
|
+
key: "x_axis_show_label",
|
|
151
|
+
checked: x_axis_show_label || false,
|
|
152
|
+
placeholder: intl.get('Display_title'),
|
|
153
|
+
onChange: event => onAxisLabelShowChange(event, 'x_axis_show_label')
|
|
154
|
+
}), x_axis_show_label && /*#__PURE__*/React.createElement(DTableSelect, {
|
|
155
|
+
value: xAxisLabelPosition,
|
|
156
|
+
options: xAxisLabelOptions,
|
|
157
|
+
onChange: option => onAxisLabelPositionChange(option, 'x_axis_label_position')
|
|
158
|
+
})), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
|
|
159
|
+
className: "sea-chart-parameter-item"
|
|
160
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Y_axis')), /*#__PURE__*/React.createElement(Switch, {
|
|
161
|
+
key: "y_axis_show_label",
|
|
162
|
+
checked: y_axis_show_label || false,
|
|
163
|
+
placeholder: intl.get('Display_title'),
|
|
164
|
+
onChange: event => onAxisLabelShowChange(event, 'y_axis_show_label')
|
|
165
|
+
}), y_axis_show_label && /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
className: "sea-chart-parameter-container"
|
|
167
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
168
|
+
value: yAxisLabelPosition,
|
|
169
|
+
classNamePrefix: "chart-y-axis-label-position",
|
|
170
|
+
options: yAxisLabelOptions,
|
|
171
|
+
onChange: option => onAxisLabelPositionChange(option, 'y_axis_label_position')
|
|
172
|
+
})), /*#__PURE__*/React.createElement(Switch, {
|
|
173
|
+
key: "y_axis_auto_range",
|
|
174
|
+
checked: y_axis_auto_range,
|
|
175
|
+
placeholder: intl.get('Auto_range'),
|
|
176
|
+
onChange: onYAxisAutoRangeChange
|
|
177
|
+
}), !y_axis_auto_range && /*#__PURE__*/React.createElement(MinMaxSetting, {
|
|
178
|
+
min: y_axis_min,
|
|
179
|
+
max: y_axis_max,
|
|
180
|
+
onMinChange: onYAxisMinChange,
|
|
181
|
+
onMaxChange: onYAxisMaxChange
|
|
182
|
+
})), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(Switch, {
|
|
183
|
+
key: "y_axis_show_value",
|
|
184
|
+
checked: y_axis_show_value,
|
|
185
|
+
placeholder: intl.get('Display_value'),
|
|
186
|
+
onChange: onDisplayValueChange
|
|
187
|
+
}), display_increase && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
|
|
188
|
+
className: "sea-chart-parameter-item"
|
|
189
|
+
}, /*#__PURE__*/React.createElement(Switch, {
|
|
190
|
+
key: "display_increase_percentage",
|
|
191
|
+
checked: display_increase_percentage || false,
|
|
192
|
+
placeholder: intl.get('Display_percentage_increase'),
|
|
193
|
+
onChange: onDisplayPercentageIncreaseChange
|
|
194
|
+
}), /*#__PURE__*/React.createElement(Label, null, intl.get('Color')), /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: "d-flex align-items-center justify-content-between"
|
|
196
|
+
}, LABEL_COLORS.map((item, index) => {
|
|
197
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
key: "y-axis-label-color-".concat(index)
|
|
199
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
200
|
+
className: "colorinput"
|
|
201
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
202
|
+
className: "colorinput-color chart-colorinput d-flex justify-content-center align-items-center",
|
|
203
|
+
onClick: event => onIncreaseDisplayColorChang(event, item),
|
|
204
|
+
style: {
|
|
205
|
+
backgroundColor: item,
|
|
206
|
+
borderColor: item
|
|
207
|
+
}
|
|
208
|
+
}, item === (increase_display_color || LABEL_COLORS[3]) && /*#__PURE__*/React.createElement("i", {
|
|
209
|
+
className: "dtable-font dtable-icon-check-mark chart-check-mark"
|
|
210
|
+
}))));
|
|
211
|
+
})))));
|
|
212
|
+
};
|
|
213
|
+
export default StyleSettings;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.sea-chart-settings .summary-type-explanation {
|
|
2
|
+
color: #9c9c9c;
|
|
3
|
+
font-size: 12px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sea-chart-settings .chart-summary-types__option--is-selected .summary-type-explanation {
|
|
7
|
+
color: #9c9c9c !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.sea-chart-settings .chart-summary-types__value-container .summary-type-explanation {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { Label, FormGroup } from 'reactstrap';
|
|
3
|
+
import DTableSelect from "dtable-ui-component/lib/DTableSelect";
|
|
4
|
+
import { COLUMNS_ICON_CONFIG, CellType, getTableById } from 'dtable-utils';
|
|
5
|
+
import { ChartUtils } from '../../../utils';
|
|
6
|
+
import { CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPES, CHART_SUMMARY_TYPE, CHART_SUMMARY_CALCULATION_METHOD, CHART_DATE_SUMMARY_CALCULATION_METHOD } from '../../../constants';
|
|
7
|
+
import intl from '../../../intl';
|
|
8
|
+
import './index.css';
|
|
9
|
+
const BasicSummary = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
tables,
|
|
12
|
+
chart,
|
|
13
|
+
onChange,
|
|
14
|
+
summaryTypeOptions: oldSummaryTypeOptions,
|
|
15
|
+
summaryTypeKey,
|
|
16
|
+
summaryColumnKey,
|
|
17
|
+
summaryMethodKey,
|
|
18
|
+
showSummaryTypes = true,
|
|
19
|
+
label,
|
|
20
|
+
supportColumnTypes
|
|
21
|
+
} = _ref;
|
|
22
|
+
const selectedTable = useMemo(() => {
|
|
23
|
+
const {
|
|
24
|
+
table_id
|
|
25
|
+
} = chart.config;
|
|
26
|
+
return getTableById(tables, table_id);
|
|
27
|
+
}, [tables, chart.config]);
|
|
28
|
+
const numericColumns = useMemo(() => {
|
|
29
|
+
if (!selectedTable) return [];
|
|
30
|
+
const {
|
|
31
|
+
columns
|
|
32
|
+
} = selectedTable;
|
|
33
|
+
return columns.filter(column => supportColumnTypes.includes(CellType.NUMBER) && ChartUtils.isNumericSummaryColumn(column) || supportColumnTypes.includes(CellType.DATE) && ChartUtils.isDateSummaryColumn(column));
|
|
34
|
+
}, [selectedTable, supportColumnTypes]);
|
|
35
|
+
const numericColumnOptions = useMemo(() => {
|
|
36
|
+
return numericColumns.map(column => {
|
|
37
|
+
return {
|
|
38
|
+
value: column.key,
|
|
39
|
+
column: column,
|
|
40
|
+
label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
41
|
+
className: "sea-chart-column-icon"
|
|
42
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
43
|
+
className: COLUMNS_ICON_CONFIG[column.type]
|
|
44
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "select-module select-module-name ml-0"
|
|
46
|
+
}, column.name))
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}, [numericColumns]);
|
|
50
|
+
const summaryTypeOptions = useMemo(() => {
|
|
51
|
+
const summaryExplanation = ChartUtils.getSummaryExplanation(chart);
|
|
52
|
+
return Array.isArray(oldSummaryTypeOptions) ? oldSummaryTypeOptions.map(summaryType => {
|
|
53
|
+
return {
|
|
54
|
+
value: summaryType,
|
|
55
|
+
label: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: "select-module select-module-name ml-0"
|
|
57
|
+
}, intl.get(CHART_SUMMARY_SHOW[summaryType])), /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: "summary-type-explanation"
|
|
59
|
+
}, summaryExplanation[summaryType]))
|
|
60
|
+
};
|
|
61
|
+
}) : [];
|
|
62
|
+
}, [chart, oldSummaryTypeOptions]);
|
|
63
|
+
const summaryMethodOptions = useMemo(() => {
|
|
64
|
+
const summaryColumn = numericColumns.find(column => column.key === chart.config[summaryColumnKey]);
|
|
65
|
+
const methods = ChartUtils.isNumericSummaryColumn(summaryColumn) ? CHART_SUMMARY_CALCULATION_METHOD : CHART_DATE_SUMMARY_CALCULATION_METHOD;
|
|
66
|
+
return methods.map(item => {
|
|
67
|
+
return {
|
|
68
|
+
value: item,
|
|
69
|
+
label: intl.get(CHART_SUMMARY_SHOW[item])
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}, [chart, numericColumns, summaryColumnKey]);
|
|
73
|
+
const onSummaryTypeChange = useCallback(option => {
|
|
74
|
+
const summaryType = option.value;
|
|
75
|
+
const {
|
|
76
|
+
config
|
|
77
|
+
} = chart;
|
|
78
|
+
const oldValue = config[summaryTypeKey];
|
|
79
|
+
if (summaryType === oldValue) return;
|
|
80
|
+
let update = {
|
|
81
|
+
[summaryTypeKey]: summaryType,
|
|
82
|
+
[summaryColumnKey]: '',
|
|
83
|
+
[summaryMethodKey]: ''
|
|
84
|
+
};
|
|
85
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
86
|
+
update[summaryMethodKey] = CHART_SUMMARY_CALCULATION_METHOD[0];
|
|
87
|
+
}
|
|
88
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED && numericColumns[0]) {
|
|
89
|
+
update[summaryColumnKey] = numericColumns[0].key;
|
|
90
|
+
}
|
|
91
|
+
onChange && onChange(update);
|
|
92
|
+
}, [chart, summaryTypeKey, summaryColumnKey, summaryMethodKey, onChange, numericColumns]);
|
|
93
|
+
const onSummaryColumnChange = useCallback(option => {
|
|
94
|
+
const value = option.value;
|
|
95
|
+
const {
|
|
96
|
+
config
|
|
97
|
+
} = chart;
|
|
98
|
+
const oldValue = config[summaryColumnKey];
|
|
99
|
+
if (value === oldValue) return;
|
|
100
|
+
let update = {
|
|
101
|
+
[summaryColumnKey]: value,
|
|
102
|
+
[summaryMethodKey]: config[summaryMethodKey]
|
|
103
|
+
};
|
|
104
|
+
const oldColumn = numericColumns.find(column => column.key === oldValue);
|
|
105
|
+
const newColumn = numericColumns.find(column => column.key === value);
|
|
106
|
+
const isDateColumn = ChartUtils.isDateSummaryColumn(newColumn);
|
|
107
|
+
if (ChartUtils.isDateSummaryColumn(oldColumn) !== isDateColumn) {
|
|
108
|
+
const methods = isDateColumn ? CHART_DATE_SUMMARY_CALCULATION_METHOD : CHART_SUMMARY_CALCULATION_METHOD;
|
|
109
|
+
if (!methods.includes(config[summaryMethodKey])) {
|
|
110
|
+
update[summaryMethodKey] = methods[0];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
onChange && onChange(update);
|
|
114
|
+
}, [chart, summaryColumnKey, summaryMethodKey, onChange, numericColumns]);
|
|
115
|
+
const onSummaryMethodChange = useCallback(option => {
|
|
116
|
+
const value = option.value;
|
|
117
|
+
const {
|
|
118
|
+
config
|
|
119
|
+
} = chart;
|
|
120
|
+
const oldValue = config[summaryMethodKey];
|
|
121
|
+
if (value === oldValue) return;
|
|
122
|
+
onChange && onChange({
|
|
123
|
+
[summaryMethodKey]: value
|
|
124
|
+
});
|
|
125
|
+
}, [chart, summaryMethodKey, onChange]);
|
|
126
|
+
const renderNumericColumn = useCallback(() => {
|
|
127
|
+
const column_key = chart.config[summaryColumnKey];
|
|
128
|
+
const selectedColumnOption = numericColumnOptions.find(option => option.value === column_key);
|
|
129
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
130
|
+
className: "sea-chart-parameter-item"
|
|
131
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Summary_field')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
132
|
+
value: selectedColumnOption,
|
|
133
|
+
onChange: onSummaryColumnChange,
|
|
134
|
+
options: numericColumnOptions,
|
|
135
|
+
placeholder: intl.get('Select_a_column'),
|
|
136
|
+
noOptionsMessage: () => {
|
|
137
|
+
return /*#__PURE__*/React.createElement("span", null, intl.get('No_options'));
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}, [chart, summaryColumnKey, numericColumnOptions, onSummaryColumnChange]);
|
|
141
|
+
const renderSummaryMethod = useCallback(() => {
|
|
142
|
+
const summaryMethod = chart.config[summaryMethodKey];
|
|
143
|
+
const selectedMethodOption = summaryMethodOptions.find(option => option.value === summaryMethod);
|
|
144
|
+
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
145
|
+
className: "sea-chart-parameter-item"
|
|
146
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
147
|
+
value: selectedMethodOption,
|
|
148
|
+
onChange: onSummaryMethodChange,
|
|
149
|
+
options: summaryMethodOptions
|
|
150
|
+
}));
|
|
151
|
+
}, [chart, summaryMethodKey, onSummaryMethodChange, summaryMethodOptions]);
|
|
152
|
+
const renderOtherSummaries = useCallback(() => {
|
|
153
|
+
const summaryType = chart.config[summaryTypeKey] || CHART_SUMMARY_TYPE.COUNT;
|
|
154
|
+
if (summaryType !== CHART_SUMMARY_TYPE.ADVANCED) return null;
|
|
155
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, renderNumericColumn(), renderSummaryMethod());
|
|
156
|
+
}, [summaryTypeKey, chart, renderNumericColumn, renderSummaryMethod]);
|
|
157
|
+
const summaryType = chart.config[summaryTypeKey] || CHART_SUMMARY_TYPE.COUNT;
|
|
158
|
+
const selectedSummaryTypeOption = summaryTypeOptions.find(item => item.value === summaryType) || summaryTypeOptions[0];
|
|
159
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showSummaryTypes && /*#__PURE__*/React.createElement(FormGroup, {
|
|
160
|
+
className: "sea-chart-parameter-item"
|
|
161
|
+
}, /*#__PURE__*/React.createElement(Label, null, label), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
162
|
+
classNamePrefix: "chart-summary-types",
|
|
163
|
+
value: selectedSummaryTypeOption,
|
|
164
|
+
onChange: onSummaryTypeChange,
|
|
165
|
+
options: summaryTypeOptions
|
|
166
|
+
})), renderOtherSummaries());
|
|
167
|
+
};
|
|
168
|
+
BasicSummary.defaultProps = {
|
|
169
|
+
showSummaryTypes: true,
|
|
170
|
+
summaryTypeKey: 'y_axis_summary_type',
|
|
171
|
+
summaryMethodKey: 'y_axis_summary_method',
|
|
172
|
+
summaryColumnKey: 'y_axis_summary_column_key',
|
|
173
|
+
supportColumnTypes: [CellType.NUMBER, CellType.DATE],
|
|
174
|
+
summaryTypeOptions: CHART_SUMMARY_TYPES
|
|
175
|
+
};
|
|
176
|
+
export default BasicSummary;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.sea-chart-settings .sea-chart-selected-type-container {
|
|
2
2
|
height: 38px;
|
|
3
3
|
border: 1px solid hsl(0, 0%, 80%);
|
|
4
4
|
border-radius: 4px;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
justify-content: space-between;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
10
|
+
.sea-chart-settings .sea-chart-type-icon-container {
|
|
11
11
|
height: 24px;
|
|
12
12
|
width: 24px;
|
|
13
13
|
margin-left: 10px;
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
justify-content: center;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.
|
|
19
|
+
.sea-chart-settings .sea-chart-type-icon-container:hover {
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.
|
|
23
|
+
.sea-chart-settings .sea-chart-type-icon-container .sea-chart-type-icon {
|
|
24
24
|
height: 14px;
|
|
25
25
|
width: 14px;
|
|
26
26
|
color: #ccc;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.
|
|
29
|
+
.sea-chart-settings .sea-chart-type-icon-container:hover .sea-chart-type-icon {
|
|
30
30
|
color: #999;
|
|
31
31
|
}
|