sea-chart 1.1.97 → 1.1.99
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/settings/advance-bar-settings/data-settings.js +2 -2
- package/dist/settings/bar-settings/data-settings.js +2 -2
- package/dist/settings/widgets/group-by.js +2 -2
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +4 -4
- package/dist/utils/chart-utils/sql-statistics-utils.js +8 -8
- package/dist/utils/column-utils.js +14 -3
- package/dist/utils/index.js +1 -1
- package/dist/utils/sql/column-2-sql-column.js +5 -7
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import CommonDataSettings from '../widgets/common-data-settings';
|
|
|
5
5
|
import Divider from '../widgets/divider';
|
|
6
6
|
import GroupBy from '../widgets/group-by';
|
|
7
7
|
import YAxisGroupSettings from '../widgets/y-axis-group-settings';
|
|
8
|
-
import {
|
|
8
|
+
import { isDateFormulaColumn } from '../../utils/column-utils';
|
|
9
9
|
import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, SUPPORT_DATA_SORT_CHART_TYPES } from '../../constants';
|
|
10
10
|
import intl from '../../intl';
|
|
11
11
|
import DataSort from '../widgets/data-sort';
|
|
@@ -38,7 +38,7 @@ const DataSettings = _ref => {
|
|
|
38
38
|
update['x_axis_date_granularity'] = null;
|
|
39
39
|
update['x_axis_geolocation_granularity'] = null;
|
|
40
40
|
} else {
|
|
41
|
-
if (DATE_COLUMN_OPTIONS.includes(type) ||
|
|
41
|
+
if (DATE_COLUMN_OPTIONS.includes(type) || isDateFormulaColumn(column)) {
|
|
42
42
|
update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
|
|
43
43
|
update['x_axis_geolocation_granularity'] = null;
|
|
44
44
|
} else if (type === CellType.GEOLOCATION) {
|
|
@@ -7,7 +7,7 @@ import Divider from '../widgets/divider';
|
|
|
7
7
|
import GroupBy from '../widgets/group-by';
|
|
8
8
|
import BasicSummary from '../widgets/basic-summary';
|
|
9
9
|
import DataSort from '../widgets/data-sort';
|
|
10
|
-
import {
|
|
10
|
+
import { isDateFormulaColumn } from '../../utils/column-utils';
|
|
11
11
|
import { CHART_SUMMARY_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, CHART_SUMMARY_TYPES, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, CHART_TYPE } from '../../constants';
|
|
12
12
|
const DataSettings = _ref => {
|
|
13
13
|
let {
|
|
@@ -38,7 +38,7 @@ const DataSettings = _ref => {
|
|
|
38
38
|
update['x_axis_date_granularity'] = null;
|
|
39
39
|
update['x_axis_geolocation_granularity'] = null;
|
|
40
40
|
} else {
|
|
41
|
-
if (DATE_COLUMN_OPTIONS.includes(type) ||
|
|
41
|
+
if (DATE_COLUMN_OPTIONS.includes(type) || isDateFormulaColumn(column)) {
|
|
42
42
|
update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
|
|
43
43
|
update['x_axis_geolocation_granularity'] = null;
|
|
44
44
|
} else if (type === CellType.GEOLOCATION) {
|
|
@@ -4,7 +4,7 @@ import React, { Component } from 'react';
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { Label, FormGroup } from 'reactstrap';
|
|
6
6
|
import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
7
|
-
import {
|
|
7
|
+
import { isDateFormulaColumn } from '../../utils/column-utils';
|
|
8
8
|
import { CHART_SUPPORT_COLUMNS, DATE_GRANULATES, GEOLOCATION_GRANULATES, CHART_SUMMARY_SHOW, GEOLOCATION_FORMAT_MAP, CHART_TYPE, TIME_COLUMN_LIST, COMPLETENESS_GROUPBY_SUPPORTED_COLUMN_TYPE, NUMBERIC_COLUMN_TYPE, MIRROR_COLUMN_LIST } from '../../constants';
|
|
9
9
|
import intl from '../../intl';
|
|
10
10
|
class GroupBy extends Component {
|
|
@@ -185,7 +185,7 @@ class GroupBy extends Component {
|
|
|
185
185
|
const {
|
|
186
186
|
type: groupbyColumnType
|
|
187
187
|
} = groupbyColumn;
|
|
188
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) ||
|
|
188
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || isDateFormulaColumn(groupbyColumn)) && this.renderGroupbyDateGranulates(), groupbyColumnType === CellType.GEOLOCATION && this.geolocationGranulatesOptions.length > 0 && this.renderGroupbyGeolocationGranulates());
|
|
189
189
|
};
|
|
190
190
|
this.dateGranulatesOptions = this.generatorGranulatesOptions(DATE_GRANULATES);
|
|
191
191
|
this.initOptions(_props);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import { CellType, DATE_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
3
3
|
import { CHART_STYLE_COLORS, CHART_SUMMARY_TYPE, CHART_TYPE, Y_AXIS_TYPE_PREFIX } from '../../../constants';
|
|
4
|
-
import { getColorFromSingleSelectColumn,
|
|
4
|
+
import { getColorFromSingleSelectColumn, isDateFormulaColumn } from '../../column-utils';
|
|
5
5
|
import { isArrayCellValue } from '../../cell-value-utils';
|
|
6
6
|
import { getFormattedLabel, isValidRow } from '../../row-utils';
|
|
7
7
|
import { fixGeoGranularity } from '../../map';
|
|
@@ -67,7 +67,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
67
67
|
const {
|
|
68
68
|
type: groupby_column_type
|
|
69
69
|
} = groupbyColumn;
|
|
70
|
-
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) ||
|
|
70
|
+
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || isDateFormulaColumn(groupbyColumn)) && !groupby_date_granularity) {
|
|
71
71
|
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
72
72
|
if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
73
73
|
groupby_date_granularity = CHART_SUMMARY_TYPE.DAY;
|
|
@@ -162,7 +162,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
162
162
|
const {
|
|
163
163
|
type: groupby_column_type
|
|
164
164
|
} = groupbyColumn;
|
|
165
|
-
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) ||
|
|
165
|
+
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || isDateFormulaColumn(groupbyColumn)) && !groupby_date_granularity) {
|
|
166
166
|
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
167
167
|
}
|
|
168
168
|
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
@@ -464,7 +464,7 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
464
464
|
} = groupbyColumn;
|
|
465
465
|
let groupbyDateGranularity = x_axis_date_granularity;
|
|
466
466
|
let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
|
|
467
|
-
if ((DATE_COLUMN_OPTIONS.includes(groupbyColumnType) ||
|
|
467
|
+
if ((DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || isDateFormulaColumn(groupbyColumn)) && !groupbyDateGranularity) {
|
|
468
468
|
groupbyDateGranularity = CHART_SUMMARY_TYPE.MONTH;
|
|
469
469
|
}
|
|
470
470
|
if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
@@ -64,23 +64,23 @@ SQLStatisticsUtils.getGroupLabelFromDB = async (cellValue, column, chart, isPivo
|
|
|
64
64
|
return cellValue || null;
|
|
65
65
|
}
|
|
66
66
|
case CellType.FORMULA:
|
|
67
|
+
{
|
|
68
|
+
if (Array.isArray(cellValue)) {
|
|
69
|
+
const validValue = getFormulaDisplayString(cellValue, data) || [];
|
|
70
|
+
return validValue;
|
|
71
|
+
}
|
|
72
|
+
return cellValue || null;
|
|
73
|
+
}
|
|
67
74
|
case CellType.LINK_FORMULA:
|
|
68
75
|
{
|
|
69
76
|
const {
|
|
70
|
-
array_type,
|
|
71
77
|
result_type
|
|
72
78
|
} = data || {};
|
|
73
|
-
const validValue = getFormulaDisplayString(cellValue, data) || [];
|
|
74
|
-
if (array_type === 'date' && (cellValue === null || cellValue === void 0 ? void 0 : cellValue.length) === 1) {
|
|
75
|
-
if (!dateGranularity) return validValue;
|
|
76
|
-
if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(validValue, 'QUARTAR');
|
|
77
|
-
return DateUtils.getDateByGranularity(validValue, dateGranularity);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
79
|
// handles mutiple select
|
|
81
80
|
if (result_type === 'array') {
|
|
82
81
|
return cellValue;
|
|
83
82
|
}
|
|
83
|
+
const validValue = getFormulaDisplayString(cellValue, data) || [];
|
|
84
84
|
if (!validValue && validValue !== 0) {
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
@@ -173,16 +173,27 @@ export const isStatisticMirrorColumn = column => {
|
|
|
173
173
|
if (!column) return false;
|
|
174
174
|
return MIRROR_COLUMN_LIST.includes(column.type);
|
|
175
175
|
};
|
|
176
|
-
export const
|
|
176
|
+
export const isDateFormulaColumn = column => {
|
|
177
177
|
if (column) {
|
|
178
178
|
const {
|
|
179
179
|
type,
|
|
180
180
|
data
|
|
181
181
|
} = column;
|
|
182
182
|
const {
|
|
183
|
-
array_type
|
|
183
|
+
array_type,
|
|
184
|
+
result_type
|
|
184
185
|
} = data || {};
|
|
185
|
-
|
|
186
|
+
// formula or link formula
|
|
187
|
+
if (type === 'link-formula' && array_type === 'date' || type === 'formula' && result_type === FORMULA_RESULT_TYPE.DATE) return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
};
|
|
191
|
+
export const isDateColumn = column => {
|
|
192
|
+
if (column) {
|
|
193
|
+
const {
|
|
194
|
+
type
|
|
195
|
+
} = column;
|
|
196
|
+
return type === CellType.CTIME || type === CellType.MTIME || type === CellType.DATE;
|
|
186
197
|
}
|
|
187
198
|
return false;
|
|
188
199
|
};
|
package/dist/utils/index.js
CHANGED
|
@@ -248,6 +248,6 @@ export const getFirstDayOfWeekForGroupby = source => {
|
|
|
248
248
|
} = dtableSettings || {};
|
|
249
249
|
firstDayOfWeek = date_settings === null || date_settings === void 0 ? void 0 : date_settings.first_day_of_week;
|
|
250
250
|
}
|
|
251
|
-
return firstDayOfWeek;
|
|
251
|
+
return firstDayOfWeek || 'Monday';
|
|
252
252
|
};
|
|
253
253
|
export { ObjectUtils, chartColumn2SqlColumn, summaryMethodColumn2SqlColumn, ChartUtils, ChartDataSQL, BaseUtils };
|
|
@@ -2,7 +2,7 @@ import { CellType, getTableColumnByKey } from 'dtable-utils';
|
|
|
2
2
|
import { CHART_SUMMARY_TYPE, CHART_TYPE, DTABLE_DB_SUMMARY_METHOD, MAP_LEVEL } from '../../constants';
|
|
3
3
|
import BaseUtils from '../chart-utils/base-utils';
|
|
4
4
|
import { fixGeoGranularity } from '../map';
|
|
5
|
-
import { getSqlGroup } from '../column-utils';
|
|
5
|
+
import { getSqlGroup, isDateColumn, isDateFormulaColumn } from '../column-utils';
|
|
6
6
|
import intl from '../../intl';
|
|
7
7
|
import { getFirstDayOfWeekForGroupby } from '../index';
|
|
8
8
|
export const column2SqlColumn = function (column) {
|
|
@@ -12,15 +12,13 @@ export const column2SqlColumn = function (column) {
|
|
|
12
12
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
13
|
const {
|
|
14
14
|
name,
|
|
15
|
-
type,
|
|
16
15
|
key
|
|
17
16
|
} = column;
|
|
18
17
|
const validColumnName = `\`${name}\``;
|
|
19
18
|
const startOfWeek = getFirstDayOfWeekForGroupby('app').toLowerCase();
|
|
20
|
-
switch (
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
case CellType.CTIME:
|
|
19
|
+
switch (true) {
|
|
20
|
+
case isDateColumn(column):
|
|
21
|
+
case isDateFormulaColumn(column):
|
|
24
22
|
{
|
|
25
23
|
const validDateGranularity = dateGranularity && dateGranularity.toUpperCase();
|
|
26
24
|
if (['DAY', 'DAYS_7', 'DAYS_30'].includes(validDateGranularity)) {
|
|
@@ -71,7 +69,7 @@ export const column2SqlColumn = function (column) {
|
|
|
71
69
|
key: sqlColumnName
|
|
72
70
|
};
|
|
73
71
|
}
|
|
74
|
-
case CellType.GEOLOCATION:
|
|
72
|
+
case column.type === CellType.GEOLOCATION:
|
|
75
73
|
{
|
|
76
74
|
const validGeolocationGranularity = geolocationGranularity && geolocationGranularity.toUpperCase();
|
|
77
75
|
if (validGeolocationGranularity === 'PROVINCE') {
|