dtable-statistic 4.1.5 → 4.1.7

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.
@@ -161,6 +161,10 @@
161
161
  height: 100%;
162
162
  }
163
163
 
164
+ .statistic-chart-container.map {
165
+ padding: 20px;
166
+ }
167
+
164
168
  .statistic-chart-loading-container {
165
169
  position: absolute;
166
170
  width: 100%;
@@ -438,7 +438,7 @@ var BasicChartCalculator = /*#__PURE__*/function (_BaseCalculator) {
438
438
  }
439
439
  var color;
440
440
  if (columnGroupbyColumn.type === CellType.SINGLE_SELECT) {
441
- var tempValue = StatUtils.getGroupLabel(item[columnGroupbyColumn.key], {}, columnGroupbyColumn, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, _this2.value);
441
+ var tempValue = StatUtils.getGroupLabel(item[columnGroupbyColumn.key], item, columnGroupbyColumn, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, _this2.value);
442
442
  color = getColorFromSingleSelectColumn(columnGroupbyColumn, tempValue);
443
443
  }
444
444
  var groupLabel = _this2.getLabel(columnGroupbyColumn, columnGroupbyColumnName, item, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity);
@@ -564,7 +564,7 @@ var BasicChartCalculator = /*#__PURE__*/function (_BaseCalculator) {
564
564
  label = item[groupName];
565
565
  } else {
566
566
  var currentGroupLabel = item[groupColumn.key];
567
- label = StatUtils.getGroupLabel(currentGroupLabel, {}, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
567
+ label = StatUtils.getGroupLabel(currentGroupLabel, item, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
568
568
  label = getFormattedLabel(groupColumn, label, this.value.collaborators);
569
569
  }
570
570
  return label;
@@ -310,7 +310,7 @@ var CombinationCalculator = /*#__PURE__*/function (_BaseCalculator) {
310
310
  label = item[groupName];
311
311
  } else {
312
312
  var currentGroupLabel = item[groupColumn.key];
313
- label = StatUtils.getGroupLabel(currentGroupLabel, {}, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
313
+ label = StatUtils.getGroupLabel(currentGroupLabel, item, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
314
314
  label = getFormattedLabel(groupColumn, label);
315
315
  }
316
316
  return label;
@@ -147,7 +147,7 @@ var CompareBarCalculator = /*#__PURE__*/function (_BaseCalculator) {
147
147
  valueKey = isAdvanced ? "".concat(method, "(").concat(summaryColumnName, ")") : "".concat(method, "(").concat(selectedColumn.name, ")");
148
148
  result.data.results.forEach(function (item) {
149
149
  var name = item[groupName];
150
- var label = StatUtils.getGroupLabel(name, {}, selectedColumn, x_axis_date_granularity, '', _this.value);
150
+ var label = StatUtils.getGroupLabel(name, item, selectedColumn, x_axis_date_granularity, '', _this.value);
151
151
  var value = item[valueKey];
152
152
  if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
153
153
  var currentValue = dateRangeResult.get(label);
@@ -150,7 +150,7 @@ var CompletenessCalculator = /*#__PURE__*/function (_BaseCalculator) {
150
150
  var name = item[selectedColumn.key];
151
151
  var label;
152
152
  if (name || Number.isFinite(name)) {
153
- label = StatUtils.getGroupLabel(name, {}, selectedColumn, '', '', _this.value);
153
+ label = StatUtils.getGroupLabel(name, item, selectedColumn, '', '', _this.value);
154
154
  if (isColumnDataAsAnArray) {
155
155
  label = label[0];
156
156
  }
@@ -226,7 +226,7 @@ var CompletenessCalculator = /*#__PURE__*/function (_BaseCalculator) {
226
226
 
227
227
  // get and format name
228
228
  if (name || Number.isFinite(name)) {
229
- label = StatUtils.getGroupLabel(name, {}, selectedColumn, '', '', _this.value);
229
+ label = StatUtils.getGroupLabel(name, item, selectedColumn, '', '', _this.value);
230
230
  if (isColumnDataAsAnArray) {
231
231
  label = label[0];
232
232
  }
@@ -236,7 +236,7 @@ var CompletenessCalculator = /*#__PURE__*/function (_BaseCalculator) {
236
236
  // get and format group name
237
237
  if (!isTimeGroupColumn) {
238
238
  groupLabel = item[groupColumn.key];
239
- groupLabel = StatUtils.getGroupLabel(groupLabel, {}, groupColumn, '', '', _this.value);
239
+ groupLabel = StatUtils.getGroupLabel(groupLabel, item, groupColumn, '', '', _this.value);
240
240
  if (groupLabel && isGroupColumnDataAsAnArray) {
241
241
  groupLabel = groupLabel[0];
242
242
  }
@@ -127,7 +127,7 @@ var MirrorCalculator = /*#__PURE__*/function (_BaseCalculator) {
127
127
  _context2.next = 22;
128
128
  break;
129
129
  case 21:
130
- sqlString = "select `".concat(columnName, "`, `").concat(groupColumnName, "`, ").concat(method, "(").concat(columnName, ") from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by `").concat(columnName, "`, `").concat(groupColumnName, "` limit 5000");
130
+ sqlString = "select `".concat(columnName, "`, `").concat(groupColumnName, "`, ").concat(method, "(`").concat(columnName, "`) from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by `").concat(columnName, "`, `").concat(groupColumnName, "` limit 5000");
131
131
  case 22:
132
132
  _context2.next = 24;
133
133
  return this.sqlQuery(sqlString);
@@ -152,7 +152,7 @@ var MirrorCalculator = /*#__PURE__*/function (_BaseCalculator) {
152
152
  groupData0 = groupData[0] || {};
153
153
  groupData1 = groupData[1] || {};
154
154
  data.results.forEach(function (item) {
155
- var label = StatUtils.getGroupLabel(item[column], {}, selectedColumn, '', '', _this.value);
155
+ var label = StatUtils.getGroupLabel(item[column], item, selectedColumn, '', '', _this.value);
156
156
  var groupValue = item[group_column];
157
157
  var equal2GroupData0 = groupData0.id === groupValue;
158
158
  var equal2GroupData1 = groupData1.id === groupValue;
@@ -369,7 +369,8 @@ var PivotTableCalculator = /*#__PURE__*/function (_BaseCalculator) {
369
369
  var groupbyColumn = columnMap.groupbyColumn;
370
370
  var summary_type = chart.summary_type,
371
371
  groupby_geolocation_granularity = chart.groupby_geolocation_granularity,
372
- groupby_date_granularity = chart.groupby_date_granularity;
372
+ groupby_date_granularity = chart.groupby_date_granularity,
373
+ groupby_include_empty_cells = chart.groupby_include_empty_cells;
373
374
  var pivot_columns = [];
374
375
  var pivot_rows = [];
375
376
  var isCount = summary_type === SUMMARY_TYPE.COUNT;
@@ -378,11 +379,14 @@ var PivotTableCalculator = /*#__PURE__*/function (_BaseCalculator) {
378
379
  sqlSummaryColumnKey = statisticSQLMap.sqlSummaryColumnKey;
379
380
  var _allTotal = 0;
380
381
  sqlRows.forEach(function (row) {
381
- var total = row[sqlSummaryColumnKey] || 0;
382
- _allTotal += total;
383
382
  var originalLabel = _this3.getOriginalLabel(groupbyColumn, _sqlGroupbyColumnKey, row, groupby_geolocation_granularity, groupby_date_granularity);
384
383
  var name = _this3.getLabel(groupbyColumn, originalLabel);
385
384
  var original_name = _this3.getOriginalName(groupbyColumn, originalLabel);
385
+ if (!groupby_include_empty_cells && !name) {
386
+ return;
387
+ }
388
+ var total = row[sqlSummaryColumnKey] || 0;
389
+ _allTotal += total;
386
390
  pivot_rows.push({
387
391
  name: name,
388
392
  original_name: original_name,
@@ -653,7 +657,7 @@ var PivotTableCalculator = /*#__PURE__*/function (_BaseCalculator) {
653
657
  return statRow[groupName];
654
658
  }
655
659
  var currentGroupLabel = statRow[groupColumn.key];
656
- return StatUtils.getGroupLabel(currentGroupLabel, {}, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
660
+ return StatUtils.getGroupLabel(currentGroupLabel, statRow, groupColumn, groupby_date_granularity, groupby_geolocation_granularity, this.value);
657
661
  }
658
662
  }, {
659
663
  key: "getOriginalName",
@@ -663,7 +667,7 @@ var PivotTableCalculator = /*#__PURE__*/function (_BaseCalculator) {
663
667
  return originalLabel;
664
668
  }
665
669
  var columnType = groupColumn.type;
666
- if (columnType === CellType.MULTIPLE_SELECT || columnType === CellType.COLLABORATOR || columnType === CellType.LINK) {
670
+ if (columnType === CellType.MULTIPLE_SELECT || columnType === CellType.COLLABORATOR) {
667
671
  return Array.isArray(originalLabel) ? originalLabel[0] : null;
668
672
  }
669
673
  return originalLabel;
@@ -141,7 +141,7 @@ var ScatterCalculator = /*#__PURE__*/function (_BaseCalculator) {
141
141
  key: "getColumnValue",
142
142
  value: function getColumnValue(data, column) {
143
143
  var tempValue = data[column.key];
144
- var value = StatUtils.getGroupLabel(tempValue, {}, column, DATE_GRANULARITY.DAY, '', this.value);
144
+ var value = StatUtils.getGroupLabel(tempValue, data, column, DATE_GRANULARITY.DAY, '', this.value);
145
145
  return getFormattedLabel(column, value, this.value.collaborators);
146
146
  }
147
147
  }]);
@@ -114,3 +114,7 @@
114
114
  .statistic-records-dialog .statistic-records-container .records-list .records-container {
115
115
  height: auto;
116
116
  }
117
+
118
+ .statistic-records-dialog .row-card-item-content .grid-cell-type-button .grid-cell-type-button-inner {
119
+ justify-content: flex-start;
120
+ }
@@ -1,19 +1,19 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
6
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
7
  import React, { Fragment } from 'react';
7
8
  import intl from 'react-intl-universal';
8
9
  import { Modal, ModalBody } from 'reactstrap';
9
- import { CellType, Views } from 'dtable-store';
10
+ import { Views } from 'dtable-store';
10
11
  import dtableDbAPI from '../../../api/dtable-db-api';
11
12
  import { DtableSearchInput, Loading } from '../../index';
12
13
  import { searchRows } from '../../../utils';
13
14
  import { getSqlString } from '../../../utils/sql-utils';
14
15
  import { CommonEventTypes } from '../../../constants';
15
16
  import './index.css';
16
- export var UNSHOWN_COLUMN_TYPES = [CellType.LINK, CellType.LONG_TEXT, CellType.FORMULA, CellType.LINK_FORMULA];
17
17
  var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
18
18
  _inherits(StatisticRecordDialog, _React$Component);
19
19
  var _super = _createSuper(StatisticRecordDialog);
@@ -37,6 +37,8 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
37
37
  _this.table = getTableById(table_id);
38
38
  _this.view = Views.getViewById(_this.table.views, view_id);
39
39
  _this.isArchiveView = Views.isArchiveView(_this.view);
40
+ _this.unShowColumnKeyList = _this.getUnShowColumnKeyList(_this.view);
41
+ _this.renderedColumns = _this.getRenderedColumns(_this.table);
40
42
  if (_this.isArchiveView || !records) {
41
43
  var sqlString = getSqlString(chart, statisticRecord, {
42
44
  isColumn: isColumn,
@@ -60,6 +62,7 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
60
62
  drilledRows.forEach(function (row) {
61
63
  idRowMap[row._id] = row;
62
64
  });
65
+ _this.initComputedProperties(drilledRows);
63
66
  _this.setState({
64
67
  loading: false,
65
68
  title: name,
@@ -68,6 +71,25 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
68
71
  searchedRowsIds: searchedRowsIds
69
72
  });
70
73
  };
74
+ _this.initComputedProperties = function (drilledRows) {
75
+ if (_this.isArchiveView) {
76
+ var formulaColumns = Views.getFormulaColumnsContainLinks(_this.table);
77
+ if (formulaColumns.length === 0) return {};
78
+ var _formulaRows = {};
79
+ drilledRows.forEach(function (row) {
80
+ var rowId = row._id;
81
+ _formulaRows[rowId] = {};
82
+ formulaColumns.forEach(function (column) {
83
+ return _formulaRows[rowId][column.key] = row[column.key];
84
+ });
85
+ });
86
+ _this.formulaRows = _formulaRows;
87
+ return;
88
+ }
89
+ var _this$getTableViewFor = _this.getTableViewFormulaRows(),
90
+ formulaRows = _this$getTableViewFor.formulaRows;
91
+ _this.formulaRows = formulaRows;
92
+ };
71
93
  _this.onSearch = function (searchVal) {
72
94
  var rows = _this.state.rows;
73
95
  var searchedRowsIds = _this.getSearchedRows(rows, searchVal);
@@ -176,22 +198,49 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
176
198
  searchedRowsIds: updatedSearchedRowsIds
177
199
  });
178
200
  };
201
+ _this.getUnShowColumnKeyList = function (view) {
202
+ var firstColumnKey = '0000';
203
+ var _view$hidden_columns = view.hidden_columns,
204
+ hidden_columns = _view$hidden_columns === void 0 ? [] : _view$hidden_columns;
205
+ return [firstColumnKey].concat(_toConsumableArray(hidden_columns));
206
+ };
207
+ _this.getRenderedColumns = function (table) {
208
+ var columns = table.columns;
209
+ return columns.filter(function (column) {
210
+ return !_this.unShowColumnKeyList.includes(column.key);
211
+ });
212
+ };
213
+ _this.getTableViewFormulaRows = function () {
214
+ var _assertThisInitialize = _assertThisInitialized(_this),
215
+ table = _assertThisInitialize.table,
216
+ view = _assertThisInitialize.view;
217
+ var value = _this.props.getValue();
218
+ if (view.formula_rows && Object.keys(view.formula_rows).length > 0) {
219
+ return {
220
+ formulaRows: view.formula_rows
221
+ };
222
+ }
223
+ Views.cacheFormulaResults(table.rows, {
224
+ targetViewId: view._id,
225
+ table: table,
226
+ value: value
227
+ });
228
+ return {
229
+ formulaRows: view.formula_rows
230
+ };
231
+ };
179
232
  _this.renderRowsCards = function () {
180
233
  var searchedRowsIds = _this.state.searchedRowsIds;
181
234
  var searchedRows = _this.getRowsByIds(searchedRowsIds);
182
235
  if (searchedRows.length === 0) return null;
183
- var unShowColumnKeyList = ['0000'];
184
- var allColumns = _this.table.columns;
185
- var renderedColumns = allColumns.filter(function (column) {
186
- return !unShowColumnKeyList.includes(column.key) && !UNSHOWN_COLUMN_TYPES.includes(column.type);
187
- });
188
236
  if (!window.app || !window.app.renderRowsCards) return null;
189
237
  return window.app.renderRowsCards({
190
238
  table: _this.table,
191
- renderedColumns: renderedColumns,
192
- unShowColumnKeyList: unShowColumnKeyList,
239
+ renderedColumns: _this.renderedColumns,
240
+ unShowColumnKeyList: _this.unShowColumnKeyList,
193
241
  isShowRowCardHeader: true,
194
- columns: allColumns,
242
+ formulaRows: _this.formulaRows,
243
+ columns: _this.renderedColumns,
195
244
  rows: searchedRows,
196
245
  rowCardType: 'statistic'
197
246
  });
@@ -208,6 +257,9 @@ var StatisticRecordDialog = /*#__PURE__*/function (_React$Component) {
208
257
  _this.view = null;
209
258
  _this.isArchiveView = false;
210
259
  _this.valueChanged = false;
260
+ _this.renderedColumns = [];
261
+ _this.formulaRows = null;
262
+ _this.unShowColumnKeyList = null;
211
263
  return _this;
212
264
  }
213
265
  _createClass(StatisticRecordDialog, [{
package/es/custom-g2.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // register theme
2
2
  import * as CanvasEngine from '@antv/g-canvas/esm/index';
3
+ // import * as SvgEngine from '@antv/g-svg/esm/index';
3
4
  import Area from '@antv/g2/esm/geometry/area';
4
5
  import Edge from '@antv/g2/esm/geometry/edge';
5
6
  import HeatMap from '@antv/g2/esm/geometry/heatmap';
@@ -96,6 +97,7 @@ export { getRectWithCornerRadius } from '@antv/g2/esm/geometry/shape/interval/ut
96
97
 
97
98
  // register G renderer
98
99
  registerEngine('canvas', CanvasEngine);
100
+ // registerEngine('svg', SvgEngine);
99
101
 
100
102
  // register internal G2 geometry
101
103
  registerGeometry('Polygon', Polygon);
package/es/dashboard.js CHANGED
@@ -378,6 +378,9 @@ var DashBoard = /*#__PURE__*/function (_Component) {
378
378
  _this.getViews = function (table) {
379
379
  return table.views;
380
380
  };
381
+ _this.getValue = function () {
382
+ return _this.value;
383
+ };
381
384
  _this.isTableReadOnly = function () {
382
385
  if (window.dtable.modulePermission) {
383
386
  return window.dtable.modulePermission.isTableReadOnly;
@@ -484,6 +487,7 @@ var DashBoard = /*#__PURE__*/function (_Component) {
484
487
  getTableById: this.getTableById,
485
488
  getTables: this.getTables,
486
489
  getViews: this.getViews,
490
+ getValue: this.getValue,
487
491
  queryMapJson: this.queryMapJson,
488
492
  getInitChart: this.getInitChart,
489
493
  getConvertedChart: this.getConvertedChart,
@@ -145,6 +145,7 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
145
145
  value: function render() {
146
146
  var _this$props4 = this.props,
147
147
  getTableById = _this$props4.getTableById,
148
+ getValue = _this$props4.getValue,
148
149
  isTableReadOnly = _this$props4.isTableReadOnly,
149
150
  dtableChangedTime = _this$props4.dtableChangedTime,
150
151
  colorThemeName = _this$props4.colorThemeName,
@@ -271,6 +272,7 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
271
272
  eventBus: this.props.eventBus,
272
273
  chartRecordsParams: chartRecordsParams,
273
274
  getTableById: getTableById,
275
+ getValue: getValue,
274
276
  toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
275
277
  }));
276
278
  }
@@ -34,10 +34,6 @@ var Map = /*#__PURE__*/function (_BaseChart) {
34
34
  isCalculatingData: false
35
35
  });
36
36
  _this.updateStatisticData(_this.fixData(statData));
37
- if (_this.props.isPreview) {
38
- var canvasSize = _this.getCanvasSize();
39
- _this.chart.changeSize(canvasSize.w, canvasSize.h);
40
- }
41
37
  });
42
38
  };
43
39
  _this.rerenderChart = function () {
@@ -246,22 +242,24 @@ var Map = /*#__PURE__*/function (_BaseChart) {
246
242
  _this.statisticView.interaction('element-active');
247
243
  _this.statisticView.render();
248
244
  };
249
- _this.getCanvasSize = function () {
245
+ _this.getSize = function () {
250
246
  var statItem = _this.props.statItem;
251
247
  var map_level = statItem.map_level,
252
248
  map_location = statItem.map_location;
253
- var maxWidth = _this.container.clientWidth;
254
- var maxHeight = _this.container.clientHeight;
249
+ var containerWidth = _this.container.clientWidth - 40; // 40: padding
250
+ var containerHeight = _this.container.clientHeight - 40;
255
251
  var _getRegionScaleOffset = getRegionScaleOffsets(map_level, map_location),
256
252
  scale_w = _getRegionScaleOffset.scale_w,
257
253
  scale_h = _getRegionScaleOffset.scale_h;
258
- var h = maxHeight;
254
+ var h = containerHeight;
259
255
  var w = h * (scale_w / scale_h);
260
- if (w > maxWidth) {
261
- w = maxWidth;
256
+ if (w > containerWidth) {
257
+ w = containerWidth;
262
258
  h = w * (scale_h / scale_w);
263
259
  }
264
260
  return {
261
+ containerWidth: containerWidth,
262
+ containerHeight: containerHeight,
265
263
  w: w,
266
264
  h: h
267
265
  };
@@ -269,13 +267,19 @@ var Map = /*#__PURE__*/function (_BaseChart) {
269
267
  _this.initStatisticContext = function (geolocation) {
270
268
  _this.mapData = geolocation;
271
269
  if (!_this.container) return;
270
+
272
271
  // create chart
273
- var canvasSize = _this.getCanvasSize();
272
+ var _this$getSize = _this.getSize(),
273
+ containerWidth = _this$getSize.containerWidth,
274
+ containerHeight = _this$getSize.containerHeight,
275
+ mapWidth = _this$getSize.w;
276
+ var horizontalPadding = (containerWidth - mapWidth) / 4;
277
+ var leftPadding = horizontalPadding < 20 ? 20 : horizontalPadding;
274
278
  _this.chart = new Chart({
275
279
  container: _this.container,
276
- width: canvasSize.w,
277
- height: canvasSize.h,
278
- padding: [20, 20]
280
+ width: containerWidth,
281
+ height: containerHeight,
282
+ padding: [0, horizontalPadding, 0, leftPadding]
279
283
  });
280
284
  _this.chart.on('element:click', function (e) {
281
285
  var statItem = _this.props.statItem;
@@ -401,10 +405,6 @@ var Map = /*#__PURE__*/function (_BaseChart) {
401
405
  }
402
406
  } else {
403
407
  this.updateStatisticData(this.fixData(this.calculateData));
404
- if (this.props.isPreview) {
405
- var canvasSize = this.getCanvasSize();
406
- this.chart.changeSize(canvasSize.w, canvasSize.h);
407
- }
408
408
  }
409
409
  }
410
410
  }, {
@@ -424,7 +424,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
424
424
  ref: function ref(_ref) {
425
425
  return _this4.container = _ref;
426
426
  },
427
- className: "statistic-chart-container d-flex justify-content-around align-items-center w-100 h-100"
427
+ className: "statistic-chart-container map d-flex justify-content-around align-items-center w-100 h-100"
428
428
  }));
429
429
  }
430
430
  }]);
@@ -99,9 +99,12 @@ var PivotTableDisplayName = /*#__PURE__*/function (_React$Component) {
99
99
  }
100
100
  case CellType.LINK:
101
101
  {
102
- var _displayValue = getClientFormulaDisplayString([value], data, {
102
+ var _displayValue = getClientFormulaDisplayString(Array.isArray(value) ? value : [value], data, {
103
103
  collaborators: collaborators
104
104
  }) || null;
105
+ if (!_displayValue) {
106
+ break;
107
+ }
105
108
  displayName = /*#__PURE__*/React.createElement("div", {
106
109
  title: _displayValue,
107
110
  "aria-label": _displayValue
@@ -177,7 +180,10 @@ var PivotTableDisplayName = /*#__PURE__*/function (_React$Component) {
177
180
  var _this$props2 = this.props,
178
181
  value = _this$props2.value,
179
182
  column = _this$props2.column;
180
- var displayName = value ? this.getDisplayName(value, column) : /*#__PURE__*/React.createElement("div", null, "(".concat(intl.get(EMPTY_NAME), ")"));
183
+ var displayName = value && this.getDisplayName(value, column);
184
+ if (!displayName) {
185
+ return /*#__PURE__*/React.createElement("div", null, "(".concat(intl.get(EMPTY_NAME), ")"));
186
+ }
181
187
  return /*#__PURE__*/React.createElement(Fragment, null, displayName);
182
188
  }
183
189
  }]);
@@ -20,6 +20,11 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
20
20
  var _this;
21
21
  _classCallCheck(this, WorldMap);
22
22
  _this = _super.call(this, props);
23
+ _this.rerenderChart = function () {
24
+ if (!_this.chart) return;
25
+ _this.chart.destroy();
26
+ _this.initStatisticContext(_this.geoData);
27
+ };
23
28
  _this.fixData = function (statisticData) {
24
29
  if (!statisticData) return [];
25
30
  var statisticNewData = [];
@@ -225,16 +230,18 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
225
230
  }
226
231
  _this.chart.render();
227
232
  };
228
- _this.getCanvasSize = function () {
229
- var maxWidth = _this.container.clientWidth;
230
- var maxHeight = _this.container.clientHeight;
231
- var h = maxHeight;
233
+ _this.getSize = function () {
234
+ var containerWidth = _this.container.clientWidth - 40; // 40: padding
235
+ var containerHeight = _this.container.clientHeight - 40;
236
+ var h = containerHeight;
232
237
  var w = h * (WIDTH / HEIGHT);
233
- if (w > maxWidth) {
234
- w = maxWidth;
238
+ if (w > containerWidth) {
239
+ w = containerWidth;
235
240
  h = w * (HEIGHT / WIDTH);
236
241
  }
237
242
  return {
243
+ containerWidth: containerWidth,
244
+ containerHeight: containerHeight,
238
245
  w: w,
239
246
  h: h
240
247
  };
@@ -246,13 +253,19 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
246
253
  _this.countryMap.set(item.properties.name_cn, item.properties.name);
247
254
  });
248
255
  if (!_this.container) return;
256
+
249
257
  // create chart
250
- var canvasSize = _this.getCanvasSize();
258
+ var _this$getSize = _this.getSize(),
259
+ containerWidth = _this$getSize.containerWidth,
260
+ containerHeight = _this$getSize.containerHeight,
261
+ mapWidth = _this$getSize.w;
262
+ var horizontalPadding = (containerWidth - mapWidth) / 4;
263
+ var leftPadding = horizontalPadding < 20 ? 20 : horizontalPadding;
251
264
  _this.chart = new Chart({
252
265
  container: _this.container,
253
- width: canvasSize.w,
254
- height: canvasSize.h,
255
- padding: [20, 20]
266
+ width: containerWidth,
267
+ height: containerHeight,
268
+ padding: [0, horizontalPadding, 0, leftPadding]
256
269
  });
257
270
  _this.chart.on('element:click', function (e) {
258
271
  var statItem = _this.props.statItem;
@@ -371,28 +384,20 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
371
384
  isCalculatingData: true
372
385
  });
373
386
  if (this.container) {
374
- if (this.chart) {
375
- this.chart.destroy();
376
- this.initStatisticContext(this.geoData);
377
- }
387
+ this.rerenderChart();
378
388
  chartCalculator.calculate(statItem).then(function (calculation) {
379
389
  _this3.setState({
380
390
  isCalculatingData: false
381
391
  });
382
392
  _this3.calculateData = calculation;
383
393
  _this3.updateStatisticData(_this3.fixData(calculation));
384
- if (_this3.props.isPreview) {
385
- var canvasSize = _this3.getCanvasSize();
386
- _this3.chart.changeSize(canvasSize.w, canvasSize.h);
387
- }
388
394
  });
389
395
  }
390
396
  } else {
391
- this.updateStatisticData(this.fixData(this.calculateData));
392
397
  if (this.props.isPreview) {
393
- var canvasSize = this.getCanvasSize();
394
- this.chart.changeSize(canvasSize.w, canvasSize.h);
398
+ this.rerenderChart();
395
399
  }
400
+ this.updateStatisticData(this.fixData(this.calculateData));
396
401
  }
397
402
  }
398
403
  }, {
@@ -412,7 +417,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
412
417
  ref: function ref(_ref) {
413
418
  return _this4.container = _ref;
414
419
  },
415
- className: "statistic-chart-container d-flex justify-content-around align-items-center w-100 h-100"
420
+ className: "statistic-chart-container map d-flex justify-content-around align-items-center w-100 h-100"
416
421
  }));
417
422
  }
418
423
  }]);
@@ -1,4 +1,4 @@
1
- import { CellType, isDateColumn, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES } from 'dtable-store';
1
+ import { CellType, isDateColumn, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES, Views } from 'dtable-store';
2
2
  import { MIRROR_COLUMN_LIST } from '../constants';
3
3
  export function getColorFromSingleSelectColumn(column, target) {
4
4
  var columnType = column.type,
@@ -220,13 +220,18 @@ var getPieColor = function getPieColor(color_option, column, index, data, curren
220
220
  return selectedItem.color || '#dbdbdb';
221
221
  }
222
222
  } else {
223
- var newIndex = String(index).at(-1);
224
- return colors[newIndex];
223
+ var sIndex = String(index);
224
+ var colorIndex = sIndex.charAt(sIndex.length - 1);
225
+ return colors[colorIndex];
225
226
  }
226
227
  };
227
228
  export function formatPieChartData(data, statItem, table, currentTheme) {
228
229
  var groupby_column_key = statItem.groupby_column_key,
229
- color_option = statItem.color_option;
230
+ color_option = statItem.color_option,
231
+ summary_column_key = statItem.summary_column_key,
232
+ summaryMethod = statItem.summary_method,
233
+ summary_type = statItem.summary_type;
234
+ var isAdvanced = summary_type === 'advanced';
230
235
  var column = TableUtils.getTableColumnByKey(table, groupby_column_key);
231
236
  var sum = data.reduce(function (total, currentValue) {
232
237
  return total += currentValue.value;
@@ -256,6 +261,11 @@ export function formatPieChartData(data, statItem, table, currentTheme) {
256
261
  var filteredSum = filteredItems.reduce(function (total, currentValue) {
257
262
  return total += currentValue.value;
258
263
  }, 0);
264
+ var formattedValueSum = filteredSum;
265
+ if (isAdvanced) {
266
+ var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
267
+ formattedValueSum = StatUtils.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
268
+ }
259
269
  var original_name_list = [];
260
270
  var name_list = [];
261
271
  var rows = [];
@@ -276,6 +286,7 @@ export function formatPieChartData(data, statItem, table, currentTheme) {
276
286
  original_name_list: original_name_list,
277
287
  name: intl.get('Others'),
278
288
  value: filteredSum,
289
+ formatted_value: formattedValueSum,
279
290
  color: '#dbdbdb',
280
291
  original_name: 'Others',
281
292
  percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%'
@@ -64,7 +64,7 @@ export var getFormattedLabel = function getFormattedLabel(column, name, collabor
64
64
  }
65
65
  }
66
66
  } else if (columnType === CellType.LINK) {
67
- return getClientFormulaDisplayString([name], columnData, {
67
+ return getClientFormulaDisplayString(Array.isArray(name) ? name : [name], columnData, {
68
68
  collaborators: collaborators
69
69
  });
70
70
  } else if (columnType === CellType.CHECKBOX) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
@@ -12,7 +12,7 @@
12
12
  "@seafile/seafile-calendar": "0.0.24",
13
13
  "comlink": "^4.3.1",
14
14
  "dayjs": "1.10.7",
15
- "dtable-store": "4.1.2",
15
+ "dtable-store": "4.1.5",
16
16
  "dtable-web-api": "4.0.11",
17
17
  "glamor": "^2.20.40",
18
18
  "html2canvas": "^1.4.1",