sea-chart 0.0.28-beta → 0.0.28

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.
@@ -245,7 +245,6 @@ const en = {
245
245
  'Line_type': 'Line type',
246
246
  'Summarize_description': 'Count the sum, maximum, minimum, average, or number of distinct values of records based on a field',
247
247
  'Count_description': 'Count the number of records based on data settings',
248
- 'Display_empty_when_data_is_zero': 'Display empty when data is zero',
249
- 'Count_description': 'Count the number of records based on data settings'
248
+ 'Display_empty_when_data_is_zero': 'Display empty when data is zero'
250
249
  };
251
250
  export default en;
@@ -168,7 +168,6 @@ const es = {
168
168
  'Line_type': 'Line type',
169
169
  'Summarize_description': 'Count the sum, maximum, minimum, average, or number of distinct values of records based on a field',
170
170
  'Count_description': 'Count the number of records based on data settings',
171
- 'Display_empty_when_data_is_zero': 'Display empty when data is zero',
172
- 'Count_description': 'Count the number of records based on data settings'
171
+ 'Display_empty_when_data_is_zero': 'Display empty when data is zero'
173
172
  };
174
173
  export default es;
@@ -168,7 +168,6 @@ const fr = {
168
168
  'Line_type': 'Line type',
169
169
  'Summarize_description': 'Count the sum, maximum, minimum, average, or number of distinct values of records based on a field',
170
170
  'Count_description': 'Count the number of records based on data settings',
171
- 'Display_empty_when_data_is_zero': 'Display empty when data is zero',
172
- 'Count_description': 'Count the number of records based on data settings'
171
+ 'Display_empty_when_data_is_zero': 'Display empty when data is zero'
173
172
  };
174
173
  export default fr;
@@ -168,7 +168,6 @@ const pt = {
168
168
  'Line_type': 'Line type',
169
169
  'Summarize_description': 'Count the sum, maximum, minimum, average, or number of distinct values of records based on a field',
170
170
  'Count_description': 'Count the number of records based on data settings',
171
- 'Display_empty_when_data_is_zero': 'Display empty when data is zero',
172
- 'Count_description': 'Count the number of records based on data settings'
171
+ 'Display_empty_when_data_is_zero': 'Display empty when data is zero'
173
172
  };
174
173
  export default pt;
@@ -168,7 +168,6 @@ const ru = {
168
168
  'Line_type': 'Line type',
169
169
  'Summarize_description': 'Count the sum, maximum, minimum, average, or number of distinct values of records based on a field',
170
170
  'Count_description': 'Count the number of records based on data settings',
171
- 'Display_empty_when_data_is_zero': 'Display empty when data is zero',
172
- 'Count_description': 'Count the number of records based on data settings'
171
+ 'Display_empty_when_data_is_zero': 'Display empty when data is zero'
173
172
  };
174
173
  export default ru;
@@ -245,7 +245,6 @@ const zh_CN = {
245
245
  'Line_type': '线型',
246
246
  'Summarize_description': '按照一个字段计算记录的总和、最大值、最小值或者平均值',
247
247
  'Count_description': '根据数据设置计算记录数量',
248
- 'Display_empty_when_data_is_zero': '数据为零时留空',
249
- 'Count_description': '根据数据设置计算记录数量'
248
+ 'Display_empty_when_data_is_zero': '数据为零时留空'
250
249
  };
251
250
  export default zh_CN;
@@ -1,5 +1,5 @@
1
1
  import { isNumericColumn, getTableById, getTableColumnByKey } from 'dtable-utils';
2
- import { CHART_SUMMARY_CALCULATION_METHOD, CHART_TYPE, CHART_Y_GROUP_TYPE } from '../constants';
2
+ import { CHART_SUMMARY_TYPE, CHART_TYPE } from '../constants';
3
3
  import BaseModel from './base-model';
4
4
  class BasicNumberCard extends BaseModel {
5
5
  constructor(options, tables) {
@@ -16,8 +16,7 @@ class BasicNumberCard extends BaseModel {
16
16
  this.numeric_column_key = null;
17
17
  }
18
18
  }
19
- this.summary_type = options.x_axis_summary_type || CHART_Y_GROUP_TYPE.COUNT;
20
- this.summary_method = options.y_axis_summary_method || CHART_SUMMARY_CALCULATION_METHOD[0];
19
+ this.summary_method = options.y_axis_summary_method || CHART_SUMMARY_TYPE.ROW_COUNT;
21
20
  this.font_size = options.font_size || 40;
22
21
  this.font_color = options.font_color;
23
22
  this.label_font_size = options.label_font_size || 12;
@@ -4,7 +4,7 @@ import { COLUMNS_ICON_CONFIG, getTableById } from 'dtable-utils';
4
4
  import DTableSelect from "dtable-ui-component/lib/DTableSelect";
5
5
  import CommonDataSettings from '../widgets/common-data-settings';
6
6
  import { BaseUtils } from '../../utils';
7
- import { CHART_SUMMARY_SHOW, CHART_SUMMARY_CALCULATION_METHOD, CHART_SUPPORT_COLUMNS, CHART_Y_GROUP_TYPE } from '../../constants';
7
+ import { CHART_SUMMARY_SHOW, CHART_SUMMARY_CALCULATION_METHOD, CHART_SUPPORT_COLUMNS, BASIC_NUMBER_CARD_CALCULATION_METHOD } from '../../constants';
8
8
  import intl from '../../intl';
9
9
  const DataSettings = _ref => {
10
10
  let {
@@ -14,7 +14,7 @@ const DataSettings = _ref => {
14
14
  onChange
15
15
  } = _ref;
16
16
  const summaryMethodsOptions = useMemo(() => {
17
- const numberCardSummaryMethod = [...CHART_SUMMARY_CALCULATION_METHOD];
17
+ const numberCardSummaryMethod = [BASIC_NUMBER_CARD_CALCULATION_METHOD, ...CHART_SUMMARY_CALCULATION_METHOD];
18
18
  return numberCardSummaryMethod.map(method => {
19
19
  return {
20
20
  label: /*#__PURE__*/React.createElement("span", {
@@ -24,21 +24,6 @@ const DataSettings = _ref => {
24
24
  };
25
25
  });
26
26
  }, []);
27
- const summaryTypeOptions = [{
28
- value: CHART_Y_GROUP_TYPE.COUNT,
29
- label: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
30
- className: "select-module select-module-name ml-0"
31
- }, intl.get(CHART_SUMMARY_SHOW['count'])), /*#__PURE__*/React.createElement("div", {
32
- className: "summary-type-explanation"
33
- }, intl.get('Count_description')))
34
- }, {
35
- value: CHART_Y_GROUP_TYPE.SINGLE_NUMERIC_COLUMN,
36
- label: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
37
- className: "select-module select-module-name ml-0"
38
- }, intl.get(CHART_SUMMARY_SHOW['advanced'])), /*#__PURE__*/React.createElement("div", {
39
- className: "summary-type-explanation"
40
- }, intl.get('Summarize_description')))
41
- }];
42
27
  const selectedTable = useMemo(() => {
43
28
  const {
44
29
  table_id: selectedTableId
@@ -78,19 +63,6 @@ const DataSettings = _ref => {
78
63
  }
79
64
  }, ...options];
80
65
  }, [numericColumns]);
81
- const onSummaryTypeChange = useCallback(option => {
82
- const {
83
- config
84
- } = chart;
85
- const {
86
- summary_type
87
- } = config;
88
- const newSummaryType = option.value;
89
- if (newSummaryType === summary_type) return;
90
- onChange && onChange({
91
- summary_type: newSummaryType
92
- });
93
- }, [chart, onChange]);
94
66
  const onSelectColumnChange = useCallback(option => {
95
67
  const {
96
68
  config
@@ -120,19 +92,23 @@ const DataSettings = _ref => {
120
92
  const getSelectedMethodOption = useCallback((method, summaryMethodsOptions) => {
121
93
  return summaryMethodsOptions.find(m => m.value === method) || summaryMethodsOptions[0];
122
94
  }, []);
123
- const selectedSummaryTypeOption = summaryTypeOptions.find(option => option.value === chart.config.summary_type) || summaryTypeOptions[0];
124
- const isSummarizeAField = chart.config.summary_type === CHART_Y_GROUP_TYPE.SINGLE_NUMERIC_COLUMN;
125
- const {
126
- summary_method
127
- } = chart.config;
128
- const selectedMethodOption = getSelectedMethodOption(summary_method, summaryMethodsOptions);
129
- let selectedColumnOption;
130
- if (isSummarizeAField) {
95
+ const renderSummaryMethod = useCallback(() => {
131
96
  const {
132
- config
133
- } = chart;
134
- selectedColumnOption = numericColumnOptions.find(option => option.value.key === config.numeric_column_key) || numericColumnOptions[0];
135
- }
97
+ summary_method
98
+ } = chart.config;
99
+ const selectedMethodOption = getSelectedMethodOption(summary_method, summaryMethodsOptions);
100
+ return /*#__PURE__*/React.createElement("div", {
101
+ className: "dtable-plugin-stat-parameter-item"
102
+ }, /*#__PURE__*/React.createElement("label", null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
103
+ value: selectedMethodOption,
104
+ onChange: onSelectSummaryMethod,
105
+ options: summaryMethodsOptions
106
+ }));
107
+ }, [chart, getSelectedMethodOption, onSelectSummaryMethod, summaryMethodsOptions]);
108
+ const {
109
+ config
110
+ } = chart;
111
+ const selectedColumnOption = numericColumnOptions.find(option => option.value.key === config.numeric_column_key) || numericColumnOptions[0];
136
112
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CommonDataSettings, {
137
113
  dataSources: dataSources,
138
114
  chart: chart,
@@ -140,26 +116,13 @@ const DataSettings = _ref => {
140
116
  onChange: onChange
141
117
  }), /*#__PURE__*/React.createElement(FormGroup, {
142
118
  className: "sea-chart-parameter-item"
143
- }, /*#__PURE__*/React.createElement("label", null, intl.get('Summary_type')), /*#__PURE__*/React.createElement(DTableSelect, {
144
- classNamePrefix: "chart-summary-types",
145
- value: selectedSummaryTypeOption,
146
- options: summaryTypeOptions,
147
- placeholder: intl.get('Select_a_column'),
148
- onChange: onSummaryTypeChange
149
- })), isSummarizeAField && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
150
- className: "sea-chart-parameter-item"
151
- }, /*#__PURE__*/React.createElement("label", null, intl.get('Summary_field')), /*#__PURE__*/React.createElement(DTableSelect, {
119
+ }, /*#__PURE__*/React.createElement("label", null, intl.get('Statistic_field')), /*#__PURE__*/React.createElement(DTableSelect, {
152
120
  value: selectedColumnOption,
153
121
  options: numericColumnOptions,
122
+ placeholder: intl.get('Select_a_column'),
154
123
  onChange: onSelectColumnChange
155
124
  })), /*#__PURE__*/React.createElement(FormGroup, {
156
125
  className: "sea-chart-parameter-item"
157
- }, /*#__PURE__*/React.createElement("div", {
158
- className: "dtable-plugin-stat-parameter-item"
159
- }, /*#__PURE__*/React.createElement("label", null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
160
- value: selectedMethodOption,
161
- onChange: onSelectSummaryMethod,
162
- options: summaryMethodsOptions
163
- })))));
126
+ }, renderSummaryMethod()));
164
127
  };
165
128
  export default DataSettings;
@@ -2,12 +2,12 @@ import React, { Component } from 'react';
2
2
  import { FormGroup, Label } from 'reactstrap';
3
3
  import DTableSelect from "dtable-ui-component/lib/DTableSelect";
4
4
  import { COLUMNS_ICON_CONFIG, getTableById } from 'dtable-utils';
5
- import { CHART_Y_GROUP_TYPE, CHART_SUMMARY_SHOW, CHART_SUMMARY_CALCULATION_METHOD, CHART_SUMMARY_TYPE, DATE_GRANULATES, GEOLOCATION_GRANULATES, CHART_DATE_SUMMARY_CALCULATION_METHOD, CHART_SUPPORT_COLUMNS, CHART_TYPE } from '../../constants';
6
- import { BaseUtils } from '../../utils';
7
- import intl from '../../intl';
8
5
  import NumericSummaryItem from './numeric-summary-item';
9
6
  import SummaryMethodSettings from './summary-method-setting';
10
7
  import Groupby from './group-by';
8
+ import { CHART_Y_GROUP_TYPE, CHART_SUMMARY_SHOW, CHART_SUMMARY_CALCULATION_METHOD, CHART_SUMMARY_TYPE, DATE_GRANULATES, GEOLOCATION_GRANULATES, CHART_DATE_SUMMARY_CALCULATION_METHOD, CHART_SUPPORT_COLUMNS, CHART_TYPE } from '../../constants';
9
+ import { BaseUtils } from '../../utils';
10
+ import intl from '../../intl';
11
11
  class YAxisGroupSettings extends Component {
12
12
  constructor(_props) {
13
13
  super(_props);
@@ -20,7 +20,7 @@ class YAxisGroupSettings extends Component {
20
20
  table_id,
21
21
  type
22
22
  } = chart.config;
23
- this.isMapChart = [CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type);
23
+ this.isMapChart = type === CHART_TYPE.MAP || type === CHART_TYPE.MAP_BUBBLE || type === CHART_TYPE.WORLD_MAP || type === CHART_TYPE.WORLD_MAP_BUBBLE;
24
24
  this.selectedTable = getTableById(tables, table_id);
25
25
  };
26
26
  this.initGroupTypeOptions = () => {
@@ -2,7 +2,7 @@ var _class;
2
2
  import shallowEqual from 'shallowequal';
3
3
  import dayjs from 'dayjs';
4
4
  import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString } from 'dtable-utils';
5
- import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE, CHART_Y_GROUP_TYPE } from '../../constants';
5
+ import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE } from '../../constants';
6
6
  import { getClientFormulaDisplayString } from '../cell-format-utils';
7
7
  import { getKnownCollaboratorByEmail, generateDefaultUser, getUsers } from '../collaborator-utils';
8
8
  import { getDateColumnFormat, getColumnByKey } from '../column-utils';
@@ -60,10 +60,6 @@ BaseUtils.isValidExistChart = (tables, chart) => {
60
60
  const table = getTableById(tables, table_id);
61
61
  if (!table) return false;
62
62
  if (config.type === CHART_TYPE.BASIC_NUMBER_CARD) {
63
- const {
64
- summary_type
65
- } = config;
66
- if (summary_type === CHART_Y_GROUP_TYPE.COUNT || !summary_type) return true;
67
63
  const numericColumnKey = config.numeric_column_key;
68
64
  if (!numericColumnKey) return false;
69
65
  return getTableColumnByKey(table, numericColumnKey);
@@ -1,6 +1,6 @@
1
1
  import { CellType, filter2SqlCondition, isNumericColumn, isDateColumn } from 'dtable-utils';
2
2
  import { getSqlGroup } from '../column-utils';
3
- import { CHART_TYPE, DTABLE_DB_SUMMARY_METHOD, CHART_SUMMARY_TYPE, TIME_COLUMN_LIST, Y_AXIS_TYPE_PREFIX, CHART_Y_GROUP_TYPE } from '../../constants';
3
+ import { CHART_TYPE, DTABLE_DB_SUMMARY_METHOD, CHART_SUMMARY_TYPE, TIME_COLUMN_LIST, Y_AXIS_TYPE_PREFIX } from '../../constants';
4
4
  import { fixGeoGranularity } from '../map';
5
5
 
6
6
  /*
@@ -678,10 +678,6 @@ class ChartDataSQL {
678
678
  return "SELECT ".concat(groupby_column_name, " FROM ").concat(this.table_name, " ").concat(this.filter_sql, " GROUP BY ").concat(groupby_column_name, " LIMIT 0, 5000");
679
679
  };
680
680
  this._basic_number_card_chart_statistic_2_sql = () => {
681
- const summary_type = this.chart['summary_type'];
682
- if (summary_type === CHART_Y_GROUP_TYPE.COUNT) {
683
- return "SELECT COUNT(*) FROM ".concat(this.table_name, " ").concat(this.filter_sql, " LIMIT 0, 5000");
684
- }
685
681
  const numeric_column_key = this.chart['numeric_column_key'] || '';
686
682
  let summary_method = this.chart['summary_method'] || '';
687
683
  const numeric_column = this._get_column_by_key(numeric_column_key);
@@ -43,10 +43,6 @@
43
43
  bottom: 8%;
44
44
  }
45
45
 
46
- .sea-chart-formatter .sea-chart-container.plugin-number-card {
47
- bottom: 2%;
48
- }
49
-
50
46
  .sea-chart-formatter .sea-chart-container.show-x-axis-label,
51
47
  .sea-chart-formatter .sea-chart-container.show-horizontal-axis-label {
52
48
  padding-bottom: 20px;
@@ -54,11 +54,9 @@ class BasicNumericCard extends Component {
54
54
  summaryColumn
55
55
  } = this.props;
56
56
  const {
57
- summary_type,
58
57
  summary_method
59
58
  } = chart.config;
60
- // COUNT / SUMMARIZE_A_FIELD
61
- if (summary_type !== BASIC_NUMBER_CARD_CALCULATION_METHOD) {
59
+ if (summary_method !== BASIC_NUMBER_CARD_CALCULATION_METHOD) {
62
60
  const formattedContent = BaseUtils.getSummaryValueDisplayString(summaryColumn, data, summary_method);
63
61
  return formattedContent;
64
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.28beta",
3
+ "version": "0.0.28",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",
@@ -22,7 +22,7 @@
22
22
  "peerDependencies": {
23
23
  "@antv/scale": "0.3.14",
24
24
  "babel-plugin-on-demand-loading": "^0.0.9",
25
- "dtable-ui-component": "4.4.30",
25
+ "dtable-ui-component": "~4.4.*",
26
26
  "dtable-utils": "~4.4.*",
27
27
  "prop-types": "15.8.1",
28
28
  "react": "^17.0.0",