dtable-statistic 4.0.12 → 4.1.0

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.
@@ -1,4 +1,6 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, generatorBase64Code, isNumber, TableUtils } from 'dtable-store';
3
+ import intl from 'react-intl-universal';
2
4
  import { STAT_TYPE, DEFAULT_LABEL_FONT_SIZE, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, CHART_STYLE_COLORS, PIE_COLOR_OPTIONS, SUMMARY_METHOD_MAP } from '../constants';
3
5
  import StatUtils from './stat-utils';
4
6
  export var generatorUniqueId = function generatorUniqueId(list) {
@@ -8,7 +10,10 @@ export var generatorUniqueId = function generatorUniqueId(list) {
8
10
  uniqueId = generatorBase64Code();
9
11
 
10
12
  // eslint-disable-next-line
11
- isUnique = Array.isArray(list) && list.length > 0 ? true : list.every(function (item) {
13
+ if (!Array.isArray(list) || list.length === 0) {
14
+ break;
15
+ }
16
+ isUnique = list.every(function (item) {
12
17
  return item._id !== uniqueId;
13
18
  });
14
19
  if (isUnique) {
@@ -251,10 +256,28 @@ export function formatPieChartData(data, statItem, table, currentTheme) {
251
256
  var filteredSum = filteredItems.reduce(function (total, currentValue) {
252
257
  return total += currentValue.value;
253
258
  }, 0);
259
+ var original_name_list = [];
260
+ var name_list = [];
261
+ var rows = [];
262
+ filteredItems.forEach(function (item) {
263
+ if (item.original_name) {
264
+ original_name_list.push(item.original_name);
265
+ }
266
+ if (item.name) {
267
+ name_list.push(item.name);
268
+ }
269
+ if (item.rows) {
270
+ rows.push.apply(rows, _toConsumableArray(item.rows));
271
+ }
272
+ });
254
273
  data.push({
255
- name: 'Others',
274
+ rows: rows,
275
+ name_list: name_list,
276
+ original_name_list: original_name_list,
277
+ name: intl.get('Others'),
256
278
  value: filteredSum,
257
279
  color: '#dbdbdb',
280
+ original_name: 'Others',
258
281
  percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%'
259
282
  });
260
283
  colorSet.push('#dbdbdb');