dtable-statistic 4.1.2 → 4.1.4

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/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,
@@ -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$props3 = this.props,
138
- getTableById = _this$props3.getTableById,
139
- isTableReadOnly = _this$props3.isTableReadOnly,
140
- dtableChangedTime = _this$props3.dtableChangedTime,
141
- colorThemeName = _this$props3.colorThemeName,
142
- statistics = _this$props3.statistics,
143
- selectedDashboardIdx = _this$props3.selectedDashboardIdx,
144
- chartCalculator = _this$props3.chartCalculator,
145
- labelColorConfigs = _this$props3.labelColorConfigs,
146
- eventBus = _this$props3.eventBus;
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,
@@ -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;
@@ -240,6 +240,7 @@ var zh_CN = {
240
240
  'New_table': '新建表',
241
241
  'Select_table': '选择子表',
242
242
  'Update_to_a_table': '更新到子表',
243
- 'Export_to_a_new_table': '导出到新的子表'
243
+ 'Export_to_a_new_table': '导出到新的子表',
244
+ "Move_to": "移动到..."
244
245
  };
245
246
  export default zh_CN;
@@ -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 { GEOLOCATION_GRANULARITY, LEGEND_DIRECTION_MAP, SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
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.geolocation_granularity = object.x_axis_geolocation_granularity || GEOLOCATION_GRANULARITY.PROVINCE;
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 };
@@ -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, {
@@ -5,11 +5,12 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React, { Component, Fragment } from 'react';
6
6
  import BaseSettings from '../public-setting/base-settings';
7
7
  import ColumnSettings from '../public-setting/column-settings';
8
- import GeoGranularitySettings from './geo-granularity-settings';
9
8
  import SummarySettings from './summary-settings';
10
9
  import MapStyleSetting from './style-setting/map-setting';
11
10
  import { isMapColumn } from '../../../utils/column-utils';
12
11
  import { GEOLOCATION_GRANULARITY } from '../../../constants';
12
+ import MapLevelSettings from '../map/map-level';
13
+ import MapProvinceCitySettings from '../map/map-province-city';
13
14
  var MapSettings = /*#__PURE__*/function (_Component) {
14
15
  _inherits(MapSettings, _Component);
15
16
  var _super = _createSuper(MapSettings);
@@ -23,29 +24,11 @@ var MapSettings = /*#__PURE__*/function (_Component) {
23
24
  return isMapColumn(column);
24
25
  });
25
26
  };
26
- _this.getGeoGranularityOptions = function () {
27
- return [{
28
- id: GEOLOCATION_GRANULARITY.PROVINCE,
29
- name: '按省'
30
- }].map(function (granularity) {
31
- return {
32
- label: /*#__PURE__*/React.createElement("span", {
33
- className: "select-option-name"
34
- }, granularity.name),
35
- value: granularity.id
36
- };
37
- });
38
- };
39
27
  _this.getSelectedGeoColumnOption = function () {
40
28
  return _this.geoColumnsOptions.find(function (option) {
41
29
  return option.value.key === _this.props.statItem.geo_column;
42
30
  });
43
31
  };
44
- _this.getSelectedGeoGranularityOption = function () {
45
- return _this.geoGranularityOptions.find(function (option) {
46
- return option.value === _this.props.statItem.geolocation_granularity;
47
- });
48
- };
49
32
  _this.onSelectGeoColumn = function (option) {
50
33
  var geo_column = _this.props.statItem.geo_column;
51
34
  var new_geo_column = option.value.key;
@@ -55,19 +38,10 @@ var MapSettings = /*#__PURE__*/function (_Component) {
55
38
  geolocation_granularity: GEOLOCATION_GRANULARITY.PROVINCE
56
39
  }));
57
40
  };
58
- _this.onSelectGeoGranularity = function (option) {
59
- var geolocation_granularity = _this.props.statItem.geolocation_granularity;
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
- }));
65
- };
66
41
  var _columns = props.columns,
67
42
  getColumnsOptions = props.getColumnsOptions;
68
43
  var geoColumns = _this.getColumns(_columns);
69
44
  _this.geoColumnsOptions = getColumnsOptions(geoColumns);
70
- _this.geoGranularityOptions = _this.getGeoGranularityOptions();
71
45
  return _this;
72
46
  }
73
47
  _createClass(MapSettings, [{
@@ -93,7 +67,6 @@ var MapSettings = /*#__PURE__*/function (_Component) {
93
67
  numericColumns = _this$props.numericColumns;
94
68
  var selectedViewId = statItem.view_id;
95
69
  var selectedGeoColumnOption = this.getSelectedGeoColumnOption();
96
- var selectedGeoGranularityOption = this.getSelectedGeoGranularityOption();
97
70
  if (settingType === 'style') {
98
71
  return /*#__PURE__*/React.createElement(MapStyleSetting, {
99
72
  statItem: statItem,
@@ -112,18 +85,20 @@ var MapSettings = /*#__PURE__*/function (_Component) {
112
85
  updateStatItem: this.props.updateStatItem
113
86
  }), /*#__PURE__*/React.createElement("div", {
114
87
  className: "statistic-chart-parameter-divider"
88
+ }), /*#__PURE__*/React.createElement(MapLevelSettings, {
89
+ statItem: statItem,
90
+ updateStatItem: this.props.updateStatItem
91
+ }), /*#__PURE__*/React.createElement(MapProvinceCitySettings, {
92
+ statItem: statItem,
93
+ updateStatItem: this.props.updateStatItem
94
+ }), /*#__PURE__*/React.createElement("div", {
95
+ className: "statistic-chart-parameter-divider"
115
96
  }), /*#__PURE__*/React.createElement("div", {
116
97
  className: "statistic-chart-parameter-item"
117
98
  }, /*#__PURE__*/React.createElement("label", null, "\u4F4D\u7F6E\u5B57\u6BB5"), /*#__PURE__*/React.createElement(ColumnSettings, {
118
99
  columnsOptions: this.geoColumnsOptions,
119
100
  selectedColumnOption: selectedGeoColumnOption,
120
101
  onChangeSelectedColumn: this.onSelectGeoColumn
121
- })), /*#__PURE__*/React.createElement("div", {
122
- className: "statistic-chart-parameter-item"
123
- }, /*#__PURE__*/React.createElement(GeoGranularitySettings, {
124
- geoGranularityOptions: this.geoGranularityOptions,
125
- selectedGeoGranularityOption: selectedGeoGranularityOption,
126
- onChangeGeoGranularity: this.onSelectGeoGranularity
127
102
  })), /*#__PURE__*/React.createElement("div", {
128
103
  className: "statistic-chart-parameter-divider"
129
104
  }), /*#__PURE__*/React.createElement(SummarySettings, {
@@ -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;