dtable-statistic 4.0.7 → 4.0.9

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 (64) hide show
  1. package/es/calculator/basic-chart-calculator.js +27 -18
  2. package/es/calculator/combination-calculator.js +34 -9
  3. package/es/calculator/compare-bar-calculator.js +37 -30
  4. package/es/calculator/heat-map-calculator.js +25 -14
  5. package/es/calculator/map-calculator.js +25 -14
  6. package/es/calculator/mirror-calculator.js +29 -14
  7. package/es/calculator/pivot-table-calculator.js +78 -51
  8. package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
  9. package/es/calculator/workers/combination-calculator-worker.js +20 -5
  10. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
  11. package/es/calculator/workers/mirror-calculator-worker.js +15 -6
  12. package/es/calculator/workers/pivot-table-calculator-worker.js +87 -41
  13. package/es/calculator/world-map-calculator.js +25 -14
  14. package/es/components/dialog/enlarged-chart-dialog.js +2 -2
  15. package/es/components/dialog/statistic-record-dialog/index.js +71 -41
  16. package/es/constants/index.js +30 -29
  17. package/es/dashboard.js +57 -43
  18. package/es/desktop-dashboard.js +16 -51
  19. package/es/index.js +34 -2
  20. package/es/locale/lang/de.js +2 -0
  21. package/es/locale/lang/en.js +2 -0
  22. package/es/locale/lang/fr.js +2 -0
  23. package/es/locale/lang/zh_CN.js +2 -0
  24. package/es/mobile-dashboard.js +5 -5
  25. package/es/model/horizontal-bar-group.js +2 -0
  26. package/es/model/ring.js +3 -2
  27. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
  28. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  29. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +4 -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 +81 -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 +207 -231
  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 +22 -15
  53. package/es/stat-view/pivot-table/two-dimension-table.js +98 -31
  54. package/es/stat-view/ring-chart.js +24 -42
  55. package/es/stat-view/scatter-chart.js +4 -21
  56. package/es/stat-view/treemap-chart.js +3 -12
  57. package/es/stat-view/trend-chart.js +6 -17
  58. package/es/stat-view/world-map.js +39 -50
  59. package/es/tabs/tab.js +2 -1
  60. package/es/utils/common-utils.js +29 -12
  61. package/es/utils/sql-utils.js +10 -9
  62. package/es/utils/stat-utils.js +23 -15
  63. package/es/utils/trend-utils.js +1 -1
  64. package/package.json +1 -1
@@ -6,10 +6,10 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
6
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
7
  import React, { PureComponent } from 'react';
8
8
  import intl from 'react-intl-universal';
9
- import { CellType, isNumber, TableUtils, Views } from 'dtable-store';
9
+ import { FORMULA_COLUMN_TYPES_MAP, isNumber, TableUtils, Views } from 'dtable-store';
10
10
  import PivotTableDisplayName from './pivot-table-display-name';
11
11
  import { isMobile } from '../../utils';
12
- import { TITLE_TOTAL } from '../../constants';
12
+ import { STATISTICS_COUNT_TYPE, SUMMARY_METHOD_MAP, TITLE_TOTAL } from '../../constants';
13
13
  import styles from './statistic-pivot-table.module.css';
14
14
  var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
15
15
  _inherits(TwoDimensionTable, _PureComponent);
@@ -59,6 +59,95 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
59
59
  }
60
60
  return 0;
61
61
  };
62
+ _this.getCellValueFromRow = function (row, formulaRow, columnType, columnKey, sqlKey, isSqlQuery) {
63
+ if (!isSqlQuery) {
64
+ if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
65
+ var cellValue = formulaRow[columnKey];
66
+ return Array.isArray(cellValue) ? cellValue[0] : cellValue;
67
+ }
68
+ return row[columnKey];
69
+ }
70
+ return row[sqlKey];
71
+ };
72
+ _this.getSummaryTotal = function (summaryColumnType, summaryColumnKey, sqlKey, summaryType, summaryMethod, rows, formulaRows, isSqlQuery) {
73
+ if (summaryType === STATISTICS_COUNT_TYPE.COUNT) {
74
+ return rows.length;
75
+ }
76
+ if (summaryType !== STATISTICS_COUNT_TYPE.ADVANCED) {
77
+ return 0;
78
+ }
79
+ switch (summaryMethod) {
80
+ case SUMMARY_METHOD_MAP.Distinct_values:
81
+ {
82
+ var count = 0;
83
+ var existMap = {};
84
+ rows.forEach(function (row) {
85
+ var formulaRow = formulaRows && formulaRows[row._id];
86
+ var cellValue = _this.getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
87
+ if (!cellValue) {
88
+ if (cellValue === 0) {
89
+ cellValue = '0';
90
+ } else {
91
+ cellValue = !!cellValue;
92
+ }
93
+ }
94
+ if (!existMap[cellValue]) {
95
+ existMap[cellValue] = true;
96
+ count++;
97
+ }
98
+ });
99
+ return count;
100
+ }
101
+ case SUMMARY_METHOD_MAP.Sum:
102
+ case SUMMARY_METHOD_MAP.Mean:
103
+ {
104
+ var sum = 0;
105
+ var validNumbersCount = 0;
106
+ rows.forEach(function (row) {
107
+ var formulaRow = formulaRows && formulaRows[row._id];
108
+ var cellValue = _this.getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
109
+ if (isNumber(cellValue)) {
110
+ validNumbersCount++;
111
+ sum += cellValue;
112
+ }
113
+ });
114
+ if (summaryMethod === SUMMARY_METHOD_MAP.Sum) {
115
+ sum = Number.parseFloat(sum.toFixed(8));
116
+ } else if (summaryMethod === SUMMARY_METHOD_MAP.Mean) {
117
+ sum = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
118
+ }
119
+ return sum;
120
+ }
121
+ case SUMMARY_METHOD_MAP.Max:
122
+ case SUMMARY_METHOD_MAP.Min:
123
+ {
124
+ if (rows.length === 0) {
125
+ return 0;
126
+ }
127
+ var result = rows.reduce(function (current, next) {
128
+ var currentFormulaRow = formulaRows && formulaRows[current._id];
129
+ var nextFormulaRow = formulaRows && formulaRows[next._id];
130
+ var currentValue = _this.getCellValueFromRow(current, currentFormulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
131
+ var nextValue = _this.getCellValueFromRow(next, nextFormulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
132
+ if (!nextValue && nextValue !== 0) {
133
+ return current;
134
+ }
135
+ var isNextGreater = currentValue < nextValue;
136
+ if (summaryMethod === SUMMARY_METHOD_MAP.Min) {
137
+ return isNextGreater ? current : next;
138
+ } else {
139
+ return isNextGreater ? next : current;
140
+ }
141
+ });
142
+ var formulaRow = formulaRows && formulaRows[result._id];
143
+ return _this.getCellValueFromRow(result, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
144
+ }
145
+ default:
146
+ {
147
+ return 0;
148
+ }
149
+ }
150
+ };
62
151
  _this.getCells = function (row, summaryColumn) {
63
152
  var _this$props2 = _this.props,
64
153
  pivotResult = _this$props2.pivotResult,
@@ -83,19 +172,7 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
83
172
  sqlKey = column.sqlKey,
84
173
  method = column.method;
85
174
  if (Array.isArray(rowData)) {
86
- var sum = 0;
87
- rowData.forEach(function (rowDataItem) {
88
- if (!isSqlQuery) {
89
- if (type === CellType.FORMULA) {
90
- var formulaRow = formulaRows[rowDataItem._id];
91
- sum += _this.getNumberValue(formulaRow[key]);
92
- return;
93
- }
94
- sum += _this.getNumberValue(rowDataItem[key]);
95
- return;
96
- }
97
- sum += _this.getNumberValue(rowDataItem[sqlKey]);
98
- });
175
+ var sum = _this.getSummaryTotal(type, key, sqlKey, STATISTICS_COUNT_TYPE.ADVANCED, method, rowData, formulaRows, isSqlQuery);
99
176
  summary_multiple_columns.push(sum);
100
177
  formatted_summary_multiple_columns.push(getSummaryValueDisplayString(column, sum, method));
101
178
  return;
@@ -304,22 +381,12 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
304
381
  var isValidTotalDisplayValue = true;
305
382
  if (column_groupby_multiple_numeric_column) {
306
383
  var total = 0;
307
- pivotColumnCell.forEach(function (item) {
308
- pivot_summary_multiple_columns.forEach(function (jtem) {
309
- var type = jtem.type,
310
- key = jtem.key,
311
- sqlKey = jtem.sqlKey;
312
- if (!isSqlQuery) {
313
- if (type === CellType.FORMULA) {
314
- var formulaRow = formulaRows[item._id];
315
- total += _this.getNumberValue(formulaRow[key]);
316
- return;
317
- }
318
- total += _this.getNumberValue(item[key]);
319
- return;
320
- }
321
- total += _this.getNumberValue(item[sqlKey]);
322
- });
384
+ pivot_summary_multiple_columns.forEach(function (summaryCol) {
385
+ var type = summaryCol.type,
386
+ key = summaryCol.key,
387
+ sqlKey = summaryCol.sqlKey,
388
+ method = summaryCol.method;
389
+ total += _this.getSummaryTotal(type, key, sqlKey, STATISTICS_COUNT_TYPE.ADVANCED, method, pivotColumnCell, formulaRows, isSqlQuery);
323
390
  });
324
391
  totalDisplayValue = total;
325
392
  allTotalDisplay += total;
@@ -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
  },