sea-chart 0.0.94 → 0.0.95
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/services/map-json.js +8 -2
- package/dist/settings/widgets/select-view/index.js +12 -3
- package/dist/utils/chart-utils/base-utils.js +7 -4
- package/dist/utils/chart-utils/sql-statistics-utils.js +21 -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
|
@@ -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"
|
|
@@ -693,16 +693,19 @@ BaseUtils.sortCharts = (charts, column, sortKey) => {
|
|
|
693
693
|
}
|
|
694
694
|
case CellType.SINGLE_SELECT:
|
|
695
695
|
{
|
|
696
|
+
// key was used to sort "pivot columns" in pivot chart
|
|
696
697
|
const {
|
|
697
698
|
name: currentName,
|
|
698
|
-
group_name: currentGroupName
|
|
699
|
+
group_name: currentGroupName,
|
|
700
|
+
key: currentKey
|
|
699
701
|
} = currResult || {};
|
|
700
702
|
const {
|
|
701
703
|
name: nextName,
|
|
702
|
-
group_name: nextGroupName
|
|
704
|
+
group_name: nextGroupName,
|
|
705
|
+
key: nextKey
|
|
703
706
|
} = nextResult || {};
|
|
704
|
-
const current = currentGroupName || currentName;
|
|
705
|
-
const next = nextGroupName || nextName;
|
|
707
|
+
const current = currentGroupName || currentName || currentKey;
|
|
708
|
+
const next = nextGroupName || nextName || nextKey;
|
|
706
709
|
return sortSingleSelect(current, next, {
|
|
707
710
|
sort_type: sortType,
|
|
708
711
|
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,
|
|
@@ -1550,14 +1552,17 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1550
1552
|
const {
|
|
1551
1553
|
column_groupby_column_key
|
|
1552
1554
|
} = chart.config;
|
|
1555
|
+
let result;
|
|
1553
1556
|
if (!column_groupby_column_key) {
|
|
1554
|
-
|
|
1557
|
+
result = {
|
|
1555
1558
|
result: _SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1556
1559
|
};
|
|
1560
|
+
} else {
|
|
1561
|
+
result = {
|
|
1562
|
+
result: _SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1563
|
+
};
|
|
1557
1564
|
}
|
|
1558
|
-
return
|
|
1559
|
-
result: _SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1560
|
-
};
|
|
1565
|
+
return result;
|
|
1561
1566
|
}
|
|
1562
1567
|
case CHART_TYPE.PIE:
|
|
1563
1568
|
case CHART_TYPE.RING:
|
|
@@ -1792,20 +1797,29 @@ SQLStatisticsUtils.scatterSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, c
|
|
|
1792
1797
|
columnGroupbyColumn,
|
|
1793
1798
|
summaryColumn
|
|
1794
1799
|
} = columnMap;
|
|
1795
|
-
|
|
1796
1800
|
// format sql rows
|
|
1801
|
+
const originalSqlRows = cloneDeep(sqlRows);
|
|
1797
1802
|
BaseUtils.updateTableViewList(sqlRows, groupbyColumn, groupbyColumn.key, 'color');
|
|
1798
1803
|
BaseUtils.updateTableViewList(sqlRows, summaryColumn, summaryColumn.key, 'color');
|
|
1799
1804
|
if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows, columnGroupbyColumn, sqlColumnGroupbyColumnKey, 'color');
|
|
1800
1805
|
const res = [];
|
|
1801
|
-
sqlRows.forEach(row => {
|
|
1806
|
+
sqlRows.forEach((row, index) => {
|
|
1802
1807
|
const xValue = '' + row[sqlXColumnKey] || intl.get('Empty');
|
|
1803
1808
|
const yValue = '' + row[sqlYColumnKey] || intl.get('Empty');
|
|
1804
1809
|
const groupby = '' + row[sqlColumnGroupbyColumnKey] || intl.get('Empty');
|
|
1810
|
+
const originalSqlRow = originalSqlRows[index];
|
|
1811
|
+
const originalXValue = originalSqlRow[sqlXColumnKey];
|
|
1812
|
+
const originalYValue = originalSqlRow[sqlYColumnKey];
|
|
1813
|
+
const originalGroupby = originalSqlRow[sqlColumnGroupbyColumnKey];
|
|
1805
1814
|
res.push({
|
|
1806
1815
|
name: xValue,
|
|
1807
1816
|
value: yValue,
|
|
1808
|
-
groupby
|
|
1817
|
+
groupby,
|
|
1818
|
+
original_value: {
|
|
1819
|
+
name: originalXValue,
|
|
1820
|
+
value: originalYValue,
|
|
1821
|
+
groupby: originalGroupby
|
|
1822
|
+
}
|
|
1809
1823
|
});
|
|
1810
1824
|
});
|
|
1811
1825
|
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() {
|