dtable-statistic 4.0.3 → 4.0.5

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.
Files changed (76) hide show
  1. package/es/assets/css/dashboard.css +6 -7
  2. package/es/assets/css/theme.css +4 -0
  3. package/es/assets/icons/switch-icon.svg +17 -0
  4. package/es/calculator/workers/basic-chart-calculator-worker.js +1 -1
  5. package/es/components/dialog/chart-addition-edit-dialog.js +1 -0
  6. package/es/components/dialog/chart-addition-widgets/chart-selector.js +2 -1
  7. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +9 -0
  8. package/es/components/dialog/statistic-types-dialog/index.css +14 -0
  9. package/es/components/dialog/statistic-types-dialog/index.js +63 -0
  10. package/es/components/icon.js +12 -0
  11. package/es/constants/index.js +17 -6
  12. package/es/constants/model.js +20 -0
  13. package/es/dashboard.js +47 -9
  14. package/es/desktop-dashboard.js +9 -8
  15. package/es/locale/lang/de.js +6 -4
  16. package/es/locale/lang/en.js +4 -2
  17. package/es/locale/lang/fr.js +6 -4
  18. package/es/locale/lang/zh_CN.js +4 -2
  19. package/es/model/bar-group.js +60 -0
  20. package/es/model/bar.js +49 -0
  21. package/es/model/base-model.js +12 -0
  22. package/es/model/basic-number-card.js +27 -0
  23. package/es/model/combination.js +50 -0
  24. package/es/model/compare-bar.js +58 -0
  25. package/es/model/completeness-group.js +33 -0
  26. package/es/model/completeness.js +27 -0
  27. package/es/model/custom-bar.js +27 -0
  28. package/es/model/dashboard.js +22 -0
  29. package/es/model/generic-model.js +219 -0
  30. package/es/model/heat-map.js +35 -0
  31. package/es/model/horizontal-bar-group.js +55 -0
  32. package/es/model/horizontal-bar.js +49 -0
  33. package/es/model/index.js +26 -0
  34. package/es/model/map.js +37 -0
  35. package/es/model/mirror.js +35 -0
  36. package/es/model/pie.js +40 -0
  37. package/es/model/ring.js +41 -0
  38. package/es/model/scatter.js +24 -0
  39. package/es/model/table.js +34 -0
  40. package/es/model/trend.js +34 -0
  41. package/es/model/world-map.js +36 -0
  42. package/es/service/chart-service.js +47 -169
  43. package/es/service/dashboard-service.js +6 -5
  44. package/es/stat-editor/index.js +2 -0
  45. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +1 -0
  46. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +1 -0
  47. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +1 -0
  48. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +4 -3
  49. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +9 -10
  50. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +7 -31
  51. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +4 -3
  52. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +4 -3
  53. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +5 -29
  54. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +1 -0
  55. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -0
  56. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +1 -0
  57. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +1 -0
  58. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +1 -0
  59. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +1 -0
  60. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +10 -0
  61. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +1 -0
  62. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +1 -0
  63. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +1 -0
  64. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -0
  65. package/es/stat-editor/stat-settings/public-setting/base-settings.js +22 -1
  66. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +29 -0
  67. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +58 -0
  68. package/es/stat-view/pie-chart.js +2 -2
  69. package/es/stat-view/ring-chart.js +2 -2
  70. package/es/utils/column-utils.js +69 -2
  71. package/es/utils/common-utils.js +3 -0
  72. package/es/utils/model.js +13 -0
  73. package/es/utils/row-utils.js +1 -0
  74. package/es/utils/stat-utils.js +4 -0
  75. package/package.json +2 -1
  76. package/es/model/stat-item.js +0 -340
@@ -57,6 +57,7 @@ var StatEditor = /*#__PURE__*/function (_Component) {
57
57
  getTables: getTables,
58
58
  getViews: getViews,
59
59
  getTableById: getTableById,
60
+ getConvertedChart: this.props.getConvertedChart,
60
61
  updateStatItem: this.props.modifyChart
61
62
  }) : /*#__PURE__*/React.createElement(AdvancedChartSettings, {
62
63
  statItem: statItem,
@@ -65,6 +66,7 @@ var StatEditor = /*#__PURE__*/function (_Component) {
65
66
  getTables: getTables,
66
67
  getViews: getViews,
67
68
  getTableById: getTableById,
69
+ getConvertedChart: this.props.getConvertedChart,
68
70
  updateStatItem: this.props.modifyChart
69
71
  }));
70
72
  }
@@ -130,6 +130,7 @@ var BasicNumberCardSettings = /*#__PURE__*/function (_Component) {
130
130
  getTables: this.props.getTables,
131
131
  getViews: this.props.getViews,
132
132
  getTableById: this.props.getTableById,
133
+ getConvertedChart: this.props.getConvertedChart,
133
134
  updateStatItem: updateStatItem
134
135
  }), /*#__PURE__*/React.createElement("div", {
135
136
  className: "statistic-chart-parameter-divider"
@@ -358,6 +358,7 @@ var CombinationSettings = /*#__PURE__*/function (_Component) {
358
358
  getTables: getTables,
359
359
  getViews: getViews,
360
360
  getTableById: this.props.getTableById,
361
+ getConvertedChart: this.props.getConvertedChart,
361
362
  updateStatItem: updateStatItem
362
363
  }), /*#__PURE__*/React.createElement("div", {
363
364
  className: "statistic-chart-parameter-divider"
@@ -164,6 +164,7 @@ var DashboardChartSettings = /*#__PURE__*/function (_Component) {
164
164
  getTables: getTables,
165
165
  getViews: getViews,
166
166
  getTableById: this.props.getTableById,
167
+ getConvertedChart: this.props.getConvertedChart,
167
168
  updateStatItem: updateStatItem
168
169
  }), /*#__PURE__*/React.createElement("div", {
169
170
  className: "statistic-chart-parameter-divider"
@@ -8,7 +8,7 @@ import BaseSettings from '../public-setting/base-settings';
8
8
  import ColumnSettings from '../public-setting/column-settings';
9
9
  import SummarySettings from './summary-settings';
10
10
  import StyleSettings from './style-setting/heat-map-settings';
11
- import { TIME_COLUMN_LIST } from '../../../constants';
11
+ import { isStatisticDateColumn } from '../../../utils/column-utils';
12
12
  var HeatMapSettings = /*#__PURE__*/function (_Component) {
13
13
  _inherits(HeatMapSettings, _Component);
14
14
  var _super = _createSuper(HeatMapSettings);
@@ -32,7 +32,7 @@ var HeatMapSettings = /*#__PURE__*/function (_Component) {
32
32
  var columns = props.columns,
33
33
  getColumnsOptions = props.getColumnsOptions;
34
34
  var dateColumns = columns.filter(function (column) {
35
- return TIME_COLUMN_LIST.includes(column.type);
35
+ return isStatisticDateColumn(column);
36
36
  });
37
37
  _this.dateColumnsOptions = getColumnsOptions(dateColumns);
38
38
  return _this;
@@ -44,7 +44,7 @@ var HeatMapSettings = /*#__PURE__*/function (_Component) {
44
44
  var columns = nextProps.columns,
45
45
  getColumnsOptions = nextProps.getColumnsOptions;
46
46
  var dateColumns = columns.filter(function (column) {
47
- return TIME_COLUMN_LIST.includes(column.type);
47
+ return isStatisticDateColumn(column);
48
48
  });
49
49
  this.dateColumnsOptions = getColumnsOptions(dateColumns);
50
50
  }
@@ -76,6 +76,7 @@ var HeatMapSettings = /*#__PURE__*/function (_Component) {
76
76
  getTables: getTables,
77
77
  getViews: getViews,
78
78
  getTableById: this.props.getTableById,
79
+ getConvertedChart: this.props.getConvertedChart,
79
80
  updateStatItem: this.props.updateStatItem
80
81
  }), /*#__PURE__*/React.createElement("div", {
81
82
  className: "statistic-chart-parameter-divider"
@@ -26,13 +26,6 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
26
26
  var _this;
27
27
  _classCallCheck(this, AdvancedChartSettings);
28
28
  _this = _super.call(this, props);
29
- _this.getDefaultColumnGroupbyType = function (_ref) {
30
- var summary_type = _ref.summary_type;
31
- if (summary_type === SUMMARY_TYPE.ADVANCED) {
32
- return GROUP_TYPES.SINGLE_NUMERIC_COLUMN;
33
- }
34
- return GROUP_TYPES.COUNT;
35
- };
36
29
  _this.getNumericColumns = function (columns) {
37
30
  if (!columns) return [];
38
31
  return columns.filter(function (column) {
@@ -67,6 +60,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
67
60
  getViews: getViews,
68
61
  getTableById: getTableById,
69
62
  getColumnsOptions: _this.getColumnsOptions,
63
+ getConvertedChart: _this.props.getConvertedChart,
70
64
  updateStatItem: updateStatItem,
71
65
  onChangeSummaryType: _this.onChangeSummaryType,
72
66
  onSelectSummaryColumn: _this.onSelectSummaryColumn,
@@ -89,6 +83,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
89
83
  getTables: getTables,
90
84
  getViews: getViews,
91
85
  getTableById: getTableById,
86
+ getConvertedChart: _this.props.getConvertedChart,
92
87
  updateStatItem: updateStatItem,
93
88
  onChangeSummaryType: _this.onChangeSummaryType,
94
89
  onSelectSummaryColumn: _this.onSelectSummaryColumn,
@@ -110,6 +105,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
110
105
  getTables: getTables,
111
106
  getViews: getViews,
112
107
  getTableById: getTableById,
108
+ getConvertedChart: _this.props.getConvertedChart,
113
109
  updateStatItem: updateStatItem,
114
110
  onChangeSummaryType: _this.onChangeSummaryType,
115
111
  onSelectSummaryColumn: _this.onSelectSummaryColumn,
@@ -131,6 +127,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
131
127
  getTables: getTables,
132
128
  getViews: getViews,
133
129
  getTableById: getTableById,
130
+ getConvertedChart: _this.props.getConvertedChart,
134
131
  updateStatItem: updateStatItem,
135
132
  onChangeSummaryType: _this.onChangeSummaryType,
136
133
  onSelectSummaryColumn: _this.onSelectSummaryColumn,
@@ -148,6 +145,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
148
145
  getTables: getTables,
149
146
  getViews: getViews,
150
147
  getTableById: getTableById,
148
+ getConvertedChart: _this.props.getConvertedChart,
151
149
  updateStatItem: updateStatItem,
152
150
  numericColumns: _this.numericColumns,
153
151
  getColumnsOptions: _this.getColumnsOptions,
@@ -167,6 +165,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
167
165
  getTables: getTables,
168
166
  getViews: getViews,
169
167
  getTableById: getTableById,
168
+ getConvertedChart: _this.props.getConvertedChart,
170
169
  updateStatItem: updateStatItem,
171
170
  numericColumns: _this.numericColumns,
172
171
  getColumnsOptions: _this.getColumnsOptions
@@ -186,6 +185,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
186
185
  getTables: getTables,
187
186
  getViews: getViews,
188
187
  getTableById: getTableById,
188
+ getConvertedChart: _this.props.getConvertedChart,
189
189
  updateStatItem: updateStatItem,
190
190
  onChangeSummaryType: _this.onChangeSummaryType,
191
191
  onSelectSummaryColumn: _this.onSelectSummaryColumn,
@@ -203,6 +203,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
203
203
  getTables: getTables,
204
204
  getViews: getViews,
205
205
  getTableById: getTableById,
206
+ getConvertedChart: _this.props.getConvertedChart,
206
207
  updateStatItem: updateStatItem,
207
208
  numericColumns: _this.numericColumns,
208
209
  getColumnsOptions: _this.getColumnsOptions
@@ -237,7 +238,7 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
237
238
  summary_type = _this$props$statItem.summary_type,
238
239
  summary_column = _this$props$statItem.summary_column,
239
240
  summary_method = _this$props$statItem.summary_method;
240
- if (summaryType === _this.columnGroupbyType) return;
241
+ if (summaryType === summary_type) return;
241
242
  if (summaryType === GROUP_TYPES.SINGLE_NUMERIC_COLUMN) {
242
243
  var defaultColumn = _this.numericColumns[0];
243
244
  summary_column = defaultColumn ? defaultColumn.key : null;
@@ -248,7 +249,6 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
248
249
  summary_method = null;
249
250
  summary_column = null;
250
251
  }
251
- _this.columnGroupbyType = summaryType;
252
252
  _this.props.updateStatItem(Object.assign({}, _this.props.statItem, {
253
253
  summary_type: summary_type,
254
254
  summary_column: summary_column,
@@ -287,7 +287,6 @@ var AdvancedChartSettings = /*#__PURE__*/function (_React$Component) {
287
287
  _this.state = {
288
288
  settingType: 'data'
289
289
  };
290
- _this.columnGroupbyType = _this.getDefaultColumnGroupbyType(_statItem);
291
290
  return _this;
292
291
  }
293
292
  _createClass(AdvancedChartSettings, [{
@@ -3,12 +3,12 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React, { Component, Fragment } from 'react';
6
- import { CellType, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES } from 'dtable-store';
7
6
  import BaseSettings from '../public-setting/base-settings';
8
7
  import ColumnSettings from '../public-setting/column-settings';
9
8
  import GeoGranularitySettings from './geo-granularity-settings';
10
9
  import SummarySettings from './summary-settings';
11
10
  import MapStyleSetting from './style-setting/map-setting';
11
+ import { isMapColumn } from '../../../utils/column-utils';
12
12
  import { GEOLOCATION_GRANULARITY } from '../../../constants';
13
13
  var MapSettings = /*#__PURE__*/function (_Component) {
14
14
  _inherits(MapSettings, _Component);
@@ -18,35 +18,10 @@ var MapSettings = /*#__PURE__*/function (_Component) {
18
18
  _classCallCheck(this, MapSettings);
19
19
  _this = _super.call(this, props);
20
20
  _this.getColumns = function (columns) {
21
- var geoColumns = columns.filter(function (column) {
22
- var type = column.type,
23
- data = column.data;
24
- if (type === CellType.GEOLOCATION) {
25
- var _ref = data || {},
26
- geo_format = _ref.geo_format;
27
- if (geo_format === 'lng_lat' || geo_format === 'country_region') {
28
- return false;
29
- }
30
- return true;
31
- }
32
- if (FORMULA_COLUMN_TYPES.includes(type)) {
33
- var _ref2 = data || {},
34
- result_type = _ref2.result_type,
35
- array_type = _ref2.array_type,
36
- array_data = _ref2.array_data;
37
- if (result_type !== FORMULA_RESULT_TYPE.ARRAY || array_type !== CellType.GEOLOCATION) {
38
- return false;
39
- }
40
- var _ref3 = array_data || {},
41
- _geo_format = _ref3.geo_format;
42
- if (_geo_format === 'lng_lat' || _geo_format === 'country_region') {
43
- return false;
44
- }
45
- return true;
46
- }
47
- return false;
21
+ if (!Array.isArray(columns) || columns.length === 0) return [];
22
+ return columns.filter(function (column) {
23
+ return isMapColumn(column);
48
24
  });
49
- return geoColumns;
50
25
  };
51
26
  _this.getGeoGranularityOptions = function () {
52
27
  return [{
@@ -90,8 +65,8 @@ var MapSettings = /*#__PURE__*/function (_Component) {
90
65
  };
91
66
  var _columns = props.columns,
92
67
  getColumnsOptions = props.getColumnsOptions;
93
- var _geoColumns = _this.getColumns(_columns);
94
- _this.geoColumnsOptions = getColumnsOptions(_geoColumns);
68
+ var geoColumns = _this.getColumns(_columns);
69
+ _this.geoColumnsOptions = getColumnsOptions(geoColumns);
95
70
  _this.geoGranularityOptions = _this.getGeoGranularityOptions();
96
71
  return _this;
97
72
  }
@@ -133,6 +108,7 @@ var MapSettings = /*#__PURE__*/function (_Component) {
133
108
  getTables: getTables,
134
109
  getViews: getViews,
135
110
  getTableById: this.props.getTableById,
111
+ getConvertedChart: this.props.getConvertedChart,
136
112
  updateStatItem: this.props.updateStatItem
137
113
  }), /*#__PURE__*/React.createElement("div", {
138
114
  className: "statistic-chart-parameter-divider"
@@ -8,7 +8,7 @@ import BaseSettings from '../public-setting/base-settings';
8
8
  import ColumnSettings from '../public-setting/column-settings';
9
9
  import SummarySettings from './summary-settings';
10
10
  import ToggleSetting from '../public-setting/toggle-setting';
11
- import { MIRROR_COLUMN_LIST } from '../../../constants';
11
+ import { isMirrorColumn } from '../../../utils/column-utils';
12
12
  var MirrorSettings = /*#__PURE__*/function (_Component) {
13
13
  _inherits(MirrorSettings, _Component);
14
14
  var _super = _createSuper(MirrorSettings);
@@ -50,7 +50,7 @@ var MirrorSettings = /*#__PURE__*/function (_Component) {
50
50
  var columns = props.columns,
51
51
  getColumnsOptions = props.getColumnsOptions;
52
52
  var statColumns = columns.filter(function (column) {
53
- return MIRROR_COLUMN_LIST.includes(column.type);
53
+ return isMirrorColumn(column);
54
54
  });
55
55
  var groupColumns = columns.filter(function (column) {
56
56
  return column.type === 'single-select';
@@ -66,7 +66,7 @@ var MirrorSettings = /*#__PURE__*/function (_Component) {
66
66
  var columns = nextProps.columns,
67
67
  getColumnsOptions = nextProps.getColumnsOptions;
68
68
  var statColumns = columns.filter(function (column) {
69
- return MIRROR_COLUMN_LIST.includes(column.type);
69
+ return isMirrorColumn(column);
70
70
  });
71
71
  this.statColumnsOptions = getColumnsOptions(statColumns);
72
72
  var groupColumns = columns.filter(function (column) {
@@ -98,6 +98,7 @@ var MirrorSettings = /*#__PURE__*/function (_Component) {
98
98
  getTables: getTables,
99
99
  getViews: getViews,
100
100
  getTableById: this.props.getTableById,
101
+ getConvertedChart: this.props.getConvertedChart,
101
102
  updateStatItem: this.props.updateStatItem
102
103
  }), /*#__PURE__*/React.createElement("div", {
103
104
  className: "statistic-chart-parameter-divider"
@@ -10,7 +10,7 @@ import { DTableSelect } from '../../../components';
10
10
  import ColumnSettings from '../public-setting/column-settings';
11
11
  import BaseSettings from '../public-setting/base-settings';
12
12
  import SummarySettings from './summary-settings';
13
- import { TIME_COLUMN_LIST } from '../../../constants';
13
+ import { isStatisticDateColumn } from '../../../utils/column-utils';
14
14
  var COMPARE_GRANULARITY = ['day', 'week', 'quarter', 'month', 'year', 'days_7', 'days_30'];
15
15
  var COMPARED_LIST = (_COMPARED_LIST = {}, _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[0], 'Yesterday_vs_the_day_before_yesterday'), _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[1], 'Last_week_vs_the_week_before_last'), _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[3], 'Last_month_vs_the_month_before_last'), _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[2], 'Last_quarter_vs_the_quarter_before_last'), _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[4], 'Last_year_vs_the_year_before_last'), _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[5], 'Last_7_days_vs_previous_7_days'), _defineProperty(_COMPARED_LIST, COMPARE_GRANULARITY[6], 'Last_30_days_vs_previous_30_days'), _COMPARED_LIST);
16
16
  var TrendSettings = /*#__PURE__*/function (_Component) {
@@ -67,7 +67,7 @@ var TrendSettings = /*#__PURE__*/function (_Component) {
67
67
  var columns = props.columns,
68
68
  getColumnsOptions = props.getColumnsOptions;
69
69
  var dateColumns = columns.filter(function (column) {
70
- return TIME_COLUMN_LIST.includes(column.type);
70
+ return isStatisticDateColumn(column);
71
71
  });
72
72
  _this.dateColumnsOptions = getColumnsOptions(dateColumns);
73
73
  _this.dateGranularityOptions = _this.getGranularityOptions(COMPARE_GRANULARITY);
@@ -80,7 +80,7 @@ var TrendSettings = /*#__PURE__*/function (_Component) {
80
80
  var columns = nextProps.columns,
81
81
  getColumnsOptions = nextProps.getColumnsOptions;
82
82
  var dateColumns = columns.filter(function (column) {
83
- return TIME_COLUMN_LIST.includes(column.type);
83
+ return isStatisticDateColumn(column);
84
84
  });
85
85
  this.dateColumnsOptions = getColumnsOptions(dateColumns);
86
86
  }
@@ -107,6 +107,7 @@ var TrendSettings = /*#__PURE__*/function (_Component) {
107
107
  getTables: getTables,
108
108
  getViews: getViews,
109
109
  getTableById: this.props.getTableById,
110
+ getConvertedChart: this.props.getConvertedChart,
110
111
  updateStatItem: this.props.updateStatItem
111
112
  }), /*#__PURE__*/React.createElement("div", {
112
113
  className: "statistic-chart-parameter-divider"
@@ -4,11 +4,11 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React, { Component, Fragment } from 'react';
6
6
  import intl from 'react-intl-universal';
7
- import { CellType, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES } from 'dtable-store';
8
7
  import BaseSettings from '../public-setting/base-settings';
9
8
  import ColumnSettings from '../public-setting/column-settings';
10
9
  import SummarySettings from './summary-settings';
11
10
  import MapStyleSetting from './style-setting/map-setting';
11
+ import { isWorldMapColumn } from '../../../utils/column-utils';
12
12
  var WordMapSettings = /*#__PURE__*/function (_Component) {
13
13
  _inherits(WordMapSettings, _Component);
14
14
  var _super = _createSuper(WordMapSettings);
@@ -17,35 +17,10 @@ var WordMapSettings = /*#__PURE__*/function (_Component) {
17
17
  _classCallCheck(this, WordMapSettings);
18
18
  _this = _super.call(this, props);
19
19
  _this.getColumns = function (columns) {
20
- var geoColumns = columns.filter(function (column) {
21
- var type = column.type,
22
- data = column.data;
23
- if (type === CellType.TEXT) return true;
24
- if (type === CellType.GEOLOCATION) {
25
- var _ref = data || {},
26
- geo_format = _ref.geo_format;
27
- if (geo_format === 'country_region') {
28
- return true;
29
- }
30
- }
31
- if (FORMULA_COLUMN_TYPES.includes(type)) {
32
- var _data = column.data;
33
- var _ref2 = _data || {},
34
- result_type = _ref2.result_type,
35
- array_type = _ref2.array_type,
36
- array_data = _ref2.array_data;
37
- if (result_type !== FORMULA_RESULT_TYPE.ARRAY || array_type !== CellType.GEOLOCATION) {
38
- return false;
39
- }
40
- var _ref3 = array_data || {},
41
- _geo_format = _ref3.geo_format;
42
- if (_geo_format === 'country_region') {
43
- return true;
44
- }
45
- }
46
- return false;
20
+ if (!Array.isArray(columns) || columns.length === 0) return [];
21
+ return columns.filter(function (column) {
22
+ return isWorldMapColumn(column);
47
23
  });
48
- return geoColumns;
49
24
  };
50
25
  _this.getSelectedTextColumnOption = function () {
51
26
  return _this.textColumnsOptions.find(function (option) {
@@ -104,6 +79,7 @@ var WordMapSettings = /*#__PURE__*/function (_Component) {
104
79
  getTables: getTables,
105
80
  getViews: getViews,
106
81
  getTableById: this.props.getTableById,
82
+ getConvertedChart: this.props.getConvertedChart,
107
83
  updateStatItem: this.props.updateStatItem
108
84
  }), /*#__PURE__*/React.createElement("div", {
109
85
  className: "statistic-chart-parameter-divider"
@@ -106,6 +106,7 @@ var AdvanceBarChartSettings = /*#__PURE__*/function (_Component) {
106
106
  getTables: getTables,
107
107
  getViews: getViews,
108
108
  getTableById: this.props.getTableById,
109
+ getConvertedChart: this.props.getConvertedChart,
109
110
  updateStatItem: this.props.updateStatItem
110
111
  }), /*#__PURE__*/React.createElement("div", {
111
112
  className: "statistic-chart-parameter-divider"
@@ -103,6 +103,7 @@ var BarSettings = /*#__PURE__*/function (_Component) {
103
103
  getTables: getTables,
104
104
  getViews: getViews,
105
105
  getTableById: this.props.getTableById,
106
+ getConvertedChart: this.props.getConvertedChart,
106
107
  updateStatItem: this.props.updateStatItem
107
108
  }), /*#__PURE__*/React.createElement("div", {
108
109
  className: "statistic-chart-parameter-divider"
@@ -177,6 +177,7 @@ var CompletenessSetting = /*#__PURE__*/function (_Component) {
177
177
  getTables: getTables,
178
178
  getViews: getViews,
179
179
  getTableById: this.props.getTableById,
180
+ getConvertedChart: this.props.getConvertedChart,
180
181
  updateStatItem: this.props.updateStatItem
181
182
  }), /*#__PURE__*/React.createElement("div", {
182
183
  className: "statistic-chart-parameter-divider"
@@ -91,6 +91,7 @@ var CustomBarSettings = /*#__PURE__*/function (_Component) {
91
91
  getTableById: getTableById,
92
92
  getTables: getTables,
93
93
  getViews: getViews,
94
+ getConvertedChart: this.props.getConvertedChart,
94
95
  updateStatItem: this.props.updateStatItem
95
96
  }), /*#__PURE__*/React.createElement("div", {
96
97
  className: "statistic-chart-parameter-divider"
@@ -102,6 +102,7 @@ var BarSettings = /*#__PURE__*/function (_Component) {
102
102
  getTables: getTables,
103
103
  getViews: getViews,
104
104
  getTableById: this.props.getTableById,
105
+ getConvertedChart: this.props.getConvertedChart,
105
106
  updateStatItem: this.props.updateStatItem
106
107
  }), /*#__PURE__*/React.createElement("div", {
107
108
  className: "statistic-chart-parameter-divider"
@@ -103,6 +103,7 @@ var HorizontalGroupBarChartSettings = /*#__PURE__*/function (_Component) {
103
103
  getTables: getTables,
104
104
  getViews: getViews,
105
105
  getTableById: this.props.getTableById,
106
+ getConvertedChart: this.props.getConvertedChart,
106
107
  updateStatItem: this.props.updateStatItem
107
108
  }), /*#__PURE__*/React.createElement("div", {
108
109
  className: "statistic-chart-parameter-divider"
@@ -180,6 +180,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
180
180
  dateGranularityOptions: _this.dateGranularityOptions,
181
181
  geolocationGranularityOptions: _this.geolocationGranularityOptions,
182
182
  getSelectedColumnOption: _this.getSelectedColumnOption,
183
+ getConvertedChart: _this.props.getConvertedChart,
183
184
  updateStatItem: _this.props.updateStatItem,
184
185
  renderIncludeEmpty: _this.renderIncludeEmpty
185
186
  });
@@ -199,6 +200,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
199
200
  numericColumnsOptions: _this.numericColumnsOptions,
200
201
  dateGranularityOptions: _this.dateGranularityOptions,
201
202
  getSelectedColumnOption: _this.getSelectedColumnOption,
203
+ getConvertedChart: _this.props.getConvertedChart,
202
204
  updateStatItem: _this.props.updateStatItem
203
205
  });
204
206
  }
@@ -223,6 +225,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
223
225
  dateGranularityOptions: _this.dateGranularityOptions,
224
226
  geolocationGranularityOptions: _this.geolocationGranularityOptions,
225
227
  getSelectedColumnOption: _this.getSelectedColumnOption,
228
+ getConvertedChart: _this.props.getConvertedChart,
226
229
  updateStatItem: _this.props.updateStatItem,
227
230
  renderIncludeEmpty: _this.renderIncludeEmpty
228
231
  });
@@ -244,6 +247,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
244
247
  dateGranularityOptions: _this.dateGranularityOptions,
245
248
  geolocationGranularityOptions: _this.geolocationGranularityOptions,
246
249
  getSelectedColumnOption: _this.getSelectedColumnOption,
250
+ getConvertedChart: _this.props.getConvertedChart,
247
251
  updateStatItem: _this.props.updateStatItem,
248
252
  renderIncludeEmpty: _this.renderIncludeEmpty
249
253
  });
@@ -261,6 +265,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
261
265
  getViews: getViews,
262
266
  getTableById: getTableById,
263
267
  selectedTable: selectedTable,
268
+ getConvertedChart: _this.props.getConvertedChart,
264
269
  columnsOptions: _this.generalColumnsOptions,
265
270
  numericColumnsOptions: _this.numericColumnsOptions,
266
271
  dateGranularityOptions: _this.dateGranularityOptions,
@@ -280,6 +285,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
280
285
  getTables: getTables,
281
286
  getViews: getViews,
282
287
  getTableById: getTableById,
288
+ getConvertedChart: _this.props.getConvertedChart,
283
289
  numericColumnsOptions: _this.numericColumnsOptions,
284
290
  generalColumnsOptions: _this.generalColumnsOptions,
285
291
  columnGroupbyColumnsOptions: _this.columnGroupbyColumnsOptions,
@@ -298,6 +304,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
298
304
  getViews: getViews,
299
305
  getTableById: getTableById,
300
306
  selectedTable: selectedTable,
307
+ getConvertedChart: _this.props.getConvertedChart,
301
308
  generalColumnsOptions: _this.generalColumnsOptions,
302
309
  columnGroupbyColumnsOptions: _this.columnGroupbyColumnsOptions,
303
310
  numericColumnsOptions: _this.numericColumnsOptions,
@@ -327,6 +334,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
327
334
  geolocationGranularityOptions: _this.geolocationGranularityOptions,
328
335
  getSelectedColumnOption: _this.getSelectedColumnOption,
329
336
  updateStatItem: _this.props.updateStatItem,
337
+ getConvertedChart: _this.props.getConvertedChart,
330
338
  renderIncludeEmpty: _this.renderIncludeEmpty
331
339
  });
332
340
  }
@@ -341,6 +349,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
341
349
  getTables: getTables,
342
350
  getViews: getViews,
343
351
  getTableById: getTableById,
352
+ getConvertedChart: _this.props.getConvertedChart,
344
353
  selectedTable: selectedTable,
345
354
  generalColumnsOptions: _this.generalColumnsOptions,
346
355
  numericColumnsOptions: _this.numericColumnsOptions,
@@ -361,6 +370,7 @@ var BasicChartSettings = /*#__PURE__*/function (_Component) {
361
370
  getTables: getTables,
362
371
  getViews: getViews,
363
372
  getTableById: getTableById,
373
+ getConvertedChart: _this.props.getConvertedChart,
364
374
  selectedTable: selectedTable,
365
375
  generalColumnsOptions: _this.generalColumnsOptions,
366
376
  pivotTableSummaryColumnOptions: _this.pivotTableSummaryColumnOptions,
@@ -140,6 +140,7 @@ var PieSettings = /*#__PURE__*/function (_Component) {
140
140
  getTables: this.props.getTables,
141
141
  getViews: this.props.getViews,
142
142
  getTableById: this.props.getTableById,
143
+ getConvertedChart: this.props.getConvertedChart,
143
144
  updateStatItem: this.props.updateStatisticsSettings
144
145
  }), /*#__PURE__*/React.createElement("div", {
145
146
  className: "statistic-chart-parameter-divider"
@@ -441,6 +441,7 @@ var PivotSettings = /*#__PURE__*/function (_Component) {
441
441
  getTables: this.props.getTables,
442
442
  getViews: this.props.getViews,
443
443
  getTableById: this.props.getTableById,
444
+ getConvertedChart: this.props.getConvertedChart,
444
445
  updateStatItem: this.props.updateStatItem
445
446
  }), /*#__PURE__*/React.createElement("div", {
446
447
  className: "statistic-chart-parameter-divider"
@@ -82,6 +82,7 @@ var ScatterSettings = /*#__PURE__*/function (_Component) {
82
82
  getTables: this.props.getTables,
83
83
  getViews: this.props.getViews,
84
84
  getTableById: this.props.getTableById,
85
+ getConvertedChart: this.props.getConvertedChart,
85
86
  updateStatItem: this.props.updateStatItem
86
87
  }), /*#__PURE__*/React.createElement("div", {
87
88
  className: "statistic-chart-parameter-divider"
@@ -241,6 +241,7 @@ var TimeComparisonSettings = /*#__PURE__*/function (_Component) {
241
241
  getTables: this.props.getTables,
242
242
  getViews: this.props.getViews,
243
243
  getTableById: this.props.getTableById,
244
+ getConvertedChart: this.props.getConvertedChart,
244
245
  updateStatItem: this.props.updateStatItem
245
246
  }), /*#__PURE__*/React.createElement("div", {
246
247
  className: "statistic-chart-parameter-divider"
@@ -5,7 +5,9 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React, { Component, Fragment } from 'react';
7
7
  import intl from 'react-intl-universal';
8
+ import TypeSettings from './type-settings';
8
9
  import { DTableSelect } from '../../../components';
10
+ import ChartService from '../../../service/chart-service';
9
11
  import { INIT_STAT_ITEM } from '../../../constants';
10
12
  var BaseSettings = /*#__PURE__*/function (_Component) {
11
13
  _inherits(BaseSettings, _Component);
@@ -88,8 +90,23 @@ var BaseSettings = /*#__PURE__*/function (_Component) {
88
90
  view_id: id
89
91
  }));
90
92
  };
93
+ _this.onChangeType = function (type) {
94
+ var statItem = _this.props.statItem;
95
+ var table_id = statItem.table_id;
96
+ var activeTable = _this.props.getTableById(table_id);
97
+ var newStatistic = _this.props.getConvertedChart({
98
+ originalStatistic: statItem,
99
+ targetStatisticType: type,
100
+ activeTable: activeTable
101
+ });
102
+ _this.props.updateStatItem(newStatistic);
103
+ };
91
104
  _this.tablesOptions = _this.getTablesOptions();
92
105
  _this.viewsOptions = _this.getViewsOptions(_props);
106
+ var defaultChartTitle = intl.get('Untitled');
107
+ _this.charService = new ChartService({
108
+ defaultChartTitle: defaultChartTitle
109
+ });
93
110
  return _this;
94
111
  }
95
112
  _createClass(BaseSettings, [{
@@ -102,9 +119,13 @@ var BaseSettings = /*#__PURE__*/function (_Component) {
102
119
  }, {
103
120
  key: "render",
104
121
  value: function render() {
122
+ var statItem = this.props.statItem;
105
123
  var selectedTableOption = this.getSelectedTableOption();
106
124
  var selectedViewOption = this.getSelectedViewOption();
107
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
125
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TypeSettings, {
126
+ chart: statItem,
127
+ onChange: this.onChangeType
128
+ }), /*#__PURE__*/React.createElement("div", {
108
129
  className: "statistic-chart-parameter-item"
109
130
  }, /*#__PURE__*/React.createElement("label", null, intl.get('Table')), /*#__PURE__*/React.createElement(DTableSelect, {
110
131
  value: selectedTableOption,
@@ -0,0 +1,29 @@
1
+ .statistic-chart-parameter-item .statistic-selected-type-container {
2
+ height: 38px;
3
+ border: 1px solid hsl(0, 0%, 80%);
4
+ border-radius: 4px;
5
+ padding-left: 8px;
6
+ padding-right: 3px;
7
+ justify-content: space-between;
8
+ background-color: #fff;
9
+ }
10
+
11
+ .statistic-chart-parameter-item .statistic-switch-type-container {
12
+ height: 24px;
13
+ width: 24px;
14
+ text-align: center;
15
+ line-height: 24px;
16
+ margin-left: 10px;
17
+ }
18
+
19
+ .statistic-chart-parameter-item .statistic-switch-type-container:hover {
20
+ cursor: pointer;
21
+ }
22
+
23
+ .statistic-chart-parameter-item .statistic-switch-type-container .statistic-type-switch-icon {
24
+ color: hsl(0, 0%, 80%);
25
+ }
26
+
27
+ .statistic-chart-parameter-item .statistic-switch-type-container:hover .statistic-type-switch-icon {
28
+ color: hsl(0, 0%, 60%);
29
+ }