dtable-statistic 4.3.6 → 4.3.8

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 (112) hide show
  1. package/es/calculator/base-calculator.js +16 -5
  2. package/es/calculator/basic-chart-calculator.js +17 -31
  3. package/es/calculator/combination-calculator.js +20 -34
  4. package/es/calculator/compare-bar-calculator.js +9 -20
  5. package/es/calculator/completeness-calculator.js +10 -24
  6. package/es/calculator/dashboard-calculator.js +6 -20
  7. package/es/calculator/heat-map-calculator.js +6 -20
  8. package/es/calculator/horizontal-bar-calculator.js +2 -13
  9. package/es/calculator/index.js +2 -0
  10. package/es/calculator/map-calculator.js +7 -21
  11. package/es/calculator/mirror-calculator.js +8 -22
  12. package/es/calculator/number-card-calculator.js +4 -18
  13. package/es/calculator/pivot-table-calculator.js +40 -54
  14. package/es/calculator/scatter-calculator.js +6 -20
  15. package/es/calculator/thread-manager.js +41 -41
  16. package/es/calculator/trend-calculator.js +6 -20
  17. package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
  18. package/es/calculator/workers/calculator.worker.js +5 -2
  19. package/es/calculator/workers/card-calculator-worker.js +13 -9
  20. package/es/calculator/workers/combination-calculator-worker.js +20 -16
  21. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
  22. package/es/calculator/workers/completeness-calculator-worker.js +21 -17
  23. package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
  24. package/es/calculator/workers/mirror-calculator-worker.js +14 -10
  25. package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
  26. package/es/calculator/workers/scatter-calculator-worker.js +15 -11
  27. package/es/calculator/workers/trend-calculator-worker.js +14 -10
  28. package/es/calculator/world-map-calculator.js +6 -20
  29. package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
  30. package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
  31. package/es/components/dialog/statistic-record-dialog/index.js +21 -11
  32. package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
  33. package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
  34. package/es/components/popover/color-rules-popover.js +2 -2
  35. package/es/components/select/select.js +3 -3
  36. package/es/components/toast/alert.js +2 -0
  37. package/es/components/toast/toastManager.js +1 -0
  38. package/es/constants/color-rules.js +3 -3
  39. package/es/constants/index.js +9 -9
  40. package/es/dashboard.js +7 -13
  41. package/es/desktop-dashboard.js +1 -1
  42. package/es/locale/lang/de.js +10 -10
  43. package/es/locale/lang/en.js +8 -8
  44. package/es/locale/lang/fr.js +10 -10
  45. package/es/locale/lang/zh_CN.js +8 -8
  46. package/es/model/basic-number-card.js +3 -3
  47. package/es/model/compare-bar.js +2 -2
  48. package/es/model/generic-model.js +11 -11
  49. package/es/model/heat-map.js +2 -2
  50. package/es/model/horizontal-bar.js +2 -2
  51. package/es/model/index.js +3 -2
  52. package/es/model/map.js +3 -3
  53. package/es/model/mirror.js +2 -2
  54. package/es/model/trend.js +2 -2
  55. package/es/model/world-map.js +3 -3
  56. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
  57. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
  58. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
  59. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  60. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
  61. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
  62. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
  63. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
  64. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
  65. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
  66. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
  67. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
  68. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
  69. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
  70. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +4 -18
  71. package/es/stat-editor/stat-settings/color-setting/color-picker.js +1 -0
  72. package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
  73. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
  74. package/es/stat-view/area-chart.js +4 -4
  75. package/es/stat-view/bar-chart.js +4 -4
  76. package/es/stat-view/base-chart.js +2 -2
  77. package/es/stat-view/basic-number-card.js +49 -49
  78. package/es/stat-view/combination-chart.js +69 -69
  79. package/es/stat-view/compare-chart.js +4 -4
  80. package/es/stat-view/completeness-chart.js +3 -3
  81. package/es/stat-view/custom-bar.js +2 -2
  82. package/es/stat-view/dashboard-chart.js +50 -50
  83. package/es/stat-view/heat-map.js +2 -2
  84. package/es/stat-view/horizontal-bar-chart.js +4 -4
  85. package/es/stat-view/line-chart.js +4 -4
  86. package/es/stat-view/map.js +3 -3
  87. package/es/stat-view/mirror.js +2 -2
  88. package/es/stat-view/pivot-table/index.js +6 -6
  89. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
  90. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
  91. package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
  92. package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
  93. package/es/stat-view/ring-chart.js +2 -2
  94. package/es/stat-view/scatter-chart.js +56 -56
  95. package/es/stat-view/treemap-chart.js +50 -49
  96. package/es/stat-view/trend-chart.js +52 -52
  97. package/es/stat-view/world-map.js +3 -3
  98. package/es/utils/cell-format.js +16 -16
  99. package/es/utils/cell-value.js +3 -3
  100. package/es/utils/color-utils.js +3 -3
  101. package/es/utils/column-utils.js +10 -10
  102. package/es/utils/column.js +2 -2
  103. package/es/utils/common-utils.js +10 -8
  104. package/es/utils/export-table-utils.js +38 -38
  105. package/es/utils/object.js +3 -3
  106. package/es/utils/pivot-table.js +3 -3
  107. package/es/utils/row-utils.js +17 -17
  108. package/es/utils/search.js +14 -14
  109. package/es/utils/sql-utils.js +23 -20
  110. package/es/utils/stat-utils.js +52 -52
  111. package/es/utils/trend-utils.js +1 -0
  112. package/package.json +6 -3
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  var _constants = require("../../constants");
10
10
  var _columnUtils = require("../../utils/column-utils");
11
11
  var _commonUtils = require("../../utils/common-utils");
@@ -13,26 +13,46 @@ var _rowUtils = require("../../utils/row-utils");
13
13
  var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
14
14
  var _map = require("../../utils/map");
15
15
  const MAP_CHART_TYPES = [_constants.STAT_TYPE.MAP, _constants.STAT_TYPE.WORLD_MAP, _constants.STAT_TYPE.MAP_BUBBLE, _constants.STAT_TYPE.WORLD_MAP_BUBBLE];
16
- function calculateChart(chart, value, username, userId) {
16
+ function calculateChart(chart, value, _ref) {
17
+ let {
18
+ getViewRows,
19
+ getTableFormulaResults
20
+ } = _ref;
17
21
  const {
18
22
  type
19
23
  } = chart;
20
24
  if (MAP_CHART_TYPES.includes(type)) {
21
- return calculateGeolocationBasicChart(chart, value, username, userId);
25
+ return calculateGeolocationBasicChart(chart, value, {
26
+ getViewRows,
27
+ getTableFormulaResults
28
+ });
22
29
  }
23
30
  if (type === _constants.STAT_TYPE.CUSTOM_BAR) {
24
- return calculateCustomBar(chart, value, username, userId);
31
+ return calculateCustomBar(chart, value, {
32
+ getViewRows,
33
+ getTableFormulaResults
34
+ });
25
35
  }
26
36
  const {
27
37
  column_groupby_column_key,
28
38
  column_groupby_multiple_numeric_column
29
39
  } = chart;
30
40
  if (!column_groupby_column_key && !column_groupby_multiple_numeric_column) {
31
- return calculateBasicChart(chart, value, username, userId);
41
+ return calculateBasicChart(chart, value, {
42
+ getViewRows,
43
+ getTableFormulaResults
44
+ });
32
45
  }
33
- return calculateGroupingChart(chart, value, username, userId);
46
+ return calculateGroupingChart(chart, value, {
47
+ getViewRows,
48
+ getTableFormulaResults
49
+ });
34
50
  }
35
- function calculateBasicChart(chart, value, username, userId) {
51
+ async function calculateBasicChart(chart, value, _ref2) {
52
+ let {
53
+ getViewRows,
54
+ getTableFormulaResults
55
+ } = _ref2;
36
56
  const {
37
57
  table_id,
38
58
  view_id,
@@ -62,28 +82,28 @@ function calculateBasicChart(chart, value, username, userId) {
62
82
  groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
63
83
  include_empty = chart.x_axis_include_empty;
64
84
  }
65
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
66
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
85
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
86
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
67
87
  if (!view) {
68
88
  return;
69
89
  }
70
- const groupbyColumn = groupby_column_key && _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
90
+ const groupbyColumn = groupby_column_key && (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
71
91
  if (!groupbyColumn) {
72
92
  return;
73
93
  }
74
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
94
+ const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
75
95
  const {
76
96
  type: groupby_column_type
77
97
  } = groupbyColumn;
78
- if (_dtableStore.DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
98
+ if (_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
79
99
  groupby_date_granularity = _constants.STATISTICS_COUNT_TYPE.MONTH;
80
100
  }
81
- if (groupby_column_type === _dtableStore.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
101
+ if (groupby_column_type === _dtableUtils.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
82
102
  groupby_geolocation_granularity = _constants.STATISTICS_COUNT_TYPE.PROVINCE;
83
103
  }
84
104
  const yAxisType = null;
85
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
86
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
105
+ const statRows = await getViewRows(view, table);
106
+ const formulaRows = await getTableFormulaResults(table, statRows);
87
107
  const isGroupbyColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupbyColumn);
88
108
  let results = getBasicChartResults(statRows, formulaRows, groupbyColumn, include_empty, isGroupbyColumnDataAsAnArray, groupby_date_granularity, groupby_geolocation_granularity, summaryColumn, summary_type, summary_method, yAxisType, value);
89
109
  if (sort_type) {
@@ -97,7 +117,11 @@ function calculateBasicChart(chart, value, username, userId) {
97
117
  });
98
118
  return results;
99
119
  }
100
- function calculateGroupingChart(chart, value, username, userId) {
120
+ async function calculateGroupingChart(chart, value, _ref3) {
121
+ let {
122
+ getViewRows,
123
+ getTableFormulaResults
124
+ } = _ref3;
101
125
  const {
102
126
  table_id,
103
127
  view_id,
@@ -115,27 +139,27 @@ function calculateGroupingChart(chart, value, username, userId) {
115
139
  let groupby_date_granularity = chart.x_axis_date_granularity;
116
140
  let groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
117
141
  let column_groupby_numeric_columns = chart.column_groupby_numeric_columns || [];
118
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
119
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
142
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
143
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
120
144
  if (!view) {
121
145
  return;
122
146
  }
123
- const groupbyColumn = groupby_column_key && _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
147
+ const groupbyColumn = groupby_column_key && (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
124
148
  if (!groupbyColumn) {
125
149
  return;
126
150
  }
127
151
  const {
128
152
  type: groupby_column_type
129
153
  } = groupbyColumn;
130
- if (_dtableStore.DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
154
+ if (_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
131
155
  groupby_date_granularity = _constants.STATISTICS_COUNT_TYPE.MONTH;
132
156
  }
133
- if (groupby_column_type === _dtableStore.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
157
+ if (groupby_column_type === _dtableUtils.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
134
158
  groupby_geolocation_granularity = _constants.STATISTICS_COUNT_TYPE.PROVINCE;
135
159
  }
136
160
  const yAxisType = null;
137
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
138
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
161
+ const statRows = await getViewRows(view, table);
162
+ const formulaRows = await getTableFormulaResults(table, statRows);
139
163
  let results = getGroupingChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty, groupby_date_granularity, groupby_geolocation_granularity, column_groupby_column_key, column_groupby_date_granularity, column_groupby_geolocation_granularity, y_axis_column_key, y_axis_summary_type, y_axis_summary_method, column_groupby_multiple_numeric_column, column_groupby_numeric_columns, yAxisType, table, value);
140
164
  _statUtils.default.sortStatistics(results, groupbyColumn, 'name');
141
165
  results = results.map(result => {
@@ -147,7 +171,7 @@ function calculateGroupingChart(chart, value, username, userId) {
147
171
  return results;
148
172
  }
149
173
  function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
150
- let columnGroupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, groupColumnKey);
174
+ let columnGroupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, groupColumnKey);
151
175
  if (!columnGroupbyColumn) {
152
176
  return [];
153
177
  }
@@ -309,16 +333,16 @@ function getGroupingChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeE
309
333
  return results;
310
334
  }
311
335
  function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumnKey, summaryType, summaryMethod, yAxisType, table, value) {
312
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summaryColumnKey);
336
+ const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summaryColumnKey);
313
337
  const columnGroupbyMultipleNumericColumn = false;
314
338
  let results = getGroupChartStatResult(table, value, groupbyColumn, columnGroupbyColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
315
- const columnGroupByColumn = _dtableStore.TableUtils.getTableColumnByKey(table, columnGroupbyColumnKey);
339
+ const columnGroupByColumn = (0, _dtableUtils.getTableColumnByKey)(table, columnGroupbyColumnKey);
316
340
  results = results.map(result => {
317
341
  const groupName = result.group_name;
318
342
  let formattedResult = {
319
343
  ...result
320
344
  };
321
- if (columnGroupByColumn.type === _dtableStore.CellType.SINGLE_SELECT) {
345
+ if (columnGroupByColumn.type === _dtableUtils.CellType.SINGLE_SELECT) {
322
346
  formattedResult.color = (0, _columnUtils.getColorFromSingleSelectColumn)(columnGroupByColumn, groupName);
323
347
  }
324
348
  formattedResult.group_name = (0, _rowUtils.getFormattedLabel)(columnGroupByColumn, groupName, value.collaborators);
@@ -327,11 +351,15 @@ function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, inclu
327
351
  return results;
328
352
  }
329
353
  function getGroupbyNumericColumnsChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, numericSummaryColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryType, summaryMethod, yAxisType, table, value) {
330
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, numericSummaryColumnKey);
354
+ const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, numericSummaryColumnKey);
331
355
  const columnGroupbyMultipleNumericColumn = true;
332
356
  return getGroupChartStatResult(table, value, groupbyColumn, numericSummaryColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
333
357
  }
334
- function calculateGeolocationBasicChart(chart, value, username, userId) {
358
+ async function calculateGeolocationBasicChart(chart, value, _ref4) {
359
+ let {
360
+ getViewRows,
361
+ getTableFormulaResults
362
+ } = _ref4;
335
363
  const {
336
364
  type,
337
365
  table_id,
@@ -341,24 +369,24 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
341
369
  summary_column,
342
370
  summary_method
343
371
  } = chart;
344
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
345
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
372
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
373
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
346
374
  if (!view) {
347
375
  return;
348
376
  }
349
- const geoColumn = geo_column && _dtableStore.TableUtils.getTableColumnByKey(table, geo_column);
377
+ const geoColumn = geo_column && (0, _dtableUtils.getTableColumnByKey)(table, geo_column);
350
378
  if (!geoColumn) {
351
379
  return;
352
380
  }
353
381
  let geolocationGranularity = null;
354
382
  if (type && type.includes('world')) {
355
- geolocationGranularity = geoColumn.type === _dtableStore.CellType.GEOLOCATION ? chart.geolocation_granularity : null;
383
+ geolocationGranularity = geoColumn.type === _dtableUtils.CellType.GEOLOCATION ? chart.geolocation_granularity : null;
356
384
  } else {
357
385
  geolocationGranularity = (0, _map.fixMapGeoGranularity)(chart);
358
386
  }
359
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column);
360
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
361
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
387
+ const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column);
388
+ const statRows = await getViewRows(view, table);
389
+ const formulaRows = await getTableFormulaResults(table, statRows);
362
390
  const geoColumnType = geoColumn.type;
363
391
  let results = [];
364
392
  statRows.forEach(row => {
@@ -367,7 +395,7 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
367
395
  } = row;
368
396
  const formulaRow = formulaRows[rowId];
369
397
  if ((0, _rowUtils.isValidRow)(row, formulaRow, geoColumn, false)) {
370
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
398
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
371
399
  const list = formulaRow[geoColumn.key];
372
400
  list.forEach(n => {
373
401
  const nameIndex = results.findIndex(r => {
@@ -395,7 +423,11 @@ function calculateGeolocationBasicChart(chart, value, username, userId) {
395
423
  updateChartValue(summaryColumn, summary_type, summary_method, formulaRows, results);
396
424
  return results;
397
425
  }
398
- function calculateCustomBar(statItem, value, username, userId) {
426
+ async function calculateCustomBar(statItem, value, _ref5) {
427
+ let {
428
+ getViewRows,
429
+ getTableFormulaResults
430
+ } = _ref5;
399
431
  const {
400
432
  table_id,
401
433
  view_id,
@@ -405,12 +437,12 @@ function calculateCustomBar(statItem, value, username, userId) {
405
437
  x_axis_include_empty,
406
438
  y_axises
407
439
  } = statItem;
408
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
409
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
440
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
441
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
410
442
  if (!view || !x_axis_column_key || !Array.isArray(y_axises) || y_axises.length === 0) {
411
443
  return [];
412
444
  }
413
- const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
445
+ const groupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
414
446
  if (!groupbyColumn) {
415
447
  return [];
416
448
  }
@@ -419,16 +451,16 @@ function calculateCustomBar(statItem, value, username, userId) {
419
451
  } = groupbyColumn;
420
452
  let groupbyDateGranularity = x_axis_date_granularity;
421
453
  let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
422
- if (_dtableStore.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
454
+ if (_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
423
455
  groupbyDateGranularity = _constants.STATISTICS_COUNT_TYPE.MONTH;
424
456
  }
425
- if (groupbyColumnType === _dtableStore.CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
457
+ if (groupbyColumnType === _dtableUtils.CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
426
458
  groupbyGeolocationGranularity = _constants.STATISTICS_COUNT_TYPE.PROVINCE;
427
459
  }
428
460
  const columnGroupbyDateGranularity = null;
429
461
  const columnGroupbyGeolocationGranularity = null;
430
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
431
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
462
+ const statRows = await getViewRows(view, table);
463
+ const formulaRows = await getTableFormulaResults(table, statRows);
432
464
  let results = [];
433
465
  y_axises.forEach((yAxis, index) => {
434
466
  const {
@@ -33,9 +33,12 @@ const typeCalculatorWorkerMap = {
33
33
  [_constants.STAT_TYPE.TREND_CHART]: _trendCalculatorWorker.default,
34
34
  [_constants.STAT_TYPE.DASHBOARD]: _dashboardCalculatorWorker.default
35
35
  };
36
- function calculator(chart, value, username, userId) {
36
+ function calculator(chart, value, getViewRows, getTableFormulaResults) {
37
37
  const type = chart.type;
38
38
  const calculatorWorker = typeCalculatorWorkerMap[type] || typeCalculatorWorkerMap[BASIC_CHART];
39
- return calculatorWorker(chart, value, username, userId);
39
+ return calculatorWorker(chart, value, {
40
+ getViewRows,
41
+ getTableFormulaResults
42
+ });
40
43
  }
41
44
  (0, _comlink.expose)(calculator);
@@ -4,27 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _commonUtils = require("../../utils/common-utils");
9
9
  var _rowUtils = require("../../utils/row-utils");
10
- function calculateResult(chart, dtableValue, username, userId) {
10
+ async function calculateResult(chart, dtableValue, _ref) {
11
+ let {
12
+ getViewRows,
13
+ getTableFormulaResults
14
+ } = _ref;
11
15
  const {
12
16
  table_id,
13
17
  view_id,
14
18
  numeric_column,
15
19
  summary_method
16
20
  } = chart;
17
- const selectedTable = _dtableStore.TableUtils.getTableById(dtableValue.tables, table_id);
18
- const selectedView = selectedTable && _dtableStore.Views.getViewById(selectedTable.views, view_id);
19
- const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, numeric_column);
20
- const _isNumericColumn = selectedColumn && (0, _dtableStore.isNumericColumn)(selectedColumn);
21
- const statRows = _dtableStore.Views.getViewRows(selectedView, selectedTable, dtableValue, username, userId);
22
- const formulaRows = _isNumericColumn ? _dtableStore.Views.getTableFormulaResults(selectedTable, statRows, dtableValue) : {};
21
+ const selectedTable = (0, _dtableUtils.getTableById)(dtableValue.tables, table_id);
22
+ const selectedView = selectedTable && (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
23
+ const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, numeric_column);
24
+ const _isNumericColumn = selectedColumn && (0, _dtableUtils.isNumericColumn)(selectedColumn);
25
+ const statRows = await getViewRows(selectedView, selectedTable);
26
+ const formulaRows = _isNumericColumn ? await getTableFormulaResults(selectedTable, statRows) : {};
23
27
  const numberList = [];
24
28
  _isNumericColumn && statRows.forEach(row => {
25
29
  const formulaRow = formulaRows[row._id];
26
30
  const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn);
27
- if ((0, _dtableStore.isNumber)(cellValue)) {
31
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
28
32
  numberList.push(cellValue);
29
33
  }
30
34
  });
@@ -5,12 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = calculateResult;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
10
10
  var _commonUtils = require("../../utils/common-utils");
11
11
  var _constants = require("../../constants");
12
12
  var _rowUtils = require("../../utils/row-utils");
13
- function calculateResult(chart, value, username, userId) {
13
+ async function calculateResult(chart, value, _ref) {
14
+ let {
15
+ getViewRows,
16
+ getTableFormulaResults
17
+ } = _ref;
14
18
  const {
15
19
  table_id,
16
20
  view_id,
@@ -27,17 +31,17 @@ function calculateResult(chart, value, username, userId) {
27
31
  y_axis_left_group_by_multiple_numeric_column,
28
32
  y_axis_left_group_by_numeric_columns
29
33
  } = chart;
30
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
31
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
34
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
35
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
32
36
  if (!view) {
33
37
  return [];
34
38
  }
35
- const xAxisColumn = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
39
+ const xAxisColumn = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
36
40
  if (!xAxisColumn) return [];
37
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
38
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
39
- const column1 = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_left_summary_column);
40
- const column2 = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_right_summary_column);
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);
41
45
  const leftResultMap = new Map();
42
46
  const rightResultMap = new Map();
43
47
  let isColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(xAxisColumn);
@@ -55,7 +59,7 @@ function calculateResult(chart, value, username, userId) {
55
59
  }
56
60
  if (y_axis_left_group_by_multiple_numeric_column) {
57
61
  y_axis_left_group_by_numeric_columns.forEach((item, index) => {
58
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, item.column_key);
62
+ const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, item.column_key);
59
63
  if (summaryColumn) {
60
64
  leftSummaryColumn[item.column_key] = {
61
65
  method: item.summary_method,
@@ -111,7 +115,7 @@ function calculateResult(chart, value, username, userId) {
111
115
  key
112
116
  });
113
117
  const currentLabelList = currentLabelMap[key] || [];
114
- if ((0, _dtableStore.isNumber)(cellValue)) {
118
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
115
119
  currentLabelList.push(cellValue);
116
120
  }
117
121
  currentLabelMap[key] = currentLabelList;
@@ -127,7 +131,7 @@ function calculateResult(chart, value, username, userId) {
127
131
  key
128
132
  });
129
133
  const currentLabelList = currentValue[key] || [];
130
- if ((0, _dtableStore.isNumber)(cellValue)) {
134
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
131
135
  currentLabelList.push(cellValue);
132
136
  }
133
137
  currentValue[key] = currentLabelList;
@@ -143,7 +147,7 @@ function calculateResult(chart, value, username, userId) {
143
147
  key
144
148
  });
145
149
  const currentList = currentValue[key] || [];
146
- if ((0, _dtableStore.isNumber)(cellValue)) {
150
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
147
151
  currentList.push(cellValue);
148
152
  }
149
153
  currentValue[key] = currentList;
@@ -182,7 +186,7 @@ function calculateResult(chart, value, username, userId) {
182
186
  if (label.length > 0) {
183
187
  label.forEach(name => {
184
188
  const currentLabelList = rightResultMap.get(name) || [];
185
- if ((0, _dtableStore.isNumber)(cellValue)) {
189
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
186
190
  currentLabelList.push(cellValue);
187
191
  }
188
192
  rightResultMap.set(name, currentLabelList);
@@ -190,7 +194,7 @@ function calculateResult(chart, value, username, userId) {
190
194
  }
191
195
  if (label.length === 0 && x_axis_include_empty) {
192
196
  let currentValue = rightResultMap.get(null) || [];
193
- if ((0, _dtableStore.isNumber)(cellValue)) {
197
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
194
198
  currentValue.push(cellValue);
195
199
  }
196
200
  rightResultMap.set(null, currentValue);
@@ -198,7 +202,7 @@ function calculateResult(chart, value, username, userId) {
198
202
  } else {
199
203
  if (x_axis_include_empty || label) {
200
204
  const currentLabelList = rightResultMap.get(label) || [];
201
- if ((0, _dtableStore.isNumber)(cellValue)) {
205
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
202
206
  currentLabelList.push(cellValue);
203
207
  }
204
208
  rightResultMap.set(label, currentLabelList);
@@ -5,12 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
10
10
  var _commonUtils = require("../../utils/common-utils");
11
11
  var _rowUtils = require("../../utils/row-utils");
12
12
  var _constants = require("../../constants");
13
- function calculateChart(chart, value, username, userId) {
13
+ async function calculateChart(chart, value, _ref) {
14
+ let {
15
+ getViewRows,
16
+ getTableFormulaResults
17
+ } = _ref;
14
18
  const {
15
19
  table_id,
16
20
  view_id,
@@ -27,18 +31,18 @@ function calculateChart(chart, value, username, userId) {
27
31
  } = chart;
28
32
  const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
29
33
  const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
30
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
31
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
34
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
35
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
32
36
  if (!view || !x_axis_column_key) {
33
37
  return [];
34
38
  }
35
- const groupbyColumn = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
39
+ const groupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
36
40
  if (!groupbyColumn) {
37
41
  return [];
38
42
  }
39
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
40
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
41
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
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);
42
46
  const dateRangeResultMap = new Map();
43
47
  const comparedDateRangeResultMap = new Map();
44
48
  const isAdvance = y_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED;
@@ -5,12 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  var _commonUtils = require("../../utils/common-utils");
10
10
  var _rowUtils = require("../../utils/row-utils");
11
11
  var _statUtils = _interopRequireDefault(require("../../utils/stat-utils"));
12
12
  var _constants = require("../../constants");
13
- function calculateResult(chart, value, username, userId) {
13
+ async function calculateResult(chart, value, _ref) {
14
+ let {
15
+ getViewRows,
16
+ getTableFormulaResults
17
+ } = _ref;
14
18
  const {
15
19
  table_id,
16
20
  view_id,
@@ -21,16 +25,16 @@ function calculateResult(chart, value, username, userId) {
21
25
  date_granularity,
22
26
  geolocation_granularity
23
27
  } = chart;
24
- const table = _dtableStore.TableUtils.getTableById(value.tables, table_id);
25
- const view = table && _dtableStore.Views.getViewById(table.views, view_id);
28
+ const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
29
+ const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
26
30
  if (!view) {
27
31
  return [];
28
32
  }
29
- const nameColumn = _dtableStore.TableUtils.getTableColumnByKey(table, name_column);
33
+ const nameColumn = (0, _dtableUtils.getTableColumnByKey)(table, name_column);
30
34
  if (!nameColumn) return [];
31
- const statRows = _dtableStore.Views.getViewRows(view, table, value, username, userId);
32
- const formulaRows = _dtableStore.Views.getTableFormulaResults(table, statRows, value);
33
- const groupColumn = _dtableStore.TableUtils.getTableColumnByKey(table, group_column);
35
+ const statRows = await getViewRows(view, table);
36
+ const formulaRows = await getTableFormulaResults(table, statRows);
37
+ const groupColumn = (0, _dtableUtils.getTableColumnByKey)(table, group_column);
34
38
  const isColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(nameColumn);
35
39
  const isGroupChart = !!groupColumn;
36
40
  let result = [];
@@ -49,12 +53,12 @@ function calculateResult(chart, value, username, userId) {
49
53
  }
50
54
  label = (0, _rowUtils.getFormattedLabel)(nameColumn, label, value.collaborators);
51
55
  if (!memo.get(label)) {
52
- const completedColumn = _dtableStore.TableUtils.getTableColumnByKey(table, completed_column);
53
- const targetColumn = _dtableStore.TableUtils.getTableColumnByKey(table, target_column);
56
+ const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
57
+ const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
54
58
  let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
55
59
  let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
56
- currentValue = (0, _dtableStore.isNumber)(currentValue) ? currentValue : 0;
57
- targetValue = (0, _dtableStore.isNumber)(targetValue) ? targetValue : 0;
60
+ currentValue = (0, _dtableUtils.isNumber)(currentValue) ? currentValue : 0;
61
+ targetValue = (0, _dtableUtils.isNumber)(targetValue) ? targetValue : 0;
58
62
  if (currentValue >= targetValue) {
59
63
  result.unshift({
60
64
  name: label,
@@ -86,7 +90,7 @@ function calculateResult(chart, value, username, userId) {
86
90
  const memo = new Map();
87
91
  const colorMap = {};
88
92
  let colorIndex = 0;
89
- let isFormulaType = _dtableStore.FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
93
+ let isFormulaType = _dtableUtils.FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
90
94
  const isGroupColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupColumn);
91
95
  statRows.forEach(row => {
92
96
  let {
@@ -114,12 +118,12 @@ function calculateResult(chart, value, username, userId) {
114
118
  }
115
119
  let cache = memo.get(label);
116
120
  if (groupLabel && (!cache || !cache[groupLabel])) {
117
- const completedColumn = _dtableStore.TableUtils.getTableColumnByKey(table, completed_column);
118
- const targetColumn = _dtableStore.TableUtils.getTableColumnByKey(table, target_column);
121
+ const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
122
+ const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
119
123
  let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
120
124
  let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
121
- currentValue = (0, _dtableStore.isNumber)(currentValue) ? currentValue : 0;
122
- targetValue = (0, _dtableStore.isNumber)(targetValue) ? targetValue : 0;
125
+ currentValue = (0, _dtableUtils.isNumber)(currentValue) ? currentValue : 0;
126
+ targetValue = (0, _dtableUtils.isNumber)(targetValue) ? targetValue : 0;
123
127
  if (currentValue >= targetValue) {
124
128
  result.unshift({
125
129
  name: label,
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _commonUtils = require("../../utils/common-utils");
9
9
  var _rowUtils = require("../../utils/row-utils");
10
- function calculateResult(chart, value, username, userId) {
10
+ async function calculateResult(chart, value, _ref) {
11
+ let {
12
+ getViewRows,
13
+ getTableFormulaResults
14
+ } = _ref;
11
15
  const {
12
16
  table_id,
13
17
  view_id,
@@ -16,17 +20,17 @@ function calculateResult(chart, value, username, userId) {
16
20
  total_value_column,
17
21
  total_value_column_summary_method
18
22
  } = chart;
19
- const selectedTable = _dtableStore.TableUtils.getTableById(value.tables, table_id);
20
- const selectedView = selectedTable && _dtableStore.Views.getViewById(selectedTable.views, view_id);
21
- const selectedColumn1 = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, target_value_column);
22
- const selectedColumn2 = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, total_value_column);
23
- const statRows = _dtableStore.Views.getViewRows(selectedView, selectedTable, value, username, userId);
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);
24
28
  if (statRows.length === 0) {
25
29
  return 0;
26
30
  }
27
- const isNumericColumn1 = selectedColumn1 && (0, _dtableStore.isNumericColumn)(selectedColumn1);
28
- const isNumericColumn2 = selectedColumn2 && (0, _dtableStore.isNumericColumn)(selectedColumn2);
29
- const formulaRows = isNumericColumn1 || isNumericColumn2 ? _dtableStore.Views.getTableFormulaResults(selectedTable, statRows, value) : {};
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) : {};
30
34
  let result1;
31
35
  let result2;
32
36
  let numberList1 = [];
@@ -35,13 +39,13 @@ function calculateResult(chart, value, username, userId) {
35
39
  const formulaRow = formulaRows[row._id];
36
40
  if (isNumericColumn1) {
37
41
  const cellValue1 = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn1);
38
- if ((0, _dtableStore.isNumber)(cellValue1)) {
42
+ if ((0, _dtableUtils.isNumber)(cellValue1)) {
39
43
  numberList1.push(cellValue1);
40
44
  }
41
45
  }
42
46
  if (isNumericColumn2) {
43
47
  const cellValue2 = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn2);
44
- if ((0, _dtableStore.isNumber)(cellValue2)) {
48
+ if ((0, _dtableUtils.isNumber)(cellValue2)) {
45
49
  numberList2.push(cellValue2);
46
50
  }
47
51
  }