sea-chart 1.1.25 → 1.1.27

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.
@@ -0,0 +1,107 @@
1
+ import { COLUMNS_ICON_CONFIG } from 'dtable-utils';
2
+ import React, { useEffect, useRef } from 'react';
3
+ import { UncontrolledPopover } from 'reactstrap';
4
+ import isHotkey from 'is-hotkey';
5
+ import intl from '../../../intl';
6
+ import { getEventClassName } from '../../../utils/common-utils';
7
+ import styles from './index.module.css';
8
+ export default function DrillDownFieldsPopover(_ref) {
9
+ let {
10
+ onPopoverToggle,
11
+ columns,
12
+ drillDownFields,
13
+ setDrillDownFields
14
+ } = _ref;
15
+ const isAllColumnsVisible = columns.every(c => drillDownFields.includes(c.key));
16
+ const toggleAllColumnsVisible = () => {
17
+ const visible = !isAllColumnsVisible;
18
+ const newDrillDownFields = visible ? columns.map(c => c.key) : ['0000'];
19
+ if (!newDrillDownFields.includes('0000')) newDrillDownFields.push('0000');
20
+ setDrillDownFields(newDrillDownFields);
21
+ };
22
+ const changeColumnVisible = (columnKey, visible) => {
23
+ if (visible) {
24
+ setDrillDownFields(drillDownFields.concat(columnKey));
25
+ } else {
26
+ setDrillDownFields(drillDownFields.filter(key => key !== columnKey));
27
+ }
28
+ };
29
+ const popoverRef = useRef(null);
30
+ const onPopoverInsideClick = e => {
31
+ e.stopPropagation();
32
+ };
33
+ useEffect(() => {
34
+ const hidePopover = e => {
35
+ if (popoverRef.current && !getEventClassName(e).includes('popover') && !popoverRef.current.contains(e.target)) {
36
+ onPopoverToggle(false);
37
+ e.preventDefault();
38
+ e.stopPropagation();
39
+ }
40
+ };
41
+ const onHotKey = e => {
42
+ if (isHotkey('esc', e)) {
43
+ e.preventDefault();
44
+ onPopoverToggle(false);
45
+ }
46
+ };
47
+ document.addEventListener('click', hidePopover);
48
+ document.addEventListener('keydown', onHotKey);
49
+ return () => {
50
+ document.removeEventListener('click', hidePopover);
51
+ document.removeEventListener('keydown', onHotKey);
52
+ };
53
+ }, [onPopoverToggle]);
54
+ return /*#__PURE__*/React.createElement(UncontrolledPopover, {
55
+ placement: "left",
56
+ isOpen: true,
57
+ target: "set-drill-down-fields",
58
+ fade: false,
59
+ hideArrow: true,
60
+ className: styles['drill-down-fields-popover'],
61
+ boundariesElement: document.body
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ ref: popoverRef,
64
+ onClick: onPopoverInsideClick
65
+ }, /*#__PURE__*/React.createElement("div", {
66
+ className: styles['drill-down-fields-container']
67
+ }, /*#__PURE__*/React.createElement("table", {
68
+ className: styles['drill-down-fields-table']
69
+ }, /*#__PURE__*/React.createElement("thead", {
70
+ className: styles['drill-down-fields-table-header']
71
+ }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
72
+ width: "80%",
73
+ className: styles['text-truncate']
74
+ }, ''), /*#__PURE__*/React.createElement("th", {
75
+ width: "20%",
76
+ className: "".concat(styles['column-checkbox'], " pr-3")
77
+ }, intl.get('Visible')))), /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", {
78
+ className: styles['drill-down-fields-row']
79
+ }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", {
80
+ className: styles['drill-down-fields-select-all']
81
+ }, intl.get('Select_all'))), /*#__PURE__*/React.createElement("td", {
82
+ className: "".concat(styles['column-checkbox'], " pr-3")
83
+ }, /*#__PURE__*/React.createElement("input", {
84
+ type: "checkbox",
85
+ checked: isAllColumnsVisible,
86
+ onChange: toggleAllColumnsVisible
87
+ }))), columns.map(column => {
88
+ const visibleChecked = drillDownFields.includes(column.key);
89
+ const checkedByDefault = column.key === '0000';
90
+ return /*#__PURE__*/React.createElement("tr", {
91
+ key: column.key,
92
+ className: styles['drill-down-fields-row']
93
+ }, /*#__PURE__*/React.createElement("td", {
94
+ className: "pl-5 text-truncate",
95
+ title: column.name
96
+ }, /*#__PURE__*/React.createElement("i", {
97
+ className: "".concat(COLUMNS_ICON_CONFIG[column.type], " mr-2 ").concat(styles['drill-down-fields-icon'])
98
+ }), /*#__PURE__*/React.createElement("span", null, column.name)), /*#__PURE__*/React.createElement("td", {
99
+ className: "".concat(styles['column-checkbox'], " pr-3")
100
+ }, /*#__PURE__*/React.createElement("input", {
101
+ disabled: checkedByDefault,
102
+ type: "checkbox",
103
+ checked: visibleChecked,
104
+ onChange: () => changeColumnVisible(column.key, !visibleChecked)
105
+ })));
106
+ }))))));
107
+ }
@@ -0,0 +1,50 @@
1
+
2
+ .drill-down-fields-popover :global(.popover) {
3
+ max-width: 410px;
4
+ }
5
+
6
+ .drill-down-fields-container {
7
+ max-height: 380px;
8
+ display: flex;
9
+ flex-direction: column;
10
+ overflow: auto;
11
+ }
12
+
13
+ .drill-down-fields-table {
14
+ width: 100%;
15
+ line-height: 30px;
16
+ color: #212529;
17
+ font-size: 14px;
18
+ table-layout: fixed;
19
+ }
20
+
21
+ .drill-down-fields-table-header {
22
+ background-color: #f7f9fe;
23
+ border-top: 1px solid #eee;
24
+ line-height: 30px;
25
+ font-size: 14px;
26
+ }
27
+
28
+ .column-checkbox {
29
+ text-align: center;
30
+ }
31
+
32
+ .drill-down-fields-row {
33
+ border-bottom: 1px solid #eee;
34
+ }
35
+
36
+ .drill-down-fields-select-all {
37
+ margin-left: 1.5rem
38
+ }
39
+
40
+ .drill-down-fields-icon {
41
+ font-size: 14px;
42
+ color: #666;
43
+ }
44
+
45
+ table td {
46
+ padding: 0.5rem 0.1875rem;
47
+ border-bottom: 1px solid #eee;
48
+ font-size: 0.875rem;
49
+ word-break: break-all;
50
+ }
@@ -0,0 +1,30 @@
1
+ import React, { useState } from 'react';
2
+ import DrillDownFieldsPopover from '../drill-down-fields-popover';
3
+ import intl from '../../../intl';
4
+ import styles from './index.module.css';
5
+ export default function DrillDownFieldSettings(_ref) {
6
+ let {
7
+ columns,
8
+ drillDownFields,
9
+ setDrillDownFields
10
+ } = _ref;
11
+ const [isFieldsPopoverShow, setFieldsPopoverShow] = useState(false);
12
+ const handleFieldsPopoverShow = e => {
13
+ // stop event propagation to prevent tragger click handler inside of the popover
14
+ // otherwise popover close handler will be triggered immediately after component mounted becase click event is still bubbling
15
+ e.stopPropagation();
16
+ setFieldsPopoverShow(!isFieldsPopoverShow);
17
+ };
18
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
19
+ className: styles['drill-down-fields-btn'],
20
+ id: "set-drill-down-fields",
21
+ onClick: handleFieldsPopoverShow
22
+ }, /*#__PURE__*/React.createElement("span", {
23
+ className: "ml-2"
24
+ }, intl.get('Field_settings'))), isFieldsPopoverShow && /*#__PURE__*/React.createElement(DrillDownFieldsPopover, {
25
+ onPopoverToggle: setFieldsPopoverShow,
26
+ columns: columns,
27
+ drillDownFields: drillDownFields,
28
+ setDrillDownFields: setDrillDownFields
29
+ }));
30
+ }
@@ -0,0 +1,16 @@
1
+ .drill-down-fields-btn {
2
+ align-items: center;
3
+ border: 1px solid #acacac;
4
+ border-radius: 4px;
5
+ cursor: pointer;
6
+ display: flex;
7
+ height: 32px;
8
+ justify-content: center;
9
+ margin-top: 10px;
10
+ -webkit-user-select: none;
11
+ user-select: none;
12
+ }
13
+
14
+ .drill-down-fields-btn:hover {
15
+ background-color: #eee;
16
+ }
@@ -0,0 +1,25 @@
1
+ import _CollapsibleSettingLayout from "dtable-ui-component/lib/CollapsibleSettingLayout";
2
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
3
+ import React from 'react';
4
+ import intl from '../../intl';
5
+ import DrillDownFieldSettings from './drill-down-fields-settings';
6
+ export default function DrillDownSettings(_ref) {
7
+ let {
8
+ columns,
9
+ drillDownStatus,
10
+ toggleDrillDownStatus,
11
+ drillDownFields,
12
+ setDrillDownFields
13
+ } = _ref;
14
+ return /*#__PURE__*/React.createElement(_CollapsibleSettingLayout, {
15
+ title: intl.get('Drill_down_settings')
16
+ }, /*#__PURE__*/React.createElement(_DTableSwitch, {
17
+ onChange: toggleDrillDownStatus,
18
+ checked: drillDownStatus,
19
+ placeholder: intl.get('Enable_drill_down_feature')
20
+ }), drillDownStatus && /*#__PURE__*/React.createElement(DrillDownFieldSettings, {
21
+ columns: columns,
22
+ drillDownFields: drillDownFields,
23
+ setDrillDownFields: setDrillDownFields
24
+ }));
25
+ }
@@ -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';
@@ -34,7 +35,8 @@ class StatisticRecordDialog extends React.Component {
34
35
  } = statisticRecord || {};
35
36
  const {
36
37
  table_id,
37
- view_id
38
+ view_id,
39
+ drill_down_fields
38
40
  } = chart.config;
39
41
  this.table = getTableById(tables, table_id);
40
42
  const currentElementId = chart.id;
@@ -43,7 +45,7 @@ class StatisticRecordDialog extends React.Component {
43
45
  this.isArchiveView = isArchiveView(this.view);
44
46
  }
45
47
  this.unShowColumnKeyList = this.getUnShowColumnKeyList(this.view);
46
- this.renderedColumns = this.getRenderedColumns(this.table);
48
+ this.renderedColumns = this.getRenderedColumns(this.table, drill_down_fields, isCalculateByView);
47
49
  if (this.isArchiveView || !isCalculateByView || statisticRecord.isQueryBySql) {
48
50
  var _context$api, _context$api2;
49
51
  if ((_context$api = context.api) === null || _context$api === void 0 ? void 0 : _context$api.customQueryRows) {
@@ -99,11 +101,18 @@ class StatisticRecordDialog extends React.Component {
99
101
  } = view;
100
102
  return [firstColumnKey, ...hidden_columns];
101
103
  };
102
- this.getRenderedColumns = table => {
104
+ this.getRenderedColumns = (table, drillDownFields, isCalculateByView) => {
103
105
  const {
104
106
  columns
105
107
  } = table;
106
- return columns.filter(column => !this.unShowColumnKeyList.includes(column.key));
108
+ const renderedColumns = columns.filter(column => !this.unShowColumnKeyList.includes(column.key));
109
+ // in dtable-statistics always show all columns
110
+ if (isCalculateByView || !drillDownFields) {
111
+ // use all columns as default
112
+ return renderedColumns;
113
+ } else {
114
+ return renderedColumns.filter(column => drillDownFields.includes(column.key));
115
+ }
107
116
  };
108
117
  this.processDrilledRows = drilledRows => {
109
118
  const {
@@ -280,7 +289,12 @@ class StatisticRecordDialog extends React.Component {
280
289
  searchedRowsIds
281
290
  } = this.state;
282
291
  const searchedRows = this.getRowsByIds(searchedRowsIds);
283
- if (searchedRows.length === 0) return null;
292
+ if (searchedRows.length === 0) return /*#__PURE__*/React.createElement("div", {
293
+ className: "w-100 h-100"
294
+ }, /*#__PURE__*/React.createElement(_DTableEmptyTip, {
295
+ src: "".concat(context.getSetting('mediaUrl'), "img/no-items-tip.png"),
296
+ text: intl.get('No_record')
297
+ }));
284
298
  const props = {
285
299
  table: this.table,
286
300
  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,12 @@ 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",
269
+ "Drill_down_settings": "Drilldown-Einstellungen",
270
+ "Enable_drill_down_feature": "Aktivieren Sie die Drilldown-Funktion",
271
+ "Field_settings": "Feldeinstellungen",
272
+ "Select_all": "Alles auswählen",
273
+ "Visible": "Sichtbar"
268
274
  };
269
275
  export default de;
@@ -264,6 +264,12 @@ 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",
269
+ "Drill_down_settings": "Drill down settings",
270
+ "Enable_drill_down_feature": "Enable drill down feature",
271
+ "Field_settings": "Field settings",
272
+ "Select_all": "Select all",
273
+ "Visible": "Visible"
268
274
  };
269
275
  export default en;
@@ -264,6 +264,12 @@ 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",
269
+ "Drill_down_settings": "Drill down settings",
270
+ "Enable_drill_down_feature": "Enable drill down feature",
271
+ "Field_settings": "Field settings",
272
+ "Select_all": "Select all",
273
+ "Visible": "Visible"
268
274
  };
269
275
  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,12 @@ 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",
269
+ "Drill_down_settings": "Paramètres d'exploration",
270
+ "Enable_drill_down_feature": "Activer la fonctionnalité d'exploration vers le bas",
271
+ "Field_settings": "Paramètres de champ",
272
+ "Select_all": "Tout sélectionner",
273
+ "Visible": "Visible"
268
274
  };
269
275
  export default fr;
@@ -264,6 +264,12 @@ 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",
269
+ "Drill_down_settings": "Drill down settings",
270
+ "Enable_drill_down_feature": "Enable drill down feature",
271
+ "Field_settings": "Field settings",
272
+ "Select_all": "Select all",
273
+ "Visible": "Visible"
268
274
  };
269
275
  export default pt;
@@ -264,6 +264,12 @@ 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",
269
+ "Drill_down_settings": "Drill down settings",
270
+ "Enable_drill_down_feature": "Enable drill down feature",
271
+ "Field_settings": "Field settings",
272
+ "Select_all": "Select all",
273
+ "Visible": "Visible"
268
274
  };
269
275
  export default ru;
@@ -264,6 +264,12 @@ 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": "没有记录",
269
+ "Drill_down_settings": "钻取设置",
270
+ "Enable_drill_down_feature": "开启钻取功能",
271
+ "Field_settings": "字段设置",
272
+ "Select_all": "选择全部",
273
+ "Visible": "可见"
268
274
  };
269
275
  export default zh_CN;
@@ -5,5 +5,9 @@ export default class BaseModel {
5
5
  this.table_id = options.table_id || null;
6
6
  this.filters = options.filters || [];
7
7
  this.filter_conjunction = options.filter_conjunction || 'And';
8
+ // set to null to use all columns as default
9
+ this.drill_down_fields = options.drill_down_fields || null;
10
+ // default set to true
11
+ this.drill_down_status = typeof options.drill_down_status === 'boolean' ? options.drill_down_status : true;
8
12
  }
9
13
  }
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { generateChartConfig } from '../../utils';
3
+ import DrillDownSettings from '../../components/drill-down-settings';
3
4
  import StatisticType from './chart-type';
4
5
  import SelectTable from './select-table';
5
6
  import SelectView from './select-view';
@@ -12,10 +13,10 @@ const CommonDataSettings = _ref => {
12
13
  tables,
13
14
  onChange
14
15
  } = _ref;
16
+ const {
17
+ config
18
+ } = chart;
15
19
  const onTableChange = useCallback(option => {
16
- const {
17
- config
18
- } = chart;
19
20
  const {
20
21
  table_id
21
22
  } = config;
@@ -26,11 +27,8 @@ const CommonDataSettings = _ref => {
26
27
  filters: [],
27
28
  filter_conjunction: 'And'
28
29
  });
29
- }, [chart, onChange]);
30
+ }, [config, onChange]);
30
31
  const onViewChange = useCallback(option => {
31
- const {
32
- config
33
- } = chart;
34
32
  const {
35
33
  view_id
36
34
  } = config;
@@ -39,13 +37,30 @@ const CommonDataSettings = _ref => {
39
37
  onChange && onChange({
40
38
  view_id: selectedViewId
41
39
  });
42
- }, [chart, onChange]);
40
+ }, [config, onChange]);
41
+ const onDrillDownStatusChange = useCallback(event => {
42
+ onChange && onChange({
43
+ drill_down_status: event.target.checked
44
+ });
45
+ }, [onChange]);
46
+ const onDrillDownFieldChange = useCallback(fields => {
47
+ onChange && onChange({
48
+ drill_down_fields: fields
49
+ });
50
+ }, [onChange]);
43
51
  const generateConfig = useCallback(config => {
44
52
  return generateChartConfig(config, tables);
45
53
  }, [tables]);
46
54
  const {
47
- table_id
48
- } = chart.config;
55
+ table_id,
56
+ drill_down_status,
57
+ drill_down_fields
58
+ } = config;
59
+ const selectedTable = tables.find(table => table._id === table_id);
60
+ const columns = selectedTable ? selectedTable.columns : [];
61
+ const drillDownStatus = drill_down_status !== undefined && drill_down_status !== null ? drill_down_status : true;
62
+ // use all columns as default
63
+ const drillDownFields = drill_down_fields || columns.map(column => column.key);
49
64
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StatisticType, {
50
65
  chart: chart,
51
66
  generateChartConfig: generateConfig,
@@ -63,7 +78,13 @@ const CommonDataSettings = _ref => {
63
78
  selectedTableId: table_id,
64
79
  selectedViewId: chart.config.view_id,
65
80
  onChange: onViewChange
66
- }), /*#__PURE__*/React.createElement(Divider, null));
81
+ }), /*#__PURE__*/React.createElement(Divider, null), dataSources === 'filter' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DrillDownSettings, {
82
+ columns: columns,
83
+ drillDownStatus: drillDownStatus,
84
+ toggleDrillDownStatus: onDrillDownStatusChange,
85
+ drillDownFields: drillDownFields,
86
+ setDrillDownFields: onDrillDownFieldChange
87
+ }), /*#__PURE__*/React.createElement(Divider, null)));
67
88
  };
68
89
  CommonDataSettings.defaultProps = {
69
90
  dataSources: 'filter'
@@ -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) => {
@@ -1472,19 +1476,14 @@ SQLStatisticsUtils.trendMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
1472
1476
  compareDate,
1473
1477
  comparedDate
1474
1478
  } = getCompareDate(date_granularity);
1475
- for (let index = sqlRows.length - 1; index >= 0; index--) {
1476
- const item = sqlRows[index];
1479
+ for (const item of sqlRows) {
1477
1480
  if (!item[sqlGroupbyColumnKey]) continue;
1478
1481
  const currentDate = item[sqlGroupbyColumnKey] + '';
1479
- if (currentDate && currentDate < comparedDate) {
1480
- break;
1481
- }
1482
1482
  if (currentDate === compareDate) {
1483
1483
  compareValue = item[sqlSummaryColumnKey];
1484
1484
  }
1485
1485
  if (currentDate === comparedDate) {
1486
1486
  comparedValue = item[sqlSummaryColumnKey];
1487
- break;
1488
1487
  }
1489
1488
  }
1490
1489
  }
@@ -2011,7 +2010,7 @@ SQLStatisticsUtils.calculateChart = async (chart, value, callback, sqlRows) => {
2011
2010
  }
2012
2011
 
2013
2012
  // map is special, still need to show map even data is empty
2014
- if (!Array.isArray(sqlRows) || sqlRows.length === 0 && !chartType.includes('map')) {
2013
+ if (!Array.isArray(sqlRows) || sqlRows.length === 0 && !MAP_CHART_TYPES.includes(chartType)) {
2015
2014
  callback && callback('', tipMessage, null);
2016
2015
  return;
2017
2016
  }
@@ -99,8 +99,8 @@ class Funnel extends ChartComponent {
99
99
  }
100
100
  const contentFormatterMap = {
101
101
  [FUNNEL_LABEL_FORMAT.NUMBER]: obj => obj.value,
102
- [FUNNEL_LABEL_FORMAT.PERCENTAGE]: obj => obj.percent + '%',
103
- [FUNNEL_LABEL_FORMAT.NUMBER_AND_PERCENTAGE]: obj => "".concat(obj.value, " (").concat(obj.percent, "%)")
102
+ [FUNNEL_LABEL_FORMAT.PERCENTAGE]: obj => ((obj === null || obj === void 0 ? void 0 : obj.percent) || 0) + '%',
103
+ [FUNNEL_LABEL_FORMAT.NUMBER_AND_PERCENTAGE]: obj => "".concat(obj.value, " (").concat((obj === null || obj === void 0 ? void 0 : obj.percent) || 0, "%)")
104
104
  };
105
105
  this.chart.axis(false);
106
106
  this.chart.coordinate('rect').transpose().scale(1, -1);
@@ -149,10 +149,11 @@ class Funnel extends ChartComponent {
149
149
  });
150
150
  });
151
151
  if (funnel_show_overall_rate) {
152
+ var _sortedData;
152
153
  this.chart.annotation().text({
153
154
  top: true,
154
155
  position: ['50.5%', '-4%'],
155
- content: sortedData[sortedData.length - 1].percent + '%',
156
+ content: (((_sortedData = sortedData[sortedData.length - 1]) === null || _sortedData === void 0 ? void 0 : _sortedData.percent) || 0) + '%',
156
157
  style: {
157
158
  fontSize: funnel_label_font_size,
158
159
  stroke: null,
@@ -289,7 +289,16 @@ const Wrapper = _ref => {
289
289
  }
290
290
  }
291
291
  };
292
- return /*#__PURE__*/React.createElement(React.Fragment, null, renderChart(), isStatisticRecordsDialogShow && /*#__PURE__*/React.createElement(StatisticRecordDialog, {
292
+ const {
293
+ config
294
+ } = chart;
295
+ const {
296
+ drill_down_status
297
+ } = config;
298
+ const drillDownStatus = drill_down_status !== undefined && drill_down_status !== null ? drill_down_status : true;
299
+ // in dtable-statistics always support drill down
300
+ const supportDrillDown = isCalculateByView ? true : drillDownStatus;
301
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderChart(), isStatisticRecordsDialogShow && supportDrillDown && /*#__PURE__*/React.createElement(StatisticRecordDialog, {
293
302
  chartRecordsParams: {
294
303
  statisticRecord: {
295
304
  ...statisticRecords
@@ -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.25",
3
+ "version": "1.1.27",
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",