dtable-statistic 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +5 -8
  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
package/es/dashboard.js CHANGED
@@ -12,11 +12,8 @@ var _dtableUtils = require("dtable-utils");
12
12
  var _statisticDashboard = _interopRequireDefault(require("./model/statistic-dashboard"));
13
13
  var _dashboardService = _interopRequireDefault(require("./service/dashboard-service"));
14
14
  var _chartService = _interopRequireDefault(require("./service/chart-service"));
15
- var _mapJson = require("./service/map-json");
16
15
  var _desktopDashboard = _interopRequireDefault(require("./desktop-dashboard"));
17
16
  var _mobileDashboard = _interopRequireDefault(require("./mobile-dashboard"));
18
- var _threadManager = _interopRequireDefault(require("./calculator/thread-manager"));
19
- var _calculator = _interopRequireDefault(require("./calculator"));
20
17
  var _utils = require("./utils");
21
18
  var _commonUtils = require("./utils/common-utils");
22
19
  var _constants = require("./constants");
@@ -75,28 +72,14 @@ class DashBoard extends _react.Component {
75
72
  });
76
73
  };
77
74
  this.initDashboard = () => {
78
- const {
79
- username,
80
- userId,
81
- userDepartmentIdsMap
82
- } = window.dtable;
83
75
  const value = this.value;
84
- this.chartCalculator = new _calculator.default({
85
- username,
86
- userId,
87
- userDepartmentIdsMap,
88
- value,
89
- statisticThreadManager: this.statisticThreadManager
90
- });
91
76
  this.dashboardService = new _dashboardService.default({
92
77
  value,
93
78
  defaultDashboardName: this.defaultDashboardName,
94
- chartCalculator: this.chartCalculator,
95
79
  chartService: this.chartService,
96
80
  updateStatistics: this.props.updateStatistics,
97
81
  deletePluginSettings: this.props.deletePluginSettings
98
82
  });
99
- this.initLabelColorConfigs();
100
83
  const statistics = this.dashboardService.getStatistics();
101
84
  const validStatistics = this.dashboardService.getValidStatistics(statistics);
102
85
  let selectedDashboardIdx = this.getSelectedDashboardIdxFromLocal(_constants.KEY_SELECTED_DASHBOARD) || 0;
@@ -108,26 +91,6 @@ class DashBoard extends _react.Component {
108
91
  selectedDashboardIdx
109
92
  };
110
93
  };
111
- this.initLabelColorConfigs = () => {
112
- const systemCustomColors = window.dtable.customColors || [];
113
- const baseSettings = this.value && this.value.settings;
114
- const baseCustomColors = baseSettings && baseSettings.custom_colors || [];
115
- this.labelColorConfigs = [..._constants.LABEL_COLORS.map(color => ({
116
- color: color.toUpperCase(),
117
- text_color: '#fff'
118
- })), ...systemCustomColors.map(customColor => ({
119
- ...customColor,
120
- color: customColor.color.toUpperCase()
121
- })), ...baseCustomColors.map(customColor => ({
122
- color: customColor.COLOR.toUpperCase(),
123
- text_color: customColor.TEXT_COLOR,
124
- border_color: customColor.BORDER_COLOR
125
- }))];
126
- };
127
- this.clearCalculations = () => {
128
- this.statisticThreadManager.clearQueue();
129
- this.statisticThreadManager.terminateWorkers();
130
- };
131
94
  this.getSelectedDashboardIdxFromLocal = key => {
132
95
  const {
133
96
  dtableUuid
@@ -165,22 +128,9 @@ class DashBoard extends _react.Component {
165
128
  activeView
166
129
  });
167
130
  };
168
- this.getConvertedChart = _ref3 => {
169
- let {
170
- originalStatistic,
171
- targetStatisticType,
172
- activeTable
173
- } = _ref3;
174
- return this.chartService.getConvertedChart({
175
- originalStatistic,
176
- targetStatisticType,
177
- activeTable
178
- });
179
- };
180
131
  this.selectDashboard = selectedDashboardIdx => {
181
132
  this.disabledUpdateLayout = true;
182
133
  this.setSelectedDashboardIdx(selectedDashboardIdx);
183
- this.clearCalculations();
184
134
  this.setState({
185
135
  selectedDashboardIdx
186
136
  });
@@ -211,7 +161,6 @@ class DashBoard extends _react.Component {
211
161
  dashboard
212
162
  }
213
163
  });
214
- this.clearCalculations();
215
164
  const selectedDashboardIdx = updatedStatistics.length - 1;
216
165
  this.setSelectedDashboardIdx(selectedDashboardIdx);
217
166
  this.updateStatistics({
@@ -252,7 +201,6 @@ class DashBoard extends _react.Component {
252
201
  }
253
202
  });
254
203
  this.setSelectedDashboardIdx(nextSelectedDashboardIdx);
255
- this.clearCalculations();
256
204
  this.updateStatistics({
257
205
  statistics: updatedStatistics,
258
206
  selectedDashboardIdx: nextSelectedDashboardIdx
@@ -301,7 +249,7 @@ class DashBoard extends _react.Component {
301
249
  selectedDashboardIdx
302
250
  } = this.state;
303
251
  const dashboard = statistics[selectedDashboardIdx];
304
- const fromChart = dashboard && dashboard.stat_items.find(chart => chart._id === chartId);
252
+ const fromChart = dashboard && dashboard.stat_items.find(chart => chart.config._id === chartId);
305
253
  if (!fromChart) return;
306
254
  const newChart = this.chartService.getCopiedChart({
307
255
  dashboard,
@@ -337,9 +285,6 @@ class DashBoard extends _react.Component {
337
285
  });
338
286
  };
339
287
  this.addChart = chart => {
340
- if (!this.chartCalculator.isValidChart(chart)) {
341
- return;
342
- }
343
288
  this.disabledUpdateLayout = true;
344
289
  const updatedStatistics = this.dashboardService.update({
345
290
  action: _constants.DASHBOARD_ACTION_TYPE.ADD_CHART,
@@ -351,8 +296,9 @@ class DashBoard extends _react.Component {
351
296
  this.updateStatistics({
352
297
  statistics: updatedStatistics
353
298
  }, () => {
299
+ var _document$getElementB;
354
300
  // make the copied stat item display in the view
355
- document.getElementById(chart._id).scrollIntoView(true);
301
+ (_document$getElementB = document.getElementById(chart.config._id)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.scrollIntoView(true);
356
302
  });
357
303
  };
358
304
  this.modifyChart = chart => {
@@ -402,19 +348,6 @@ class DashBoard extends _react.Component {
402
348
  const permission = window.dtable.permission || '';
403
349
  return permission === 'r' || permission.slice(0, 2) === 'c-';
404
350
  };
405
- this.queryMapJson = (_ref4, callback) => {
406
- let {
407
- map_level,
408
- map_location
409
- } = _ref4;
410
- this.mapJsonService.queryMapJson({
411
- map_level,
412
- map_location
413
- }, callback);
414
- };
415
- const {
416
- mediaUrl
417
- } = window.dtable;
418
351
  const {
419
352
  value: _value
420
353
  } = props;
@@ -424,10 +357,6 @@ class DashBoard extends _react.Component {
424
357
  this.chartService = new _chartService.default({
425
358
  defaultChartTitle
426
359
  });
427
- this.statisticThreadManager = new _threadManager.default((navigator.hardwareConcurrency || 4) - 1);
428
- this.mapJsonService = new _mapJson.MapJsonService({
429
- mediaUrl
430
- });
431
360
  const {
432
361
  statistics: _statistics,
433
362
  selectedDashboardIdx: _selectedDashboardIdx
@@ -454,7 +383,6 @@ class DashBoard extends _react.Component {
454
383
  this.unsubscribeLocalDtableChanged();
455
384
  this.unsubscribeRemoteDtableChange();
456
385
  this.unsubscribeRefreshCharts();
457
- this.clearCalculations();
458
386
  }
459
387
  render() {
460
388
  const {
@@ -463,8 +391,7 @@ class DashBoard extends _react.Component {
463
391
  const {
464
392
  statistics,
465
393
  selectedDashboardIdx,
466
- dtableChangedTime,
467
- editingChart
394
+ dtableChangedTime
468
395
  } = this.state;
469
396
  const isTableReadOnly = this.isTableReadOnly();
470
397
  const colorThemeName = this.dashboardService.getColorThemeName();
@@ -474,29 +401,27 @@ class DashBoard extends _react.Component {
474
401
  dtableChangedTime: dtableChangedTime,
475
402
  statistics: statistics,
476
403
  selectedDashboardIdx: selectedDashboardIdx,
477
- chartCalculator: this.chartCalculator,
478
- labelColorConfigs: this.labelColorConfigs,
479
404
  eventBus: eventBus,
480
405
  onCloseDashboard: this.props.onCloseStatistic,
406
+ getViewRows: this.props.getViewRows,
407
+ getTableFormulaResults: this.props.getTableFormulaResults,
481
408
  selectDashboard: this.selectDashboard,
482
409
  addDashboard: this.addDashboard,
483
410
  renameDashboard: this.renameDashboard,
484
411
  deleteDashboard: this.deleteDashboard,
485
- getTableById: this.getTableById,
486
- queryMapJson: this.queryMapJson
412
+ getTableById: this.getTableById
487
413
  }) : /*#__PURE__*/_react.default.createElement(_desktopDashboard.default, {
488
414
  isTableReadOnly: isTableReadOnly,
489
415
  colorThemeName: colorThemeName,
490
416
  dtableChangedTime: dtableChangedTime,
491
417
  statistics: statistics,
492
- editingChart: editingChart,
493
418
  selectedDashboardIdx: selectedDashboardIdx,
494
- chartCalculator: this.chartCalculator,
495
- labelColorConfigs: this.labelColorConfigs,
496
419
  eventBus: eventBus,
497
420
  getActiveTable: this.getActiveTable,
498
421
  getActiveView: this.getActiveView,
499
422
  onCloseDashboard: this.props.onCloseStatistic,
423
+ getViewRows: this.props.getViewRows,
424
+ getTableFormulaResults: this.props.getTableFormulaResults,
500
425
  selectDashboard: this.selectDashboard,
501
426
  modifyColorTheme: this.modifyColorTheme,
502
427
  addDashboard: this.addDashboard,
@@ -505,11 +430,8 @@ class DashBoard extends _react.Component {
505
430
  moveDashboard: this.moveDashboard,
506
431
  getTableById: this.getTableById,
507
432
  getTables: this.getTables,
508
- getViews: this.getViews,
509
433
  getValue: this.getValue,
510
- queryMapJson: this.queryMapJson,
511
434
  getInitChart: this.getInitChart,
512
- getConvertedChart: this.getConvertedChart,
513
435
  copyChart: this.copyChart,
514
436
  moveChartToView: this.moveChartToView,
515
437
  deleteChart: this.deleteChart,
@@ -10,11 +10,13 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _reactstrap = require("reactstrap");
12
12
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
13
+ var _seaChart = require("sea-chart");
13
14
  var _tabs = _interopRequireDefault(require("./tabs"));
14
15
  var _statList = _interopRequireDefault(require("./stat-list"));
15
16
  var _colorThemeDialog = _interopRequireDefault(require("./components/dialog/color-theme-dialog"));
16
- var _chartAdditionEditDialog = _interopRequireDefault(require("./components/dialog/chart-addition-edit-dialog"));
17
+ var _chartEditDialog = _interopRequireDefault(require("./components/dialog/chart-edit-dialog"));
17
18
  var _statisticRecordDialog = _interopRequireDefault(require("./components/dialog/statistic-record-dialog"));
19
+ var _dtableDbApi = _interopRequireDefault(require("./api/dtable-db-api"));
18
20
  var _chartService = _interopRequireDefault(require("./service/chart-service"));
19
21
  var _constants = require("./constants");
20
22
  var _icon = _interopRequireDefault(require("./assets/images/icon.png"));
@@ -34,10 +36,24 @@ class DesktopDashboard extends _react.Component {
34
36
  isFullScreen: !this.state.isFullScreen
35
37
  });
36
38
  };
37
- this.onToggleChartAddition = () => {
39
+ this.onToggleAddChart = () => {
38
40
  this.setState({
39
- isShowChartAdditionDialog: !this.state.isShowChartAdditionDialog,
40
- editingChart: null
41
+ isShowChartAddDialog: !this.state.isShowChartAddDialog
42
+ });
43
+ };
44
+ this.onToggleEditChart = chartId => {
45
+ let editingChart = null;
46
+ if (chartId) {
47
+ const {
48
+ statistics,
49
+ selectedDashboardIdx
50
+ } = this.props;
51
+ const statistic = statistics[selectedDashboardIdx];
52
+ editingChart = statistic && statistic.stat_items.find(chart => chart.config._id === chartId);
53
+ }
54
+ this.setState({
55
+ isShowChartEditDialog: !this.state.isShowChartEditDialog,
56
+ editingChart
41
57
  });
42
58
  };
43
59
  this.toggleThemeMode = () => {
@@ -48,16 +64,11 @@ class DesktopDashboard extends _react.Component {
48
64
  this.saveThemeMode2LocalStorage(theme);
49
65
  });
50
66
  };
51
- this.onToggleEditChart = chartId => {
52
- const {
53
- statistics,
54
- selectedDashboardIdx
55
- } = this.props;
56
- const statistic = statistics[selectedDashboardIdx];
57
- const editingChart = statistic && statistic.stat_items.find(chart => chart._id === chartId);
67
+ this.onTypeChange = newType => {
68
+ const convertedChart = this.generateChart(newType);
58
69
  this.setState({
59
- isShowChartAdditionDialog: true,
60
- editingChart
70
+ isShowChartEditDialog: true,
71
+ editingChart: convertedChart
61
72
  });
62
73
  };
63
74
  this.onCloseDashboard = () => {
@@ -136,11 +147,21 @@ class DesktopDashboard extends _react.Component {
136
147
  this.state = {
137
148
  theme: this.getThemeModeFromLocalStorage() || '',
138
149
  isFullScreen: false,
139
- isShowChartAdditionDialog: false,
150
+ isShowChartEditDialog: false,
151
+ isShowChartAddDialog: false,
140
152
  isShowColorThemeDialog: false,
141
153
  editingChart: null,
142
154
  chartRecordsParams: null
143
155
  };
156
+ this.api = {
157
+ sqlQuery: this.sqlQuery,
158
+ getViewRows: this.props.getViewRows,
159
+ getTableFormulaResults: this.props.getTableFormulaResults,
160
+ queryUsers: window.app.queryUsers || (() => {})
161
+ };
162
+ }
163
+ async sqlQuery(sql) {
164
+ return _dtableDbApi.default.sqlQuery(sql);
144
165
  }
145
166
  render() {
146
167
  const {
@@ -151,15 +172,14 @@ class DesktopDashboard extends _react.Component {
151
172
  colorThemeName,
152
173
  statistics,
153
174
  selectedDashboardIdx,
154
- chartCalculator,
155
- labelColorConfigs,
156
175
  eventBus
157
176
  } = this.props;
158
177
  const {
159
178
  theme,
160
179
  isFullScreen,
161
180
  editingChart,
162
- chartRecordsParams
181
+ chartRecordsParams,
182
+ isShowChartAddDialog
163
183
  } = this.state;
164
184
  const darkMode = theme === _constants.THEME_NAME_MAP.DARK;
165
185
  const statistic = statistics[selectedDashboardIdx];
@@ -195,7 +215,7 @@ class DesktopDashboard extends _react.Component {
195
215
  className: "statistic-header-operators d-flex align-items-center"
196
216
  }, !isTableReadOnly && /*#__PURE__*/_react.default.createElement("button", {
197
217
  className: "btn btn-secondary op-item add-stat",
198
- onClick: this.onToggleChartAddition
218
+ onClick: this.onToggleAddChart
199
219
  }, /*#__PURE__*/_react.default.createElement("i", {
200
220
  className: "op-item-icon add-chart-icon dtable-font dtable-icon-add-table"
201
221
  }), /*#__PURE__*/_react.default.createElement("span", {
@@ -244,12 +264,12 @@ class DesktopDashboard extends _react.Component {
244
264
  theme: theme,
245
265
  colorThemeName: colorThemeName,
246
266
  statItems: statItems,
247
- chartCalculator: chartCalculator,
248
267
  eventBus: eventBus,
268
+ api: this.api,
269
+ getValue: getValue,
249
270
  getOtherStatistics: this.getOtherStatistics,
250
271
  getTableById: this.props.getTableById,
251
272
  getTables: this.props.getTables,
252
- queryMapJson: this.props.queryMapJson,
253
273
  copyChart: this.props.copyChart,
254
274
  moveChartToView: this.props.moveChartToView,
255
275
  deleteChart: this.props.deleteChart,
@@ -257,23 +277,22 @@ class DesktopDashboard extends _react.Component {
257
277
  onToggleEditChart: this.onToggleEditChart,
258
278
  onCloseDashboard: this.props.onCloseDashboard,
259
279
  toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
260
- })), this.state.isShowChartAdditionDialog && /*#__PURE__*/_react.default.createElement(_chartAdditionEditDialog.default, {
261
- dtableChangedTime: dtableChangedTime,
280
+ })), this.state.isShowChartEditDialog && /*#__PURE__*/_react.default.createElement(_chartEditDialog.default, {
281
+ theme: theme,
262
282
  colorThemeName: colorThemeName,
263
283
  editingChart: editingChart,
264
- labelColorConfigs: labelColorConfigs,
265
- chartCalculator: chartCalculator,
266
- eventBus: eventBus,
267
- getTables: this.props.getTables,
268
- getViews: this.props.getViews,
269
- getTableById: this.props.getTableById,
270
- queryMapJson: this.props.queryMapJson,
271
- generateChart: this.generateChart,
272
- hideChartAdditionDialog: this.onToggleChartAddition,
273
- getConvertedChart: this.props.getConvertedChart,
284
+ api: this.api,
285
+ getValue: getValue,
286
+ statistics: statistics,
287
+ selectedDashboardIdx: selectedDashboardIdx,
274
288
  addChart: this.props.addChart,
275
289
  modifyChart: this.props.modifyChart,
290
+ onToggleEditChart: this.onToggleEditChart,
276
291
  toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
292
+ }), isShowChartAddDialog && /*#__PURE__*/_react.default.createElement(_seaChart.TypesDialog, {
293
+ type: "",
294
+ onToggle: this.onToggleAddChart,
295
+ onChange: this.onTypeChange
277
296
  }), this.state.isShowColorThemeDialog && /*#__PURE__*/_react.default.createElement(_colorThemeDialog.default, {
278
297
  colorThemeName: colorThemeName,
279
298
  onToggleColorThemeDialog: this.onToggleColorThemeDialog,
package/es/index.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  var _react = _interopRequireDefault(require("react"));
5
+ var _dtableStore = require("dtable-store");
5
6
  var _dashboard = _interopRequireDefault(require("./dashboard"));
7
+ var _converStatItem = require("./model/conver-statItem");
6
8
  class Statistic {
7
9
  static getInitProps() {
8
10
  if (!window || !window.app) {
@@ -17,15 +19,68 @@ class Statistic {
17
19
  selectedTableIdx,
18
20
  selectedViewId
19
21
  } = state;
22
+ const convertedValue = this.convertStatistics(value);
20
23
  return {
21
- value,
24
+ value: convertedValue,
22
25
  eventBus: dtableStore.eventBus,
23
26
  activeTableIdx: selectedTableIdx,
24
27
  activeViewId: selectedViewId,
28
+ getViewRows: this.getViewRows,
29
+ getTableFormulaResults: this.getTableFormulaResults,
25
30
  updateStatistics: this.updateStatistics.bind(this, dtableStore),
26
31
  deletePluginSettings: this.deletePluginSettings.bind(this, dtableStore)
27
32
  };
28
33
  }
34
+
35
+ // Compatible with old statistics
36
+ static convertStatistics(value) {
37
+ value.statistics.forEach(dashboard => {
38
+ const new_stat_items = dashboard.stat_items.map(item => {
39
+ if (!item.config) {
40
+ const newItem = {
41
+ config: {
42
+ ...item,
43
+ ...(0, _converStatItem.convertByType)(item)
44
+ },
45
+ layout: item.layout,
46
+ style_config: {
47
+ border: {},
48
+ title: {
49
+ text: item.name
50
+ }
51
+ }
52
+ };
53
+ return newItem;
54
+ }
55
+ return item;
56
+ });
57
+ dashboard.stat_items = new_stat_items;
58
+ });
59
+ return value;
60
+ }
61
+ static getViewRows(view, table) {
62
+ const dtableStore = window.app.dtableStore || {};
63
+ const {
64
+ username = null,
65
+ userId = null,
66
+ userDepartmentIdsMap = null
67
+ } = dtableStore.dtableSettings;
68
+ return _dtableStore.Views.getViewRows(view, table, dtableStore.value, username, userId, userDepartmentIdsMap);
69
+ }
70
+ static getTableFormulaResults(table, rows) {
71
+ const dtableStore = window.app.dtableStore || {};
72
+ const {
73
+ username = null,
74
+ userId = null,
75
+ userDepartmentIdsMap = null
76
+ } = dtableStore.dtableSettings;
77
+ const formulaColumns = _dtableStore.Views.getFormulaColumnsContainLinks(table);
78
+ return _dtableStore.Views.getTableFormulaResults(table, rows, dtableStore.value, formulaColumns, {
79
+ username,
80
+ userId,
81
+ userDepartmentIdsMap
82
+ });
83
+ }
29
84
  static updateStatistics(dtableStore, statistics) {
30
85
  dtableStore.updateStatisticsList(statistics);
31
86
  }
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
11
11
  var _tabs = _interopRequireDefault(require("./tabs"));
12
12
  var _statView = _interopRequireDefault(require("./stat-view"));
13
+ var _seaChart = require("sea-chart");
13
14
  var _constants = require("./constants");
14
15
  var _icon = _interopRequireDefault(require("./assets/images/icon.png"));
15
16
  var _mobileDashboardModule = _interopRequireDefault(require("./assets/css/mobile-dashboard.module.css"));
@@ -25,13 +26,9 @@ class MobileDashboard extends _react.Component {
25
26
  render() {
26
27
  const {
27
28
  getTableById,
28
- dtableChangedTime,
29
29
  colorThemeName,
30
30
  statistics,
31
- selectedDashboardIdx,
32
- chartCalculator,
33
- labelColorConfigs,
34
- eventBus
31
+ selectedDashboardIdx
35
32
  } = this.props;
36
33
  const statistic = statistics[selectedDashboardIdx];
37
34
  const {
@@ -70,10 +67,12 @@ class MobileDashboard extends _react.Component {
70
67
  }, statItems.map(statItem => {
71
68
  const {
72
69
  _id,
73
- type,
70
+ type
71
+ } = statItem.config;
72
+ const {
74
73
  name
75
- } = statItem;
76
- const showStatName = !(type === _constants.STAT_TYPE.BASIC_NUMBER_CARD || type === _constants.STAT_TYPE.DASHBOARD);
74
+ } = statItem.style_config.title.text;
75
+ const showStatName = !(type === _seaChart.CHART_TYPE.BASIC_NUMBER_CARD || type === _seaChart.CHART_TYPE.DASHBOARD);
77
76
  return /*#__PURE__*/_react.default.createElement("div", {
78
77
  key: "mobile-statistic-chart-".concat(_id),
79
78
  className: _mobileDashboardModule.default['mobile-statistic-chart-wrapper']
@@ -82,17 +81,10 @@ class MobileDashboard extends _react.Component {
82
81
  }, showStatName && name), /*#__PURE__*/_react.default.createElement("div", {
83
82
  className: _mobileDashboardModule.default['mobile-statistic-chart-container']
84
83
  }, /*#__PURE__*/_react.default.createElement(_statView.default, {
85
- isPreview: true,
86
- isEnlarge: false,
87
- dtableChangedTime: dtableChangedTime,
88
84
  theme: _constants.THEME_NAME_MAP.LIGHT,
89
85
  colorThemeName: colorThemeName,
90
86
  statItem: statItem,
91
- chartCalculator: chartCalculator,
92
- labelColorConfigs: labelColorConfigs,
93
- eventBus: eventBus,
94
- getTableById: getTableById,
95
- queryMapJson: this.props.queryMapJson
87
+ getTableById: getTableById
96
88
  })));
97
89
  })));
98
90
  }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertByType = void 0;
7
+ var _seaChart = require("sea-chart");
8
+ const typeMapping = {
9
+ 'chart_bar': _seaChart.CHART_TYPE.BAR,
10
+ 'chart_bar_group': _seaChart.CHART_TYPE.BAR_GROUP,
11
+ 'chart_bar_stack': _seaChart.CHART_TYPE.BAR_STACK,
12
+ 'custom_bar': _seaChart.CHART_TYPE.BAR_CUSTOM,
13
+ 'completeness_chart': _seaChart.CHART_TYPE.COMPLETENESS,
14
+ 'group_completeness_chart': _seaChart.CHART_TYPE.COMPLETENESS_GROUP,
15
+ 'chart_line': _seaChart.CHART_TYPE.LINE,
16
+ 'chart_group_line': _seaChart.CHART_TYPE.LINE_GROUP,
17
+ 'area_chart': _seaChart.CHART_TYPE.AREA,
18
+ 'area_group_chart': _seaChart.CHART_TYPE.AREA_GROUP,
19
+ 'chart_pie': _seaChart.CHART_TYPE.PIE,
20
+ 'chart_ring': _seaChart.CHART_TYPE.RING,
21
+ 'scatter_chart': _seaChart.CHART_TYPE.SCATTER,
22
+ 'combination_chart': _seaChart.CHART_TYPE.COMBINATION,
23
+ 'trend_chart': _seaChart.CHART_TYPE.TREND,
24
+ 'treemap': _seaChart.CHART_TYPE.TREE_MAP,
25
+ 'pivot_table': _seaChart.CHART_TYPE.TABLE
26
+ };
27
+
28
+ // Compatible with old chart
29
+ const convertByType = statItem => {
30
+ const {
31
+ type
32
+ } = statItem;
33
+ const newStatItem = {};
34
+ if (['chart_bar', 'chart_bar_group', 'chart_bar_stack', 'chart_line', 'chart_group_line', 'area_chart', 'area_group_chart'].includes(type)) {
35
+ newStatItem['type'] = typeMapping[type];
36
+ newStatItem['x_axis_include_empty_cells'] = (statItem === null || statItem === void 0 ? void 0 : statItem.x_axis_include_empty) || false;
37
+ newStatItem['x_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_x_axis_label) || false;
38
+ newStatItem['y_axis_summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.y_axis_column_key;
39
+ newStatItem['y_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_y_axis_label) || false;
40
+ newStatItem['y_axis_show_value'] = (statItem === null || statItem === void 0 ? void 0 : statItem.display_data) || false;
41
+ if (type === 'chart_group_line' || type === 'area_group_chart') {
42
+ newStatItem['summary_columns'] = statItem === null || statItem === void 0 ? void 0 : statItem.column_groupby_numeric_columns;
43
+ }
44
+ }
45
+ if (type === 'compare_bar') {
46
+ newStatItem['x_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_x_axis_label) || false;
47
+ newStatItem['y_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_y_axis_label) || false;
48
+ newStatItem['y_axis_summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.y_axis_column_key;
49
+ }
50
+ if (type === 'custom_bar') {
51
+ newStatItem['type'] = typeMapping[type];
52
+ newStatItem['x_axis_include_empty_cells'] = (statItem === null || statItem === void 0 ? void 0 : statItem.x_axis_include_empty) || false;
53
+ newStatItem['x_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_x_axis_label) || false;
54
+ newStatItem['y_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_y_axis_label) || false;
55
+ newStatItem['y_axises'] = statItem === null || statItem === void 0 ? void 0 : statItem.y_axises.map(item => ({
56
+ ...item,
57
+ type: 'bar_stack'
58
+ }));
59
+ }
60
+ if (type === 'completeness_chart' || type === 'group_completeness_chart') {
61
+ newStatItem['type'] = typeMapping[type];
62
+ newStatItem['groupby_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.name_column;
63
+ newStatItem['completed_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.completed_column;
64
+ newStatItem['target_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.target_column;
65
+ if (type === 'group_completeness_chart') {
66
+ newStatItem['column_groupby_column_key'] = statItem.group_column;
67
+ }
68
+ }
69
+ if (type === 'chart_pie' || type === 'chart_ring') {
70
+ newStatItem['type'] = typeMapping[type];
71
+ }
72
+ if (type === 'scatter_chart') {
73
+ newStatItem['type'] = typeMapping[type];
74
+ newStatItem['x_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_x_axis_label) || false;
75
+ newStatItem['y_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_y_axis_label) || false;
76
+ newStatItem['x_axis_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.x_axis_column;
77
+ newStatItem['y_axis_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.y_axis_column;
78
+ newStatItem['column_groupby_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.group_column;
79
+ }
80
+ if (type === 'combination_chart') {
81
+ newStatItem['type'] = typeMapping[type];
82
+ newStatItem['x_axis_show_label'] = (statItem === null || statItem === void 0 ? void 0 : statItem.show_x_axis_label) || false;
83
+ newStatItem['x_axis_include_empty_cells'] = (statItem === null || statItem === void 0 ? void 0 : statItem.x_axis_include_empty) || false;
84
+ }
85
+ if (type === 'map' || type === 'map_bubble') {
86
+ newStatItem['geo_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.geo_column;
87
+ newStatItem['summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.summary_column;
88
+ newStatItem['x_axis_include_empty_cells'] = (statItem === null || statItem === void 0 ? void 0 : statItem.x_axis_include_empty) || false;
89
+ }
90
+ if (type === 'world_map' || type === 'world_map_bubble') {
91
+ newStatItem['geo_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.column;
92
+ newStatItem['summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.summary_column;
93
+ }
94
+ if (type === 'heat_map') {
95
+ newStatItem['time_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.time_column;
96
+ newStatItem['summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.summary_column;
97
+ }
98
+ if (type === 'mirror') {
99
+ newStatItem['column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.column;
100
+ newStatItem['group_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.group_column;
101
+ newStatItem['summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.summary_column;
102
+ }
103
+ if (type === 'basic_number_card') {
104
+ newStatItem['numeric_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.numeric_column;
105
+ }
106
+ if (type === 'trend_chart') {
107
+ newStatItem['type'] = typeMapping[type];
108
+ newStatItem['date_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.date_column;
109
+ newStatItem['summary_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.summary_column;
110
+ }
111
+ if (type === 'dashboard') {
112
+ newStatItem['target_value_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.target_value_column;
113
+ newStatItem['total_value_column_key'] = statItem === null || statItem === void 0 ? void 0 : statItem.total_value_column;
114
+ }
115
+ if (type === 'treemap') {
116
+ newStatItem['type'] = typeMapping[type];
117
+ }
118
+ if (type === 'pivot_table') {
119
+ newStatItem['type'] = typeMapping[type];
120
+ newStatItem['summary_columns'] = statItem === null || statItem === void 0 ? void 0 : statItem.summary_columns_option;
121
+ }
122
+ return newStatItem;
123
+ };
124
+ exports.convertByType = convertByType;