sea-chart 0.0.78 → 0.0.79
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.
|
@@ -8,6 +8,7 @@ import DtableSearchInput from '../dtable-search-input';
|
|
|
8
8
|
import Loading from '../loading';
|
|
9
9
|
import { searchRows } from '../../utils/search';
|
|
10
10
|
import ChartDataSQL from '../../utils/sql/chart-data-sql';
|
|
11
|
+
import { getFilterConditions } from '../../utils/row-record-utils';
|
|
11
12
|
import RowCard from '../row-card/row-card';
|
|
12
13
|
import { CommonEventTypes } from '../../constants/common-constants';
|
|
13
14
|
import './index.css';
|
|
@@ -31,8 +32,7 @@ class StatisticRecordDialog extends React.Component {
|
|
|
31
32
|
} = statisticRecord || {};
|
|
32
33
|
const {
|
|
33
34
|
table_id,
|
|
34
|
-
view_id
|
|
35
|
-
filters
|
|
35
|
+
view_id
|
|
36
36
|
} = chart.config;
|
|
37
37
|
this.table = getTableById(tables, table_id);
|
|
38
38
|
if (view_id) {
|
|
@@ -44,15 +44,8 @@ class StatisticRecordDialog extends React.Component {
|
|
|
44
44
|
if (this.isArchiveView || !isCalculateByView || statisticRecord.isQueryBySql) {
|
|
45
45
|
var _context$api, _context$api2;
|
|
46
46
|
if ((_context$api = context.api) === null || _context$api === void 0 ? void 0 : _context$api.customQueryRows) {
|
|
47
|
-
const newFilters = (filters === null || filters === void 0 ? void 0 : filters.map(item => {
|
|
48
|
-
return {
|
|
49
|
-
...item,
|
|
50
|
-
column_key: (item === null || item === void 0 ? void 0 : item.column_key) || '',
|
|
51
|
-
value: (item === null || item === void 0 ? void 0 : item.filter_term) || ''
|
|
52
|
-
};
|
|
53
|
-
})) || [];
|
|
54
47
|
const detailFilterConditions = {
|
|
55
|
-
filters:
|
|
48
|
+
filters: getFilterConditions(statisticRecord, chart, this.table.columns)
|
|
56
49
|
};
|
|
57
50
|
context.api.customQueryRows(detailFilterConditions).then(res => {
|
|
58
51
|
const {
|
package/dist/constants/index.js
CHANGED
|
@@ -256,4 +256,47 @@ export const MONTH_MIRROR = {
|
|
|
256
256
|
'10': 'Nov',
|
|
257
257
|
'11': 'Dec'
|
|
258
258
|
};
|
|
259
|
+
export const xAxisMap = {
|
|
260
|
+
[CHART_TYPE.BAR_CUSTOM]: 'x_axis_column_key',
|
|
261
|
+
[CHART_TYPE.BAR_GROUP]: 'x_axis_column_key',
|
|
262
|
+
[CHART_TYPE.BAR_STACK]: 'x_axis_column_key',
|
|
263
|
+
[CHART_TYPE.BAR]: 'x_axis_column_key',
|
|
264
|
+
[CHART_TYPE.AREA_GROUP]: 'x_axis_column_key',
|
|
265
|
+
[CHART_TYPE.AREA]: 'x_axis_column_key',
|
|
266
|
+
[CHART_TYPE.BASIC_NUMBER_CARD]: 'numeric_column_key',
|
|
267
|
+
[CHART_TYPE.COMBINATION]: 'x_axis_column_key',
|
|
268
|
+
[CHART_TYPE.COMPARE_BAR]: 'x_axis_column_key',
|
|
269
|
+
[CHART_TYPE.COMPLETENESS_GROUP]: 'groupby_column_key',
|
|
270
|
+
[CHART_TYPE.COMPLETENESS]: 'groupby_column_key',
|
|
271
|
+
[CHART_TYPE.DASHBOARD]: 'target_value_column_key',
|
|
272
|
+
[CHART_TYPE.HEAT_MAP]: 'time_column_key',
|
|
273
|
+
[CHART_TYPE.HORIZONTAL_BAR]: 'vertical_axis_column_key',
|
|
274
|
+
[CHART_TYPE.HORIZONTAL_GROUP_BAR]: 'vertical_axis_column_key',
|
|
275
|
+
[CHART_TYPE.STACKED_HORIZONTAL_BAR]: 'vertical_axis_column_key',
|
|
276
|
+
[CHART_TYPE.LINE_GROUP]: 'x_axis_column_key',
|
|
277
|
+
[CHART_TYPE.LINE]: 'x_axis_column_key',
|
|
278
|
+
[CHART_TYPE.MAP_BUBBLE]: 'geo_column_key',
|
|
279
|
+
[CHART_TYPE.MAP]: 'geo_column_key',
|
|
280
|
+
[CHART_TYPE.WORLD_MAP_BUBBLE]: 'geo_column_key',
|
|
281
|
+
[CHART_TYPE.WORLD_MAP]: 'geo_column_key',
|
|
282
|
+
[CHART_TYPE.MIRROR]: 'column_key',
|
|
283
|
+
[CHART_TYPE.PIE]: 'groupby_column_key',
|
|
284
|
+
[CHART_TYPE.RING]: 'groupby_column_key',
|
|
285
|
+
[CHART_TYPE.SCATTER]: 'x_axis_column_key',
|
|
286
|
+
[CHART_TYPE.TABLE]: 'groupby_column_key',
|
|
287
|
+
[CHART_TYPE.TREE_MAP]: 'groupby_column_key',
|
|
288
|
+
[CHART_TYPE.TREND]: 'date_column_key'
|
|
289
|
+
};
|
|
290
|
+
export const groupAxisMap = {
|
|
291
|
+
[CHART_TYPE.BAR_GROUP]: 'column_groupby_column_key',
|
|
292
|
+
[CHART_TYPE.BAR_STACK]: 'column_groupby_column_key',
|
|
293
|
+
[CHART_TYPE.AREA_GROUP]: 'column_groupby_column_key',
|
|
294
|
+
[CHART_TYPE.COMPLETENESS_GROUP]: 'column_groupby_column_key',
|
|
295
|
+
[CHART_TYPE.HORIZONTAL_GROUP_BAR]: 'column_groupby_column_key',
|
|
296
|
+
[CHART_TYPE.STACKED_HORIZONTAL_BAR]: 'column_groupby_column_key',
|
|
297
|
+
[CHART_TYPE.LINE_GROUP]: 'column_groupby_column_key',
|
|
298
|
+
[CHART_TYPE.SCATTER]: 'column_groupby_column_key',
|
|
299
|
+
[CHART_TYPE.MIRROR]: 'group_column_key',
|
|
300
|
+
[CHART_TYPE.TABLE]: 'groupby_column_key'
|
|
301
|
+
};
|
|
259
302
|
export { GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, CHART_KEY, GENERIC_KEY, GENERIC_KEY_2_SIMILAR_KEYS, STYLE_COLORS, HORIZONTAL_ALIGN, HORIZONTAL_ALIGNS, HORIZONTAL_ALIGN_SHOW, CHART_TYPE, CHART_TYPE_SHOW, CHART_TYPES, CHART_TYPE_IMAGE, GEOLOCATION_GRANULARITY, GEOLOCATION_GRANULARITY_LIST, MAP_LEVEL, MUNICIPALITIES, regions, TABLE_DIMENSIONS };
|
|
@@ -241,13 +241,13 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
241
241
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
242
242
|
const pivot_summary_multiple_columns = [];
|
|
243
243
|
Array.isArray(summary_columns) && summary_columns.forEach(item => {
|
|
244
|
-
const column = getTableColumnByKey(table, item.
|
|
244
|
+
const column = getTableColumnByKey(table, item.column_key);
|
|
245
245
|
if (column && isNumericColumn(column)) {
|
|
246
246
|
pivot_summary_multiple_columns.push({
|
|
247
|
-
key: item.
|
|
247
|
+
key: item.column_key,
|
|
248
248
|
type: column.type,
|
|
249
249
|
data: column.data,
|
|
250
|
-
method: item.
|
|
250
|
+
method: item.summary_method,
|
|
251
251
|
column_name: column.name
|
|
252
252
|
});
|
|
253
253
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ButtonFormatter from "dtable-ui-component/lib/ButtonFormatter";
|
|
2
2
|
import _RateFormatter from "dtable-ui-component/lib/RateFormatter";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber } from 'dtable-utils';
|
|
4
|
+
import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn } from 'dtable-utils';
|
|
5
5
|
import { LinksUtils } from 'dtable-store';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import cellFormatterFactory from '../components/cell-factory/cell-formatter-factory';
|
|
@@ -10,7 +10,9 @@ import SingleSelectOption from '../components/cell-factory/SingleSelectOption';
|
|
|
10
10
|
import { isFunction, getFileIconUrl, getImageThumbnailUrl, isArchiveViewRowData } from '../utils/common-utils';
|
|
11
11
|
import Highlighter from '../components/highlighter/highlighter';
|
|
12
12
|
import DigitalSignUtils from '../utils/digital-sign-utils';
|
|
13
|
+
import { getColumnByKey } from '../utils/column-utils';
|
|
13
14
|
import context from '../context';
|
|
15
|
+
import { xAxisMap, groupAxisMap } from '../constants';
|
|
14
16
|
export const UNSHOW_COLUMN_TYPE = [CellType.LINK, CellType.LONG_TEXT, CellType.FORMULA, CellType.LINK_FORMULA];
|
|
15
17
|
export const getCellRecordWidth = column => {
|
|
16
18
|
let {
|
|
@@ -479,4 +481,59 @@ const createColumnFormatter = (columnType, formatterProps) => {
|
|
|
479
481
|
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
480
482
|
}
|
|
481
483
|
return /*#__PURE__*/React.createElement(SimpleCellFormatter, formatterProps);
|
|
484
|
+
};
|
|
485
|
+
const filterPredicateMap = {
|
|
486
|
+
[CellType.TEXT]: 'is',
|
|
487
|
+
[CellType.NUMBER]: 'equal',
|
|
488
|
+
[CellType.CHECKBOX]: 'is',
|
|
489
|
+
[CellType.DATE]: 'is',
|
|
490
|
+
[CellType.CTIME]: 'is',
|
|
491
|
+
[CellType.MTIME]: 'is',
|
|
492
|
+
[CellType.SINGLE_SELECT]: 'is',
|
|
493
|
+
[CellType.MULTIPLE_SELECT]: 'has_all_of',
|
|
494
|
+
[CellType.DEPARTMENT_SINGLE_SELECT]: 'is',
|
|
495
|
+
[CellType.COLLABORATOR]: 'has_all_of',
|
|
496
|
+
[CellType.CREATOR]: 'is',
|
|
497
|
+
[CellType.LAST_MODIFIER]: 'is',
|
|
498
|
+
[CellType.AUTO_NUMBER]: 'is',
|
|
499
|
+
[CellType.EMAIL]: 'is',
|
|
500
|
+
[CellType.URL]: 'is',
|
|
501
|
+
[CellType.STRING]: 'is',
|
|
502
|
+
[CellType.BOOL]: 'is'
|
|
503
|
+
};
|
|
504
|
+
const getFilterByColumnType = (columnKey, columns, value) => {
|
|
505
|
+
const filter = {
|
|
506
|
+
column_key: columnKey || ''
|
|
507
|
+
};
|
|
508
|
+
const column = getColumnByKey(columnKey, columns);
|
|
509
|
+
if (isDateColumn(column) || (column === null || column === void 0 ? void 0 : column.type) === CellType.GEOLOCATION) {
|
|
510
|
+
filter['value'] = value;
|
|
511
|
+
return filter;
|
|
512
|
+
}
|
|
513
|
+
filter['filter_predicate'] = filterPredicateMap[column === null || column === void 0 ? void 0 : column.type];
|
|
514
|
+
filter['filter_term'] = value;
|
|
515
|
+
return filter;
|
|
516
|
+
};
|
|
517
|
+
export const getFilterConditions = function (statisticRecord, chart) {
|
|
518
|
+
let columns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
519
|
+
const {
|
|
520
|
+
name = '',
|
|
521
|
+
group_name = ''
|
|
522
|
+
} = statisticRecord || {};
|
|
523
|
+
const {
|
|
524
|
+
config
|
|
525
|
+
} = chart;
|
|
526
|
+
const {
|
|
527
|
+
type
|
|
528
|
+
} = config;
|
|
529
|
+
const filters = [];
|
|
530
|
+
const columnKey = xAxisMap[type];
|
|
531
|
+
const groupColumnKey = groupAxisMap[type];
|
|
532
|
+
const columnFilter = getFilterByColumnType(config[columnKey], columns, name);
|
|
533
|
+
filters.push(columnFilter);
|
|
534
|
+
if (config[groupColumnKey]) {
|
|
535
|
+
const groupColumnFilter = getFilterByColumnType(config[groupColumnKey], columns, group_name);
|
|
536
|
+
filters.push(groupColumnFilter);
|
|
537
|
+
}
|
|
538
|
+
return filters;
|
|
482
539
|
};
|