dtable-statistic 4.0.4 → 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 (74) hide show
  1. package/es/assets/icons/switch-icon.svg +17 -0
  2. package/es/calculator/workers/basic-chart-calculator-worker.js +1 -1
  3. package/es/components/dialog/chart-addition-edit-dialog.js +1 -0
  4. package/es/components/dialog/chart-addition-widgets/chart-selector.js +2 -1
  5. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +9 -0
  6. package/es/components/dialog/statistic-types-dialog/index.css +14 -0
  7. package/es/components/dialog/statistic-types-dialog/index.js +63 -0
  8. package/es/components/icon.js +12 -0
  9. package/es/constants/index.js +17 -6
  10. package/es/constants/model.js +20 -0
  11. package/es/dashboard.js +47 -9
  12. package/es/desktop-dashboard.js +3 -2
  13. package/es/locale/lang/de.js +3 -1
  14. package/es/locale/lang/en.js +3 -1
  15. package/es/locale/lang/fr.js +3 -1
  16. package/es/locale/lang/zh_CN.js +3 -1
  17. package/es/model/bar-group.js +60 -0
  18. package/es/model/bar.js +49 -0
  19. package/es/model/base-model.js +12 -0
  20. package/es/model/basic-number-card.js +27 -0
  21. package/es/model/combination.js +50 -0
  22. package/es/model/compare-bar.js +58 -0
  23. package/es/model/completeness-group.js +33 -0
  24. package/es/model/completeness.js +27 -0
  25. package/es/model/custom-bar.js +27 -0
  26. package/es/model/dashboard.js +22 -0
  27. package/es/model/generic-model.js +219 -0
  28. package/es/model/heat-map.js +35 -0
  29. package/es/model/horizontal-bar-group.js +55 -0
  30. package/es/model/horizontal-bar.js +49 -0
  31. package/es/model/index.js +26 -0
  32. package/es/model/map.js +37 -0
  33. package/es/model/mirror.js +35 -0
  34. package/es/model/pie.js +40 -0
  35. package/es/model/ring.js +41 -0
  36. package/es/model/scatter.js +24 -0
  37. package/es/model/table.js +34 -0
  38. package/es/model/trend.js +34 -0
  39. package/es/model/world-map.js +36 -0
  40. package/es/service/chart-service.js +47 -169
  41. package/es/service/dashboard-service.js +6 -5
  42. package/es/stat-editor/index.js +2 -0
  43. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +1 -0
  44. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +1 -0
  45. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +1 -0
  46. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +4 -3
  47. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +9 -10
  48. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +7 -31
  49. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +4 -3
  50. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +4 -3
  51. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +5 -29
  52. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +1 -0
  53. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -0
  54. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +1 -0
  55. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +1 -0
  56. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +1 -0
  57. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +1 -0
  58. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +10 -0
  59. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +1 -0
  60. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +1 -0
  61. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +1 -0
  62. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -0
  63. package/es/stat-editor/stat-settings/public-setting/base-settings.js +22 -1
  64. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +29 -0
  65. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +58 -0
  66. package/es/stat-view/pie-chart.js +2 -2
  67. package/es/stat-view/ring-chart.js +2 -2
  68. package/es/utils/column-utils.js +69 -2
  69. package/es/utils/common-utils.js +3 -0
  70. package/es/utils/model.js +13 -0
  71. package/es/utils/row-utils.js +1 -0
  72. package/es/utils/stat-utils.js +4 -0
  73. package/package.json +1 -1
  74. package/es/model/stat-item.js +0 -340
@@ -0,0 +1,40 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ import { SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
7
+ var Pie = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(Pie, _BaseModel);
9
+ var _super = _createSuper(Pie);
10
+ function Pie(object) {
11
+ var _this;
12
+ _classCallCheck(this, Pie);
13
+ _this = _super.call(this, object);
14
+
15
+ // groupby data
16
+ _this.groupby_column_key = object.x_axis_column_key;
17
+ _this.groupby_date_granularity = object.x_axis_date_granularity;
18
+ _this.groupby_geolocation_granularity = object.x_axis_geolocation_granularity;
19
+ _this.groupby_include_empty_cells = object.x_axis_include_empty;
20
+
21
+ // summary
22
+ _this.summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
23
+ _this.summary_column_key = object.y_axis_column_key;
24
+ _this.summary_method = object.y_axis_summary_method;
25
+ if (_this.summary_method === SUMMARY_METHOD_MAP.Row_count) {
26
+ _this.summary_method = SUMMARY_METHOD_MAP.Max;
27
+ }
28
+ _this.show_legend = isBoolean(object.show_legend) ? object.show_legend : true;
29
+ _this.display_label = isBoolean(object.display_label) ? object.display_label : true;
30
+ _this.show_percent = object.show_percent;
31
+ _this.sort_type = object.sort_type;
32
+ _this.minimum_slice_percent = object.minimum_slice_percent;
33
+ _this.label_font_size = object.label_font_size;
34
+ _this.label_format = object.label_format;
35
+ _this.label_position = object.label_position;
36
+ return _this;
37
+ }
38
+ return Pie;
39
+ }(BaseModel);
40
+ export { Pie as default };
@@ -0,0 +1,41 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ import { SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
7
+ var Ring = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(Ring, _BaseModel);
9
+ var _super = _createSuper(Ring);
10
+ function Ring(object) {
11
+ var _this;
12
+ _classCallCheck(this, Ring);
13
+ _this = _super.call(this, object);
14
+
15
+ // group data
16
+ _this.groupby_column_key = object.x_axis_column_key;
17
+ _this.groupby_date_granularity = object.x_axis_date_granularity;
18
+ _this.groupby_geolocation_granularity = object.x_axis_geolocation_granularity;
19
+ _this.groupby_include_empty_cells = object.x_axis_include_empty;
20
+
21
+ // summary
22
+ _this.summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
23
+ _this.summary_column_key = object.y_axis_column_key;
24
+ _this.summary_method = object.y_axis_summary_method;
25
+ if (_this.summary_method === SUMMARY_METHOD_MAP.Row_count) {
26
+ _this.summary_method = SUMMARY_METHOD_MAP.Max;
27
+ }
28
+ _this.show_legend = object.show_legend;
29
+ _this.display_label = object.display_label;
30
+ _this.show_percent = object.show_percent;
31
+ _this.sort_type = object.sort_type;
32
+ _this.minimum_slice_percent = object.minimum_slice_percent;
33
+ _this.display_annotation = isBoolean(object.display_annotation) ? object.display_annotation : true;
34
+ _this.annotation_font_size = object.annotation_font_size;
35
+ _this.label_format = object.label_format;
36
+ _this.label_position = object.label_position;
37
+ return _this;
38
+ }
39
+ return Ring;
40
+ }(BaseModel);
41
+ export { Ring as default };
@@ -0,0 +1,24 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ var Scatter = /*#__PURE__*/function (_BaseModel) {
7
+ _inherits(Scatter, _BaseModel);
8
+ var _super = _createSuper(Scatter);
9
+ function Scatter(object) {
10
+ var _this;
11
+ _classCallCheck(this, Scatter);
12
+ _this = _super.call(this, object);
13
+ _this.x_axis_column = object.x_axis_column_key;
14
+ _this.y_axis_column = object.y_axis_column_key;
15
+ _this.group_column = object.column_groupby_column_key;
16
+ _this.show_x_axis_label = isBoolean(object.show_x_axis_label) ? object.show_x_axis_label : false;
17
+ _this.show_y_axis_label = isBoolean(object.show_y_axis_label) ? object.show_y_axis_label : false;
18
+ _this.x_axis_label_position = object.x_axis_label_position;
19
+ _this.y_axis_label_position = object.y_axis_label_position;
20
+ return _this;
21
+ }
22
+ return Scatter;
23
+ }(BaseModel);
24
+ export { Scatter as default };
@@ -0,0 +1,34 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ import { SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
7
+ var Table = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(Table, _BaseModel);
9
+ var _super = _createSuper(Table);
10
+ function Table(object) {
11
+ var _this;
12
+ _classCallCheck(this, Table);
13
+ _this = _super.call(this, object);
14
+ _this.groupby_column_key = object.x_axis_column_key;
15
+ _this.groupby_date_granularity = object.x_axis_date_granularity;
16
+ _this.groupby_geolocation_granularity = object.x_axis_geolocation_granularity;
17
+ _this.groupby_include_empty_cells = object.x_axis_include_empty;
18
+ _this.summary_column_key = object.y_axis_summary_column;
19
+ _this.summary_method = object.y_axis_summary_method;
20
+ _this.summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
21
+ if (_this.summary_method === SUMMARY_METHOD_MAP.Row_count) {
22
+ _this.summary_method = SUMMARY_METHOD_MAP.Max;
23
+ }
24
+ _this.column_groupby_multiple_numeric_column = isBoolean(object.column_groupby_multiple_numeric_column) ? object.column_groupby_multiple_numeric_column : false;
25
+ _this.column_groupby_column_key = object.column_groupby_column_key;
26
+ _this.column_groupby_date_granularity = object.column_groupby_date_granularity;
27
+ _this.column_groupby_geolocation_granularity = object.column_groupby_geolocation_granularity;
28
+ _this.display_total = isBoolean(object.display_total) ? object.display_total : true;
29
+ _this.summary_columns_option = object.summary_columns_option || [];
30
+ return _this;
31
+ }
32
+ return Table;
33
+ }(BaseModel);
34
+ export { Table as default };
@@ -0,0 +1,34 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import { TableUtils } from 'dtable-store';
5
+ import BaseModel from './base-model';
6
+ import { isStatisticDateColumn } from '../utils/column-utils';
7
+ import { DATE_GRANULARITY, SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
8
+ var Trend = /*#__PURE__*/function (_BaseModel) {
9
+ _inherits(Trend, _BaseModel);
10
+ var _super = _createSuper(Trend);
11
+ function Trend(object, table) {
12
+ var _this;
13
+ _classCallCheck(this, Trend);
14
+ _this = _super.call(this, object);
15
+ _this.date_column = object.x_axis_column_key;
16
+ _this.date_granularity = object.x_axis_date_granularity || DATE_GRANULARITY.MONTH;
17
+ if (_this.date_column) {
18
+ var column = TableUtils.getTableColumnByKey(table, _this.date_column);
19
+ if (!isStatisticDateColumn(column)) {
20
+ _this.date_column = null;
21
+ _this.date_granularity = null;
22
+ }
23
+ }
24
+ _this.summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
25
+ _this.summary_column = object.y_axis_summary_column;
26
+ _this.summary_method = object.y_axis_summary_method;
27
+ if (_this.summary_method === SUMMARY_METHOD_MAP.Row_count) {
28
+ _this.summary_method = SUMMARY_METHOD_MAP.Max;
29
+ }
30
+ return _this;
31
+ }
32
+ return Trend;
33
+ }(BaseModel);
34
+ export { Trend as default };
@@ -0,0 +1,36 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import { isNumber, TableUtils } from 'dtable-store';
5
+ import BaseModel from './base-model';
6
+ import { isWorldMapColumn } from '../utils/column-utils';
7
+ import { LEGEND_DIRECTION_MAP, SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
8
+ var WorldMap = /*#__PURE__*/function (_BaseModel) {
9
+ _inherits(WorldMap, _BaseModel);
10
+ var _super = _createSuper(WorldMap);
11
+ function WorldMap(object, table) {
12
+ var _this;
13
+ _classCallCheck(this, WorldMap);
14
+ _this = _super.call(this, object);
15
+ _this.column = object.x_axis_column_key;
16
+ if (_this.column) {
17
+ var column = TableUtils.getTableColumnByKey(table, _this.column);
18
+ if (!isWorldMapColumn(column)) {
19
+ _this.column = null;
20
+ }
21
+ }
22
+ _this.summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
23
+ _this.summary_method = object.y_axis_summary_method;
24
+ _this.summary_column = object.y_axis_summary_column;
25
+ if (_this.summary_method === SUMMARY_METHOD_MAP.Row_count) {
26
+ _this.summary_method = SUMMARY_METHOD_MAP.Max;
27
+ }
28
+ _this.legend_direction = object.legend_direction || LEGEND_DIRECTION_MAP.VERTICAL;
29
+ _this.legend_size = isNumber(object.legend_size) ? object.legend_size : 1;
30
+ _this.data_color = object.data_color;
31
+ _this.bubble_color = object.bubble_color;
32
+ return _this;
33
+ }
34
+ return WorldMap;
35
+ }(BaseModel);
36
+ export { WorldMap as default };
@@ -1,9 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import StatItem from '../model/stat-item';
5
- import { STAT_TYPE, GEOLOCATION_GRANULARITY, SUMMARY_TYPE, LABEL_COLORS, STATISTICS_COUNT_TYPE } from '../constants';
6
4
  import { generatorUniqueId } from '../utils/common-utils';
5
+ import ChartModelConfig, { GenericModel } from '../model';
7
6
  var ChartService = /*#__PURE__*/function () {
8
7
  function ChartService(_ref) {
9
8
  var defaultChartTitle = _ref.defaultChartTitle;
@@ -11,180 +10,59 @@ var ChartService = /*#__PURE__*/function () {
11
10
  this.defaultChartTitle = defaultChartTitle;
12
11
  }
13
12
  _createClass(ChartService, [{
14
- key: "generateChart",
15
- value: function generateChart(_ref2) {
13
+ key: "generatorChart",
14
+ value: function generatorChart() {
15
+ var statistic = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
+ var table = arguments.length > 1 ? arguments[1] : undefined;
17
+ var object = new GenericModel(statistic);
18
+ var ChartModel = ChartModelConfig[object.type];
19
+ if (!ChartModel) return null;
20
+ return new ChartModel(object, table);
21
+ }
22
+ }, {
23
+ key: "getInitChart",
24
+ value: function getInitChart(_ref2) {
16
25
  var type = _ref2.type,
17
26
  dashboard = _ref2.dashboard,
18
27
  activeTable = _ref2.activeTable,
19
28
  activeView = _ref2.activeView;
20
29
  var stat_items = dashboard.stat_items;
21
- var charId = generatorUniqueId(stat_items);
22
- var commonConfigs = {
30
+ var statId = generatorUniqueId(stat_items);
31
+ var view_id = activeView._id;
32
+ var name = this.defaultChartTitle;
33
+ var initConfig = {
23
34
  type: type,
24
- _id: charId,
25
- name: this.defaultChartTitle,
26
- table_id: activeTable._id,
27
- view_id: activeView._id
35
+ name: name,
36
+ view_id: view_id,
37
+ _id: statId,
38
+ table_id: activeTable._id
28
39
  };
29
- switch (type) {
30
- case STAT_TYPE.MAP:
31
- case STAT_TYPE.MAP_BUBBLE:
32
- {
33
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
34
- geo_column: null,
35
- geolocation_granularity: GEOLOCATION_GRANULARITY.PROVINCE,
36
- summary_type: SUMMARY_TYPE.COUNT
37
- }));
38
- }
39
- case STAT_TYPE.WORLD_MAP:
40
- case STAT_TYPE.WORLD_MAP_BUBBLE:
41
- {
42
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
43
- column: null,
44
- summary_type: SUMMARY_TYPE.COUNT
45
- }));
46
- }
47
- case STAT_TYPE.HEAT_MAP:
48
- {
49
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
50
- time_column: null,
51
- summary_type: SUMMARY_TYPE.COUNT
52
- }));
53
- }
54
- case STAT_TYPE.MIRROR:
55
- {
56
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
57
- column: null,
58
- group_column: null,
59
- is_transpose: false,
60
- summary_type: SUMMARY_TYPE.COUNT
61
- }));
62
- }
63
- case STAT_TYPE.BAR:
64
- case STAT_TYPE.LINE:
65
- case STAT_TYPE.AREA_CHART:
66
- case STAT_TYPE.AREA_GROUP_CHART:
67
- case STAT_TYPE.COMPARE_BAR:
68
- {
69
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
70
- x_axis_column_key: null,
71
- y_axis_summary_type: SUMMARY_TYPE.COUNT,
72
- show_x_axis_label: false,
73
- show_y_axis_label: false
74
- }));
75
- }
76
- case STAT_TYPE.CUSTOM_BAR:
77
- {
78
- return new StatItem(commonConfigs);
79
- }
80
- case STAT_TYPE.BAR_GROUP:
81
- case STAT_TYPE.BAR_STACK:
82
- case STAT_TYPE.GROUP_LINE:
83
- {
84
- var configs = _objectSpread(_objectSpread({}, commonConfigs), {}, {
85
- x_axis_column_key: null,
86
- column_groupby_column_key: null,
87
- y_axis_summary_type: SUMMARY_TYPE.COUNT,
88
- show_x_axis_label: false,
89
- show_y_axis_label: false
90
- });
91
- if (type === STAT_TYPE.BAR_STACK) {
92
- configs.y_axis_use_stack = true;
93
- }
94
- return new StatItem(configs);
95
- }
96
- case STAT_TYPE.HORIZONTAL_BAR:
97
- {
98
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
99
- vertical_axis_column_key: null,
100
- horizontal_axis_summary_type: SUMMARY_TYPE.COUNT,
101
- show_vertical_axis_label: false,
102
- show_horizontal_axis_label: false
103
- }));
104
- }
105
- case STAT_TYPE.HORIZONTAL_GROUP_BAR:
106
- case STAT_TYPE.STACKED_HORIZONTAL_BAR:
107
- {
108
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
109
- vertical_axis_column_key: null,
110
- horizontal_axis_summary_type: SUMMARY_TYPE.COUNT,
111
- show_vertical_axis_label: false,
112
- show_horizontal_axis_label: false,
113
- column_groupby_column_key: null
114
- }));
115
- }
116
- case STAT_TYPE.PIE:
117
- case STAT_TYPE.RING:
118
- case STAT_TYPE.TREEMAP:
119
- {
120
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
121
- groupby_column_key: null,
122
- summary_type: SUMMARY_TYPE.COUNT
123
- }));
124
- }
125
- case STAT_TYPE.SCATTER:
126
- {
127
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
128
- x_axis_column: null,
129
- y_axis_column: null,
130
- group_column: null,
131
- show_x_axis_label: false,
132
- show_y_axis_label: false
133
- }));
134
- }
135
- case STAT_TYPE.BASIC_NUMBER_CARD:
136
- {
137
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
138
- numeric_column: null,
139
- summary_method: 'Row_count'
140
- }));
141
- }
142
- case STAT_TYPE.COMBINATION_CHART:
143
- {
144
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
145
- x_axis_column_key: null,
146
- x_axis_include_empty: false,
147
- y_axis_left_summary_type: STATISTICS_COUNT_TYPE.COUNT,
148
- y_axis_right_summary_type: STATISTICS_COUNT_TYPE.COUNT,
149
- y_axis_left_color: LABEL_COLORS[0],
150
- y_axis_right_color: LABEL_COLORS[1],
151
- show_y_axis_left_label: false,
152
- show_y_axis_right_label: false
153
- }));
154
- }
155
- case STAT_TYPE.TREND_CHART:
156
- {
157
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
158
- date_column: null,
159
- summary_type: STATISTICS_COUNT_TYPE.COUNT,
160
- date_granularity: STATISTICS_COUNT_TYPE.MONTH
161
- }));
162
- }
163
- case STAT_TYPE.COMPLETENESS_CHART:
164
- case STAT_TYPE.GROUP_COMPLETENESS_CHART:
165
- {
166
- return new StatItem(commonConfigs);
167
- }
168
- case STAT_TYPE.DASHBOARD:
169
- {
170
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
171
- target_value_column: null,
172
- target_value_column_summary_method: 'Row_count',
173
- total_value_column: null,
174
- total_value_column_summary_method: 'Row_count'
175
- }));
176
- }
177
- case STAT_TYPE.PIVOT_TABLE:
178
- {
179
- return new StatItem(_objectSpread(_objectSpread({}, commonConfigs), {}, {
180
- summary_type: SUMMARY_TYPE.COUNT
181
- }));
182
- }
183
- default:
184
- {
185
- return null;
186
- }
187
- }
40
+ return this.generatorChart(initConfig, activeTable);
41
+ }
42
+ }, {
43
+ key: "getCopiedChart",
44
+ value: function getCopiedChart(_ref3) {
45
+ var dashboard = _ref3.dashboard,
46
+ originalStatItem = _ref3.originalStatItem;
47
+ var stat_items = dashboard.stat_items;
48
+ var statId = generatorUniqueId(stat_items);
49
+ var name = originalStatItem.name;
50
+ return _objectSpread(_objectSpread({}, originalStatItem), {}, {
51
+ _id: statId,
52
+ name: name + '(copy)',
53
+ layout: null
54
+ });
55
+ }
56
+ }, {
57
+ key: "getConvertedChart",
58
+ value: function getConvertedChart(_ref4) {
59
+ var originalStatistic = _ref4.originalStatistic,
60
+ targetStatisticType = _ref4.targetStatisticType,
61
+ activeTable = _ref4.activeTable;
62
+ if (targetStatisticType === originalStatistic.type) return originalStatistic;
63
+ return this.generatorChart(_objectSpread(_objectSpread({}, originalStatistic), {}, {
64
+ type: targetStatisticType
65
+ }), activeTable);
188
66
  }
189
67
  }]);
190
68
  return ChartService;
@@ -3,7 +3,6 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
5
  import StatisticDashBoard from '../model/statistic-dashboard';
6
- import StatItem from '../model/stat-item';
7
6
  import { hasOwnProperty } from '../utils';
8
7
  import { generatorUniqueId } from '../utils/common-utils';
9
8
  import { DASHBOARD_ACTION_TYPE, STAT_TYPE, SUMMARY_TYPE } from '../constants';
@@ -13,11 +12,13 @@ var DashBoardService = /*#__PURE__*/function () {
13
12
  var value = _ref.value,
14
13
  defaultDashboardName = _ref.defaultDashboardName,
15
14
  chartCalculator = _ref.chartCalculator,
15
+ chartService = _ref.chartService,
16
16
  updateStatistics = _ref.updateStatistics,
17
17
  deletePluginSettings = _ref.deletePluginSettings;
18
18
  _classCallCheck(this, DashBoardService);
19
19
  this.defaultDashboardName = defaultDashboardName;
20
20
  this.chartCalculator = chartCalculator;
21
+ this.chartService = chartService;
21
22
  this.initStatistics(value, updateStatistics, deletePluginSettings);
22
23
  }
23
24
  _createClass(DashBoardService, [{
@@ -67,7 +68,7 @@ var DashBoardService = /*#__PURE__*/function () {
67
68
  }
68
69
  case STAT_TYPE.PIE:
69
70
  {
70
- return new StatItem(_objectSpread(_objectSpread({}, chart), {}, {
71
+ return _this.chartService.generatorStatistic(_objectSpread(_objectSpread({}, chart), {}, {
71
72
  type: STAT_TYPE.RING
72
73
  }));
73
74
  }
@@ -92,7 +93,7 @@ var DashBoardService = /*#__PURE__*/function () {
92
93
  if (summary_type === SUMMARY_TYPE.ADVANCED && summary_columns_option && summary_columns_option.length > 0) {
93
94
  convertedChart.column_groupby_multiple_numeric_column = true;
94
95
  }
95
- return new StatItem(convertedChart);
96
+ return this.chartService.generatorStatistic(convertedChart);
96
97
  }
97
98
  }, {
98
99
  key: "convertChartBar",
@@ -120,7 +121,7 @@ var DashBoardService = /*#__PURE__*/function () {
120
121
  }).filter(Boolean);
121
122
  }
122
123
  }
123
- return new StatItem(convertedChart);
124
+ return this.chartService.generatorStatistic(convertedChart);
124
125
  }
125
126
  }, {
126
127
  key: "convertChartLine",
@@ -144,7 +145,7 @@ var DashBoardService = /*#__PURE__*/function () {
144
145
  }).filter(Boolean);
145
146
  }
146
147
  }
147
- return new StatItem(convertedChart);
148
+ return this.chartService.generatorStatistic(convertedChart);
148
149
  }
149
150
  }, {
150
151
  key: "mergeAdvancedStatistics",
@@ -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"