sea-chart 0.0.59 → 0.0.61

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/README.md CHANGED
@@ -28,6 +28,8 @@
28
28
 
29
29
  **注意**:自定义API 的demo,目前不支持修改参数同步更新视图
30
30
 
31
+ **注意**:默认 webpack-dev-server 会打开 127.0.0.1:9001 并出错,需要手动改成 127.0.0.1:9000 才能正常访问
32
+
31
33
  ## 使用
32
34
  1. 安装 sea-chart
33
35
  ```
@@ -1,11 +1,15 @@
1
1
  import React from 'react';
2
2
  import View, { defaultProps, propTypes } from '../view';
3
3
  import Settings from '../settings';
4
+ import { settingsDefaultProps, settingsPropTypes } from '../settings';
4
5
  import './index.css';
5
6
  function Editor(props) {
6
7
  return /*#__PURE__*/React.createElement("div", {
7
8
  className: "sea-chart-editor"
8
9
  }, /*#__PURE__*/React.createElement(View, props), /*#__PURE__*/React.createElement(Settings, props, props.children));
9
10
  }
10
- Editor.defaultProps = defaultProps;
11
+ Editor.defaultProps = {
12
+ ...defaultProps,
13
+ ...settingsDefaultProps
14
+ };
11
15
  export default Editor;
@@ -1,12 +1,11 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { useCallback } from 'react';
2
3
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
4
  import CommonDataSettings from '../widgets/common-data-settings';
4
5
  import Divider from '../widgets/divider';
5
6
  import GroupBy from '../widgets/group-by';
6
- import Switch from '../widgets/switch';
7
7
  import YAxisGroupSettings from '../widgets/y-axis-group-settings';
8
8
  import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
9
- import { eventStopPropagation } from '../../utils';
10
9
  import intl from '../../intl';
11
10
  const DataSettings = _ref => {
12
11
  let {
@@ -17,14 +16,13 @@ const DataSettings = _ref => {
17
16
  xLabel,
18
17
  yLabel
19
18
  } = _ref;
20
- const onXAxisColumnChange = useCallback(option => {
19
+ const onXAxisColumnChange = useCallback(column => {
21
20
  const {
22
21
  config
23
22
  } = chart;
24
23
  const {
25
24
  x_axis_column_key
26
25
  } = config;
27
- const column = option.value;
28
26
  const {
29
27
  key: newXAxisColumnKey,
30
28
  type
@@ -86,7 +84,6 @@ const DataSettings = _ref => {
86
84
  });
87
85
  }, [chart, onChange]);
88
86
  const onIncludeEmptyChange = useCallback(event => {
89
- eventStopPropagation(event);
90
87
  const {
91
88
  config
92
89
  } = chart;
@@ -123,8 +120,7 @@ const DataSettings = _ref => {
123
120
  onGroupByChange: onXAxisColumnChange,
124
121
  onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
125
122
  onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
126
- }), /*#__PURE__*/React.createElement(Switch, {
127
- key: "x_axis_include_empty_cells",
123
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
128
124
  checked: x_axis_include_empty_cells,
129
125
  placeholder: intl.get('Include_empty'),
130
126
  onChange: onIncludeEmptyChange
@@ -1,13 +1,12 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { useCallback } from 'react';
2
3
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
4
  import intl from '../../intl';
4
5
  import CommonDataSettings from '../widgets/common-data-settings';
5
6
  import Divider from '../widgets/divider';
6
7
  import GroupBy from '../widgets/group-by';
7
- import Switch from '../widgets/switch';
8
8
  import BasicSummary from '../widgets/basic-summary';
9
9
  import DataSort from '../widgets/data-sort';
10
- import { eventStopPropagation } from '../../utils';
11
10
  import { CHART_SUMMARY_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, CHART_SUMMARY_TYPES, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, CHART_TYPE } from '../../constants';
12
11
  const DataSettings = _ref => {
13
12
  let {
@@ -18,14 +17,13 @@ const DataSettings = _ref => {
18
17
  yLabel,
19
18
  onChange
20
19
  } = _ref;
21
- const onXAxisColumnChange = useCallback(option => {
20
+ const onXAxisColumnChange = useCallback(column => {
22
21
  const {
23
22
  config
24
23
  } = chart;
25
24
  const {
26
25
  x_axis_column_key
27
26
  } = config;
28
- const column = option.value;
29
27
  const {
30
28
  key: newXAxisColumnKey,
31
29
  type
@@ -87,7 +85,6 @@ const DataSettings = _ref => {
87
85
  });
88
86
  }, [chart, onChange]);
89
87
  const onIncludeEmptyChange = useCallback(event => {
90
- eventStopPropagation(event);
91
88
  const {
92
89
  config
93
90
  } = chart;
@@ -137,8 +134,7 @@ const DataSettings = _ref => {
137
134
  onGroupByChange: onXAxisColumnChange,
138
135
  onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
139
136
  onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
140
- }), /*#__PURE__*/React.createElement(Switch, {
141
- key: "x_axis_include_empty_cells",
137
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
142
138
  checked: x_axis_include_empty_cells,
143
139
  placeholder: intl.get('Include_empty'),
144
140
  onChange: onIncludeEmptyChange
@@ -1,9 +1,9 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { useCallback } from 'react';
2
3
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
4
  import CommonDataSettings from '../widgets/common-data-settings';
4
5
  import Divider from '../widgets/divider';
5
6
  import GroupBy from '../widgets/group-by';
6
- import Switch from '../widgets/switch';
7
7
  import SummarySettings from '../widgets/summary-settings';
8
8
  import { eventStopPropagation } from '../../utils';
9
9
  import { CHART_SUMMARY_TYPE, CHART_Y_GROUP_TYPE, CHART_SUMMARY_CALCULATION_METHOD, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, COMBINATION_POSITION } from '../../constants';
@@ -16,14 +16,13 @@ const DataSettings = _ref => {
16
16
  xLabel,
17
17
  onChange
18
18
  } = _ref;
19
- const onXAxisColumnChange = useCallback(option => {
19
+ const onXAxisColumnChange = useCallback(column => {
20
20
  const {
21
21
  config
22
22
  } = chart;
23
23
  const {
24
24
  x_axis_column_key
25
25
  } = config;
26
- const column = option.value;
27
26
  const {
28
27
  key: newXAxisColumnKey,
29
28
  type
@@ -85,7 +84,6 @@ const DataSettings = _ref => {
85
84
  });
86
85
  }, [chart, onChange]);
87
86
  const onIncludeEmptyChange = useCallback(event => {
88
- eventStopPropagation(event);
89
87
  const {
90
88
  config
91
89
  } = chart;
@@ -239,8 +237,7 @@ const DataSettings = _ref => {
239
237
  onGroupByChange: onXAxisColumnChange,
240
238
  onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
241
239
  onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
242
- }), /*#__PURE__*/React.createElement(Switch, {
243
- key: "x_axis_include_empty_cells",
240
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
244
241
  checked: x_axis_include_empty_cells,
245
242
  placeholder: intl.get('Include_empty'),
246
243
  onChange: onIncludeEmptyChange
@@ -1,12 +1,11 @@
1
1
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
2
2
  import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../../constants';
3
3
  import { eventStopPropagation } from '../../../utils';
4
- const getNewUpdate = (option, chart, fieldKey) => {
4
+ const getNewUpdate = (column, chart, fieldKey) => {
5
5
  const {
6
6
  config
7
7
  } = chart;
8
8
  const fieldValue = config[fieldKey];
9
- const column = option.value;
10
9
  const {
11
10
  key
12
11
  } = column;
@@ -16,17 +15,16 @@ const getNewUpdate = (option, chart, fieldKey) => {
16
15
  };
17
16
  return update;
18
17
  };
19
- export const onGroupbyColumnChange = (option, chart, onChange) => {
20
- const update = getNewUpdate(option, chart, 'groupby_column_key');
18
+ export const onGroupbyColumnChange = (column, chart, onChange) => {
19
+ const update = getNewUpdate(column, chart, 'groupby_column_key');
21
20
  if (!update) return;
22
21
  onChange && onChange(update);
23
22
  };
24
23
 
25
24
  // select at bottom of the setting panel
26
- export const onColumnGroupByColumnChange = (option, chart, onChange) => {
27
- const column = option.value;
25
+ export const onColumnGroupByColumnChange = (column, chart, onChange) => {
28
26
  const type = column.type;
29
- const update = getNewUpdate(option, chart, 'column_groupby_column_key');
27
+ const update = getNewUpdate(column, chart, 'column_groupby_column_key');
30
28
  if (!update) return;
31
29
  if (!update['column_groupby_column_key']) {
32
30
  update['date_granularity'] = null;
@@ -54,7 +52,6 @@ export const onColumnGroupByColumnChange = (option, chart, onChange) => {
54
52
  onChange && onChange(update);
55
53
  };
56
54
  export const onIncludeEmptyChange = (event, chart, onChange) => {
57
- eventStopPropagation(event);
58
55
  const {
59
56
  config
60
57
  } = chart;
@@ -1,8 +1,8 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React from 'react';
2
3
  import CommonDataSettings from '../../widgets/common-data-settings';
3
4
  import Divider from '../../widgets/divider';
4
5
  import GroupBy from '../../widgets/group-by';
5
- import Switch from '../../widgets/switch';
6
6
  import intl from '../../../intl';
7
7
  import { onGroupbyColumnChange, onIncludeEmptyChange, onColumnGroupByColumnChange, onGroupbyDateGranularityChange, onGroupbyGeolocationGranularityChange } from '../callbacks/callbacks';
8
8
  import { CHART_TYPE } from '../../../constants';
@@ -36,9 +36,8 @@ export default function CompletenessDataSettings(_ref) {
36
36
  label: intl.get('Name_field'),
37
37
  selectedTableId: table_id,
38
38
  selectedColumnKey: x_axis_column_key,
39
- onGroupByChange: e => onGroupbyColumnChange(e, chart, onChange)
40
- }), /*#__PURE__*/React.createElement(Switch, {
41
- key: "x_axis_include_empty_cells",
39
+ onGroupByChange: column => onGroupbyColumnChange(column, chart, onChange)
40
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
42
41
  checked: x_axis_include_empty_cells,
43
42
  placeholder: intl.get('Include_empty'),
44
43
  onChange: e => onIncludeEmptyChange(e, chart, onChange)
@@ -53,7 +52,7 @@ export default function CompletenessDataSettings(_ref) {
53
52
  label: intl.get('Group_by'),
54
53
  selectedTableId: table_id,
55
54
  selectedColumnKey: column_groupby_column_key,
56
- onGroupByChange: e => onColumnGroupByColumnChange(e, chart, onChange),
55
+ onGroupByChange: column => onColumnGroupByColumnChange(column, chart, onChange),
57
56
  selectedDateGranularity: date_granularity,
58
57
  selectedGeolocationGranularity: geolocation_granularity,
59
58
  onGroupbyDateGranularityChange: e => onGroupbyDateGranularityChange(e, chart, onChange),
@@ -1,6 +1,6 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React from 'react';
2
3
  import { FormGroup, Label } from 'reactstrap';
3
- import Switch from '../widgets/switch';
4
4
  import intl from '../../intl';
5
5
  import { FontSizeSettings } from '../widgets/font-settings';
6
6
  import { PixelEditor } from '../../components';
@@ -44,8 +44,7 @@ export function CompletenessStyleSettings(_ref) {
44
44
  }
45
45
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
46
46
  className: "sea-chart-parameter-item"
47
- }, /*#__PURE__*/React.createElement(Switch, {
48
- key: 'show-percentage',
47
+ }, /*#__PURE__*/React.createElement(_DTableSwitch, {
49
48
  checked: show_percentage,
50
49
  placeholder: intl.get('Show_percentage'),
51
50
  onChange: handleShowPercentageChange
@@ -58,8 +57,7 @@ export function CompletenessStyleSettings(_ref) {
58
57
  modifyFontSize: value => onChange({
59
58
  label_font_size: value
60
59
  })
61
- }), /*#__PURE__*/React.createElement(Switch, {
62
- key: 'set-range-automatic',
60
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
63
61
  checked: y_axis_auto_range,
64
62
  placeholder: intl.get('Auto_range'),
65
63
  onChange: handleSetRangeChange
@@ -13,14 +13,13 @@ const DataSettings = _ref => {
13
13
  tables,
14
14
  onChange
15
15
  } = _ref;
16
- const onXAxisColumnChange = useCallback(option => {
16
+ const onXAxisColumnChange = useCallback(column => {
17
17
  const {
18
18
  config
19
19
  } = chart;
20
20
  const {
21
21
  time_column_key
22
22
  } = config;
23
- const column = option.value;
24
23
  const {
25
24
  key: newXAxisColumnKey
26
25
  } = column;
@@ -1,18 +1,21 @@
1
1
  import React, { useCallback, useMemo, useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import classnames from 'classnames';
4
+ import intl from '../intl';
5
+ import { settingsContext } from '../utils/contexts';
3
6
  import { eventStopPropagation } from '../utils';
4
7
  import { BaseUtils } from '../utils';
5
- import intl from '../intl';
6
8
  import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
7
- import StyleSettings from './style-settings';
8
- import DataSettings from './data-settings';
9
9
  import Divider from './widgets/divider';
10
+ import DataSettings from './data-settings';
11
+ import StyleSettings from './style-settings';
10
12
  import './index.css';
11
13
  const Settings = _ref => {
12
14
  let {
13
15
  chart,
14
16
  dataSources,
15
17
  title,
18
+ hideTitleStyleSetting,
16
19
  tables,
17
20
  onChange,
18
21
  children
@@ -57,7 +60,11 @@ const Settings = _ref => {
57
60
  const validTitle = useMemo(() => {
58
61
  return title || {};
59
62
  }, [title]);
60
- return /*#__PURE__*/React.createElement("div", {
63
+ return /*#__PURE__*/React.createElement(settingsContext.Provider, {
64
+ value: {
65
+ hideTitleStyleSetting
66
+ }
67
+ }, /*#__PURE__*/React.createElement("div", {
61
68
  className: "sea-chart-settings"
62
69
  }, /*#__PURE__*/React.createElement("div", {
63
70
  className: "sea-chart-settings-type",
@@ -85,10 +92,20 @@ const Settings = _ref => {
85
92
  chart: chart,
86
93
  labelColorConfigs: labelColorConfigs,
87
94
  onChange: modifyStyle
88
- }), children && type === CHART_SETTINGS_TYPE.GENERAL_STYLE && /*#__PURE__*/React.createElement(React.Fragment, null, children))));
95
+ }), children && type === CHART_SETTINGS_TYPE.GENERAL_STYLE && /*#__PURE__*/React.createElement(React.Fragment, null, children)))));
89
96
  };
90
- Settings.defaultProps = {
97
+ const settingsDefaultProps = {
91
98
  dataSources: 'filter'
92
99
  };
100
+ const settingsPropTypes = {
101
+ chart: PropTypes.object.isRequired,
102
+ tables: PropTypes.array.isRequired,
103
+ dataSources: PropTypes.string,
104
+ title: PropTypes.object,
105
+ hideTitleStyleSetting: PropTypes.bool,
106
+ children: PropTypes.any,
107
+ onChange: PropTypes.func.isRequired
108
+ };
109
+ Settings.defaultProps = settingsDefaultProps;
93
110
  export default Settings;
94
- export { StyleSettings, Divider };
111
+ export { StyleSettings, Divider, settingsDefaultProps, settingsPropTypes };
@@ -1,10 +1,10 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { useCallback } from 'react';
2
3
  import { CellType } from 'dtable-utils';
3
4
  import intl from '../../intl';
4
5
  import CommonDataSettings from '../widgets/common-data-settings';
5
6
  import Divider from '../widgets/divider';
6
7
  import GroupBy from '../widgets/group-by';
7
- import Switch from '../widgets/switch';
8
8
  import BasicSummary from '../widgets/basic-summary';
9
9
  import { CHART_SUMMARY_TYPES } from '../../constants';
10
10
  const DataSettings = _ref => {
@@ -14,14 +14,13 @@ const DataSettings = _ref => {
14
14
  tables,
15
15
  onChange
16
16
  } = _ref;
17
- const onXAxisColumnChange = useCallback(option => {
17
+ const onXAxisColumnChange = useCallback(column => {
18
18
  const {
19
19
  config
20
20
  } = chart;
21
21
  const {
22
22
  column_key
23
23
  } = config;
24
- const column = option.value;
25
24
  const {
26
25
  key: newXAxisColumnKey
27
26
  } = column;
@@ -32,14 +31,13 @@ const DataSettings = _ref => {
32
31
  };
33
32
  onChange && onChange(update);
34
33
  }, [chart, onChange]);
35
- const onYAxisColumnChange = useCallback(option => {
34
+ const onYAxisColumnChange = useCallback(column => {
36
35
  const {
37
36
  config
38
37
  } = chart;
39
38
  const {
40
39
  group_column_key
41
40
  } = config;
42
- const column = option.value;
43
41
  const {
44
42
  key: newXAxisColumnKey
45
43
  } = column;
@@ -84,8 +82,7 @@ const DataSettings = _ref => {
84
82
  selectedColumnKey: column_key,
85
83
  isMirror: true,
86
84
  onGroupByChange: onXAxisColumnChange
87
- }), /*#__PURE__*/React.createElement(Switch, {
88
- key: "x_axis_include_empty_cells",
85
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
89
86
  checked: is_transpose,
90
87
  placeholder: intl.get('Transpose'),
91
88
  onChange: onTranspose
@@ -1,12 +1,11 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { useCallback } from 'react';
2
3
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
4
  import CommonDataSettings from '../widgets/common-data-settings';
4
5
  import Divider from '../widgets/divider';
5
6
  import GroupBy from '../widgets/group-by';
6
- import Switch from '../widgets/switch';
7
7
  import BasicSummary from '../widgets/basic-summary';
8
8
  import DataSort from '../widgets/data-sort';
9
- import { eventStopPropagation } from '../../utils';
10
9
  import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
11
10
  import intl from '../../intl';
12
11
  const DataSettings = _ref => {
@@ -16,14 +15,13 @@ const DataSettings = _ref => {
16
15
  tables,
17
16
  onChange
18
17
  } = _ref;
19
- const onGroupByChange = useCallback(option => {
18
+ const onGroupByChange = useCallback(column => {
20
19
  const {
21
20
  config
22
21
  } = chart;
23
22
  const {
24
23
  groupby_column_key
25
24
  } = config;
26
- const column = option.value;
27
25
  const {
28
26
  key: newColumnKey,
29
27
  type
@@ -85,7 +83,6 @@ const DataSettings = _ref => {
85
83
  });
86
84
  }, [chart, onChange]);
87
85
  const onIncludeEmptyChange = useCallback(event => {
88
- eventStopPropagation(event);
89
86
  const {
90
87
  config
91
88
  } = chart;
@@ -122,8 +119,7 @@ const DataSettings = _ref => {
122
119
  onGroupByChange: onGroupByChange,
123
120
  onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
124
121
  onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
125
- }), /*#__PURE__*/React.createElement(Switch, {
126
- key: "groupby_include_empty_cells",
122
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
127
123
  checked: groupby_include_empty_cells,
128
124
  placeholder: intl.get('Include_empty'),
129
125
  onChange: onIncludeEmptyChange
@@ -3,7 +3,6 @@ import _DTableSelect from "dtable-ui-component/lib/DTableSelect";
3
3
  import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
4
4
  import React, { useCallback, useMemo } from 'react';
5
5
  import { Label, FormGroup } from 'reactstrap';
6
- import Switch from '../widgets/switch';
7
6
  import Divider from '../widgets/divider';
8
7
  import MiniNumSlicePercent from '../widgets/mininum-slice-percent';
9
8
  import { FontSizeSettings } from '../widgets/font-settings';
@@ -105,8 +104,7 @@ const StyleSettings = _ref => {
105
104
  const selectedLabelFormat = labelFormatOptions.find(item => item.value === label_format) || labelFormatOptions[0];
106
105
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
107
106
  className: "sea-chart-parameter-item"
108
- }, /*#__PURE__*/React.createElement(Switch, {
109
- key: "show_legend",
107
+ }, /*#__PURE__*/React.createElement(_DTableSwitch, {
110
108
  checked: show_legend || false,
111
109
  placeholder: intl.get('Display_legend'),
112
110
  onChange: onDisplayLegendChange
@@ -1,11 +1,10 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React from 'react';
2
3
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
4
  import CommonDataSettings from '../widgets/common-data-settings';
4
5
  import Divider from '../widgets/divider';
5
6
  import GroupBy from '../widgets/group-by';
6
- import Switch from '../widgets/switch';
7
7
  import intl from '../../intl';
8
- import { eventStopPropagation } from '../../utils';
9
8
  import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
10
9
  export default function ScatterDataSettings(_ref) {
11
10
  let {
@@ -25,12 +24,11 @@ export default function ScatterDataSettings(_ref) {
25
24
  date_granularity,
26
25
  geolocation_granularity
27
26
  } = config;
28
- const getNewUpdate = (option, fieldKey) => {
27
+ const getNewUpdate = (column, fieldKey) => {
29
28
  const {
30
29
  config
31
30
  } = chart;
32
31
  const fieldValue = config[fieldKey];
33
- const column = option.value;
34
32
  const {
35
33
  key
36
34
  } = column;
@@ -41,23 +39,22 @@ export default function ScatterDataSettings(_ref) {
41
39
  return update;
42
40
  };
43
41
  const onXAxisColumnChange = e => {
44
- const update = getNewUpdate(e, 'x_axis_column_key');
42
+ const update = getNewUpdate(column, 'x_axis_column_key');
45
43
  if (!update) return;
46
44
  onChange && onChange(update);
47
45
  };
48
46
  const onYAxisColumnChange = e => {
49
- const update = getNewUpdate(e, 'y_axis_column_key');
47
+ const update = getNewUpdate(column, 'y_axis_column_key');
50
48
  if (!update) return;
51
49
  onChange && onChange(update);
52
50
  };
53
51
  const onIncludeEmptyChange = e => {
54
- eventStopPropagation(e);
55
52
  onChange && onChange({
56
53
  x_axis_include_empty_cells: !x_axis_include_empty_cells
57
54
  });
58
55
  };
59
56
  const onColumnGroupbyColumnChange = e => {
60
- const update = getNewUpdate(e, 'column_groupby_column_key');
57
+ const update = getNewUpdate(column, 'column_groupby_column_key');
61
58
  if (!update) return;
62
59
  if (!update['column_groupby_column_key']) {
63
60
  update['date_granularity'] = null;
@@ -119,8 +116,7 @@ export default function ScatterDataSettings(_ref) {
119
116
  selectedTableId: table_id,
120
117
  selectedColumnKey: x_axis_column_key,
121
118
  onGroupByChange: onXAxisColumnChange
122
- }), /*#__PURE__*/React.createElement(Switch, {
123
- key: "x_axis_include_empty_cells",
119
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
124
120
  checked: x_axis_include_empty_cells,
125
121
  placeholder: intl.get('Include_empty'),
126
122
  onChange: onIncludeEmptyChange
@@ -1,15 +1,14 @@
1
- import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
2
1
  import _DTableSelect from "dtable-ui-component/lib/DTableSelect";
2
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
3
3
  import React, { useCallback, useMemo } from 'react';
4
4
  import { FormGroup, Label } from 'reactstrap';
5
- import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById, getTableColumnByKey } from 'dtable-utils';
5
+ import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById } from 'dtable-utils';
6
6
  import CommonDataSettings from '../widgets/common-data-settings';
7
7
  import Divider from '../widgets/divider';
8
8
  import GroupBy from '../widgets/group-by';
9
- import Switch from '../widgets/switch';
10
9
  import BasicSummary from '../widgets/basic-summary';
11
10
  import NumericSummaryItem from '../widgets/numeric-summary-item';
12
- import { eventStopPropagation, BaseUtils } from '../../utils';
11
+ import { BaseUtils } from '../../utils';
13
12
  import { CHART_SUMMARY_TYPE, CHART_Y_GROUP_TYPE, CHART_SUMMARY_SHOW, CHART_SUMMARY_CALCULATION_METHOD, CHART_DATE_SUMMARY_CALCULATION_METHOD, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
14
13
  import intl from '../../intl';
15
14
  const DataSettings = _ref => {
@@ -71,14 +70,13 @@ const DataSettings = _ref => {
71
70
  }];
72
71
  return options;
73
72
  }, []);
74
- const onGroupByColumnChange = useCallback(option => {
73
+ const onGroupByColumnChange = useCallback(column => {
75
74
  const {
76
75
  config
77
76
  } = chart;
78
77
  const {
79
78
  groupby_column_key
80
79
  } = config;
81
- const column = option.value;
82
80
  const {
83
81
  key: newColumnKey,
84
82
  type
@@ -139,14 +137,13 @@ const DataSettings = _ref => {
139
137
  groupby_geolocation_granularity: value
140
138
  });
141
139
  }, [chart, onChange]);
142
- const onColumnGroupByColumnChange = useCallback(option => {
140
+ const onColumnGroupByColumnChange = useCallback(column => {
143
141
  const {
144
142
  config
145
143
  } = chart;
146
144
  const {
147
145
  column_groupby_column_key
148
146
  } = config;
149
- const column = option.value;
150
147
  const {
151
148
  key: newColumnKey,
152
149
  type
@@ -209,7 +206,6 @@ const DataSettings = _ref => {
209
206
  });
210
207
  }, [chart, onChange]);
211
208
  const onIncludeEmptyChange = useCallback(event => {
212
- eventStopPropagation(event);
213
209
  const {
214
210
  config
215
211
  } = chart;
@@ -520,8 +516,7 @@ const DataSettings = _ref => {
520
516
  onGroupByChange: onGroupByColumnChange,
521
517
  onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
522
518
  onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
523
- }), /*#__PURE__*/React.createElement(Switch, {
524
- key: "groupby_include_empty_cells",
519
+ }), /*#__PURE__*/React.createElement(_DTableSwitch, {
525
520
  checked: groupby_include_empty_cells,
526
521
  placeholder: intl.get('Include_empty'),
527
522
  onChange: onIncludeEmptyChange
@@ -1,10 +1,10 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { useCallback } from 'react';
2
3
  import { FormGroup, Label } from 'reactstrap';
3
4
  import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
4
5
  import CommonDataSettings from '../widgets/common-data-settings';
5
6
  import Divider from '../widgets/divider';
6
7
  import GroupBy from '../widgets/group-by';
7
- import Switch from '../widgets/switch';
8
8
  import BasicSummary from '../widgets/basic-summary';
9
9
  import TimePicker from '../widgets/time-picker';
10
10
  import { eventStopPropagation } from '../../utils';
@@ -18,14 +18,13 @@ const DataSettings = _ref => {
18
18
  tables,
19
19
  onChange
20
20
  } = _ref;
21
- const onXAxisColumnChange = useCallback(option => {
21
+ const onXAxisColumnChange = useCallback(column => {
22
22
  const {
23
23
  config
24
24
  } = chart;
25
25
  const {
26
26
  x_axis_column_key
27
27
  } = config;
28
- const column = option.value;
29
28
  const {
30
29
  key: newXAxisColumnKey,
31
30
  type
@@ -167,7 +166,7 @@ const DataSettings = _ref => {
167
166
  selectedTableId: table_id,
168
167
  tables: tables,
169
168
  onChange: onChange
170
- }), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(Switch, {
169
+ }), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(_DTableSwitch, {
171
170
  checked: display_increase || false,
172
171
  placeholder: intl.get('Display_increase'),
173
172
  onChange: onDisplayIncreaseChange
@@ -35,14 +35,13 @@ const DataSettings = _ref => {
35
35
  };
36
36
  });
37
37
  }, []);
38
- const onXAxisColumnChange = useCallback(option => {
38
+ const onXAxisColumnChange = useCallback(column => {
39
39
  const {
40
40
  config
41
41
  } = chart;
42
42
  const {
43
43
  date_column_key
44
44
  } = config;
45
- const column = option.value;
46
45
  const {
47
46
  key: newXAxisColumnKey
48
47
  } = column;
@@ -3,8 +3,6 @@ import React, { useCallback } from 'react';
3
3
  import { FormGroup } from 'reactstrap';
4
4
  import { FontSizeSettings } from '../font-settings';
5
5
  import intl from '../../../intl';
6
- import { eventStopPropagation } from '../../../utils';
7
- import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW } from '../../../constants';
8
6
  import './index.css';
9
7
  const DisplayValuesSettings = _ref => {
10
8
  let {
@@ -1,4 +1,5 @@
1
1
  import _DTableSelect from "dtable-ui-component/lib/DTableSelect";
2
+ import _DTableCustomizeSelect from "dtable-ui-component/lib/DTableCustomizeSelect";
2
3
  import React, { Component } from 'react';
3
4
  import classnames from 'classnames';
4
5
  import { Label, FormGroup } from 'reactstrap';
@@ -89,11 +90,11 @@ class GroupBy extends Component {
89
90
  return {
90
91
  value: column,
91
92
  label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
92
- className: "sea-chart-column-icon"
93
+ className: "header-icon"
93
94
  }, /*#__PURE__*/React.createElement("i", {
94
95
  className: COLUMNS_ICON_CONFIG[column.type]
95
96
  })), /*#__PURE__*/React.createElement("span", {
96
- className: 'select-module select-module-name ml-0'
97
+ className: 'select-option-name'
97
98
  }, column.name))
98
99
  };
99
100
  });
@@ -124,16 +125,15 @@ class GroupBy extends Component {
124
125
  const options = this.columnOptions.find(option => option.value.key === selectedColumnKey);
125
126
  selectedOption = options ? options : null;
126
127
  }
127
- return /*#__PURE__*/React.createElement(_DTableSelect, {
128
- menuPortalTarget: "#sea-chart-settings-content",
128
+ return /*#__PURE__*/React.createElement(_DTableCustomizeSelect, {
129
+ isLocked: false,
129
130
  value: selectedOption,
130
- classNamePrefix: "select-column",
131
131
  options: this.columnOptions,
132
- onChange: this.props.onGroupByChange,
133
- placeholder: intl.get('Select_field'),
134
- noOptionsMessage: () => {
135
- return /*#__PURE__*/React.createElement("span", null, intl.get('No_column'));
136
- }
132
+ onSelectOption: this.props.onGroupByChange,
133
+ isInModal: true,
134
+ searchable: true,
135
+ searchPlaceholder: intl.get('Select_field'),
136
+ noOptionsPlaceholder: intl.get('No_column')
137
137
  });
138
138
  };
139
139
  this.renderGroupbyDateGranulates = () => {
@@ -1,7 +1,7 @@
1
+ import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
1
2
  import React, { Component } from 'react';
2
3
  import { Label, FormGroup } from 'reactstrap';
3
4
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
4
- import Switch from './switch';
5
5
  import { eventStopPropagation } from '../../utils';
6
6
  import intl from '../../intl';
7
7
  class Stack extends Component {
@@ -40,7 +40,7 @@ class Stack extends Component {
40
40
  if (!columnGroupbyColumn) return null;
41
41
  return /*#__PURE__*/React.createElement(FormGroup, {
42
42
  className: "sea-chart-parameter-item"
43
- }, /*#__PURE__*/React.createElement(Label, null, intl.get('Display_mode')), /*#__PURE__*/React.createElement(Switch, {
43
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Display_mode')), /*#__PURE__*/React.createElement(_DTableSwitch, {
44
44
  checked: y_axis_use_stack || false,
45
45
  placeholder: intl.get('Stack'),
46
46
  onChange: this.onUseStackChange
@@ -1,11 +1,15 @@
1
1
  import _CollapsibleSettingLayout from "dtable-ui-component/lib/CollapsibleSettingLayout";
2
- import React, { useMemo } from 'react';
2
+ import React, { useMemo, useContext } from 'react';
3
+ import { settingsContext } from '../../../utils/contexts';
3
4
  import { FontSizeSettings, FontWeightSettings, FontColorSettings } from '../font-settings';
4
5
  import TextHorizontalSettings from '../text-horizontal-settings';
5
6
  import { DEFAULT_CHART_FONT_WEIGHT, DEFAULT_CHART_TITLE_FONT_SIZE, CHART_SUPPORT_FONT_WEIGHTS, HORIZONTAL_ALIGN, DEFAULT_CHART_TITLE_FONT_COLOR, DAFAULT_TREND_CHART_TITLE_FONT_SIZE, CHART_TYPE } from '../../../constants';
6
7
  import intl from '../../../intl';
7
8
  import TitleText from './title-text';
8
9
  const TitleSetting = props => {
10
+ const {
11
+ hideTitleStyleSetting
12
+ } = useContext(settingsContext);
9
13
  const initialTitle = useMemo(() => {
10
14
  return props.title || {};
11
15
  }, [props.title]);
@@ -58,7 +62,7 @@ const TitleSetting = props => {
58
62
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TitleText, {
59
63
  text: initialTitle.text,
60
64
  modifyText: modifyText
61
- }), /*#__PURE__*/React.createElement(FontSizeSettings, {
65
+ }), !hideTitleStyleSetting && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FontSizeSettings, {
62
66
  className: 'mt-3',
63
67
  fontSize: initialTitle.font_size,
64
68
  defaultFontSize: isCard ? DAFAULT_TREND_CHART_TITLE_FONT_SIZE : DEFAULT_CHART_TITLE_FONT_SIZE,
@@ -78,7 +82,7 @@ const TitleSetting = props => {
78
82
  value: initialTitle.horizontal_align,
79
83
  defaultValue: HORIZONTAL_ALIGN.LEFT,
80
84
  onChange: modifyHorizontalAlign
81
- }));
85
+ })));
82
86
  };
83
87
  return /*#__PURE__*/React.createElement(_CollapsibleSettingLayout, {
84
88
  title: intl.get('Title'),
@@ -278,8 +278,7 @@ class YAxisGroupSettings extends Component {
278
278
  summary_columns: [...summary_columns]
279
279
  });
280
280
  };
281
- this.onGroupByChange = option => {
282
- const column = option.value;
281
+ this.onGroupByChange = column => {
283
282
  const {
284
283
  chart
285
284
  } = this.props;
@@ -175,7 +175,7 @@ async function calculator(chart, value, _ref) {
175
175
  if (currentValue < targetValue) {
176
176
  result.unshift({
177
177
  name: label,
178
- group_label: groupLabel,
178
+ groupby: groupLabel,
179
179
  value: currentValue,
180
180
  color,
181
181
  type: 'completed',
@@ -184,7 +184,7 @@ async function calculator(chart, value, _ref) {
184
184
  rows
185
185
  }, {
186
186
  name: label,
187
- group_label: groupLabel,
187
+ groupby: groupLabel,
188
188
  value: targetValue - currentValue,
189
189
  color,
190
190
  type: 'uncompleted',
@@ -195,7 +195,7 @@ async function calculator(chart, value, _ref) {
195
195
  } else {
196
196
  result.unshift({
197
197
  name: label,
198
- group_label: groupLabel,
198
+ groupby: groupLabel,
199
199
  value: currentValue,
200
200
  color,
201
201
  type: 'completed',
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export const settingsContext = React.createContext('');
@@ -218,24 +218,29 @@ class View extends React.PureComponent {
218
218
  }
219
219
  }
220
220
  const propTypes = {
221
+ // style
222
+ className: PropTypes.string,
221
223
  canvasStyle: PropTypes.object,
224
+ globalTheme: PropTypes.string,
225
+ // light or dark
226
+ chartColorTheme: PropTypes.string,
227
+ hideTitle: PropTypes.bool,
228
+ render: PropTypes.func,
229
+ // User-defined rendering content
230
+
231
+ // data
222
232
  chart: PropTypes.object.isRequired,
233
+ tables: PropTypes.array.isRequired,
223
234
  api: PropTypes.object.isRequired,
235
+ config: PropTypes.object,
236
+ collaboratorManager: PropTypes.object,
224
237
  collaborators: PropTypes.array,
225
238
  departments: PropTypes.array,
226
239
  dtableStoreValue: PropTypes.object,
227
- tables: PropTypes.array.isRequired,
228
- className: PropTypes.string,
229
- collaboratorManager: PropTypes.object,
230
- hideTitle: PropTypes.bool,
231
- globalTheme: PropTypes.string,
232
- // light or dark
233
- chartColorTheme: PropTypes.string,
240
+ isCalculateByView: PropTypes.bool,
241
+ // event
234
242
  integratedEventTypes: PropTypes.object,
235
243
  integratedEventBus: PropTypes.object,
236
- isCalculateByView: PropTypes.bool,
237
- render: PropTypes.func,
238
- // User-defined rendering content
239
244
  onViewRef: PropTypes.func
240
245
  };
241
246
  const defaultProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",