sea-chart 0.0.31-beta → 0.0.32
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/mirror-settings/data-settings.js +1 -1
- package/dist/settings/widgets/group-by.js +5 -3
- package/dist/utils/chart-utils/base-utils.js +33 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +4 -4
- package/dist/utils/chart-utils/sql-statistics-utils.js +111 -136
- package/dist/utils/index.js +0 -38
- package/dist/utils/sql/chart-data-sql.js +7 -4
- package/dist/utils/sql/column-2-sql-column.js +4 -1
- package/dist/view/wrapper/map.js +3 -5
- package/dist/view/wrapper/world-map.js +3 -2
- package/package.json +1 -1
|
@@ -82,7 +82,7 @@ const DataSettings = _ref => {
|
|
|
82
82
|
label: intl.get('Statistic_field'),
|
|
83
83
|
selectedTableId: table_id,
|
|
84
84
|
selectedColumnKey: column_key,
|
|
85
|
-
|
|
85
|
+
isMirror: true,
|
|
86
86
|
onGroupByChange: onXAxisColumnChange
|
|
87
87
|
}), /*#__PURE__*/React.createElement(Switch, {
|
|
88
88
|
key: "x_axis_include_empty_cells",
|
|
@@ -61,12 +61,12 @@ class GroupBy extends Component {
|
|
|
61
61
|
this.getAvailableColumns = columns => {
|
|
62
62
|
const {
|
|
63
63
|
onlySupportDate,
|
|
64
|
-
|
|
64
|
+
isMirror,
|
|
65
65
|
onlySupportSingleSelect
|
|
66
66
|
} = this.props;
|
|
67
67
|
if (!columns || !Array.isArray(columns)) return [];
|
|
68
68
|
let newColumns = [];
|
|
69
|
-
if (
|
|
69
|
+
if (isMirror) {
|
|
70
70
|
newColumns = columns.filter(column => MIRROR_COLUMN_LIST.includes(column.type));
|
|
71
71
|
return newColumns;
|
|
72
72
|
}
|
|
@@ -163,8 +163,10 @@ class GroupBy extends Component {
|
|
|
163
163
|
};
|
|
164
164
|
this.renderGroupBy = () => {
|
|
165
165
|
const {
|
|
166
|
-
selectedColumnKey
|
|
166
|
+
selectedColumnKey,
|
|
167
|
+
isMirror
|
|
167
168
|
} = this.props;
|
|
169
|
+
if (isMirror) return null;
|
|
168
170
|
if (!selectedColumnKey) return null;
|
|
169
171
|
const groupbyColumn = getTableColumnByKey(this.selectedTable, selectedColumnKey);
|
|
170
172
|
if (!groupbyColumn) return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _class;
|
|
2
2
|
import shallowEqual from 'shallowequal';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString } from 'dtable-utils';
|
|
@@ -31,7 +31,7 @@ class BaseUtils {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
_class = BaseUtils;
|
|
35
35
|
// valid chart
|
|
36
36
|
BaseUtils.isValidCombinationChart = (config, table) => {
|
|
37
37
|
const summaryLeftColumnKey = config.y_axis_left_summary_column;
|
|
@@ -101,7 +101,7 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
101
101
|
if (!groupByColumnKey) return false;
|
|
102
102
|
if (!getTableColumnByKey(table, groupByColumnKey)) return false;
|
|
103
103
|
if (type === CHART_TYPE.COMBINATION) {
|
|
104
|
-
const isExist =
|
|
104
|
+
const isExist = _class.isValidCombinationChart(config, table);
|
|
105
105
|
if (!isExist) return false;
|
|
106
106
|
} else {
|
|
107
107
|
const summaryColumnKey = config.summary_column_key || config.y_axis_summary_column_key || config.horizontal_axis_column_key;
|
|
@@ -136,6 +136,9 @@ BaseUtils.getGroupColumn = (table, chart) => {
|
|
|
136
136
|
if (type === CHART_TYPE.TREND) {
|
|
137
137
|
return getTableColumnByKey(table, config.date_column_key);
|
|
138
138
|
}
|
|
139
|
+
if (type === CHART_TYPE.HEAT_MAP) {
|
|
140
|
+
return getTableColumnByKey(table, config.time_column_key);
|
|
141
|
+
}
|
|
139
142
|
return getTableColumnByKey(table, config.x_axis_column_key);
|
|
140
143
|
};
|
|
141
144
|
BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
@@ -154,6 +157,9 @@ BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
|
154
157
|
if ([CHART_TYPE.MIRROR].includes(type)) {
|
|
155
158
|
return getTableColumnByKey(table, config.group_column_key);
|
|
156
159
|
}
|
|
160
|
+
if (type === CHART_TYPE.SCATTER) {
|
|
161
|
+
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
162
|
+
}
|
|
157
163
|
return getTableColumnByKey(table, config.y_axis_summary_column_key);
|
|
158
164
|
};
|
|
159
165
|
BaseUtils.getSummaryColumn = (table, chart) => {
|
|
@@ -182,6 +188,10 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
182
188
|
{
|
|
183
189
|
return getTableColumnByKey(table, numeric_column_key);
|
|
184
190
|
}
|
|
191
|
+
case CHART_TYPE.SCATTER:
|
|
192
|
+
{
|
|
193
|
+
return getTableColumnByKey(table, config.y_axis_column_key);
|
|
194
|
+
}
|
|
185
195
|
default:
|
|
186
196
|
{
|
|
187
197
|
return getTableColumnByKey(table, summary_column_key);
|
|
@@ -193,7 +203,7 @@ BaseUtils.getGroupName = (tables, chart) => {
|
|
|
193
203
|
config
|
|
194
204
|
} = chart;
|
|
195
205
|
const table = getTableById(tables, config.table_id);
|
|
196
|
-
const column =
|
|
206
|
+
const column = _class.getGroupColumn(table, chart);
|
|
197
207
|
return column.name;
|
|
198
208
|
};
|
|
199
209
|
BaseUtils.getChartGroups = charts => {
|
|
@@ -228,7 +238,7 @@ BaseUtils.getSummaryValueDisplayString = function (summaryColumn, summaryValue)
|
|
|
228
238
|
const {
|
|
229
239
|
data
|
|
230
240
|
} = summaryColumn;
|
|
231
|
-
if (
|
|
241
|
+
if (_class.isDateSummaryColumn(summaryColumn)) {
|
|
232
242
|
if (typeof summaryValue !== 'string') return summaryValue;
|
|
233
243
|
|
|
234
244
|
// Compatible with previous data
|
|
@@ -263,7 +273,7 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue) => {
|
|
|
263
273
|
summaryMethod,
|
|
264
274
|
summaryColumn
|
|
265
275
|
} = _ref;
|
|
266
|
-
if (
|
|
276
|
+
if (_class.isDateSummaryColumn(summaryColumn)) {
|
|
267
277
|
if (summaryMethod === 'MAX') {
|
|
268
278
|
if (currentValue && nextValue) {
|
|
269
279
|
return dayjs(currentValue).isBefore(nextValue) ? nextValue : currentValue;
|
|
@@ -340,7 +350,7 @@ BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
|
340
350
|
return !shallowEqual(prevBorder, currBorder) || !shallowEqual(prevTitle, currTitle);
|
|
341
351
|
};
|
|
342
352
|
BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
343
|
-
return !
|
|
353
|
+
return !_class.isChartEqual(prevProps.chart, currentProps.chart) ||
|
|
344
354
|
// chart attributes changed
|
|
345
355
|
!shallowEqual(prevProps.canvasStyle, currentProps.canvasStyle) ||
|
|
346
356
|
// canvasStyle
|
|
@@ -350,7 +360,7 @@ BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
|
350
360
|
// columnGroupbyColumn's data、type changed or not exist
|
|
351
361
|
!shallowEqual(prevProps.summaryColumn, currentProps.summaryColumn) ||
|
|
352
362
|
// summaryColumn's data、type changed or not exist
|
|
353
|
-
|
|
363
|
+
_class._isChartDataChange(prevProps, currentProps) || _class.isChartStyleChanged(prevProps.chart, currentProps.chart);
|
|
354
364
|
};
|
|
355
365
|
BaseUtils._isCombinationDataChange = (prevResult, currentResult) => {
|
|
356
366
|
if (prevResult.value_left !== currentResult.value_left) return true;
|
|
@@ -366,7 +376,7 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
366
376
|
result: oldData
|
|
367
377
|
} = currentProps;
|
|
368
378
|
if (chart.config.type === CHART_TYPE.COMBINATION) {
|
|
369
|
-
return
|
|
379
|
+
return _class._isCombinationDataChange(newData, oldData);
|
|
370
380
|
}
|
|
371
381
|
if (!newData && !oldData) return false;
|
|
372
382
|
if (!newData && oldData || newData && !oldData) return true;
|
|
@@ -421,7 +431,7 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
421
431
|
table_id,
|
|
422
432
|
groupby_column_key: column_id
|
|
423
433
|
} = chart.config;
|
|
424
|
-
const column =
|
|
434
|
+
const column = _class.getColumn(tables, table_id, column_id);
|
|
425
435
|
const {
|
|
426
436
|
type: columnType
|
|
427
437
|
} = column || {};
|
|
@@ -488,7 +498,7 @@ BaseUtils.formatPieChartData = (data, chart, tables) => {
|
|
|
488
498
|
const value = item.value;
|
|
489
499
|
if (value >= threshold) {
|
|
490
500
|
item.percent = String(Number.parseFloat(value / sum * 100).toFixed(1)) + '%';
|
|
491
|
-
const color =
|
|
501
|
+
const color = _class.getPieColor(column, index, item);
|
|
492
502
|
item.color = color;
|
|
493
503
|
colorSet.push(color);
|
|
494
504
|
filteredData.push(item);
|
|
@@ -603,7 +613,7 @@ BaseUtils.updateTableViewListItemNameAndColor = (result, column, nameKey, colorK
|
|
|
603
613
|
};
|
|
604
614
|
BaseUtils.updateTableViewList = (result, column, nameKey, colorKey) => {
|
|
605
615
|
result.forEach(result => {
|
|
606
|
-
|
|
616
|
+
_class.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey);
|
|
607
617
|
});
|
|
608
618
|
};
|
|
609
619
|
// sort chart
|
|
@@ -739,10 +749,10 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
739
749
|
group_name
|
|
740
750
|
} = item;
|
|
741
751
|
if (groupbyColumn) {
|
|
742
|
-
|
|
752
|
+
_class.convertResultName(item, groupbyColumn, name, 'name', 'color');
|
|
743
753
|
}
|
|
744
754
|
if (columnGroupbyColumn) {
|
|
745
|
-
|
|
755
|
+
_class.convertResultName(item, columnGroupbyColumn, group_name, 'group_name', 'group_color');
|
|
746
756
|
}
|
|
747
757
|
});
|
|
748
758
|
};
|
|
@@ -1166,19 +1176,19 @@ BaseUtils.getSummaryResult = function (results, summaryMethod) {
|
|
|
1166
1176
|
switch (summaryMethod) {
|
|
1167
1177
|
case CHART_SUMMARY_TYPE.MAX:
|
|
1168
1178
|
{
|
|
1169
|
-
return
|
|
1179
|
+
return _class.getMax(numericResults);
|
|
1170
1180
|
}
|
|
1171
1181
|
case CHART_SUMMARY_TYPE.MIN:
|
|
1172
1182
|
{
|
|
1173
|
-
return
|
|
1183
|
+
return _class.getMin(numericResults);
|
|
1174
1184
|
}
|
|
1175
1185
|
case CHART_SUMMARY_TYPE.SUM:
|
|
1176
1186
|
{
|
|
1177
|
-
return
|
|
1187
|
+
return _class.getSum(numericResults, precision);
|
|
1178
1188
|
}
|
|
1179
1189
|
case CHART_SUMMARY_TYPE.MEAN:
|
|
1180
1190
|
{
|
|
1181
|
-
return
|
|
1191
|
+
return _class.getMean(numericResults, precision);
|
|
1182
1192
|
}
|
|
1183
1193
|
case CHART_SUMMARY_TYPE.Distinct_values:
|
|
1184
1194
|
{
|
|
@@ -1225,7 +1235,7 @@ BaseUtils.getSum = function (list) {
|
|
|
1225
1235
|
BaseUtils.getMean = function (list) {
|
|
1226
1236
|
let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
1227
1237
|
if (list.length === 0) return 0;
|
|
1228
|
-
const sum =
|
|
1238
|
+
const sum = _class.getSum(list);
|
|
1229
1239
|
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
1230
1240
|
};
|
|
1231
1241
|
BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) => {
|
|
@@ -1271,11 +1281,11 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1271
1281
|
// }
|
|
1272
1282
|
|
|
1273
1283
|
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1274
|
-
comparedValue =
|
|
1275
|
-
compareValue =
|
|
1284
|
+
comparedValue = _class.getSummaryResult(comparedValue, summaryMethod);
|
|
1285
|
+
compareValue = _class.getSummaryResult(compareValue, summaryMethod);
|
|
1276
1286
|
} else {
|
|
1277
|
-
compareValue =
|
|
1278
|
-
comparedValue =
|
|
1287
|
+
compareValue = _class.getSummaryResult(compareValue, 'Sum');
|
|
1288
|
+
comparedValue = _class.getSummaryResult(comparedValue, 'Sum');
|
|
1279
1289
|
}
|
|
1280
1290
|
return {
|
|
1281
1291
|
compareValue,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _class;
|
|
2
2
|
import { getTableById, getViewById } from 'dtable-utils';
|
|
3
3
|
import PivotTableCalculator from './pivot-table-calculator';
|
|
4
4
|
import BasicChartCalculator from './basic-chart-calculator';
|
|
@@ -34,7 +34,7 @@ const calculatorMap = {
|
|
|
34
34
|
[CHART_TYPE.DASHBOARD]: DashboardCalculator
|
|
35
35
|
};
|
|
36
36
|
class OriginalDataUtils {}
|
|
37
|
-
|
|
37
|
+
_class = OriginalDataUtils;
|
|
38
38
|
OriginalDataUtils.dataSources = 'original_data';
|
|
39
39
|
OriginalDataUtils.isValidExistChart = (tables, chart) => {
|
|
40
40
|
const isValid = BaseUtils.isValidExistChart(tables || [], chart);
|
|
@@ -49,7 +49,7 @@ OriginalDataUtils.isValidExistChart = (tables, chart) => {
|
|
|
49
49
|
return true;
|
|
50
50
|
};
|
|
51
51
|
OriginalDataUtils.calculateChart = async (chart, value, callback) => {
|
|
52
|
-
if (!
|
|
52
|
+
if (!_class.isValidExistChart((value === null || value === void 0 ? void 0 : value.tables) || [], chart)) {
|
|
53
53
|
const tip_message = 'Please_complete_the_chart_configuration_first';
|
|
54
54
|
return callback && callback('', tip_message, null);
|
|
55
55
|
}
|
|
@@ -76,7 +76,7 @@ OriginalDataUtils.calculateChart = async (chart, value, callback) => {
|
|
|
76
76
|
const chartTableColumns = table.columns;
|
|
77
77
|
return callback && callback('', '', {
|
|
78
78
|
result,
|
|
79
|
-
data_sources:
|
|
79
|
+
data_sources: _class.dataSources,
|
|
80
80
|
groupbyColumn,
|
|
81
81
|
columnGroupbyColumn,
|
|
82
82
|
summaryColumn,
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _class;
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
4
|
-
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, LABEL_COLORS, TABLE_DIMENSIONS,
|
|
4
|
+
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, LABEL_COLORS, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX } from '../../constants';
|
|
5
5
|
import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
|
|
6
6
|
import { getClientLinkDisplayString } from '../cell-format-utils';
|
|
7
7
|
import context from '../../context';
|
|
8
8
|
import { column2SqlColumn } from '../sql/column-2-sql-column';
|
|
9
|
-
import { formatNumericValue, getFormattedValue,
|
|
9
|
+
import { formatNumericValue, getFormattedValue, getSummaryResult } from '../column-utils';
|
|
10
10
|
import { getCompareDate } from '../trend-utils';
|
|
11
11
|
import intl from '../../intl';
|
|
12
12
|
import BaseUtils from './base-utils';
|
|
13
|
-
class SQLStatisticsUtils {
|
|
14
|
-
|
|
13
|
+
class SQLStatisticsUtils {
|
|
14
|
+
constructor() {
|
|
15
|
+
this._get_completeness_name = (row, column) => {
|
|
16
|
+
let value = row[column.key];
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
value = value.join('、');
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
_class = SQLStatisticsUtils;
|
|
15
25
|
SQLStatisticsUtils.dataSources = 'sql_statistics';
|
|
16
26
|
SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables) => {
|
|
17
27
|
const collaborators = context.getCollaboratorsFromCache();
|
|
@@ -230,7 +240,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
230
240
|
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
231
241
|
let newSqlRows = sqlRows;
|
|
232
242
|
if (groupbyColumn.type === CellType.COLLABORATOR) {
|
|
233
|
-
newSqlRows =
|
|
243
|
+
newSqlRows = _class.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
234
244
|
}
|
|
235
245
|
if (isCount) {
|
|
236
246
|
let allTotal = 0;
|
|
@@ -238,7 +248,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
238
248
|
const total = row[sqlSummaryColumnKey] || 0;
|
|
239
249
|
allTotal += total;
|
|
240
250
|
pivot_rows.push({
|
|
241
|
-
name:
|
|
251
|
+
name: _class.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
|
|
242
252
|
rows: [],
|
|
243
253
|
total: {
|
|
244
254
|
total
|
|
@@ -291,7 +301,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
291
301
|
}
|
|
292
302
|
});
|
|
293
303
|
pivot_rows.push({
|
|
294
|
-
name:
|
|
304
|
+
name: _class.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
|
|
295
305
|
rows: [row],
|
|
296
306
|
total: rowTotal
|
|
297
307
|
});
|
|
@@ -465,11 +475,11 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
465
475
|
sqlColumnGroupbyColumnKey,
|
|
466
476
|
sqlSummaryColumnKey
|
|
467
477
|
} = chartSQLMap;
|
|
468
|
-
if (!sqlColumnGroupbyColumnKey) return
|
|
478
|
+
if (!sqlColumnGroupbyColumnKey) return _class.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
469
479
|
const summaryMethod = (summary_method || 'sum').toUpperCase();
|
|
470
480
|
let newSqlRows = sqlRows;
|
|
471
481
|
if (groupbyColumn.type === CellType.COLLABORATOR) {
|
|
472
|
-
newSqlRows =
|
|
482
|
+
newSqlRows = _class.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
473
483
|
}
|
|
474
484
|
let pivot_columns = [];
|
|
475
485
|
let pivot_rows = [];
|
|
@@ -477,12 +487,12 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
477
487
|
const isRowGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
478
488
|
newSqlRows.forEach(row => {
|
|
479
489
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
480
|
-
const groupbyColumnCellValueKey =
|
|
490
|
+
const groupbyColumnCellValueKey = _class.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
481
491
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
482
|
-
const columnGroupbyColumnCellValueKey =
|
|
492
|
+
const columnGroupbyColumnCellValueKey = _class.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
483
493
|
const count = !row[sqlSummaryColumnKey] && row[sqlSummaryColumnKey] !== 0 ? null : row[sqlSummaryColumnKey];
|
|
484
494
|
if (BaseUtils.isValidCellValue(columnGroupbyColumnCellValue, groupby_include_empty_cells)) {
|
|
485
|
-
|
|
495
|
+
_class.updateTwoDimensionColumns(pivot_columns, columnGroupbyColumnCellValueKey, {
|
|
486
496
|
isIncludeEmpty: groupby_include_empty_cells,
|
|
487
497
|
isCellValueAsAnArray: isRowGroupbyColumnDataAsAnArray
|
|
488
498
|
});
|
|
@@ -491,14 +501,14 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
491
501
|
if (MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn]) {
|
|
492
502
|
if ((!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) && groupby_include_empty_cells) {
|
|
493
503
|
let pivotRowIndex = pivot_rows.findIndex(r => !r.name);
|
|
494
|
-
|
|
504
|
+
_class.updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, null, count, row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
495
505
|
summaryMethod,
|
|
496
506
|
summaryColumn
|
|
497
507
|
});
|
|
498
508
|
} else {
|
|
499
509
|
groupbyColumnCellValueKey.forEach(n => {
|
|
500
510
|
let pivotRowIndex = pivot_rows.findIndex(r => n === r.name);
|
|
501
|
-
|
|
511
|
+
_class.updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, n, count, row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
502
512
|
summaryMethod,
|
|
503
513
|
summaryColumn
|
|
504
514
|
});
|
|
@@ -509,14 +519,14 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
509
519
|
let resName = r.name;
|
|
510
520
|
return resName === null && groupbyColumnCellValueKey === null || resName === undefined && groupbyColumnCellValueKey === undefined || resName === 0 && groupbyColumnCellValueKey === 0 || resName === groupbyColumnCellValueKey;
|
|
511
521
|
});
|
|
512
|
-
|
|
522
|
+
_class.updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, groupbyColumnCellValueKey, count, row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
513
523
|
summaryMethod,
|
|
514
524
|
summaryColumn
|
|
515
525
|
});
|
|
516
526
|
}
|
|
517
527
|
}
|
|
518
528
|
});
|
|
519
|
-
let pivot_table_total =
|
|
529
|
+
let pivot_table_total = _class.getAndUpdateTwoDimensionTotal(pivot_columns_total, pivot_columns, pivot_rows, {
|
|
520
530
|
summaryMethod,
|
|
521
531
|
summaryColumn
|
|
522
532
|
});
|
|
@@ -558,7 +568,7 @@ SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap
|
|
|
558
568
|
formatted_value = getFormattedValue(cellValue, y_axis_summary_column_key, y_axis_summary_method);
|
|
559
569
|
}
|
|
560
570
|
if (BaseUtils.isValidCellValue(cellValue)) {
|
|
561
|
-
const key =
|
|
571
|
+
const key = _class.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
562
572
|
if (isGroupbyColumnDataAsAnArray) {
|
|
563
573
|
if (!Array.isArray(key) || key.length === 0) {
|
|
564
574
|
let itemIdx = result.findIndex(v => v.name === null);
|
|
@@ -672,7 +682,7 @@ SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMa
|
|
|
672
682
|
let result = [];
|
|
673
683
|
sqlRows.forEach(row => {
|
|
674
684
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
675
|
-
const label =
|
|
685
|
+
const label = _class.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
676
686
|
const isEmpty = !label;
|
|
677
687
|
const groupItems = [];
|
|
678
688
|
summaryMethods.forEach((summaryMethod, index) => {
|
|
@@ -695,46 +705,35 @@ SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMa
|
|
|
695
705
|
return result;
|
|
696
706
|
};
|
|
697
707
|
SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
708
|
+
const {
|
|
709
|
+
groupbyColumn,
|
|
710
|
+
summaryColumn
|
|
711
|
+
} = columnMap;
|
|
712
|
+
const {
|
|
713
|
+
sqlGroupbyColumnKey,
|
|
714
|
+
sqlSummaryColumnKey
|
|
715
|
+
} = chartSQLMap;
|
|
698
716
|
const {
|
|
699
717
|
config
|
|
700
718
|
} = chart;
|
|
701
719
|
const {
|
|
702
|
-
table_id,
|
|
703
720
|
x_axis_date_range_start,
|
|
704
721
|
x_axis_date_range_end,
|
|
705
722
|
x_axis_compared_date_range_start,
|
|
706
723
|
x_axis_compared_date_range_end,
|
|
707
724
|
y_axis_summary_type,
|
|
708
725
|
y_axis_summary_method,
|
|
709
|
-
x_axis_column_key,
|
|
710
|
-
y_axis_column_key,
|
|
711
|
-
x_axis_geolocation_granularity,
|
|
712
726
|
display_increase
|
|
713
727
|
} = config;
|
|
714
728
|
const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
|
|
715
729
|
const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
|
|
716
730
|
const dateRangeResult = new Map();
|
|
717
731
|
let dateComparedResult = new Map();
|
|
718
|
-
const selectedTable = getTableById(tables, table_id);
|
|
719
|
-
const selectedColumn = getColumnByKey(x_axis_column_key, selectedTable.columns);
|
|
720
|
-
const groupName = getSqlGroup(selectedColumn, {
|
|
721
|
-
'date_granularity': 'day',
|
|
722
|
-
'geolocation_granularity': x_axis_geolocation_granularity
|
|
723
|
-
});
|
|
724
|
-
let summaryColumnName = "".concat(selectedColumn.name);
|
|
725
|
-
let selectedSummaryColumn = {};
|
|
726
732
|
const isAdvanced = y_axis_summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
727
|
-
if (isAdvanced) {
|
|
728
|
-
selectedSummaryColumn = getColumnByKey(y_axis_column_key, selectedTable.columns);
|
|
729
|
-
if (!selectedSummaryColumn) return [];
|
|
730
|
-
summaryColumnName = "".concat(selectedSummaryColumn.name);
|
|
731
|
-
}
|
|
732
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[y_axis_summary_method] : DTABLE_DB_SUMMARY_METHOD.COUNT;
|
|
733
|
-
const valueKey = isAdvanced ? "".concat(method, "(").concat(summaryColumnName, ")") : "".concat(method, "(").concat(selectedColumn.name, ")");
|
|
734
733
|
sqlRows.forEach(item => {
|
|
735
|
-
const name = item[
|
|
736
|
-
const label =
|
|
737
|
-
const value = item[
|
|
734
|
+
const name = item[sqlGroupbyColumnKey];
|
|
735
|
+
const label = _class.getGroupLabelFromDB(name, groupbyColumn, tables);
|
|
736
|
+
const value = item[sqlSummaryColumnKey];
|
|
738
737
|
if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
|
|
739
738
|
const currentValue = dateRangeResult.get(label);
|
|
740
739
|
if (!currentValue) {
|
|
@@ -769,13 +768,13 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
769
768
|
});
|
|
770
769
|
let comparedResult = [];
|
|
771
770
|
let rangeResult = [];
|
|
772
|
-
const data =
|
|
771
|
+
const data = (summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.data) || {};
|
|
773
772
|
for (let item of dateRangeResult) {
|
|
774
773
|
let value = item[1];
|
|
775
774
|
let formatted_value = value;
|
|
776
775
|
if (isAdvanced) {
|
|
777
776
|
value = getSummaryResult(item[1], y_axis_summary_method, data.precision);
|
|
778
|
-
formatted_value = getFormattedValue(value,
|
|
777
|
+
formatted_value = getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
779
778
|
}
|
|
780
779
|
rangeResult.push({
|
|
781
780
|
name: item[0],
|
|
@@ -795,7 +794,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
795
794
|
let formatted_value = value;
|
|
796
795
|
if (isAdvanced) {
|
|
797
796
|
value = getSummaryResult(item[1], y_axis_summary_method, data.precision);
|
|
798
|
-
formatted_value = getFormattedValue(value,
|
|
797
|
+
formatted_value = getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
799
798
|
}
|
|
800
799
|
const newItem = {
|
|
801
800
|
name: dateRangeItem.name,
|
|
@@ -857,7 +856,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
857
856
|
sqlRows.forEach(row => {
|
|
858
857
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
859
858
|
const summaryValue = row[sqlSummaryColumnKey];
|
|
860
|
-
const key =
|
|
859
|
+
const key = _class.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
861
860
|
let valueLeft = row[sqlLeftSummaryColumnKey] || 0;
|
|
862
861
|
let valueRight = row[sqlRightSummaryColumnKey] || 0;
|
|
863
862
|
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
@@ -944,7 +943,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
944
943
|
});
|
|
945
944
|
sqlRows.forEach((item, index) => {
|
|
946
945
|
const cellValue = item[sqlGroupbyColumnKey];
|
|
947
|
-
const key =
|
|
946
|
+
const key = _class.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
948
947
|
let valueRight = item[sqlRightSummaryColumnKey] || 0;
|
|
949
948
|
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
950
949
|
valueRight = BaseUtils.getPrecisionNumber(valueRight, rightSummaryColumn.data);
|
|
@@ -1017,15 +1016,15 @@ SQLStatisticsUtils.updateGroupingChartRow = (results, name, groupName, row, coun
|
|
|
1017
1016
|
SQLStatisticsUtils.updateGroupingChartRows = (results, name, row, count, isColumnGroupbyColumnDataAsAnArray, groupName) => {
|
|
1018
1017
|
if (isColumnGroupbyColumnDataAsAnArray) {
|
|
1019
1018
|
if (!Array.isArray(groupName) || groupName.length === 0) {
|
|
1020
|
-
|
|
1019
|
+
_class.updateGroupingChartRow(results, name, null, row, count);
|
|
1021
1020
|
return;
|
|
1022
1021
|
}
|
|
1023
1022
|
groupName.forEach(v => {
|
|
1024
|
-
|
|
1023
|
+
_class.updateGroupingChartRow(results, name, v, row, count);
|
|
1025
1024
|
});
|
|
1026
1025
|
return;
|
|
1027
1026
|
}
|
|
1028
|
-
|
|
1027
|
+
_class.updateGroupingChartRow(results, name, groupName, row, count);
|
|
1029
1028
|
};
|
|
1030
1029
|
SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1031
1030
|
const {
|
|
@@ -1045,21 +1044,21 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRo
|
|
|
1045
1044
|
const isColumnGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
1046
1045
|
sqlRows.forEach(row => {
|
|
1047
1046
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1048
|
-
const groupbyColumnCellValueKey =
|
|
1047
|
+
const groupbyColumnCellValueKey = _class.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1049
1048
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1050
1049
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
1051
|
-
const columnGroupbyColumnCellValueKey =
|
|
1050
|
+
const columnGroupbyColumnCellValueKey = _class.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
1052
1051
|
const count = row[sqlSummaryColumnKey];
|
|
1053
1052
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1054
1053
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
1055
|
-
|
|
1054
|
+
_class.updateGroupingChartRows(result, null, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1056
1055
|
} else {
|
|
1057
1056
|
groupbyColumnCellValueKey.forEach(n => {
|
|
1058
|
-
|
|
1057
|
+
_class.updateGroupingChartRows(result, n, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1059
1058
|
});
|
|
1060
1059
|
}
|
|
1061
1060
|
} else {
|
|
1062
|
-
|
|
1061
|
+
_class.updateGroupingChartRows(result, groupbyColumnCellValueKey, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1063
1062
|
}
|
|
1064
1063
|
}
|
|
1065
1064
|
});
|
|
@@ -1076,15 +1075,15 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1076
1075
|
x_axis_include_empty_cells: includeEmpty
|
|
1077
1076
|
} = chart.config;
|
|
1078
1077
|
if (!column_groupby_column_key && !column_groupby_multiple_numeric_column) {
|
|
1079
|
-
return
|
|
1078
|
+
return _class.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1080
1079
|
}
|
|
1081
1080
|
const {
|
|
1082
1081
|
groupbyColumn,
|
|
1083
1082
|
columnGroupbyColumn
|
|
1084
1083
|
} = columnMap;
|
|
1085
1084
|
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1086
|
-
if (!columnGroupbyColumn) return
|
|
1087
|
-
return
|
|
1085
|
+
if (!columnGroupbyColumn) return _class.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1086
|
+
return _class.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1088
1087
|
}
|
|
1089
1088
|
const {
|
|
1090
1089
|
sqlGroupbyColumnKey
|
|
@@ -1097,7 +1096,7 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1097
1096
|
const isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn.type];
|
|
1098
1097
|
sqlRows.forEach(row => {
|
|
1099
1098
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1100
|
-
const groupbyColumnCellValueKey =
|
|
1099
|
+
const groupbyColumnCellValueKey = _class.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1101
1100
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1102
1101
|
Object.keys(summaryColumns).forEach(sqlSummaryColumnName => {
|
|
1103
1102
|
const {
|
|
@@ -1107,14 +1106,14 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1107
1106
|
const numberColumnCellValue = row[sqlSummaryColumnKey];
|
|
1108
1107
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1109
1108
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
1110
|
-
|
|
1109
|
+
_class.updateGroupingChartRows(result, null, row, numberColumnCellValue, false, columnName);
|
|
1111
1110
|
} else {
|
|
1112
1111
|
groupbyColumnCellValueKey.forEach(n => {
|
|
1113
|
-
|
|
1112
|
+
_class.updateGroupingChartRows(result, n, row, numberColumnCellValue, false, columnName);
|
|
1114
1113
|
});
|
|
1115
1114
|
}
|
|
1116
1115
|
} else {
|
|
1117
|
-
|
|
1116
|
+
_class.updateGroupingChartRows(result, groupbyColumnCellValueKey, row, numberColumnCellValue, false, columnName);
|
|
1118
1117
|
}
|
|
1119
1118
|
});
|
|
1120
1119
|
}
|
|
@@ -1124,31 +1123,24 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1124
1123
|
return result;
|
|
1125
1124
|
}
|
|
1126
1125
|
if (!columnGroupbyColumn) {
|
|
1127
|
-
return
|
|
1126
|
+
return _class.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1128
1127
|
}
|
|
1129
|
-
return
|
|
1128
|
+
return _class.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1130
1129
|
};
|
|
1131
1130
|
SQLStatisticsUtils.heatMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1132
|
-
const {
|
|
1133
|
-
config
|
|
1134
|
-
} = chart;
|
|
1135
|
-
const {
|
|
1136
|
-
time_column_key,
|
|
1137
|
-
summary_type
|
|
1138
|
-
} = config;
|
|
1139
1131
|
const {
|
|
1140
1132
|
summaryColumn
|
|
1141
1133
|
} = columnMap;
|
|
1142
1134
|
const {
|
|
1135
|
+
sqlGroupbyColumnKey,
|
|
1143
1136
|
sqlSummaryColumnKey
|
|
1144
1137
|
} = chartSQLMap;
|
|
1145
1138
|
let result = [];
|
|
1146
|
-
const isAdvanced = summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
1147
1139
|
sqlRows.forEach(item => {
|
|
1148
|
-
const currentValue = item[
|
|
1149
|
-
if (currentValue) {
|
|
1140
|
+
const currentValue = item[sqlGroupbyColumnKey];
|
|
1141
|
+
if (currentValue || currentValue === 0) {
|
|
1150
1142
|
let value = item[sqlSummaryColumnKey];
|
|
1151
|
-
if (
|
|
1143
|
+
if (summaryColumn) {
|
|
1152
1144
|
value = formatNumericValue(value, summaryColumn);
|
|
1153
1145
|
}
|
|
1154
1146
|
const name = typeof currentValue === 'string' ? currentValue : currentValue.country_region;
|
|
@@ -1175,13 +1167,9 @@ SQLStatisticsUtils.heatMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQLM
|
|
|
1175
1167
|
}
|
|
1176
1168
|
});
|
|
1177
1169
|
data.sort((current, next) => {
|
|
1178
|
-
if (current.year > next.year)
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
return 1;
|
|
1182
|
-
} else {
|
|
1183
|
-
return 0;
|
|
1184
|
-
}
|
|
1170
|
+
if (current.year > next.year) return -1;
|
|
1171
|
+
if (current.year < next.year) return 1;
|
|
1172
|
+
return 0;
|
|
1185
1173
|
});
|
|
1186
1174
|
return {
|
|
1187
1175
|
data,
|
|
@@ -1209,12 +1197,12 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQ
|
|
|
1209
1197
|
} = chartSQLMap;
|
|
1210
1198
|
const isAdvanced = summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
1211
1199
|
const newResult = [];
|
|
1212
|
-
const groupData =
|
|
1200
|
+
const groupData = _class.getGroupData(sqlRows, columnGroupbyColumn);
|
|
1213
1201
|
if (groupData.length > 0) {
|
|
1214
1202
|
const groupData0 = groupData[0] || {};
|
|
1215
1203
|
const groupData1 = groupData[1] || {};
|
|
1216
1204
|
sqlRows.forEach(item => {
|
|
1217
|
-
const label =
|
|
1205
|
+
const label = _class.getGroupLabelFromDB(item[column_key], groupbyColumn, tables);
|
|
1218
1206
|
const groupValue = item[group_column_key];
|
|
1219
1207
|
const equal2GroupData0 = groupData0.id === groupValue;
|
|
1220
1208
|
const equal2GroupData1 = groupData1.id === groupValue;
|
|
@@ -1309,11 +1297,11 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1309
1297
|
} = chart.config;
|
|
1310
1298
|
if (!column_groupby_column_key) {
|
|
1311
1299
|
return {
|
|
1312
|
-
result:
|
|
1300
|
+
result: _class.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1313
1301
|
};
|
|
1314
1302
|
}
|
|
1315
1303
|
return {
|
|
1316
|
-
result:
|
|
1304
|
+
result: _class.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1317
1305
|
};
|
|
1318
1306
|
}
|
|
1319
1307
|
case CHART_TYPE.PIE:
|
|
@@ -1321,19 +1309,19 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1321
1309
|
case CHART_TYPE.TREE_MAP:
|
|
1322
1310
|
{
|
|
1323
1311
|
return {
|
|
1324
|
-
result:
|
|
1312
|
+
result: _class.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1325
1313
|
};
|
|
1326
1314
|
}
|
|
1327
1315
|
case CHART_TYPE.BASIC_NUMBER_CARD:
|
|
1328
1316
|
{
|
|
1329
1317
|
return {
|
|
1330
|
-
result:
|
|
1318
|
+
result: _class.basicNumberCardSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1331
1319
|
};
|
|
1332
1320
|
}
|
|
1333
1321
|
case CHART_TYPE.DASHBOARD:
|
|
1334
1322
|
{
|
|
1335
1323
|
return {
|
|
1336
|
-
result:
|
|
1324
|
+
result: _class.dashboardSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1337
1325
|
};
|
|
1338
1326
|
}
|
|
1339
1327
|
case CHART_TYPE.BAR:
|
|
@@ -1342,13 +1330,13 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1342
1330
|
case CHART_TYPE.AREA:
|
|
1343
1331
|
{
|
|
1344
1332
|
return {
|
|
1345
|
-
result:
|
|
1333
|
+
result: _class.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1346
1334
|
};
|
|
1347
1335
|
}
|
|
1348
1336
|
case CHART_TYPE.COMPLETENESS:
|
|
1349
1337
|
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
1350
1338
|
{
|
|
1351
|
-
const result =
|
|
1339
|
+
const result = _class.completenessSQlResult(chart, sqlRows, chartSQLMap, tables);
|
|
1352
1340
|
return {
|
|
1353
1341
|
result
|
|
1354
1342
|
};
|
|
@@ -1356,13 +1344,13 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1356
1344
|
case CHART_TYPE.COMBINATION:
|
|
1357
1345
|
{
|
|
1358
1346
|
return {
|
|
1359
|
-
result:
|
|
1347
|
+
result: _class.combinationSQLResult2Javascript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1360
1348
|
};
|
|
1361
1349
|
}
|
|
1362
1350
|
case CHART_TYPE.COMPARE_BAR:
|
|
1363
1351
|
{
|
|
1364
1352
|
return {
|
|
1365
|
-
result:
|
|
1353
|
+
result: _class.compareSQLResult2Javascript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1366
1354
|
};
|
|
1367
1355
|
}
|
|
1368
1356
|
case CHART_TYPE.BAR_GROUP:
|
|
@@ -1373,51 +1361,51 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1373
1361
|
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1374
1362
|
{
|
|
1375
1363
|
return {
|
|
1376
|
-
result:
|
|
1364
|
+
result: _class.groupingChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1377
1365
|
};
|
|
1378
1366
|
}
|
|
1379
1367
|
case CHART_TYPE.SCATTER:
|
|
1380
1368
|
{
|
|
1381
1369
|
return {
|
|
1382
|
-
result:
|
|
1370
|
+
result: _class.scatterSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1383
1371
|
};
|
|
1384
1372
|
}
|
|
1385
1373
|
case CHART_TYPE.BAR_CUSTOM:
|
|
1386
1374
|
{
|
|
1387
1375
|
return {
|
|
1388
|
-
result:
|
|
1376
|
+
result: _class.customChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables, params)
|
|
1389
1377
|
};
|
|
1390
1378
|
}
|
|
1391
1379
|
case CHART_TYPE.MAP:
|
|
1392
1380
|
case CHART_TYPE.MAP_BUBBLE:
|
|
1393
1381
|
{
|
|
1394
1382
|
return {
|
|
1395
|
-
result:
|
|
1383
|
+
result: _class.mapSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1396
1384
|
};
|
|
1397
1385
|
}
|
|
1398
1386
|
case CHART_TYPE.WORLD_MAP:
|
|
1399
1387
|
case CHART_TYPE.WORLD_MAP_BUBBLE:
|
|
1400
1388
|
{
|
|
1401
1389
|
return {
|
|
1402
|
-
result:
|
|
1390
|
+
result: _class.worldMapSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1403
1391
|
};
|
|
1404
1392
|
}
|
|
1405
1393
|
case CHART_TYPE.HEAT_MAP:
|
|
1406
1394
|
{
|
|
1407
1395
|
return {
|
|
1408
|
-
result:
|
|
1396
|
+
result: _class.heatMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1409
1397
|
};
|
|
1410
1398
|
}
|
|
1411
1399
|
case CHART_TYPE.MIRROR:
|
|
1412
1400
|
{
|
|
1413
1401
|
return {
|
|
1414
|
-
result:
|
|
1402
|
+
result: _class.mirrorMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1415
1403
|
};
|
|
1416
1404
|
}
|
|
1417
1405
|
case CHART_TYPE.TREND:
|
|
1418
1406
|
{
|
|
1419
1407
|
return {
|
|
1420
|
-
result:
|
|
1408
|
+
result: _class.trendMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1421
1409
|
};
|
|
1422
1410
|
}
|
|
1423
1411
|
default:
|
|
@@ -1426,7 +1414,7 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1426
1414
|
}
|
|
1427
1415
|
}
|
|
1428
1416
|
};
|
|
1429
|
-
SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows,
|
|
1417
|
+
SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, chartSQLMap, tables) => {
|
|
1430
1418
|
const {
|
|
1431
1419
|
config: {
|
|
1432
1420
|
type
|
|
@@ -1436,7 +1424,7 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1436
1424
|
const {
|
|
1437
1425
|
sqlColumns,
|
|
1438
1426
|
sqlColumnGroupByColumnKey
|
|
1439
|
-
} =
|
|
1427
|
+
} = chartSQLMap;
|
|
1440
1428
|
const {
|
|
1441
1429
|
name_column,
|
|
1442
1430
|
completed_column,
|
|
@@ -1447,19 +1435,11 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1447
1435
|
// format the fetched value
|
|
1448
1436
|
BaseUtils.updateTableViewList(sqlRows, name_column, name_column.key, 'color');
|
|
1449
1437
|
if (sqlColumnGroupByColumnKey) BaseUtils.updateTableViewList(sqlRows, column_groupby_column, sqlColumnGroupByColumnKey, 'color');
|
|
1450
|
-
function getFormatedKey(row, column) {
|
|
1451
|
-
// const newKey = column.name;
|
|
1452
|
-
let value = row[column.key];
|
|
1453
|
-
if (Array.isArray(value)) {
|
|
1454
|
-
value = value.join('、');
|
|
1455
|
-
}
|
|
1456
|
-
return value;
|
|
1457
|
-
}
|
|
1458
1438
|
const res = [];
|
|
1459
|
-
let
|
|
1439
|
+
let summedSqlRows;
|
|
1460
1440
|
if (!isGroup) {
|
|
1461
1441
|
const sumSqlRows = sqlRows.reduce((acc, row) => {
|
|
1462
|
-
const nameValue =
|
|
1442
|
+
const nameValue = _class._get_completeness_name(row, name_column);
|
|
1463
1443
|
if (!acc[nameValue]) {
|
|
1464
1444
|
acc[nameValue] = row;
|
|
1465
1445
|
} else {
|
|
@@ -1471,10 +1451,10 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1471
1451
|
}
|
|
1472
1452
|
return acc;
|
|
1473
1453
|
}, {});
|
|
1474
|
-
|
|
1454
|
+
summedSqlRows = Object.values(sumSqlRows);
|
|
1475
1455
|
} else {
|
|
1476
1456
|
const sumSqlRowsWithGroupBy = sqlRows.reduce((acc, row) => {
|
|
1477
|
-
const nameValue =
|
|
1457
|
+
const nameValue = _class._get_completeness_name(row, name_column);
|
|
1478
1458
|
const groupby = row[sqlColumnGroupByColumnKey];
|
|
1479
1459
|
const key = "".concat(nameValue, "_").concat(groupby);
|
|
1480
1460
|
if (!acc[key]) {
|
|
@@ -1489,10 +1469,10 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1489
1469
|
}
|
|
1490
1470
|
return acc;
|
|
1491
1471
|
}, {});
|
|
1492
|
-
|
|
1472
|
+
summedSqlRows = Object.values(sumSqlRowsWithGroupBy);
|
|
1493
1473
|
}
|
|
1494
|
-
|
|
1495
|
-
const nameValue =
|
|
1474
|
+
summedSqlRows.forEach(row => {
|
|
1475
|
+
const nameValue = _class._get_completeness_name(row, name_column);
|
|
1496
1476
|
let targetValue;
|
|
1497
1477
|
let completedValue;
|
|
1498
1478
|
let groupby;
|
|
@@ -1501,8 +1481,8 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1501
1481
|
completedValue = row["SUM(".concat(completed_column.name, ")")];
|
|
1502
1482
|
groupby = row[sqlColumnGroupByColumnKey] || intl.get('Empty');
|
|
1503
1483
|
} else {
|
|
1504
|
-
completedValue =
|
|
1505
|
-
targetValue =
|
|
1484
|
+
completedValue = _class._get_completeness_name(row, completed_column);
|
|
1485
|
+
targetValue = _class._get_completeness_name(row, target_column);
|
|
1506
1486
|
}
|
|
1507
1487
|
let completedRate;
|
|
1508
1488
|
if (!targetValue && completedValue) {
|
|
@@ -1540,26 +1520,21 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1540
1520
|
return res;
|
|
1541
1521
|
};
|
|
1542
1522
|
SQLStatisticsUtils.scatterSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1543
|
-
const {
|
|
1544
|
-
x_axis_column_key,
|
|
1545
|
-
y_axis_column_key,
|
|
1546
|
-
column_groupby_column_key,
|
|
1547
|
-
table_id
|
|
1548
|
-
} = chart.config;
|
|
1549
1523
|
const {
|
|
1550
1524
|
sqlXColumnKey,
|
|
1551
1525
|
sqlYColumnKey,
|
|
1552
1526
|
sqlColumnGroupbyColumnKey
|
|
1553
1527
|
} = chartSQLMap;
|
|
1554
|
-
const
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1528
|
+
const {
|
|
1529
|
+
groupbyColumn,
|
|
1530
|
+
columnGroupbyColumn,
|
|
1531
|
+
summaryColumn
|
|
1532
|
+
} = columnMap;
|
|
1558
1533
|
|
|
1559
1534
|
// format sql rows
|
|
1560
|
-
BaseUtils.updateTableViewList(sqlRows,
|
|
1561
|
-
BaseUtils.updateTableViewList(sqlRows,
|
|
1562
|
-
if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows,
|
|
1535
|
+
BaseUtils.updateTableViewList(sqlRows, groupbyColumn, groupbyColumn.key, 'color');
|
|
1536
|
+
BaseUtils.updateTableViewList(sqlRows, summaryColumn, summaryColumn.key, 'color');
|
|
1537
|
+
if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows, columnGroupbyColumn, sqlColumnGroupbyColumnKey, 'color');
|
|
1563
1538
|
const res = [];
|
|
1564
1539
|
sqlRows.forEach(row => {
|
|
1565
1540
|
const xValue = row[sqlXColumnKey];
|
|
@@ -1668,7 +1643,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
|
1668
1643
|
const result = [];
|
|
1669
1644
|
sqlRows.forEach((item, index) => {
|
|
1670
1645
|
if (item.length !== 0) {
|
|
1671
|
-
const chartResult =
|
|
1646
|
+
const chartResult = _class.sqlResult2JavaScript(newChart, item, chartSQLMap, columnMap, tables, {
|
|
1672
1647
|
index
|
|
1673
1648
|
});
|
|
1674
1649
|
result.push(...chartResult.result);
|
|
@@ -1680,7 +1655,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
|
1680
1655
|
}
|
|
1681
1656
|
callback && callback('', '', {
|
|
1682
1657
|
result,
|
|
1683
|
-
data_sources:
|
|
1658
|
+
data_sources: _class.dataSources,
|
|
1684
1659
|
groupbyColumn,
|
|
1685
1660
|
columnGroupbyColumn,
|
|
1686
1661
|
summaryColumn,
|
|
@@ -1694,7 +1669,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
|
1694
1669
|
callback && callback('', tipMessage, null);
|
|
1695
1670
|
return;
|
|
1696
1671
|
}
|
|
1697
|
-
const chartResult =
|
|
1672
|
+
const chartResult = _class.sqlResult2JavaScript(newChart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1698
1673
|
|
|
1699
1674
|
// map is special
|
|
1700
1675
|
if (BaseUtils.imEmptyChartResult(chartResult) && !chartType.includes('map')) {
|
|
@@ -1703,7 +1678,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
|
1703
1678
|
}
|
|
1704
1679
|
callback && callback('', '', {
|
|
1705
1680
|
...chartResult,
|
|
1706
|
-
data_sources:
|
|
1681
|
+
data_sources: _class.dataSources,
|
|
1707
1682
|
groupbyColumn,
|
|
1708
1683
|
columnGroupbyColumn,
|
|
1709
1684
|
summaryColumn,
|
package/dist/utils/index.js
CHANGED
|
@@ -11,44 +11,6 @@ export { getDateColumnFormat, isCheckboxColumn, getColumnByKey, getColumnByName,
|
|
|
11
11
|
export { generatorKey } from './key-generator';
|
|
12
12
|
export { translateCalendar } from './date-translate';
|
|
13
13
|
export { isFunction } from './common-utils';
|
|
14
|
-
function removeStrBeforeMedia(url) {
|
|
15
|
-
const mediaIndex = url.indexOf('/media/');
|
|
16
|
-
if (mediaIndex !== -1) {
|
|
17
|
-
return url.substring(mediaIndex);
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// don't use it unless on map json query
|
|
23
|
-
export const getMediaUrlForMap = () => {
|
|
24
|
-
let {
|
|
25
|
-
mediaUrl,
|
|
26
|
-
server
|
|
27
|
-
} = window.seaChartConfig;
|
|
28
|
-
|
|
29
|
-
// proxy to dev server to aviod CORS
|
|
30
|
-
if (process.env.NODE_ENV === 'development' && server.includes('dev.seatable.cn')) {
|
|
31
|
-
server = process.env.DEV_SERVER_URL;
|
|
32
|
-
}
|
|
33
|
-
if (mediaUrl.startsWith('http')) {
|
|
34
|
-
mediaUrl = removeStrBeforeMedia(mediaUrl);
|
|
35
|
-
if (!mediaUrl) {
|
|
36
|
-
throw new Error('on getMediaUrl: mediaUrl is not valid');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return "".concat(server).concat(mediaUrl);
|
|
40
|
-
};
|
|
41
|
-
export const getMediaUrl = () => {
|
|
42
|
-
const {
|
|
43
|
-
media,
|
|
44
|
-
server
|
|
45
|
-
} = window.seaChartConfig;
|
|
46
|
-
if (media.startsWith('http')) {
|
|
47
|
-
return media;
|
|
48
|
-
} else {
|
|
49
|
-
return server + media;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
14
|
export const getGeoGranularityByLevel = mapLevel => {
|
|
53
15
|
switch (mapLevel) {
|
|
54
16
|
case MAP_LEVEL.PROVINCE:
|
|
@@ -107,7 +107,9 @@ class ChartDataSQL {
|
|
|
107
107
|
return '';
|
|
108
108
|
}
|
|
109
109
|
this._update_filter_sql(true, groupby_column);
|
|
110
|
-
const column_name = this._chart_column_name_to_sql(groupby_column, {
|
|
110
|
+
const column_name = this._chart_column_name_to_sql(groupby_column, {
|
|
111
|
+
date_granularity: 'day'
|
|
112
|
+
});
|
|
111
113
|
let summary_column_name = this._summary_column_2_sql('COUNT', groupby_column);
|
|
112
114
|
if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
113
115
|
const summary_column = this._get_column_by_key(summary_column_key);
|
|
@@ -117,7 +119,7 @@ class ChartDataSQL {
|
|
|
117
119
|
}
|
|
118
120
|
summary_column_name = this._summary_column_2_sql(summary_method.toUpperCase(), summary_column);
|
|
119
121
|
}
|
|
120
|
-
return "SELECT ".concat(column_name, ", ").concat(summary_column_name, " FROM
|
|
122
|
+
return "SELECT ".concat(column_name, ", ").concat(summary_column_name, " FROM ").concat(this.table_name, " ").concat(this.filter_sql, " GROUP BY ").concat(column_name, " LIMIT 0, 5000");
|
|
121
123
|
};
|
|
122
124
|
this._mirror_map_statistic_2_sql = () => {
|
|
123
125
|
const {
|
|
@@ -309,9 +311,10 @@ class ChartDataSQL {
|
|
|
309
311
|
this._compare_chart_statistic_2_sql = () => {
|
|
310
312
|
const {
|
|
311
313
|
x_axis_column_key,
|
|
314
|
+
x_axis_date_granularity,
|
|
315
|
+
x_axis_geolocation_granularity,
|
|
312
316
|
y_axis_summary_type,
|
|
313
317
|
y_axis_column_key,
|
|
314
|
-
x_axis_geolocation_granularity,
|
|
315
318
|
y_axis_summary_method,
|
|
316
319
|
x_axis_include_empty_cells
|
|
317
320
|
} = this.chart;
|
|
@@ -322,7 +325,7 @@ class ChartDataSQL {
|
|
|
322
325
|
}
|
|
323
326
|
this._update_filter_sql(x_axis_include_empty_cells, groupby_column);
|
|
324
327
|
const groupby_column_name = this._chart_column_name_to_sql(groupby_column, {
|
|
325
|
-
'date_granularity':
|
|
328
|
+
'date_granularity': x_axis_date_granularity,
|
|
326
329
|
'geolocation_granularity': x_axis_geolocation_granularity
|
|
327
330
|
});
|
|
328
331
|
let summary_column_name = this._summary_column_2_sql('COUNT', groupby_column);
|
|
@@ -319,7 +319,9 @@ const heatMapChartStatisticColumn2sqlColumn = (chart, table) => {
|
|
|
319
319
|
if (!groupbyColumn) return {};
|
|
320
320
|
const {
|
|
321
321
|
key: sqlGroupbyColumnKey
|
|
322
|
-
} = column2SqlColumn(groupbyColumn
|
|
322
|
+
} = column2SqlColumn(groupbyColumn, {
|
|
323
|
+
'dateGranularity': 'day'
|
|
324
|
+
});
|
|
323
325
|
const summaryMethod = summary_method && summary_method.toUpperCase();
|
|
324
326
|
let sqlSummaryColumnKey;
|
|
325
327
|
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
@@ -766,6 +768,7 @@ const chartColumn2SqlColumn = (chartElement, table) => {
|
|
|
766
768
|
case CHART_TYPE.LINE:
|
|
767
769
|
case CHART_TYPE.HORIZONTAL_BAR:
|
|
768
770
|
case CHART_TYPE.AREA:
|
|
771
|
+
case CHART_TYPE.COMPARE_BAR:
|
|
769
772
|
{
|
|
770
773
|
return basicChartStatisticColumn2sqlColumn(chart, table);
|
|
771
774
|
}
|
package/dist/view/wrapper/map.js
CHANGED
|
@@ -3,11 +3,11 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { getTableById, getTableColumnByKey, getNumberDisplayString } from 'dtable-utils';
|
|
4
4
|
import { DataSet } from '@antv/data-set';
|
|
5
5
|
import Loading from "dtable-ui-component/lib/Loading";
|
|
6
|
-
import { getMediaUrlForMap } from '../../utils';
|
|
7
6
|
import { CHART_SUMMARY_TYPE, DEFAULT_NUMBER_FORMAT_OBJECT, MAP_LEVEL } from '../../constants';
|
|
8
7
|
import { Chart } from '../../utils/custom-g2';
|
|
9
8
|
import fetchMapJson from '../../services/map-json';
|
|
10
9
|
import { COLOR_OPTIONS } from '../../constants/color-rules';
|
|
10
|
+
import context from '../../context';
|
|
11
11
|
const CHART_STYLE_CONFIG = {
|
|
12
12
|
'g2-tooltip': {
|
|
13
13
|
borderRadius: '2px',
|
|
@@ -87,9 +87,7 @@ const formatStatisticData = (statisticData, mapData, type) => {
|
|
|
87
87
|
export default function Map(props) {
|
|
88
88
|
const {
|
|
89
89
|
result: statisticData,
|
|
90
|
-
chart
|
|
91
|
-
tables,
|
|
92
|
-
theme
|
|
90
|
+
chart
|
|
93
91
|
} = props;
|
|
94
92
|
|
|
95
93
|
// mapLocation is initially set to null, in this case mapLevel is country, so doesn't here
|
|
@@ -256,7 +254,7 @@ export default function Map(props) {
|
|
|
256
254
|
// used to fetch mapJson data
|
|
257
255
|
useEffect(() => {
|
|
258
256
|
(async () => {
|
|
259
|
-
const mediaUrl =
|
|
257
|
+
const mediaUrl = context.getSetting('mediaUrl');
|
|
260
258
|
const mapJson = await fetchMapJson(mapLevel, mapLocation, mediaUrl);
|
|
261
259
|
setMapData(mapJson);
|
|
262
260
|
setIsLoading(false);
|
|
@@ -5,9 +5,10 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import { debounce } from 'lodash-es';
|
|
6
6
|
import intl from '../../intl';
|
|
7
7
|
import fetchMapJson from '../../services/map-json';
|
|
8
|
-
import { BaseUtils
|
|
8
|
+
import { BaseUtils } from '../../utils';
|
|
9
9
|
import { COLOR_OPTIONS } from '../../constants/color-rules';
|
|
10
10
|
import { CHART_SUMMARY_TYPE, MAP_LEVEL, CHART_TYPE, TITLE_AMOUNT, DEFAULT_NUMBER_FORMAT_OBJECT } from '../../constants';
|
|
11
|
+
import context from '../../context';
|
|
11
12
|
import ChartComponent from './chart-component';
|
|
12
13
|
const WIDTH = 798;
|
|
13
14
|
const HEIGHT = 394;
|
|
@@ -20,7 +21,7 @@ class WorldMap extends ChartComponent {
|
|
|
20
21
|
this.drawChart();
|
|
21
22
|
};
|
|
22
23
|
this.queryMapJson = async () => {
|
|
23
|
-
const mediaUrl =
|
|
24
|
+
const mediaUrl = context.getSetting('mediaUrl');
|
|
24
25
|
const mapJson = await fetchMapJson(MAP_LEVEL.WORLD, '', mediaUrl);
|
|
25
26
|
this.geoData = mapJson;
|
|
26
27
|
this.geoData.features.forEach(item => {
|