dtable-statistic 4.0.6 → 4.0.8

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.
Files changed (67) hide show
  1. package/es/assets/css/dashboard.css +22 -0
  2. package/es/calculator/basic-chart-calculator.js +27 -18
  3. package/es/calculator/combination-calculator.js +34 -9
  4. package/es/calculator/compare-bar-calculator.js +37 -30
  5. package/es/calculator/heat-map-calculator.js +25 -14
  6. package/es/calculator/map-calculator.js +25 -14
  7. package/es/calculator/mirror-calculator.js +29 -14
  8. package/es/calculator/pivot-table-calculator.js +132 -76
  9. package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
  10. package/es/calculator/workers/combination-calculator-worker.js +20 -5
  11. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
  12. package/es/calculator/workers/mirror-calculator-worker.js +15 -6
  13. package/es/calculator/workers/pivot-table-calculator-worker.js +97 -44
  14. package/es/calculator/world-map-calculator.js +25 -14
  15. package/es/components/dialog/enlarged-chart-dialog.js +2 -2
  16. package/es/components/dialog/statistic-record-dialog/index.css +2 -0
  17. package/es/components/dialog/statistic-record-dialog/index.js +80 -52
  18. package/es/constants/index.js +30 -29
  19. package/es/dashboard.js +57 -43
  20. package/es/desktop-dashboard.js +21 -56
  21. package/es/index.js +34 -2
  22. package/es/locale/lang/de.js +7 -3
  23. package/es/locale/lang/en.js +5 -1
  24. package/es/locale/lang/fr.js +7 -3
  25. package/es/locale/lang/zh_CN.js +5 -1
  26. package/es/mobile-dashboard.js +5 -5
  27. package/es/model/horizontal-bar-group.js +2 -0
  28. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
  29. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  30. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
  31. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
  32. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
  33. package/es/stat-list/chart-preview.js +3 -4
  34. package/es/stat-list/index.js +10 -4
  35. package/es/stat-view/area-chart.js +177 -162
  36. package/es/stat-view/bar-chart.js +221 -222
  37. package/es/stat-view/base-chart.js +79 -7
  38. package/es/stat-view/basic-number-card.js +11 -19
  39. package/es/stat-view/combination-chart.js +100 -83
  40. package/es/stat-view/compare-chart.js +133 -144
  41. package/es/stat-view/completeness-chart.js +108 -102
  42. package/es/stat-view/custom-bar.js +79 -99
  43. package/es/stat-view/dashboard-chart.js +57 -57
  44. package/es/stat-view/heat-map.js +13 -32
  45. package/es/stat-view/horizontal-bar-chart.js +200 -230
  46. package/es/stat-view/index.js +2 -2
  47. package/es/stat-view/line-chart.js +162 -158
  48. package/es/stat-view/map.js +26 -40
  49. package/es/stat-view/mirror.js +88 -94
  50. package/es/stat-view/pie-chart.js +11 -39
  51. package/es/stat-view/pivot-table/index.js +4 -16
  52. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +36 -23
  53. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +11 -5
  54. package/es/stat-view/pivot-table/pivot-table-display-name.js +206 -0
  55. package/es/stat-view/pivot-table/two-dimension-table.js +104 -60
  56. package/es/stat-view/ring-chart.js +24 -42
  57. package/es/stat-view/scatter-chart.js +4 -21
  58. package/es/stat-view/treemap-chart.js +3 -12
  59. package/es/stat-view/trend-chart.js +6 -17
  60. package/es/stat-view/world-map.js +39 -50
  61. package/es/tabs/tab.js +2 -1
  62. package/es/utils/collaborator.js +9 -0
  63. package/es/utils/common-utils.js +24 -6
  64. package/es/utils/index.js +1 -1
  65. package/es/utils/sql-utils.js +10 -9
  66. package/es/utils/stat-utils.js +8 -5
  67. package/package.json +1 -1
@@ -5,17 +5,14 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import intl from 'react-intl-universal';
8
- import { TableUtils, getNumberDisplayString } from 'dtable-store';
8
+ import { TableUtils } from 'dtable-store';
9
9
  import BaseChart from './base-chart';
10
10
  import { Chart } from '../custom-g2';
11
- import { Loading } from '../components';
12
- import { formatPieChartData, getCurrentTheme, getLabelFontSize } from '../utils/common-utils';
13
- import { DEFAULT_ANNOTATION_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_FORMATS, LABEL_POSITIONS, NO_STATISTIC_RESULTS, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, TITLE_TOTAL } from '../constants';
11
+ import { formatPieChartData, getCurrentTheme } from '../utils/common-utils';
12
+ import { DEFAULT_ANNOTATION_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_FORMATS, LABEL_POSITIONS, SUMMARY_TYPE, TITLE_TOTAL } from '../constants';
14
13
  import chartStyles from '../assets/css/statistic-chart.module.css';
15
14
  var propTypes = {
16
15
  isPreview: PropTypes.bool,
17
- isEnlarge: PropTypes.bool,
18
- theme: PropTypes.string,
19
16
  colorThemeName: PropTypes.string,
20
17
  statItem: PropTypes.object,
21
18
  chartCalculator: PropTypes.object,
@@ -61,14 +58,11 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
61
58
  var _this$props2 = _this.props,
62
59
  getTableById = _this$props2.getTableById,
63
60
  statItem = _this$props2.statItem,
64
- theme = _this$props2.theme,
65
- isEnlarge = _this$props2.isEnlarge,
66
- isPreview = _this$props2.isPreview,
67
61
  colorThemeName = _this$props2.colorThemeName;
68
- var currentTheme = getCurrentTheme(colorThemeName);
69
62
  var summaryColumn = null;
70
- var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
63
+ var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
71
64
  var summary_type = statItem.summary_type,
65
+ summary_method = statItem.summary_method,
72
66
  summary_column_key = statItem.summary_column_key,
73
67
  table_id = statItem.table_id,
74
68
  show_legend = statItem.show_legend,
@@ -79,16 +73,14 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
79
73
  var table = getTableById(table_id);
80
74
  if (summary_type !== SUMMARY_TYPE.COUNT) {
81
75
  summaryColumn = summary_column_key && TableUtils.getTableColumnByKey(table, summary_column_key);
82
- columnData = summaryColumn && summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
76
+ summaryColumnData = summaryColumn && summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
83
77
  }
84
78
  _this.chart.coordinate('theta', {
85
79
  radius: isCreating ? 0.75 : 0.95,
86
80
  innerRadius: isCreating ? 0.6 : 0.7
87
81
  });
88
- var themeColors = STAT_ITEM_THEME_COLORS.light;
89
- if (theme === 'dark' && !isEnlarge && isPreview) {
90
- themeColors = STAT_ITEM_THEME_COLORS.dark;
91
- }
82
+ var currentTheme = getCurrentTheme(colorThemeName);
83
+ var themeColors = _this.getThemeColors();
92
84
  var newData = formatPieChartData(data, statItem, table, currentTheme);
93
85
  _this.chart.data(newData, {
94
86
  'name': {
@@ -153,10 +145,9 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
153
145
  nice: false
154
146
  }
155
147
  });
156
- _this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', function (value, percent) {
157
- var displayedValue = getNumberDisplayString(value, columnData);
148
+ _this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('formatted_value*percent', function (value, percent) {
158
149
  return {
159
- content: _this.getLabel(displayedValue, percent)
150
+ content: _this.getLabel(value, percent)
160
151
  };
161
152
  }, {
162
153
  offset: !label_position || label_position == LABEL_POSITIONS[0] ? isCreating ? -10 : -2 : undefined,
@@ -166,20 +157,19 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
166
157
  shadowBlur: 2,
167
158
  shadowColor: 'rgba(0, 0, 0, .45)'
168
159
  }
169
- }).tooltip('name*value*percent', function (name, value, percent) {
160
+ }).tooltip('name*formatted_value*percent', function (name, value, percent) {
170
161
  var title = name;
171
162
  if (!name || name === 'undefined') {
172
163
  title = intl.get(EMPTY_NAME);
173
164
  } else if (name === 'Others') {
174
165
  title = intl.get('Others');
175
166
  }
176
- var displayedValue = getNumberDisplayString(value, columnData);
177
167
  return show_percent || display_label ? {
178
168
  name: title,
179
- value: _this.getLabel(displayedValue, percent)
169
+ value: _this.getLabel(value, percent)
180
170
  } : {
181
171
  name: title,
182
- value: displayedValue
172
+ value: value
183
173
  };
184
174
  }).state({
185
175
  active: {
@@ -199,13 +189,13 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
199
189
  if (display_annotation == undefined || display_annotation) {
200
190
  _this.setAnnotation({
201
191
  name: intl.get(TITLE_TOTAL),
202
- value: summaryColumn ? getNumberDisplayString(_this.sum, summaryColumn.data) : _this.sum
192
+ value: summaryColumn ? _this.getNumberDisplayString(_this.sum, summaryColumnData, summary_method) : _this.sum
203
193
  }, themeColors.labelColor);
204
194
  _this.chart.on('interval:mouseenter', function (evt) {
205
- return _this.onEnterRingChart(evt, themeColors.labelColor, summaryColumn);
195
+ return _this.onEnterRingChart(evt, themeColors.labelColor, summaryColumn, summaryColumnData);
206
196
  });
207
197
  _this.chart.on('interval:mouseleave', function (evt) {
208
- return _this.onLeaveRingChart(evt, themeColors.labelColor, summaryColumn);
198
+ return _this.onLeaveRingChart(evt, themeColors.labelColor, summaryColumn, summaryColumnData);
209
199
  });
210
200
  }
211
201
  };
@@ -239,11 +229,6 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
239
229
  }
240
230
  return content;
241
231
  };
242
- _this.getLabelFontSize = function () {
243
- var statItem = _this.props.statItem;
244
- var label_font_size = statItem.label_font_size;
245
- return getLabelFontSize(label_font_size);
246
- };
247
232
  _this.getAnnotationFontSize = function () {
248
233
  var statItem = _this.props.statItem;
249
234
  var annotation_font_size = statItem.annotation_font_size;
@@ -254,7 +239,8 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
254
239
  subFontSize: subFontSize
255
240
  };
256
241
  };
257
- _this.setAnnotation = function (content, fontColor, summaryColumn) {
242
+ _this.setAnnotation = function (content, fontColor, summaryColumn, summaryColumnData) {
243
+ var summary_method = _this.props.statItem.summary_method;
258
244
  var name = content.name;
259
245
  if (!name || name === 'undefined') {
260
246
  name = intl.get(EMPTY_NAME);
@@ -276,7 +262,7 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
276
262
  offsetY: -20
277
263
  }).text({
278
264
  position: ['50%', '50%'],
279
- content: summaryColumn ? getNumberDisplayString(content.value, summaryColumn.data) : content.value,
265
+ content: summaryColumn ? _this.getNumberDisplayString(content.value, summaryColumnData, summary_method) : content.value,
280
266
  style: {
281
267
  fontSize: mainFontSize,
282
268
  fill: fontColor,
@@ -285,18 +271,18 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
285
271
  offsetY: 20
286
272
  });
287
273
  };
288
- _this.onEnterRingChart = function (ev, color, summaryColumn) {
274
+ _this.onEnterRingChart = function (ev, color, summaryColumn, summaryColumnData) {
289
275
  var item = ev.data.data;
290
276
  _this.chart.annotation().clear(true);
291
- _this.setAnnotation(item, color, summaryColumn);
277
+ _this.setAnnotation(item, color, summaryColumn, summaryColumnData);
292
278
  _this.chart.render(true);
293
279
  };
294
- _this.onLeaveRingChart = function (ev, color, summaryColumn) {
280
+ _this.onLeaveRingChart = function (ev, color, summaryColumn, summaryColumnData) {
295
281
  _this.chart.annotation().clear(true);
296
282
  _this.setAnnotation({
297
283
  name: intl.get(TITLE_TOTAL),
298
284
  value: _this.sum
299
- }, color, summaryColumn);
285
+ }, color, summaryColumn, summaryColumnData);
300
286
  _this.chart.render(true);
301
287
  };
302
288
  _this.destroyChart = function () {
@@ -398,11 +384,7 @@ var RingChart = /*#__PURE__*/function (_BaseChart) {
398
384
  var _this$state = this.state,
399
385
  isCalculatingData = _this$state.isCalculatingData,
400
386
  showResultDescription = _this$state.showResultDescription;
401
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
402
- className: 'statistic-chart-loading-container'
403
- }, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
404
- className: 'statistic-chart-text'
405
- }, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
387
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
406
388
  ref: function ref(_ref) {
407
389
  return _this4.container = _ref;
408
390
  },
@@ -10,14 +10,11 @@ import intl from 'react-intl-universal';
10
10
  import { TableUtils } from 'dtable-store';
11
11
  import BaseChart from './base-chart';
12
12
  import { Chart } from '../custom-g2';
13
- import { Loading } from '../components';
14
13
  import { getCurrentTheme } from '../utils/common-utils';
15
- import { EMPTY_NAME, LABEL_CONFIG_CHANGED, STAT_ITEM_THEME_COLORS } from '../constants';
14
+ import { EMPTY_NAME, LABEL_CONFIG_CHANGED } from '../constants';
16
15
  import chartStyles from '../assets/css/statistic-chart.module.css';
17
16
  var propTypes = {
18
17
  isPreview: PropTypes.bool,
19
- isEnlarge: PropTypes.bool,
20
- theme: PropTypes.string,
21
18
  colorThemeName: PropTypes.string,
22
19
  statItem: PropTypes.object,
23
20
  chartCalculator: PropTypes.object,
@@ -127,8 +124,6 @@ var ScatterChart = /*#__PURE__*/function (_BaseChart) {
127
124
  getTableById = _this$props3.getTableById,
128
125
  isPreview = _this$props3.isPreview,
129
126
  statItem = _this$props3.statItem,
130
- isEnlarge = _this$props3.isEnlarge,
131
- theme = _this$props3.theme,
132
127
  colorThemeName = _this$props3.colorThemeName;
133
128
  var currentTheme = getCurrentTheme(colorThemeName);
134
129
  var table_id = statItem.table_id,
@@ -152,10 +147,7 @@ var ScatterChart = /*#__PURE__*/function (_BaseChart) {
152
147
  _this.chart.on('element:click', function (e) {
153
148
  _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
154
149
  });
155
- var themeColors = STAT_ITEM_THEME_COLORS.light;
156
- if (theme === 'dark' && !isEnlarge && isPreview) {
157
- themeColors = STAT_ITEM_THEME_COLORS.dark;
158
- }
150
+ var themeColors = _this.getThemeColors();
159
151
  _this.chart.axis('x_axis', {
160
152
  label: {
161
153
  style: {
@@ -245,10 +237,6 @@ var ScatterChart = /*#__PURE__*/function (_BaseChart) {
245
237
  }
246
238
  if (!_this.chart) return;
247
239
  statItem = newStatItem || statItem;
248
- var _this$props5 = _this.props,
249
- isEnlarge = _this$props5.isEnlarge,
250
- isPreview = _this$props5.isPreview,
251
- theme = _this$props5.theme;
252
240
  var _statItem = statItem,
253
241
  table_id = _statItem.table_id,
254
242
  x_axis_column = _statItem.x_axis_column,
@@ -259,10 +247,7 @@ var ScatterChart = /*#__PURE__*/function (_BaseChart) {
259
247
  x_axis_label_position = _statItem.x_axis_label_position;
260
248
  var table = getTableById(table_id);
261
249
  var autoPadding = _this.chart.autoPadding;
262
- var textColor = '#999999';
263
- if (theme === 'dark' && !isEnlarge && isPreview) {
264
- textColor = '#ffffff';
265
- }
250
+ var textColor = _this.getAxisLabelColor();
266
251
  var xAxisID = "chart-x-axis-label_".concat(statItem._id);
267
252
  var chartContainer = _this.chart.getCanvas().get('container');
268
253
  var xLabel = chartContainer.querySelector("#".concat(xAxisID));
@@ -350,9 +335,7 @@ var ScatterChart = /*#__PURE__*/function (_BaseChart) {
350
335
  if (show_y_axis_label) {
351
336
  style.paddingLeft = 38;
352
337
  }
353
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
354
- className: 'statistic-chart-loading-container'
355
- }, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
338
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
356
339
  ref: function ref(_ref3) {
357
340
  return _this2.container = _ref3;
358
341
  },
@@ -14,7 +14,6 @@ import { getEllipsisText } from '@antv/g2/esm/util/text';
14
14
  import { TableUtils } from 'dtable-store';
15
15
  import BaseChart from './base-chart';
16
16
  import { Chart, registerGeometryLabelLayout } from '../custom-g2';
17
- import { Loading } from '../components';
18
17
  import { formatPieChartData, getCurrentTheme } from '../utils/common-utils';
19
18
  import { EMPTY_NAME, STATISTICS_COUNT_TYPE } from '../constants';
20
19
  import chartStyles from '../assets/css/statistic-chart.module.css';
@@ -215,14 +214,8 @@ var TreemapChart = /*#__PURE__*/function (_BaseChart) {
215
214
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
216
215
  itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{name}<div><div class="tooltip-item">{info}<div></div>',
217
216
  domStyles: {
218
- 'g2-tooltip': {
219
- borderRadius: '2px',
220
- backgroundColor: '#fff',
221
- padding: '10px'
222
- },
223
- 'tooltip-item': {
224
- marginTop: '5px'
225
- }
217
+ 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
218
+ 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
226
219
  }
227
220
  });
228
221
  chart.polygon().position('x*y').color('name', colorSet).tooltip('name*formatted_value*percent', function (name, value, percent) {
@@ -302,9 +295,7 @@ var TreemapChart = /*#__PURE__*/function (_BaseChart) {
302
295
  value: function render() {
303
296
  var _this2 = this;
304
297
  var isCalculatingData = this.state.isCalculatingData;
305
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
306
- className: 'statistic-chart-loading-container'
307
- }, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
298
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
308
299
  ref: function ref(_ref3) {
309
300
  return _this2.container = _ref3;
310
301
  },
@@ -7,15 +7,12 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
7
  import React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import intl from 'react-intl-universal';
10
- import { TableUtils, getNumberDisplayString } from 'dtable-store';
10
+ import { TableUtils } from 'dtable-store';
11
11
  import BaseChart from './base-chart';
12
12
  import { Chart } from '../custom-g2';
13
- import { Loading } from '../components';
14
- import { DATE_GRANULARITY, EMPTY_NAME, STATISTICS_COUNT_TYPE, STAT_ITEM_THEME_COLORS } from '../constants';
13
+ import { DATE_GRANULARITY, EMPTY_NAME, STATISTICS_COUNT_TYPE, SUMMARY_METHOD_MAP } from '../constants';
15
14
  var propTypes = {
16
15
  isPreview: PropTypes.bool,
17
- isEnlarge: PropTypes.bool,
18
- theme: PropTypes.string,
19
16
  statItem: PropTypes.object,
20
17
  chartCalculator: PropTypes.object,
21
18
  getTableById: PropTypes.func
@@ -116,8 +113,6 @@ var BasicNumericCard = /*#__PURE__*/function (_BaseChart) {
116
113
  _this.drawChart = function (data) {
117
114
  var _this$props3 = _this.props,
118
115
  isPreview = _this$props3.isPreview,
119
- isEnlarge = _this$props3.isEnlarge,
120
- theme = _this$props3.theme,
121
116
  statItem = _this$props3.statItem;
122
117
  if (isPreview) {
123
118
  _this.chart = new Chart({
@@ -134,13 +129,10 @@ var BasicNumericCard = /*#__PURE__*/function (_BaseChart) {
134
129
  }
135
130
  var summary_method = statItem.summary_method;
136
131
  var latest = data && data.latest;
137
- var content = summary_method === 'Distinct_values' ? latest : _this.formatData(latest);
132
+ var content = summary_method === SUMMARY_METHOD_MAP.Distinct_values ? latest : _this.formatData(latest);
138
133
  var fontSize = _this.getFontSize(content);
139
134
  var labelFontSize = fontSize - 32;
140
- var themeColors = STAT_ITEM_THEME_COLORS.light;
141
- if (theme === 'dark' && !isEnlarge && isPreview) {
142
- themeColors = STAT_ITEM_THEME_COLORS.dark;
143
- }
135
+ var themeColors = _this.getThemeColors();
144
136
  var labelContent = _this.createLabelContent(data, labelFontSize);
145
137
  _this.chart.annotation().html({
146
138
  position: ['50%', '50%'],
@@ -159,8 +151,7 @@ var BasicNumericCard = /*#__PURE__*/function (_BaseChart) {
159
151
  if (summary_type !== STATISTICS_COUNT_TYPE.COUNT) {
160
152
  var table = getTableById(table_id);
161
153
  var selectedColumn = TableUtils.getTableColumnByKey(table, summary_column);
162
- var formattedContent = getNumberDisplayString(data, selectedColumn.data || {});
163
- return formattedContent;
154
+ return _this.getNumberDisplayString(data, selectedColumn.data || {});
164
155
  }
165
156
  var string = data + '';
166
157
  var isFloat = string.indexOf('.') > 0;
@@ -283,9 +274,7 @@ var BasicNumericCard = /*#__PURE__*/function (_BaseChart) {
283
274
  value: function render() {
284
275
  var _this2 = this;
285
276
  var isCalculatingData = this.state.isCalculatingData;
286
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
287
- className: 'statistic-chart-loading-container'
288
- }, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
277
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
289
278
  ref: function ref(_ref4) {
290
279
  return _this2.container = _ref4;
291
280
  },
@@ -6,11 +6,10 @@ import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import DataSet from '@antv/data-set/lib/index';
8
8
  import intl from 'react-intl-universal';
9
- import { TableUtils, getNumberDisplayString } from 'dtable-store';
9
+ import { TableUtils } from 'dtable-store';
10
10
  import BaseChart from './base-chart';
11
11
  import { Chart } from '../custom-g2';
12
- import { Loading } from '../components';
13
- import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_ITEM_THEME_COLORS, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
12
+ import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
14
13
  var WIDTH = 798;
15
14
  var HEIGHT = 394;
16
15
  var WorldMap = /*#__PURE__*/function (_BaseChart) {
@@ -44,7 +43,8 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
44
43
  name_cn: name_cn,
45
44
  name: name,
46
45
  nameType: nameType,
47
- value: value || 0
46
+ value: value || 0,
47
+ formatted_value: item.formatted_value
48
48
  });
49
49
  if (type === STAT_TYPE.WORLD_MAP_BUBBLE) {
50
50
  sum += item.value;
@@ -60,10 +60,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
60
60
  _this.renderCommonMap = function (data) {
61
61
  var _this$props = _this.props,
62
62
  getTableById = _this$props.getTableById,
63
- statItem = _this$props.statItem,
64
- theme = _this$props.theme,
65
- isEnlarge = _this$props.isEnlarge,
66
- isPreview = _this$props.isPreview;
63
+ statItem = _this$props.statItem;
67
64
  var userDataView = _this.dataSet.getView('statisticViewModel').source(data).transform({
68
65
  geoDataView: _this.dataSet.getView('mapDataModel'),
69
66
  field: 'name',
@@ -74,17 +71,18 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
74
71
  table_id = _this$props$statItem.table_id,
75
72
  data_color = _this$props$statItem.data_color,
76
73
  summary_type = _this$props$statItem.summary_type,
74
+ summary_method = _this$props$statItem.summary_method,
77
75
  summary_column = _this$props$statItem.summary_column;
78
76
  var currentColorOption = COLOR_OPTIONS.filter(function (item) {
79
77
  return item.name == data_color;
80
78
  })[0] || COLOR_OPTIONS[0];
81
79
  var exampleColors = currentColorOption.exampleColors,
82
80
  highlightedBorderColor = currentColorOption.highlightedBorderColor;
83
- var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
81
+ var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
84
82
  if (summary_type === SUMMARY_TYPE.ADVANCED) {
85
83
  var table = getTableById(table_id);
86
84
  var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
87
- columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
85
+ summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
88
86
  }
89
87
  _this.statisticView = _this.chart.createView();
90
88
  _this.statisticView.data(userDataView.rows);
@@ -99,17 +97,14 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
99
97
  stroke: highlightedBorderColor
100
98
  }
101
99
  }
102
- }).tooltip('name*value*color*nameType*name_cn', function (name, value, color, nameType, name_cn) {
100
+ }).tooltip('name*formatted_value*color*nameType*name_cn', function (name, value, color, nameType, name_cn) {
103
101
  return {
104
102
  name: nameType === 'en' ? name : name_cn,
105
- value: getNumberDisplayString(value, columnData),
106
- color: color
103
+ color: color,
104
+ value: value
107
105
  };
108
106
  });
109
- var themeColors = STAT_ITEM_THEME_COLORS.light;
110
- if (theme === 'dark' && !isEnlarge && isPreview) {
111
- themeColors = STAT_ITEM_THEME_COLORS.dark;
112
- }
107
+ var themeColors = _this.getThemeColors();
113
108
  var legendDirection = statItem.legend_direction || 'vertical';
114
109
  var size = statItem.legend_size || 1;
115
110
  _this.chart.legend({
@@ -126,7 +121,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
126
121
  },
127
122
  align: legendDirection === 'vertical' ? 'right' : 'bottom',
128
123
  formatter: function formatter(value) {
129
- return getNumberDisplayString(value, columnData);
124
+ return _this.getNumberDisplayString(value, summaryColumnData, summary_method);
130
125
  }
131
126
  },
132
127
  handler: {
@@ -142,9 +137,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
142
137
  var _this$props2 = _this.props,
143
138
  getTableById = _this$props2.getTableById,
144
139
  statItem = _this$props2.statItem,
145
- isPreview = _this$props2.isPreview,
146
- isEnlarge = _this$props2.isEnlarge,
147
- theme = _this$props2.theme;
140
+ isPreview = _this$props2.isPreview;
148
141
  var userDv = _this.dataSet.createView().source(data).transform({
149
142
  geoDataView: _this.dataSet.getView('mapDataModel'),
150
143
  field: 'name',
@@ -154,12 +147,13 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
154
147
  var _this$props$statItem2 = _this.props.statItem,
155
148
  table_id = _this$props$statItem2.table_id,
156
149
  summary_type = _this$props$statItem2.summary_type,
150
+ summary_method = _this$props$statItem2.summary_method,
157
151
  summary_column = _this$props$statItem2.summary_column;
158
- var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
152
+ var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
159
153
  if (summary_type === SUMMARY_TYPE.ADVANCED) {
160
154
  var table = getTableById(table_id);
161
155
  var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
162
- columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
156
+ summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
163
157
  }
164
158
  _this.statisticView = _this.chart.createView();
165
159
  _this.statisticView.data(userDv.rows);
@@ -170,11 +164,11 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
170
164
  size = 60;
171
165
  }
172
166
  return size;
173
- }).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*value*color', function (name, value, color) {
167
+ }).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*formatted_value*color', function (name, value, color) {
174
168
  return {
175
169
  name: name,
176
- value: getNumberDisplayString(value, columnData),
177
- color: color
170
+ color: color,
171
+ value: value
178
172
  };
179
173
  }).style({
180
174
  fillOpacity: 0.6,
@@ -188,10 +182,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
188
182
  }
189
183
  }
190
184
  });
191
- var themeColors = STAT_ITEM_THEME_COLORS.light;
192
- if (theme === 'dark' && !isEnlarge && isPreview) {
193
- themeColors = STAT_ITEM_THEME_COLORS.dark;
194
- }
185
+ var themeColors = _this.getThemeColors();
195
186
  var legendDirection = statItem.legend_direction || 'vertical';
196
187
  var size = statItem.legend_size || 1;
197
188
  _this.chart.legend({
@@ -207,7 +198,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
207
198
  },
208
199
  align: legendDirection === 'vertical' ? 'right' : 'bottom',
209
200
  formatter: function formatter(value) {
210
- return getNumberDisplayString(value, columnData);
201
+ return _this.getNumberDisplayString(value, summaryColumnData, summary_method);
211
202
  }
212
203
  },
213
204
  handler: {
@@ -286,14 +277,8 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
286
277
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
287
278
  itemTpl: "<div class=\"g2-tooltip-content\"><div class=\"tooltip-name\">{name}<div><div class=\"tooltip-item\">".concat(intl.get(TITLE_AMOUNT), " : {value}<div></div>"),
288
279
  domStyles: {
289
- 'g2-tooltip': {
290
- borderRadius: '2px',
291
- backgroundColor: '#fff',
292
- padding: '10px'
293
- },
294
- 'tooltip-item': {
295
- marginTop: '5px'
296
- }
280
+ 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
281
+ 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
297
282
  }
298
283
  });
299
284
  _this.chart.scale({
@@ -351,14 +336,15 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
351
336
  isDataLoaded: true
352
337
  });
353
338
  if (!data) return;
339
+ _this2.geoData = data;
354
340
  _this2.initStatisticContext(data);
355
341
  if (_this2.container) {
356
- chartCalculator.calculate(statItem).then(function (data) {
342
+ chartCalculator.calculate(statItem).then(function (calculation) {
357
343
  _this2.setState({
358
344
  isCalculatingData: false
359
345
  });
360
- _this2.calculateData = data;
361
- _this2.updateStatisticData(_this2.fixData(data));
346
+ _this2.calculateData = calculation;
347
+ _this2.updateStatisticData(_this2.fixData(calculation));
362
348
  });
363
349
  }
364
350
  });
@@ -389,9 +375,16 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
389
375
  isCalculatingData: true
390
376
  });
391
377
  if (this.container) {
392
- chartCalculator.calculate(statItem).then(function (data) {
393
- _this3.calculateData = data;
394
- _this3.updateStatisticData(_this3.fixData(data));
378
+ if (this.chart) {
379
+ this.chart.destroy();
380
+ this.initStatisticContext(this.geoData);
381
+ }
382
+ chartCalculator.calculate(statItem).then(function (calculation) {
383
+ _this3.setState({
384
+ isCalculatingData: false
385
+ });
386
+ _this3.calculateData = calculation;
387
+ _this3.updateStatisticData(_this3.fixData(calculation));
395
388
  if (_this3.props.isPreview) {
396
389
  var canvasSize = _this3.getCanvasSize();
397
390
  _this3.chart.changeSize(canvasSize.w, canvasSize.h);
@@ -419,9 +412,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
419
412
  var _this$state = this.state,
420
413
  isDataLoaded = _this$state.isDataLoaded,
421
414
  isCalculatingData = _this$state.isCalculatingData;
422
- return /*#__PURE__*/React.createElement(React.Fragment, null, !isDataLoaded && isCalculatingData && /*#__PURE__*/React.createElement("div", {
423
- className: 'statistic-chart-loading-container'
424
- }, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
415
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (!isDataLoaded || isCalculatingData) && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
425
416
  ref: function ref(_ref) {
426
417
  return _this4.container = _ref;
427
418
  },
@@ -433,8 +424,6 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
433
424
  }(BaseChart);
434
425
  WorldMap.propTypes = {
435
426
  isPreview: PropTypes.bool,
436
- isEnlarge: PropTypes.bool,
437
- theme: PropTypes.string,
438
427
  statItem: PropTypes.object,
439
428
  chartCalculator: PropTypes.object,
440
429
  getTableById: PropTypes.func,
package/es/tabs/tab.js CHANGED
@@ -7,6 +7,7 @@ import React, { Component } from 'react';
7
7
  import intl from 'react-intl-universal';
8
8
  import { ModalPortal } from '../components';
9
9
  import { isMobile } from '../utils';
10
+ import { THEME_NAME_MAP } from '../constants';
10
11
  import styles from './statistic-tabs.module.css';
11
12
  var DashBoardTab = /*#__PURE__*/function (_Component) {
12
13
  _inherits(DashBoardTab, _Component);
@@ -141,7 +142,7 @@ var DashBoardTab = /*#__PURE__*/function (_Component) {
141
142
  }, /*#__PURE__*/React.createElement("i", {
142
143
  className: "".concat(styles['icon'], " dtable-font dtable-icon-drop-down")
143
144
  }), isShowViewDropdown && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement("div", {
144
- className: "".concat(theme === 'dark' ? 'statistic-tabs-dropdown-dark' : 'statistic-tabs-dropdown-light', " statistic-dropdown-menu dropdown-menu large show"),
145
+ className: "".concat(theme === THEME_NAME_MAP.DARK ? 'statistic-tabs-dropdown-dark' : 'statistic-tabs-dropdown-light', " statistic-dropdown-menu dropdown-menu large show"),
145
146
  style: _objectSpread(_objectSpread({}, dropdownMenuPosition), {}, {
146
147
  zIndex: 1500
147
148
  })
@@ -28,4 +28,13 @@ export var getKnownCreatorByEmail = function getKnownCreatorByEmail(collaborator
28
28
  creator = dtableCollaborators[email];
29
29
  if (creator) return creator;
30
30
  return null;
31
+ };
32
+ export var generateDefaultUser = function generateDefaultUser(name) {
33
+ if (!window || window.dtable) return {};
34
+ var mediaUrl = window.dtable.mediaUrl;
35
+ var defaultAvatarUrl = "".concat(mediaUrl, "avatars/default.png");
36
+ return {
37
+ name: name,
38
+ avatar_url: defaultAvatarUrl
39
+ };
31
40
  };
@@ -134,27 +134,45 @@ export var isArrayCellValue = function isArrayCellValue(column) {
134
134
 
135
135
  export var getSummaryResult = function getSummaryResult(results, summaryMethod) {
136
136
  var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
137
+ var numericResults = Array.isArray(results) && results.length > 0 ? results.filter(function (res) {
138
+ return isNumber(res);
139
+ }) : [];
137
140
  switch (summaryMethod) {
138
141
  case SUMMARY_METHOD_MAP.Max:
139
142
  {
140
- return getMax(results);
143
+ return getMax(numericResults);
141
144
  }
142
145
  case SUMMARY_METHOD_MAP.Min:
143
146
  {
144
- return getMin(results);
147
+ return getMin(numericResults);
145
148
  }
146
149
  case SUMMARY_METHOD_MAP.Sum:
147
150
  {
148
- return getSum(results, precision);
151
+ return getSum(numericResults, precision);
149
152
  }
150
153
  case SUMMARY_METHOD_MAP.Mean:
151
154
  {
152
- return getMean(results, precision);
155
+ return getMean(numericResults, precision);
153
156
  }
154
157
  case SUMMARY_METHOD_MAP.Distinct_values:
155
158
  {
156
- var result = new Set(results).size;
157
- return result;
159
+ var count = 0;
160
+ var existMap = {};
161
+ Array.isArray(results) && results.forEach(function (resNum) {
162
+ var num = resNum;
163
+ if (!num) {
164
+ if (num === 0) {
165
+ num = '0';
166
+ } else {
167
+ num = !!num;
168
+ }
169
+ }
170
+ if (!existMap[num]) {
171
+ existMap[num] = true;
172
+ count++;
173
+ }
174
+ });
175
+ return count;
158
176
  }
159
177
  default:
160
178
  {