dtable-statistic 5.0.0 → 5.0.1

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 (201) hide show
  1. package/es/assets/css/dashboard.css +1 -0
  2. package/es/assets/css/dialog.css +35 -0
  3. package/es/components/dialog/chart-edit-dialog.js +93 -0
  4. package/es/components/dialog/enlarged-chart-dialog.js +8 -13
  5. package/es/components/dialog/statistic-record-dialog/index.js +27 -35
  6. package/es/components/dialog/table-select-dialog.js +3 -3
  7. package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
  8. package/es/constants/index.js +3 -499
  9. package/es/dashboard.js +9 -87
  10. package/es/desktop-dashboard.js +51 -32
  11. package/es/index.js +56 -1
  12. package/es/mobile-dashboard.js +8 -16
  13. package/es/model/conver-statItem.js +124 -0
  14. package/es/service/chart-service.js +8 -27
  15. package/es/service/dashboard-service.js +25 -29
  16. package/es/stat-list/chart-preview.js +19 -20
  17. package/es/stat-list/index.js +17 -23
  18. package/es/stat-view/index.js +47 -156
  19. package/es/tabs/tab.js +18 -15
  20. package/es/utils/common-utils.js +2 -352
  21. package/es/utils/export-table-utils.js +0 -69
  22. package/es/utils/index.js +12 -89
  23. package/package.json +6 -9
  24. package/es/assets/css/color-picker.css +0 -53
  25. package/es/assets/css/color-rules-popover.css +0 -144
  26. package/es/assets/css/slider.css +0 -77
  27. package/es/assets/css/statistic-chart.module.css +0 -11
  28. package/es/assets/css/statistic-custom-title.module.css +0 -3
  29. package/es/assets/css/statistic-custom.module.css +0 -4
  30. package/es/assets/css/statistic-numeric-column-item.module.css +0 -43
  31. package/es/assets/css/statistic-time-picker.module.css +0 -21
  32. package/es/calculator/base-calculator.js +0 -80
  33. package/es/calculator/basic-chart-calculator.js +0 -349
  34. package/es/calculator/combination-calculator.js +0 -246
  35. package/es/calculator/compare-bar-calculator.js +0 -197
  36. package/es/calculator/completeness-calculator.js +0 -215
  37. package/es/calculator/copy-value.js +0 -53
  38. package/es/calculator/dashboard-calculator.js +0 -70
  39. package/es/calculator/heat-map-calculator.js +0 -148
  40. package/es/calculator/horizontal-bar-calculator.js +0 -67
  41. package/es/calculator/index.js +0 -81
  42. package/es/calculator/map-calculator.js +0 -103
  43. package/es/calculator/mirror-calculator.js +0 -146
  44. package/es/calculator/number-card-calculator.js +0 -60
  45. package/es/calculator/pivot-table-calculator.js +0 -821
  46. package/es/calculator/scatter-calculator.js +0 -75
  47. package/es/calculator/thread-manager.js +0 -57
  48. package/es/calculator/trend-calculator.js +0 -113
  49. package/es/calculator/workers/basic-chart-calculator-worker.js +0 -495
  50. package/es/calculator/workers/calculator.worker.js +0 -44
  51. package/es/calculator/workers/card-calculator-worker.js +0 -40
  52. package/es/calculator/workers/combination-calculator-worker.js +0 -276
  53. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +0 -150
  54. package/es/calculator/workers/completeness-calculator-worker.js +0 -208
  55. package/es/calculator/workers/dashboard-calculator-worker.js +0 -68
  56. package/es/calculator/workers/mirror-calculator-worker.js +0 -152
  57. package/es/calculator/workers/pivot-table-calculator-worker.js +0 -718
  58. package/es/calculator/workers/scatter-calculator-worker.js +0 -80
  59. package/es/calculator/workers/trend-calculator-worker.js +0 -108
  60. package/es/calculator/world-map-calculator.js +0 -124
  61. package/es/components/dialog/chart-addition-edit-dialog.js +0 -90
  62. package/es/components/dialog/chart-addition-widgets/chart-selector.js +0 -259
  63. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +0 -83
  64. package/es/components/dialog/statistic-types-dialog/index.css +0 -14
  65. package/es/components/dialog/statistic-types-dialog/index.js +0 -62
  66. package/es/components/popover/color-rules/color-rule.js +0 -183
  67. package/es/components/popover/color-rules/index.js +0 -87
  68. package/es/components/popover/color-rules/rule-filters/filter.js +0 -221
  69. package/es/components/popover/color-rules/rule-filters/index.css +0 -210
  70. package/es/components/popover/color-rules/rule-filters/index.js +0 -97
  71. package/es/components/popover/color-rules/rule-filters/number-input.js +0 -78
  72. package/es/components/popover/color-rules-popover.js +0 -218
  73. package/es/components/popover/color-selector-popover.js +0 -83
  74. package/es/constants/color-rules.js +0 -17
  75. package/es/constants/map.js +0 -13
  76. package/es/constants/model.js +0 -26
  77. package/es/constants/regions.js +0 -2111
  78. package/es/constants/zIndexes.js +0 -7
  79. package/es/custom-g2.js +0 -644
  80. package/es/model/bar-group.js +0 -58
  81. package/es/model/bar.js +0 -47
  82. package/es/model/base-model.js +0 -18
  83. package/es/model/basic-number-card.js +0 -25
  84. package/es/model/combination.js +0 -48
  85. package/es/model/compare-bar.js +0 -56
  86. package/es/model/completeness-group.js +0 -31
  87. package/es/model/completeness.js +0 -25
  88. package/es/model/custom-bar.js +0 -25
  89. package/es/model/dashboard.js +0 -20
  90. package/es/model/generic-model.js +0 -222
  91. package/es/model/heat-map.js +0 -33
  92. package/es/model/horizontal-bar-group.js +0 -55
  93. package/es/model/horizontal-bar.js +0 -47
  94. package/es/model/index.js +0 -187
  95. package/es/model/map.js +0 -38
  96. package/es/model/mirror.js +0 -33
  97. package/es/model/pie.js +0 -38
  98. package/es/model/ring.js +0 -40
  99. package/es/model/scatter.js +0 -22
  100. package/es/model/table.js +0 -32
  101. package/es/model/trend.js +0 -32
  102. package/es/model/world-map.js +0 -34
  103. package/es/service/map-json.js +0 -140
  104. package/es/stat-editor/chart-name-editor.js +0 -68
  105. package/es/stat-editor/index.js +0 -75
  106. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +0 -153
  107. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +0 -422
  108. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +0 -203
  109. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +0 -23
  110. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +0 -104
  111. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +0 -334
  112. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +0 -119
  113. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +0 -132
  114. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +0 -240
  115. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +0 -89
  116. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +0 -138
  117. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +0 -331
  118. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +0 -143
  119. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +0 -109
  120. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +0 -153
  121. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +0 -144
  122. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +0 -214
  123. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +0 -121
  124. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +0 -172
  125. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +0 -366
  126. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +0 -142
  127. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +0 -150
  128. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +0 -473
  129. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +0 -182
  130. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +0 -564
  131. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +0 -112
  132. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +0 -87
  133. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +0 -187
  134. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +0 -300
  135. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +0 -113
  136. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +0 -289
  137. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +0 -58
  138. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +0 -359
  139. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +0 -48
  140. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +0 -121
  141. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +0 -143
  142. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +0 -269
  143. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +0 -104
  144. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +0 -366
  145. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +0 -55
  146. package/es/stat-editor/stat-settings/color-setting/color-picker.js +0 -130
  147. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +0 -374
  148. package/es/stat-editor/stat-settings/map/map-level.js +0 -72
  149. package/es/stat-editor/stat-settings/map/map-province-city.js +0 -151
  150. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +0 -108
  151. package/es/stat-editor/stat-settings/public-setting/base-settings.js +0 -154
  152. package/es/stat-editor/stat-settings/public-setting/calender.js +0 -125
  153. package/es/stat-editor/stat-settings/public-setting/column-settings.js +0 -24
  154. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +0 -62
  155. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +0 -61
  156. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +0 -35
  157. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +0 -60
  158. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +0 -123
  159. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +0 -33
  160. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +0 -29
  161. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +0 -82
  162. package/es/stat-view/area-chart.js +0 -551
  163. package/es/stat-view/bar-chart.js +0 -582
  164. package/es/stat-view/base-chart.js +0 -132
  165. package/es/stat-view/basic-number-card.js +0 -201
  166. package/es/stat-view/combination-chart.js +0 -546
  167. package/es/stat-view/compare-chart.js +0 -483
  168. package/es/stat-view/completeness-chart.js +0 -390
  169. package/es/stat-view/custom-bar.js +0 -418
  170. package/es/stat-view/dashboard-chart.js +0 -266
  171. package/es/stat-view/heat-map.js +0 -463
  172. package/es/stat-view/horizontal-bar-chart.js +0 -562
  173. package/es/stat-view/line-chart.js +0 -518
  174. package/es/stat-view/map.js +0 -448
  175. package/es/stat-view/mirror.js +0 -275
  176. package/es/stat-view/pie-chart.js +0 -290
  177. package/es/stat-view/pivot-table/index.js +0 -196
  178. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +0 -156
  179. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +0 -176
  180. package/es/stat-view/pivot-table/pivot-table-display-name.js +0 -215
  181. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +0 -132
  182. package/es/stat-view/pivot-table/two-dimension-table.js +0 -384
  183. package/es/stat-view/ring-chart.js +0 -392
  184. package/es/stat-view/scatter-chart.js +0 -306
  185. package/es/stat-view/treemap-chart.js +0 -253
  186. package/es/stat-view/trend-chart.js +0 -249
  187. package/es/stat-view/world-map.js +0 -431
  188. package/es/utils/basic-chart-utils.js +0 -29
  189. package/es/utils/cell-format.js +0 -115
  190. package/es/utils/collaborator.js +0 -50
  191. package/es/utils/color-utils.js +0 -134
  192. package/es/utils/column-utils.js +0 -110
  193. package/es/utils/column.js +0 -20
  194. package/es/utils/date-format.js +0 -71
  195. package/es/utils/map.js +0 -114
  196. package/es/utils/model.js +0 -19
  197. package/es/utils/row-utils.js +0 -134
  198. package/es/utils/search.js +0 -73
  199. package/es/utils/sql-utils.js +0 -359
  200. package/es/utils/stat-utils.js +0 -351
  201. package/es/utils/trend-utils.js +0 -135
@@ -1,276 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = calculateResult;
8
- var _dtableUtils = require("dtable-utils");
9
- var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
10
- var _commonUtils = require("../../utils/common-utils");
11
- var _constants = require("../../constants");
12
- var _rowUtils = require("../../utils/row-utils");
13
- async function calculateResult(chart, value, _ref) {
14
- let {
15
- getViewRows,
16
- getTableFormulaResults
17
- } = _ref;
18
- const {
19
- table_id,
20
- view_id,
21
- x_axis_column_key,
22
- x_axis_include_empty,
23
- x_axis_date_granularity: groupby_date_granularity,
24
- x_axis_geolocation_granularity: groupby_geolocation_granularity,
25
- y_axis_left_summary_column,
26
- y_axis_right_summary_column,
27
- y_axis_left_summary_type,
28
- y_axis_right_summary_type,
29
- y_axis_left_summary_method,
30
- y_axis_right_summary_method,
31
- y_axis_left_group_by_multiple_numeric_column,
32
- y_axis_left_group_by_numeric_columns
33
- } = chart;
34
- const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
35
- const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
36
- if (!view) {
37
- return [];
38
- }
39
- const xAxisColumn = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
40
- if (!xAxisColumn) return [];
41
- const statRows = await getViewRows(view, table);
42
- const formulaRows = await getTableFormulaResults(table, statRows);
43
- const column1 = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column);
44
- const column2 = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column);
45
- const leftResultMap = new Map();
46
- const rightResultMap = new Map();
47
- let isColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(xAxisColumn);
48
- let leftSummaryColumn = {};
49
- let leftSummaryColumnKeys = [];
50
- if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
51
- if (column1) {
52
- leftSummaryColumn[y_axis_left_summary_column] = {
53
- method: y_axis_left_summary_method,
54
- column_name: column1.name,
55
- type: column1.type,
56
- data: column1.data,
57
- color: _constants.LABEL_COLORS[0]
58
- };
59
- }
60
- if (y_axis_left_group_by_multiple_numeric_column) {
61
- y_axis_left_group_by_numeric_columns.forEach((item, index) => {
62
- const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, item.column_key);
63
- if (summaryColumn) {
64
- leftSummaryColumn[item.column_key] = {
65
- method: item.summary_method,
66
- column_name: summaryColumn.name,
67
- type: summaryColumn.type,
68
- data: summaryColumn.data,
69
- color: _constants.LABEL_COLORS[(index + 1) % 12]
70
- };
71
- }
72
- });
73
- }
74
- leftSummaryColumnKeys = Object.keys(leftSummaryColumn);
75
- }
76
- statRows.forEach(row => {
77
- let {
78
- _id: rowId
79
- } = row;
80
- let formulaRow = formulaRows[rowId];
81
- const currentValue = row[xAxisColumn.key];
82
- let label = _statUtils.default.getGroupLabel(currentValue, formulaRow, xAxisColumn, groupby_date_granularity, groupby_geolocation_granularity, value);
83
-
84
- // collect left y axis data
85
- if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.COUNT) {
86
- if (isColumnDataAsAnArray) {
87
- if (label.length > 0) {
88
- label.forEach(name => {
89
- let currentValue = leftResultMap.get(name) || 0;
90
- currentValue = currentValue + 1;
91
- leftResultMap.set(name, currentValue);
92
- });
93
- }
94
- if (label.length === 0 && x_axis_include_empty) {
95
- let currentValue = leftResultMap.get(null) || 0;
96
- currentValue += 1;
97
- leftResultMap.set(null, currentValue);
98
- }
99
- } else {
100
- if (x_axis_include_empty || label) {
101
- let currentLabelCount = leftResultMap.get(label) || 0;
102
- currentLabelCount = currentLabelCount + 1;
103
- leftResultMap.set(label, currentLabelCount);
104
- }
105
- }
106
- }
107
- if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
108
- if (isColumnDataAsAnArray) {
109
- if (label.length > 0) {
110
- label.forEach(name => {
111
- const currentLabelMap = leftResultMap.get(name) || {};
112
- leftSummaryColumnKeys.forEach(key => {
113
- const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, {
114
- ...leftSummaryColumn[key],
115
- key
116
- });
117
- const currentLabelList = currentLabelMap[key] || [];
118
- if ((0, _dtableUtils.isNumber)(cellValue)) {
119
- currentLabelList.push(cellValue);
120
- }
121
- currentLabelMap[key] = currentLabelList;
122
- });
123
- leftResultMap.set(name, currentLabelMap);
124
- });
125
- }
126
- if (label.length === 0 && x_axis_include_empty) {
127
- let currentValue = leftResultMap.get(null) || {};
128
- leftSummaryColumnKeys.forEach(key => {
129
- const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, {
130
- ...leftSummaryColumn[key],
131
- key
132
- });
133
- const currentLabelList = currentValue[key] || [];
134
- if ((0, _dtableUtils.isNumber)(cellValue)) {
135
- currentLabelList.push(cellValue);
136
- }
137
- currentValue[key] = currentLabelList;
138
- });
139
- leftResultMap.set(null, currentValue);
140
- }
141
- } else {
142
- if (x_axis_include_empty || label) {
143
- const currentValue = leftResultMap.get(label) || {};
144
- leftSummaryColumnKeys.forEach(key => {
145
- const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, {
146
- ...leftSummaryColumn[key],
147
- key
148
- });
149
- const currentList = currentValue[key] || [];
150
- if ((0, _dtableUtils.isNumber)(cellValue)) {
151
- currentList.push(cellValue);
152
- }
153
- currentValue[key] = currentList;
154
- });
155
- leftResultMap.set(label, currentValue);
156
- }
157
- }
158
- }
159
-
160
- // collect right y axis data
161
- if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.COUNT) {
162
- if (isColumnDataAsAnArray) {
163
- if (label.length > 0) {
164
- label.forEach(name => {
165
- let currentValue = rightResultMap.get(name) || 0;
166
- currentValue = currentValue + 1;
167
- rightResultMap.set(name, currentValue);
168
- });
169
- }
170
- if (label.length === 0 && x_axis_include_empty) {
171
- let currentValue = rightResultMap.get(null) || 0;
172
- currentValue += 1;
173
- rightResultMap.set(null, currentValue);
174
- }
175
- } else {
176
- if (x_axis_include_empty || label) {
177
- let currentLabelCount = rightResultMap.get(label) || 0;
178
- currentLabelCount = currentLabelCount + 1;
179
- rightResultMap.set(label, currentLabelCount);
180
- }
181
- }
182
- }
183
- if (y_axis_right_summary_column && y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
184
- const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, column2);
185
- if (isColumnDataAsAnArray) {
186
- if (label.length > 0) {
187
- label.forEach(name => {
188
- const currentLabelList = rightResultMap.get(name) || [];
189
- if ((0, _dtableUtils.isNumber)(cellValue)) {
190
- currentLabelList.push(cellValue);
191
- }
192
- rightResultMap.set(name, currentLabelList);
193
- });
194
- }
195
- if (label.length === 0 && x_axis_include_empty) {
196
- let currentValue = rightResultMap.get(null) || [];
197
- if ((0, _dtableUtils.isNumber)(cellValue)) {
198
- currentValue.push(cellValue);
199
- }
200
- rightResultMap.set(null, currentValue);
201
- }
202
- } else {
203
- if (x_axis_include_empty || label) {
204
- const currentLabelList = rightResultMap.get(label) || [];
205
- if ((0, _dtableUtils.isNumber)(cellValue)) {
206
- currentLabelList.push(cellValue);
207
- }
208
- rightResultMap.set(label, currentLabelList);
209
- }
210
- }
211
- }
212
- });
213
-
214
- // Summary collect data
215
- let results = [];
216
- let targetMap = leftResultMap;
217
- if (leftSummaryColumnKeys.length === 0 && y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
218
- targetMap = rightResultMap;
219
- }
220
- for (let item of targetMap) {
221
- const key = item[0];
222
- const leftValue = item[1];
223
- let value1 = 0;
224
- let value2 = 0;
225
- let formattedValueLeft = value1;
226
- let formattedValueRight = value2;
227
- const rightValue = rightResultMap.get(key);
228
- if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.COUNT) {
229
- value2 = rightValue;
230
- formattedValueRight = value2;
231
- }
232
- if (y_axis_right_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
233
- value2 = (0, _commonUtils.getSummaryResult)(rightValue, y_axis_right_summary_method);
234
- formattedValueRight = _statUtils.default.getFormattedValue(value2, column2, y_axis_right_summary_method);
235
- }
236
- if (!y_axis_left_group_by_multiple_numeric_column) {
237
- if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.COUNT) {
238
- value1 = leftValue;
239
- formattedValueLeft = value1;
240
- }
241
- if (y_axis_left_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
242
- const list = leftValue[column1.key];
243
- value1 = (0, _commonUtils.getSummaryResult)(list, y_axis_left_summary_method);
244
- formattedValueLeft = _statUtils.default.getFormattedValue(value1, column1, y_axis_left_summary_method);
245
- }
246
- results.push({
247
- name: key,
248
- value_left: value1,
249
- value_right: value2,
250
- formatted_value_left: formattedValueLeft,
251
- formatted_value_right: formattedValueRight
252
- });
253
- } else {
254
- leftSummaryColumnKeys.forEach(columnKey => {
255
- const summaryColumn = leftSummaryColumn[columnKey];
256
- const summaryMethod = summaryColumn.method;
257
- const list = leftValue[columnKey];
258
- const value = (0, _commonUtils.getSummaryResult)(list, summaryMethod);
259
- formattedValueLeft = _statUtils.default.getFormattedValue(value, summaryColumn, summaryMethod);
260
- results.push({
261
- name: key,
262
- value_left: value,
263
- color: leftSummaryColumn[columnKey].color,
264
- value_right: value2,
265
- formatted_value_left: formattedValueLeft,
266
- formatted_value_right: formattedValueRight
267
- });
268
- });
269
- }
270
- }
271
- _statUtils.default.sortStatistics(results, xAxisColumn, 'name');
272
- results.forEach(item => {
273
- item.name = (0, _rowUtils.getFormattedLabel)(xAxisColumn, item.name, value.collaborators);
274
- });
275
- return results;
276
- }
@@ -1,150 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _dtableUtils = require("dtable-utils");
9
- var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
10
- var _commonUtils = require("../../utils/common-utils");
11
- var _rowUtils = require("../../utils/row-utils");
12
- var _constants = require("../../constants");
13
- async function calculateChart(chart, value, _ref) {
14
- let {
15
- getViewRows,
16
- getTableFormulaResults
17
- } = _ref;
18
- const {
19
- table_id,
20
- view_id,
21
- x_axis_column_key,
22
- y_axis_summary_type,
23
- y_axis_summary_method,
24
- y_axis_column_key,
25
- x_axis_date_granularity,
26
- x_axis_date_range_start,
27
- x_axis_date_range_end,
28
- x_axis_compared_date_range_start,
29
- x_axis_compared_date_range_end,
30
- display_increase
31
- } = chart;
32
- const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
33
- const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
34
- const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
35
- const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
36
- if (!view || !x_axis_column_key) {
37
- return [];
38
- }
39
- const groupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
40
- if (!groupbyColumn) {
41
- return [];
42
- }
43
- const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
44
- const statRows = await getViewRows(view, table);
45
- const formulaRows = await getTableFormulaResults(table, statRows);
46
- const dateRangeResultMap = new Map();
47
- const comparedDateRangeResultMap = new Map();
48
- const isAdvance = y_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED;
49
- statRows.forEach(row => {
50
- const {
51
- _id: rowId
52
- } = row;
53
- const cellValue = row[groupbyColumn.key];
54
- const formulaRow = formulaRows[rowId];
55
- if (!cellValue) return;
56
- if (cellValue >= x_axis_date_range_start && cellValue <= x_axis_date_range_end || cellValue >= x_axis_compared_date_range_start && cellValue <= x_axis_compared_date_range_end) {
57
- const name = _statUtils.default.getGroupLabel(cellValue, formulaRow, groupbyColumn, x_axis_date_granularity, '', value);
58
- if (cellValue >= x_axis_date_range_start && cellValue <= x_axis_date_range_end) {
59
- if (isAdvance) {
60
- const currentValue = dateRangeResultMap.get(name);
61
- const _cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, summaryColumn);
62
- if (!currentValue) {
63
- dateRangeResultMap.set(name, [_cellValue]);
64
- } else {
65
- currentValue.push(_cellValue);
66
- }
67
- } else {
68
- const currentValue = dateRangeResultMap.get(name);
69
- if (!currentValue) {
70
- dateRangeResultMap.set(name, 1);
71
- } else {
72
- dateRangeResultMap.set(name, currentValue + 1);
73
- }
74
- }
75
- } else {
76
- if (isAdvance) {
77
- const currentValue = comparedDateRangeResultMap.get(name);
78
- const _cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, summaryColumn);
79
- if (!currentValue && summaryColumn) {
80
- comparedDateRangeResultMap.set(name, [_cellValue]);
81
- } else {
82
- currentValue.push(_cellValue);
83
- }
84
- } else {
85
- const currentValue = comparedDateRangeResultMap.get(name);
86
- if (!currentValue) {
87
- comparedDateRangeResultMap.set(name, 1);
88
- } else {
89
- comparedDateRangeResultMap.set(name, currentValue + 1);
90
- }
91
- }
92
- }
93
- }
94
- });
95
- let dateRangeResult = [];
96
- let comparedDateRangeResult = [];
97
- const data = summaryColumn.data || {};
98
- for (let item of dateRangeResultMap) {
99
- const key = item[0];
100
- let value = item[1];
101
- let formatted_value = value;
102
- if (isAdvance) {
103
- value = (0, _commonUtils.getSummaryResult)(value, y_axis_summary_method, data.precision);
104
- formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, y_axis_summary_method);
105
- }
106
- dateRangeResult.push({
107
- name: key,
108
- group_name: groupName1,
109
- raw_name: key,
110
- value,
111
- formatted_value
112
- });
113
- }
114
- _statUtils.default.sortStatistics(dateRangeResult, groupbyColumn, 'name');
115
- for (let item of comparedDateRangeResultMap) {
116
- const key = item[0];
117
- let value = item[1];
118
- let formatted_value = value;
119
- if (isAdvance) {
120
- value = (0, _commonUtils.getSummaryResult)(value, y_axis_summary_method, data.precision);
121
- formatted_value = _statUtils.default.getFormattedValue(value, summaryColumn, y_axis_summary_method);
122
- }
123
- comparedDateRangeResult.push({
124
- name: key,
125
- group_name: groupName2,
126
- raw_name: key,
127
- value,
128
- formatted_value
129
- });
130
- }
131
- _statUtils.default.sortStatistics(comparedDateRangeResult, groupbyColumn, 'name');
132
- for (let i = 0; i < dateRangeResult.length; i++) {
133
- if (!comparedDateRangeResult[i]) break;
134
- comparedDateRangeResult[i].name = dateRangeResult[i].name;
135
- if (display_increase) {
136
- const value1 = dateRangeResult[i].value;
137
- const value2 = comparedDateRangeResult[i].value || 0.001;
138
- if (!value2) {
139
- comparedDateRangeResult[i].increase_value = 1;
140
- } else {
141
- comparedDateRangeResult[i].increase_value = Number(((value1 - value2) / value2).toFixed(2));
142
- }
143
- }
144
- }
145
- if (comparedDateRangeResult.length > dateRangeResult.length) {
146
- comparedDateRangeResult = comparedDateRangeResult.slice(0, dateRangeResult.length);
147
- }
148
- return [...comparedDateRangeResult, ...dateRangeResult];
149
- }
150
- var _default = exports.default = calculateChart;
@@ -1,208 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _dtableUtils = require("dtable-utils");
9
- var _commonUtils = require("../../utils/common-utils");
10
- var _rowUtils = require("../../utils/row-utils");
11
- var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
12
- var _constants = require("../../constants");
13
- async function calculateResult(chart, value, _ref) {
14
- let {
15
- getViewRows,
16
- getTableFormulaResults
17
- } = _ref;
18
- const {
19
- table_id,
20
- view_id,
21
- name_column,
22
- completed_column,
23
- target_column,
24
- group_column,
25
- date_granularity,
26
- geolocation_granularity
27
- } = chart;
28
- const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
29
- const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
30
- if (!view) {
31
- return [];
32
- }
33
- const nameColumn = (0, _dtableUtils.getTableColumnByKey)(table, name_column);
34
- if (!nameColumn) return [];
35
- const statRows = await getViewRows(view, table);
36
- const formulaRows = await getTableFormulaResults(table, statRows);
37
- const groupColumn = (0, _dtableUtils.getTableColumnByKey)(table, group_column);
38
- const isColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(nameColumn);
39
- const isGroupChart = !!groupColumn;
40
- let result = [];
41
- if (!isGroupChart) {
42
- const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
43
- const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
44
- let labelCountMap = {};
45
- let labels = [];
46
- statRows.forEach(row => {
47
- let {
48
- _id: rowId
49
- } = row;
50
- let formulaRow = formulaRows[rowId] || {};
51
- const name = row[nameColumn.key];
52
- if (name || Number.isFinite(name)) {
53
- let label = _statUtils.default.getGroupLabel(name, formulaRow, nameColumn, '', '', value);
54
- if (isColumnDataAsAnArray) {
55
- label = label[0];
56
- }
57
- label = (0, _rowUtils.getFormattedLabel)(nameColumn, label, value.collaborators);
58
- let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
59
- let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
60
- currentValue = (0, _dtableUtils.isNumber)(currentValue) ? currentValue : 0;
61
- targetValue = (0, _dtableUtils.isNumber)(targetValue) ? targetValue : 0;
62
- if (labelCountMap[label]) {
63
- labelCountMap[label].currentValue = currentValue + labelCountMap[label].currentValue;
64
- labelCountMap[label].targetValue = targetValue + labelCountMap[label].targetValue;
65
- } else {
66
- labelCountMap[label] = {
67
- currentValue,
68
- targetValue
69
- };
70
- labels.push(label);
71
- }
72
- }
73
- });
74
- labels.forEach(label => {
75
- if (labelCountMap[label]) {
76
- const {
77
- currentValue,
78
- targetValue
79
- } = labelCountMap[label];
80
- if (currentValue < targetValue) {
81
- result.unshift({
82
- name: label,
83
- value: currentValue,
84
- type: 'completed',
85
- current_value: currentValue,
86
- target_value: targetValue
87
- }, {
88
- name: label,
89
- value: targetValue - currentValue,
90
- type: 'uncompleted',
91
- current_value: currentValue,
92
- target_value: targetValue
93
- });
94
- } else {
95
- result.unshift({
96
- name: label,
97
- value: currentValue,
98
- type: 'completed',
99
- current_value: currentValue,
100
- target_value: targetValue
101
- });
102
- }
103
- }
104
- });
105
- } else {
106
- const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
107
- const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
108
- let labelCountMap = {};
109
- let colorMap = {};
110
- let labelGroups = [];
111
- let colorIndex = 0;
112
- let isFormulaType = _dtableUtils.FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
113
- const isGroupColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupColumn);
114
- statRows.forEach(row => {
115
- let {
116
- _id: rowId
117
- } = row;
118
- let formulaRow = formulaRows[rowId] || {};
119
- const name = row[nameColumn.key],
120
- groupLabelName = !isFormulaType ? row[groupColumn.key] : formulaRow[rowId][groupColumn.key];
121
- if ((name || Number.isFinite(name)) && (groupLabelName || Number.isFinite(groupLabelName))) {
122
- let label = _statUtils.default.getGroupLabel(name, formulaRow, nameColumn, '', '', value),
123
- groupLabel = _statUtils.default.getGroupLabel(groupLabelName, formulaRow, groupColumn, date_granularity, geolocation_granularity, value);
124
- if (isColumnDataAsAnArray) {
125
- label = label[0];
126
- }
127
- if (isGroupColumnDataAsAnArray) {
128
- groupLabel = groupLabel[0];
129
- }
130
- label = (0, _rowUtils.getFormattedLabel)(nameColumn, label, value.collaborators);
131
- groupLabel = (0, _rowUtils.getFormattedLabel)(groupColumn, groupLabel, value.collaborators);
132
- let color = colorMap[groupLabel];
133
- if (!color) {
134
- color = _constants.PIE_CHART_COLORS[colorIndex % 12];
135
- colorMap[groupLabel] = color;
136
- colorIndex++;
137
- }
138
- if (groupLabel) {
139
- let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
140
- let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
141
- currentValue = (0, _dtableUtils.isNumber)(currentValue) ? currentValue : 0;
142
- targetValue = (0, _dtableUtils.isNumber)(targetValue) ? targetValue : 0;
143
- const concatLabel = "".concat(label, "_").concat(groupLabel);
144
- if (labelCountMap[concatLabel]) {
145
- labelCountMap[concatLabel].currentValue = currentValue + labelCountMap[concatLabel].currentValue;
146
- labelCountMap[concatLabel].targetValue = targetValue + labelCountMap[concatLabel].targetValue;
147
- } else {
148
- labelCountMap[concatLabel] = {
149
- currentValue,
150
- targetValue
151
- };
152
- labelGroups.push({
153
- key: concatLabel,
154
- label,
155
- groupLabel
156
- });
157
- }
158
- }
159
- }
160
- });
161
- labelGroups.forEach(labelGroup => {
162
- const {
163
- key,
164
- label,
165
- groupLabel
166
- } = labelGroup;
167
- if (labelCountMap[key]) {
168
- const color = colorMap[groupLabel];
169
- const {
170
- currentValue,
171
- targetValue
172
- } = labelCountMap[key];
173
- if (currentValue < targetValue) {
174
- result.unshift({
175
- name: label,
176
- group_label: groupLabel,
177
- value: currentValue,
178
- color,
179
- type: 'completed',
180
- current_value: currentValue,
181
- target_value: targetValue
182
- }, {
183
- name: label,
184
- group_label: groupLabel,
185
- value: targetValue - currentValue,
186
- color,
187
- type: 'uncompleted',
188
- current_value: currentValue,
189
- target_value: targetValue
190
- });
191
- } else {
192
- result.unshift({
193
- name: label,
194
- group_label: groupLabel,
195
- value: currentValue,
196
- color,
197
- type: 'completed',
198
- current_value: currentValue,
199
- target_value: targetValue
200
- });
201
- }
202
- }
203
- });
204
- result.colorMap = colorMap;
205
- }
206
- return result;
207
- }
208
- var _default = exports.default = calculateResult;
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _dtableUtils = require("dtable-utils");
8
- var _commonUtils = require("../../utils/common-utils");
9
- var _rowUtils = require("../../utils/row-utils");
10
- async function calculateResult(chart, value, _ref) {
11
- let {
12
- getViewRows,
13
- getTableFormulaResults
14
- } = _ref;
15
- const {
16
- table_id,
17
- view_id,
18
- target_value_column,
19
- target_value_column_summary_method,
20
- total_value_column,
21
- total_value_column_summary_method
22
- } = chart;
23
- const selectedTable = (0, _dtableUtils.getTableById)(value.tables, table_id);
24
- const selectedView = selectedTable && (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
25
- const selectedColumn1 = (0, _dtableUtils.getTableColumnByKey)(selectedTable, target_value_column);
26
- const selectedColumn2 = (0, _dtableUtils.getTableColumnByKey)(selectedTable, total_value_column);
27
- const statRows = await getViewRows(selectedView, selectedTable);
28
- if (statRows.length === 0) {
29
- return 0;
30
- }
31
- const isNumericColumn1 = selectedColumn1 && (0, _dtableUtils.isNumericColumn)(selectedColumn1);
32
- const isNumericColumn2 = selectedColumn2 && (0, _dtableUtils.isNumericColumn)(selectedColumn2);
33
- const formulaRows = isNumericColumn1 || isNumericColumn2 ? await getTableFormulaResults(selectedTable, statRows) : {};
34
- let result1;
35
- let result2;
36
- let numberList1 = [];
37
- let numberList2 = [];
38
- statRows.forEach(row => {
39
- const formulaRow = formulaRows[row._id];
40
- if (isNumericColumn1) {
41
- const cellValue1 = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn1);
42
- if ((0, _dtableUtils.isNumber)(cellValue1)) {
43
- numberList1.push(cellValue1);
44
- }
45
- }
46
- if (isNumericColumn2) {
47
- const cellValue2 = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn2);
48
- if ((0, _dtableUtils.isNumber)(cellValue2)) {
49
- numberList2.push(cellValue2);
50
- }
51
- }
52
- });
53
- if (target_value_column_summary_method === 'Row_count') {
54
- result1 = statRows.length;
55
- } else {
56
- result1 = (0, _commonUtils.getSummaryResult)(numberList1, target_value_column_summary_method);
57
- }
58
- if (total_value_column_summary_method === 'Row_count') {
59
- result2 = statRows.length;
60
- } else {
61
- result2 = (0, _commonUtils.getSummaryResult)(numberList2, total_value_column_summary_method);
62
- }
63
- if (result2 === 0) {
64
- return 0;
65
- }
66
- return result1 / result2;
67
- }
68
- var _default = exports.default = calculateResult;