sea-chart 0.0.83 → 0.0.84-alpha.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.
@@ -21,10 +21,14 @@ class ChartModel {
21
21
  font_weight: DEFAULT_CHART_FONT_WEIGHT,
22
22
  horizontal_align: HORIZONTAL_ALIGN.LEFT
23
23
  };
24
+ let tableList = tables;
25
+ if (!Array.isArray(tables)) {
26
+ tableList = [tables];
27
+ }
24
28
  if (options.view_id) {
25
- const table = tables.find(table => table._id === table_id);
29
+ const table = tableList.find(table => table._id === table_id);
26
30
  const currentView = table === null || table === void 0 ? void 0 : table.views.find(view => view._id === options.view_id);
27
- this.config.view_id = currentView._id || '0000';
31
+ this.config.view_id = (currentView === null || currentView === void 0 ? void 0 : currentView._id) || '0000';
28
32
  }
29
33
  }
30
34
  }
@@ -5,6 +5,7 @@
5
5
  padding-left: 8px;
6
6
  padding-right: 3px;
7
7
  justify-content: space-between;
8
+ background-color: #fff;
8
9
  }
9
10
 
10
11
  .sea-chart-settings .sea-chart-type-icon-container {
@@ -308,6 +308,14 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue) => {
308
308
  if (currentValue === null && nextValue === null) return null;
309
309
  if (currentValue === null) return nextValue;
310
310
  if (nextValue === null) return currentValue;
311
+ if (currentValue && nextValue) {
312
+ if (summaryMethod === 'MAX') {
313
+ return Math.max(currentValue, nextValue);
314
+ }
315
+ if (summaryMethod === 'MIN') {
316
+ return Math.min(currentValue, nextValue);
317
+ }
318
+ }
311
319
  }
312
320
  return (currentValue - 0 || 0) + (nextValue - 0 || 0);
313
321
  };
@@ -1278,9 +1286,9 @@ BaseUtils.getMean = function (list) {
1278
1286
  BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) => {
1279
1287
  const currentTime = dayjs();
1280
1288
  const days = duration === 'days_30' ? 30 : 7;
1281
- const endDate = currentTime.format('YYYY-MM-DD');
1282
- const middleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
1283
- const startDate = dayjs(middleDate).subtract(days, 'days').format('YYYY-MM-DD');
1289
+ const endDate = currentTime;
1290
+ const middleDate = currentTime.subtract(days, 'days');
1291
+ const startDate = dayjs(middleDate).subtract(days, 'days');
1284
1292
  let compareValue = [];
1285
1293
  let comparedValue = [];
1286
1294
  if (useDataDb) {
@@ -1288,7 +1296,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
1288
1296
  const days2 = [];
1289
1297
  for (let index = 0; index < result.length; index++) {
1290
1298
  const item = result[index];
1291
- const key = item[dbDateKey];
1299
+ const key = dayjs(item[dbDateKey]);
1292
1300
  if (key >= startDate && key < middleDate) {
1293
1301
  comparedValue.push(item[valueKey]);
1294
1302
  days1.push(key);
@@ -1316,7 +1324,6 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
1316
1324
  // }
1317
1325
  // }
1318
1326
  // }
1319
-
1320
1327
  if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
1321
1328
  comparedValue = _BaseUtils.getSummaryResult(comparedValue, summaryMethod);
1322
1329
  compareValue = _BaseUtils.getSummaryResult(compareValue, summaryMethod);
@@ -5,6 +5,8 @@ import { isArrayCellValue } from '../../cell-value-utils';
5
5
  import { getFormattedLabel, isValidRow } from '../../row-utils';
6
6
  import BaseUtils from '../base-utils';
7
7
  import { summaryMethodColumn2SqlColumn } from '../../sql/column-2-sql-column';
8
+
9
+ // one
8
10
  async function calculateOneDimensionTable(chart, value, _ref) {
9
11
  let {
10
12
  getViewRows,
@@ -56,7 +58,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
56
58
  }
57
59
  }
58
60
  });
59
- const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.key) : [];
61
+ const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.column_key) : [];
60
62
  const statisticColumnKeys = [summary_column_key, ...summary_columns_option_keys];
61
63
  const validStatisticColumnKeys = statisticColumnKeys;
62
64
  let statisticColumns = validStatisticColumnKeys.map(key => {
@@ -70,7 +72,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
70
72
  }
71
73
  Array.isArray(summary_columns) && summary_columns.forEach((option, index) => {
72
74
  if (statisticColumns[index + 1]) {
73
- statisticColumns[index + 1].method = option.method;
75
+ statisticColumns[index + 1].method = option.summary_method;
74
76
  }
75
77
  });
76
78
  const {
@@ -205,6 +207,8 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
205
207
  pivot_columns_total
206
208
  };
207
209
  }
210
+
211
+ // two
208
212
  async function calculateTwoDimensionTable(chart, value, _ref2) {
209
213
  let {
210
214
  getViewRows,
@@ -239,34 +243,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
239
243
  const summaryColumn = getTableColumnByKey(table, summary_column_key);
240
244
  const statRows = await getViewRows(view, table);
241
245
  const formulaRows = await getTableFormulaResults(table, statRows);
242
- const pivot_summary_multiple_columns = [];
243
- Array.isArray(summary_columns) && summary_columns.forEach(item => {
244
- const column = getTableColumnByKey(table, item.column_key);
245
- if (column && isNumericColumn(column)) {
246
- pivot_summary_multiple_columns.push({
247
- key: item.column_key,
248
- type: column.type,
249
- data: column.data,
250
- method: item.summary_method,
251
- column_name: column.name
252
- });
253
- }
254
- });
255
-
256
- // [{key: null}, {key: cell_value}, {key: cell_value}, ...]
257
246
  let pivot_columns = [];
258
-
259
- // [
260
- // {
261
- // name: '',
262
- // cells: {
263
- // [key1]: {rows: [], total: ''},
264
- // [key2]: {rows: [], total: ''},
265
- // [key3]: {rows: [], total: ''},
266
- // }
267
- // },
268
- // ...
269
- // ]
270
247
  let pivot_rows = [];
271
248
  statRows.forEach(row => {
272
249
  const {
@@ -329,9 +306,10 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
329
306
  pivot_columns,
330
307
  pivot_columns_total: new_pivot_columns_total,
331
308
  pivot_table_total,
332
- pivot_summary_multiple_columns,
333
309
  formulaRows,
334
- dimensions: TABLE_DIMENSIONS.TWO
310
+ dimensions: TABLE_DIMENSIONS.TWO,
311
+ summary_columns: [summaryColumn, ...(summary_columns === null || summary_columns === void 0 ? void 0 : summary_columns.map(item => getTableColumnByKey(table, item.column_key)))],
312
+ isSingleNumericColumn: !summary_columns.length ? 'true' : 'false'
335
313
  };
336
314
  }
337
315
  function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow, isIncludeEmpty, dateGranularity, geolocationGranularity, isRowGroupbyColumnDataAsAnArray) {
@@ -434,7 +412,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
434
412
  const nextValue = row[current === null || current === void 0 ? void 0 : current.column.key];
435
413
  const currentValue = Object.values(cells[key].total).find(item => item[2] === columnKey)[1];
436
414
  const computedValue = BaseUtils.getSummaryValue({
437
- summaryMethod: current.summary_method,
415
+ summaryMethod: current.summary_method.toUpperCase(),
438
416
  summaryColumn: current.column
439
417
  }, currentValue, nextValue);
440
418
  const columnName = current.column.name;
@@ -528,21 +506,6 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
528
506
  total
529
507
  });
530
508
  }
531
- function isSameName(prevName, currName) {
532
- if (isNumber(prevName) && isNumber(currName)) {
533
- return prevName === currName;
534
- }
535
- if (!prevName && !currName) {
536
- return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
537
- }
538
- return prevName === currName;
539
- }
540
- function isSameGroup(isColumnDataAsAnArray, source, target) {
541
- if (isColumnDataAsAnArray) {
542
- return (!source || source.length === 0) && !target || source && source.includes(target);
543
- }
544
- return source === null && target === null || source === undefined && target === undefined || source === target;
545
- }
546
509
  function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formula_rows) {
547
510
  let pivot_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
548
511
  let pivot_columns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
@@ -619,6 +582,23 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
619
582
  pivot_table_total
620
583
  };
621
584
  }
585
+
586
+ // utils
587
+ function isSameName(prevName, currName) {
588
+ if (isNumber(prevName) && isNumber(currName)) {
589
+ return prevName === currName;
590
+ }
591
+ if (!prevName && !currName) {
592
+ return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
593
+ }
594
+ return prevName === currName;
595
+ }
596
+ function isSameGroup(isColumnDataAsAnArray, source, target) {
597
+ if (isColumnDataAsAnArray) {
598
+ return (!source || source.length === 0) && !target || source && source.includes(target);
599
+ }
600
+ return source === null && target === null || source === undefined && target === undefined || source === target;
601
+ }
622
602
  function getTotal(summary_column, summary_type, summary_method) {
623
603
  let rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
624
604
  let formula_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
@@ -654,6 +634,7 @@ function getTotal(summary_column, summary_type, summary_method) {
654
634
  total++;
655
635
  }
656
636
  });
637
+ total = getTotalByType(oldTotal, total);
657
638
  return total;
658
639
  }
659
640
  if (summary_column && isDateColumn(summary_column)) {
@@ -711,22 +692,10 @@ function getTotal(summary_column, summary_type, summary_method) {
711
692
  }
712
693
  });
713
694
  if (summary_method === 'Sum') {
714
- if (Array.isArray(oldTotal)) {
715
- const newTotal = JSON.parse(JSON.stringify(oldTotal));
716
- newTotal[0][1] = Number.parseFloat(sum.toFixed(8));
717
- total = newTotal;
718
- } else {
719
- total = Number.parseFloat(sum.toFixed(8));
720
- }
695
+ total = getTotalByType(oldTotal, Number.parseFloat(sum.toFixed(8)));
721
696
  } else if (summary_method === 'Mean') {
722
- if (Array.isArray(oldTotal)) {
723
- const newTotal = JSON.parse(JSON.stringify(oldTotal));
724
- const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
725
- newTotal[0][1] = val;
726
- total = newTotal;
727
- } else {
728
- total = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
729
- }
697
+ const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
698
+ total = getTotalByType(oldTotal, val);
730
699
  }
731
700
  break;
732
701
  }
@@ -759,15 +728,15 @@ function getTotal(summary_column, summary_type, summary_method) {
759
728
  let formulaRow = formula_rows[result._id];
760
729
  if (formulaRow) {
761
730
  if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
762
- total = formulaRow[summary_column_key][0];
731
+ total = getTotalByType(oldTotal, formulaRow[summary_column_key][0]);
763
732
  } else {
764
- total = formulaRow[summary_column_key];
733
+ getTotalByType(oldTotal, formulaRow[summary_column_key]);
765
734
  }
766
735
  } else {
767
- total = null;
736
+ total = getTotalByType(oldTotal, null);
768
737
  }
769
738
  } else {
770
- total = result[summary_column_key];
739
+ total = getTotalByType(oldTotal, result[summary_column_key]);
771
740
  }
772
741
  }
773
742
  break;
@@ -781,7 +750,7 @@ function getTotal(summary_column, summary_type, summary_method) {
781
750
  }
782
751
  // formula_rows result can be '#VALUE!'
783
752
  if (total === '#VALUE!') {
784
- total = 0;
753
+ total = getTotalByType(oldTotal, 0);
785
754
  }
786
755
  return total || 0;
787
756
  }
@@ -831,6 +800,18 @@ function getDateMaxOrMinTotal(dateArr, type) {
831
800
  dateIndex = list.indexOf(dateValue);
832
801
  return dateArr[dateIndex];
833
802
  }
803
+ function getTotalByType(oldTotal, value) {
804
+ let newTotal = '';
805
+ if (Array.isArray(oldTotal)) {
806
+ newTotal = JSON.parse(JSON.stringify(oldTotal));
807
+ newTotal[0][1] = value;
808
+ } else {
809
+ newTotal = value;
810
+ }
811
+ return newTotal;
812
+ }
813
+
814
+ // index
834
815
  function calculator(chart, value, _ref3) {
835
816
  let {
836
817
  getViewRows,
@@ -317,7 +317,7 @@ export const getSqlGroup = (column, groupBy) => {
317
317
  const type = (column === null || column === void 0 ? void 0 : column.type) || '';
318
318
  if (type === CellType.CTIME || type === CellType.MTIME || type === CellType.DATE) {
319
319
  const dateGranularity = (groupBy['date_granularity'] || '').toUpperCase();
320
- if (dateGranularity === 'DAY') {
320
+ if (['DAY', 'DAYS_7', 'DAYS_30'].includes(dateGranularity)) {
321
321
  return "ISODATE(".concat(validColumnName, ")");
322
322
  }
323
323
  if (dateGranularity === 'WEEK') {
@@ -12,6 +12,30 @@ export { getDateColumnFormat, isCheckboxColumn, getColumnByKey, isStatisticMapCo
12
12
  export { generatorKey } from './key-generator';
13
13
  export { translateCalendar } from './date-translate';
14
14
  export { isFunction } from './common-utils';
15
+ export function getMapCanvasStyle(container, ratio) {
16
+ let cWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
17
+ let cHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 200;
18
+ let width, height;
19
+ let containerWidth, containerHeight;
20
+ if (!container) {
21
+ containerWidth = cWidth;
22
+ containerHeight = cHeight;
23
+ } else {
24
+ containerWidth = container.clientWidth;
25
+ containerHeight = container.clientHeight;
26
+ }
27
+ if (containerWidth / containerHeight >= ratio) {
28
+ width = containerHeight * ratio;
29
+ height = containerHeight;
30
+ } else {
31
+ width = containerWidth;
32
+ height = containerWidth / ratio;
33
+ }
34
+ return {
35
+ width,
36
+ height
37
+ };
38
+ }
15
39
  export const getErrorMessage = err => {
16
40
  if (!err.response) {
17
41
  return intl.get('Network_error');
@@ -20,7 +20,7 @@ export const column2SqlColumn = function (column) {
20
20
  case CellType.CTIME:
21
21
  {
22
22
  const validDateGranularity = dateGranularity && dateGranularity.toUpperCase();
23
- if (validDateGranularity === 'DAY') {
23
+ if (['DAY', 'DAYS_7', 'DAYS_30'].includes(validDateGranularity)) {
24
24
  const sqlColumnName = "ISODATE(".concat(validColumnName, ")");
25
25
  return {
26
26
  name: sqlColumnName,
@@ -8,6 +8,7 @@ import { Chart } from '../../utils/custom-g2';
8
8
  import fetchMapJson from '../../services/map-json';
9
9
  import { COLOR_OPTIONS } from '../../constants/color-rules';
10
10
  import context from '../../context';
11
+ import { getMapCanvasStyle } from '../../utils';
11
12
  const CHART_STYLE_CONFIG = {
12
13
  'g2-tooltip': {
13
14
  borderRadius: '2px',
@@ -22,11 +23,15 @@ const getDefaultChartStyleByKey = key => {
22
23
  return CHART_STYLE_CONFIG[key] || {};
23
24
  };
24
25
  function createChart(container) {
26
+ // width / height = 1.5 for chinese map
27
+ const {
28
+ width,
29
+ height
30
+ } = getMapCanvasStyle(container, 1.5);
25
31
  let config = {
26
32
  container: container,
27
- autoFit: true,
28
- width: '100%',
29
- height: '100%'
33
+ width,
34
+ height
30
35
  };
31
36
  return new Chart(config);
32
37
  }
@@ -258,6 +263,20 @@ export default function Map(props) {
258
263
  statisticView.render();
259
264
  return statisticView;
260
265
  }, [bubble_color, data_color, legend_direction, legend_size, summary_column_key, summary_method, summary_type, table_id]);
266
+ useEffect(() => {
267
+ const handleResize = () => {
268
+ const container = chartContainerRef.current;
269
+ const {
270
+ width,
271
+ height
272
+ } = getMapCanvasStyle(container, 1.5);
273
+ chartRef.current.changeSize(width, height);
274
+ };
275
+ window.addEventListener('resize', handleResize);
276
+ return () => {
277
+ window.removeEventListener('resize', handleResize);
278
+ };
279
+ }, []);
261
280
 
262
281
  // used to fetch mapJson data
263
282
  useEffect(() => {
@@ -332,6 +351,11 @@ export default function Map(props) {
332
351
  className: 'statistic-chart-loading-container'
333
352
  }, /*#__PURE__*/React.createElement(_Loading, null)), /*#__PURE__*/React.createElement("div", {
334
353
  className: classnames('sea-chart-container '),
354
+ style: {
355
+ display: 'flex',
356
+ justifyContent: 'center',
357
+ alignItems: 'center'
358
+ },
335
359
  ref: chartContainerRef
336
360
  }));
337
361
  }
@@ -132,9 +132,9 @@ class TwoDimensionTable extends PureComponent {
132
132
  };
133
133
  this.renderEmpty = (summaryColumns, cellIdx) => {
134
134
  if (summaryColumns && (summaryColumns === null || summaryColumns === void 0 ? void 0 : summaryColumns.length) !== 0) {
135
- return summaryColumns === null || summaryColumns === void 0 ? void 0 : summaryColumns.map(() => {
135
+ return summaryColumns.map(item => {
136
136
  return /*#__PURE__*/React.createElement("div", {
137
- key: "table-cell-".concat(cellIdx),
137
+ key: "table-cell-".concat(item.key),
138
138
  className: classnames('pivot-cell', {
139
139
  'pivot-empty-cell': true
140
140
  })
@@ -93,7 +93,7 @@ class Trend extends Component {
93
93
  }, resultText);
94
94
  }
95
95
  if (labelFontSize <= 12) {
96
- if (!result) return '';
96
+ if (!result && result !== 0) return '';
97
97
  return /*#__PURE__*/React.createElement("span", {
98
98
  style: {
99
99
  fontSize: "".concat(labelFontSize, "px"),
@@ -116,7 +116,7 @@ class Trend extends Component {
116
116
  style: {
117
117
  color: "".concat(color)
118
118
  }
119
- }, result ? Number.parseFloat(result * 100).toFixed(2) : '', "%"));
119
+ }, result || result === 0 ? Number.parseFloat(result * 100).toFixed(2) : '', "%"));
120
120
  }
121
121
  const resultContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
122
122
  style: {
@@ -131,7 +131,7 @@ class Trend extends Component {
131
131
  whiteSpace: 'nowrap',
132
132
  marginRight: '16px'
133
133
  }
134
- }, !result ? '' : /*#__PURE__*/React.createElement("i", {
134
+ }, !result && result !== 0 ? '' : /*#__PURE__*/React.createElement("i", {
135
135
  style: {
136
136
  flexShrink: '0',
137
137
  flexBasis: 'auto',
@@ -151,7 +151,7 @@ class Trend extends Component {
151
151
  color: color,
152
152
  marginRight: '0px'
153
153
  }
154
- }, result ? Number.parseFloat(result * 100).toFixed(2) + '%' : '')), /*#__PURE__*/React.createElement("span", {
154
+ }, result || result === 0 ? Number.parseFloat(result * 100).toFixed(2) + '%' : '')), /*#__PURE__*/React.createElement("span", {
155
155
  style: {
156
156
  color: labelFontColor,
157
157
  fontWeight: labelFontWeight,
@@ -3,9 +3,10 @@ import DataSet from '@antv/data-set/lib/index';
3
3
  import { getNumberDisplayString } from 'dtable-utils';
4
4
  import PropTypes from 'prop-types';
5
5
  import { debounce } from 'lodash-es';
6
+ import { Chart } from '@antv/g2';
6
7
  import intl from '../../intl';
7
8
  import fetchMapJson from '../../services/map-json';
8
- import { BaseUtils } from '../../utils';
9
+ import { BaseUtils, getMapCanvasStyle } from '../../utils';
9
10
  import { COLOR_OPTIONS } from '../../constants/color-rules';
10
11
  import { CHART_SUMMARY_TYPE, MAP_LEVEL, CHART_TYPE, TITLE_AMOUNT, DEFAULT_NUMBER_FORMAT_OBJECT } from '../../constants';
11
12
  import context from '../../context';
@@ -16,9 +17,12 @@ class WorldMap extends ChartComponent {
16
17
  constructor(props) {
17
18
  super(props);
18
19
  this.handleResize = () => {
19
- this.chart && this.chart.destroy();
20
- this.createChart();
21
- this.drawChart();
20
+ const container = this.container;
21
+ const {
22
+ width,
23
+ height
24
+ } = getMapCanvasStyle(container, 2.1);
25
+ this.chart && this.chart.changeSize(width, height);
22
26
  };
23
27
  this.queryMapJson = async () => {
24
28
  const mediaUrl = context.getSetting('mediaUrl');
@@ -77,23 +81,20 @@ class WorldMap extends ChartComponent {
77
81
  }
78
82
  return statisticNewData;
79
83
  };
84
+ this.initChart = container => {
85
+ const {
86
+ width,
87
+ height
88
+ } = getMapCanvasStyle(container, 2.1);
89
+ let config = {
90
+ container: container,
91
+ width,
92
+ height
93
+ };
94
+ this.chart = new Chart(config);
95
+ };
80
96
  this.createChart = () => {
81
- const containerWidth = this.container.clientWidth - 40; // 40: padding
82
- const containerHeight = this.container.clientHeight - 40;
83
- let h = containerHeight;
84
- let w = h * (WIDTH / HEIGHT);
85
- if (w > containerWidth) {
86
- w = containerWidth;
87
- h = w * (HEIGHT / WIDTH);
88
- }
89
- const horizontalPadding = (containerWidth - w) / 4;
90
- const leftPadding = horizontalPadding < 20 ? 20 : horizontalPadding;
91
- const appendPadding = [0, horizontalPadding, 0, leftPadding];
92
- this.initChart(this.container, {
93
- appendPadding,
94
- width: containerWidth,
95
- height: containerHeight
96
- });
97
+ this.initChart(this.container);
97
98
  this.chart.on('element:click', e => {
98
99
  const {
99
100
  result
@@ -325,6 +326,8 @@ class WorldMap extends ChartComponent {
325
326
  }
326
327
  componentDidMount() {
327
328
  this.queryMapJson();
329
+ this.debouncedHandleResize = debounce(this.handleResize, 300);
330
+ window.addEventListener('resize', this.debouncedHandleResize);
328
331
  }
329
332
  componentDidUpdate(prevProps) {
330
333
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
@@ -332,8 +335,6 @@ class WorldMap extends ChartComponent {
332
335
  this.createChart();
333
336
  this.drawChart();
334
337
  }
335
- this.debouncedHandleResize = debounce(this.handleResize, 300);
336
- window.addEventListener('resize', this.debouncedHandleResize);
337
338
  }
338
339
  componentWillUnmount() {
339
340
  this.chart && this.chart.destroy();
@@ -341,7 +342,12 @@ class WorldMap extends ChartComponent {
341
342
  }
342
343
  render() {
343
344
  return /*#__PURE__*/React.createElement("div", {
344
- className: "sea-chart-container ",
345
+ className: "sea-chart-container",
346
+ style: {
347
+ display: 'flex',
348
+ justifyContent: 'center',
349
+ alignItems: 'center'
350
+ },
345
351
  ref: ref => this.container = ref
346
352
  });
347
353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.83",
3
+ "version": "0.0.84-alpha.0",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",