sea-chart 0.0.93 → 0.0.95-alpha.0
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 +2 -1
- package/dist/services/map-json.js +8 -2
- package/dist/settings/widgets/select-view/index.js +12 -3
- package/dist/utils/chart-utils/base-utils.js +14 -4
- package/dist/utils/chart-utils/sql-statistics-utils.js +26 -7
- package/dist/utils/row-record-utils.js +20 -5
- package/dist/view/wrapper/area.js +14 -14
- package/dist/view/wrapper/scatter.js +1 -1
- package/dist/view/wrapper/table/index.js +13 -3
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ class StatisticRecordDialog extends React.Component {
|
|
|
37
37
|
view_id
|
|
38
38
|
} = chart.config;
|
|
39
39
|
this.table = getTableById(tables, table_id);
|
|
40
|
+
const currentElementId = chart.id;
|
|
40
41
|
if (view_id) {
|
|
41
42
|
this.view = getViewById(this.table.views, view_id);
|
|
42
43
|
this.isArchiveView = isArchiveView(this.view);
|
|
@@ -49,7 +50,7 @@ class StatisticRecordDialog extends React.Component {
|
|
|
49
50
|
const detailFilterConditions = {
|
|
50
51
|
filters: getFilterConditions(statisticRecord, chart, this.table.columns)
|
|
51
52
|
};
|
|
52
|
-
context.api.customQueryRows(detailFilterConditions).then(res => {
|
|
53
|
+
context.api.customQueryRows(currentElementId, detailFilterConditions).then(res => {
|
|
53
54
|
const {
|
|
54
55
|
results: rows
|
|
55
56
|
} = res.data;
|
|
@@ -86,7 +86,13 @@ export default async function fetchMapJson(mapLevel, mapLocation, mediaUrl) {
|
|
|
86
86
|
if (cachedJson) {
|
|
87
87
|
return Promise.resolve(cachedJson);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
let mapJson;
|
|
90
|
+
try {
|
|
91
|
+
const res = await fetch("".concat(mediaUrl, "dtable-statistic/geolocation/").concat(url, ".json"));
|
|
92
|
+
mapJson = await res.json();
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error('on fetchMapJson: fetch error', error);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
91
97
|
return handleLoadedMapJson(url, mapJson);
|
|
92
98
|
}
|
|
@@ -15,7 +15,14 @@ const SelectView = _ref => {
|
|
|
15
15
|
const viewOptions = useMemo(() => {
|
|
16
16
|
const table = getTableById(tables, selectedTableId);
|
|
17
17
|
if (!table) return [];
|
|
18
|
-
|
|
18
|
+
let views = getNonPrivateViews(table.views);
|
|
19
|
+
const selectedView = views.find(view => view._id === selectedViewId);
|
|
20
|
+
|
|
21
|
+
// not support archive view on plugin, do not show archive view
|
|
22
|
+
// but if it is selected, keep it
|
|
23
|
+
if (!isArchiveView(selectedView)) {
|
|
24
|
+
views = views.filter(v => !isArchiveView(v));
|
|
25
|
+
}
|
|
19
26
|
return Array.isArray(views) ? views.map(view => {
|
|
20
27
|
const value = view._id;
|
|
21
28
|
const archiveView = isArchiveView(view);
|
|
@@ -23,7 +30,9 @@ const SelectView = _ref => {
|
|
|
23
30
|
label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
24
31
|
className: "sea-chart-table-view mr-2"
|
|
25
32
|
}, /*#__PURE__*/React.createElement("i", {
|
|
26
|
-
className: classnames('dtable-font',
|
|
33
|
+
className: classnames('dtable-font',
|
|
34
|
+
// 'dtable-icon-main-view',
|
|
35
|
+
{
|
|
27
36
|
'dtable-icon-archive-view': archiveView,
|
|
28
37
|
'dtable-icon-main-view': !archiveView
|
|
29
38
|
})
|
|
@@ -33,7 +42,7 @@ const SelectView = _ref => {
|
|
|
33
42
|
value
|
|
34
43
|
};
|
|
35
44
|
}) : [];
|
|
36
|
-
}, [tables, selectedTableId]);
|
|
45
|
+
}, [tables, selectedTableId, selectedViewId]);
|
|
37
46
|
const selectedOption = selectedViewId ? viewOptions.find(option => option.value === selectedViewId) : null;
|
|
38
47
|
return /*#__PURE__*/React.createElement(FormGroup, {
|
|
39
48
|
className: "sea-chart-setting-item table-setting"
|
|
@@ -655,6 +655,7 @@ BaseUtils.sortCharts = (charts, column, sortKey) => {
|
|
|
655
655
|
const {
|
|
656
656
|
options
|
|
657
657
|
} = data || {};
|
|
658
|
+
console.log('options', options);
|
|
658
659
|
Array.isArray(options) && options.forEach((option, index) => {
|
|
659
660
|
optionIdIndexMap[option.id] = index;
|
|
660
661
|
});
|
|
@@ -693,16 +694,25 @@ BaseUtils.sortCharts = (charts, column, sortKey) => {
|
|
|
693
694
|
}
|
|
694
695
|
case CellType.SINGLE_SELECT:
|
|
695
696
|
{
|
|
697
|
+
// key was used to sort "pivot columns" in pivot chart
|
|
696
698
|
const {
|
|
697
699
|
name: currentName,
|
|
698
|
-
group_name: currentGroupName
|
|
700
|
+
group_name: currentGroupName,
|
|
701
|
+
key: currentKey
|
|
699
702
|
} = currResult || {};
|
|
700
703
|
const {
|
|
701
704
|
name: nextName,
|
|
702
|
-
group_name: nextGroupName
|
|
705
|
+
group_name: nextGroupName,
|
|
706
|
+
key: nextKey
|
|
703
707
|
} = nextResult || {};
|
|
704
|
-
const current = currentGroupName || currentName;
|
|
705
|
-
const next = nextGroupName || nextName;
|
|
708
|
+
const current = currentGroupName || currentName || currentKey;
|
|
709
|
+
const next = nextGroupName || nextName || nextKey;
|
|
710
|
+
console.log('currResult', currResult);
|
|
711
|
+
console.log('nextResult', nextResult);
|
|
712
|
+
console.log(current, next, {
|
|
713
|
+
sort_type: sortType,
|
|
714
|
+
option_id_index_map: optionIdIndexMap
|
|
715
|
+
});
|
|
706
716
|
return sortSingleSelect(current, next, {
|
|
707
717
|
sort_type: sortType,
|
|
708
718
|
option_id_index_map: optionIdIndexMap
|
|
@@ -2,6 +2,7 @@ var _SQLStatisticsUtils;
|
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, DateUtils } from 'dtable-utils';
|
|
4
4
|
import { isObject } from 'lodash';
|
|
5
|
+
import { cloneDeep } from 'lodash-es';
|
|
5
6
|
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS, TREND_TYPES } from '../../constants';
|
|
6
7
|
import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
|
|
7
8
|
import { getClientLinkDisplayString } from '../cell-format-utils';
|
|
@@ -493,6 +494,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
493
494
|
}
|
|
494
495
|
});
|
|
495
496
|
});
|
|
497
|
+
BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
|
|
496
498
|
return {
|
|
497
499
|
pivot_columns,
|
|
498
500
|
pivot_rows: pivot_rows,
|
|
@@ -763,9 +765,11 @@ SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap
|
|
|
763
765
|
});
|
|
764
766
|
BaseUtils.updateTableViewList(result, groupbyColumn, 'name', 'color');
|
|
765
767
|
if (SUPPORT_DATA_SORT_CHART_TYPES.includes(type) && sort_type) {
|
|
768
|
+
console.log(11, JSON.parse(JSON.stringify(result)));
|
|
766
769
|
BaseUtils.sortChartData(result, sort_type);
|
|
767
770
|
return result;
|
|
768
771
|
}
|
|
772
|
+
console.log(22, JSON.parse(JSON.stringify(result)));
|
|
769
773
|
BaseUtils.sortCharts(result, groupbyColumn, 'name');
|
|
770
774
|
return result;
|
|
771
775
|
};
|
|
@@ -1289,8 +1293,10 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRo
|
|
|
1289
1293
|
}
|
|
1290
1294
|
}
|
|
1291
1295
|
});
|
|
1296
|
+
console.log('result', JSON.parse(JSON.stringify(result)));
|
|
1292
1297
|
BaseUtils.updateTableViewList(result, groupbyColumn, 'name', 'color');
|
|
1293
1298
|
BaseUtils.updateTableViewList(result, columnGroupbyColumn, 'group_name', 'group_color');
|
|
1299
|
+
console.log('result', JSON.parse(JSON.stringify(result)));
|
|
1294
1300
|
BaseUtils.sortCharts(result, groupbyColumn, 'name');
|
|
1295
1301
|
return result;
|
|
1296
1302
|
};
|
|
@@ -1308,6 +1314,7 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1308
1314
|
groupbyColumn,
|
|
1309
1315
|
columnGroupbyColumn
|
|
1310
1316
|
} = columnMap;
|
|
1317
|
+
console.log('columnGroupbyColumn', columnGroupbyColumn);
|
|
1311
1318
|
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1312
1319
|
if (!columnGroupbyColumn) return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1313
1320
|
return _SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
@@ -1550,14 +1557,17 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1550
1557
|
const {
|
|
1551
1558
|
column_groupby_column_key
|
|
1552
1559
|
} = chart.config;
|
|
1560
|
+
let result;
|
|
1553
1561
|
if (!column_groupby_column_key) {
|
|
1554
|
-
|
|
1562
|
+
result = {
|
|
1555
1563
|
result: _SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1556
1564
|
};
|
|
1565
|
+
} else {
|
|
1566
|
+
result = {
|
|
1567
|
+
result: _SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1568
|
+
};
|
|
1557
1569
|
}
|
|
1558
|
-
return
|
|
1559
|
-
result: _SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1560
|
-
};
|
|
1570
|
+
return result;
|
|
1561
1571
|
}
|
|
1562
1572
|
case CHART_TYPE.PIE:
|
|
1563
1573
|
case CHART_TYPE.RING:
|
|
@@ -1792,20 +1802,29 @@ SQLStatisticsUtils.scatterSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, c
|
|
|
1792
1802
|
columnGroupbyColumn,
|
|
1793
1803
|
summaryColumn
|
|
1794
1804
|
} = columnMap;
|
|
1795
|
-
|
|
1796
1805
|
// format sql rows
|
|
1806
|
+
const originalSqlRows = cloneDeep(sqlRows);
|
|
1797
1807
|
BaseUtils.updateTableViewList(sqlRows, groupbyColumn, groupbyColumn.key, 'color');
|
|
1798
1808
|
BaseUtils.updateTableViewList(sqlRows, summaryColumn, summaryColumn.key, 'color');
|
|
1799
1809
|
if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows, columnGroupbyColumn, sqlColumnGroupbyColumnKey, 'color');
|
|
1800
1810
|
const res = [];
|
|
1801
|
-
sqlRows.forEach(row => {
|
|
1811
|
+
sqlRows.forEach((row, index) => {
|
|
1802
1812
|
const xValue = '' + row[sqlXColumnKey] || intl.get('Empty');
|
|
1803
1813
|
const yValue = '' + row[sqlYColumnKey] || intl.get('Empty');
|
|
1804
1814
|
const groupby = '' + row[sqlColumnGroupbyColumnKey] || intl.get('Empty');
|
|
1815
|
+
const originalSqlRow = originalSqlRows[index];
|
|
1816
|
+
const originalXValue = originalSqlRow[sqlXColumnKey];
|
|
1817
|
+
const originalYValue = originalSqlRow[sqlYColumnKey];
|
|
1818
|
+
const originalGroupby = originalSqlRow[sqlColumnGroupbyColumnKey];
|
|
1805
1819
|
res.push({
|
|
1806
1820
|
name: xValue,
|
|
1807
1821
|
value: yValue,
|
|
1808
|
-
groupby
|
|
1822
|
+
groupby,
|
|
1823
|
+
original_value: {
|
|
1824
|
+
name: originalXValue,
|
|
1825
|
+
value: originalYValue,
|
|
1826
|
+
groupby: originalGroupby
|
|
1827
|
+
}
|
|
1809
1828
|
});
|
|
1810
1829
|
});
|
|
1811
1830
|
return res;
|
|
@@ -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, isDateColumn, isValidLink } from 'dtable-utils';
|
|
4
|
+
import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn, isValidLink, getColumnOptions } from 'dtable-utils';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import { isEqual } from 'lodash-es';
|
|
7
7
|
import cellFormatterFactory from '../components/cell-factory/cell-formatter-factory';
|
|
@@ -501,6 +501,7 @@ const filterPredicateMap = {
|
|
|
501
501
|
[CellType.STRING]: 'is',
|
|
502
502
|
[CellType.BOOL]: 'is'
|
|
503
503
|
};
|
|
504
|
+
const USE_OPTION_ID_CELL_TYPES = [CellType.SINGLE_SELECT, CellType.MULTIPLE_SELECT];
|
|
504
505
|
const getFilterByColumnType = (columnKey, columns, value) => {
|
|
505
506
|
const filter = {
|
|
506
507
|
column_key: columnKey || ''
|
|
@@ -510,8 +511,20 @@ const getFilterByColumnType = (columnKey, columns, value) => {
|
|
|
510
511
|
filter['value'] = value;
|
|
511
512
|
return filter;
|
|
512
513
|
}
|
|
514
|
+
if (typeof value === 'string') {
|
|
515
|
+
value = value.trim();
|
|
516
|
+
}
|
|
517
|
+
if (USE_OPTION_ID_CELL_TYPES.includes(column === null || column === void 0 ? void 0 : column.type)) {
|
|
518
|
+
const options = getColumnOptions(column);
|
|
519
|
+
// name may contains spaces
|
|
520
|
+
// value maybe id or name, find option by name or id
|
|
521
|
+
const selectedOption = options.find(o => o.name.trim() === value || o.id === value);
|
|
522
|
+
filter['filter_term'] = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.id;
|
|
523
|
+
} else {
|
|
524
|
+
// value may contains spaces
|
|
525
|
+
filter['filter_term'] = value;
|
|
526
|
+
}
|
|
513
527
|
filter['filter_predicate'] = filterPredicateMap[column === null || column === void 0 ? void 0 : column.type];
|
|
514
|
-
filter['filter_term'] = value;
|
|
515
528
|
return filter;
|
|
516
529
|
};
|
|
517
530
|
export const getFilterConditions = function (statisticRecord, chart) {
|
|
@@ -519,7 +532,9 @@ export const getFilterConditions = function (statisticRecord, chart) {
|
|
|
519
532
|
const {
|
|
520
533
|
name = '',
|
|
521
534
|
group_name = '',
|
|
522
|
-
|
|
535
|
+
groupby = '',
|
|
536
|
+
rows,
|
|
537
|
+
isPivot
|
|
523
538
|
} = statisticRecord || {};
|
|
524
539
|
const {
|
|
525
540
|
config
|
|
@@ -530,7 +545,7 @@ export const getFilterConditions = function (statisticRecord, chart) {
|
|
|
530
545
|
const filters = [];
|
|
531
546
|
const columnKey = xAxisMap[type];
|
|
532
547
|
const groupColumnKey = groupAxisMap[type];
|
|
533
|
-
if (
|
|
548
|
+
if (isPivot && rows.length) {
|
|
534
549
|
const xValueList = [];
|
|
535
550
|
const yValueList = [];
|
|
536
551
|
rows.forEach(r => {
|
|
@@ -555,7 +570,7 @@ export const getFilterConditions = function (statisticRecord, chart) {
|
|
|
555
570
|
const columnFilter = getFilterByColumnType(config[columnKey], columns, name);
|
|
556
571
|
filters.push(columnFilter);
|
|
557
572
|
if (config[groupColumnKey]) {
|
|
558
|
-
const groupColumnFilter = getFilterByColumnType(config[groupColumnKey], columns, group_name);
|
|
573
|
+
const groupColumnFilter = getFilterByColumnType(config[groupColumnKey], columns, group_name || groupby);
|
|
559
574
|
filters.push(groupColumnFilter);
|
|
560
575
|
}
|
|
561
576
|
}
|
|
@@ -125,20 +125,6 @@ class Area extends ChartComponent {
|
|
|
125
125
|
lineWidth: 2,
|
|
126
126
|
opacity: 1
|
|
127
127
|
});
|
|
128
|
-
|
|
129
|
-
// point
|
|
130
|
-
let point;
|
|
131
|
-
point = this.chart.point().animate({
|
|
132
|
-
appear: {
|
|
133
|
-
animation: 'fadeIn',
|
|
134
|
-
duration: 1000,
|
|
135
|
-
easing: 'easeLinear'
|
|
136
|
-
}
|
|
137
|
-
}).position('name*value').color(chartBarColor, colorCallBack).shape('circle').size(4).style({
|
|
138
|
-
stroke: 0,
|
|
139
|
-
fillOpacity: 1,
|
|
140
|
-
opacity: y_axis_show_value ? 1 : 0
|
|
141
|
-
}).tooltip(false);
|
|
142
128
|
const area = this.chart.area().position('name*value').animate({
|
|
143
129
|
appear: {
|
|
144
130
|
animation: 'fadeIn',
|
|
@@ -154,6 +140,20 @@ class Area extends ChartComponent {
|
|
|
154
140
|
}).style({
|
|
155
141
|
fillOpacity: 0.3
|
|
156
142
|
});
|
|
143
|
+
|
|
144
|
+
// point
|
|
145
|
+
let point;
|
|
146
|
+
point = this.chart.point().animate({
|
|
147
|
+
appear: {
|
|
148
|
+
animation: 'fadeIn',
|
|
149
|
+
duration: 1000,
|
|
150
|
+
easing: 'easeLinear'
|
|
151
|
+
}
|
|
152
|
+
}).position('name*value').color(chartBarColor, colorCallBack).shape('circle').size(4).style({
|
|
153
|
+
stroke: 0,
|
|
154
|
+
fillOpacity: 1,
|
|
155
|
+
opacity: y_axis_show_value ? 1 : 0
|
|
156
|
+
}).tooltip(false);
|
|
157
157
|
this.chart.on('tooltip:show', () => {
|
|
158
158
|
if (line.styleOption.cfg.opacity === 0.3) return;
|
|
159
159
|
line.style({
|
|
@@ -7,6 +7,10 @@ import './index.css';
|
|
|
7
7
|
class Table extends PureComponent {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
|
+
this.toggleRecords = (cell, selectedCell) => {
|
|
11
|
+
cell && (cell.isPivot = true);
|
|
12
|
+
this.props.toggleRecords(cell, selectedCell);
|
|
13
|
+
};
|
|
10
14
|
this.renderContainer = () => {
|
|
11
15
|
const {
|
|
12
16
|
groupbyColumn,
|
|
@@ -21,13 +25,19 @@ class Table extends PureComponent {
|
|
|
21
25
|
return /*#__PURE__*/React.createElement("div", null, intl.get('There_are_too_many_statistics_entries_to_display'));
|
|
22
26
|
}
|
|
23
27
|
if (columnGroupbyColumn) {
|
|
24
|
-
return /*#__PURE__*/React.createElement(TwoDimensionTable, this.props
|
|
28
|
+
return /*#__PURE__*/React.createElement(TwoDimensionTable, Object.assign({}, this.props, {
|
|
29
|
+
toggleRecords: this.toggleRecords
|
|
30
|
+
}));
|
|
25
31
|
}
|
|
26
32
|
if (!Array.isArray(pivot_columns)) return null;
|
|
27
33
|
if (pivot_columns.length < 2) {
|
|
28
|
-
return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, this.props
|
|
34
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, Object.assign({}, this.props, {
|
|
35
|
+
toggleRecords: this.toggleRecords
|
|
36
|
+
}));
|
|
29
37
|
}
|
|
30
|
-
return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, this.props
|
|
38
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, Object.assign({}, this.props, {
|
|
39
|
+
toggleRecords: this.toggleRecords
|
|
40
|
+
}));
|
|
31
41
|
};
|
|
32
42
|
}
|
|
33
43
|
render() {
|