sea-chart 0.0.76-alpha.0 → 0.0.76-alpha.2
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/components/statistic-record-dialog/index.js +3 -10
- package/dist/constants/index.js +43 -0
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +60 -36
- package/dist/utils/row-record-utils.js +39 -1
- package/dist/view/wrapper/completeness.js +3 -5
- package/package.json +1 -1
|
@@ -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
|
@@ -254,4 +254,47 @@ export const MONTH_MIRROR = {
|
|
|
254
254
|
'10': 'Nov',
|
|
255
255
|
'11': 'Dec'
|
|
256
256
|
};
|
|
257
|
+
export const xAxisMap = {
|
|
258
|
+
[CHART_TYPE.BAR_CUSTOM]: 'x_axis_column_key',
|
|
259
|
+
[CHART_TYPE.BAR_GROUP]: 'x_axis_column_key',
|
|
260
|
+
[CHART_TYPE.BAR_STACK]: 'x_axis_column_key',
|
|
261
|
+
[CHART_TYPE.BAR]: 'x_axis_column_key',
|
|
262
|
+
[CHART_TYPE.AREA_GROUP]: 'x_axis_column_key',
|
|
263
|
+
[CHART_TYPE.AREA]: 'x_axis_column_key',
|
|
264
|
+
[CHART_TYPE.BASIC_NUMBER_CARD]: 'numeric_column_key',
|
|
265
|
+
[CHART_TYPE.COMBINATION]: 'x_axis_column_key',
|
|
266
|
+
[CHART_TYPE.COMPARE_BAR]: 'x_axis_column_key',
|
|
267
|
+
[CHART_TYPE.COMPLETENESS_GROUP]: 'groupby_column_key',
|
|
268
|
+
[CHART_TYPE.COMPLETENESS]: 'groupby_column_key',
|
|
269
|
+
[CHART_TYPE.DASHBOARD]: 'target_value_column_key',
|
|
270
|
+
[CHART_TYPE.HEAT_MAP]: 'time_column_key',
|
|
271
|
+
[CHART_TYPE.HORIZONTAL_BAR]: 'vertical_axis_column_key',
|
|
272
|
+
[CHART_TYPE.HORIZONTAL_GROUP_BAR]: 'vertical_axis_column_key',
|
|
273
|
+
[CHART_TYPE.STACKED_HORIZONTAL_BAR]: 'vertical_axis_column_key',
|
|
274
|
+
[CHART_TYPE.LINE_GROUP]: 'x_axis_column_key',
|
|
275
|
+
[CHART_TYPE.LINE]: 'x_axis_column_key',
|
|
276
|
+
[CHART_TYPE.MAP_BUBBLE]: 'geo_column_key',
|
|
277
|
+
[CHART_TYPE.MAP]: 'geo_column_key',
|
|
278
|
+
[CHART_TYPE.WORLD_MAP_BUBBLE]: 'geo_column_key',
|
|
279
|
+
[CHART_TYPE.WORLD_MAP]: 'geo_column_key',
|
|
280
|
+
[CHART_TYPE.MIRROR]: 'column_key',
|
|
281
|
+
[CHART_TYPE.PIE]: 'groupby_column_key',
|
|
282
|
+
[CHART_TYPE.RING]: 'groupby_column_key',
|
|
283
|
+
[CHART_TYPE.SCATTER]: 'x_axis_column_key',
|
|
284
|
+
[CHART_TYPE.TABLE]: 'groupby_column_key',
|
|
285
|
+
[CHART_TYPE.TREE_MAP]: 'groupby_column_key',
|
|
286
|
+
[CHART_TYPE.TREND]: 'date_column_key'
|
|
287
|
+
};
|
|
288
|
+
export const groupAxisMap = {
|
|
289
|
+
[CHART_TYPE.BAR_GROUP]: 'column_groupby_column_key',
|
|
290
|
+
[CHART_TYPE.BAR_STACK]: 'column_groupby_column_key',
|
|
291
|
+
[CHART_TYPE.AREA_GROUP]: 'column_groupby_column_key',
|
|
292
|
+
[CHART_TYPE.COMPLETENESS_GROUP]: 'column_groupby_column_key',
|
|
293
|
+
[CHART_TYPE.HORIZONTAL_GROUP_BAR]: 'column_groupby_column_key',
|
|
294
|
+
[CHART_TYPE.STACKED_HORIZONTAL_BAR]: 'column_groupby_column_key',
|
|
295
|
+
[CHART_TYPE.LINE_GROUP]: 'column_groupby_column_key',
|
|
296
|
+
[CHART_TYPE.SCATTER]: 'column_groupby_column_key',
|
|
297
|
+
[CHART_TYPE.MIRROR]: 'group_column_key',
|
|
298
|
+
[CHART_TYPE.TABLE]: 'groupby_column_key'
|
|
299
|
+
};
|
|
257
300
|
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 };
|
|
@@ -81,22 +81,33 @@ async function calculator(chart, value, _ref) {
|
|
|
81
81
|
} else {
|
|
82
82
|
completedRate = (currentValue / targetValue * 100).toFixed(0);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
if (currentValue < targetValue) {
|
|
85
|
+
result.unshift({
|
|
86
|
+
name: label,
|
|
87
|
+
value: currentValue,
|
|
88
|
+
group_name: 'completed',
|
|
89
|
+
current_value: currentValue,
|
|
90
|
+
target_value: targetValue,
|
|
91
|
+
rows
|
|
92
|
+
}, {
|
|
93
|
+
name: label,
|
|
94
|
+
value: targetValue - currentValue,
|
|
95
|
+
group_name: 'rest',
|
|
96
|
+
current_value: currentValue,
|
|
97
|
+
target_value: targetValue,
|
|
98
|
+
rows,
|
|
99
|
+
completedRate
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
result.unshift({
|
|
103
|
+
name: label,
|
|
104
|
+
value: currentValue,
|
|
105
|
+
group_name: 'completed',
|
|
106
|
+
current_value: currentValue,
|
|
107
|
+
target_value: targetValue,
|
|
108
|
+
rows
|
|
109
|
+
});
|
|
110
|
+
}
|
|
100
111
|
}
|
|
101
112
|
});
|
|
102
113
|
} else {
|
|
@@ -178,26 +189,39 @@ async function calculator(chart, value, _ref) {
|
|
|
178
189
|
} else {
|
|
179
190
|
completedRate = (currentValue / targetValue * 100).toFixed(0);
|
|
180
191
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
if (currentValue < targetValue) {
|
|
193
|
+
result.unshift({
|
|
194
|
+
name: label,
|
|
195
|
+
groupby: groupLabel,
|
|
196
|
+
value: currentValue,
|
|
197
|
+
color,
|
|
198
|
+
group_name: 'completed',
|
|
199
|
+
current_value: currentValue,
|
|
200
|
+
target_value: targetValue,
|
|
201
|
+
rows
|
|
202
|
+
}, {
|
|
203
|
+
name: label,
|
|
204
|
+
groupby: groupLabel,
|
|
205
|
+
value: targetValue - currentValue,
|
|
206
|
+
color,
|
|
207
|
+
group_name: 'rest',
|
|
208
|
+
current_value: currentValue,
|
|
209
|
+
target_value: targetValue,
|
|
210
|
+
rows,
|
|
211
|
+
completedRate
|
|
212
|
+
});
|
|
213
|
+
} else {
|
|
214
|
+
result.unshift({
|
|
215
|
+
name: label,
|
|
216
|
+
groupby: groupLabel,
|
|
217
|
+
value: currentValue,
|
|
218
|
+
color,
|
|
219
|
+
group_name: 'completed',
|
|
220
|
+
current_value: currentValue,
|
|
221
|
+
target_value: targetValue,
|
|
222
|
+
rows
|
|
223
|
+
});
|
|
224
|
+
}
|
|
201
225
|
}
|
|
202
226
|
});
|
|
203
227
|
result.colorMap = colorMap;
|
|
@@ -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 {
|
|
@@ -477,4 +479,40 @@ const createColumnFormatter = (columnType, formatterProps) => {
|
|
|
477
479
|
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
478
480
|
}
|
|
479
481
|
return /*#__PURE__*/React.createElement(SimpleCellFormatter, formatterProps);
|
|
482
|
+
};
|
|
483
|
+
const getFilterByColumnType = (columnKey, columns, value) => {
|
|
484
|
+
const filter = {
|
|
485
|
+
column_key: columnKey || ''
|
|
486
|
+
};
|
|
487
|
+
const column = getColumnByKey(columnKey, columns);
|
|
488
|
+
if (isDateColumn(column) || (column === null || column === void 0 ? void 0 : column.type) === CellType.GEOLOCATION) {
|
|
489
|
+
filter['value'] = value;
|
|
490
|
+
return filter;
|
|
491
|
+
}
|
|
492
|
+
filter['filter_predicate'] = 'is';
|
|
493
|
+
filter['filter_term'] = value;
|
|
494
|
+
return filter;
|
|
495
|
+
};
|
|
496
|
+
export const getFilterConditions = function (statisticRecord, chart) {
|
|
497
|
+
let columns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
498
|
+
const {
|
|
499
|
+
name = '',
|
|
500
|
+
group_name = ''
|
|
501
|
+
} = statisticRecord || {};
|
|
502
|
+
const {
|
|
503
|
+
config
|
|
504
|
+
} = chart;
|
|
505
|
+
const {
|
|
506
|
+
type
|
|
507
|
+
} = config;
|
|
508
|
+
const filters = [];
|
|
509
|
+
const columnKey = xAxisMap[type];
|
|
510
|
+
const groupColumnKey = groupAxisMap[type];
|
|
511
|
+
const columnFilter = getFilterByColumnType(config[columnKey], columns, name);
|
|
512
|
+
filters.push(columnFilter);
|
|
513
|
+
if (config[groupColumnKey]) {
|
|
514
|
+
const groupColumnFilter = getFilterByColumnType(config[groupColumnKey], columns, group_name);
|
|
515
|
+
filters.push(groupColumnFilter);
|
|
516
|
+
}
|
|
517
|
+
return filters;
|
|
480
518
|
};
|
|
@@ -3,7 +3,7 @@ import React, { useEffect, useRef } from 'react';
|
|
|
3
3
|
import { maxBy } from 'lodash-es';
|
|
4
4
|
import { BaseUtils, isBoolean } from '../../utils';
|
|
5
5
|
import intl from '../../intl';
|
|
6
|
-
import { CHART_TYPE, CHART_THEME_COLOR } from '../../constants';
|
|
6
|
+
import { CHART_STYLE_COLORS, CHART_TYPE, CHART_THEME_COLOR } from '../../constants';
|
|
7
7
|
import ChartComponent from './chart-component';
|
|
8
8
|
export default function Completeness(props) {
|
|
9
9
|
var _chartRef$current, _chartRef$current2;
|
|
@@ -21,13 +21,11 @@ export default function Completeness(props) {
|
|
|
21
21
|
var _style_config$title;
|
|
22
22
|
let {
|
|
23
23
|
chart: {
|
|
24
|
-
style_config
|
|
25
|
-
config
|
|
24
|
+
style_config
|
|
26
25
|
}
|
|
27
26
|
} = props;
|
|
28
27
|
chartPaddingTop = ((_style_config$title = style_config.title) === null || _style_config$title === void 0 ? void 0 : _style_config$title.text) ? 17 : 0;
|
|
29
|
-
const
|
|
30
|
-
const appendPadding = [chartPaddingTop, chartPaddingRight, 0, 0];
|
|
28
|
+
const appendPadding = [chartPaddingTop, 30, 0, 0];
|
|
31
29
|
currentChart.initChart(chartContainerRef.current, {
|
|
32
30
|
appendPadding
|
|
33
31
|
});
|