sea-chart 2.0.36 → 2.0.37

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 (84) hide show
  1. package/dist/api/index.js +59 -17
  2. package/dist/assets/css/sea-chart-d3-tooltip.css +1 -0
  3. package/dist/components/color-popover/color-rules-popover.js +2 -4
  4. package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +4 -5
  5. package/dist/components/icon/index.js +13 -9
  6. package/dist/components/number-input/index.js +13 -7
  7. package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +3 -7
  8. package/dist/components/popover/hide-column-popover/hide-column-popover.css +1 -5
  9. package/dist/components/popover/hide-column-popover/hide-column-popover.js +4 -2
  10. package/dist/components/popover/sort-popover/sort-popover.js +7 -6
  11. package/dist/components/statistic-record-dialog/index.js +8 -9
  12. package/dist/components/tooltip/index.js +8 -26
  13. package/dist/editor/index.js +1 -5
  14. package/dist/locale/lang/de.js +0 -1
  15. package/dist/locale/lang/en.js +0 -1
  16. package/dist/locale/lang/es.js +0 -1
  17. package/dist/locale/lang/fr.js +0 -1
  18. package/dist/locale/lang/pt.js +0 -1
  19. package/dist/locale/lang/ru.js +0 -1
  20. package/dist/locale/lang/zh_CN.js +0 -1
  21. package/dist/model/funnel.js +2 -2
  22. package/dist/model/map-bubble.js +0 -4
  23. package/dist/services/map-json.js +0 -3
  24. package/dist/settings/advance-bar-settings/data-settings.js +1 -1
  25. package/dist/settings/advance-bar-settings/style-settings.js +3 -4
  26. package/dist/settings/bar-settings/data-settings.js +1 -1
  27. package/dist/settings/bar-settings/style-settings.js +2 -2
  28. package/dist/settings/basic-number-card/data-settings.js +2 -3
  29. package/dist/settings/combination-settings/data-settings.js +1 -0
  30. package/dist/settings/combination-settings/style-settings.js +2 -2
  31. package/dist/settings/dashboard-settings/data-settings.js +2 -3
  32. package/dist/settings/funnel-settings/components/funnel-layer-setting.js +7 -7
  33. package/dist/settings/index.js +3 -8
  34. package/dist/settings/table-element-settings/components/data-filter.js +25 -24
  35. package/dist/settings/table-element-settings/index.css +31 -1
  36. package/dist/settings/table-settings/data-settings.js +2 -3
  37. package/dist/settings/time-comparison-settings/style-settings.js +2 -2
  38. package/dist/settings/widgets/basic-summary/index.js +7 -8
  39. package/dist/settings/widgets/common-data-settings.js +6 -7
  40. package/dist/settings/widgets/data-filter/index.js +22 -30
  41. package/dist/settings/widgets/group-by.js +3 -4
  42. package/dist/settings/widgets/summary-settings.js +2 -3
  43. package/dist/settings/widgets/y-axis-group-settings.js +2 -3
  44. package/dist/utils/cell-format-utils.js +7 -9
  45. package/dist/utils/chart-utils/base-utils.js +86 -194
  46. package/dist/utils/chart-utils/index.js +3 -5
  47. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +5 -5
  48. package/dist/utils/chart-utils/original-data-utils/card-calculator.js +2 -8
  49. package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +3 -12
  50. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +1 -4
  51. package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +0 -1
  52. package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +3 -24
  53. package/dist/utils/chart-utils/sql-statistics-utils.js +177 -182
  54. package/dist/utils/column-utils.js +7 -20
  55. package/dist/utils/contexts.js +2 -5
  56. package/dist/utils/index.js +4 -25
  57. package/dist/utils/row-record-utils.js +20 -100
  58. package/dist/utils/sql/column-2-sql-column.js +10 -10
  59. package/dist/utils/trend-utils.js +2 -15
  60. package/dist/view/index.css +8 -2
  61. package/dist/view/index.js +9 -14
  62. package/dist/view/wrapper/area-group.js +7 -15
  63. package/dist/view/wrapper/bar-compare.js +2 -18
  64. package/dist/view/wrapper/bar-custom-stack.js +9 -35
  65. package/dist/view/wrapper/bar-group.js +26 -55
  66. package/dist/view/wrapper/bar-stack.js +2 -2
  67. package/dist/view/wrapper/basic-number-card.js +3 -27
  68. package/dist/view/wrapper/chart-component.js +440 -43
  69. package/dist/view/wrapper/completeness-group.js +49 -104
  70. package/dist/view/wrapper/dashboard.js +18 -68
  71. package/dist/view/wrapper/horizontal-bar-group.js +6 -26
  72. package/dist/view/wrapper/horizontal-bar-stack.js +2 -2
  73. package/dist/view/wrapper/line-group.js +3 -8
  74. package/dist/view/wrapper/map-world-bubble.js +0 -1
  75. package/dist/view/wrapper/map-world.js +0 -1
  76. package/dist/view/wrapper/pie.js +1 -1
  77. package/dist/view/wrapper/ring.js +1 -1
  78. package/dist/view/wrapper/scatter.js +6 -8
  79. package/dist/view/wrapper/table/two-dimension-table.js +2 -3
  80. package/dist/view/wrapper/table-element/components/records-header/index.js +1 -0
  81. package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +1 -3
  82. package/dist/view/wrapper/table-element/index.js +21 -16
  83. package/dist/view/wrapper/trend.js +1 -24
  84. package/package.json +14 -17
@@ -122,22 +122,6 @@ BaseUtils.isValidExistChart = (tables, chart) => {
122
122
  return (0, _dtableUtils.getTableColumnByKey)(table, totalColumnKey);
123
123
  }
124
124
 
125
- // completeness chart requires groupby_column_key, completed_column_key, and target_column_key
126
- if (config.type === _constants.CHART_TYPE.COMPLETENESS || config.type === _constants.CHART_TYPE.COMPLETENESS_GROUP) {
127
- const {
128
- groupby_column_key,
129
- completed_column_key,
130
- target_column_key
131
- } = config;
132
- if (!groupby_column_key) return false;
133
- if (!completed_column_key) return false;
134
- if (!target_column_key) return false;
135
- if (!(0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key)) return false;
136
- if (!(0, _dtableUtils.getTableColumnByKey)(table, completed_column_key)) return false;
137
- if (!(0, _dtableUtils.getTableColumnByKey)(table, target_column_key)) return false;
138
- return true;
139
- }
140
-
141
125
  // if current chart is using "groupby_column_key" as key
142
126
  // if groupby_column_key is null, still return false
143
127
  let groupByColumnKey = config.groupby_column_key || config.x_axis_column_key || config.vertical_axis_column_key || config.columnKey || config.date_column_key;
@@ -174,7 +158,7 @@ BaseUtils.isValidExistChart = (tables, chart) => {
174
158
  // "key" and "column_key" are both exists currently, "column_key" is defined in public component, to avoid bugs, better not to change "column_key" to "key"
175
159
  summaryColumnKey = config.summary_columns[0].key || config.summary_columns[0].column_key;
176
160
  }
177
- const summaryType = _BaseUtils.getSummaryType(config);
161
+ const summaryType = config.summary_type || config.y_axis_summary_type || config.horizontal_axis_summary_type;
178
162
  if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
179
163
  if (summaryColumnKey) {
180
164
  return (0, _dtableUtils.getTableColumnByKey)(table, summaryColumnKey);
@@ -569,8 +553,7 @@ BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) =>
569
553
  let updatedStatistics = [];
570
554
  for (let i = 0; i < dataList.length; i++) {
571
555
  let item = dataList[i];
572
- // let updated = {};
573
- if (!item.name && item.name !== 0) {
556
+ if (!item.name) {
574
557
  item.name = emptyName;
575
558
  }
576
559
  if (column_groupby_column_key && !item.group_name) {
@@ -700,156 +683,94 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
700
683
  };
701
684
  // table
702
685
  // format SINGLE_SELECT, LAST_MODIFIER, CREATOR, COLLABORATOR, DATE, NUMBER
703
- BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
704
- return new Promise((resolve, reject) => {
705
- let resultPromise = Promise.resolve();
686
+ BaseUtils.updateTableViewListItemNameAndColor = (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
687
+ let {
688
+ type: columnType,
689
+ data: columnData
690
+ } = column;
691
+ let name = result[nameKey];
692
+ if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
693
+ const options = (0, _dtableUtils.getColumnOptions)(column);
694
+ let selectedOption = (0, _dtableUtils.getOption)(options, name);
706
695
  let {
707
- type: columnType,
708
- data: columnData
709
- } = column;
710
- let name = result[nameKey];
711
- if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
712
- const options = (0, _dtableUtils.getColumnOptions)(column);
713
- let selectedOption = (0, _dtableUtils.getOption)(options, name);
714
- let {
715
- name: optionName,
716
- color: optionColor,
717
- id
718
- } = selectedOption || {};
719
- if (selectedOption) {
720
- result[nameKey] = optionName;
721
- result[colorKey] = optionColor;
722
- isNameField && (result.original_name = id);
723
- } else {
724
- result[colorKey] = '#dbdbdb';
696
+ name: optionName,
697
+ color: optionColor,
698
+ id
699
+ } = selectedOption || {};
700
+ if (selectedOption) {
701
+ result[nameKey] = optionName;
702
+ result[colorKey] = optionColor;
703
+ isNameField && (result.original_name = id);
704
+ } else {
705
+ result[colorKey] = '#dbdbdb';
706
+ }
707
+ } else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
708
+ (0, _collaboratorUtils.getUsers)(name, users => {
709
+ // if users not found , use name instead
710
+ if (!users.length) {
711
+ if (!Array.isArray(name)) {
712
+ name = [name];
713
+ }
714
+ result[nameKey] = name.join(', ');
715
+ return;
725
716
  }
726
- } else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
727
- const users = _context.default.getCollaboratorsFromCache();
728
- const user = users.find(user => user.email === name);
729
- if (user) {
730
- result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
731
- isNameField && (result.original_name = name);
732
- resolve();
733
- } else {
734
- _context.default.queryUsers([name], users => {
735
- const userEmail = name;
736
- const user = users[userEmail] || (0, _collaboratorUtils.generateDefaultUser)(userEmail);
737
- const userName = user.name || userEmail;
738
- result[nameKey] = userName;
739
- isNameField && (result.original_name = userEmail);
740
- user.loaded = true;
741
- _context.default.updateCollaboratorsCache(userEmail, user);
742
- resolve();
743
- });
717
+ result[nameKey] = users.map(user => user.name).join(', ');
718
+ isNameField && (result.original_name = users.map(user => user.email).join(', '));
719
+ });
720
+ } else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
721
+ // move collaborators logic to collaborator-utils.js
722
+ (0, _collaboratorUtils.getUsers)(name, users => {
723
+ // if users not found , use name instead
724
+ if (!users.length) {
725
+ if (!Array.isArray(name)) {
726
+ name = [name];
727
+ }
728
+ result[nameKey] = name.join(', ');
729
+ return;
744
730
  }
745
- return;
746
- } else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
747
- const users = _context.default.getCollaboratorsFromCache();
748
- const user = users.find(user => user.email === name);
749
- if (user) {
750
- result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
751
- isNameField && (result.original_name = name);
752
- resolve();
753
- } else {
754
- _context.default.queryUsers([name], users => {
755
- const userEmail = name;
756
- const user = users[userEmail] || (0, _collaboratorUtils.generateDefaultUser)(userEmail);
757
- const userName = user.name || userEmail;
758
- result[nameKey] = userName;
759
- isNameField && (result.original_name = userEmail);
760
- user.loaded = true;
761
- _context.default.updateCollaboratorsCache(userEmail, user);
762
- resolve();
763
- });
731
+ result[nameKey] = users.map(user => user.name).join(', ');
732
+ isNameField && (result.original_name = users.map(user => user.email).join(', '));
733
+ });
734
+ } else if (columnType === _dtableUtils.CellType.NUMBER) {
735
+ let valueNumber = parseFloat(name);
736
+ result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
737
+ isNameField && (result.original_name = name);
738
+ } else if (columnType === _dtableUtils.CellType.DATE) {
739
+ name = name + '';
740
+ if (name && name.split('-').length === 3) {
741
+ let format = (0, _columnUtils.getDateColumnFormat)(column);
742
+ let spaceIndex = format.indexOf(' ');
743
+ if (spaceIndex > -1) {
744
+ format = format.slice(0, spaceIndex);
764
745
  }
765
- return;
766
- } else if (columnType === _dtableUtils.CellType.NUMBER) {
746
+ result[nameKey] = (0, _dayjs.default)(name).format(format);
747
+ }
748
+ } else if (columnType === _dtableUtils.CellType.LINK_FORMULA) {
749
+ // scatter only use number
750
+ if (isScatterChart) {
751
+ name.length && (name = name[0]);
767
752
  let valueNumber = parseFloat(name);
768
753
  result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
769
- isNameField && (result.original_name = name);
770
- } else if (columnType === _dtableUtils.CellType.DATE) {
771
- name = name + '';
772
- if (name && name.split('-').length === 3) {
773
- let format = (0, _columnUtils.getDateColumnFormat)(column);
774
- let spaceIndex = format.indexOf(' ');
775
- if (spaceIndex > -1) {
776
- format = format.slice(0, spaceIndex);
777
- }
778
- result[nameKey] = (0, _dayjs.default)(name).format(format);
779
- }
780
- } else if (columnType === _dtableUtils.CellType.LINK_FORMULA) {
781
- // scatter only use number
782
- if (isScatterChart) {
783
- name.length && (name = name[0]);
784
- let valueNumber = parseFloat(name);
785
- result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
786
- }
787
- const {
788
- array_data,
789
- array_type
790
- } = columnData;
791
- const linkedColumn = {
792
- ...column,
793
- type: array_type,
794
- data: array_data
795
- };
796
- // for linked formula, need to call recursively, using it's result as the result of the promise
797
- resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
798
- } else if (columnType === _dtableUtils.CellType.FORMULA) {
799
- const {
800
- result_type: resultType,
801
- array_type: arrayType,
802
- array_data: arrayData
803
- } = columnData || {};
804
- if (resultType === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
805
- const valueNumber = parseFloat(name);
806
- result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
807
- isNameField && (result.original_name = name);
808
- } else if (resultType === _dtableUtils.FORMULA_RESULT_TYPE.DATE || resultType === _dtableUtils.CellType.CTIME || resultType === _dtableUtils.CellType.MTIME) {
809
- result[nameKey] = (0, _dtableUtils.getFormulaDisplayString)(name, columnData);
810
- isNameField && (result.original_name = name);
811
- } else if (arrayType && arrayData) {
812
- const formulaArrayColumn = {
813
- ...column,
814
- type: arrayType,
815
- data: arrayData
816
- };
817
- resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, formulaArrayColumn, nameKey, colorKey, isScatterChart, isNameField);
818
- } else if (Array.isArray(name)) {
819
- result[nameKey] = name.map(item => {
820
- if ((0, _collaborator.isValidCollaboratorEmail)(item)) {
821
- const collaborator = (0, _collaboratorUtils.getKnownCollaboratorByEmail)(item);
822
- return collaborator ? collaborator.name : item;
823
- }
824
- return item;
825
- }).join(', ');
826
- isNameField && (result.original_name = name.join(', '));
827
- } else if (typeof name === 'string' && (0, _collaborator.isValidCollaboratorEmail)(name)) {
828
- const collaborator = (0, _collaboratorUtils.getKnownCollaboratorByEmail)(name);
829
- result[nameKey] = collaborator ? collaborator.name : name;
830
- isNameField && (result.original_name = name);
831
- } else {
832
- result[nameKey] = (0, _dtableUtils.getFormulaDisplayString)(name, columnData);
833
- isNameField && (result.original_name = name);
834
- }
835
754
  }
836
- resolve(resultPromise);
837
- });
755
+ const {
756
+ array_data,
757
+ array_type
758
+ } = columnData;
759
+ const linkedColumn = {
760
+ ...column,
761
+ type: array_type,
762
+ data: array_data
763
+ };
764
+ return _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
765
+ }
838
766
  };
839
- BaseUtils.updateTableViewList = async (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
840
- const promises = [];
767
+ BaseUtils.updateTableViewList = (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
841
768
  result.forEach(result => {
842
- const promise = _BaseUtils.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey, isScatterChart, isNameField);
843
- promises.push(promise);
769
+ _BaseUtils.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey, isScatterChart, isNameField);
844
770
  });
845
- try {
846
- await Promise.all(promises);
847
- } catch (e) {
848
- console.error(e);
849
- }
850
771
  };
851
- // sort chart result
852
- BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
772
+ // sort chart
773
+ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
853
774
  let {
854
775
  type: columnType,
855
776
  data
@@ -876,7 +797,7 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
876
797
  optionIdIndexMap[option.id] = index;
877
798
  });
878
799
  }
879
- results.sort((currResult, nextResult) => {
800
+ charts.sort((currResult, nextResult) => {
880
801
  let {
881
802
  [sortKey]: current
882
803
  } = currResult;
@@ -1215,32 +1136,6 @@ BaseUtils.convertConfig = config => {
1215
1136
  }
1216
1137
  return config;
1217
1138
  };
1218
- BaseUtils.getSummaryType = config => {
1219
- switch (config.type) {
1220
- case _constants.CHART_TYPE.HORIZONTAL_BAR:
1221
- case _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR:
1222
- case _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR:
1223
- {
1224
- return config.horizontal_axis_summary_type;
1225
- }
1226
- case _constants.CHART_TYPE.BAR:
1227
- case _constants.CHART_TYPE.BAR_GROUP:
1228
- case _constants.CHART_TYPE.BAR_STACK:
1229
- case _constants.CHART_TYPE.LINE:
1230
- case _constants.CHART_TYPE.LINE_GROUP:
1231
- case _constants.CHART_TYPE.AREA:
1232
- case _constants.CHART_TYPE.AREA_GROUP:
1233
- case _constants.CHART_TYPE.SCATTER:
1234
- {
1235
- return config.y_axis_summary_type;
1236
- }
1237
- case _constants.CHART_TYPE.TABLE:
1238
- default:
1239
- {
1240
- return config.summary_type;
1241
- }
1242
- }
1243
- };
1244
1139
  BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGranularity, value) => {
1245
1140
  let {
1246
1141
  type,
@@ -1276,11 +1171,11 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
1276
1171
  if (!dateGranularity) {
1277
1172
  return (0, _dtableUtils.getDateDisplayString)(cellValue);
1278
1173
  }
1279
- const firstDayOfWeek = (0, _index.getFirstDayOfWeekForGroupby)('base');
1280
1174
  if (dateGranularity.toUpperCase() === 'QUARTER') {
1281
- return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
1175
+ // TODO: fix the unknown word 'QUARTAR'
1176
+ return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
1282
1177
  }
1283
- return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
1178
+ return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity);
1284
1179
  }
1285
1180
  case _dtableUtils.CellType.MULTIPLE_SELECT:
1286
1181
  {
@@ -1314,9 +1209,8 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
1314
1209
  if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
1315
1210
  const dateCellValue = formulaCellValue[0];
1316
1211
  if (!dateGranularity) return (0, _dtableUtils.getDateDisplayString)(dateCellValue);
1317
- const firstDayOfWeek = (0, _index.getFirstDayOfWeekForGroupby)('base');
1318
- if (dateGranularity.toUpperCase() === 'QUARTER') return _dtableUtils.DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR', firstDayOfWeek);
1319
- return _dtableUtils.DateUtils.getDateByGranularity(dateCellValue, dateGranularity, firstDayOfWeek);
1212
+ if (dateGranularity.toUpperCase() === 'QUARTER') return _dtableUtils.DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR');
1213
+ return _dtableUtils.DateUtils.getDateByGranularity(dateCellValue, dateGranularity);
1320
1214
  }
1321
1215
  return (0, _dtableUtils.getFormulaDisplayString)(formulaCellValue, data, {
1322
1216
  tables: value.tables
@@ -1908,9 +1802,7 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
1908
1802
  });
1909
1803
  _BaseUtils.sortCharts(data, groupColumn, 'name');
1910
1804
  data.forEach(item => {
1911
- if (Object.prototype.hasOwnProperty.call(item, 'oldName')) {
1912
- item.name = item['oldName'];
1913
- }
1805
+ item.name = item['oldName'];
1914
1806
  });
1915
1807
  return data;
1916
1808
  }
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "BaseUtils", {
11
11
  }
12
12
  });
13
13
  exports.ChartUtils = void 0;
14
- var _lodash = require("lodash");
14
+ var _lodashEs = require("lodash-es");
15
15
  var _context = _interopRequireDefault(require("../../context"));
16
16
  var _ = require("..");
17
17
  var _intl = _interopRequireDefault(require("../../intl"));
@@ -23,12 +23,10 @@ class ChartUtils {}
23
23
  exports.ChartUtils = ChartUtils;
24
24
  ChartUtils.calculateChart = async (chart, value, callback) => {
25
25
  if (!_baseUtils.default.isValidExistChart(value.tables, chart)) {
26
- const roleId = _context.default.getSetting('roleId');
27
- const isEditAppPage = _context.default.getSetting('isEditAppPage');
28
- const tip_message = !roleId && !isEditAppPage ? 'The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations' : 'Please_complete_the_chart_configuration_first';
26
+ const tip_message = 'Please_complete_the_chart_configuration_first';
29
27
  return callback && callback('', tip_message, null);
30
28
  }
31
- const id = (0, _lodash.uniqueId)();
29
+ const id = (0, _lodashEs.uniqueId)();
32
30
  const requestData = () => {
33
31
  _context.default.queryChartResult({
34
32
  chart,
@@ -74,7 +74,7 @@ async function calculateBasicChart(chart, value, _ref) {
74
74
  const {
75
75
  type: groupby_column_type
76
76
  } = groupbyColumn;
77
- if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupby_date_granularity) {
77
+ if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.islinkDateFormula)(groupbyColumn)) && !groupby_date_granularity) {
78
78
  groupby_date_granularity = _constants.CHART_SUMMARY_TYPE.MONTH;
79
79
  if ([_constants.CHART_TYPE.HEAT_MAP].includes(chart.type)) {
80
80
  groupby_date_granularity = _constants.CHART_SUMMARY_TYPE.DAY;
@@ -169,7 +169,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
169
169
  const {
170
170
  type: groupby_column_type
171
171
  } = groupbyColumn;
172
- if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupby_date_granularity) {
172
+ if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.islinkDateFormula)(groupbyColumn)) && !groupby_date_granularity) {
173
173
  groupby_date_granularity = _constants.CHART_SUMMARY_TYPE.MONTH;
174
174
  }
175
175
  if (groupby_column_type === _dtableUtils.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
@@ -189,7 +189,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
189
189
  });
190
190
  return results;
191
191
  }
192
- function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
192
+ function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
193
193
  let columnGroupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, groupColumnKey);
194
194
  if (!columnGroupbyColumn) {
195
195
  return [];
@@ -206,7 +206,7 @@ function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, st
206
206
  let name = _baseUtils.default.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
207
207
  let groupName = columnGroupbyColumn.name;
208
208
  if (!columnGroupbyMultipleNumericColumn) {
209
- groupName = _baseUtils.default.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, value);
209
+ groupName = _baseUtils.default.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyGateGranularity, columnGroupbyGeolocationGranularity, value);
210
210
  }
211
211
  if (isGroupbyColumnDataAsAnArray) {
212
212
  if (name.length === 0 && includeEmpty) {
@@ -471,7 +471,7 @@ async function calculateCustomBar(statItem, value, _ref4) {
471
471
  } = groupbyColumn;
472
472
  let groupbyDateGranularity = x_axis_date_granularity;
473
473
  let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
474
- if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupbyDateGranularity) {
474
+ if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || (0, _columnUtils.islinkDateFormula)(groupbyColumn)) && !groupbyDateGranularity) {
475
475
  groupbyDateGranularity = _constants.CHART_SUMMARY_TYPE.MONTH;
476
476
  }
477
477
  if (groupbyColumnType === _dtableUtils.CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
@@ -35,15 +35,9 @@ async function calculator(chart, dtableValue, _ref) {
35
35
  numberList.push(cellValue);
36
36
  }
37
37
  });
38
- let value;
39
38
  if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
40
- value = statRows.length;
41
- } else {
42
- value = _baseUtils.default.getSummaryResult(numberList, summary_method);
39
+ return statRows.length;
43
40
  }
44
- return {
45
- value,
46
- rows: statRows
47
- };
41
+ return _baseUtils.default.getSummaryResult(numberList, summary_method);
48
42
  }
49
43
  var _default = exports.default = calculator;
@@ -27,10 +27,7 @@ async function calculator(chart, value, _ref) {
27
27
  const selectedColumn2 = (0, _dtableUtils.getTableColumnByKey)(selectedTable, total_value_column_key);
28
28
  const statRows = await getViewRows(selectedView, selectedTable);
29
29
  if (statRows.length === 0) {
30
- return {
31
- value: 0,
32
- rows: []
33
- };
30
+ return 0;
34
31
  }
35
32
  const isNumericColumn1 = selectedColumn1 && (0, _dtableUtils.isNumericColumn)(selectedColumn1);
36
33
  const isNumericColumn2 = selectedColumn2 && (0, _dtableUtils.isNumericColumn)(selectedColumn2);
@@ -65,14 +62,8 @@ async function calculator(chart, value, _ref) {
65
62
  result2 = _baseUtils.default.getSummaryResult(numberList2, total_value_column_summary_method);
66
63
  }
67
64
  if (result2 === 0) {
68
- return {
69
- value: 0,
70
- rows: statRows
71
- };
65
+ return 0;
72
66
  }
73
- return {
74
- value: result1 / result2,
75
- rows: statRows
76
- };
67
+ return result1 / result2;
77
68
  }
78
69
  var _default = exports.default = calculator;
@@ -243,10 +243,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
243
243
  const isGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(groupbyColumn);
244
244
  const rowGroupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, column_groupby_column_key);
245
245
  if (!rowGroupbyColumn) {
246
- return calculateOneDimensionTable(chart, value, {
247
- getViewRows,
248
- getTableFormulaResults
249
- });
246
+ return calculateOneDimensionTable(chart, value);
250
247
  }
251
248
  const isRowGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(rowGroupbyColumn);
252
249
  const statRows = await getViewRows(view, table);
@@ -74,7 +74,6 @@ async function calculator(chart, value, _ref) {
74
74
  };
75
75
  updateBasicChartRows(data, nameIndex, name, dataItem, row);
76
76
  });
77
- _baseUtils.default.sortCharts(data, selectedXAxisColumn, 'name');
78
77
  return data;
79
78
  }
80
79
  var _default = exports.default = calculator;
@@ -31,7 +31,6 @@ async function calculator(chart, value, _ref) {
31
31
  const selectedView = selectedTable && (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
32
32
  const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, date_column_key);
33
33
  const resultMap = new Map();
34
- const rowsMap = new Map(); // Store rows for each time period
35
34
  let formulaRows = {};
36
35
  const rows = await getViewRows(selectedView, selectedTable);
37
36
  const numericColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, summary_column_key);
@@ -48,10 +47,6 @@ async function calculator(chart, value, _ref) {
48
47
  const dateValue = row[selectedColumn.key];
49
48
  const label = _baseUtils.default.getGroupLabel(dateValue, {}, selectedColumn, granularity, '', value);
50
49
  if (dateValue) {
51
- // Store rows for each time period
52
- const currentRows = rowsMap.get(label) || [];
53
- currentRows.push(row);
54
- rowsMap.set(label, currentRows);
55
50
  if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
56
51
  const currentCount = resultMap.get(label) || 0;
57
52
  resultMap.set(label, currentCount + 1);
@@ -66,7 +61,7 @@ async function calculator(chart, value, _ref) {
66
61
  }
67
62
  }
68
63
  });
69
- let currentValues, previousValues, currentPeriodRows;
64
+ let currentValues, previousValues;
70
65
  if (date_granularity === 'days_30' || date_granularity === 'days_7') {
71
66
  const {
72
67
  compareValue: value1,
@@ -74,28 +69,13 @@ async function calculator(chart, value, _ref) {
74
69
  } = (0, _trendUtils.summaryDurationResult)(resultMap, date_granularity, summary_type, summary_method, false);
75
70
  currentValues = value1;
76
71
  previousValues = value2;
77
- // Collect rows for the current period (last 7 or 30 days)
78
- currentPeriodRows = [];
79
- const currentTime = (0, _dayjs.default)();
80
- const days = date_granularity === 'days_30' ? 30 : 7;
81
- const formattedEndDate = currentTime.format('YYYY-MM-DD');
82
- const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
83
- const endDate = (0, _dayjs.default)(formattedEndDate);
84
- const middleDate = (0, _dayjs.default)(formattedMiddleDate);
85
- rowsMap.forEach((periodRows, label) => {
86
- const key = (0, _dayjs.default)(label);
87
- if (key.isValid() && key >= middleDate && key < endDate) {
88
- currentPeriodRows = currentPeriodRows.concat(periodRows);
89
- }
90
- });
91
72
  } else {
92
73
  const {
93
74
  compareDate,
94
75
  comparedDate
95
- } = (0, _trendUtils.getCompareDate)(date_granularity, 'base');
76
+ } = (0, _trendUtils.getCompareDate)(date_granularity);
96
77
  currentValues = resultMap.get(compareDate);
97
78
  previousValues = resultMap.get(comparedDate);
98
- currentPeriodRows = rowsMap.get(compareDate) || [];
99
79
  if (summary_type === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
100
80
  if (currentValues) {
101
81
  currentValues = _baseUtils.default.getSummaryResult(currentValues, summary_method);
@@ -136,8 +116,7 @@ async function calculator(chart, value, _ref) {
136
116
  latest: currentValues,
137
117
  previous: previousValues,
138
118
  result,
139
- type,
140
- rows: currentPeriodRows
119
+ type
141
120
  };
142
121
  }
143
122
  var _default = exports.default = calculator;