dtable-statistic 4.1.2 → 4.1.3
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/es/assets/css/dashboard.css +58 -0
- package/es/assets/icons/move-to.svg +20 -0
- package/es/calculator/map-calculator.js +23 -17
- package/es/calculator/workers/basic-chart-calculator-worker.js +2 -2
- package/es/components/dialog/chart-addition-edit-dialog.js +1 -0
- package/es/components/dialog/enlarged-chart-dialog.js +1 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +79 -3
- package/es/constants/index.js +1 -0
- package/es/constants/map.js +7 -0
- package/es/constants/regions.js +1292 -0
- package/es/dashboard.js +31 -1
- package/es/desktop-dashboard.js +23 -10
- package/es/locale/lang/en.js +2 -1
- package/es/locale/lang/zh_CN.js +2 -1
- package/es/mobile-dashboard.js +3 -1
- package/es/model/generic-model.js +5 -0
- package/es/model/map.js +5 -2
- package/es/service/dashboard-service.js +39 -0
- package/es/service/map-json.js +154 -0
- package/es/stat-editor/index.js +1 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +58 -22
- package/es/stat-editor/stat-settings/map/map-level.js +76 -0
- package/es/stat-editor/stat-settings/map/map-province-city.js +144 -0
- package/es/stat-list/chart-preview.js +8 -1
- package/es/stat-list/index.js +4 -0
- package/es/stat-view/index.js +1 -0
- package/es/stat-view/map.js +51 -28
- package/es/stat-view/world-map.js +8 -6
- package/es/utils/map.js +64 -0
- package/package.json +3 -3
package/es/dashboard.js
CHANGED
|
@@ -10,6 +10,7 @@ import { TableUtils, Views } from 'dtable-store';
|
|
|
10
10
|
import StatisticDashBoard from './model/statistic-dashboard';
|
|
11
11
|
import DashBoardService from './service/dashboard-service';
|
|
12
12
|
import ChartService from './service/chart-service';
|
|
13
|
+
import { MapJsonService } from './service/map-json';
|
|
13
14
|
import DesktopDashboard from './desktop-dashboard';
|
|
14
15
|
import MobileDashboard from './mobile-dashboard';
|
|
15
16
|
import ThreadManager from './calculator/thread-manager';
|
|
@@ -302,6 +303,20 @@ var DashBoard = /*#__PURE__*/function (_Component) {
|
|
|
302
303
|
});
|
|
303
304
|
_this.addChart(newChart);
|
|
304
305
|
};
|
|
306
|
+
_this.moveChartToView = function (chartId, viewId) {
|
|
307
|
+
_this.disabledUpdateLayout = true;
|
|
308
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
309
|
+
action: DASHBOARD_ACTION_TYPE.MOVE_CHART_TO_VIEW,
|
|
310
|
+
payload: {
|
|
311
|
+
index: _this.state.selectedDashboardIdx,
|
|
312
|
+
chart_id: chartId,
|
|
313
|
+
target_view_id: viewId
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
_this.updateStatistics({
|
|
317
|
+
statistics: updatedStatistics
|
|
318
|
+
});
|
|
319
|
+
};
|
|
305
320
|
_this.deleteChart = function (chartId) {
|
|
306
321
|
_this.disabledUpdateLayout = true;
|
|
307
322
|
var updatedStatistics = _this.dashboardService.update({
|
|
@@ -370,6 +385,15 @@ var DashBoard = /*#__PURE__*/function (_Component) {
|
|
|
370
385
|
var permission = window.dtable.permission || '';
|
|
371
386
|
return permission === 'r' || permission.slice(0, 2) === 'c-';
|
|
372
387
|
};
|
|
388
|
+
_this.queryMapJson = function (_ref4, callback) {
|
|
389
|
+
var map_level = _ref4.map_level,
|
|
390
|
+
map_location = _ref4.map_location;
|
|
391
|
+
_this.mapJsonService.queryMapJson({
|
|
392
|
+
map_level: map_level,
|
|
393
|
+
map_location: map_location
|
|
394
|
+
}, callback);
|
|
395
|
+
};
|
|
396
|
+
var mediaUrl = window.dtable.mediaUrl;
|
|
373
397
|
var _value = props.value;
|
|
374
398
|
var defaultChartTitle = intl.get('Untitled');
|
|
375
399
|
_this.defaultDashboardName = intl.get('Default_dashboard');
|
|
@@ -378,6 +402,9 @@ var DashBoard = /*#__PURE__*/function (_Component) {
|
|
|
378
402
|
defaultChartTitle: defaultChartTitle
|
|
379
403
|
});
|
|
380
404
|
_this.statisticThreadManager = new ThreadManager((navigator.hardwareConcurrency || 4) - 1);
|
|
405
|
+
_this.mapJsonService = new MapJsonService({
|
|
406
|
+
mediaUrl: mediaUrl
|
|
407
|
+
});
|
|
381
408
|
var _this$initDashboard2 = _this.initDashboard(),
|
|
382
409
|
_statistics = _this$initDashboard2.statistics,
|
|
383
410
|
_selectedDashboardIdx = _this$initDashboard2.selectedDashboardIdx;
|
|
@@ -433,7 +460,8 @@ var DashBoard = /*#__PURE__*/function (_Component) {
|
|
|
433
460
|
addDashboard: this.addDashboard,
|
|
434
461
|
renameDashboard: this.renameDashboard,
|
|
435
462
|
deleteDashboard: this.deleteDashboard,
|
|
436
|
-
getTableById: this.getTableById
|
|
463
|
+
getTableById: this.getTableById,
|
|
464
|
+
queryMapJson: this.queryMapJson
|
|
437
465
|
}) : /*#__PURE__*/React.createElement(DesktopDashboard, {
|
|
438
466
|
isTableReadOnly: isTableReadOnly,
|
|
439
467
|
colorThemeName: colorThemeName,
|
|
@@ -456,9 +484,11 @@ var DashBoard = /*#__PURE__*/function (_Component) {
|
|
|
456
484
|
getTableById: this.getTableById,
|
|
457
485
|
getTables: this.getTables,
|
|
458
486
|
getViews: this.getViews,
|
|
487
|
+
queryMapJson: this.queryMapJson,
|
|
459
488
|
getInitChart: this.getInitChart,
|
|
460
489
|
getConvertedChart: this.getConvertedChart,
|
|
461
490
|
copyChart: this.copyChart,
|
|
491
|
+
moveChartToView: this.moveChartToView,
|
|
462
492
|
deleteChart: this.deleteChart,
|
|
463
493
|
modifyDashboardLayout: this.modifyDashboardLayout,
|
|
464
494
|
addChart: this.addChart,
|
package/es/desktop-dashboard.js
CHANGED
|
@@ -117,6 +117,15 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
|
|
|
117
117
|
activeView: activeView
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
|
+
_this.getOtherStatistics = function () {
|
|
121
|
+
var _this$props3 = _this.props,
|
|
122
|
+
statistics = _this$props3.statistics,
|
|
123
|
+
selectedDashboardIdx = _this$props3.selectedDashboardIdx;
|
|
124
|
+
if (!Array.isArray(statistics)) return [];
|
|
125
|
+
return statistics.filter(function (_, index) {
|
|
126
|
+
return index !== selectedDashboardIdx;
|
|
127
|
+
});
|
|
128
|
+
};
|
|
120
129
|
var defaultChartTitle = intl.get('Untitled');
|
|
121
130
|
_this.charService = new ChartService({
|
|
122
131
|
defaultChartTitle: defaultChartTitle
|
|
@@ -134,16 +143,16 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
|
|
|
134
143
|
_createClass(DesktopDashboard, [{
|
|
135
144
|
key: "render",
|
|
136
145
|
value: function render() {
|
|
137
|
-
var _this$
|
|
138
|
-
getTableById = _this$
|
|
139
|
-
isTableReadOnly = _this$
|
|
140
|
-
dtableChangedTime = _this$
|
|
141
|
-
colorThemeName = _this$
|
|
142
|
-
statistics = _this$
|
|
143
|
-
selectedDashboardIdx = _this$
|
|
144
|
-
chartCalculator = _this$
|
|
145
|
-
labelColorConfigs = _this$
|
|
146
|
-
eventBus = _this$
|
|
146
|
+
var _this$props4 = this.props,
|
|
147
|
+
getTableById = _this$props4.getTableById,
|
|
148
|
+
isTableReadOnly = _this$props4.isTableReadOnly,
|
|
149
|
+
dtableChangedTime = _this$props4.dtableChangedTime,
|
|
150
|
+
colorThemeName = _this$props4.colorThemeName,
|
|
151
|
+
statistics = _this$props4.statistics,
|
|
152
|
+
selectedDashboardIdx = _this$props4.selectedDashboardIdx,
|
|
153
|
+
chartCalculator = _this$props4.chartCalculator,
|
|
154
|
+
labelColorConfigs = _this$props4.labelColorConfigs,
|
|
155
|
+
eventBus = _this$props4.eventBus;
|
|
147
156
|
var _this$state = this.state,
|
|
148
157
|
theme = _this$state.theme,
|
|
149
158
|
isFullScreen = _this$state.isFullScreen,
|
|
@@ -226,9 +235,12 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
|
|
|
226
235
|
statItems: statItems,
|
|
227
236
|
chartCalculator: chartCalculator,
|
|
228
237
|
eventBus: eventBus,
|
|
238
|
+
getOtherStatistics: this.getOtherStatistics,
|
|
229
239
|
getTableById: this.props.getTableById,
|
|
230
240
|
getTables: this.props.getTables,
|
|
241
|
+
queryMapJson: this.props.queryMapJson,
|
|
231
242
|
copyChart: this.props.copyChart,
|
|
243
|
+
moveChartToView: this.props.moveChartToView,
|
|
232
244
|
deleteChart: this.props.deleteChart,
|
|
233
245
|
modifyDashboardLayout: this.props.modifyDashboardLayout,
|
|
234
246
|
onToggleEditChart: this.onToggleEditChart,
|
|
@@ -244,6 +256,7 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
|
|
|
244
256
|
getTables: this.props.getTables,
|
|
245
257
|
getViews: this.props.getViews,
|
|
246
258
|
getTableById: this.props.getTableById,
|
|
259
|
+
queryMapJson: this.props.queryMapJson,
|
|
247
260
|
generateChart: this.generateChart,
|
|
248
261
|
hideChartAdditionDialog: this.onToggleChartAddition,
|
|
249
262
|
getConvertedChart: this.props.getConvertedChart,
|
package/es/locale/lang/en.js
CHANGED
|
@@ -240,6 +240,7 @@ var en = {
|
|
|
240
240
|
'New_table': 'New table',
|
|
241
241
|
'Select_table': 'Select table',
|
|
242
242
|
'Update_to_a_table': 'Update to a table',
|
|
243
|
-
'Export_to_a_new_table': 'Export to a new table'
|
|
243
|
+
'Export_to_a_new_table': 'Export to a new table',
|
|
244
|
+
"Move_to": "Move to..."
|
|
244
245
|
};
|
|
245
246
|
export default en;
|
package/es/locale/lang/zh_CN.js
CHANGED
package/es/mobile-dashboard.js
CHANGED
|
@@ -29,6 +29,7 @@ var MobileDashboard = /*#__PURE__*/function (_Component) {
|
|
|
29
29
|
_createClass(MobileDashboard, [{
|
|
30
30
|
key: "render",
|
|
31
31
|
value: function render() {
|
|
32
|
+
var _this2 = this;
|
|
32
33
|
var _this$props = this.props,
|
|
33
34
|
getTableById = _this$props.getTableById,
|
|
34
35
|
dtableChangedTime = _this$props.dtableChangedTime,
|
|
@@ -93,7 +94,8 @@ var MobileDashboard = /*#__PURE__*/function (_Component) {
|
|
|
93
94
|
chartCalculator: chartCalculator,
|
|
94
95
|
labelColorConfigs: labelColorConfigs,
|
|
95
96
|
eventBus: eventBus,
|
|
96
|
-
getTableById: getTableById
|
|
97
|
+
getTableById: getTableById,
|
|
98
|
+
queryMapJson: _this2.props.queryMapJson
|
|
97
99
|
})));
|
|
98
100
|
})));
|
|
99
101
|
}
|
|
@@ -7,6 +7,7 @@ import { getChartConfigValueFromKey, getChartConfigValueFromKeys } from '../util
|
|
|
7
7
|
import { isBoolean } from '../utils/common-utils';
|
|
8
8
|
import { DATE_GRANULARITY, DATE_GRANULARITY_LIST, DEFAULT_LABEL_FONT_SIZE, GEOLOCATION_GRANULARITY, GEOLOCATION_GRANULARITY_LIST } from '../constants';
|
|
9
9
|
import { COLUMN_DATE_GRANULARITY_KEYS, COLUMN_GEO_GRANULARITY_KEYS, COLUMN_GROUPBY_KEYS, LABEL_FRONT_SIZE_KEYS, X_DATE_GRANULARITY_KEYS, X_GEO_GRANULARITY_KEYS, X_GROUPBY_KEYS, X_INCLUDE_EMPTY_KEYS, X_LABEL_POSITION_KEYS, X_SHOW_AXIS_LABEL, Y_AUTO_RANGE_KEYS, Y_AUTO_RANGE_MAX_KEYS, Y_AUTO_RANGE_MIN_KEYS, Y_LABEL_COLOR_KEYS, Y_LABEL_COLOR_RULES_KEYS, Y_LABEL_POSITION_KEYS, Y_SHOW_AXIS_LABEL_KEYS, Y_SUMMARY_BY_KEYS, Y_SUMMARY_METHOD_KEYS, Y_SUMMARY_TYPE_KEYS } from '../constants/model';
|
|
10
|
+
import { MAP_LEVEL } from '../constants/map';
|
|
10
11
|
var GenericModel = /*#__PURE__*/function (_BaseModel) {
|
|
11
12
|
_inherits(GenericModel, _BaseModel);
|
|
12
13
|
var _super = _createSuper(GenericModel);
|
|
@@ -212,6 +213,10 @@ var GenericModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
212
213
|
}
|
|
213
214
|
_this.bubble_color = getChartConfigValueFromKey('bubble_color', object);
|
|
214
215
|
_this.label_format = getChartConfigValueFromKey('label_format', object);
|
|
216
|
+
|
|
217
|
+
// map
|
|
218
|
+
_this.map_level = getChartConfigValueFromKey('map_level', object) || MAP_LEVEL.COUNTRY;
|
|
219
|
+
_this.map_location = getChartConfigValueFromKey('map_location', object);
|
|
215
220
|
return _this;
|
|
216
221
|
}
|
|
217
222
|
return GenericModel;
|
package/es/model/map.js
CHANGED
|
@@ -4,7 +4,8 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
4
4
|
import { isNumber, TableUtils } from 'dtable-store';
|
|
5
5
|
import BaseModel from './base-model';
|
|
6
6
|
import { isMapColumn } from '../utils/column-utils';
|
|
7
|
-
import {
|
|
7
|
+
import { LEGEND_DIRECTION_MAP, SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
|
|
8
|
+
import { fixMapGeoGranularity } from '../utils/map';
|
|
8
9
|
var Map = /*#__PURE__*/function (_BaseModel) {
|
|
9
10
|
_inherits(Map, _BaseModel);
|
|
10
11
|
var _super = _createSuper(Map);
|
|
@@ -13,7 +14,9 @@ var Map = /*#__PURE__*/function (_BaseModel) {
|
|
|
13
14
|
_classCallCheck(this, Map);
|
|
14
15
|
_this = _super.call(this, object);
|
|
15
16
|
_this.geo_column = object.x_axis_column_key;
|
|
16
|
-
_this.
|
|
17
|
+
_this.map_level = object.map_level;
|
|
18
|
+
_this.map_location = object.map_location;
|
|
19
|
+
_this.geolocation_granularity = fixMapGeoGranularity(object);
|
|
17
20
|
if (_this.geo_column) {
|
|
18
21
|
var column = TableUtils.getTableColumnByKey(table, _this.geo_column);
|
|
19
22
|
if (!isMapColumn(column)) {
|
|
@@ -417,6 +417,45 @@ var DashBoardService = /*#__PURE__*/function () {
|
|
|
417
417
|
this.statistics = _updatedStatistics6;
|
|
418
418
|
break;
|
|
419
419
|
}
|
|
420
|
+
case DASHBOARD_ACTION_TYPE.MOVE_CHART_TO_VIEW:
|
|
421
|
+
{
|
|
422
|
+
var _index6 = payload.index,
|
|
423
|
+
_chart_id = payload.chart_id,
|
|
424
|
+
target_view_id = payload.target_view_id;
|
|
425
|
+
var _updatedStatistics7 = _toConsumableArray(this.statistics);
|
|
426
|
+
var currentDashboard = _updatedStatistics7[_index6];
|
|
427
|
+
if (!currentDashboard || !Array.isArray(currentDashboard.stat_items)) break;
|
|
428
|
+
var movedChartIndex = currentDashboard.stat_items.findIndex(function (chart) {
|
|
429
|
+
return chart._id === _chart_id;
|
|
430
|
+
});
|
|
431
|
+
if (movedChartIndex < 0) break;
|
|
432
|
+
var _targetDashboard = target_view_id && _updatedStatistics7.find(function (view) {
|
|
433
|
+
return view._id === target_view_id;
|
|
434
|
+
});
|
|
435
|
+
if (!_targetDashboard) break;
|
|
436
|
+
var movedCharts = currentDashboard.stat_items.splice(movedChartIndex, 1);
|
|
437
|
+
var movedChart = movedCharts && movedCharts[0];
|
|
438
|
+
if (!movedChart) break;
|
|
439
|
+
var newChartId = movedChart._id;
|
|
440
|
+
if (!Array.isArray(_targetDashboard.stat_items)) {
|
|
441
|
+
_targetDashboard.stat_items = [];
|
|
442
|
+
} else {
|
|
443
|
+
newChartId = generatorUniqueId(_targetDashboard.statItems);
|
|
444
|
+
}
|
|
445
|
+
movedChart = Object.assign(movedChart, {
|
|
446
|
+
_id: newChartId,
|
|
447
|
+
layout: {
|
|
448
|
+
i: newChartId,
|
|
449
|
+
x: _targetDashboard.stat_items.length % 2 * 2,
|
|
450
|
+
y: Infinity,
|
|
451
|
+
w: 2,
|
|
452
|
+
h: 7
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
_targetDashboard.stat_items.push(movedChart);
|
|
456
|
+
this.statistics = _updatedStatistics7;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
420
459
|
default:
|
|
421
460
|
{
|
|
422
461
|
break;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import { MAP_LEVEL } from '../constants/map';
|
|
4
|
+
import { regions } from '../constants/regions';
|
|
5
|
+
var MapJsonService = /*#__PURE__*/function () {
|
|
6
|
+
function MapJsonService(_ref) {
|
|
7
|
+
var mediaUrl = _ref.mediaUrl;
|
|
8
|
+
_classCallCheck(this, MapJsonService);
|
|
9
|
+
this.mediaUrl = mediaUrl;
|
|
10
|
+
this.urlMapJsonQuerying = {};
|
|
11
|
+
this.urlWaitingExecCallbacks = {};
|
|
12
|
+
this.urlMapJson = {};
|
|
13
|
+
}
|
|
14
|
+
_createClass(MapJsonService, [{
|
|
15
|
+
key: "getNameEnByMapLocation",
|
|
16
|
+
value: function getNameEnByMapLocation(mapLocation) {
|
|
17
|
+
var provinceName = mapLocation && mapLocation.province;
|
|
18
|
+
var province = provinceName && regions.find(function (province) {
|
|
19
|
+
return province.name === provinceName;
|
|
20
|
+
});
|
|
21
|
+
if (!province) return null;
|
|
22
|
+
var nameEN = {
|
|
23
|
+
province_name_en: province.name_en
|
|
24
|
+
};
|
|
25
|
+
var cityName = mapLocation.city;
|
|
26
|
+
var cities = province.cities;
|
|
27
|
+
var city = cityName && Array.isArray(cities) && cities.find(function (city) {
|
|
28
|
+
return city.name === cityName;
|
|
29
|
+
});
|
|
30
|
+
if (!city) {
|
|
31
|
+
return nameEN;
|
|
32
|
+
}
|
|
33
|
+
nameEN.city_name_en = city.name_en;
|
|
34
|
+
return nameEN;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} mapLevel
|
|
39
|
+
* @param {object} mapLocation: province, city
|
|
40
|
+
* @returns part url for query map-json
|
|
41
|
+
*/
|
|
42
|
+
}, {
|
|
43
|
+
key: "getMapJsonQueryUrl",
|
|
44
|
+
value: function getMapJsonQueryUrl(mapLevel, mapLocation) {
|
|
45
|
+
switch (mapLevel) {
|
|
46
|
+
case MAP_LEVEL.WORLD:
|
|
47
|
+
{
|
|
48
|
+
return 'world';
|
|
49
|
+
}
|
|
50
|
+
case MAP_LEVEL.COUNTRY:
|
|
51
|
+
{
|
|
52
|
+
return 'china';
|
|
53
|
+
}
|
|
54
|
+
case MAP_LEVEL.PROVINCE:
|
|
55
|
+
{
|
|
56
|
+
var nameEn = this.getNameEnByMapLocation(mapLocation);
|
|
57
|
+
var provinceNameEn = nameEn && nameEn.province_name_en;
|
|
58
|
+
if (!provinceNameEn) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return "region-mapjson/".concat(provinceNameEn, "/").concat(provinceNameEn);
|
|
62
|
+
}
|
|
63
|
+
case MAP_LEVEL.CITY:
|
|
64
|
+
{
|
|
65
|
+
var _nameEn = this.getNameEnByMapLocation(mapLocation);
|
|
66
|
+
var _provinceNameEn = _nameEn && _nameEn.province_name_en;
|
|
67
|
+
var cityNameEn = _nameEn && _nameEn.city_name_en;
|
|
68
|
+
if (!_provinceNameEn || !cityNameEn) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// e.g. 北京市/北京市
|
|
73
|
+
if (_provinceNameEn === cityNameEn) {
|
|
74
|
+
return "region-mapjson/".concat(_provinceNameEn, "/").concat(_provinceNameEn);
|
|
75
|
+
}
|
|
76
|
+
return "region-mapjson/".concat(_provinceNameEn, "/").concat(_provinceNameEn, "_").concat(cityNameEn);
|
|
77
|
+
}
|
|
78
|
+
default:
|
|
79
|
+
{
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "getMapJson",
|
|
86
|
+
value: function getMapJson(url) {
|
|
87
|
+
return this.urlMapJson[url];
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "setMapJson",
|
|
91
|
+
value: function setMapJson(url, json) {
|
|
92
|
+
this.urlMapJsonMap[url] = json;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "queryMapJson",
|
|
96
|
+
value: function queryMapJson(_ref2, callback) {
|
|
97
|
+
var map_level = _ref2.map_level,
|
|
98
|
+
map_location = _ref2.map_location;
|
|
99
|
+
var url = this.getMapJsonQueryUrl(map_level, map_location);
|
|
100
|
+
if (!url) {
|
|
101
|
+
callback && callback();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
var existMapJson = this.getMapJson(url);
|
|
105
|
+
if (existMapJson) {
|
|
106
|
+
callback && callback(existMapJson);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (this.urlWaitingExecCallbacks[url]) {
|
|
110
|
+
this.urlWaitingExecCallbacks[url].push(callback);
|
|
111
|
+
} else {
|
|
112
|
+
this.urlWaitingExecCallbacks[url] = [callback];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// the target map-json is being querying
|
|
116
|
+
if (this.urlMapJsonQuerying[url]) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.urlMapJsonQuerying[url] = true;
|
|
120
|
+
this.startQuery(url);
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "startQuery",
|
|
124
|
+
value: function startQuery(url) {
|
|
125
|
+
var _this = this;
|
|
126
|
+
fetch("".concat(this.mediaUrl, "dtable-statistic/geolocation/").concat(url, ".json")).then(function (res) {
|
|
127
|
+
return res && res.json();
|
|
128
|
+
}).then(function (mapJson) {
|
|
129
|
+
_this.handleLoadedMapJson(url, mapJson);
|
|
130
|
+
}).catch(function (err) {
|
|
131
|
+
// eslint-disable-next-line
|
|
132
|
+
console.log(err);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "handleLoadedMapJson",
|
|
137
|
+
value: function handleLoadedMapJson(url, mapJson) {
|
|
138
|
+
var isValid = mapJson && !mapJson.features;
|
|
139
|
+
if (isValid) {
|
|
140
|
+
this.setMapJson(url, mapJson);
|
|
141
|
+
}
|
|
142
|
+
var callbacks = this.urlWaitingExecCallbacks[url];
|
|
143
|
+
if (Array.isArray(callbacks) && callbacks.length > 0) {
|
|
144
|
+
callbacks.forEach(function (callback) {
|
|
145
|
+
callback && callback(mapJson);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
delete this.urlWaitingExecCallbacks[url];
|
|
149
|
+
delete this.urlMapJsonQuerying[url];
|
|
150
|
+
}
|
|
151
|
+
}]);
|
|
152
|
+
return MapJsonService;
|
|
153
|
+
}();
|
|
154
|
+
export { MapJsonService };
|
package/es/stat-editor/index.js
CHANGED
|
@@ -49,6 +49,7 @@ var StatEditor = /*#__PURE__*/function (_Component) {
|
|
|
49
49
|
chartCalculator: chartCalculator,
|
|
50
50
|
eventBus: eventBus,
|
|
51
51
|
getTableById: getTableById,
|
|
52
|
+
queryMapJson: this.props.queryMapJson,
|
|
52
53
|
updateStatItem: this.props.modifyChart,
|
|
53
54
|
toggleStatisticRecordsDialog: this.props.toggleStatisticRecordsDialog
|
|
54
55
|
}))), BASIC_STAT_TYPES.includes(statItem.type) ? /*#__PURE__*/React.createElement(BasicChartSettings, {
|
|
@@ -10,6 +10,10 @@ import SummarySettings from './summary-settings';
|
|
|
10
10
|
import MapStyleSetting from './style-setting/map-setting';
|
|
11
11
|
import { isMapColumn } from '../../../utils/column-utils';
|
|
12
12
|
import { GEOLOCATION_GRANULARITY } from '../../../constants';
|
|
13
|
+
import MapLevelSettings from '../map/map-level';
|
|
14
|
+
import MapProvinceCitySettings from '../map/map-province-city';
|
|
15
|
+
import { MAP_LEVEL } from '../../../constants/map';
|
|
16
|
+
import { fixGeoGranularity } from '../../../utils/map';
|
|
13
17
|
var MapSettings = /*#__PURE__*/function (_Component) {
|
|
14
18
|
_inherits(MapSettings, _Component);
|
|
15
19
|
var _super = _createSuper(MapSettings);
|
|
@@ -23,28 +27,57 @@ var MapSettings = /*#__PURE__*/function (_Component) {
|
|
|
23
27
|
return isMapColumn(column);
|
|
24
28
|
});
|
|
25
29
|
};
|
|
26
|
-
_this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
30
|
+
_this.generateGeoGranularityOptions = function () {
|
|
31
|
+
_this.provinceGranularityOption = {
|
|
32
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
33
|
+
className: "select-option-name"
|
|
34
|
+
}, '按省'),
|
|
35
|
+
value: GEOLOCATION_GRANULARITY.PROVINCE
|
|
36
|
+
};
|
|
37
|
+
_this.cityGranularityOption = {
|
|
38
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
className: "select-option-name"
|
|
40
|
+
}, '按市'),
|
|
41
|
+
value: GEOLOCATION_GRANULARITY.CITY
|
|
42
|
+
};
|
|
43
|
+
_this.districtGranularityOption = {
|
|
44
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "select-option-name"
|
|
46
|
+
}, '按区/县'),
|
|
47
|
+
value: GEOLOCATION_GRANULARITY.DISTRICT
|
|
48
|
+
};
|
|
38
49
|
};
|
|
39
50
|
_this.getSelectedGeoColumnOption = function () {
|
|
40
51
|
return _this.geoColumnsOptions.find(function (option) {
|
|
41
52
|
return option.value.key === _this.props.statItem.geo_column;
|
|
42
53
|
});
|
|
43
54
|
};
|
|
55
|
+
_this.getGeoGranularityOptions = function () {
|
|
56
|
+
var map_level = _this.props.statItem.map_level;
|
|
57
|
+
return _this.mapLevel2GeoGranularityOptions[map_level || MAP_LEVEL.COUNTRY];
|
|
58
|
+
};
|
|
44
59
|
_this.getSelectedGeoGranularityOption = function () {
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
var _this$props$statItem = _this.props.statItem,
|
|
61
|
+
map_level = _this$props$statItem.map_level,
|
|
62
|
+
map_location = _this$props$statItem.map_location;
|
|
63
|
+
var geoGranularity = fixGeoGranularity({
|
|
64
|
+
mapLevel: map_level,
|
|
65
|
+
mapLocation: map_location
|
|
47
66
|
});
|
|
67
|
+
switch (geoGranularity) {
|
|
68
|
+
case GEOLOCATION_GRANULARITY.CITY:
|
|
69
|
+
{
|
|
70
|
+
return _this.cityGranularityOption;
|
|
71
|
+
}
|
|
72
|
+
case GEOLOCATION_GRANULARITY.DISTRICT:
|
|
73
|
+
{
|
|
74
|
+
return _this.districtGranularityOption;
|
|
75
|
+
}
|
|
76
|
+
default:
|
|
77
|
+
{
|
|
78
|
+
return _this.provinceGranularityOption;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
48
81
|
};
|
|
49
82
|
_this.onSelectGeoColumn = function (option) {
|
|
50
83
|
var geo_column = _this.props.statItem.geo_column;
|
|
@@ -56,18 +89,13 @@ var MapSettings = /*#__PURE__*/function (_Component) {
|
|
|
56
89
|
}));
|
|
57
90
|
};
|
|
58
91
|
_this.onSelectGeoGranularity = function (option) {
|
|
59
|
-
|
|
60
|
-
var new_geolocation_granularity = option.value;
|
|
61
|
-
if (new_geolocation_granularity === geolocation_granularity) return;
|
|
62
|
-
_this.props.updateStatItem(Object.assign({}, _this.props.statItem, {
|
|
63
|
-
geolocation_granularity: new_geolocation_granularity
|
|
64
|
-
}));
|
|
92
|
+
return;
|
|
65
93
|
};
|
|
66
94
|
var _columns = props.columns,
|
|
67
95
|
getColumnsOptions = props.getColumnsOptions;
|
|
68
96
|
var geoColumns = _this.getColumns(_columns);
|
|
69
97
|
_this.geoColumnsOptions = getColumnsOptions(geoColumns);
|
|
70
|
-
_this.
|
|
98
|
+
_this.generateGeoGranularityOptions();
|
|
71
99
|
return _this;
|
|
72
100
|
}
|
|
73
101
|
_createClass(MapSettings, [{
|
|
@@ -112,6 +140,14 @@ var MapSettings = /*#__PURE__*/function (_Component) {
|
|
|
112
140
|
updateStatItem: this.props.updateStatItem
|
|
113
141
|
}), /*#__PURE__*/React.createElement("div", {
|
|
114
142
|
className: "statistic-chart-parameter-divider"
|
|
143
|
+
}), /*#__PURE__*/React.createElement(MapLevelSettings, {
|
|
144
|
+
statItem: statItem,
|
|
145
|
+
updateStatItem: this.props.updateStatItem
|
|
146
|
+
}), /*#__PURE__*/React.createElement(MapProvinceCitySettings, {
|
|
147
|
+
statItem: statItem,
|
|
148
|
+
updateStatItem: this.props.updateStatItem
|
|
149
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
className: "statistic-chart-parameter-divider"
|
|
115
151
|
}), /*#__PURE__*/React.createElement("div", {
|
|
116
152
|
className: "statistic-chart-parameter-item"
|
|
117
153
|
}, /*#__PURE__*/React.createElement("label", null, "\u4F4D\u7F6E\u5B57\u6BB5"), /*#__PURE__*/React.createElement(ColumnSettings, {
|
|
@@ -121,7 +157,7 @@ var MapSettings = /*#__PURE__*/function (_Component) {
|
|
|
121
157
|
})), /*#__PURE__*/React.createElement("div", {
|
|
122
158
|
className: "statistic-chart-parameter-item"
|
|
123
159
|
}, /*#__PURE__*/React.createElement(GeoGranularitySettings, {
|
|
124
|
-
geoGranularityOptions:
|
|
160
|
+
geoGranularityOptions: [selectedGeoGranularityOption],
|
|
125
161
|
selectedGeoGranularityOption: selectedGeoGranularityOption,
|
|
126
162
|
onChangeGeoGranularity: this.onSelectGeoGranularity
|
|
127
163
|
})), /*#__PURE__*/React.createElement("div", {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Component } from 'react';
|
|
6
|
+
import { DTableSelect } from '../../../components';
|
|
7
|
+
import { fixGeoGranularity } from '../../../utils/map';
|
|
8
|
+
import { MAP_LEVEL } from '../../../constants/map';
|
|
9
|
+
var MAP_LEVELS = [{
|
|
10
|
+
key: MAP_LEVEL.COUNTRY,
|
|
11
|
+
name: '国家'
|
|
12
|
+
}, {
|
|
13
|
+
key: MAP_LEVEL.PROVINCE,
|
|
14
|
+
name: '省级'
|
|
15
|
+
}, {
|
|
16
|
+
key: MAP_LEVEL.CITY,
|
|
17
|
+
name: '市级'
|
|
18
|
+
}];
|
|
19
|
+
var MapLevelSettings = /*#__PURE__*/function (_Component) {
|
|
20
|
+
_inherits(MapLevelSettings, _Component);
|
|
21
|
+
var _super = _createSuper(MapLevelSettings);
|
|
22
|
+
function MapLevelSettings(props) {
|
|
23
|
+
var _this;
|
|
24
|
+
_classCallCheck(this, MapLevelSettings);
|
|
25
|
+
_this = _super.call(this, props);
|
|
26
|
+
_this.createMapLevelOptions = function () {
|
|
27
|
+
return MAP_LEVELS.map(function (mapLevel) {
|
|
28
|
+
return {
|
|
29
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
className: "select-option-name"
|
|
31
|
+
}, mapLevel.name),
|
|
32
|
+
value: mapLevel.key
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
_this.getSelectedMapLevelOption = function () {
|
|
37
|
+
var map_level = _this.props.statItem.map_level;
|
|
38
|
+
var defaultOption = _this.mapLevelOptions[0];
|
|
39
|
+
if (!map_level) return defaultOption;
|
|
40
|
+
return _this.mapLevelOptions.find(function (option) {
|
|
41
|
+
return option.value === map_level;
|
|
42
|
+
}) || defaultOption;
|
|
43
|
+
};
|
|
44
|
+
_this.onSelectMapLevel = function (option) {
|
|
45
|
+
var _this$props$statItem = _this.props.statItem,
|
|
46
|
+
map_level = _this$props$statItem.map_level,
|
|
47
|
+
map_location = _this$props$statItem.map_location;
|
|
48
|
+
var newLevel = option.value;
|
|
49
|
+
if (newLevel === map_level) return;
|
|
50
|
+
var updated = {
|
|
51
|
+
map_level: newLevel,
|
|
52
|
+
geolocation_granularity: fixGeoGranularity({
|
|
53
|
+
mapLevel: newLevel,
|
|
54
|
+
mapLocation: map_location
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
_this.props.updateStatItem(Object.assign({}, _this.props.statItem, updated));
|
|
58
|
+
};
|
|
59
|
+
_this.mapLevelOptions = _this.createMapLevelOptions();
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
_createClass(MapLevelSettings, [{
|
|
63
|
+
key: "render",
|
|
64
|
+
value: function render() {
|
|
65
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "statistic-chart-parameter-item"
|
|
67
|
+
}, /*#__PURE__*/React.createElement("label", null, "\u5730\u56FE\u7EA7\u522B"), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
68
|
+
value: this.getSelectedMapLevelOption(),
|
|
69
|
+
options: this.mapLevelOptions,
|
|
70
|
+
onChange: this.onSelectMapLevel
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
return MapLevelSettings;
|
|
75
|
+
}(Component);
|
|
76
|
+
export default MapLevelSettings;
|