sea-chart 2.0.35 → 2.0.36
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.
- package/dist/api/index.js +17 -59
- package/dist/assets/css/sea-chart-d3-tooltip.css +0 -1
- package/dist/components/color-popover/color-rules-popover.js +4 -2
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +5 -4
- package/dist/components/icon/index.js +9 -13
- package/dist/components/number-input/index.js +7 -13
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +7 -3
- package/dist/components/popover/hide-column-popover/hide-column-popover.css +5 -1
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +2 -4
- package/dist/components/popover/sort-popover/sort-popover.js +6 -7
- package/dist/components/statistic-record-dialog/index.js +9 -8
- package/dist/components/tooltip/index.js +26 -8
- package/dist/editor/index.js +5 -1
- package/dist/locale/lang/de.js +1 -0
- package/dist/locale/lang/en.js +1 -0
- package/dist/locale/lang/es.js +1 -0
- package/dist/locale/lang/fr.js +1 -0
- package/dist/locale/lang/pt.js +1 -0
- package/dist/locale/lang/ru.js +1 -0
- package/dist/locale/lang/zh_CN.js +1 -0
- package/dist/model/funnel.js +2 -2
- package/dist/model/map-bubble.js +4 -0
- package/dist/services/map-json.js +3 -0
- package/dist/settings/advance-bar-settings/data-settings.js +1 -1
- package/dist/settings/advance-bar-settings/style-settings.js +4 -3
- package/dist/settings/bar-settings/data-settings.js +1 -1
- package/dist/settings/bar-settings/style-settings.js +2 -2
- package/dist/settings/basic-number-card/data-settings.js +3 -2
- package/dist/settings/combination-settings/data-settings.js +0 -1
- package/dist/settings/combination-settings/style-settings.js +2 -2
- package/dist/settings/dashboard-settings/data-settings.js +3 -2
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +7 -7
- package/dist/settings/index.js +8 -3
- package/dist/settings/table-element-settings/components/data-filter.js +24 -25
- package/dist/settings/table-element-settings/index.css +1 -31
- package/dist/settings/table-settings/data-settings.js +3 -2
- package/dist/settings/time-comparison-settings/style-settings.js +2 -2
- package/dist/settings/widgets/basic-summary/index.js +8 -7
- package/dist/settings/widgets/common-data-settings.js +7 -6
- package/dist/settings/widgets/data-filter/index.js +30 -22
- package/dist/settings/widgets/group-by.js +4 -3
- package/dist/settings/widgets/summary-settings.js +3 -2
- package/dist/settings/widgets/y-axis-group-settings.js +3 -2
- package/dist/utils/cell-format-utils.js +9 -7
- package/dist/utils/chart-utils/base-utils.js +194 -86
- package/dist/utils/chart-utils/index.js +5 -3
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +5 -5
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +8 -2
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +12 -3
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +4 -1
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +1 -0
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +24 -3
- package/dist/utils/chart-utils/sql-statistics-utils.js +182 -177
- package/dist/utils/column-utils.js +20 -7
- package/dist/utils/contexts.js +5 -2
- package/dist/utils/index.js +25 -4
- package/dist/utils/row-record-utils.js +100 -20
- package/dist/utils/sql/column-2-sql-column.js +10 -10
- package/dist/utils/trend-utils.js +15 -2
- package/dist/view/index.css +2 -8
- package/dist/view/index.js +14 -9
- package/dist/view/wrapper/area-group.js +15 -7
- package/dist/view/wrapper/bar-compare.js +18 -2
- package/dist/view/wrapper/bar-custom-stack.js +35 -9
- package/dist/view/wrapper/bar-group.js +55 -26
- package/dist/view/wrapper/bar-stack.js +2 -2
- package/dist/view/wrapper/basic-number-card.js +27 -3
- package/dist/view/wrapper/chart-component.js +43 -440
- package/dist/view/wrapper/completeness-group.js +104 -49
- package/dist/view/wrapper/dashboard.js +68 -18
- package/dist/view/wrapper/horizontal-bar-group.js +26 -6
- package/dist/view/wrapper/horizontal-bar-stack.js +2 -2
- package/dist/view/wrapper/line-group.js +8 -3
- package/dist/view/wrapper/map-world-bubble.js +1 -0
- package/dist/view/wrapper/map-world.js +1 -0
- package/dist/view/wrapper/pie.js +1 -1
- package/dist/view/wrapper/ring.js +1 -1
- package/dist/view/wrapper/scatter.js +8 -6
- package/dist/view/wrapper/table/two-dimension-table.js +3 -2
- package/dist/view/wrapper/table-element/components/records-header/index.js +0 -1
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +3 -1
- package/dist/view/wrapper/table-element/index.js +16 -21
- package/dist/view/wrapper/trend.js +24 -1
- package/package.json +15 -12
|
@@ -122,6 +122,22 @@ 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
|
+
|
|
125
141
|
// if current chart is using "groupby_column_key" as key
|
|
126
142
|
// if groupby_column_key is null, still return false
|
|
127
143
|
let groupByColumnKey = config.groupby_column_key || config.x_axis_column_key || config.vertical_axis_column_key || config.columnKey || config.date_column_key;
|
|
@@ -158,7 +174,7 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
158
174
|
// "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"
|
|
159
175
|
summaryColumnKey = config.summary_columns[0].key || config.summary_columns[0].column_key;
|
|
160
176
|
}
|
|
161
|
-
const summaryType =
|
|
177
|
+
const summaryType = _BaseUtils.getSummaryType(config);
|
|
162
178
|
if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
|
|
163
179
|
if (summaryColumnKey) {
|
|
164
180
|
return (0, _dtableUtils.getTableColumnByKey)(table, summaryColumnKey);
|
|
@@ -553,7 +569,8 @@ BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) =>
|
|
|
553
569
|
let updatedStatistics = [];
|
|
554
570
|
for (let i = 0; i < dataList.length; i++) {
|
|
555
571
|
let item = dataList[i];
|
|
556
|
-
|
|
572
|
+
// let updated = {};
|
|
573
|
+
if (!item.name && item.name !== 0) {
|
|
557
574
|
item.name = emptyName;
|
|
558
575
|
}
|
|
559
576
|
if (column_groupby_column_key && !item.group_name) {
|
|
@@ -683,94 +700,156 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
683
700
|
};
|
|
684
701
|
// table
|
|
685
702
|
// format SINGLE_SELECT, LAST_MODIFIER, CREATOR, COLLABORATOR, DATE, NUMBER
|
|
686
|
-
BaseUtils.updateTableViewListItemNameAndColor = (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
687
|
-
|
|
688
|
-
|
|
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);
|
|
703
|
+
BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
704
|
+
return new Promise((resolve, reject) => {
|
|
705
|
+
let resultPromise = Promise.resolve();
|
|
695
706
|
let {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
result[nameKey] = name.join(', ');
|
|
715
|
-
return;
|
|
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';
|
|
716
725
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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
|
+
});
|
|
730
744
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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
|
+
});
|
|
745
764
|
}
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
} else if (columnType === _dtableUtils.CellType.LINK_FORMULA) {
|
|
749
|
-
// scatter only use number
|
|
750
|
-
if (isScatterChart) {
|
|
751
|
-
name.length && (name = name[0]);
|
|
765
|
+
return;
|
|
766
|
+
} else if (columnType === _dtableUtils.CellType.NUMBER) {
|
|
752
767
|
let valueNumber = parseFloat(name);
|
|
753
768
|
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
|
+
}
|
|
754
835
|
}
|
|
755
|
-
|
|
756
|
-
|
|
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
|
-
}
|
|
836
|
+
resolve(resultPromise);
|
|
837
|
+
});
|
|
766
838
|
};
|
|
767
|
-
BaseUtils.updateTableViewList = (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
839
|
+
BaseUtils.updateTableViewList = async (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
840
|
+
const promises = [];
|
|
768
841
|
result.forEach(result => {
|
|
769
|
-
_BaseUtils.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey, isScatterChart, isNameField);
|
|
842
|
+
const promise = _BaseUtils.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey, isScatterChart, isNameField);
|
|
843
|
+
promises.push(promise);
|
|
770
844
|
});
|
|
845
|
+
try {
|
|
846
|
+
await Promise.all(promises);
|
|
847
|
+
} catch (e) {
|
|
848
|
+
console.error(e);
|
|
849
|
+
}
|
|
771
850
|
};
|
|
772
|
-
// sort chart
|
|
773
|
-
BaseUtils.sortCharts = (
|
|
851
|
+
// sort chart result
|
|
852
|
+
BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
774
853
|
let {
|
|
775
854
|
type: columnType,
|
|
776
855
|
data
|
|
@@ -797,7 +876,7 @@ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
|
|
|
797
876
|
optionIdIndexMap[option.id] = index;
|
|
798
877
|
});
|
|
799
878
|
}
|
|
800
|
-
|
|
879
|
+
results.sort((currResult, nextResult) => {
|
|
801
880
|
let {
|
|
802
881
|
[sortKey]: current
|
|
803
882
|
} = currResult;
|
|
@@ -1136,6 +1215,32 @@ BaseUtils.convertConfig = config => {
|
|
|
1136
1215
|
}
|
|
1137
1216
|
return config;
|
|
1138
1217
|
};
|
|
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
|
+
};
|
|
1139
1244
|
BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGranularity, value) => {
|
|
1140
1245
|
let {
|
|
1141
1246
|
type,
|
|
@@ -1171,11 +1276,11 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1171
1276
|
if (!dateGranularity) {
|
|
1172
1277
|
return (0, _dtableUtils.getDateDisplayString)(cellValue);
|
|
1173
1278
|
}
|
|
1279
|
+
const firstDayOfWeek = (0, _index.getFirstDayOfWeekForGroupby)('base');
|
|
1174
1280
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
1175
|
-
|
|
1176
|
-
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
1281
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
|
|
1177
1282
|
}
|
|
1178
|
-
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
1283
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
|
|
1179
1284
|
}
|
|
1180
1285
|
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
1181
1286
|
{
|
|
@@ -1209,8 +1314,9 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1209
1314
|
if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
|
|
1210
1315
|
const dateCellValue = formulaCellValue[0];
|
|
1211
1316
|
if (!dateGranularity) return (0, _dtableUtils.getDateDisplayString)(dateCellValue);
|
|
1212
|
-
|
|
1213
|
-
return _dtableUtils.DateUtils.getDateByGranularity(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);
|
|
1214
1320
|
}
|
|
1215
1321
|
return (0, _dtableUtils.getFormulaDisplayString)(formulaCellValue, data, {
|
|
1216
1322
|
tables: value.tables
|
|
@@ -1802,7 +1908,9 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1802
1908
|
});
|
|
1803
1909
|
_BaseUtils.sortCharts(data, groupColumn, 'name');
|
|
1804
1910
|
data.forEach(item => {
|
|
1805
|
-
item
|
|
1911
|
+
if (Object.prototype.hasOwnProperty.call(item, 'oldName')) {
|
|
1912
|
+
item.name = item['oldName'];
|
|
1913
|
+
}
|
|
1806
1914
|
});
|
|
1807
1915
|
return data;
|
|
1808
1916
|
}
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "BaseUtils", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
exports.ChartUtils = void 0;
|
|
14
|
-
var
|
|
14
|
+
var _lodash = require("lodash");
|
|
15
15
|
var _context = _interopRequireDefault(require("../../context"));
|
|
16
16
|
var _ = require("..");
|
|
17
17
|
var _intl = _interopRequireDefault(require("../../intl"));
|
|
@@ -23,10 +23,12 @@ 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
|
|
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';
|
|
27
29
|
return callback && callback('', tip_message, null);
|
|
28
30
|
}
|
|
29
|
-
const id = (0,
|
|
31
|
+
const id = (0, _lodash.uniqueId)();
|
|
30
32
|
const requestData = () => {
|
|
31
33
|
_context.default.queryChartResult({
|
|
32
34
|
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.
|
|
77
|
+
if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.isDateFormulaColumn)(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.
|
|
172
|
+
if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.isDateFormulaColumn)(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,
|
|
192
|
+
function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, 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,
|
|
209
|
+
groupName = _baseUtils.default.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyDateGranularity, 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.
|
|
474
|
+
if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupbyDateGranularity) {
|
|
475
475
|
groupbyDateGranularity = _constants.CHART_SUMMARY_TYPE.MONTH;
|
|
476
476
|
}
|
|
477
477
|
if (groupbyColumnType === _dtableUtils.CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
@@ -35,9 +35,15 @@ async function calculator(chart, dtableValue, _ref) {
|
|
|
35
35
|
numberList.push(cellValue);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
let value;
|
|
38
39
|
if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
39
|
-
|
|
40
|
+
value = statRows.length;
|
|
41
|
+
} else {
|
|
42
|
+
value = _baseUtils.default.getSummaryResult(numberList, summary_method);
|
|
40
43
|
}
|
|
41
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
value,
|
|
46
|
+
rows: statRows
|
|
47
|
+
};
|
|
42
48
|
}
|
|
43
49
|
var _default = exports.default = calculator;
|
|
@@ -27,7 +27,10 @@ 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
|
|
30
|
+
return {
|
|
31
|
+
value: 0,
|
|
32
|
+
rows: []
|
|
33
|
+
};
|
|
31
34
|
}
|
|
32
35
|
const isNumericColumn1 = selectedColumn1 && (0, _dtableUtils.isNumericColumn)(selectedColumn1);
|
|
33
36
|
const isNumericColumn2 = selectedColumn2 && (0, _dtableUtils.isNumericColumn)(selectedColumn2);
|
|
@@ -62,8 +65,14 @@ async function calculator(chart, value, _ref) {
|
|
|
62
65
|
result2 = _baseUtils.default.getSummaryResult(numberList2, total_value_column_summary_method);
|
|
63
66
|
}
|
|
64
67
|
if (result2 === 0) {
|
|
65
|
-
return
|
|
68
|
+
return {
|
|
69
|
+
value: 0,
|
|
70
|
+
rows: statRows
|
|
71
|
+
};
|
|
66
72
|
}
|
|
67
|
-
return
|
|
73
|
+
return {
|
|
74
|
+
value: result1 / result2,
|
|
75
|
+
rows: statRows
|
|
76
|
+
};
|
|
68
77
|
}
|
|
69
78
|
var _default = exports.default = calculator;
|
|
@@ -243,7 +243,10 @@ 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
|
|
246
|
+
return calculateOneDimensionTable(chart, value, {
|
|
247
|
+
getViewRows,
|
|
248
|
+
getTableFormulaResults
|
|
249
|
+
});
|
|
247
250
|
}
|
|
248
251
|
const isRowGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(rowGroupbyColumn);
|
|
249
252
|
const statRows = await getViewRows(view, table);
|
|
@@ -31,6 +31,7 @@ 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
|
|
34
35
|
let formulaRows = {};
|
|
35
36
|
const rows = await getViewRows(selectedView, selectedTable);
|
|
36
37
|
const numericColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, summary_column_key);
|
|
@@ -47,6 +48,10 @@ async function calculator(chart, value, _ref) {
|
|
|
47
48
|
const dateValue = row[selectedColumn.key];
|
|
48
49
|
const label = _baseUtils.default.getGroupLabel(dateValue, {}, selectedColumn, granularity, '', value);
|
|
49
50
|
if (dateValue) {
|
|
51
|
+
// Store rows for each time period
|
|
52
|
+
const currentRows = rowsMap.get(label) || [];
|
|
53
|
+
currentRows.push(row);
|
|
54
|
+
rowsMap.set(label, currentRows);
|
|
50
55
|
if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
51
56
|
const currentCount = resultMap.get(label) || 0;
|
|
52
57
|
resultMap.set(label, currentCount + 1);
|
|
@@ -61,7 +66,7 @@ async function calculator(chart, value, _ref) {
|
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
});
|
|
64
|
-
let currentValues, previousValues;
|
|
69
|
+
let currentValues, previousValues, currentPeriodRows;
|
|
65
70
|
if (date_granularity === 'days_30' || date_granularity === 'days_7') {
|
|
66
71
|
const {
|
|
67
72
|
compareValue: value1,
|
|
@@ -69,13 +74,28 @@ async function calculator(chart, value, _ref) {
|
|
|
69
74
|
} = (0, _trendUtils.summaryDurationResult)(resultMap, date_granularity, summary_type, summary_method, false);
|
|
70
75
|
currentValues = value1;
|
|
71
76
|
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
|
+
});
|
|
72
91
|
} else {
|
|
73
92
|
const {
|
|
74
93
|
compareDate,
|
|
75
94
|
comparedDate
|
|
76
|
-
} = (0, _trendUtils.getCompareDate)(date_granularity);
|
|
95
|
+
} = (0, _trendUtils.getCompareDate)(date_granularity, 'base');
|
|
77
96
|
currentValues = resultMap.get(compareDate);
|
|
78
97
|
previousValues = resultMap.get(comparedDate);
|
|
98
|
+
currentPeriodRows = rowsMap.get(compareDate) || [];
|
|
79
99
|
if (summary_type === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
80
100
|
if (currentValues) {
|
|
81
101
|
currentValues = _baseUtils.default.getSummaryResult(currentValues, summary_method);
|
|
@@ -116,7 +136,8 @@ async function calculator(chart, value, _ref) {
|
|
|
116
136
|
latest: currentValues,
|
|
117
137
|
previous: previousValues,
|
|
118
138
|
result,
|
|
119
|
-
type
|
|
139
|
+
type,
|
|
140
|
+
rows: currentPeriodRows
|
|
120
141
|
};
|
|
121
142
|
}
|
|
122
143
|
var _default = exports.default = calculator;
|