dtable-statistic 4.0.7 → 4.0.9

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 (64) hide show
  1. package/es/calculator/basic-chart-calculator.js +27 -18
  2. package/es/calculator/combination-calculator.js +34 -9
  3. package/es/calculator/compare-bar-calculator.js +37 -30
  4. package/es/calculator/heat-map-calculator.js +25 -14
  5. package/es/calculator/map-calculator.js +25 -14
  6. package/es/calculator/mirror-calculator.js +29 -14
  7. package/es/calculator/pivot-table-calculator.js +78 -51
  8. package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
  9. package/es/calculator/workers/combination-calculator-worker.js +20 -5
  10. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
  11. package/es/calculator/workers/mirror-calculator-worker.js +15 -6
  12. package/es/calculator/workers/pivot-table-calculator-worker.js +87 -41
  13. package/es/calculator/world-map-calculator.js +25 -14
  14. package/es/components/dialog/enlarged-chart-dialog.js +2 -2
  15. package/es/components/dialog/statistic-record-dialog/index.js +71 -41
  16. package/es/constants/index.js +30 -29
  17. package/es/dashboard.js +57 -43
  18. package/es/desktop-dashboard.js +16 -51
  19. package/es/index.js +34 -2
  20. package/es/locale/lang/de.js +2 -0
  21. package/es/locale/lang/en.js +2 -0
  22. package/es/locale/lang/fr.js +2 -0
  23. package/es/locale/lang/zh_CN.js +2 -0
  24. package/es/mobile-dashboard.js +5 -5
  25. package/es/model/horizontal-bar-group.js +2 -0
  26. package/es/model/ring.js +3 -2
  27. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
  28. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  29. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +4 -1
  30. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
  31. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
  32. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
  33. package/es/stat-list/chart-preview.js +3 -4
  34. package/es/stat-list/index.js +10 -4
  35. package/es/stat-view/area-chart.js +177 -162
  36. package/es/stat-view/bar-chart.js +221 -222
  37. package/es/stat-view/base-chart.js +81 -7
  38. package/es/stat-view/basic-number-card.js +11 -19
  39. package/es/stat-view/combination-chart.js +100 -83
  40. package/es/stat-view/compare-chart.js +133 -144
  41. package/es/stat-view/completeness-chart.js +108 -102
  42. package/es/stat-view/custom-bar.js +79 -99
  43. package/es/stat-view/dashboard-chart.js +57 -57
  44. package/es/stat-view/heat-map.js +13 -32
  45. package/es/stat-view/horizontal-bar-chart.js +207 -231
  46. package/es/stat-view/index.js +2 -2
  47. package/es/stat-view/line-chart.js +162 -158
  48. package/es/stat-view/map.js +26 -40
  49. package/es/stat-view/mirror.js +88 -94
  50. package/es/stat-view/pie-chart.js +11 -39
  51. package/es/stat-view/pivot-table/index.js +4 -16
  52. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +22 -15
  53. package/es/stat-view/pivot-table/two-dimension-table.js +98 -31
  54. package/es/stat-view/ring-chart.js +24 -42
  55. package/es/stat-view/scatter-chart.js +4 -21
  56. package/es/stat-view/treemap-chart.js +3 -12
  57. package/es/stat-view/trend-chart.js +6 -17
  58. package/es/stat-view/world-map.js +39 -50
  59. package/es/tabs/tab.js +2 -1
  60. package/es/utils/common-utils.js +29 -12
  61. package/es/utils/sql-utils.js +10 -9
  62. package/es/utils/stat-utils.js +23 -15
  63. package/es/utils/trend-utils.js +1 -1
  64. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import { FORMULA_COLUMN_TYPES_MAP, isNumber, TableUtils, Views, isDateColumn, isNumericColumn } from 'dtable-store';
4
- import { SUMMARY_TYPE } from '../../constants';
4
+ import { SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../../constants';
5
5
  import { isArrayCellValue } from '../../utils/common-utils';
6
6
  import { getFormattedLabel, isValidRow } from '../../utils/row-utils';
7
7
  import StatUtils from '../../utils/stat-utils';
@@ -73,15 +73,15 @@ function calculateOneDimensionTable(chart, value, username, userId) {
73
73
  var column = TableUtils.getTableColumnByKey(table, key);
74
74
  return column ? _objectSpread({}, column) : null;
75
75
  }).filter(Boolean);
76
- if (statisticColumns.length > 1) {
76
+ if (statisticColumns.length > 0) {
77
77
  statisticColumns[0].method = summary_method;
78
- Array.isArray(summary_columns_option) && summary_columns_option.forEach(function (option, index) {
79
- if (statisticColumns[index + 1]) {
80
- statisticColumns[index + 1].method = option.method;
81
- }
82
- });
83
78
  }
84
- var _getOneDimensionTotal = getOneDimensionTotal(statisticColumns, summary_type, summary_method, formulaRows, pivot_rows),
79
+ Array.isArray(summary_columns_option) && summary_columns_option.forEach(function (option, index) {
80
+ if (statisticColumns[index + 1]) {
81
+ statisticColumns[index + 1].method = option.method;
82
+ }
83
+ });
84
+ var _getOneDimensionTotal = getOneDimensionTotal(statisticColumns, summary_type, formulaRows, pivot_rows),
85
85
  pivot_columns_total = _getOneDimensionTotal.pivot_columns_total;
86
86
  StatUtils.sortStatistics(pivot_rows, column, 'name');
87
87
  var pivot_columns = summary_type === SUMMARY_TYPE.COUNT ? [] : statisticColumns.map(function (column) {
@@ -116,8 +116,8 @@ function updateOneDimensionRows(pivot_rows, index, name, row) {
116
116
  pivot_rows.push(_updatedPivotRow);
117
117
  }
118
118
  }
119
- function getOneDimensionTotal(columns, summary_type, summary_method, formula_rows) {
120
- var statResult = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
119
+ function getOneDimensionTotal(columns, summary_type, formula_rows) {
120
+ var statResult = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
121
121
  var pivot_columns_total = {};
122
122
  var dateColumnsTotalArr = {};
123
123
  if (Array.isArray(columns) && columns.length > 0) {
@@ -138,44 +138,60 @@ function getOneDimensionTotal(columns, summary_type, summary_method, formula_row
138
138
  if (Array.isArray(columns)) {
139
139
  if (columns.length === 1) {
140
140
  var summaryColumn = columns[0];
141
- var key = summaryColumn.key;
142
- var total = getTotal(summaryColumn, summary_type, summary_method, rows, formula_rows);
141
+ var key = summaryColumn.key,
142
+ method = summaryColumn.method;
143
+ var total = getTotal(summaryColumn, summary_type, method, rows, formula_rows);
143
144
  if (summaryColumn && isDateColumn(summaryColumn)) {
144
- totalMap['total'] = total === 0 ? 0 : total.date;
145
- if (total != 0) {
146
- dateColumnsTotalArr[key].push(total);
145
+ if (method === SUMMARY_METHOD_MAP.Distinct_values) {
146
+ totalMap['total'] = total;
147
+ } else {
148
+ totalMap['total'] = total === 0 ? 0 : total.date;
149
+ if (total !== 0) {
150
+ dateColumnsTotalArr[key].push(total);
151
+ }
147
152
  }
148
- if (summary_method === 'Max') {
149
- pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], 'Max').date;
150
- } else if (summary_method === 'Min') {
151
- pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], 'Min').date;
153
+ if (method === SUMMARY_METHOD_MAP.Max) {
154
+ pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], SUMMARY_METHOD_MAP.Max).date;
155
+ } else if (method === SUMMARY_METHOD_MAP.Min) {
156
+ pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], SUMMARY_METHOD_MAP.Min).date;
157
+ } else if (method === SUMMARY_METHOD_MAP.Distinct_values) {
158
+ var pivotColumnTotal = (pivot_columns_total['total'] ? pivot_columns_total['total'] - 0 : 0) + total;
159
+ pivot_columns_total['total'] = Number.parseFloat(pivotColumnTotal.toFixed(8));
152
160
  }
153
161
  } else {
154
162
  var validTotal = total ? total - 0 : 0;
155
163
  totalMap['total'] = validTotal;
156
- var pivotColumnTotal = (pivot_columns_total['total'] ? pivot_columns_total['total'] - 0 : 0) + validTotal;
157
- pivot_columns_total['total'] = Number.parseFloat(pivotColumnTotal.toFixed(8));
164
+ var _pivotColumnTotal = (pivot_columns_total['total'] ? pivot_columns_total['total'] - 0 : 0) + validTotal;
165
+ pivot_columns_total['total'] = Number.parseFloat(_pivotColumnTotal.toFixed(8));
158
166
  }
159
167
  } else {
160
168
  columns.forEach(function (column) {
161
169
  var key = column.key,
162
170
  method = column.method;
171
+ var totalKey = key + method;
163
172
  var total = getTotal(column, summary_type, method, rows, formula_rows);
164
173
  if (column && isDateColumn(column)) {
165
- totalMap[key + method] = total === 0 ? 0 : total.date;
166
- if (total != 0) {
167
- dateColumnsTotalArr[key].push(total);
174
+ if (method === SUMMARY_METHOD_MAP.Distinct_values) {
175
+ totalMap[totalKey] = total;
176
+ } else {
177
+ totalMap[totalKey] = total === 0 ? 0 : total.date;
178
+ if (total !== 0) {
179
+ dateColumnsTotalArr[key].push(total);
180
+ }
168
181
  }
169
- if (method === 'Max') {
170
- pivot_columns_total[key + method] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], 'Max').date;
171
- } else if (method === 'Min') {
172
- pivot_columns_total[key + method] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], 'Min').date;
182
+ if (method === SUMMARY_METHOD_MAP.Max) {
183
+ pivot_columns_total[totalKey] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], SUMMARY_METHOD_MAP.Max).date;
184
+ } else if (method === SUMMARY_METHOD_MAP.Min) {
185
+ pivot_columns_total[totalKey] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], SUMMARY_METHOD_MAP.Min).date;
186
+ } else if (method === SUMMARY_METHOD_MAP.Distinct_values) {
187
+ var _pivotColumnTotal2 = (pivot_columns_total[totalKey] ? pivot_columns_total[totalKey] - 0 : 0) + total;
188
+ pivot_columns_total[totalKey] = Number.parseFloat(_pivotColumnTotal2.toFixed(8));
173
189
  }
174
190
  } else {
175
191
  var _validTotal = total ? total - 0 : 0;
176
- totalMap[key + method] = _validTotal;
177
- var _pivotColumnTotal = (pivot_columns_total[key + method] ? pivot_columns_total[key + method] - 0 : 0) + _validTotal;
178
- pivot_columns_total[key + method] = Number.parseFloat(_pivotColumnTotal.toFixed(8));
192
+ totalMap[totalKey] = _validTotal;
193
+ var _pivotColumnTotal3 = (pivot_columns_total[totalKey] ? pivot_columns_total[totalKey] - 0 : 0) + _validTotal;
194
+ pivot_columns_total[totalKey] = Number.parseFloat(_pivotColumnTotal3.toFixed(8));
179
195
  }
180
196
  });
181
197
  }
@@ -429,13 +445,17 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
429
445
  }
430
446
  }
431
447
  });
432
- if (summary_column_type != 'date') {
448
+ if (summary_column_type !== 'date') {
433
449
  pivotRow.total = Number.parseFloat(total.toFixed(8));
434
450
  pivot_table_total += total;
435
451
  }
436
452
  });
437
453
  if (summaryColumn && isDateColumn(summaryColumn)) {
438
- pivot_columns_total = showTwoDimensionDateColumnsAndRowsTotal(dateColumnsTotalArr, pivot_rows, date_summary_column_format, pivot_columns, summary_method);
454
+ if (summary_method === SUMMARY_METHOD_MAP.Distinct_values) {
455
+ pivot_columns_total = Number.parseFloat(pivot_table_total.toFixed(8));
456
+ } else {
457
+ pivot_columns_total = showTwoDimensionDateColumnsAndRowsTotal(dateColumnsTotalArr, pivot_rows, date_summary_column_format, pivot_columns, summary_method);
458
+ }
439
459
  if (summary_method === 'Max') {
440
460
  pivot_table_total = dateColumnsTotalArr.length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr, 'Max').date;
441
461
  } else if (summary_method === 'Min') {
@@ -459,6 +479,32 @@ function getTotal(summary_column, summary_type, summary_method) {
459
479
  if (summary_type === SUMMARY_TYPE.COUNT) {
460
480
  total = rowsLength;
461
481
  } else if (summary_type === SUMMARY_TYPE.ADVANCED) {
482
+ if (summary_method === SUMMARY_METHOD_MAP.Distinct_values) {
483
+ total = 0;
484
+ var existMap = {};
485
+ rows.forEach(function (row) {
486
+ var num;
487
+ if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
488
+ var formulaRow = formula_rows[row._id] || {};
489
+ num = formulaRow[summary_column_key];
490
+ num = Array.isArray(num) ? num[0] : num;
491
+ } else {
492
+ num = row[summary_column_key];
493
+ }
494
+ if (!num) {
495
+ if (num === 0) {
496
+ num = '0';
497
+ } else {
498
+ num = !!num;
499
+ }
500
+ }
501
+ if (!existMap[num]) {
502
+ existMap[num] = true;
503
+ total++;
504
+ }
505
+ });
506
+ return total;
507
+ }
462
508
  if (summary_column && isDateColumn(summary_column)) {
463
509
  if (rowsLength === 0) return;
464
510
  var dateArr = [];
@@ -483,15 +529,15 @@ function getTotal(summary_column, summary_type, summary_method) {
483
529
  formatDate.value = Date.parse(formatDateData);
484
530
  dateArr.push(formatDate);
485
531
  });
486
- if (summary_method === 'Max') {
487
- total = getDateMaxOrMinTotal(dateArr, 'Max');
488
- } else if (summary_method === 'Min') {
489
- total = getDateMaxOrMinTotal(dateArr, 'Min');
532
+ if (summary_method === SUMMARY_METHOD_MAP.Max) {
533
+ total = getDateMaxOrMinTotal(dateArr, SUMMARY_METHOD_MAP.Max);
534
+ } else if (summary_method === SUMMARY_METHOD_MAP.Min) {
535
+ total = getDateMaxOrMinTotal(dateArr, SUMMARY_METHOD_MAP.Min);
490
536
  }
491
537
  } else {
492
538
  switch (summary_method) {
493
- case 'Sum':
494
- case 'Mean':
539
+ case SUMMARY_METHOD_MAP.Sum:
540
+ case SUMMARY_METHOD_MAP.Mean:
495
541
  {
496
542
  var sum = 0;
497
543
  var validNumbersCount = 0;
@@ -519,8 +565,8 @@ function getTotal(summary_column, summary_type, summary_method) {
519
565
  }
520
566
  break;
521
567
  }
522
- case 'Max':
523
- case 'Min':
568
+ case SUMMARY_METHOD_MAP.Max:
569
+ case SUMMARY_METHOD_MAP.Min:
524
570
  {
525
571
  if (rowsLength > 0) {
526
572
  var result = rows.reduce(function (current, next) {
@@ -109,29 +109,40 @@ var WorldMapCalculator = /*#__PURE__*/function (_BaseCalculator) {
109
109
  sqlCondition = filter2SqlCondition(selectedTable, selectedView);
110
110
  summaryColumnName = '';
111
111
  sqlString = '';
112
- if (isAdvanced) {
113
- summaryColumn = TableUtils.getTableColumnByKey(selectedTable, summary_column);
114
- summaryColumnName = summaryColumn.name;
115
- summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
116
- sqlString = "select `".concat(columnName, "`, ").concat(summaryColumnMethod, " from ").concat(selectedTable.name, " ").concat(sqlCondition, " group by ").concat(columnName, " limit 5000");
117
- } else {
118
- sqlString = "select `".concat(columnName, "`, ").concat(method, "(").concat(columnName, ") from ").concat(selectedTable.name, " ").concat(sqlCondition, " group by ").concat(columnName, " limit 5000");
112
+ if (!isAdvanced) {
113
+ _context2.next = 21;
114
+ break;
115
+ }
116
+ summaryColumn = TableUtils.getTableColumnByKey(selectedTable, summary_column);
117
+ if (summaryColumn) {
118
+ _context2.next = 16;
119
+ break;
119
120
  }
120
- _context2.next = 15;
121
+ return _context2.abrupt("return", []);
122
+ case 16:
123
+ summaryColumnName = summaryColumn.name;
124
+ summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
125
+ sqlString = "select `".concat(columnName, "`, ").concat(summaryColumnMethod, " from ").concat(selectedTable.name, " ").concat(sqlCondition, " group by ").concat(columnName, " limit 5000");
126
+ _context2.next = 22;
127
+ break;
128
+ case 21:
129
+ sqlString = "select `".concat(columnName, "`, ").concat(method, "(").concat(columnName, ") from ").concat(selectedTable.name, " ").concat(sqlCondition, " group by ").concat(columnName, " limit 5000");
130
+ case 22:
131
+ _context2.next = 24;
121
132
  return this.sqlQuery(sqlString);
122
- case 15:
133
+ case 24:
123
134
  result = _context2.sent;
124
135
  if (!(result.status === 200 && result.data.success)) {
125
- _context2.next = 25;
136
+ _context2.next = 34;
126
137
  break;
127
138
  }
128
139
  data = result.data;
129
140
  if (data.results) {
130
- _context2.next = 20;
141
+ _context2.next = 29;
131
142
  break;
132
143
  }
133
144
  return _context2.abrupt("return", []);
134
- case 20:
145
+ case 29:
135
146
  newResult = [];
136
147
  _summaryColumnMethod = getSummaryColumnMethod(method, summaryColumnName);
137
148
  valueKey = isAdvanced ? "".concat(_summaryColumnMethod) : "".concat(method, "(").concat(columnName, ")");
@@ -150,9 +161,9 @@ var WorldMapCalculator = /*#__PURE__*/function (_BaseCalculator) {
150
161
  }
151
162
  });
152
163
  return _context2.abrupt("return", newResult);
153
- case 25:
164
+ case 34:
154
165
  return _context2.abrupt("return", []);
155
- case 26:
166
+ case 35:
156
167
  case "end":
157
168
  return _context2.stop();
158
169
  }
@@ -26,7 +26,7 @@ var EnlargeChartDialog = /*#__PURE__*/function (_Component) {
26
26
  _this.renderStatisticView = function () {
27
27
  var _this$props = _this.props,
28
28
  colorThemeName = _this$props.colorThemeName,
29
- refresh = _this$props.refresh,
29
+ dtableChangedTime = _this$props.dtableChangedTime,
30
30
  statItem = _this$props.statItem,
31
31
  eventBus = _this$props.eventBus,
32
32
  chartCalculator = _this$props.chartCalculator,
@@ -35,7 +35,7 @@ var EnlargeChartDialog = /*#__PURE__*/function (_Component) {
35
35
  var viewProps = {
36
36
  isEnlarge: true,
37
37
  isPreview: true,
38
- refresh: refresh,
38
+ dtableChangedTime: dtableChangedTime,
39
39
  colorThemeName: colorThemeName,
40
40
  statItem: statItem,
41
41
  eventBus: eventBus,
@@ -6,8 +6,10 @@ import React, { Fragment } from 'react';
6
6
  import intl from 'react-intl-universal';
7
7
  import { Modal, ModalBody } from 'reactstrap';
8
8
  import { CellType, Views } from 'dtable-store';
9
+ import dtableDbAPI from '../../../api/dtable-db-api';
9
10
  import { DtableSearchInput, Loading } from '../../index';
10
11
  import { searchRows } from '../../../utils';
12
+ import { getSqlString } from '../../../utils/sql-utils';
11
13
  import './index.css';
12
14
  export var UNSHOWN_COLUMN_TYPES = [CellType.LINK, CellType.LONG_TEXT, CellType.FORMULA, CellType.LINK_FORMULA];
13
15
  var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
@@ -17,11 +19,54 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
17
19
  var _this;
18
20
  _classCallCheck(this, StatisticRecordDialog);
19
21
  _this = _super.call(this, props);
22
+ _this.init = function () {
23
+ var chartRecordsParams = _this.props.chartRecordsParams;
24
+ var _ref = chartRecordsParams || {},
25
+ statisticRecord = _ref.statisticRecord,
26
+ chart = _ref.chart,
27
+ isColumn = _ref.isColumn,
28
+ isCurrentView = _ref.isCurrentView,
29
+ isRow = _ref.isRow;
30
+ var records = statisticRecord.rows,
31
+ title = statisticRecord.name;
32
+ var getTableById = _this.props.getTableById;
33
+ var table_id = chart.table_id,
34
+ view_id = chart.view_id;
35
+ var table = getTableById(table_id);
36
+ var view = Views.getViewById(table.views, view_id);
37
+ var isArchiveView = Views.isArchiveView(view);
38
+ if (isArchiveView || !records) {
39
+ var sqlString = getSqlString(chart, statisticRecord, {
40
+ isColumn: isColumn,
41
+ isCurrentView: isCurrentView,
42
+ isRow: isRow,
43
+ getTableById: getTableById
44
+ });
45
+ dtableDbAPI.sqlQuery(sqlString).then(function (res) {
46
+ var rows = res.data.results;
47
+ var searchedRows = Array.isArray(rows) && rows.length > 0 ? _this.getSearchedRows(rows) : [];
48
+ _this.setState({
49
+ loading: false,
50
+ title: title,
51
+ rows: rows,
52
+ searchedRows: searchedRows
53
+ });
54
+ });
55
+ return;
56
+ }
57
+ var searchedRows = Array.isArray(records) && records.length > 0 ? _this.getSearchedRows(records) : [];
58
+ _this.setState({
59
+ loading: false,
60
+ title: title,
61
+ rows: records,
62
+ searchedRows: searchedRows
63
+ });
64
+ };
20
65
  _this.onSearch = function (searchVal) {
21
66
  var rows = _this.state.rows;
22
- var searchRows = _this.getSearchRows(rows, searchVal);
67
+ var searchedRows = _this.getSearchedRows(rows, searchVal);
23
68
  _this.setState({
24
- searchRows: searchRows,
69
+ searchedRows: searchedRows,
25
70
  searchVal: searchVal
26
71
  });
27
72
  };
@@ -33,14 +78,14 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
33
78
  };
34
79
  _this.getStatisticTable = function () {
35
80
  var _this$props = _this.props,
36
- statistic = _this$props.statistic,
81
+ chartRecordsParams = _this$props.chartRecordsParams,
37
82
  getTableById = _this$props.getTableById;
38
- var table_id = statistic.table_id;
83
+ var table_id = chartRecordsParams.chart.table_id;
39
84
  return getTableById(table_id);
40
85
  };
41
86
  _this.getStatisticView = function (table) {
42
- var statistic = _this.props.statistic;
43
- var view_id = statistic.view_id;
87
+ var chartRecordsParams = _this.props.chartRecordsParams;
88
+ var view_id = chartRecordsParams.chart.view_id;
44
89
  return Views.getViewById(table.views, view_id);
45
90
  };
46
91
  _this.getStatisticColumns = function () {
@@ -51,11 +96,11 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
51
96
  _this.clearSearch = function () {
52
97
  var rows = _this.state.rows;
53
98
  _this.setState({
54
- searchRows: _this.getSearchRows(rows),
99
+ searchedRows: rows,
55
100
  searchVal: ''
56
101
  });
57
102
  };
58
- _this.getSearchRows = function (rows, searchVal) {
103
+ _this.getSearchedRows = function (rows, searchVal) {
59
104
  if (searchVal) {
60
105
  return searchRows(rows, _this.getStatisticColumns(), searchVal, function (row) {
61
106
  return row;
@@ -67,61 +112,46 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
67
112
  _this.props.toggleStatisticRecordsDialog();
68
113
  };
69
114
  _this.renderRowsCards = function () {
70
- var searchRows = _this.state.searchRows;
115
+ var searchedRows = _this.state.searchedRows;
116
+ if (!Array.isArray(searchedRows) || searchedRows.length === 0) {
117
+ return null;
118
+ }
71
119
  var unShowColumnKeyList = ['0000'];
72
120
  var table = _this.getStatisticTable();
73
121
  var renderedColumns = table.columns.filter(function (column) {
74
122
  return !unShowColumnKeyList.includes(column.key) && !UNSHOWN_COLUMN_TYPES.includes(column.type);
75
123
  });
76
- if (!window.app || !window.app.renderRowsCards) return;
124
+ if (!window.app || !window.app.renderRowsCards) return null;
77
125
  return window.app.renderRowsCards({
78
126
  table: table,
79
127
  renderedColumns: renderedColumns,
80
128
  unShowColumnKeyList: unShowColumnKeyList,
81
129
  isShowRowCardHeader: true,
82
130
  columns: table.columns,
83
- rows: searchRows,
131
+ rows: searchedRows,
84
132
  rowCardType: 'statistic'
85
133
  });
86
134
  };
87
135
  _this.state = {
136
+ loading: true,
137
+ title: '',
88
138
  rows: [],
89
139
  searchVal: '',
90
- searchRows: []
140
+ searchedRows: []
91
141
  };
92
142
  return _this;
93
143
  }
94
144
  _createClass(StatisticRecordDialog, [{
95
- key: "componentDidUpdate",
96
- value: function componentDidUpdate(prevProps, prevState) {
97
- var oldLoading = prevProps.isLoading;
98
- var _this$props2 = this.props,
99
- isLoading = _this$props2.isLoading,
100
- rows = _this$props2.rows;
101
- if (oldLoading !== isLoading && !isLoading) {
102
- this.setState({
103
- rows: rows,
104
- searchRows: this.getSearchRows(rows)
105
- });
106
- }
145
+ key: "componentDidMount",
146
+ value: function componentDidMount() {
147
+ this.init();
107
148
  }
108
149
  }, {
109
150
  key: "render",
110
151
  value: function render() {
111
- var _this$props3 = this.props,
112
- isLoading = _this$props3.isLoading,
113
- currentDate = _this$props3.currentDate;
114
- // const { searchRows } = this.state;
115
- // const unShowColumnKeyList = ['0000'];
116
- // let table;
117
- // let renderedColumns = [];
118
- // if (!isLoading) {
119
- // table = this.getStatisticTable();
120
- // renderedColumns = table.columns.filter(column => {
121
- // return !unShowColumnKeyList.includes(column.key) && !UNSHOWN_COLUMN_TYPES.includes(column.type);
122
- // });
123
- // }
124
-
152
+ var _this$state = this.state,
153
+ loading = _this$state.loading,
154
+ title = _this$state.title;
125
155
  return /*#__PURE__*/React.createElement(Modal, {
126
156
  isOpen: true,
127
157
  autoFocus: false,
@@ -130,7 +160,7 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
130
160
  zIndex: 1048
131
161
  }, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
132
162
  className: "search-header"
133
- }, /*#__PURE__*/React.createElement("span", null, currentDate), /*#__PURE__*/React.createElement("button", {
163
+ }, /*#__PURE__*/React.createElement("span", null, title), /*#__PURE__*/React.createElement("button", {
134
164
  type: "button",
135
165
  className: "close",
136
166
  "aria-label": "Close",
@@ -162,8 +192,8 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
162
192
  }
163
193
  })), /*#__PURE__*/React.createElement(ModalBody, {
164
194
  className: "statistic-records-container"
165
- }, isLoading ? /*#__PURE__*/React.createElement("div", {
166
- className: "py-8"
195
+ }, loading ? /*#__PURE__*/React.createElement("div", {
196
+ className: "d-flex py-8"
167
197
  }, /*#__PURE__*/React.createElement(Loading, null)) : this.renderRowsCards())));
168
198
  }
169
199
  }]);
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- var _INIT_STAT_ITEM, _MULTIPLE_CELL_VALUE_, _DATA_SORT_TYPE_LABEL, _TYPE_DISPLAY_COLOR_U, _STATISTIC_TYPE_SHOW;
2
+ var _INIT_STAT_ITEM, _MULTIPLE_CELL_VALUE_, _STAT_ITEM_THEME_COLO, _DATA_SORT_TYPE_LABEL, _TYPE_DISPLAY_COLOR_U, _STATISTIC_TYPE_SHOW;
3
3
  import { CellType } from 'dtable-store';
4
4
  import KeyCodes from './key-codes';
5
5
  import { MenuSelectStyle, UserSelectStyle } from './dtable-select-style';
@@ -97,18 +97,18 @@ export var SUMMARY_METHOD_MAP = {
97
97
  };
98
98
  export var SUMMARY_METHOD = [SUMMARY_METHOD_MAP.Sum, SUMMARY_METHOD_MAP.Max, SUMMARY_METHOD_MAP.Min, SUMMARY_METHOD_MAP.Mean, SUMMARY_METHOD_MAP.Distinct_values];
99
99
  export var MONTH_MIRROR = {
100
- '0': 'Jan.abbr',
101
- '1': 'Feb.abbr',
102
- '2': 'Mar.abbr',
103
- '3': 'Apr.abbr',
104
- '4': 'May.abbr',
105
- '5': 'Jun.abbr',
106
- '6': 'Jul.abbr',
107
- '7': 'Aug.abbr',
108
- '8': 'Sep.abbr',
109
- '9': 'Oct.abbr',
110
- '10': 'Nov.abbr',
111
- '11': 'Dec.abbr'
100
+ '0': 'Jan',
101
+ '1': 'Feb',
102
+ '2': 'Mar',
103
+ '3': 'Apr',
104
+ '4': 'May',
105
+ '5': 'Jun',
106
+ '6': 'Jul',
107
+ '7': 'Aug',
108
+ '8': 'Sep',
109
+ '9': 'Oct',
110
+ '10': 'Nov',
111
+ '11': 'Dec'
112
112
  };
113
113
  export var TIME_COLUMN_LIST = [CellType.CTIME, CellType.MTIME, CellType.DATE];
114
114
  export var MIRROR_COLUMN_LIST = [CellType.TEXT, CellType.NUMBER, CellType.CTIME, CellType.MTIME, CellType.DATE, CellType.COLLABORATOR, CellType.AUTO_NUMBER, CellType.FORMULA, CellType.GEOLOCATION, CellType.URL, CellType.SINGLE_SELECT, CellType.LINK, CellType.CREATOR, CellType.LAST_MODIFIER, CellType.DURATION, CellType.EMAIL];
@@ -409,22 +409,23 @@ export var EMPTY_NAME = 'Empty';
409
409
  export var NO_STATISTIC_RESULTS = 'There_are_no_statistic_results_yet';
410
410
  export var TOO_MANY_STATISTIC_ENTRIES = 'There_are_too_many_statistics_entries_to_display';
411
411
  export var MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP = (_MULTIPLE_CELL_VALUE_ = {}, _defineProperty(_MULTIPLE_CELL_VALUE_, CellType.MULTIPLE_SELECT, true), _defineProperty(_MULTIPLE_CELL_VALUE_, CellType.COLLABORATOR, true), _defineProperty(_MULTIPLE_CELL_VALUE_, CellType.LINK, true), _MULTIPLE_CELL_VALUE_);
412
- export var STAT_ITEM_THEME_COLORS = {
413
- dark: {
414
- textColor: '#ffffff',
415
- gridColor: '#4E4E56',
416
- labelColor: '#ffffff',
417
- legendPageNavigatorMarkerColor: '#ffffff',
418
- cardColor: '#ffffff'
419
- },
420
- light: {
421
- textColor: '#6e6e6e',
422
- gridColor: '#bfbfbf',
423
- labelColor: '#000000',
424
- legendPageNavigatorMarkerColor: '#000000',
425
- cardColor: '#545454'
426
- }
412
+ export var THEME_NAME_MAP = {
413
+ DARK: 'dark',
414
+ LIGHT: 'light'
427
415
  };
416
+ export var STAT_ITEM_THEME_COLORS = (_STAT_ITEM_THEME_COLO = {}, _defineProperty(_STAT_ITEM_THEME_COLO, THEME_NAME_MAP.DARK, {
417
+ textColor: '#ffffff',
418
+ gridColor: '#4E4E56',
419
+ labelColor: '#ffffff',
420
+ legendPageNavigatorMarkerColor: '#ffffff',
421
+ cardColor: '#ffffff'
422
+ }), _defineProperty(_STAT_ITEM_THEME_COLO, THEME_NAME_MAP.LIGHT, {
423
+ textColor: '#6e6e6e',
424
+ gridColor: '#bfbfbf',
425
+ labelColor: '#000000',
426
+ legendPageNavigatorMarkerColor: '#000000',
427
+ cardColor: '#545454'
428
+ }), _STAT_ITEM_THEME_COLO);
428
429
  export var DATA_SORT_TYPE = {
429
430
  NOT_SORTED: 'not_sorted',
430
431
  ASCENDING: 'ascending',
@@ -509,4 +510,4 @@ export var LEGEND_DIRECTION_MAP = {
509
510
  VERTICAL: 'vertical'
510
511
  };
511
512
  export var Y_AXIS_TYPE_PREFIX = '__y_axis__';
512
- export var STATISTIC_TYPE_SHOW = (_STATISTIC_TYPE_SHOW = {}, _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR, 'Basic_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR_GROUP, 'Grouped_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR_STACK, 'Stacked_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMPARE_BAR, 'Time_comparison_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.CUSTOM_BAR, 'Custom_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HORIZONTAL_BAR, 'Basic_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HORIZONTAL_GROUP_BAR, 'Grouped_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.STACKED_HORIZONTAL_BAR, 'Stacked_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMPLETENESS_CHART, 'Completeness_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.GROUP_COMPLETENESS_CHART, 'Grouped_completeness_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.LINE, 'Basic_line_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.GROUP_LINE, 'Grouped_line_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.AREA_CHART, 'Area_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.AREA_GROUP_CHART, 'Grouped_area_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.PIE, 'Basic_pie_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.RING, 'Ring_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.SCATTER, 'Scatter_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMBINATION_CHART, 'Combination_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MAP, '中国地图'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MAP_BUBBLE, '中国地图(气泡图)'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.WORLD_MAP, 'World_map'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.WORLD_MAP_BUBBLE, 'World_map_bubble'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HEAT_MAP, 'Heat_map'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MIRROR, 'Mirror_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BASIC_NUMBER_CARD, 'Basic_number_card'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.TREND_CHART, 'Trend_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.DASHBOARD, 'Gauge'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.TREEMAP, 'Treemap'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.PIVOT_TABLE, 'Pivot_table'), _STATISTIC_TYPE_SHOW);
513
+ export var STATISTIC_TYPE_SHOW = (_STATISTIC_TYPE_SHOW = {}, _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR, 'Basic_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR_GROUP, 'Grouped_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR_STACK, 'Stacked_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMPARE_BAR, 'Time_comparison_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.CUSTOM_BAR, 'Custom_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HORIZONTAL_BAR, 'Basic_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HORIZONTAL_GROUP_BAR, 'Grouped_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.STACKED_HORIZONTAL_BAR, 'Stacked_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMPLETENESS_CHART, 'Completeness_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.GROUP_COMPLETENESS_CHART, 'Grouped_completeness_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.LINE, 'Basic_line_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.GROUP_LINE, 'Grouped_line_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.AREA_CHART, 'Area_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.AREA_GROUP_CHART, 'Grouped_area_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.PIE, 'Basic_pie_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.RING, 'Ring_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.SCATTER, 'Scatter_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMBINATION_CHART, 'Combination_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MAP, '中国地图'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MAP_BUBBLE, '中国地图(气泡图)'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.WORLD_MAP, 'World_map'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HEAT_MAP, 'Heat_map'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MIRROR, 'Mirror_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BASIC_NUMBER_CARD, 'Basic_number_card'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.TREND_CHART, 'Trend_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.DASHBOARD, 'Gauge'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.TREEMAP, 'Treemap'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.PIVOT_TABLE, 'Pivot_table'), _STATISTIC_TYPE_SHOW);