sea-chart 1.1.24 → 1.1.26

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 (33) hide show
  1. package/dist/components/statistic-record-dialog/index.css +6 -5
  2. package/dist/components/statistic-record-dialog/index.js +7 -1
  3. package/dist/constants/index.js +1 -0
  4. package/dist/locale/lang/de.js +3 -2
  5. package/dist/locale/lang/en.js +2 -1
  6. package/dist/locale/lang/es.js +2 -1
  7. package/dist/locale/lang/fr.js +3 -2
  8. package/dist/locale/lang/pt.js +2 -1
  9. package/dist/locale/lang/ru.js +2 -1
  10. package/dist/locale/lang/zh_CN.js +2 -1
  11. package/dist/utils/chart-utils/base-utils.js +7 -6
  12. package/dist/utils/chart-utils/sql-statistics-utils.js +12 -8
  13. package/dist/view/wrapper/area.js +7 -3
  14. package/dist/view/wrapper/bar-custom.js +8 -4
  15. package/dist/view/wrapper/bar-group.js +7 -3
  16. package/dist/view/wrapper/bar.js +9 -4
  17. package/dist/view/wrapper/chart-component.js +6 -2
  18. package/dist/view/wrapper/combination.js +10 -5
  19. package/dist/view/wrapper/compare.js +7 -3
  20. package/dist/view/wrapper/completeness.js +4 -2
  21. package/dist/view/wrapper/dashboard.js +2 -1
  22. package/dist/view/wrapper/funnel.js +4 -2
  23. package/dist/view/wrapper/heat-map.js +32 -16
  24. package/dist/view/wrapper/horizontal-bar-group.js +9 -4
  25. package/dist/view/wrapper/horizontal-bar.js +8 -4
  26. package/dist/view/wrapper/horizontal-component.js +4 -1
  27. package/dist/view/wrapper/line-group.js +7 -3
  28. package/dist/view/wrapper/line.js +7 -3
  29. package/dist/view/wrapper/mirror.js +4 -2
  30. package/dist/view/wrapper/pie.js +3 -1
  31. package/dist/view/wrapper/ring.js +3 -1
  32. package/dist/view/wrapper/world-map.js +13 -7
  33. package/package.json +2 -2
@@ -74,13 +74,14 @@
74
74
  }
75
75
 
76
76
  .sea-chart-statistic-records-dialog .search-input-container .clear-search-text {
77
- display: inline-block;
77
+ display: flex;
78
78
  position: absolute;
79
+ justify-content: center;
80
+ align-items: center;
79
81
  right: 30px;
80
- top: 10px;
81
- height: 12px;
82
- width: 12px;
83
- line-height: 12px;
82
+ top: 0px;
83
+ /* 2px border */
84
+ height: calc(100% - 2px);
84
85
  color: #ccc;
85
86
  }
86
87
 
@@ -1,3 +1,4 @@
1
+ import _DTableEmptyTip from "dtable-ui-component/lib/DTableEmptyTip";
1
2
  import _toaster from "dtable-ui-component/lib/toaster";
2
3
  import React, { Fragment } from 'react';
3
4
  import { Modal, ModalBody } from 'reactstrap';
@@ -280,7 +281,12 @@ class StatisticRecordDialog extends React.Component {
280
281
  searchedRowsIds
281
282
  } = this.state;
282
283
  const searchedRows = this.getRowsByIds(searchedRowsIds);
283
- if (searchedRows.length === 0) return null;
284
+ if (searchedRows.length === 0) return /*#__PURE__*/React.createElement("div", {
285
+ className: "w-100 h-100"
286
+ }, /*#__PURE__*/React.createElement(_DTableEmptyTip, {
287
+ src: "".concat(context.getSetting('mediaUrl'), "img/no-items-tip.png"),
288
+ text: intl.get('No_record')
289
+ }));
284
290
  const props = {
285
291
  table: this.table,
286
292
  renderedColumns: this.renderedColumns,
@@ -29,6 +29,7 @@ export const NUMBERIC_COLUMN_TYPE = [CellType.RATE, CellType.NUMBER];
29
29
 
30
30
  // chart supports groupby
31
31
  export const SUPPORT_GROUP_BY_CHART_TYPES = [CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.AREA_GROUP, CHART_TYPE.LINE_GROUP, CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR, CHART_TYPE.SCATTER];
32
+ export const MAP_CHART_TYPES = [CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE];
32
33
  export const ZH_CN_SUPPORT_CHARTS = [CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE];
33
34
  export const SUPPORT_DATA_SORT_CHART_TYPES = [CHART_TYPE.BAR, CHART_TYPE.BAR_STACK, CHART_TYPE.LINE, CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR, CHART_TYPE.AREA, CHART_TYPE.TREE_MAP];
34
35
  export const SUPPORT_STACK_VALUE_CHART_TYPES = [CHART_TYPE.BAR_STACK, CHART_TYPE.BAR_CUSTOM];
@@ -252,7 +252,7 @@ const de = {
252
252
  "Use_default_color": "Standardfarbe verwenden",
253
253
  "Use_colors_in_single_select_solumn": "Verwenden Sie Farben in einer einzelnen Auswahlspalte",
254
254
  "Search_records": "Einträge suchen",
255
- "Please_select_a_grouping_column": "Please select grouping column",
255
+ "Please_select_a_grouping_column": "Bitte Gruppierungsspalte auswählen",
256
256
  "View": "Sicht",
257
257
  "Funnel": "Trichterdiagramm",
258
258
  "All_charts": "Alle Diagramme",
@@ -264,6 +264,7 @@ const de = {
264
264
  "Outside": "Draußen",
265
265
  "Show_overall_rate": "Gesamtpreisbeschriftung anzeigen",
266
266
  "Percentage": "Prozentsatz",
267
- "Number_and_percentage": "Anzahl und Prozentsatz"
267
+ "Number_and_percentage": "Anzahl und Prozentsatz",
268
+ "No_record": "Keine Aufzeichnung"
268
269
  };
269
270
  export default de;
@@ -264,6 +264,7 @@ const en = {
264
264
  "Outside": "Outside",
265
265
  "Show_overall_rate": "Show overall rate",
266
266
  "Percentage": "Percentage",
267
- "Number_and_percentage": "Number and percentage"
267
+ "Number_and_percentage": "Number and percentage",
268
+ "No_record": "No record"
268
269
  };
269
270
  export default en;
@@ -264,6 +264,7 @@ const es = {
264
264
  "Outside": "Outside",
265
265
  "Show_overall_rate": "Show overall rate",
266
266
  "Percentage": "Percentage",
267
- "Number_and_percentage": "Number and percentage"
267
+ "Number_and_percentage": "Number and percentage",
268
+ "No_record": "No record"
268
269
  };
269
270
  export default es;
@@ -252,7 +252,7 @@ const fr = {
252
252
  "Use_default_color": "Utiliser la couleur par défaut",
253
253
  "Use_colors_in_single_select_solumn": "Utiliser les couleurs dans une colonne de sélection unique",
254
254
  "Search_records": "Rechercher des enregistrements",
255
- "Please_select_a_grouping_column": "Please select grouping column",
255
+ "Please_select_a_grouping_column": "Veuillez sélectionner la colonne de regroupement",
256
256
  "View": "Voir",
257
257
  "Funnel": "Entonnoir",
258
258
  "All_charts": "Tous les graphiques",
@@ -264,6 +264,7 @@ const fr = {
264
264
  "Outside": "Dehors",
265
265
  "Show_overall_rate": "Afficher le libellé du tarif global",
266
266
  "Percentage": "Couche d'entonnoir",
267
- "Number_and_percentage": "Nombre et pourcentage"
267
+ "Number_and_percentage": "Nombre et pourcentage",
268
+ "No_record": "Aucun enregistrement"
268
269
  };
269
270
  export default fr;
@@ -264,6 +264,7 @@ const pt = {
264
264
  "Outside": "Outside",
265
265
  "Show_overall_rate": "Show overall rate",
266
266
  "Percentage": "Percentage",
267
- "Number_and_percentage": "Number and percentage"
267
+ "Number_and_percentage": "Number and percentage",
268
+ "No_record": "No record"
268
269
  };
269
270
  export default pt;
@@ -264,6 +264,7 @@ const ru = {
264
264
  "Outside": "Outside",
265
265
  "Show_overall_rate": "Show overall rate",
266
266
  "Percentage": "Percentage",
267
- "Number_and_percentage": "Number and percentage"
267
+ "Number_and_percentage": "Number and percentage",
268
+ "No_record": "No record"
268
269
  };
269
270
  export default ru;
@@ -264,6 +264,7 @@ const zh_CN = {
264
264
  "Outside": "在图表外",
265
265
  "Show_overall_rate": "显示总转化率标签",
266
266
  "Percentage": "百分比",
267
- "Number_and_percentage": "数值和百分比"
267
+ "Number_and_percentage": "数值和百分比",
268
+ "No_record": "没有记录"
268
269
  };
269
270
  export default zh_CN;
@@ -490,16 +490,17 @@ BaseUtils.getColumn = (tables, tableId, columnKey) => {
490
490
  BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) => {
491
491
  if (!Array.isArray(dataList)) return [];
492
492
  let updatedStatistics = [];
493
- dataList.forEach(item => {
494
- let updated = {};
493
+ for (let i = 0; i < dataList.length; i++) {
494
+ let item = dataList[i];
495
+ // let updated = {};
495
496
  if (!item.name) {
496
- updated.name = emptyName;
497
+ item.name = emptyName;
497
498
  }
498
499
  if (column_groupby_column_key && !item.group_name) {
499
- updated.group_name = emptyName;
500
+ item.group_name = emptyName;
500
501
  }
501
- updatedStatistics.push(Object.assign({}, item, updated));
502
- });
502
+ updatedStatistics.push(item);
503
+ }
503
504
  return updatedStatistics;
504
505
  };
505
506
  // init
@@ -3,7 +3,7 @@ import dayjs from 'dayjs';
3
3
  import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, DateUtils } from 'dtable-utils';
4
4
  import { isObject } from 'lodash';
5
5
  import { cloneDeep } from 'lodash-es';
6
- import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS, TREND_TYPES, CHART_STYLE_COLORS } from '../../constants';
6
+ import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS, TREND_TYPES, CHART_STYLE_COLORS, MAP_CHART_TYPES } from '../../constants';
7
7
  import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
8
8
  import { getClientLinkDisplayString } from '../cell-format-utils';
9
9
  import { column2SqlColumn } from '../sql/column-2-sql-column';
@@ -1415,6 +1415,7 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = async (chart, sqlRows, c
1415
1415
  const equal2GroupData0 = groupData0.id === groupValue;
1416
1416
  const equal2GroupData1 = groupData1.id === groupValue;
1417
1417
  if (equal2GroupData0 || equal2GroupData1) {
1418
+ var _groupData$, _groupData$2, _groupData$3, _groupData$4;
1418
1419
  let value = item[sqlSummaryColumnKey];
1419
1420
  let formattedValue = value;
1420
1421
  if (isAdvanced) {
@@ -1426,24 +1427,27 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = async (chart, sqlRows, c
1426
1427
  original_name: item[column_key],
1427
1428
  value: equal2GroupData0 ? value : 0,
1428
1429
  formatted_value: equal2GroupData0 ? formattedValue : 0,
1429
- group_name: groupData[0].name,
1430
- color: groupData[0].color,
1430
+ group_name: ((_groupData$ = groupData[0]) === null || _groupData$ === void 0 ? void 0 : _groupData$.name) || '',
1431
+ color: ((_groupData$2 = groupData[0]) === null || _groupData$2 === void 0 ? void 0 : _groupData$2.color) || STYLE_COLORS[0].colors[0],
1431
1432
  rows: [item]
1432
- }, {
1433
+ });
1434
+ groupData[1] && newResult.push({
1433
1435
  name: label,
1434
1436
  original_name: item[column_key],
1435
1437
  value: equal2GroupData1 ? value : 0,
1436
1438
  formatted_value: equal2GroupData1 ? formattedValue : 0,
1437
- group_name: groupData[1].name,
1438
- color: groupData[1].color,
1439
+ group_name: ((_groupData$3 = groupData[1]) === null || _groupData$3 === void 0 ? void 0 : _groupData$3.name) || '',
1440
+ color: ((_groupData$4 = groupData[1]) === null || _groupData$4 === void 0 ? void 0 : _groupData$4.color) || STYLE_COLORS[0].colors[0],
1439
1441
  rows: [item]
1440
1442
  });
1441
1443
  }
1442
1444
  }
1443
1445
  }
1446
+ const colorSet = [groupData[0] && groupData[0].color];
1447
+ groupData[1] && groupData[1].color && colorSet.push(groupData[1].color);
1444
1448
  return {
1445
1449
  data: newResult,
1446
- colorSet: [groupData[0] && groupData[0].color, groupData[1] && groupData[1].color]
1450
+ colorSet
1447
1451
  };
1448
1452
  };
1449
1453
  SQLStatisticsUtils.trendMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
@@ -2011,7 +2015,7 @@ SQLStatisticsUtils.calculateChart = async (chart, value, callback, sqlRows) => {
2011
2015
  }
2012
2016
 
2013
2017
  // map is special, still need to show map even data is empty
2014
- if (!Array.isArray(sqlRows) || sqlRows.length === 0 && !chartType.includes('map')) {
2018
+ if (!Array.isArray(sqlRows) || sqlRows.length === 0 && !MAP_CHART_TYPES.includes(chartType)) {
2015
2019
  callback && callback('', tipMessage, null);
2016
2020
  return;
2017
2021
  }
@@ -55,7 +55,9 @@ class Area extends ChartComponent {
55
55
  this.loadData(data);
56
56
  this.draw(data);
57
57
  isFunction(customRender) && customRender(this.chart);
58
- this.chart.render();
58
+ requestAnimationFrame(() => {
59
+ this.chart.render();
60
+ });
59
61
  };
60
62
  this.draw = data => {
61
63
  const {
@@ -221,15 +223,17 @@ class Area extends ChartComponent {
221
223
  componentDidUpdate(prevProps) {
222
224
  super.componentDidUpdate(prevProps);
223
225
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
226
+ var _this$chart;
224
227
  this.initChartType();
225
- this.chart && this.chart.destroy();
228
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
226
229
  this.createChart();
227
230
  this.drawChart();
228
231
  this.renderAxisLabel(prevProps.chart, prevProps.tables);
229
232
  }
230
233
  }
231
234
  componentWillUnmount() {
232
- this.chart && this.chart.destroy();
235
+ var _this$chart2;
236
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
233
237
  super.componentWillUnmount();
234
238
  }
235
239
  render() {
@@ -42,8 +42,10 @@ class BarCustom extends ChartComponent {
42
42
  if (!Array.isArray(data)) return;
43
43
  this.loadData(data);
44
44
  this.draw(data);
45
- this.chart.render();
46
- this.renderAxisLabel(this.props.chart, this.props.tables);
45
+ requestAnimationFrame(() => {
46
+ this.chart.render();
47
+ this.renderAxisLabel(this.props.chart, this.props.tables);
48
+ });
47
49
  };
48
50
  this.organizeData = data => {
49
51
  const dataMap = {};
@@ -183,13 +185,15 @@ class BarCustom extends ChartComponent {
183
185
  componentDidUpdate(prevProps) {
184
186
  super.componentDidUpdate(prevProps);
185
187
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
186
- this.chart && this.chart.destroy();
188
+ var _this$chart;
189
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
187
190
  this.createChart();
188
191
  this.drawChart();
189
192
  }
190
193
  }
191
194
  componentWillUnmount() {
192
- this.chart && this.chart.destroy();
195
+ var _this$chart2;
196
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
193
197
  window.removeEventListener('resize', this.handleResize);
194
198
  }
195
199
  render() {
@@ -60,7 +60,9 @@ class BarGroup extends ChartComponent {
60
60
  }
61
61
  this.loadData(data);
62
62
  this.draw(data);
63
- this.chart.render();
63
+ requestAnimationFrame(() => {
64
+ this.chart.render();
65
+ });
64
66
  };
65
67
  this.draw = data => {
66
68
  const {
@@ -216,14 +218,16 @@ class BarGroup extends ChartComponent {
216
218
  componentDidUpdate(prevProps) {
217
219
  super.componentDidUpdate(prevProps);
218
220
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
219
- this.chart && this.chart.destroy();
221
+ var _this$chart;
222
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
220
223
  this.createChart();
221
224
  this.drawChart();
222
225
  this.renderAxisLabel(prevProps.chart, prevProps.tables);
223
226
  }
224
227
  }
225
228
  componentWillUnmount() {
226
- this.chart && this.chart.destroy();
229
+ var _this$chart2;
230
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
227
231
  window.removeEventListener('resize', this.debouncedHandleResize);
228
232
  }
229
233
  render() {
@@ -42,8 +42,10 @@ class Bar extends ChartComponent {
42
42
  if (!Array.isArray(data)) return;
43
43
  this.loadData(data);
44
44
  this.draw(data);
45
- this.chart.render();
46
- this.renderAxisLabel(this.props.chart, this.props.tables);
45
+ requestAnimationFrame(() => {
46
+ this.chart.render();
47
+ this.renderAxisLabel(this.props.chart, this.props.tables);
48
+ });
47
49
  };
48
50
  this.draw = data => {
49
51
  const {
@@ -129,13 +131,16 @@ class Bar extends ChartComponent {
129
131
  componentDidUpdate(prevProps) {
130
132
  super.componentDidUpdate(prevProps);
131
133
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
132
- this.chart && this.chart.destroy();
134
+ var _this$chart;
135
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
133
136
  this.createChart();
134
137
  this.drawChart();
135
138
  }
136
139
  }
137
140
  componentWillUnmount() {
138
- this.chart && this.chart.destroy();
141
+ var _this$chart2;
142
+ // chart doesn't have autoPadding before they were rendered
143
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
139
144
  window.removeEventListener('resize', this.debouncedHandleResize);
140
145
  }
141
146
  render() {
@@ -18,8 +18,9 @@ export default class ChartComponent extends Component {
18
18
  };
19
19
  };
20
20
  this.handleResize = debounce(() => {
21
+ var _this$chart;
21
22
  if (!this.createChart || !this.drawChart) return;
22
- this.chart && this.chart.destroy();
23
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
23
24
  this.createChart();
24
25
  this.drawChart();
25
26
  if (this.needRenderAxisLabel) {
@@ -206,6 +207,7 @@ export default class ChartComponent extends Component {
206
207
  }
207
208
  };
208
209
  this.renderAxisLabel = (chart, tables) => {
210
+ var _this$chart2;
209
211
  if (!this.chart || !chart) return;
210
212
  let {
211
213
  table_id,
@@ -226,7 +228,9 @@ export default class ChartComponent extends Component {
226
228
  y_axis_column_key = y_axis_summary_column_key;
227
229
  }
228
230
  const table = getTableById(tables, table_id);
229
- const autoPadding = this.chart.autoPadding;
231
+ const autoPadding = ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) || {
232
+ bottom: 0
233
+ };
230
234
  let textColor;
231
235
  this.globalTheme === THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
232
236
  const xAxisID = "chart-x-axis-label_".concat(chart.id);
@@ -397,10 +397,13 @@ class Combination extends ChartComponent {
397
397
  }, 100));
398
398
  isFunction(customRender) && customRender(this.chart);
399
399
  this.chart.removeInteraction('legend-filter');
400
- this.chart.render();
401
- this.renderAxisLabel();
400
+ requestAnimationFrame(() => {
401
+ this.chart.render();
402
+ this.renderAxisLabel();
403
+ });
402
404
  };
403
405
  this.renderAxisLabel = () => {
406
+ var _this$chart;
404
407
  if (!this.chart) return;
405
408
  let {
406
409
  chart,
@@ -424,7 +427,7 @@ class Combination extends ChartComponent {
424
427
  y_axis_right_summary_type
425
428
  } = config;
426
429
  const table = getTableById(tables, table_id);
427
- const autoPadding = this.chart.autoPadding;
430
+ const autoPadding = ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) || 0;
428
431
  const textColor = '#999';
429
432
  const xAxisID = "chart-x-axis-label_".concat(chart.id);
430
433
  const chartContainer = this.chart.getCanvas().get('container');
@@ -648,13 +651,15 @@ class Combination extends ChartComponent {
648
651
  componentDidUpdate(prevProps) {
649
652
  super.componentDidUpdate(prevProps);
650
653
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
651
- this.chart && this.chart.destroy();
654
+ var _this$chart2;
655
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
652
656
  this.drawChart();
653
657
  this.renderAxisLabel(prevProps.chart, prevProps.tables);
654
658
  }
655
659
  }
656
660
  componentWillUnmount() {
657
- this.chart && this.chart.destroy();
661
+ var _this$chart3;
662
+ ((_this$chart3 = this.chart) === null || _this$chart3 === void 0 ? void 0 : _this$chart3.autoPadding) && this.chart.destroy();
658
663
  }
659
664
  render() {
660
665
  const {
@@ -38,7 +38,9 @@ class Compare extends ChartComponent {
38
38
  if (!Array.isArray(data)) return;
39
39
  this.loadData(data);
40
40
  this.draw(data);
41
- this.chart.render();
41
+ requestAnimationFrame(() => {
42
+ this.chart.render();
43
+ });
42
44
  };
43
45
  this.draw = data => {
44
46
  const {
@@ -335,14 +337,16 @@ class Compare extends ChartComponent {
335
337
  componentDidUpdate(prevProps) {
336
338
  super.componentDidUpdate(prevProps);
337
339
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
338
- this.chart && this.chart.destroy();
340
+ var _this$chart;
341
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
339
342
  this.createChart();
340
343
  this.drawChart();
341
344
  this.renderAxisLabel(this.props.chart, this.props.tables);
342
345
  }
343
346
  }
344
347
  componentWillUnmount() {
345
- this.chart && this.chart.destroy();
348
+ var _this$chart2;
349
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
346
350
  }
347
351
  render() {
348
352
  const {
@@ -48,8 +48,10 @@ export default function Completeness(_ref) {
48
48
  if (!Array.isArray(currentData)) return;
49
49
  currentChart.loadData(currentData);
50
50
  draw(currentData);
51
- currentChart.chart.render();
52
- currentChart.renderAxisLabel(chart, tables);
51
+ requestAnimationFrame(() => {
52
+ currentChart.chart.render();
53
+ currentChart.renderAxisLabel(chart, tables);
54
+ });
53
55
  }
54
56
  function draw(data) {
55
57
  const theme = CHART_THEME_COLOR[globalTheme];
@@ -157,7 +157,8 @@ class Dashboard extends Component {
157
157
  }
158
158
  componentDidUpdate(prevProps) {
159
159
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
160
- this.chart && this.chart.destroy();
160
+ var _this$chart;
161
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
161
162
  this.drawChart();
162
163
  }
163
164
  }
@@ -178,13 +178,15 @@ class Funnel extends ChartComponent {
178
178
  }
179
179
  componentDidUpdate(prevProps) {
180
180
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
181
- this.chart && this.chart.destroy();
181
+ var _this$chart;
182
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
182
183
  this.createChart();
183
184
  this.drawChart();
184
185
  }
185
186
  }
186
187
  componentWillUnmount() {
187
- this.chart && this.chart.destroy();
188
+ var _this$chart2;
189
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
188
190
  }
189
191
  render() {
190
192
  return /*#__PURE__*/React.createElement("div", {
@@ -56,32 +56,44 @@ class HeatMap extends ChartComponent {
56
56
  return [];
57
57
  };
58
58
  this.generateBackgroundGridData = statData => {
59
- let momentDate = dayjs(this.firstDate);
60
- const year = momentDate.year();
59
+ let currentDate = new Date(this.firstDate);
60
+ const year = currentDate.getFullYear();
61
61
  const gridData = [];
62
- const isLeapYear = year % 4 > 0 ? false : true;
63
- let yearDayCount = 365;
64
- if (isLeapYear) {
65
- yearDayCount = 366;
66
- }
62
+ const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
63
+ const yearDayCount = isLeapYear ? 366 : 365;
64
+ const getISOWeek = date => {
65
+ const target = new Date(date.valueOf());
66
+ // set 0 to monday, 6 to sunday
67
+ const dayNumber = (date.getUTCDay() + 6) % 7;
68
+ // set target to Thursday of this week, daynumber is days passed this week, 3 is Thursday
69
+ target.setUTCDate(target.getUTCDate() - dayNumber + 3);
70
+ const firstThursday = target.valueOf();
71
+ target.setUTCMonth(0, 1);
72
+ // find first thursday of the year
73
+ // https://blog.csdn.net/theadore2017/article/details/88578753
74
+ if (target.getUTCDay() !== 4) {
75
+ target.setUTCMonth(0, 1 + (4 - target.getUTCDay() + 7) % 7);
76
+ }
77
+ return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000ms in one week
78
+ };
67
79
  for (let i = 0; i < yearDayCount; i++) {
68
- const day = momentDate.day();
69
- let week = momentDate.week() - 1;
70
- const month = momentDate.month();
80
+ const day = currentDate.getDay();
81
+ let week = getISOWeek(currentDate) - 1;
82
+ const month = currentDate.getMonth();
71
83
  if (week === 0 && month === 11) {
72
84
  week = 52;
73
85
  }
74
- const yearDate = momentDate.format('YYYY-MM-DD');
86
+ const yearDate = currentDate.toISOString().split('T')[0];
75
87
  const value = statData[yearDate] || 0;
76
88
  this.maxValue = Math.max(this.maxValue, value);
77
89
  gridData.push({
78
90
  date: yearDate,
79
- value: statData[yearDate],
91
+ value,
80
92
  day,
81
93
  week,
82
94
  month
83
95
  });
84
- momentDate = momentDate.add(1, 'days');
96
+ currentDate.setDate(currentDate.getDate() + 1);
85
97
  }
86
98
  return gridData;
87
99
  };
@@ -261,7 +273,9 @@ class HeatMap extends ChartComponent {
261
273
  items: this.getLegendItems(exampleColors)
262
274
  });
263
275
  this.chart.removeInteraction('legend-filter');
264
- this.chart.render();
276
+ requestAnimationFrame(() => {
277
+ this.chart.render();
278
+ });
265
279
  };
266
280
  dayjs.locale('en');
267
281
  this.chart = null;
@@ -314,13 +328,15 @@ class HeatMap extends ChartComponent {
314
328
  componentDidUpdate(prevProps) {
315
329
  super.componentDidUpdate(prevProps);
316
330
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
317
- this.chart && this.chart.destroy();
331
+ var _this$chart;
332
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
318
333
  this.createChart();
319
334
  this.drawChart();
320
335
  }
321
336
  }
322
337
  componentWillUnmount() {
323
- this.chart && this.chart.destroy();
338
+ var _this$chart2;
339
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
324
340
  }
325
341
  getLegendItemPath(x, y, r, index, textWidth) {
326
342
  // x, y represents the coordinates of the center point of the legend item marker
@@ -13,7 +13,8 @@ class HorizontalBarGroup extends HorizontalComponent {
13
13
  constructor(props) {
14
14
  super(props);
15
15
  this.handleResize = debounce(() => {
16
- this.chart && this.chart.destroy();
16
+ var _this$chart;
17
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
17
18
  this.createChart();
18
19
  this.drawChart();
19
20
  this.renderHorizontalLabel(this.props.chart, this.props.tables);
@@ -59,7 +60,9 @@ class HorizontalBarGroup extends HorizontalComponent {
59
60
  this.loadData(data);
60
61
  this.draw(data);
61
62
  isFunction(customRender) && customRender(this.chart);
62
- this.chart.render();
63
+ requestAnimationFrame(() => {
64
+ this.chart.render();
65
+ });
63
66
  };
64
67
  this.draw = data => {
65
68
  const {
@@ -175,14 +178,16 @@ class HorizontalBarGroup extends HorizontalComponent {
175
178
  componentDidUpdate(prevProps) {
176
179
  super.componentDidUpdate(prevProps);
177
180
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
178
- this.chart && this.chart.destroy();
181
+ var _this$chart2;
182
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
179
183
  this.createChart();
180
184
  this.drawChart();
181
185
  this.renderHorizontalLabel(prevProps.chart, prevProps.tables);
182
186
  }
183
187
  }
184
188
  componentWillUnmount() {
185
- this.chart && this.chart.destroy();
189
+ var _this$chart3;
190
+ ((_this$chart3 = this.chart) === null || _this$chart3 === void 0 ? void 0 : _this$chart3.autoPadding) && this.chart.destroy();
186
191
  window.removeEventListener('resize', this.handleResize);
187
192
  }
188
193
  render() {
@@ -38,8 +38,10 @@ class HorizontalBar extends HorizontalComponent {
38
38
  this.loadData(data);
39
39
  this.draw(data);
40
40
  isFunction(customRender) && customRender(this.chart);
41
- this.chart.render();
42
- this.renderHorizontalLabel(this.props.chart, this.props.tables);
41
+ requestAnimationFrame(() => {
42
+ this.chart.render();
43
+ this.renderHorizontalLabel(this.props.chart, this.props.tables);
44
+ });
43
45
  };
44
46
  this.draw = data => {
45
47
  const {
@@ -127,13 +129,15 @@ class HorizontalBar extends HorizontalComponent {
127
129
  componentDidUpdate(prevProps) {
128
130
  super.componentDidUpdate(prevProps);
129
131
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
130
- this.chart && this.chart.destroy();
132
+ var _this$chart;
133
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
131
134
  this.createChart();
132
135
  this.drawChart();
133
136
  }
134
137
  }
135
138
  componentWillUnmount() {
136
- this.chart && this.chart.destroy();
139
+ var _this$chart2;
140
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
137
141
  super.componentWillUnmount();
138
142
  }
139
143
  render() {
@@ -6,6 +6,7 @@ export default class HorizontalComponent extends ChartComponent {
6
6
  constructor() {
7
7
  super(...arguments);
8
8
  this.renderHorizontalLabel = (chart, tables) => {
9
+ var _this$chart;
9
10
  if (!this.chart || !chart) return;
10
11
  let {
11
12
  table_id,
@@ -18,7 +19,9 @@ export default class HorizontalComponent extends ChartComponent {
18
19
  show_horizontal_axis_label
19
20
  } = chart.config;
20
21
  const table = getTableById(tables, table_id);
21
- const autoPadding = this.chart.autoPadding;
22
+ const autoPadding = ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) || {
23
+ bottom: 0
24
+ };
22
25
  const textColor = '#999999';
23
26
  const xAxisID = "chart-x-axis-label_".concat(chart.id);
24
27
  const chartContainer = this.chart.getCanvas().get('container');
@@ -42,7 +42,9 @@ class LineGroup extends ChartComponent {
42
42
  this.loadData(data);
43
43
  this.draw(data);
44
44
  isFunction(customRender) && customRender(this.chart);
45
- this.chart.render();
45
+ requestAnimationFrame(() => {
46
+ this.chart.render();
47
+ });
46
48
  };
47
49
  this.draw = data => {
48
50
  const {
@@ -159,14 +161,16 @@ class LineGroup extends ChartComponent {
159
161
  componentDidUpdate(prevProps) {
160
162
  super.componentDidUpdate(prevProps);
161
163
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
162
- this.chart && this.chart.destroy();
164
+ var _this$chart;
165
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
163
166
  this.createChart();
164
167
  this.drawChart();
165
168
  this.renderAxisLabel(prevProps.chart, prevProps.tables);
166
169
  }
167
170
  }
168
171
  componentWillUnmount() {
169
- this.chart && this.chart.destroy();
172
+ var _this$chart2;
173
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
170
174
  super.componentWillUnmount();
171
175
  }
172
176
  render() {
@@ -40,7 +40,9 @@ class Line extends ChartComponent {
40
40
  this.draw(data);
41
41
  this.autoAdjustDataOptions(chart, data, summaryColumn);
42
42
  isFunction(customRender) && customRender(this.chart);
43
- this.chart.render();
43
+ requestAnimationFrame(() => {
44
+ this.chart.render();
45
+ });
44
46
  };
45
47
  this.draw = data => {
46
48
  const {
@@ -162,14 +164,16 @@ class Line extends ChartComponent {
162
164
  componentDidUpdate(prevProps) {
163
165
  super.componentDidUpdate(prevProps);
164
166
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
165
- this.chart && this.chart.destroy();
167
+ var _this$chart;
168
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
166
169
  this.createChart();
167
170
  this.drawChart();
168
171
  this.renderAxisLabel(prevProps.chart, prevProps.tables);
169
172
  }
170
173
  }
171
174
  componentWillUnmount() {
172
- this.chart && this.chart.destroy();
175
+ var _this$chart2;
176
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
173
177
  super.componentWillUnmount();
174
178
  }
175
179
  render() {
@@ -179,13 +179,15 @@ class Mirror extends ChartComponent {
179
179
  componentDidUpdate(prevProps) {
180
180
  super.componentDidUpdate(prevProps);
181
181
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
182
- this.chart && this.chart.destroy();
182
+ var _this$chart;
183
+ ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
183
184
  this.createChart();
184
185
  this.drawChart();
185
186
  }
186
187
  }
187
188
  componentWillUnmount() {
188
- this.chart && this.chart.destroy();
189
+ var _this$chart2;
190
+ ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
189
191
  }
190
192
  render() {
191
193
  return /*#__PURE__*/React.createElement("div", {
@@ -128,7 +128,9 @@ class Pie extends ChartComponent {
128
128
  summaryMethod: summary_method
129
129
  }));
130
130
  isFunction(customRender) && customRender(this.chart);
131
- this.chart.render();
131
+ requestAnimationFrame(() => {
132
+ this.chart.render();
133
+ });
132
134
  };
133
135
  this.onEnterElement = (evt, _ref) => {
134
136
  let {
@@ -153,7 +153,9 @@ class Ring extends ChartComponent {
153
153
  }));
154
154
  this.chart.interaction('element-highlight');
155
155
  isFunction(customRender) && customRender(this.chart);
156
- this.chart.render();
156
+ requestAnimationFrame(() => {
157
+ this.chart.render();
158
+ });
157
159
  };
158
160
  this.getLabel = (value, percent) => {
159
161
  const {
@@ -29,13 +29,19 @@ const fixData = (statisticData, countryMap, chartType) => {
29
29
  }
30
30
  const value = item.value;
31
31
  if (name_cn && name) {
32
- statisticNewData.push({
33
- name_cn,
34
- name,
35
- nameType,
36
- value: value || 0,
37
- formatted_value: item.formatted_value
38
- });
32
+ const existedData = statisticNewData.find(i => i.name === name);
33
+ if (existedData) {
34
+ existedData.value += value;
35
+ existedData.formatted_value = parseInt(existedData.formatted_value) + parseInt(item.formatted_value) + '';
36
+ } else {
37
+ statisticNewData.push({
38
+ name_cn,
39
+ name,
40
+ nameType,
41
+ value: value || 0,
42
+ formatted_value: item.formatted_value + ''
43
+ });
44
+ }
39
45
  if (chartType === CHART_TYPE.WORLD_MAP_BUBBLE) {
40
46
  sum += item.value;
41
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@antv/scale": "0.3.14",
29
- "dtable-ui-component": "^5.1.2",
29
+ "dtable-ui-component": "^5.1.10",
30
30
  "dtable-utils": "~5.0.*",
31
31
  "prop-types": "15.8.1",
32
32
  "react": "^17.0.0",