sea-chart 0.0.82 → 0.0.83-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.
package/dist/context.js CHANGED
@@ -11,7 +11,7 @@ class Context {
11
11
  onSuccess,
12
12
  onFail
13
13
  } = _ref;
14
- // used custom api to get chart result data
14
+ // use custom api to get chart result data
15
15
  if (this.api.queryChartResult) {
16
16
  return this.api.queryChartResult({
17
17
  chart,
@@ -20,12 +20,12 @@ class Context {
20
20
  });
21
21
  }
22
22
  const table = getTableById(tables, chart.config.table_id);
23
-
24
- // use default view here
23
+ const currentView = table.views.find(view => view._id === chart.config.view_id);
24
+ // use default view
25
25
  const defaultView = table.views.find(view => view._id === '0000');
26
26
  const chartDataSQL = new ChartDataSQL({
27
27
  table,
28
- view: defaultView,
28
+ view: currentView || defaultView,
29
29
  chart
30
30
  });
31
31
  const {
@@ -7,7 +7,8 @@ class ChartModel {
7
7
  const {
8
8
  id,
9
9
  _id,
10
- style_config
10
+ style_config,
11
+ table_id
11
12
  } = options;
12
13
  this.id = id;
13
14
  this.type = 'statistic';
@@ -20,6 +21,11 @@ class ChartModel {
20
21
  font_weight: DEFAULT_CHART_FONT_WEIGHT,
21
22
  horizontal_align: HORIZONTAL_ALIGN.LEFT
22
23
  };
24
+ if (options.view_id) {
25
+ const table = tables.find(table => table._id === table_id);
26
+ 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';
28
+ }
23
29
  }
24
30
  }
25
31
  export default ChartModel;
package/dist/model/map.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
2
- import BaseModel from './base-model';
3
2
  import { isStatisticMapColumn } from '../utils';
4
3
  import { CHART_TYPE, MAP_LEVEL, regions } from '../constants';
4
+ import BaseModel from './base-model';
5
5
  class Map extends BaseModel {
6
6
  constructor(options, tables) {
7
7
  super({
@@ -1,7 +1,7 @@
1
1
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
2
- import BaseModel from './base-model';
3
2
  import { isBoolean, isStatisticMirrorColumn } from '../utils';
4
3
  import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
4
+ import BaseModel from './base-model';
5
5
  class Mirror extends BaseModel {
6
6
  constructor(options, tables) {
7
7
  super({
@@ -1,15 +1,16 @@
1
- import { getTableColumnByKey, isDateColumn } from 'dtable-utils';
1
+ import { getTableById, getTableColumnByKey, isDateColumn } from 'dtable-utils';
2
2
  import { CHART_TYPE, HORIZONTAL_ALIGN } from '../constants';
3
3
  import BaseModel from './base-model';
4
4
  class Trend extends BaseModel {
5
- constructor(options, table) {
5
+ constructor(options, tables) {
6
6
  super({
7
7
  ...options,
8
8
  type: CHART_TYPE.TREND
9
9
  });
10
10
  this.date_column_key = options.x_axis_column_key;
11
11
  this.date_granularity = options.x_axis_date_granularity;
12
- if (this.date_column_key) {
12
+ if (this.date_column_key && this.table_id) {
13
+ const table = getTableById(tables, this.table_id);
13
14
  const column = getTableColumnByKey(table, this.date_column_key);
14
15
  if (!column || !isDateColumn(column)) {
15
16
  this.date_column_key = null;
@@ -1,7 +1,7 @@
1
1
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
2
- import BaseModel from './base-model';
3
2
  import { isStatisticWorldMapColumn } from '../utils';
4
3
  import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
4
+ import BaseModel from './base-model';
5
5
  class WorldMapBubble extends BaseModel {
6
6
  constructor(options, tables) {
7
7
  super({
@@ -1,7 +1,7 @@
1
1
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
2
- import BaseModel from './base-model';
3
2
  import { isStatisticWorldMapColumn } from '../utils';
4
3
  import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
4
+ import BaseModel from './base-model';
5
5
  class WorldMap extends BaseModel {
6
6
  constructor(options, tables) {
7
7
  super({
@@ -38,12 +38,12 @@ export default function ScatterDataSettings(_ref) {
38
38
  };
39
39
  return update;
40
40
  };
41
- const onXAxisColumnChange = e => {
41
+ const onXAxisColumnChange = column => {
42
42
  const update = getNewUpdate(column, 'x_axis_column_key');
43
43
  if (!update) return;
44
44
  onChange && onChange(update);
45
45
  };
46
- const onYAxisColumnChange = e => {
46
+ const onYAxisColumnChange = column => {
47
47
  const update = getNewUpdate(column, 'y_axis_column_key');
48
48
  if (!update) return;
49
49
  onChange && onChange(update);
@@ -53,14 +53,13 @@ export default function ScatterDataSettings(_ref) {
53
53
  x_axis_include_empty_cells: !x_axis_include_empty_cells
54
54
  });
55
55
  };
56
- const onColumnGroupbyColumnChange = e => {
56
+ const onColumnGroupbyColumnChange = column => {
57
57
  const update = getNewUpdate(column, 'column_groupby_column_key');
58
58
  if (!update) return;
59
59
  if (!update['column_groupby_column_key']) {
60
60
  update['date_granularity'] = null;
61
61
  update['geolocation_granularity'] = null;
62
62
  } else {
63
- const column = e.value;
64
63
  const type = column.type;
65
64
  if (DATE_COLUMN_OPTIONS.includes(type)) {
66
65
  update['date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
@@ -31,7 +31,11 @@ const BasicSummary = _ref => {
31
31
  const {
32
32
  columns
33
33
  } = selectedTable;
34
- return columns.filter(column => supportColumnTypes.includes(CellType.NUMBER) && BaseUtils.isNumericSummaryColumn(column) || supportColumnTypes.includes(CellType.DATE) && BaseUtils.isDateSummaryColumn(column));
34
+ return columns.filter(column => {
35
+ const supportNum = supportColumnTypes.includes(CellType.NUMBER) && BaseUtils.isNumericSummaryColumn(column) && column.type !== CellType.DURATION;
36
+ const supportDate = supportColumnTypes.includes(CellType.DATE) && BaseUtils.isDateSummaryColumn(column);
37
+ return supportNum || supportDate;
38
+ });
35
39
  }, [selectedTable, supportColumnTypes]);
36
40
  const numericColumnOptions = useMemo(() => {
37
41
  return numericColumns.map(column => {
@@ -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
  };
@@ -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,
@@ -1692,9 +1692,9 @@ SQLStatisticsUtils.scatterSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, c
1692
1692
  if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows, columnGroupbyColumn, sqlColumnGroupbyColumnKey, 'color');
1693
1693
  const res = [];
1694
1694
  sqlRows.forEach(row => {
1695
- const xValue = row[sqlXColumnKey];
1696
- const yValue = row[sqlYColumnKey];
1697
- const groupby = row[sqlColumnGroupbyColumnKey];
1695
+ const xValue = '' + row[sqlXColumnKey] || intl.get('Empty');
1696
+ const yValue = '' + row[sqlYColumnKey] || intl.get('Empty');
1697
+ const groupby = '' + row[sqlColumnGroupbyColumnKey] || intl.get('Empty');
1698
1698
  res.push({
1699
1699
  name: xValue,
1700
1700
  value: yValue,
@@ -7,7 +7,7 @@ import classNames from 'classnames';
7
7
  import { CellType } from 'dtable-ui-component/lib/constants';
8
8
  import intl from '../../intl';
9
9
  import { sortDataByGroupSum } from '../../utils/column-utils';
10
- import { EMPTY_NAME, CHART_TYPE, CHART_SUMMARY_TYPE, DEFAULT_NUMBER_FORMAT_OBJECT, CHART_THEME_COLOR } from '../../constants';
10
+ import { EMPTY_NAME, CHART_TYPE, CHART_SUMMARY_TYPE, DEFAULT_NUMBER_FORMAT_OBJECT, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
11
11
  import { BaseUtils, isFunction } from '../../utils';
12
12
  import { STACK_AND_PIE_CHART_THEMES_OPTIONS } from '../../constants/color-rules';
13
13
  import ChartComponent from './chart-component';
@@ -167,7 +167,7 @@ class BarGroup extends ChartComponent {
167
167
  },
168
168
  position: type === CHART_TYPE.BAR_STACK ? 'middle' : ''
169
169
  }).position('name*value').size(singleBarWidth).color('group_name*group_color', (group_name, group_color) => {
170
- return useSingleSelectColumnColor ? group_color : this.colorMap[group_name];
170
+ return useSingleSelectColumnColor ? group_color : this.colorMap[group_name] || CHART_STYLE_COLORS[0];
171
171
  }).tooltip('name*value*group_name*raw_name', (name, value, group_name, raw_name) => {
172
172
  return {
173
173
  title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { debounce, maxBy, throttle } from 'lodash-es';
4
4
  import classNames from 'classnames';
5
5
  import { CellType } from 'dtable-ui-component/lib/constants';
6
- import { CHART_TYPE, EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
6
+ import { CHART_TYPE, EMPTY_NAME, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
7
7
  import { BaseUtils, isFunction } from '../../utils';
8
8
  import intl from '../../intl';
9
9
  import { STACK_AND_PIE_CHART_THEMES_OPTIONS } from '../../constants/color-rules';
@@ -118,7 +118,7 @@ class HorizontalBarGroup extends HorizontalComponent {
118
118
  lineWidth: 1
119
119
  }
120
120
  }).position('name*value').size(singleBarWidth).color('group_name*group_color', (group_name, group_color) => {
121
- return useSingleSelectColumnColor ? group_color : this.colorMap[group_name];
121
+ return useSingleSelectColumnColor ? group_color : this.colorMap[group_name] || CHART_STYLE_COLORS[0];
122
122
  }).tooltip('name*value*group_name*raw_name', (name, value, group_name, raw_name) => {
123
123
  return {
124
124
  title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
@@ -262,10 +262,15 @@ export default function Map(props) {
262
262
  // used to fetch mapJson data
263
263
  useEffect(() => {
264
264
  (async () => {
265
- const mediaUrl = context.getSetting('mediaUrl');
266
- const mapJson = await fetchMapJson(mapLevel, mapLocation, mediaUrl);
267
- setMapData(mapJson);
268
- setIsLoading(false);
265
+ try {
266
+ const mediaUrl = context.getSetting('mediaUrl');
267
+ const mapJson = await fetchMapJson(mapLevel, mapLocation, mediaUrl);
268
+ setMapData(mapJson);
269
+ setIsLoading(false);
270
+ } catch (error) {
271
+ console.error(error);
272
+ setIsLoading(false);
273
+ }
269
274
  })();
270
275
  }, [mapLevel, mapLocation]);
271
276
 
@@ -6,11 +6,20 @@ import intl from '../../intl';
6
6
  import { CHART_THEME_COLOR } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  const chartComponent = new ChartComponent();
9
- export function Scatter(props) {
9
+ export function Scatter(_ref) {
10
+ let {
11
+ toggleRecords,
12
+ result: data,
13
+ chart,
14
+ tables,
15
+ globalTheme,
16
+ chartColorTheme
17
+ } = _ref;
10
18
  const chartRef = useRef(chartComponent);
11
19
  const chartContainerRef = useRef(null);
12
20
  useEffect(() => {
13
21
  const currentChart = chartRef.current;
22
+ currentChart.isDestoryed = false;
14
23
 
15
24
  // avoid closure trap
16
25
  function createChart() {
@@ -19,29 +28,18 @@ export function Scatter(props) {
19
28
  appendPadding
20
29
  });
21
30
  currentChart.chart.on('element:click', e => {
22
- props.toggleRecords(e.data.data);
31
+ toggleRecords(e.data.data);
23
32
  });
24
33
  }
25
34
  function drawChart() {
26
- let {
27
- result: data,
28
- chart,
29
- tables
30
- } = props;
31
- data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
32
- if (!Array.isArray(data)) return;
33
- currentChart.loadData(data);
34
- draw(data);
35
+ const newData = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
36
+ if (!Array.isArray(newData)) return;
37
+ currentChart.loadData(newData);
38
+ draw(newData);
35
39
  currentChart.chart.render();
36
40
  currentChart.renderAxisLabel(chart, tables);
37
41
  }
38
42
  function draw(data) {
39
- const {
40
- chart,
41
- globalTheme,
42
- chartColorTheme,
43
- tables
44
- } = props;
45
43
  const theme = CHART_THEME_COLOR[globalTheme];
46
44
  const {
47
45
  label_font_size,
@@ -117,12 +115,11 @@ export function Scatter(props) {
117
115
  createChart();
118
116
  drawChart();
119
117
  return () => {
118
+ if (currentChart.isDestoryed) return;
120
119
  currentChart.chart.destroy();
120
+ currentChart.isDestoryed = true;
121
121
  };
122
- }, [props]);
123
- const {
124
- chart
125
- } = props;
122
+ }, [chart, chartColorTheme, data, globalTheme, tables, toggleRecords]);
126
123
  const showXLabel = chartRef.current.isShowXAxisLabel(chart);
127
124
  const showYLabel = chartRef.current.isShowYAxisLabel(chart);
128
125
  return /*#__PURE__*/React.createElement("div", {
@@ -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.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
  })
@@ -22,15 +22,20 @@ class WorldMap extends ChartComponent {
22
22
  };
23
23
  this.queryMapJson = async () => {
24
24
  const mediaUrl = context.getSetting('mediaUrl');
25
- const mapJson = await fetchMapJson(MAP_LEVEL.WORLD, '', mediaUrl);
26
- this.geoData = mapJson;
27
- this.geoData.features.forEach(item => {
28
- this.countryMap.set(item.properties.name, item.properties.name_cn);
29
- this.countryMap.set(item.properties.name_cn, item.properties.name);
30
- });
31
- this.mapFormattedData = this.fixData(this.props.result);
32
- this.createChart();
33
- this.drawChart();
25
+ try {
26
+ const mapJson = await fetchMapJson(MAP_LEVEL.WORLD, '', mediaUrl);
27
+ this.geoData = mapJson;
28
+ this.geoData.features.forEach(item => {
29
+ this.countryMap.set(item.properties.name, item.properties.name_cn);
30
+ this.countryMap.set(item.properties.name_cn, item.properties.name);
31
+ });
32
+ } catch (error) {
33
+ console.error(error);
34
+ } finally {
35
+ this.mapFormattedData = this.fixData(this.props.result);
36
+ this.createChart();
37
+ this.drawChart();
38
+ }
34
39
  };
35
40
  this.fixData = statisticData => {
36
41
  if (!statisticData) return [];
@@ -128,6 +133,7 @@ class WorldMap extends ChartComponent {
128
133
  });
129
134
  this.chart.axis(false);
130
135
  this.dataSet = new DataSet();
136
+ if (!this.geoData) return;
131
137
 
132
138
  // transform map data
133
139
  const mapData = this.dataSet.createView('mapDataModel').source(this.geoData, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.82",
3
+ "version": "0.0.83-alpha.0",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",